ultimate3.c

Go to the documentation of this file.
00001 /* Ultimate IRCD 3 functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 
00014 #include "services.h"
00015 #include "pseudo.h"
00016 #include "ultimate3.h"
00017 
00018 IRCDVar myIrcd[] = {
00019     {"UltimateIRCd 3.0.*",      /* ircd name */
00020      "+S",                      /* nickserv mode */
00021      "+S",                      /* chanserv mode */
00022      "+S",                      /* memoserv mode */
00023      "+o",                      /* hostserv mode */
00024      "+iS",                     /* operserv mode */
00025      "+S",                      /* botserv mode  */
00026      "+Sh",                     /* helpserv mode */
00027      "+iS",                     /* Dev/Null mode */
00028      "+iS",                     /* Global mode   */
00029      "+o",                      /* nickserv alias mode */
00030      "+o",                      /* chanserv alias mode */
00031      "+o",                      /* memoserv alias mode */
00032      "+io",                     /* hostserv alias mode */
00033      "+io",                     /* operserv alias mode */
00034      "+o",                      /* botserv alias mode  */
00035      "+h",                      /* helpserv alias mode */
00036      "+i",                      /* Dev/Null alias mode */
00037      "+io",                     /* Global alias mode   */
00038      "+S",                      /* Used by BotServ Bots */
00039      5,                         /* Chan Max Symbols     */
00040      "-ilmnpqstRKAO",           /* Modes to Remove */
00041      "+o",                      /* Channel Umode used by Botserv bots */
00042      1,                         /* SVSNICK */
00043      1,                         /* Vhost  */
00044      0,                         /* Has Owner */
00045      NULL,                      /* Mode to set for an owner */
00046      NULL,                      /* Mode to unset for an owner */
00047      "+a",                      /* Mode to set for channel admin */
00048      "-a",                      /* Mode to unset for channel admin */
00049      "+rd",                     /* Mode On Reg          */
00050      NULL,                      /* Mode on ID for Roots */
00051      NULL,                      /* Mode on ID for Admins */
00052      NULL,                      /* Mode on ID for Opers */
00053      "-r+d",                    /* Mode on UnReg        */
00054      "+d",                      /* Mode on Nick Change  */
00055      1,                         /* Supports SGlines     */
00056      1,                         /* Supports SQlines     */
00057      1,                         /* Supports SZlines     */
00058      1,                         /* Supports Halfop +h   */
00059      3,                         /* Number of server args */
00060      0,                         /* Join 2 Set           */
00061      0,                         /* Join 2 Message       */
00062      1,                         /* Has exceptions +e    */
00063      0,                         /* TS Topic Forward     */
00064      0,                         /* TS Topci Backward    */
00065      UMODE_p,                   /* Protected Umode      */
00066      1,                         /* Has Admin            */
00067      1,                         /* Chan SQlines         */
00068      0,                         /* Quit on Kill         */
00069      1,                         /* SVSMODE unban        */
00070      0,                         /* Has Protect          */
00071      0,                         /* Reverse              */
00072      1,                         /* Chan Reg             */
00073      CMODE_r,                   /* Channel Mode         */
00074      0,                         /* vidents              */
00075      0,                         /* svshold              */
00076      1,                         /* time stamp on mode   */
00077      1,                         /* NICKIP               */
00078      0,                         /* O:LINE               */
00079      1,                         /* UMODE               */
00080      1,                         /* VHOST ON NICK        */
00081      0,                         /* Change RealName      */
00082      CMODE_K,                   /* No Knock             */
00083      CMODE_A,                   /* Admin Only           */
00084      DEFAULT_MLOCK,             /* Default MLOCK       */
00085      UMODE_x,                   /* Vhost Mode           */
00086      0,                         /* +f                   */
00087      0,                         /* +L                   */
00088      0,                         /* +f Mode                          */
00089      0,                         /* +L Mode                              */
00090      1,                         /* On nick change check if they could be identified */
00091      1,                         /* No Knock requires +i */
00092      NULL,                      /* CAPAB Chan Modes             */
00093      0,                         /* We support TOKENS */
00094      1,                         /* TOKENS are CASE inSensitive */
00095      0,                         /* TIME STAMPS are BASE64 */
00096      0,                         /* +I support */
00097      0,                         /* SJOIN ban char */
00098      0,                         /* SJOIN except char */
00099      0,                         /* SJOIN invite char */
00100      0,                         /* Can remove User Channel Modes with SVSMODE */
00101      1,                         /* Sglines are enforced */
00102      "x",                       /* vhost char */
00103      0,                         /* ts6 */
00104      1,                         /* support helper umode */
00105      0,                         /* p10 */
00106      NULL,                      /* character set */
00107      1,                         /* reports sync state */
00108      }
00109     ,
00110     {NULL}
00111 };
00112 
00113 IRCDCAPAB myIrcdcap[] = {
00114     {
00115      CAPAB_NOQUIT,              /* NOQUIT       */
00116      CAPAB_TSMODE,              /* TSMODE       */
00117      CAPAB_UNCONNECT,           /* UNCONNECT    */
00118      0,                         /* NICKIP       */
00119      CAPAB_NSJOIN,              /* SJOIN        */
00120      CAPAB_ZIP,                 /* ZIP          */
00121      CAPAB_BURST,               /* BURST        */
00122      CAPAB_TS5,                 /* TS5          */
00123      0,                         /* TS3          */
00124      CAPAB_DKEY,                /* DKEY         */
00125      0,                         /* PT4          */
00126      0,                         /* SCS          */
00127      0,                         /* QS           */
00128      0,                         /* UID          */
00129      0,                         /* KNOCK        */
00130      CAPAB_CLIENT,              /* CLIENT       */
00131      CAPAB_IPV6,                /* IPV6         */
00132      CAPAB_SSJ5,                /* SSJ5         */
00133      0,                         /* SN2          */
00134      0,                         /* TOKEN        */
00135      0,                         /* VHOST        */
00136      0,                         /* SSJ3         */
00137      0,                         /* NICK2        */
00138      0,                         /* UMODE2       */
00139      0,                         /* VL           */
00140      0,                         /* TLKEXT       */
00141      CAPAB_DODKEY,              /* DODKEY       */
00142      CAPAB_DOZIP,               /* DOZIP        */
00143      0, 0, 0}
00144 };
00145 
00146 void ultimate3_set_umode(User * user, int ac, char **av)
00147 {
00148     int add = 1;                /* 1 if adding modes, 0 if deleting */
00149     char *modes = av[0];
00150 
00151     ac--;
00152 
00153     if (debug)
00154         alog("debug: Changing mode for %s to %s", user->nick, modes);
00155 
00156     while (*modes) {
00157 
00158         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00159          * At least this is readable without paying much attention :) -GD
00160          */
00161         if (add)
00162             user->mode |= umodes[(int) *modes];
00163         else
00164             user->mode &= ~umodes[(int) *modes];
00165 
00166         switch (*modes++) {
00167         case '+':
00168             add = 1;
00169             break;
00170         case '-':
00171             add = 0;
00172             break;
00173         case 'a':
00174             if (add && !is_services_oper(user)) {
00175                 common_svsmode(user, "-a", NULL);
00176                 user->mode &= ~UMODE_a;
00177             }
00178             break;
00179         case 'P':
00180             if (add && !is_services_admin(user)) {
00181                 common_svsmode(user, "-P", NULL);
00182                 user->mode &= ~UMODE_P;
00183             }
00184             break;
00185         case 'Z':
00186             if (add && !is_services_root(user)) {
00187                 common_svsmode(user, "-Z", NULL);
00188                 user->mode &= ~UMODE_Z;
00189             }
00190             break;
00191         case 'd':
00192             if (ac == 0) {
00193                 alog("user: umode +d with no parameter (?) for user %s",
00194                      user->nick);
00195                 break;
00196             }
00197 
00198             ac--;
00199             av++;
00200             user->svid = strtoul(*av, NULL, 0);
00201             break;
00202         case 'o':
00203             if (add) {
00204                 opcnt++;
00205                 if (WallOper) {
00206                     anope_cmd_global(s_OperServ,
00207                                      "\2%s\2 is now an IRC operator.",
00208                                      user->nick);
00209                 }
00210                 display_news(user, NEWS_OPER);
00211                 if (is_services_oper(user)) {
00212                     common_svsmode(user, "+a", NULL);
00213                     user->mode |= UMODE_a;
00214                 }
00215                 if (is_services_admin(user)) {
00216                     common_svsmode(user, "+P", NULL);
00217                     user->mode |= UMODE_P;
00218                 }
00219                 if (is_services_root(user)) {
00220                     common_svsmode(user, "+Z", NULL);
00221                     user->mode |= UMODE_Z;
00222                 }
00223             } else {
00224                 opcnt--;
00225             }
00226             break;
00227         case 'r':
00228             if (add && !nick_identified(user)) {
00229                 common_svsmode(user, "-r", NULL);
00230                 user->mode &= ~UMODE_r;
00231             }
00232             break;
00233         case 'x':
00234             update_host(user);
00235             break;
00236         }
00237     }
00238 }
00239 
00240 unsigned long umodes[128] = {
00241     0, 0, 0,                    /* Unused */
00242     0, 0, 0,                    /* Unused */
00243     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00244     0, 0, 0,                    /* Line Feed, Unused, Unused */
00245     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00246     0, 0, 0,                    /* Unused */
00247     0, 0, 0,                    /* Unused */
00248     0, 0, 0,                    /* Unused */
00249     0, 0, 0,                    /* Unused */
00250     0, 0, 0,                    /* Unused */
00251     0, 0, 0,                    /* Unused, Unused, Space */
00252     0, 0, 0,                    /* ! " #  */
00253     0, 0, 0,                    /* $ % &  */
00254     0, 0, 0,                    /* ! ( )  */
00255     0, 0, 0,                    /* * + ,  */
00256     0, 0, 0,                    /* - . /  */
00257     0, 0,                       /* 0 1 */
00258     0, 0,                       /* 2 3 */
00259     0, 0,                       /* 4 5 */
00260     0, 0,                       /* 6 7 */
00261     0, 0,                       /* 8 9 */
00262     0, 0,                       /* : ; */
00263     0, 0, 0,                    /* < = > */
00264     0, 0,                       /* ? @ */
00265     UMODE_A, 0, 0,              /* A B C */
00266     UMODE_D, 0, 0,              /* D E F */
00267     0, 0, 0,                    /* G H I */
00268     0, 0, 0,                    /* J K L */
00269     0, 0, UMODE_0,              /* M N O */
00270     UMODE_P, 0, UMODE_R,        /* P Q R */
00271     UMODE_S, 0, 0,              /* S T U */
00272     0, UMODE_W, 0,              /* V W X */
00273     0,                          /* Y */
00274     UMODE_Z,                    /* Z */
00275     0, 0, 0,                    /* [ \ ] */
00276     0, 0, 0,                    /* ^ _ ` */
00277     UMODE_a, 0, 0,              /* a b c */
00278     UMODE_d, 0, 0,              /* d e f */
00279     0, UMODE_h, UMODE_i,        /* g h i */
00280     0, 0, 0,                    /* j k l */
00281     0, 0, UMODE_o,              /* m n o */
00282     UMODE_p, 0, UMODE_r,        /* p q r */
00283     0, 0, 0,                    /* s t u */
00284     0, UMODE_w, UMODE_x,        /* v w x */
00285     0,                          /* y */
00286     0,                          /* z */
00287     0, 0, 0,                    /* { | } */
00288     0, 0                        /* ~ ‚ */
00289 };
00290 
00291 
00292 char myCsmodes[128] = {
00293     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00294     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00295 
00296     0,
00297     'a',                        /* (33) ! Channel Admins */
00298     0, 0, 0,
00299     'h',                        /* (37) % Channel halfops */
00300     0, 0, 0, 0,
00301     0,
00302 
00303     'v', 0, 0, 0, 0,
00304     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00305 
00306     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00307     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00308 
00309     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00310     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00311 };
00312 
00313 
00314 CMMode myCmmodes[128] = {
00315     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00316     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00317     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00318     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00319     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00320     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00321     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00322     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00323     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00324     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00325     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00326     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00327     {NULL},
00328     {NULL},
00329     {add_ban, del_ban},
00330     {NULL},
00331     {NULL},
00332     {add_exception, del_exception},
00333     {NULL},
00334     {NULL},
00335     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00336     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00337     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00338 };
00339 
00340 
00341 CBMode myCbmodes[128] = {
00342     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00343     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00344     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00345     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00346     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00347     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00348     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00349     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00350     {0},
00351     {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
00352     {0},                        /* B */
00353     {0},                        /* C */
00354     {0},                        /* D */
00355     {0},                        /* E */
00356     {0},                        /* F */
00357     {0},                        /* G */
00358     {0},                        /* H */
00359     {0},                        /* I */
00360     {0},                        /* J */
00361     {CMODE_K, 0, NULL, NULL},   /* K */
00362     {0},                        /* L */
00363     {CMODE_M, 0, NULL, NULL},   /* M */
00364     {CMODE_N, 0, NULL, NULL},   /* N */
00365     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00366     {0},                        /* P */
00367     {0},                        /* Q */
00368     {CMODE_R, 0, NULL, NULL},   /* R */
00369     {CMODE_S, 0, NULL, NULL},   /* S */
00370     {0},                        /* T */
00371     {0},                        /* U */
00372     {0},                        /* V */
00373     {0},                        /* W */
00374     {0},                        /* X */
00375     {0},                        /* Y */
00376     {0},                        /* Z */
00377     {0}, {0}, {0}, {0}, {0}, {0},
00378     {0},                        /* a */
00379     {0},                        /* b */
00380     {CMODE_c, 0, NULL, NULL},   /* c */
00381     {0},                        /* d */
00382     {0},                        /* e */
00383     {0},                        /* f */
00384     {0},                        /* g */
00385     {0},                        /* h */
00386     {CMODE_i, 0, NULL, NULL},   /* i */
00387     {0},                        /* j */
00388     {CMODE_k, 0, chan_set_key, cs_set_key},
00389     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00390     {CMODE_m, 0, NULL, NULL},   /* m */
00391     {CMODE_n, 0, NULL, NULL},   /* n */
00392     {0},                        /* o */
00393     {CMODE_p, 0, NULL, NULL},   /* p */
00394     {CMODE_q, 0, NULL, NULL},   /* q */
00395     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00396     {CMODE_s, 0, NULL, NULL},   /* s */
00397     {CMODE_t, 0, NULL, NULL},   /* t */
00398     {0},                        /* u */
00399     {0},                        /* v */
00400     {0},                        /* w */
00401     {0},                        /* x */
00402     {0},                        /* y */
00403     {0},                        /* z */
00404     {0}, {0}, {0}, {0}
00405 };
00406 
00407 CBModeInfo myCbmodeinfos[] = {
00408     {'c', CMODE_c, 0, NULL, NULL},
00409     {'i', CMODE_i, 0, NULL, NULL},
00410     {'k', CMODE_k, 0, get_key, cs_get_key},
00411     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00412     {'m', CMODE_m, 0, NULL, NULL},
00413     {'n', CMODE_n, 0, NULL, NULL},
00414     {'p', CMODE_p, 0, NULL, NULL},
00415     {'q', CMODE_q, 0, NULL, NULL},
00416     {'r', CMODE_r, 0, NULL, NULL},
00417     {'s', CMODE_s, 0, NULL, NULL},
00418     {'t', CMODE_t, 0, NULL, NULL},
00419     {'A', CMODE_A, 0, NULL, NULL},
00420     {'K', CMODE_K, 0, NULL, NULL},
00421     {'M', CMODE_M, 0, NULL, NULL},
00422     {'N', CMODE_N, 0, NULL, NULL},
00423     {'O', CMODE_O, 0, NULL, NULL},
00424     {'R', CMODE_R, 0, NULL, NULL},
00425     {'S', CMODE_S, 0, NULL, NULL},
00426     {0}
00427 };
00428 
00429 CUMode myCumodes[128] = {
00430     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00431     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00432     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00433     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00434 
00435     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00436     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00437     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00438     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00439 
00440     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00441     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00442     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00443     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00444 
00445     {0},
00446 
00447     {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin},
00448     {0},                        /* b */
00449     {0},                        /* c */
00450     {0},                        /* d */
00451     {0},                        /* e */
00452     {0},                        /* f */
00453     {0},                        /* g */
00454     {CUS_HALFOP, 0, check_valid_op},
00455     {0},                        /* i */
00456     {0},                        /* j */
00457     {0},                        /* k */
00458     {0},                        /* l */
00459     {0},                        /* m */
00460     {0},                        /* n */
00461     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00462     {0},                        /* p */
00463     {0},                        /* q */
00464     {0},                        /* r */
00465     {0},                        /* s */
00466     {0},                        /* t */
00467     {0},                        /* u */
00468     {CUS_VOICE, 0, NULL},
00469     {0},                        /* w */
00470     {0},                        /* x */
00471     {0},                        /* y */
00472     {0},                        /* z */
00473     {0}, {0}, {0}, {0}, {0}
00474 };
00475 
00476 /* SVSMODE -b */
00477 void ultimate3_cmd_unban(char *name, char *nick)
00478 {
00479     ultimate3_cmd_svsmode_chan(name, "-b", nick);
00480 }
00481 
00482 
00483 /* SVSMODE channel modes */
00484 
00485 void ultimate3_cmd_svsmode_chan(char *name, char *mode, char *nick)
00486 {
00487     if (nick) {
00488         send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
00489     } else {
00490         send_cmd(ServerName, "SVSMODE %s %s", name, mode);
00491     }
00492 }
00493 
00494 int anope_event_sjoin(char *source, int ac, char **av)
00495 {
00496     do_sjoin(source, ac, av);
00497     return MOD_CONT;
00498 }
00499 
00500 
00501 /*
00502 ** NICK - new
00503 **      source  = NULL
00504 **  parv[0] = nickname
00505 **      parv[1] = hopcount
00506 **      parv[2] = timestamp
00507 **      parv[3] = modes
00508 **      parv[4] = username
00509 **      parv[5] = hostname
00510 **      parv[6] = server
00511 **  parv[7] = servicestamp
00512 **      parv[8] = IP
00513 **  parv[9] = info
00514 ** NICK - change 
00515 **      source  = oldnick
00516 **  parv[0] = new nickname
00517 **      parv[1] = hopcount
00518 */
00519 int anope_event_nick(char *source, int ac, char **av)
00520 {
00521     if (ac != 2) {
00522         User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
00523                              strtoul(av[2], NULL, 10), strtoul(av[7], NULL,
00524                                                                0),
00525                              strtoul(av[8], NULL, 0), "*", NULL);
00526         if (user)
00527             anope_set_umode(user, 1, &av[3]);
00528     } else {
00529         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00530                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00531     }
00532     return MOD_CONT;
00533 }
00534 
00535 int anope_event_sethost(char *source, int ac, char **av)
00536 {
00537     User *u;
00538 
00539     if (ac != 2)
00540         return MOD_CONT;
00541 
00542     u = finduser(av[0]);
00543     if (!u) {
00544         if (debug) {
00545             alog("debug: SETHOST for nonexistent user %s", av[0]);
00546         }
00547         return MOD_CONT;
00548     }
00549 
00550     change_user_host(u, av[1]);
00551     return MOD_CONT;
00552 }
00553 
00554 int anope_event_capab(char *source, int ac, char **av)
00555 {
00556     capab_parse(ac, av);
00557     return MOD_CONT;
00558 }
00559 
00560 /*
00561 ** CLIENT
00562 **      source  = NULL       
00563 **  parv[0] = nickname   Trystan
00564 **      parv[1] = hopcount   1
00565 **      parv[2] = timestamp  1090083810
00566 **      parv[3] = modes      +ix
00567 **  parv[4] = modes ?    +
00568 **      parv[5] = username   Trystan
00569 **      parv[6] = hostname   c-24-2-101-227.client.comcast.net
00570 **      parv[7] = vhost      3223f75b.2b32ee69.client.comcast.net
00571 **  parv[8] = server     WhiteRose.No.Eu.Shadow-Realm.org
00572 **      parv[9] = svid       0 
00573 **  parv[10] = ip         402810339
00574 **  parv[11] = info      Dreams are answers to questions not yet asked
00575 */
00576 int anope_event_client(char *source, int ac, char **av)
00577 {
00578     if (ac != 2) {
00579         User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11],
00580                              strtoul(av[2], NULL, 10), strtoul(av[9], NULL,
00581                                                                0),
00582                              strtoul(av[10], NULL, 0), av[7], NULL);
00583         if (user) {
00584             anope_set_umode(user, 1, &av[3]);
00585         }
00586     }
00587     return MOD_CONT;
00588 }
00589 
00590 /* *INDENT-OFF* */
00591 void moduleAddIRCDMsgs(void) {
00592     Message *m;
00593 
00594     updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a");
00595 
00596     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00597     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00598     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00599     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00600     m = createMessage("INVITE",    anope_event_invite); addCoreMessage(IRCD,m);
00601     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00602     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00603     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00604     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00605     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00606     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00607     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00608     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00609     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00610     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00611     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00612     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00613     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00614     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00615     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00616     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00617     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00618     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00619     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00620     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00621     m = createMessage("GNOTICE",   anope_event_gnotice); addCoreMessage(IRCD,m);
00622     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00623     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00624     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00625     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00626     m = createMessage("SVSMODE",   anope_event_mode); addCoreMessage(IRCD,m);
00627     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00628     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00629     m = createMessage("SQLINE",    anope_event_sqline); addCoreMessage(IRCD,m);
00630     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00631     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
00632     m = createMessage("CS",        anope_event_cs); addCoreMessage(IRCD,m);
00633     m = createMessage("HS",        anope_event_hs); addCoreMessage(IRCD,m);
00634     m = createMessage("MS",        anope_event_ms); addCoreMessage(IRCD,m);
00635     m = createMessage("NS",        anope_event_ns); addCoreMessage(IRCD,m);
00636     m = createMessage("OS",        anope_event_os); addCoreMessage(IRCD,m);
00637     m = createMessage("RS",        anope_event_null); addCoreMessage(IRCD,m);
00638     m = createMessage("SGLINE",    anope_event_null); addCoreMessage(IRCD,m);
00639     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
00640     m = createMessage("SS",        anope_event_null); addCoreMessage(IRCD,m);
00641     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
00642     m = createMessage("SZLINE",    anope_event_null); addCoreMessage(IRCD,m);
00643     m = createMessage("UNSGLINE",  anope_event_null); addCoreMessage(IRCD,m);
00644     m = createMessage("UNSZLINE",  anope_event_null); addCoreMessage(IRCD,m);
00645     m = createMessage("SETHOST",   anope_event_sethost); addCoreMessage(IRCD,m);
00646     m = createMessage("NETINFO",   anope_event_null); addCoreMessage(IRCD,m);
00647     m = createMessage("GCONNECT",  anope_event_null); addCoreMessage(IRCD,m);
00648     m = createMessage("NETGLOBAL", anope_event_netglobal); addCoreMessage(IRCD,m);
00649     m = createMessage("CHATOPS",   anope_event_null); addCoreMessage(IRCD,m);
00650     m = createMessage("NETCTRL",   anope_event_netctrl); addCoreMessage(IRCD,m);
00651     m = createMessage("CLIENT",    anope_event_client); addCoreMessage(IRCD,m);
00652     m = createMessage("SMODE",     anope_event_null); addCoreMessage(IRCD,m);
00653     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
00654     m = createMessage("BURST",     anope_event_burst); addCoreMessage(IRCD,m);
00655     m = createMessage("REHASH",    anope_event_rehash); addCoreMessage(IRCD,m);
00656     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00657     m = createMessage("CREDITS",   anope_event_credits); addCoreMessage(IRCD,m);
00658     m = createMessage("SMODE",     anope_event_mode); addCoreMessage(IRCD,m);
00659     m = createMessage("EOBURST",   anope_event_eob); addCoreMessage(IRCD,m);
00660 }
00661 
00662 /* *INDENT-ON* */
00663 
00664 
00665 void ultimate3_cmd_sqline(char *mask, char *reason)
00666 {
00667     if (!mask || !reason) {
00668         return;
00669     }
00670 
00671     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00672 }
00673 
00674 void ultimate3_cmd_unsgline(char *mask)
00675 {
00676     send_cmd(NULL, "UNSGLINE 0 :%s", mask);
00677 }
00678 
00679 void ultimate3_cmd_unszline(char *mask)
00680 {
00681     send_cmd(NULL, "UNSZLINE 0 %s", mask);
00682 }
00683 
00684 /* As of alpha27 (one after our offical support szline was removed */
00685 /* quote the changelog ---
00686    Complete rewrite of the kline/akill/zline system. (s)zlines no longer exist.
00687    K: lines set on IP addresses without username portions (or *) are treated as Z: lines used to be.
00688 */
00689 void ultimate3_cmd_szline(char *mask, char *reason, char *whom)
00690 {
00691     send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom,
00692              (long int) time(NULL), reason);
00693     /* leaving this in here in case some legacy user asks for it */
00694     /* send_cmd(NULL, "SZLINE %s :%s", mask, reason); */
00695 }
00696 
00697 void ultimate3_cmd_svsnoop(char *server, int set)
00698 {
00699     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00700 }
00701 
00702 void ultimate3_cmd_svsadmin(char *server, int set)
00703 {
00704     ultimate3_cmd_svsnoop(server, set);
00705 }
00706 
00707 void ultimate3_cmd_sgline(char *mask, char *reason)
00708 {
00709     send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason);
00710 }
00711 
00712 void ultimate3_cmd_remove_akill(char *user, char *host)
00713 {
00714     send_cmd(NULL, "RAKILL %s %s", host, user);
00715 }
00716 
00717 void ultimate3_cmd_vhost_off(User * u)
00718 {
00719     send_cmd(s_HostServ, "SVSMODE %s -x", u->nick);
00720     notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
00721 }
00722 
00723 void ultimate3_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00724 {
00725     send_cmd(s_HostServ, "SVSMODE %s +x", nick);
00726     send_cmd(ServerName, "SETHOST %s %s", nick, vhost);
00727 }
00728 
00729 void ultimate3_cmd_join(char *user, char *channel, time_t chantime)
00730 {
00731     send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
00732 }
00733 
00734 void ultimate3_cmd_akill(char *user, char *host, char *who, time_t when,
00735                          time_t expires, char *reason)
00736 {
00737     send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
00738              (long int) time(NULL), reason);
00739 }
00740 
00741 void ultimate3_cmd_svskill(char *source, char *user, char *buf)
00742 {
00743     if (!buf) {
00744         return;
00745     }
00746 
00747     send_cmd(NULL, "SVSKILL %s :%s", user, buf);
00748 }
00749 
00750 
00751 void ultimate3_cmd_svsmode(User * u, int ac, char **av)
00752 {
00753     send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
00754              (long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
00755              (ac == 2 ? av[1] : ""));
00756 }
00757 
00758 void anope_squit(char *servname, char *message)
00759 {
00760     send_cmd(servname, "SQUIT %s :%s", servname, message);
00761 }
00762 
00763 void anope_pong(char *servname)
00764 {
00765     send_cmd(servname, "PONG %s", servname);
00766 }
00767 
00768 /* Events */
00769 
00770 int anope_event_ping(char *source, int ac, char **av)
00771 {
00772     if (ac < 1)
00773         return MOD_CONT;
00774     ultimate3_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
00775     return MOD_CONT;
00776 }
00777 
00778 int anope_event_436(char *source, int ac, char **av)
00779 {
00780     if (ac < 1)
00781         return MOD_CONT;
00782 
00783     m_nickcoll(av[0]);
00784     return MOD_CONT;
00785 }
00786 
00787 int anope_event_away(char *source, int ac, char **av)
00788 {
00789     if (!source) {
00790         return MOD_CONT;
00791     }
00792     m_away(source, (ac ? av[0] : NULL));
00793     return MOD_CONT;
00794 }
00795 
00796 int anope_event_topic(char *source, int ac, char **av)
00797 {
00798     if (ac != 4)
00799         return MOD_CONT;
00800     do_topic(source, ac, av);
00801     return MOD_CONT;
00802 }
00803 
00804 int anope_event_squit(char *source, int ac, char **av)
00805 {
00806     if (ac != 2)
00807         return MOD_CONT;
00808     do_squit(source, ac, av);
00809     return MOD_CONT;
00810 }
00811 
00812 int anope_event_quit(char *source, int ac, char **av)
00813 {
00814     if (ac != 1)
00815         return MOD_CONT;
00816     do_quit(source, ac, av);
00817     return MOD_CONT;
00818 }
00819 
00820 
00821 int anope_event_mode(char *source, int ac, char **av)
00822 {
00823     if (ac < 2)
00824         return MOD_CONT;
00825 
00826     if (*av[0] == '#' || *av[0] == '&') {
00827         do_cmode(source, ac, av);
00828     } else {
00829         do_umode(source, ac, av);
00830     }
00831     return MOD_CONT;
00832 }
00833 
00834 /* EVENT : OS */
00835 int anope_event_os(char *source, int ac, char **av)
00836 {
00837     if (ac < 1)
00838         return MOD_CONT;
00839     m_privmsg(source, s_OperServ, av[0]);
00840     return MOD_CONT;
00841 }
00842 
00843 /* EVENT : NS */
00844 int anope_event_ns(char *source, int ac, char **av)
00845 {
00846     if (ac < 1)
00847         return MOD_CONT;
00848     m_privmsg(source, s_NickServ, av[0]);
00849     return MOD_CONT;
00850 }
00851 
00852 /* EVENT : MS */
00853 int anope_event_ms(char *source, int ac, char **av)
00854 {
00855     if (ac < 1)
00856         return MOD_CONT;
00857     m_privmsg(source, s_MemoServ, av[0]);
00858     return MOD_CONT;
00859 }
00860 
00861 /* EVENT : HS */
00862 int anope_event_hs(char *source, int ac, char **av)
00863 {
00864     if (ac < 1)
00865         return MOD_CONT;
00866     m_privmsg(source, s_HostServ, av[0]);
00867     return MOD_CONT;
00868 }
00869 
00870 /* EVENT : CS */
00871 int anope_event_cs(char *source, int ac, char **av)
00872 {
00873     if (ac < 1)
00874         return MOD_CONT;
00875     m_privmsg(source, s_ChanServ, av[0]);
00876     return MOD_CONT;
00877 }
00878 
00879 
00880 int anope_event_kill(char *source, int ac, char **av)
00881 {
00882     if (ac != 2)
00883         return MOD_CONT;
00884 
00885     m_kill(av[0], av[1]);
00886     return MOD_CONT;
00887 }
00888 
00889 int anope_event_kick(char *source, int ac, char **av)
00890 {
00891     if (ac != 3)
00892         return MOD_CONT;
00893     do_kick(source, ac, av);
00894     return MOD_CONT;
00895 }
00896 
00897 
00898 int anope_event_join(char *source, int ac, char **av)
00899 {
00900     if (ac != 1)
00901         return MOD_CONT;
00902     do_join(source, ac, av);
00903     return MOD_CONT;
00904 }
00905 
00906 int anope_event_motd(char *source, int ac, char **av)
00907 {
00908     if (!source) {
00909         return MOD_CONT;
00910     }
00911 
00912     m_motd(source);
00913     return MOD_CONT;
00914 }
00915 
00916 int anope_event_setname(char *source, int ac, char **av)
00917 {
00918     User *u;
00919 
00920     if (ac != 1)
00921         return MOD_CONT;
00922 
00923     u = finduser(source);
00924     if (!u) {
00925         if (debug) {
00926             alog("debug: SETNAME for nonexistent user %s", source);
00927         }
00928         return MOD_CONT;
00929     }
00930 
00931     change_user_realname(u, av[0]);
00932     return MOD_CONT;
00933 }
00934 
00935 int anope_event_chgname(char *source, int ac, char **av)
00936 {
00937