ultimate2.c

Go to the documentation of this file.
00001 /* Ultimate IRCD 2 functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@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 "ultimate2.h"
00017 #include "version.h"
00018 
00019 IRCDVar myIrcd[] = {
00020     {"UltimateIRCd 2.8.*",      /* ircd name */
00021      "+S",                      /* nickserv mode */
00022      "+S",                      /* chanserv mode */
00023      "+S",                      /* memoserv mode */
00024      "+oS",                     /* hostserv mode */
00025      "+iS",                     /* operserv mode */
00026      "+S",                      /* botserv mode  */
00027      "+Sh",                     /* helpserv mode */
00028      "+iS",                     /* Dev/Null mode */
00029      "+iS",                     /* Global mode   */
00030      "+oS",                     /* nickserv alias mode */
00031      "+oS",                     /* chanserv alias mode */
00032      "+oS",                     /* memoserv alias mode */
00033      "+ioS",                    /* hostserv alias mode */
00034      "+ioS",                    /* operserv alias mode */
00035      "+oS",                     /* botserv alias mode  */
00036      "+oS",                     /* helpserv alias mode */
00037      "+iS",                     /* Dev/Null alias mode */
00038      "+ioS",                    /* Global alias mode   */
00039      "+pS",                     /* Used by BotServ Bots */
00040      3,                         /* Chan Max Symbols     */
00041      "-ilmnpstxAIKORS",         /* Modes to Remove */
00042      "+ao",                     /* Channel Umode used by Botserv bots */
00043      1,                         /* SVSNICK */
00044      1,                         /* Vhost  */
00045      0,                         /* Has Owner */
00046      NULL,                      /* Mode to set for an owner */
00047      NULL,                      /* Mode to unset for an owner */
00048      NULL,                      /* Mode to set for chan admin */
00049      NULL,                      /* Mode to remove for chan admin */
00050      "+rd",                     /* Mode On Reg          */
00051      NULL,                      /* Mode on ID for Roots */
00052      NULL,                      /* Mode on ID for Admins */
00053      NULL,                      /* Mode on ID for Opers */
00054      "-r+d",                    /* Mode on UnReg        */
00055      "-r+d",                    /* Mode on Nick Change  */
00056      0,                         /* Supports SGlines     */
00057      1,                         /* Supports SQlines     */
00058      0,                         /* Supports SZlines     */
00059      1,                         /* Supports Halfop +h   */
00060      3,                         /* Number of server args */
00061      0,                         /* Join 2 Set           */
00062      0,                         /* Join 2 Message       */
00063      1,                         /* Has exceptions +e    */
00064      0,                         /* TS Topic Forward     */
00065      0,                         /* TS Topci Backward    */
00066      UMODE_p,                   /* Protected Umode      */
00067      0,                         /* Has Admin            */
00068      0,                         /* Chan SQlines         */
00069      0,                         /* Quit on Kill         */
00070      0,                         /* SVSMODE unban        */
00071      0,                         /* Has Protect          */
00072      1,                         /* Reverse              */
00073      1,                         /* Chan Reg             */
00074      CMODE_r,                   /* Channel Mode         */
00075      1,                         /* vidents              */
00076      0,                         /* svshold              */
00077      1,                         /* time stamp on mode   */
00078      0,                         /* NICKIP               */
00079      0,                         /* O:LINE               */
00080      1,                         /* UMODE                */
00081      0,                         /* VHOST ON NICK        */
00082      1,                         /* Change RealName      */
00083      CMODE_K,                   /* No Knock             */
00084      CMODE_A,                   /* Admin Only           */
00085      DEFAULT_MLOCK,             /* Default MLOCK        */
00086      UMODE_x,                   /* Vhost Mode           */
00087      1,                         /* +f                   */
00088      1,                         /* +L                   */
00089      CMODE_f,
00090      CMODE_L,
00091      0,
00092      1,                         /* No Knock requires +i */
00093      NULL,                      /* CAPAB Chan Modes             */
00094      1,                         /* We support TOKENS */
00095      0,                         /* TOKENS are CASE inSensitive */
00096      0,                         /* TIME STAMPS are BASE64 */
00097      0,                         /* +I support */
00098      0,                         /* SJOIN ban char */
00099      0,                         /* SJOIN except char */
00100      0,                         /* SJOIN invite char */
00101      0,                         /* Can remove User Channel Modes with SVSMODE */
00102      0,                         /* Sglines are not enforced until user reconnects */
00103      "x",                       /* vhost char */
00104      0,                         /* ts6 */
00105      1,                         /* support helper umode */
00106      0,                         /* p10 */
00107      NULL,                      /* character set */
00108      0,                         /* reports sync state */
00109      0,                         /* CIDR channelbans */
00110      0,                         /* +j */
00111      0,                         /* +j mode */
00112      0,                         /* Use delayed client introduction. */
00113      }
00114     ,
00115     {NULL}
00116 };
00117 
00118 
00119 IRCDCAPAB myIrcdcap[] = {
00120     {
00121      CAPAB_NOQUIT,              /* NOQUIT       */
00122      0,                         /* TSMODE       */
00123      0,                         /* UNCONNECT    */
00124      0,                         /* NICKIP       */
00125      0,                         /* SJOIN        */
00126      0,                         /* ZIP          */
00127      0,                         /* BURST        */
00128      0,                         /* TS5          */
00129      0,                         /* TS3          */
00130      0,                         /* DKEY         */
00131      0,                         /* PT4          */
00132      0,                         /* SCS          */
00133      0,                         /* QS           */
00134      0,                         /* UID          */
00135      CAPAB_KNOCK,               /* KNOCK        */
00136      0,                         /* CLIENT       */
00137      0,                         /* IPV6         */
00138      0,                         /* SSJ5         */
00139      0,                         /* SN2          */
00140      CAPAB_TOKEN,               /* TOKEN        */
00141      0,                         /* VHOST        */
00142      0,                         /* SSJ3         */
00143      0,                         /* NICK2        */
00144      0,                         /* UMODE2       */
00145      0,                         /* VL           */
00146      0,                         /* TLKEXT       */
00147      0,                         /* DODKEY       */
00148      0,                         /* DOZIP        */
00149      CAPAB_CHANMODE,            /* CHANMODE             */
00150      0, 0}
00151 };
00152 
00153 void ultiamte2_set_umode(User * user, int ac, char **av)
00154 {
00155     int add = 1;                /* 1 if adding modes, 0 if deleting */
00156     char *modes = av[0];
00157 
00158     ac--;
00159 
00160     if (debug)
00161         alog("debug: Changing mode for %s to %s", user->nick, modes);
00162 
00163     while (*modes) {
00164 
00165         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00166          * At least this is readable without paying much attention :) -GD
00167          */
00168         if (add)
00169             user->mode |= umodes[(int) *modes];
00170         else
00171             user->mode &= ~umodes[(int) *modes];
00172 
00173         switch (*modes++) {
00174         case '+':
00175             add = 1;
00176             break;
00177         case '-':
00178             add = 0;
00179             break;
00180         case 'a':
00181             if (add && !is_services_oper(user)) {
00182                 common_svsmode(user, "-a", NULL);
00183                 user->mode &= ~UMODE_a;
00184             }
00185             break;
00186         case 'P':
00187             if (add && !is_services_admin(user)) {
00188                 common_svsmode(user, "-P", NULL);
00189                 user->mode &= ~UMODE_P;
00190             }
00191             break;
00192         case 'R':
00193             if (add && !is_services_root(user)) {
00194                 common_svsmode(user, "-R", NULL);
00195                 user->mode &= ~UMODE_R;
00196             }
00197             break;
00198         case 'd':
00199             if (ac == 0) {
00200                 break;
00201             }
00202 
00203             ac--;
00204             av++;
00205             user->svid = strtoul(*av, NULL, 0);
00206             break;
00207         case 'o':
00208             if (add) {
00209                 opcnt++;
00210                 if (WallOper) {
00211                     anope_cmd_global(s_OperServ,
00212                                      "\2%s\2 is now an IRC operator.",
00213                                      user->nick);
00214                 }
00215                 display_news(user, NEWS_OPER);
00216                 if (is_services_oper(user)) {
00217                     common_svsmode(user, "+a", NULL);
00218                     user->mode |= UMODE_a;
00219                 }
00220                 if (is_services_admin(user)) {
00221                     common_svsmode(user, "+P", NULL);
00222                     user->mode |= UMODE_P;
00223                 }
00224                 if (is_services_root(user)) {
00225                     common_svsmode(user, "+R", NULL);
00226                     user->mode |= UMODE_R;
00227                 }
00228             } else {
00229                 opcnt--;
00230             }
00231             break;
00232         case 'r':
00233             if (add && !nick_identified(user)) {
00234                 common_svsmode(user, "-r", NULL);
00235                 user->mode &= ~UMODE_r;
00236             }
00237             break;
00238         case 'x':
00239             update_host(user);
00240             break;
00241         }
00242     }
00243 }
00244 
00245 unsigned long umodes[128] = {
00246     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00247     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00248     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00249     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00250     0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00251     UMODE_P,
00252     0,
00253     UMODE_R,
00254     0, 0, 0, 0, 0, 0, 0,
00255     0,
00256     0, 0, 0, 0, 0,
00257     0, UMODE_a, 0, 0, 0, 0, 0,
00258     UMODE_g,
00259     UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o,
00260     UMODE_p,
00261     0, UMODE_r, 0, 0, 0, 0, UMODE_w,
00262     UMODE_x,
00263     0,
00264     0,
00265     0, 0, 0, 0, 0
00266 };
00267 
00268 char myCsmodes[128] = {
00269     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00270     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00271 
00272     0,
00273     0,
00274     0, 0, 0,
00275     0,
00276     0, 0, 0, 0,
00277     0,
00278 
00279     'v', 0, 0, 0, 0,
00280     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00281 
00282     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00283     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00284 
00285     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00286     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00287 };
00288 
00289 CMMode myCmmodes[128] = {
00290     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00291     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00292     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00293     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00294     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00295     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00296     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00297     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00298     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00299     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00300     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00301     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00302     {NULL},
00303     {NULL},
00304     {add_ban, del_ban},
00305     {NULL},
00306     {NULL},
00307     {add_exception, del_exception},
00308     {NULL},
00309     {NULL},
00310     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00311     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00312     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00313 };
00314 
00315 
00316 CBMode myCbmodes[128] = {
00317     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00318     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00319     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00320     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00321     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00322     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00323     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00324     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00325     {0},
00326     {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
00327     {0},                        /* B */
00328     {0},                        /* C */
00329     {0},                        /* D */
00330     {0},                        /* E */
00331     {0},                        /* F */
00332     {0},                        /* G */
00333     {0},                        /* H */
00334     {CMODE_I, 0, NULL, NULL},   /* I */
00335     {0},                        /* J */
00336     {CMODE_K, 0, NULL, NULL},   /* K */
00337     {CMODE_L, 0, set_redirect, cs_set_redirect},
00338     {0},                        /* M */
00339     {0},                        /* N */
00340     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00341     {0},                        /* P */
00342     {0},                        /* Q */
00343     {CMODE_R, 0, NULL, NULL},   /* R */
00344     {CMODE_S, 0, NULL, NULL},   /* S */
00345     {0},                        /* T */
00346     {0},                        /* U */
00347     {0},                        /* V */
00348     {0},                        /* W */
00349     {0},                        /* X */
00350     {0},                        /* Y */
00351     {0},                        /* Z */
00352     {0}, {0}, {0}, {0}, {0}, {0},
00353     {0},                        /* a */
00354     {0},                        /* b */
00355     {0},                        /* c */
00356     {0},                        /* d */
00357     {0},                        /* e */
00358     {CMODE_f, 0, set_flood, cs_set_flood},
00359     {0},                        /* g */
00360     {0},                        /* h */
00361     {CMODE_i, 0, NULL, NULL},   /* i */
00362     {0},                        /* j */
00363     {CMODE_k, 0, chan_set_key, cs_set_key},
00364     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00365     {CMODE_m, 0, NULL, NULL},   /* m */
00366     {CMODE_n, 0, NULL, NULL},   /* n */
00367     {0},                        /* o */
00368     {CMODE_p, 0, NULL, NULL},   /* p */
00369     {0},                        /* q */
00370     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00371     {CMODE_s, 0, NULL, NULL},   /* s */
00372     {CMODE_t, 0, NULL, NULL},   /* t */
00373     {0},                        /* u */
00374     {0},                        /* v */
00375     {0},                        /* w */
00376     {CMODE_x, 0, NULL, NULL},   /* x */
00377     {0},                        /* y */
00378     {0},                        /* z */
00379     {0}, {0}, {0}, {0}
00380 };
00381 
00382 CBModeInfo myCbmodeinfos[] = {
00383     {'f', CMODE_f, 0, get_flood, cs_get_flood},
00384     {'i', CMODE_i, 0, NULL, NULL},
00385     {'k', CMODE_k, 0, get_key, cs_get_key},
00386     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00387     {'m', CMODE_m, 0, NULL, NULL},
00388     {'n', CMODE_n, 0, NULL, NULL},
00389     {'p', CMODE_p, 0, NULL, NULL},
00390     {'r', CMODE_r, 0, NULL, NULL},
00391     {'s', CMODE_s, 0, NULL, NULL},
00392     {'t', CMODE_t, 0, NULL, NULL},
00393     {'x', CMODE_x, 0, NULL, NULL},
00394     {'A', CMODE_A, 0, NULL, NULL},
00395     {'I', CMODE_I, 0, NULL, NULL},
00396     {'K', CMODE_K, 0, NULL, NULL},
00397     {'L', CMODE_L, 0, get_redirect, cs_get_redirect},
00398     {'O', CMODE_O, 0, NULL, NULL},
00399     {'R', CMODE_R, 0, NULL, NULL},
00400     {'S', CMODE_S, 0, NULL, NULL},
00401     {0}
00402 };
00403 
00404 CUMode myCumodes[128] = {
00405     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00406     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00407     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00408     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00409 
00410     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00411     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00412     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00413     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00414 
00415     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00416     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00417     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00418     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00419 
00420     {0},
00421 
00422     {0},                        /* a */
00423     {0},                        /* b */
00424     {0},                        /* c */
00425     {0},                        /* d */
00426     {0},                        /* e */
00427     {0},                        /* f */
00428     {0},                        /* g */
00429     {CUS_HALFOP, 0, check_valid_op},
00430     {0},                        /* i */
00431     {0},                        /* j */
00432     {0},                        /* k */
00433     {0},                        /* l */
00434     {0},                        /* m */
00435     {0},                        /* n */
00436     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00437     {0},                        /* p */
00438     {0},                        /* q */
00439     {0},                        /* r */
00440     {0},                        /* s */
00441     {0},                        /* t */
00442     {0},                        /* u */
00443     {CUS_VOICE, 0, NULL},
00444     {0},                        /* w */
00445     {0},                        /* x */
00446     {0},                        /* y */
00447     {0},                        /* z */
00448     {0}, {0}, {0}, {0}, {0}
00449 };
00450 
00451 
00452 int anope_event_setname(char *source, int ac, char **av)
00453 {
00454     User *u;
00455 
00456     if (ac != 1)
00457         return MOD_CONT;
00458 
00459     u = finduser(source);
00460     if (!u) {
00461         if (debug) {
00462             alog("debug: SETNAME for nonexistent user %s", source);
00463         }
00464         return MOD_CONT;
00465     }
00466 
00467     change_user_realname(u, av[0]);
00468     return MOD_CONT;
00469 }
00470 
00471 int anope_event_chgname(char *source, int ac, char **av)
00472 {
00473     User *u;
00474 
00475     if (ac != 2)
00476         return MOD_CONT;
00477 
00478     u = finduser(av[0]);
00479     if (!u) {
00480         if (debug) {
00481             alog("debug: CHGNAME for nonexistent user %s", av[0]);
00482         }
00483         return MOD_CONT;
00484     }
00485 
00486     change_user_realname(u, av[1]);
00487     return MOD_CONT;
00488 }
00489 
00490 int anope_event_setident(char *source, int ac, char **av)
00491 {
00492     User *u;
00493 
00494     if (ac != 1)
00495         return MOD_CONT;
00496 
00497     u = finduser(source);
00498     if (!u) {
00499         if (debug) {
00500             alog("debug: SETIDENT for nonexistent user %s", source);
00501         }
00502         return MOD_CONT;
00503     }
00504 
00505     change_user_username(u, av[0]);
00506     return MOD_CONT;
00507 }
00508 
00509 int anope_event_chgident(char *source, int ac, char **av)
00510 {
00511     User *u;
00512 
00513     if (ac != 2)
00514         return MOD_CONT;
00515 
00516     u = finduser(av[0]);
00517     if (!u) {
00518         if (debug) {
00519             alog("debug: CHGIDENT for nonexistent user %s", av[0]);
00520         }
00521         return MOD_CONT;
00522     }
00523 
00524     change_user_username(u, av[1]);
00525     return MOD_CONT;
00526 }
00527 
00528 int anope_event_sethost(char *source, int ac, char **av)
00529 {
00530     User *u;
00531 
00532     if (ac != 1)
00533         return MOD_CONT;
00534 
00535     u = finduser(source);
00536     if (!u) {
00537         if (debug) {
00538             alog("debug: SETHOST for nonexistent user %s", source);
00539         }
00540         return MOD_CONT;
00541     }
00542 
00543     change_user_host(u, av[0]);
00544     return MOD_CONT;
00545 }
00546 
00547 int anope_event_nick(char *source, int ac, char **av)
00548 {
00549     if (ac != 2) {
00550         if (ac == 7) {
00551             do_nick(source, av[0], av[3], av[4], av[5], av[6],
00552                     strtoul(av[2], NULL, 10), 0, 0, NULL, NULL);
00553         } else {
00554             do_nick(source, av[0], av[3], av[4], av[5], av[7],
00555                     strtoul(av[2], NULL, 10), strtoul(av[6], NULL, 0), 0,
00556                     NULL, NULL);
00557         }
00558     } else {
00559         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00560                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00561     }
00562     return MOD_CONT;
00563 }
00564 
00565 int anope_event_chghost(char *source, int ac, char **av)
00566 {
00567     User *u;
00568 
00569     if (ac != 2)
00570         return MOD_CONT;
00571 
00572     u = finduser(av[0]);
00573     if (!u) {
00574         if (debug) {
00575             alog("debug: CHGHOST for nonexistent user %s", av[0]);
00576         }
00577         return MOD_CONT;
00578     }
00579 
00580     change_user_host(u, av[1]);
00581     return MOD_CONT;
00582 }
00583 
00584 int anope_event_436(char *source, int ac, char **av)
00585 {
00586     if (ac < 1)
00587         return MOD_CONT;
00588 
00589     m_nickcoll(av[0]);
00590     return MOD_CONT;
00591 }
00592 
00593 
00594 /* *INDENT-OFF* */
00595 void moduleAddIRCDMsgs(void) {
00596     Message *m;
00597 
00598     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
00599 
00600     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00601     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00602     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00603     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00604     if (UseTokens) {
00605       m = createMessage("6",       anope_event_away); addCoreMessage(IRCD,m);
00606     }
00607     m = createMessage("INVITE",    anope_event_null); addCoreMessage(IRCD,m);
00608     if (UseTokens) {
00609       m = createMessage("*",       anope_event_null); addCoreMessage(IRCD,m);
00610     }
00611     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00612     if (UseTokens) {
00613       m = createMessage("C",       anope_event_join); addCoreMessage(IRCD,m);
00614     }
00615     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00616     if (UseTokens) {
00617       m = createMessage("H",       anope_event_kick); addCoreMessage(IRCD,m);
00618     }
00619     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00620     if (UseTokens) {
00621       m = createMessage(".",       anope_event_kill); addCoreMessage(IRCD,m);
00622     }
00623     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00624     if (UseTokens) {
00625       m = createMessage("G",       anope_event_mode); addCoreMessage(IRCD,m);
00626     }
00627     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00628     if (UseTokens) {
00629       m = createMessage("F",       anope_event_motd); addCoreMessage(IRCD,m);
00630     }
00631     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00632     if (UseTokens) {
00633       m = createMessage("&",       anope_event_nick); addCoreMessage(IRCD,m);
00634     }
00635     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00636     if (UseTokens) {
00637       m = createMessage("B",       anope_event_notice); addCoreMessage(IRCD,m);
00638     }
00639     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00640     if (UseTokens) {
00641       m = createMessage("D",       anope_event_part); addCoreMessage(IRCD,m);
00642     }
00643     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00644     if (UseTokens) {
00645       m = createMessage("<",       anope_event_pass); addCoreMessage(IRCD,m);
00646     }
00647     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00648     if (UseTokens) {
00649       m = createMessage("9",       anope_event_ping); addCoreMessage(IRCD,m);
00650     }
00651     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00652     if (UseTokens) {
00653       m = createMessage("!",       anope_event_privmsg); addCoreMessage(IRCD,m);
00654     }
00655     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00656     if (UseTokens) {
00657       m = createMessage(",",       anope_event_quit); addCoreMessage(IRCD,m);
00658     }
00659     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00660     if (UseTokens) {
00661       m = createMessage("'",       anope_event_server); addCoreMessage(IRCD,m);
00662     }
00663     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00664     if (UseTokens) {
00665       m = createMessage("-",       anope_event_squit); addCoreMessage(IRCD,m);
00666     }
00667     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00668     if (UseTokens) {
00669       m = createMessage(")",       anope_event_topic); addCoreMessage(IRCD,m);
00670     }
00671     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00672     if (UseTokens) {
00673       m = createMessage("%",       anope_event_null); addCoreMessage(IRCD,m);
00674     }
00675     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00676     if (UseTokens) {
00677       m = createMessage("=",       anope_event_null); addCoreMessage(IRCD,m);
00678     }
00679     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00680     if (UseTokens) {
00681       m = createMessage("#",       anope_event_whois); addCoreMessage(IRCD,m);
00682     }
00683     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00684     if (UseTokens) {
00685       m = createMessage("V",       anope_event_null); addCoreMessage(IRCD,m);
00686     }
00687     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00688     if (UseTokens) {
00689       m = createMessage("]",       anope_event_null); addCoreMessage(IRCD,m);
00690     }
00691     m = createMessage("GNOTICE",   anope_event_null); addCoreMessage(IRCD,m);
00692     if (UseTokens) {
00693       m = createMessage("Z",       anope_event_null); addCoreMessage(IRCD,m);
00694     }
00695     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00696     if (UseTokens) {
00697       m = createMessage("[",       anope_event_null); addCoreMessage(IRCD,m);
00698     }
00699     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00700     if (UseTokens) {
00701       m = createMessage("Y",       anope_event_null); addCoreMessage(IRCD,m);
00702     }
00703     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00704     if (UseTokens) {
00705       m = createMessage("U",       anope_event_null); addCoreMessage(IRCD,m);
00706     }
00707     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00708     if (UseTokens) {
00709       m = createMessage("h",       anope_event_null); addCoreMessage(IRCD,m);
00710     }
00711     m = createMessage("SVSMODE",   anope_event_mode); addCoreMessage(IRCD,m);
00712     if (UseTokens) {
00713       m = createMessage("n",       anope_event_mode); addCoreMessage(IRCD,m);
00714     }
00715     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00716     if (UseTokens) {
00717       m = createMessage("e",       anope_event_null); addCoreMessage(IRCD,m);
00718     }
00719     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00720     if (UseTokens) {
00721       m = createMessage("f",       anope_event_null); addCoreMessage(IRCD,m);
00722     }
00723     m = createMessage("SQLINE",    anope_event_sqline); addCoreMessage(IRCD,m);
00724     if (UseTokens) {
00725       m = createMessage("c",       anope_event_sqline); addCoreMessage(IRCD,m);
00726     }
00727     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00728     if (UseTokens) {
00729       m = createMessage("d",       anope_event_null); addCoreMessage(IRCD,m);
00730     }
00731     m = createMessage("PROTOCTL",  anope_event_capab); addCoreMessage(IRCD,m);
00732     if (UseTokens) {
00733       m = createMessage("_",       anope_event_capab); addCoreMessage(IRCD,m);
00734     }
00735     m = createMessage("CHGHOST",   anope_event_chghost); addCoreMessage(IRCD,m);
00736     if (UseTokens) {
00737       m = createMessage("!<",       anope_event_chghost); addCoreMessage(IRCD,m);
00738     }
00739     m = createMessage("CHGIDENT",  anope_event_chgident); addCoreMessage(IRCD,m);
00740     if (UseTokens) {
00741       m = createMessage("!=",       anope_event_chgident); addCoreMessage(IRCD,m);
00742     }
00743     m = createMessage("NETINFO",   anope_event_netinfo); addCoreMessage(IRCD,m);
00744     if (UseTokens) {
00745       m = createMessage("u",       anope_event_netinfo); addCoreMessage(IRCD,m);
00746     }
00747     m = createMessage("SNETINFO",  anope_event_snetinfo); addCoreMessage(IRCD,m);
00748     if (UseTokens) {
00749       m = createMessage("!1",      anope_event_snetinfo); addCoreMessage(IRCD,m);
00750     }
00751     m = createMessage("SETHOST",   anope_event_sethost); addCoreMessage(IRCD,m);
00752     if (UseTokens) {
00753       m = createMessage("!8",       anope_event_sethost); addCoreMessage(IRCD,m);
00754     }
00755     m = createMessage("SETIDENT",  anope_event_setident); addCoreMessage(IRCD,m);
00756     if (UseTokens) {
00757       m = createMessage("!9",       anope_event_setident); addCoreMessage(IRCD,m);
00758     }
00759     m = createMessage("SETNAME",   anope_event_setname); addCoreMessage(IRCD,m);
00760     if (UseTokens) {
00761       m = createMessage("!;",       anope_event_setname); addCoreMessage(IRCD,m);
00762     }
00763     m = createMessage("VCTRL",     anope_event_vctrl); addCoreMessage(IRCD,m);
00764     if (UseTokens) {
00765       m = createMessage("!I",      anope_event_vctrl); addCoreMessage(IRCD,m);
00766     }
00767     m = createMessage("REHASH",     anope_event_rehash); addCoreMessage(IRCD,m);
00768     m = createMessage("ADMIN",      anope_event_admin); addCoreMessage(IRCD,m);
00769     m = createMessage("CREDITS",    anope_event_credits); addCoreMessage(IRCD,m);
00770     m = createMessage("ERROR",      anope_event_error); addCoreMessage(IRCD,m);
00771 
00772 
00773 }
00774 
00775 /* *INDENT-ON* */
00776 
00777 /* Event: PROTOCTL */
00778 int anope_event_capab(char *source, int ac, char **av)
00779 {
00780     capab_parse(ac, av);
00781     return MOD_CONT;
00782 }
00783 
00784 void ultimate2_cmd_sqline(char *mask, char *reason)
00785 {
00786     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00787 }
00788 
00789 void ultimate2_cmd_svsnoop(char *server, int set)
00790 {
00791     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00792 }
00793 
00794 void ultimate2_cmd_svsadmin(char *server, int set)
00795 {
00796     ultimate2_cmd_svsnoop(server, set);
00797 }
00798 
00799 void ultimate2_cmd_remove_akill(char *user, char *host)
00800 {
00801     send_cmd(NULL, "RAKILL %s %s", host, user);
00802 }
00803 
00804 
00805 void ultimate2_cmd_topic(char *whosets, char *chan, char *whosetit,
00806                          char *topic, time_t when)
00807 {
00808     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
00809              (unsigned long int) when, topic);
00810 }
00811 
00812 void ultimate2_cmd_vhost_off(User * u)
00813 {
00814     /* does not support removing vhosting */
00815 }
00816 
00817 void ultimate2_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00818 {
00819     if (vIdent) {
00820         send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent);
00821     }
00822     send_cmd(s_HostServ, "SVSMODE %s +x", nick);
00823     send_cmd(ServerName, "CHGHOST %s %s", nick, vhost);
00824 }
00825 
00826 void ultimate2_cmd_unsqline(char *user)
00827 {
00828     send_cmd(NULL, "UNSQLINE %s", user);
00829 }
00830 
00831 void ultimate2_cmd_join(char *user, char *channel, time_t chantime)
00832 {
00833     send_cmd(user, "JOIN %s", channel);
00834 }
00835 
00836 void ultimate2_cmd_akill(char *user, char *host, char *who, time_t when,
00837                          time_t expires, char *reason)
00838 {
00839     send_cmd(NULL, "AKILL %s %s :%s", host, user, reason);
00840 }
00841 
00842 void ultimate2_cmd_svskill(char *source, char *user, char *buf)
00843 {
00844     if (!buf) {
00845         return;
00846     }
00847 
00848     send_cmd(source, "KILL %s :%s", user, buf);
00849 }
00850 
00851 void ultimate2_cmd_svsmode(User * u, int ac, char **av)
00852 {
00853     send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
00854              (ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
00855 }
00856 
00857 void ultimate2_cmd_capab()
00858 {
00859     if (UseTokens) {
00860         send_cmd(NULL, "PROTOCTL NOQUIT TOKEN SILENCE KNOCK");
00861     } else {
00862         send_cmd(NULL, "PROTOCTL NOQUIT SILENCE KNOCK");
00863     }
00864 }
00865 
00866 
00867 /* PASS */
00868 void ultimate2_cmd_pass(char *pass)
00869 {
00870     send_cmd(NULL, "PASS :%s", pass);
00871 }
00872 
00873 /* SERVER name hop descript */
00874 void ultimate2_cmd_server(char *servname, int hop, char *descript)
00875 {
00876     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00877 }
00878 
00879 /* PONG */
00880 void ultimate2_cmd_pong(char *servname, char *who)
00881 {
00882     send_cmd(servname, "PONG %s", who);
00883 }
00884 
00885 void ultimate2_cmd_connect(int servernum)
00886 {
00887     me_server =
00888         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00889 
00890     ultimate2_cmd_capab();
00891     if (servernum == 1)
00892         ultimate2_cmd_pass(RemotePassword);
00893     if (servernum == 2)
00894         ultimate2_cmd_pass(RemotePassword2);
00895     if (servernum == 3)
00896         ultimate2_cmd_pass(RemotePassword3);
00897     ultimate2_cmd_server(ServerName, 1, ServerDesc);
00898 }
00899 
00900 void ultimate2_cmd_bob()
00901 {
00902     /* Not used */
00903 }
00904 
00905 /* CHGHOST */
00906 void ultimate2_cmd_chghost(char *nick, char *vhost)
00907 {
00908     if (!nick || !vhost) {
00909         return;
00910     }
00911     send_cmd(ServerName, "CHGHOST %s %s", nick, vhost);
00912 }
00913 
00914 /* CHGIDENT */
00915 void ultimate2_cmd_chgident(char *nick, char *vIdent)
00916 {
00917     if (!nick || !vIdent) {
00918         return;
00919     }
00920     send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent);
00921 }
00922 
00923 /* INVITE */
00924 void ultimate2_cmd_invite(char *source, char *chan, char *nick)
00925 {
00926     if (!source || !chan || !nick) {
00927         return;
00928     }
00929 
00930     send_cmd(source, "INVITE %s %s", nick, chan);
00931 }
00932 
00933 /* PART */
00934 void ultimate2_cmd_part(char *nick, char *chan, char *buf)
00935 {
00936     if (!nick || !chan) {
00937         return;
00938     }
00939 
00940     if (buf) {
00941         send_cmd(nick, "PART %s :%s", chan, buf);
00942     } else {
00943         send_cmd(nick, "PART %s", chan);
00944     }
00945 }
00946 
00947 /* 391 */
00948 void ultimate2_cmd_391(char *source, char *timestr)
00949 {
00950     if (!timestr) {
00951         return;
00952     }
00953     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
00954 }
00955 
00956 /* 250 */
00957 void ultimate2_cmd_250(char *buf)
00958 {
00959     if (!buf) {
00960         return;
00961     }
00962 
00963     send_cmd(NULL, "250 %s", buf);
00964 }
00965 
00966 /* 307 */
00967 void ultimate2_cmd_307(char *buf)
00968 {
00969     if (!buf) {
00970         return;
00971     }
00972 
00973     send_cmd(ServerName, "307 %s", buf);
00974 }
00975 
00976 /* 311 */
00977 void ultimate2_cmd_311(char *buf)
00978 {
00979     if (!buf) {
00980         return;
00981     }
00982 
00983     send_cmd(ServerName, "311 %s", buf);
00984 }
00985 
00986 /* 312 */
00987 void ultimate2_cmd_312(char *buf)
00988 {
00989     if (!buf) {
00990         return;
00991     }
00992 
00993     send_cmd(ServerName, "312 %s", buf);
00994 }
00995 
00996 /* 317 */
00997 void ultimate2_cmd_317(char *buf)
00998 {
00999     if (!buf) {
01000         return;
01001     }
01002 
01003     send_cmd(ServerName, "317 %s", buf);
01004 }
01005 
01006 /* 219 */
01007 void ultimate2_cmd_219(char *source, char *letter)
01008 {
01009     if (!source) {
01010         return;
01011     }
01012 
01013     if (letter) {
01014         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
01015                  *letter);
01016     } else {
01017         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
01018     }
01019 }
01020 
01021 /* 401 */
01022 void ultimate2_cmd_401(char *source, char *who)
01023 {
01024     if (!source || !who) {
01025         return;
01026     }
01027     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
01028 }
01029 
01030 /* 318 */
01031 void ultimate2_cmd_318(char *source, char *who)
01032 {
01033     if (!source || !who) {
01034         return;
01035     }
01036 
01037     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01038 }
01039 
01040 /* 242 */
01041 void ultimate2_cmd_242(char *buf)
01042 {
01043     if (!buf) {
01044         return;
01045     }
01046 
01047     send_cmd(NULL, "242 %s", buf);
01048 }
01049 
01050 /* 243 */
01051 void ultimate2_cmd_243(char *buf)
01052 {
01053     if (!buf) {
01054         return;
01055     }
01056 
01057     send_cmd(NULL, "243 %s", buf);
01058 }
01059 
01060 /* 211 */
01061 void ultimate2_cmd_211(char *buf)
01062 {
01063     if (!buf) {
01064         return;
01065     }
01066 
01067     send_cmd(NULL, "211 %s", buf);
01068 }
01069 
01070 /* GLOBOPS */
01071 void ultimate2_cmd_global(char *source, char *buf)
01072 {
01073     if (!buf) {
01074         return;
01075     }
01076 
01077     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
01078 }
01079 
01080 /* SQUIT */
01081 void ultimate2_cmd_squit(char *servname, char *message)
01082 {
01083     if (!servname || !message) {
01084         return;
01085     }
01086 
01087     send_cmd(NULL, "SQUIT %s :%s", servname, message);
01088 }
01089 
01090 /* SVSO */
01091 void ultimate2_cmd_svso(char *source, char *nick, char *flag)
01092 {
01093     if (!source || !nick || !flag) {
01094         return;
01095     }
01096 
01097     send_cmd(source, "SVSO %s %s", nick, flag);
01098 }
01099 
01100 /* NICK <newnick>  */
01101 void ultimate2_cmd_chg_nick(char *oldnick, char *newnick)
01102 {
01103     if (!oldnick || !newnick) {
01104         return;
01105     }
01106 
01107     send_cmd(oldnick, "NICK %s", newnick);
01108 }
01109 
01110 /* SVSNICK */
01111 void ultimate2_cmd_svsnick(char *source, char *guest, time_t when)
01112 {
01113     if (!source || !guest) {
01114         return;
01115     }
01116     send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
01117 }
01118 
01119 /* Events */
01120 
01121 int anope_event_ping(char *source, int ac, char **av)
01122 {
01123     if (ac < 1)
01124         return MOD_CONT;
01125     ultimate2_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
01126     return MOD_CONT;
01127 }
01128 
01129 int anope_event_away(char *source, int ac, char **av)
01130 {
01131     if (!source) {
01132         return MOD_CONT;
01133     }
01134     m_away(source, (ac ? av[0] : NULL));
01135     return MOD_CONT;
01136 }
01137 
01138 int anope_event_topic(char *source, int ac, char **av)
01139 {
01140     if (ac != 4)
01141         return MOD_CONT;
01142     do_topic(source, ac, av);
01143     return MOD_CONT;
01144 }
01145 
01146 int anope_event_squit(char *source, int ac, char **av)
01147 {
01148     if (ac != 2)
01149         return MOD_CONT;
01150     do_squit(source, ac, av);
01151     return MOD_CONT;
01152 }
01153 
01154 int anope_event_quit(char *source, int ac, char **av)
01155 {
01156     if (ac != 1)
01157         return MOD_CONT;
01158     do_quit(source, ac, av);
01159     return MOD_CONT;
01160 }
01161 
01162 
01163 int anope_event_mode(char *source, int ac, char **av)
01164 {
01165     if (ac < 2)
01166         return MOD_CONT;
01167 
01168     if (*av[0] == '#' || *av[0] == '&') {
01169         do_cmode(source, ac, av);
01170     } else {
01171         do_umode(source, ac, av);
01172     }
01173     return MOD_CONT;
01174 }
01175 
01176 
01177 int anope_event_kill(char *source, int ac, char **av)
01178 {
01179     if (ac != 2)
01180         return MOD_CONT;
01181 
01182     m_kill(av[0], av[1]);
01183     return MOD_CONT;
01184 }
01185 
01186 int anope_event_kick(char *source, int ac, char **av)
01187 {
01188     if (ac != 3)
01189         return MOD_CONT;
01190     do_kick(source, ac, av);
01191     return MOD_CONT;
01192 }
01193 
01194 
01195 int anope_event_join(char *source, int ac, char **av)
01196 {
01197     if (ac != 1)
01198         return MOD_CONT;
01199     do_join(source, ac, av);
01200     return MOD_CONT;
01201 }
01202 
01203 int anope_event_motd(char *source, int ac, char **av)
01204 {
01205     if (!source) {
01206         return MOD_CONT;
01207     }
01208 
01209     m_motd(source);
01210     return MOD_CONT;
01211 }
01212 
01213 /* EVENT: SERVER */
01214 int anope_event_server(char *source, int ac, char **av)
01215 {
01216     if (!stricmp(av[1], "1")) {
01217         uplink = sstrdup(av[0]);
01218     }
01219     do_server(source, av[0], av[1], av[2], NULL);
01220     return MOD_CONT;
01221 }
01222 
01223 
01224 int anope_event_privmsg(char *source, int ac, char **av)
01225 {
01226     if (ac != 2)
01227         return MOD_CONT;
01228     m_privmsg(source, av[0], av[1]);
01229     return MOD_CONT;
01230 }
01231 
01232 int anope_event_part(char *source, int ac, char **av)
01233 {
01234     if (ac < 1 || ac > 2)
01235         return MOD_CONT;
01236     do_part(source, ac, av);
01237     return MOD_CONT;
01238 }
01239 
01240 int anope_event_whois(char *source, int ac, char **av)
01241 {
01242     if (source && ac >= 1) {
01243         m_whois(source, av[0]);
01244     }
01245     return MOD_CONT;
01246 }
01247 
01248 void ultimate2_cmd_kick(char *source, char *chan, char *user, char *buf)
01249 {
01250     if (buf) {
01251         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
01252     } else {
01253         send_cmd(source, "KICK %s %s", chan, user);
01254     }
01255 }
01256 
01257 void ultimate2_cmd_notice_ops(char *source, char *dest, char *buf)
01258 {
01259     if (!buf) {
01260         return;
01261     }
01262 
01263     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
01264 }
01265 
01266 
01267 void ultimate2_cmd_notice(char *source, char *dest, char *buf)
01268 {
01269     if (!buf) {
01270         return;
01271     }
01272 
01273     if (NSDefFlags & NI_MSG) {
01274         ultimate2_cmd_privmsg2(source, dest, buf);
01275     } else {
01276         send_cmd(source, "NOTICE %s :%s", dest, buf);
01277     }
01278 }
01279 
01280 void ultimate2_cmd_notice2(char *source, char *dest, char *msg)
01281 {
01282     send_cmd(source, "NOTICE %s :%s", dest, msg);
01283 }
01284 
01285 void ultimate2_cmd_privmsg(char *source, char *dest, char *buf)
01286 {
01287     if (!buf) {
01288         return;
01289     }
01290 
01291     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
01292 }
01293 
01294 void ultimate2_cmd_privmsg2(char *source, char *dest, char *msg)
01295 {
01296     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
01297 }
01298 
01299 void ultimate2_cmd_serv_notice(char *source, char *dest, char *msg)
01300 {
01301     send_cmd(source, "NOTICE $%s :%s", dest, msg);
01302 }
01303 
01304 void ultimate2_cmd_serv_privmsg(char *source, char *dest, char *msg)
01305 {
01306     send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
01307 }
01308 
01309 void ultimate2_cmd_nick(char *nick, char *name, char *mode)
01310 {
01311     EnforceQlinedNick(nick, NULL);
01312     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
01313              (long int) time(NULL), ServiceUser, ServiceHost, ServerName,
01314              name);
01315     anope_cmd_mode(nick, nick, "%s", mode);
01316     ultimate2_cmd_sqline(nick, "Reserved for services");
01317 }
01318 
01319 void ultimate2_cmd_351(char *source)
01320 {
01321     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01322              source, version_number, ServerName, ircd->name, version_flags,
01323              EncModule, version_build);
01324 }
01325 
01326 /* QUIT */
01327 void ultimate2_cmd_quit(char *source, char *buf)
01328 {
01329     if (buf) {
01330         send_cmd(source, "QUIT :%s", buf);
01331     } else {
01332         send_cmd(source, "QUIT");
01333     }
01334 }
01335 
01336 void ultimate2_cmd_mode(char *source, char *dest, char *buf)
01337 {
01338     if (!buf) {
01339         return;
01340     }
01341 
01342     send_cmd(source, "MODE %s %s", dest, buf);
01343 }
01344 
01345 void ultimate2_cmd_bot_nick(char *nick, char *user, char *host, char *real,
01346                             char *modes)
01347 {
01348     EnforceQlinedNick(nick, s_BotServ);
01349     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
01350              (long int) time(NULL), user, host, ServerName, real);
01351     anope_cmd_mode(nick, nick, "%s", modes);
01352     ultimate2_cmd_sqline(nick, "Reserved for services");
01353 }
01354 
01355 void ultimate2_cmd_372(char *source, char *msg)
01356 {
01357     send_cmd(ServerName, "372 %s :- %s", source, msg);
01358 }
01359 
01360 void ultimate2_cmd_372_error(char *source)
01361 {
01362     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
01363              "contact your IRC administrator.", source);
01364 }
01365 
01366 void ultimate2_cmd_375(char *source)
01367 {
01368     send_cmd(ServerName, "375 %s :- %s Message of the Day",
01369              source, ServerName);
01370 }
01371 
01372 void ultimate2_cmd_376(char *source)
01373 {
01374     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
01375 }
01376 
01377 void ultimate2_cmd_bot_chan_mode(char *nick, char *chan)
01378 {
01379     anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
01380 }
01381 
01382 /* SVSHOLD - set */
01383 void ultimate2_cmd_svshold(char *nick)
01384 {
01385     /* Not supported by this IRCD */
01386 }
01387 
01388 /* SVSHOLD - release */
01389 void ultimate2_cmd_release_svshold(char *nick)
01390 {
01391     /* Not Supported by this IRCD */
01392 }
01393 
01394 /* UNSGLINE */
01395 void ultimate2_cmd_unsgline(char *mask)
01396 {
01397     /* Not Supported by this IRCD */
01398 }
01399 
01400 /* UNSZLINE */
01401 void ultimate2_cmd_unszline(char *mask)
01402 {
01403     /* Not Supported by this IRCD */
01404 }
01405 
01406 /* SZLINE */
01407 void ultimate2_cmd_szline(char *mask, char *reason, char *whom)
01408 {
01409     /* Not Supported by this IRCD */
01410 }
01411 
01412 /* SGLINE */
01413 void ultimate2_cmd_sgline(char *mask, char *reason)
01414 {
01415     /* Not Supported by this IRCD */
01416 }
01417 
01418 void ultimate2_cmd_guest_nick(char *nick, char *user, char *host,
01419                               char *real, char *modes)
01420 {
01421     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", nick,
01422              (long int) time(NULL), user, host, ServerName, real);
01423     anope_cmd_mode(nick, nick, "MODE %s %s", modes);
01424 }
01425 
01426 
01427 void ultimate2_cmd_unban(char *name, char *nick)
01428 {
01429     /* Not Supported by this IRCD */
01430 }
01431 
01432 /* SVSMODE channel modes */
01433 
01434 void ultimate2_cmd_svsmode_chan(char *name, char *mode, char *nick)
01435 {
01436     /* Not Supported by this IRCD */
01437 }
01438 
01439 /* SVSMODE +d */
01440 /* sent if svid is something weird */
01441 void ultimate2_cmd_svid_umode(char *nick, time_t ts)
01442 {
01443     send_cmd(ServerName, "SVSMODE %s +d 1", nick);
01444 }
01445 
01446 /* SVSMODE +d */
01447 /* nc_change was = 1, and there is no na->status */
01448 void ultimate2_cmd_nc_change(User * u)
01449 {
01450     common_svsmode(u, "-r+d", "1");
01451 }
01452 
01453 /* SVSMODE +r */
01454 void ultimate2_cmd_svid_umode2(User * u, char *ts)
01455 {
01456     if (u->svid != u->timestamp) {
01457         common_svsmode(u, "+rd", ts);
01458     } else {
01459         common_svsmode(u, "+r", NULL);
01460     }
01461 }
01462 
01463 void ultimate2_cmd_svid_umode3(User * u, char *ts)
01464 {
01465     /* not used */
01466 }
01467 
01468 int anope_event_notice(char *source, int ac, char **av)
01469 {
01470     return MOD_CONT;
01471 }
01472 
01473 int anope_event_pass(char *source, int ac, char **av)
01474 {
01475     return MOD_CONT;
01476 }
01477 
01478 int anope_event_vctrl(char *source, int ac, char **av)
01479 {
01480     return MOD_CONT;
01481 }
01482 
01483 int anope_event_netinfo(char *source, int ac, char **av)
01484 {
01485     return MOD_CONT;
01486 }
01487 
01488 int anope_event_snetinfo(char *source, int ac, char **av)
01489 {
01490     return MOD_CONT;
01491 }
01492 
01493 int anope_event_sqline(char *source, int ac, char **av)
01494 {
01495     return MOD_CONT;
01496 }
01497 
01498 /*
01499 ** svsjoin
01500 **
01501 **      parv[0] - sender
01502 **      parv[1] - nick to make join
01503 **      parv[2] - channel(s) to join
01504 */
01505 void ultimate2_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
01506 {
01507     send_cmd(source, "SVSJOIN %s %s", nick, chan);
01508 }
01509 
01510 /*
01511 ** svspart
01512 **
01513 **      parv[0] - sender
01514 **      parv[1] - nick to make part
01515 **      parv[2] - channel(s) to part
01516 */
01517 void ultimate2_cmd_svspart(char *source, char *nick, char *chan)
01518 {
01519     send_cmd(source, "SVSPART %s %s", nick, chan);
01520 }
01521 
01522 void ultimate2_cmd_swhois(char *source, char *who, char *mask)
01523 {
01524     /* not supported */
01525 }
01526 
01527 void ultimate2_cmd_eob()
01528 {
01529     /* not supported */
01530 }
01531 
01532 int anope_event_rehash(char *source, int ac, char **av)
01533 {
01534     return MOD_CONT;
01535 }
01536 
01537 int anope_event_credits(char *source, int ac, char **av)
01538 {
01539     return MOD_CONT;
01540 }
01541 
01542 int anope_event_admin(char *source, int ac, char **av)
01543 {
01544     return MOD_CONT;
01545 }
01546 
01547 int ultiamte2_flood_mode_check(char *value)
01548 {
01549     char *dp, *end;
01550 
01551     if (value && *value != ':'
01552         && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0)
01553         && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0)
01554         && (*end == 0)) {
01555         return 1;
01556     } else {
01557         return 0;
01558     }
01559 }
01560 
01561 int anope_event_error(char *source, int ac, char **av)
01562 {
01563     if (av[0]) {
01564         if (debug) {
01565             alog("debug: %s", av[0]);
01566         }
01567     }
01568     return MOD_CONT;
01569 }
01570 
01571 void ultimate2_cmd_jupe(char *jserver, char *who, char *reason)
01572 {
01573     char rbuf[256];
01574 
01575     snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
01576              reason ? ": " : "", reason ? reason : "");
01577 
01578     if (findserver(servlist, jserver))
01579         ultimate2_cmd_squit(jserver, rbuf);
01580     ultimate2_cmd_server(jserver, 2, rbuf);
01581     new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
01582 }
01583 
01584 /* GLOBOPS - to handle old WALLOPS */
01585 void ultimate2_cmd_global_legacy(char *source, char *fmt)
01586 {
01587     send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
01588 }
01589 
01590 /* 
01591   1 = valid nick
01592   0 = nick is in valid
01593 */
01594 int ultiamte2_valid_nick(char *nick)
01595 {
01596     /* no hard coded invalid nicks */
01597     return 1;
01598 }
01599 
01600 /* 
01601   1 = valid chan
01602   0 = chan is in valid
01603 */
01604 int ultiamte2_valid_chan(char *chan)
01605 {
01606     /* no hard coded invalid chans */
01607     return 1;
01608 }
01609 
01610 
01611 void ultimate2_cmd_ctcp(char *source, char *dest, char *buf)
01612 {
01613     char *s;
01614 
01615     if (!buf) {
01616         return;
01617     } else {
01618         s = normalizeBuffer(buf);
01619     }
01620 
01621     send_cmd(source, "NOTICE %s :\1%s \1", dest, s);
01622     free(s);
01623 }
01624 
01625 
01630 void moduleAddAnopeCmds()
01631 {
01632     pmodule_cmd_svsnoop(ultimate2_cmd_svsnoop);
01633     pmodule_cmd_remove_akill(ultimate2_cmd_remove_akill);
01634     pmodule_cmd_topic(ultimate2_cmd_topic);
01635     pmodule_cmd_vhost_off(ultimate2_cmd_vhost_off);
01636     pmodule_cmd_akill(ultimate2_cmd_akill);
01637     pmodule_cmd_svskill(ultimate2_cmd_svskill);
01638     pmodule_cmd_svsmode(ultimate2_cmd_svsmode);
01639     pmodule_cmd_372(ultimate2_cmd_372);
01640     pmodule_cmd_372_error(ultimate2_cmd_372_error);
01641     pmodule_cmd_375(ultimate2_cmd_375);
01642     pmodule_cmd_376(ultimate2_cmd_376);
01643     pmodule_cmd_nick(ultimate2_cmd_nick);
01644     pmodule_cmd_guest_nick(ultimate2_cmd_guest_nick);
01645     pmodule_cmd_mode(ultimate2_cmd_mode);
01646     pmodule_cmd_bot_nick(ultimate2_cmd_bot_nick);
01647     pmodule_cmd_kick(ultimate2_cmd_kick);
01648     pmodule_cmd_notice_ops(ultimate2_cmd_notice_ops);
01649     pmodule_cmd_notice(ultimate2_cmd_notice);
01650     pmodule_cmd_notice2(ultimate2_cmd_notice2);
01651     pmodule_cmd_privmsg(ultimate2_cmd_privmsg);
01652     pmodule_cmd_privmsg2(ultimate2_cmd_privmsg2);
01653     pmodule_cmd_serv_notice(ultimate2_cmd_serv_notice);
01654     pmodule_cmd_serv_privmsg(ultimate2_cmd_serv_privmsg);
01655     pmodule_cmd_bot_chan_mode(ultimate2_cmd_bot_chan_mode);
01656     pmodule_cmd_351(ultimate2_cmd_351);
01657     pmodule_cmd_quit(ultimate2_cmd_quit);
01658     pmodule_cmd_pong(ultimate2_cmd_pong);
01659     pmodule_cmd_join(ultimate2_cmd_join);
01660     pmodule_cmd_unsqline(ultimate2_cmd_unsqline);
01661     pmodule_cmd_invite(ultimate2_cmd_invite);
01662     pmodule_cmd_part(ultimate2_cmd_part);
01663     pmodule_cmd_391(ultimate2_cmd_391);
01664     pmodule_cmd_250(ultimate2_cmd_250);
01665     pmodule_cmd_307(ultimate2_cmd_307);
01666     pmodule_cmd_311(ultimate2_cmd_311);
01667     pmodule_cmd_312(ultimate2_cmd_312);
01668     pmodule_cmd_317(ultimate2_cmd_317);
01669     pmodule_cmd_219(ultimate2_cmd_219);
01670     pmodule_cmd_401(ultimate2_cmd_401);
01671     pmodule_cmd_318(ultimate2_cmd_318);
01672     pmodule_cmd_242(ultimate2_cmd_242);
01673     pmodule_cmd_243(ultimate2_cmd_243);
01674     pmodule_cmd_211(ultimate2_cmd_211);
01675     pmodule_cmd_global(ultimate2_cmd_global);
01676     pmodule_cmd_global_legacy(ultimate2_cmd_global_legacy);
01677     pmodule_cmd_sqline(ultimate2_cmd_sqline);
01678     pmodule_cmd_squit(ultimate2_cmd_squit);
01679     pmodule_cmd_svso(ultimate2_cmd_svso);
01680     pmodule_cmd_chg_nick(ultimate2_cmd_chg_nick);
01681     pmodule_cmd_svsnick(ultimate2_cmd_svsnick);
01682     pmodule_cmd_vhost_on(ultimate2_cmd_vhost_on);
01683     pmodule_cmd_connect(ultimate2_cmd_connect);
01684     pmodule_cmd_bob(ultimate2_cmd_bob);
01685     pmodule_cmd_svshold(ultimate2_cmd_svshold);
01686     pmodule_cmd_release_svshold(ultimate2_cmd_release_svshold);
01687     pmodule_cmd_unsgline(ultimate2_cmd_unsgline);
01688     pmodule_cmd_unszline(ultimate2_cmd_unszline);
01689     pmodule_cmd_szline(ultimate2_cmd_szline);
01690     pmodule_cmd_sgline(ultimate2_cmd_sgline);
01691     pmodule_cmd_unban(ultimate2_cmd_unban);
01692     pmodule_cmd_svsmode_chan(ultimate2_cmd_svsmode_chan);
01693     pmodule_cmd_svid_umode(ultimate2_cmd_svid_umode);
01694     pmodule_cmd_nc_change(ultimate2_cmd_nc_change);
01695     pmodule_cmd_svid_umode2(ultimate2_cmd_svid_umode2);
01696     pmodule_cmd_svid_umode3(ultimate2_cmd_svid_umode3);
01697     pmodule_cmd_svsjoin(ultimate2_cmd_svsjoin);
01698     pmodule_cmd_svspart(ultimate2_cmd_svspart);
01699     pmodule_cmd_swhois(ultimate2_cmd_swhois);
01700     pmodule_cmd_eob(ultimate2_cmd_eob);
01701     pmodule_flood_mode_check(ultiamte2_flood_mode_check);
01702     pmodule_cmd_jupe(ultimate2_cmd_jupe);
01703     pmodule_valid_nick(ultiamte2_valid_nick);
01704     pmodule_valid_chan(ultiamte2_valid_chan);
01705     pmodule_cmd_ctcp(ultimate2_cmd_ctcp);
01706     pmodule_set_umode(ultiamte2_set_umode);
01707 }
01708 
01712 int AnopeInit(int argc, char **argv)
01713 {
01714 
01715     moduleAddAuthor("Anope");
01716     moduleAddVersion(VERSION_STRING);
01717     moduleSetType(PROTOCOL);
01718 
01719     pmodule_ircd_version("UltimateIRCd 2.8.2+");
01720     pmodule_ircd_cap(myIrcdcap);
01721     pmodule_ircd_var(myIrcd);
01722     pmodule_ircd_cbmodeinfos(myCbmodeinfos);
01723     pmodule_ircd_cumodes(myCumodes);
01724     pmodule_ircd_flood_mode_char_set("+f");
01725     pmodule_ircd_flood_mode_char_remove("-f");
01726     pmodule_ircd_cbmodes(myCbmodes);
01727     pmodule_ircd_cmmodes(myCmmodes);
01728     pmodule_ircd_csmodes(myCsmodes);
01729     pmodule_ircd_useTSMode(0);
01730 
01732     pmodule_invis_umode(UMODE_i);
01733     pmodule_oper_umode(UMODE_o);
01734     pmodule_invite_cmode(CMODE_i);
01735     pmodule_secret_cmode(CMODE_s);
01736     pmodule_private_cmode(CMODE_p);
01737     pmodule_key_mode(CMODE_k);
01738     pmodule_limit_mode(CMODE_l);
01739     pmodule_permchan_mode(0);
01740 
01741     moduleAddAnopeCmds();
01742     moduleAddIRCDMsgs();
01743 
01744     return MOD_CONT;
01745 }