ultimate3.c

Go to the documentation of this file.
00001 /* Ultimate IRCD 3 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 "ultimate3.h"
00017 #include "version.h"
00018 
00019 IRCDVar myIrcd[] = {
00020     {"UltimateIRCd 3.0.*",      /* ircd name */
00021      "+S",                      /* nickserv mode */
00022      "+S",                      /* chanserv mode */
00023      "+S",                      /* memoserv mode */
00024      "+o",                      /* hostserv mode */
00025      "+iS",                     /* operserv mode */
00026      "+S",                      /* botserv mode  */
00027      "+Sh",                     /* helpserv mode */
00028      "+iS",                     /* Dev/Null mode */
00029      "+iS",                     /* Global mode   */
00030      "+o",                      /* nickserv alias mode */
00031      "+o",                      /* chanserv alias mode */
00032      "+o",                      /* memoserv alias mode */
00033      "+io",                     /* hostserv alias mode */
00034      "+io",                     /* operserv alias mode */
00035      "+o",                      /* botserv alias mode  */
00036      "+h",                      /* helpserv alias mode */
00037      "+i",                      /* Dev/Null alias mode */
00038      "+io",                     /* Global alias mode   */
00039      "+S",                      /* Used by BotServ Bots */
00040      5,                         /* Chan Max Symbols     */
00041      "-ilmnpqstRKAO",           /* Modes to Remove */
00042      "+o",                      /* 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      "+a",                      /* Mode to set for channel admin */
00049      "-a",                      /* Mode to unset for channel 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      "+d",                      /* Mode on Nick Change  */
00056      1,                         /* Supports SGlines     */
00057      1,                         /* Supports SQlines     */
00058      1,                         /* 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      1,                         /* Has Admin            */
00068      1,                         /* Chan SQlines         */
00069      0,                         /* Quit on Kill         */
00070      1,                         /* SVSMODE unban        */
00071      0,                         /* Has Protect          */
00072      0,                         /* Reverse              */
00073      1,                         /* Chan Reg             */
00074      CMODE_r,                   /* Channel Mode         */
00075      0,                         /* vidents              */
00076      0,                         /* svshold              */
00077      1,                         /* time stamp on mode   */
00078      1,                         /* NICKIP               */
00079      0,                         /* O:LINE               */
00080      1,                         /* UMODE               */
00081      1,                         /* VHOST ON NICK        */
00082      0,                         /* Change RealName      */
00083      CMODE_K,                   /* No Knock             */
00084      CMODE_A,                   /* Admin Only           */
00085      DEFAULT_MLOCK,             /* Default MLOCK       */
00086      UMODE_x,                   /* Vhost Mode           */
00087      0,                         /* +f                   */
00088      0,                         /* +L                   */
00089      0,                         /* +f Mode                          */
00090      0,                         /* +L Mode                              */
00091      1,                         /* On nick change check if they could be identified */
00092      1,                         /* No Knock requires +i */
00093      NULL,                      /* CAPAB Chan Modes             */
00094      0,                         /* We support TOKENS */
00095      1,                         /* 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      1,                         /* Sglines are enforced */
00103      "x",                       /* vhost char */
00104      0,                         /* ts6 */
00105      1,                         /* support helper umode */
00106      0,                         /* p10 */
00107      NULL,                      /* character set */
00108      1,                         /* 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 IRCDCAPAB myIrcdcap[] = {
00119     {
00120      CAPAB_NOQUIT,              /* NOQUIT       */
00121      CAPAB_TSMODE,              /* TSMODE       */
00122      CAPAB_UNCONNECT,           /* UNCONNECT    */
00123      0,                         /* NICKIP       */
00124      CAPAB_NSJOIN,              /* SJOIN        */
00125      CAPAB_ZIP,                 /* ZIP          */
00126      CAPAB_BURST,               /* BURST        */
00127      CAPAB_TS5,                 /* TS5          */
00128      0,                         /* TS3          */
00129      CAPAB_DKEY,                /* DKEY         */
00130      0,                         /* PT4          */
00131      0,                         /* SCS          */
00132      0,                         /* QS           */
00133      0,                         /* UID          */
00134      0,                         /* KNOCK        */
00135      CAPAB_CLIENT,              /* CLIENT       */
00136      CAPAB_IPV6,                /* IPV6         */
00137      CAPAB_SSJ5,                /* SSJ5         */
00138      0,                         /* SN2          */
00139      0,                         /* TOKEN        */
00140      0,                         /* VHOST        */
00141      0,                         /* SSJ3         */
00142      0,                         /* NICK2        */
00143      0,                         /* UMODE2       */
00144      0,                         /* VL           */
00145      0,                         /* TLKEXT       */
00146      CAPAB_DODKEY,              /* DODKEY       */
00147      CAPAB_DOZIP,               /* DOZIP        */
00148      0, 0, 0}
00149 };
00150 
00151 void ultimate3_set_umode(User * user, int ac, char **av)
00152 {
00153     int add = 1;                /* 1 if adding modes, 0 if deleting */
00154     char *modes = av[0];
00155 
00156     ac--;
00157 
00158     if (debug)
00159         alog("debug: Changing mode for %s to %s", user->nick, modes);
00160 
00161     while (*modes) {
00162 
00163         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00164          * At least this is readable without paying much attention :) -GD
00165          */
00166         if (add)
00167             user->mode |= umodes[(int) *modes];
00168         else
00169             user->mode &= ~umodes[(int) *modes];
00170 
00171         switch (*modes++) {
00172         case '+':
00173             add = 1;
00174             break;
00175         case '-':
00176             add = 0;
00177             break;
00178         case 'a':
00179             if (add && !is_services_oper(user)) {
00180                 common_svsmode(user, "-a", NULL);
00181                 user->mode &= ~UMODE_a;
00182             }
00183             break;
00184         case 'P':
00185             if (add && !is_services_admin(user)) {
00186                 common_svsmode(user, "-P", NULL);
00187                 user->mode &= ~UMODE_P;
00188             }
00189             break;
00190         case 'Z':
00191             if (add && !is_services_root(user)) {
00192                 common_svsmode(user, "-Z", NULL);
00193                 user->mode &= ~UMODE_Z;
00194             }
00195             break;
00196         case 'd':
00197             if (ac == 0) {
00198                 alog("user: umode +d with no parameter (?) for user %s",
00199                      user->nick);
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, "+Z", NULL);
00226                     user->mode |= UMODE_Z;
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,                    /* Unused */
00247     0, 0, 0,                    /* Unused */
00248     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00249     0, 0, 0,                    /* Line Feed, Unused, Unused */
00250     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00251     0, 0, 0,                    /* Unused */
00252     0, 0, 0,                    /* Unused */
00253     0, 0, 0,                    /* Unused */
00254     0, 0, 0,                    /* Unused */
00255     0, 0, 0,                    /* Unused */
00256     0, 0, 0,                    /* Unused, Unused, Space */
00257     0, 0, 0,                    /* ! " #  */
00258     0, 0, 0,                    /* $ % &  */
00259     0, 0, 0,                    /* ! ( )  */
00260     0, 0, 0,                    /* * + ,  */
00261     0, 0, 0,                    /* - . /  */
00262     0, 0,                       /* 0 1 */
00263     0, 0,                       /* 2 3 */
00264     0, 0,                       /* 4 5 */
00265     0, 0,                       /* 6 7 */
00266     0, 0,                       /* 8 9 */
00267     0, 0,                       /* : ; */
00268     0, 0, 0,                    /* < = > */
00269     0, 0,                       /* ? @ */
00270     UMODE_A, 0, 0,              /* A B C */
00271     UMODE_D, 0, 0,              /* D E F */
00272     0, 0, 0,                    /* G H I */
00273     0, 0, 0,                    /* J K L */
00274     0, 0, UMODE_0,              /* M N O */
00275     UMODE_P, 0, UMODE_R,        /* P Q R */
00276     UMODE_S, 0, 0,              /* S T U */
00277     0, UMODE_W, 0,              /* V W X */
00278     0,                          /* Y */
00279     UMODE_Z,                    /* Z */
00280     0, 0, 0,                    /* [ \ ] */
00281     0, 0, 0,                    /* ^ _ ` */
00282     UMODE_a, 0, 0,              /* a b c */
00283     UMODE_d, 0, 0,              /* d e f */
00284     0, UMODE_h, UMODE_i,        /* g h i */
00285     0, 0, 0,                    /* j k l */
00286     0, 0, UMODE_o,              /* m n o */
00287     UMODE_p, 0, UMODE_r,        /* p q r */
00288     0, 0, 0,                    /* s t u */
00289     0, UMODE_w, UMODE_x,        /* v w x */
00290     0,                          /* y */
00291     0,                          /* z */
00292     0, 0, 0,                    /* { | } */
00293     0, 0                        /* ~ � */
00294 };
00295 
00296 
00297 char myCsmodes[128] = {
00298     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00299     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00300 
00301     0,
00302     'a',                        /* (33) ! Channel Admins */
00303     0, 0, 0,
00304     'h',                        /* (37) % Channel halfops */
00305     0, 0, 0, 0,
00306     0,
00307 
00308     'v', 0, 0, 0, 0,
00309     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00310 
00311     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00312     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00313 
00314     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00315     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00316 };
00317 
00318 
00319 CMMode myCmmodes[128] = {
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}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00328     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00329     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00330     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00331     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00332     {NULL},
00333     {NULL},
00334     {add_ban, del_ban},
00335     {NULL},
00336     {NULL},
00337     {add_exception, del_exception},
00338     {NULL},
00339     {NULL},
00340     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00341     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00342     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00343 };
00344 
00345 
00346 CBMode myCbmodes[128] = {
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}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00351     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00352     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00353     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00354     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00355     {0},
00356     {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
00357     {0},                        /* B */
00358     {0},                        /* C */
00359     {0},                        /* D */
00360     {0},                        /* E */
00361     {0},                        /* F */
00362     {0},                        /* G */
00363     {0},                        /* H */
00364     {0},                        /* I */
00365     {0},                        /* J */
00366     {CMODE_K, 0, NULL, NULL},   /* K */
00367     {0},                        /* L */
00368     {CMODE_M, 0, NULL, NULL},   /* M */
00369     {CMODE_N, 0, NULL, NULL},   /* N */
00370     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00371     {0},                        /* P */
00372     {0},                        /* Q */
00373     {CMODE_R, 0, NULL, NULL},   /* R */
00374     {CMODE_S, 0, NULL, NULL},   /* S */
00375     {0},                        /* T */
00376     {0},                        /* U */
00377     {0},                        /* V */
00378     {0},                        /* W */
00379     {0},                        /* X */
00380     {0},                        /* Y */
00381     {0},                        /* Z */
00382     {0}, {0}, {0}, {0}, {0}, {0},
00383     {0},                        /* a */
00384     {0},                        /* b */
00385     {CMODE_c, 0, NULL, NULL},   /* c */
00386     {0},                        /* d */
00387     {0},                        /* e */
00388     {0},                        /* f */
00389     {0},                        /* g */
00390     {0},                        /* h */
00391     {CMODE_i, 0, NULL, NULL},   /* i */
00392     {0},                        /* j */
00393     {CMODE_k, 0, chan_set_key, cs_set_key},
00394     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00395     {CMODE_m, 0, NULL, NULL},   /* m */
00396     {CMODE_n, 0, NULL, NULL},   /* n */
00397     {0},                        /* o */
00398     {CMODE_p, 0, NULL, NULL},   /* p */
00399     {CMODE_q, 0, NULL, NULL},   /* q */
00400     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00401     {CMODE_s, 0, NULL, NULL},   /* s */
00402     {CMODE_t, 0, NULL, NULL},   /* t */
00403     {0},                        /* u */
00404     {0},                        /* v */
00405     {0},                        /* w */
00406     {0},                        /* x */
00407     {0},                        /* y */
00408     {0},                        /* z */
00409     {0}, {0}, {0}, {0}
00410 };
00411 
00412 CBModeInfo myCbmodeinfos[] = {
00413     {'c', CMODE_c, 0, NULL, NULL},
00414     {'i', CMODE_i, 0, NULL, NULL},
00415     {'k', CMODE_k, 0, get_key, cs_get_key},
00416     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00417     {'m', CMODE_m, 0, NULL, NULL},
00418     {'n', CMODE_n, 0, NULL, NULL},
00419     {'p', CMODE_p, 0, NULL, NULL},
00420     {'q', CMODE_q, 0, NULL, NULL},
00421     {'r', CMODE_r, 0, NULL, NULL},
00422     {'s', CMODE_s, 0, NULL, NULL},
00423     {'t', CMODE_t, 0, NULL, NULL},
00424     {'A', CMODE_A, 0, NULL, NULL},
00425     {'K', CMODE_K, 0, NULL, NULL},
00426     {'M', CMODE_M, 0, NULL, NULL},
00427     {'N', CMODE_N, 0, NULL, NULL},
00428     {'O', CMODE_O, 0, NULL, NULL},
00429     {'R', CMODE_R, 0, NULL, NULL},
00430     {'S', CMODE_S, 0, NULL, NULL},
00431     {0}
00432 };
00433 
00434 CUMode myCumodes[128] = {
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}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00446     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00447     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00448     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00449 
00450     {0},
00451 
00452     {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin},
00453     {0},                        /* b */
00454     {0},                        /* c */
00455     {0},                        /* d */
00456     {0},                        /* e */
00457     {0},                        /* f */
00458     {0},                        /* g */
00459     {CUS_HALFOP, 0, check_valid_op},
00460     {0},                        /* i */
00461     {0},                        /* j */
00462     {0},                        /* k */
00463     {0},                        /* l */
00464     {0},                        /* m */
00465     {0},                        /* n */
00466     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00467     {0},                        /* p */
00468     {0},                        /* q */
00469     {0},                        /* r */
00470     {0},                        /* s */
00471     {0},                        /* t */
00472     {0},                        /* u */
00473     {CUS_VOICE, 0, NULL},
00474     {0},                        /* w */
00475     {0},                        /* x */
00476     {0},                        /* y */
00477     {0},                        /* z */
00478     {0}, {0}, {0}, {0}, {0}
00479 };
00480 
00481 /* SVSMODE -b */
00482 void ultimate3_cmd_unban(char *name, char *nick)
00483 {
00484     ultimate3_cmd_svsmode_chan(name, "-b", nick);
00485 }
00486 
00487 
00488 /* SVSMODE channel modes */
00489 
00490 void ultimate3_cmd_svsmode_chan(char *name, char *mode, char *nick)
00491 {
00492     if (nick) {
00493         send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
00494     } else {
00495         send_cmd(ServerName, "SVSMODE %s %s", name, mode);
00496     }
00497 }
00498 
00499 int anope_event_sjoin(char *source, int ac, char **av)
00500 {
00501     do_sjoin(source, ac, av);
00502     return MOD_CONT;
00503 }
00504 
00505 
00506 /*
00507 ** NICK - new
00508 **      source  = NULL
00509 **      parv[0] = nickname
00510 **      parv[1] = hopcount
00511 **      parv[2] = timestamp
00512 **      parv[3] = modes
00513 **      parv[4] = username
00514 **      parv[5] = hostname
00515 **      parv[6] = server
00516 **      parv[7] = servicestamp
00517 **      parv[8] = IP
00518 **      parv[9] = info
00519 ** NICK - change 
00520 **      source  = oldnick
00521 **      parv[0] = new nickname
00522 **      parv[1] = hopcount
00523 */
00524 int anope_event_nick(char *source, int ac, char **av)
00525 {
00526     if (ac != 2) {
00527         User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
00528                              strtoul(av[2], NULL, 10), strtoul(av[7], NULL,
00529                                                                0),
00530                              strtoul(av[8], NULL, 0), "*", NULL);
00531         if (user)
00532             anope_set_umode(user, 1, &av[3]);
00533     } else {
00534         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00535                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00536     }
00537     return MOD_CONT;
00538 }
00539 
00540 int anope_event_sethost(char *source, int ac, char **av)
00541 {
00542     User *u;
00543 
00544     if (ac != 2)
00545         return MOD_CONT;
00546 
00547     u = finduser(av[0]);
00548     if (!u) {
00549         if (debug) {
00550             alog("debug: SETHOST for nonexistent user %s", av[0]);
00551         }
00552         return MOD_CONT;
00553     }
00554 
00555     change_user_host(u, av[1]);
00556     return MOD_CONT;
00557 }
00558 
00559 int anope_event_capab(char *source, int ac, char **av)
00560 {
00561     capab_parse(ac, av);
00562     return MOD_CONT;
00563 }
00564 
00565 /*
00566 ** CLIENT
00567 **      source  = NULL       
00568 **      parv[0] = nickname   Trystan
00569 **      parv[1] = hopcount   1
00570 **      parv[2] = timestamp  1090083810
00571 **      parv[3] = modes      +ix
00572 **      parv[4] = modes ?    +
00573 **      parv[5] = username   Trystan
00574 **      parv[6] = hostname   c-24-2-101-227.client.comcast.net
00575 **      parv[7] = vhost      3223f75b.2b32ee69.client.comcast.net
00576 **      parv[8] = server     WhiteRose.No.Eu.Shadow-Realm.org
00577 **      parv[9] = svid       0 
00578 **      parv[10] = ip         402810339
00579 **      parv[11] = info      Dreams are answers to questions not yet asked
00580 */
00581 int anope_event_client(char *source, int ac, char **av)
00582 {
00583     if (ac != 2) {
00584         User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11],
00585                              strtoul(av[2], NULL, 10), strtoul(av[9], NULL,
00586                                                                0),
00587                              strtoul(av[10], NULL, 0), av[7], NULL);
00588         if (user) {
00589             anope_set_umode(user, 1, &av[3]);
00590         }
00591     }
00592     return MOD_CONT;
00593 }
00594 
00595 /* *INDENT-OFF* */
00596 void moduleAddIRCDMsgs(void) {
00597     Message *m;
00598 
00599     updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a");
00600 
00601     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00602     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00603     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00604     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00605     m = createMessage("INVITE",    anope_event_invite); addCoreMessage(IRCD,m);
00606     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00607     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00608     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00609     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00610     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00611     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00612     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00613     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00614     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00615     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00616     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00617     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00618     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00619     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00620     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00621     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00622     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00623     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00624     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00625     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00626     m = createMessage("GNOTICE",   anope_event_gnotice); addCoreMessage(IRCD,m);
00627     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00628     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00629     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00630     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00631     m = createMessage("SVSMODE",   anope_event_mode); addCoreMessage(IRCD,m);
00632     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00633     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00634     m = createMessage("SQLINE",    anope_event_sqline); addCoreMessage(IRCD,m);
00635     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00636     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
00637     m = createMessage("CS",        anope_event_cs); addCoreMessage(IRCD,m);
00638     m = createMessage("HS",        anope_event_hs); addCoreMessage(IRCD,m);
00639     m = createMessage("MS",        anope_event_ms); addCoreMessage(IRCD,m);
00640     m = createMessage("NS",        anope_event_ns); addCoreMessage(IRCD,m);
00641     m = createMessage("OS",        anope_event_os); addCoreMessage(IRCD,m);
00642     m = createMessage("RS",        anope_event_null); addCoreMessage(IRCD,m);
00643     m = createMessage("SGLINE",    anope_event_null); addCoreMessage(IRCD,m);
00644     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
00645     m = createMessage("SS",        anope_event_null); addCoreMessage(IRCD,m);
00646     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
00647     m = createMessage("SZLINE",    anope_event_null); addCoreMessage(IRCD,m);
00648     m = createMessage("UNSGLINE",  anope_event_null); addCoreMessage(IRCD,m);
00649     m = createMessage("UNSZLINE",  anope_event_null); addCoreMessage(IRCD,m);
00650     m = createMessage("SETHOST",   anope_event_sethost); addCoreMessage(IRCD,m);
00651     m = createMessage("NETINFO",   anope_event_null); addCoreMessage(IRCD,m);
00652     m = createMessage("GCONNECT",  anope_event_null); addCoreMessage(IRCD,m);
00653     m = createMessage("NETGLOBAL", anope_event_netglobal); addCoreMessage(IRCD,m);
00654     m = createMessage("CHATOPS",   anope_event_null); addCoreMessage(IRCD,m);
00655     m = createMessage("NETCTRL",   anope_event_netctrl); addCoreMessage(IRCD,m);
00656     m = createMessage("CLIENT",    anope_event_client); addCoreMessage(IRCD,m);
00657     m = createMessage("SMODE",     anope_event_null); addCoreMessage(IRCD,m);
00658     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
00659     m = createMessage("BURST",     anope_event_burst); addCoreMessage(IRCD,m);
00660     m = createMessage("REHASH",    anope_event_rehash); addCoreMessage(IRCD,m);
00661     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00662     m = createMessage("CREDITS",   anope_event_credits); addCoreMessage(IRCD,m);
00663     m = createMessage("SMODE",     anope_event_mode); addCoreMessage(IRCD,m);
00664     m = createMessage("EOBURST",   anope_event_eob); addCoreMessage(IRCD,m);
00665 }
00666 
00667 /* *INDENT-ON* */
00668 
00669 
00670 void ultimate3_cmd_sqline(char *mask, char *reason)
00671 {
00672     if (!mask || !reason) {
00673         return;
00674     }
00675 
00676     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00677 }
00678 
00679 void ultimate3_cmd_unsgline(char *mask)
00680 {
00681     send_cmd(NULL, "UNSGLINE 0 :%s", mask);
00682 }
00683 
00684 void ultimate3_cmd_unszline(char *mask)
00685 {
00686     send_cmd(NULL, "UNSZLINE 0 %s", mask);
00687 }
00688 
00689 /* As of alpha27 (one after our offical support szline was removed */
00690 /* quote the changelog ---
00691    Complete rewrite of the kline/akill/zline system. (s)zlines no longer exist.
00692    K: lines set on IP addresses without username portions (or *) are treated as Z: lines used to be.
00693 */
00694 void ultimate3_cmd_szline(char *mask, char *reason, char *whom)
00695 {
00696     send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom,
00697              (long int) time(NULL), reason);
00698     /* leaving this in here in case some legacy user asks for it */
00699     /* send_cmd(NULL, "SZLINE %s :%s", mask, reason); */
00700 }
00701 
00702 void ultimate3_cmd_svsnoop(char *server, int set)
00703 {
00704     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00705 }
00706 
00707 void ultimate3_cmd_svsadmin(char *server, int set)
00708 {
00709     ultimate3_cmd_svsnoop(server, set);
00710 }
00711 
00712 void ultimate3_cmd_sgline(char *mask, char *reason)
00713 {
00714     send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason);
00715 }
00716 
00717 void ultimate3_cmd_remove_akill(char *user, char *host)
00718 {
00719     send_cmd(NULL, "RAKILL %s %s", host, user);
00720 }
00721 
00722 void ultimate3_cmd_vhost_off(User * u)
00723 {
00724     common_svsmode(u, "-x", NULL);
00725     notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
00726 }
00727 
00728 void ultimate3_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00729 {
00730     send_cmd(s_HostServ, "SVSMODE %s +x", nick);
00731     send_cmd(ServerName, "SETHOST %s %s", nick, vhost);
00732 }
00733 
00734 void ultimate3_cmd_join(char *user, char *channel, time_t chantime)
00735 {
00736     send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
00737 }
00738 
00739 void ultimate3_cmd_akill(char *user, char *host, char *who, time_t when,
00740                          time_t expires, char *reason)
00741 {
00742     send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
00743              (long int) time(NULL), reason);
00744 }
00745 
00746 void ultimate3_cmd_svskill(char *source, char *user, char *buf)
00747 {
00748     if (!buf) {
00749         return;
00750     }
00751 
00752     send_cmd(NULL, "SVSKILL %s :%s", user, buf);
00753 }
00754 
00755 
00756 void ultimate3_cmd_svsmode(User * u, int ac, char **av)
00757 {
00758     send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
00759              (long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
00760              (ac == 2 ? av[1] : ""));
00761 }
00762 
00763 void anope_squit(char *servname, char *message)
00764 {
00765     send_cmd(servname, "SQUIT %s :%s", servname, message);
00766 }
00767 
00768 void anope_pong(char *servname)
00769 {
00770     send_cmd(servname, "PONG %s", servname);
00771 }
00772 
00773 /* Events */
00774 
00775 int anope_event_ping(char *source, int ac, char **av)
00776 {
00777     if (ac < 1)
00778         return MOD_CONT;
00779     ultimate3_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
00780     return MOD_CONT;
00781 }
00782 
00783 int anope_event_436(char *source, int ac, char **av)
00784 {
00785     if (ac < 1)
00786         return MOD_CONT;
00787 
00788     m_nickcoll(av[0]);
00789     return MOD_CONT;
00790 }
00791 
00792 int anope_event_away(char *source, int ac, char **av)
00793 {
00794     if (!source) {
00795         return MOD_CONT;
00796     }
00797     m_away(source, (ac ? av[0] : NULL));
00798     return MOD_CONT;
00799 }
00800 
00801 int anope_event_topic(char *source, int ac, char **av)
00802 {
00803     if (ac != 4)
00804         return MOD_CONT;
00805     do_topic(source, ac, av);
00806     return MOD_CONT;
00807 }
00808 
00809 int anope_event_squit(char *source, int ac, char **av)
00810 {
00811     if (ac != 2)
00812         return MOD_CONT;
00813     do_squit(source, ac, av);
00814     return MOD_CONT;
00815 }
00816 
00817 int anope_event_quit(char *source, int ac, char **av)
00818 {
00819     if (ac != 1)
00820         return MOD_CONT;
00821     do_quit(source, ac, av);
00822     return MOD_CONT;
00823 }
00824 
00825 
00826 int anope_event_mode(char *source, int ac, char **av)
00827 {
00828     if (ac < 2)
00829         return MOD_CONT;
00830 
00831     if (*av[0] == '#' || *av[0] == '&') {
00832         do_cmode(source, ac, av);
00833     } else {
00834         do_umode(source, ac, av);
00835     }
00836     return MOD_CONT;
00837 }
00838 
00839 /* EVENT : OS */
00840 int anope_event_os(char *source, int ac, char **av)
00841 {
00842     if (ac < 1)
00843         return MOD_CONT;
00844     m_privmsg(source, s_OperServ, av[0]);
00845     return MOD_CONT;
00846 }
00847 
00848 /* EVENT : NS */
00849 int anope_event_ns(char *source, int ac, char **av)
00850 {
00851     if (ac < 1)
00852         return MOD_CONT;
00853     m_privmsg(source, s_NickServ, av[0]);
00854     return MOD_CONT;
00855 }
00856 
00857 /* EVENT : MS */
00858 int anope_event_ms(char *source, int ac, char **av)
00859 {
00860     if (ac < 1)
00861         return MOD_CONT;
00862     m_privmsg(source, s_MemoServ, av[0]);
00863     return MOD_CONT;
00864 }
00865 
00866 /* EVENT : HS */
00867 int anope_event_hs(char *source, int ac, char **av)
00868 {
00869     if (ac < 1)
00870         return MOD_CONT;
00871     m_privmsg(source, s_HostServ, av[0]);
00872     return MOD_CONT;
00873 }
00874 
00875 /* EVENT : CS */
00876 int anope_event_cs(char *source, int ac, char **av)
00877 {
00878     if (ac < 1)
00879         return MOD_CONT;
00880     m_privmsg(source, s_ChanServ, av[0]);
00881     return MOD_CONT;
00882 }
00883 
00884 
00885 int anope_event_kill(char *source, int ac, char **av)
00886 {
00887     if (ac != 2)
00888         return MOD_CONT;
00889 
00890     m_kill(av[0], av[1]);
00891     return MOD_CONT;
00892 }
00893 
00894 int anope_event_kick(char *source, int ac, char **av)
00895 {
00896     if (ac != 3)
00897         return MOD_CONT;
00898     do_kick(source, ac, av);
00899     return MOD_CONT;
00900 }
00901 
00902 
00903 int anope_event_join(char *source, int ac, char **av)
00904 {
00905     if (ac != 1)
00906         return MOD_CONT;
00907     do_join(source, ac, av);
00908     return MOD_CONT;
00909 }
00910 
00911 int anope_event_motd(char *source, int ac, char **av)
00912 {
00913     if (!source) {
00914         return MOD_CONT;
00915     }
00916 
00917     m_motd(source);
00918     return MOD_CONT;
00919 }
00920 
00921 int anope_event_setname(char *source, int ac, char **av)
00922 {
00923     User *u;
00924 
00925     if (ac != 1)
00926         return MOD_CONT;
00927 
00928     u = finduser(source);
00929     if (!u) {
00930         if (debug) {
00931             alog("debug: SETNAME for nonexistent user %s", source);
00932         }
00933         return MOD_CONT;
00934     }
00935 
00936     change_user_realname(u, av[0]);
00937     return MOD_CONT;
00938 }
00939 
00940 int anope_event_chgname(char *source, int ac, char **av)
00941 {
00942     User *u;
00943 
00944     if (ac != 2)
00945         return MOD_CONT;
00946 
00947     u = finduser(av[0]);
00948     if (!u) {
00949         if (debug) {
00950             alog("debug: CHGNAME for nonexistent user %s", av[0]);
00951         }
00952         return MOD_CONT;
00953     }
00954 
00955     change_user_realname(u, av[1]);
00956     return MOD_CONT;
00957 }
00958 
00959 int anope_event_setident(char *source, int ac, char **av)
00960 {
00961     User *u;
00962 
00963     if (ac != 1)
00964         return MOD_CONT;
00965 
00966     u = finduser(source);
00967     if (!u) {
00968         if (debug) {
00969             alog("debug: SETIDENT for nonexistent user %s", source);
00970         }
00971         return MOD_CONT;
00972     }
00973 
00974     change_user_username(u, av[0]);
00975     return MOD_CONT;
00976 }
00977 int anope_event_chgident(char *source, int ac, char **av)
00978 {
00979     User *u;
00980 
00981     if (ac != 2)
00982         return MOD_CONT;
00983 
00984     u = finduser(av[0]);
00985     if (!u) {
00986         if (debug) {
00987             alog("debug: CHGIDENT for nonexistent user %s", av[0]);
00988         }
00989         return MOD_CONT;
00990     }
00991 
00992     change_user_username(u, av[1]);
00993     return MOD_CONT;
00994 }
00995 
00996 /* EVENT: SERVER */
00997 int anope_event_server(char *source, int ac, char **av)
00998 {
00999     if (!stricmp(av[1], "1")) {
01000         uplink = sstrdup(av[0]);
01001     }
01002     do_server(source, av[0], av[1], av[2], NULL);
01003     return MOD_CONT;
01004 }
01005 
01006 
01007 int anope_event_privmsg(char *source, int ac, char **av)
01008 {
01009     if (ac != 2)
01010         return MOD_CONT;
01011     m_privmsg(source, av[0], av[1]);
01012     return MOD_CONT;
01013 }
01014 
01015 int anope_event_part(char *source, int ac, char **av)
01016 {
01017     if (ac < 1 || ac > 2)
01018         return MOD_CONT;
01019     do_part(source, ac, av);
01020     return MOD_CONT;
01021 }
01022 
01023 int anope_event_whois(char *source, int ac, char **av)
01024 {
01025     if (source && ac >= 1) {
01026         m_whois(source, av[0]);
01027     }
01028     return MOD_CONT;
01029 }
01030 
01031 void ultimate3_cmd_topic(char *whosets, char *chan, char *whosetit,
01032                          char *topic, time_t when)
01033 {
01034     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
01035              (unsigned long int) when, topic);
01036 }
01037 
01038 void ultimate3_cmd_372(char *source, char *msg)
01039 {
01040     send_cmd(ServerName, "372 %s :- %s", source, msg);
01041 }
01042 
01043 void ultimate3_cmd_372_error(char *source)
01044 {
01045     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
01046              "contact your IRC administrator.", source);
01047 }
01048 
01049 void ultimate3_cmd_375(char *source)
01050 {
01051     send_cmd(ServerName, "375 %s :- %s Message of the Day",
01052              source, ServerName);
01053 }
01054 
01055 void ultimate3_cmd_376(char *source)
01056 {
01057     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
01058 }
01059 
01060 void ultimate3_cmd_nick(char *nick, char *name, char *modes)
01061 {
01062     EnforceQlinedNick(nick, NULL);
01063     send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
01064              (long int) time(NULL), modes, ServiceUser, ServiceHost,
01065              ServerName, name);
01066     ultimate3_cmd_sqline(nick, "Reserved for services");
01067 }
01068 
01069 void ultimate3_cmd_guest_nick(char *nick, char *user, char *host,
01070                               char *real, char *modes)
01071 {
01072     send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
01073              (long int) time(NULL), modes, user, host, ServerName, real);
01074 }
01075 
01076 void ultimate3_cmd_mode(char *source, char *dest, char *buf)
01077 {
01078     if (!buf) {
01079         return;
01080     }
01081 
01082     send_cmd(source, "MODE %s %s", dest, buf);
01083 }
01084 
01085 void ultimate3_cmd_bot_nick(char *nick, char *user, char *host, char *real,
01086                             char *modes)
01087 {
01088     EnforceQlinedNick(nick, s_BotServ);
01089     send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick,
01090              (long int) time(NULL), modes, user, host, ServerName, real);
01091     ultimate3_cmd_sqline(nick, "Reserved for services");
01092 }
01093 
01094 void ultimate3_cmd_kick(char *source, char *chan, char *user, char *buf)
01095 {
01096     if (buf) {
01097         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
01098     } else {
01099         send_cmd(source, "KICK %s %s", chan, user);
01100     }
01101 }
01102 
01103 void ultimate3_cmd_notice_ops(char *source, char *dest, char *buf)
01104 {
01105     if (!buf) {
01106         return;
01107     }
01108 
01109     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
01110 }
01111 
01112 
01113 void ultimate3_cmd_notice(char *source, char *dest, char *buf)
01114 {
01115     if (!buf) {
01116         return;
01117     }
01118 
01119     if (NSDefFlags & NI_MSG) {
01120         ultimate3_cmd_privmsg2(source, dest, buf);
01121     } else {
01122         send_cmd(source, "NOTICE %s :%s", dest, buf);
01123     }
01124 }
01125 
01126 void ultimate3_cmd_notice2(char *source, char *dest, char *msg)
01127 {
01128     send_cmd(source, "NOTICE %s :%s", dest, msg);
01129 }
01130 
01131 void ultimate3_cmd_privmsg(char *source, char *dest, char *buf)
01132 {
01133     if (!buf) {
01134         return;
01135     }
01136 
01137     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
01138 }
01139 
01140 void ultimate3_cmd_privmsg2(char *source, char *dest, char *msg)
01141 {
01142     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
01143 }
01144 
01145 void ultimate3_cmd_serv_notice(char *source, char *dest, char *msg)
01146 {
01147     send_cmd(source, "NOTICE $%s :%s", dest, msg);
01148 }
01149 
01150 void ultimate3_cmd_serv_privmsg(char *source, char *dest, char *msg)
01151 {
01152     send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
01153 }
01154 
01155 void ultimate3_cmd_bot_chan_mode(char *nick, char *chan)
01156 {
01157     anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
01158 }
01159 
01160 void ultimate3_cmd_351(char *source)
01161 {
01162     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01163              source, version_number, ServerName, ircd->name, version_flags,
01164              EncModule,version_build);
01165 
01166 }
01167 
01168 /* QUIT */
01169 void ultimate3_cmd_quit(char *source, char *buf)
01170 {
01171     if (!buf) {
01172         return;
01173     }
01174 
01175     if (buf) {
01176         send_cmd(source, "QUIT :%s", buf);
01177     } else {
01178         send_cmd(source, "QUIT");
01179     }
01180 }
01181 
01182 /* PROTOCTL */
01183 void ultimate3_cmd_capab()
01184 {
01185     send_cmd(NULL,
01186              "CAPAB TS5 NOQUIT SSJ5 BURST UNCONNECT TSMODE NICKIP CLIENT");
01187 }
01188 
01189 /* PASS */
01190 void ultimate3_cmd_pass(char *pass)
01191 {
01192     send_cmd(NULL, "PASS %s :TS", pass);
01193 }
01194 
01195 /* SERVER name hop descript */
01196 /* Unreal 3.2 actually sends some info about itself in the descript area */
01197 void ultimate3_cmd_server(char *servname, int hop, char *descript)
01198 {
01199     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
01200 }
01201 
01202 /* PONG */
01203 void ultimate3_cmd_pong(char *servname, char *who)
01204 {
01205     send_cmd(servname, "PONG %s", who);
01206 }
01207 
01208 /* UNSQLINE */
01209 void ultimate3_cmd_unsqline(char *user)
01210 {
01211     if (!user) {
01212         return;
01213     }
01214     send_cmd(NULL, "UNSQLINE %s", user);
01215 }
01216 
01217 /* CHGHOST */
01218 void ultimate3_cmd_chghost(char *nick, char *vhost)
01219 {
01220     if (!nick || !vhost) {
01221         return;
01222     }
01223     send_cmd(ServerName, "CHGHOST %s %s", nick, vhost);
01224 }
01225 
01226 /* CHGIDENT */
01227 void ultimate3_cmd_chgident(char *nick, char *vIdent)
01228 {
01229     if (!nick || !vIdent) {
01230         return;
01231     }
01232     send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent);
01233 }
01234 
01235 /* INVITE */
01236 void ultimate3_cmd_invite(char *source, char *chan, char *nick)
01237 {
01238     if (!source || !chan || !nick) {
01239         return;
01240     }
01241 
01242     send_cmd(source, "INVITE %s %s", nick, chan);
01243 }
01244 
01245 /* PART */
01246 void ultimate3_cmd_part(char *nick, char *chan, char *buf)
01247 {
01248 
01249     if (!nick || !chan) {
01250         return;
01251     }
01252 
01253     if (buf) {
01254         send_cmd(nick, "PART %s :%s", chan, buf);
01255     } else {
01256         send_cmd(nick, "PART %s", chan);
01257     }
01258 }
01259 
01260 /* 391 */
01261 void ultimate3_cmd_391(char *source, char *timestr)
01262 {
01263     if (!timestr) {
01264         return;
01265     }
01266     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
01267 }
01268 
01269 /* 250 */
01270 void ultimate3_cmd_250(char *buf)
01271 {
01272     if (!buf) {
01273         return;
01274     }
01275 
01276     send_cmd(NULL, "250 %s", buf);
01277 }
01278 
01279 /* 307 */
01280 void ultimate3_cmd_307(char *buf)
01281 {
01282     if (!buf) {
01283         return;
01284     }
01285 
01286     send_cmd(ServerName, "307 %s", buf);
01287 }
01288 
01289 /* 311 */
01290 void ultimate3_cmd_311(char *buf)
01291 {
01292     if (!buf) {
01293         return;
01294     }
01295 
01296     send_cmd(ServerName, "311 %s", buf);
01297 }
01298 
01299 /* 312 */
01300 void ultimate3_cmd_312(char *buf)
01301 {
01302     if (!buf) {
01303         return;
01304     }
01305 
01306     send_cmd(ServerName, "312 %s", buf);
01307 }
01308 
01309 /* 317 */
01310 void ultimate3_cmd_317(char *buf)
01311 {
01312     if (!buf) {
01313         return;
01314     }
01315 
01316     send_cmd(ServerName, "317 %s", buf);
01317 }
01318 
01319 /* 219 */
01320 void ultimate3_cmd_219(char *source, char *letter)
01321 {
01322     if (!source) {
01323         return;
01324     }
01325 
01326     if (letter) {
01327         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
01328                  *letter);
01329     } else {
01330         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
01331     }
01332 }
01333 
01334 /* 401 */
01335 void ultimate3_cmd_401(char *source, char *who)
01336 {
01337     if (!source || !who) {
01338         return;
01339     }
01340     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
01341 }
01342 
01343 /* 318 */
01344 void ultimate3_cmd_318(char *source, char *who)
01345 {
01346     if (!source || !who) {
01347         return;
01348     }
01349 
01350     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01351 }
01352 
01353 /* 242 */
01354 void ultimate3_cmd_242(char *buf)
01355 {
01356     if (!buf) {
01357         return;
01358     }
01359 
01360     send_cmd(NULL, "242 %s", buf);
01361 }
01362 
01363 /* 243 */
01364 void ultimate3_cmd_243(char *buf)
01365 {
01366     if (!buf) {
01367         return;
01368     }
01369 
01370     send_cmd(NULL, "243 %s", buf);
01371 }
01372 
01373 /* 211 */
01374 void ultimate3_cmd_211(char *buf)
01375 {
01376     if (!buf) {
01377         return;
01378     }
01379 
01380     send_cmd(NULL, "211 %s", buf);
01381 }
01382 
01383 /* GLOBOPS */
01384 void ultimate3_cmd_global(char *source, char *buf)
01385 {
01386     if (!buf) {
01387         return;
01388     }
01389 
01390     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
01391 }
01392 
01393 /* SQUIT */
01394 void ultimate3_cmd_squit(char *servname, char *message)
01395 {
01396     if (!servname || !message) {
01397         return;
01398     }
01399 
01400     send_cmd(NULL, "SQUIT %s :%s", servname, message);
01401 }
01402 
01403 /* SVSO */
01404 void ultimate3_cmd_svso(char *source, char *nick, char *flag)
01405 {
01406     if (!source || !nick || !flag) {
01407         return;
01408     }
01409 
01410     send_cmd(source, "SVSO %s %s", nick, flag);
01411 }
01412 
01413 /* NICK <newnick>  */
01414 void ultimate3_cmd_chg_nick(char *oldnick, char *newnick)
01415 {
01416     if (!oldnick || !newnick) {
01417         return;
01418     }
01419 
01420     send_cmd(oldnick, "NICK %s", newnick);
01421 }
01422 
01423 /* SVSNICK */
01424 void ultimate3_cmd_svsnick(char *source, char *guest, time_t when)
01425 {
01426     if (!source || !guest) {
01427         return;
01428     }
01429     send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
01430 }
01431 
01432 /* Functions that use serval cmd functions */
01433 /*
01434  * SVINFO 
01435  *       parv[0] = sender prefix 
01436  *       parv[1] = TS_CURRENT for the server 
01437  *       parv[2] = TS_MIN for the server 
01438  *       parv[3] = server is standalone or connected to non-TS only 
01439  *       parv[4] = server's idea of UTC time
01440  */
01441 void ultimate3_cmd_svinfo()
01442 {
01443     send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL));
01444 }
01445 
01446 void ultimate3_cmd_burst()
01447 {
01448     send_cmd(NULL, "BURST");
01449 }
01450 
01451 
01452 void ultimate3_cmd_connect(int servernum)
01453 {
01454     me_server =
01455         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
01456 
01457     if (servernum == 1) {
01458         ultimate3_cmd_pass(RemotePassword);
01459     }
01460     if (servernum == 2) {
01461         ultimate3_cmd_pass(RemotePassword2);
01462     }
01463     if (servernum == 3) {
01464         ultimate3_cmd_pass(RemotePassword3);
01465     }
01466     ultimate3_cmd_capab();
01467     ultimate3_cmd_server(ServerName, 1, ServerDesc);
01468     ultimate3_cmd_svinfo();
01469     ultimate3_cmd_burst();
01470 }
01471 
01472 void ultimate3_cmd_bob()
01473 {
01474     /* Not used */
01475 }
01476 
01477 /* SVSHOLD - set */
01478 void ultimate3_cmd_svshold(char *nick)
01479 {
01480     /* Not supported by this IRCD */
01481 }
01482 
01483 /* SVSHOLD - release */
01484 void ultimate3_cmd_release_svshold(char *nick)
01485 {
01486     /* Not Supported by this IRCD */
01487 }
01488 
01489 /* SVSMODE +d */
01490 /* sent if svid is something weird */
01491 void ultimate3_cmd_svid_umode(char *nick, time_t ts)
01492 {
01493     send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
01494              (unsigned long int) ts);
01495 }
01496 
01497 /* SVSMODE +d */
01498 /* nc_change was = 1, and there is no na->status */
01499 void ultimate3_cmd_nc_change(User * u)
01500 {
01501     common_svsmode(u, "+d", "1");
01502 }
01503 
01504 /* SVSMODE +d */
01505 void ultimate3_cmd_svid_umode2(User * u, char *ts)
01506 {
01507     /* not used by bahamut ircds */
01508 }
01509 
01510 void ultimate3_cmd_svid_umode3(User * u, char *ts)
01511 {
01512     if (u->svid != u->timestamp) {
01513         common_svsmode(u, "+rd", ts);
01514     } else {
01515         common_svsmode(u, "+r", NULL);
01516     }
01517 
01518 }
01519 
01520 int anope_event_svinfo(char *source, int ac, char **av)
01521 {
01522     /* currently not used but removes the message : unknown message from server */
01523     return MOD_CONT;
01524 }
01525 
01526 int anope_event_pass(char *source, int ac, char **av)
01527 {
01528     /* currently not used but removes the message : unknown message from server */
01529     return MOD_CONT;
01530 }
01531 
01532 int anope_event_gnotice(char *source, int ac, char **av)
01533 {
01534     /* currently not used but removes the message : unknown message from server */
01535     return MOD_CONT;
01536 }
01537 
01538 int anope_event_netctrl(char *source, int ac, char **av)
01539 {
01540     /* currently not used but removes the message : unknown message from server */
01541     return MOD_CONT;
01542 }
01543 
01544 int anope_event_notice(char *source, int ac, char **av)
01545 {
01546     /* currently not used but removes the message : unknown message from server */
01547     return MOD_CONT;
01548 }
01549 
01550 int anope_event_sqline(char *source, int ac, char **av)
01551 {
01552     /* currently not used but removes the message : unknown message from server */
01553     return MOD_CONT;
01554 }
01555 
01556 /*
01557  * svsjoin
01558  *
01559  * parv[0] - sender
01560  * parv[1] - nick to make join
01561  * parv[2] - channel(s) to join
01562  */
01563 void ultimate3_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
01564 {
01565     send_cmd(source, "SVSJOIN %s %s", nick, chan);
01566 }
01567 
01568 /*
01569  * svspart
01570  *
01571  * parv[0] - sender
01572  * parv[1] - nick to make part
01573  * parv[2] - channel(s) to part
01574  */
01575 void ultimate3_cmd_svspart(char *source, char *nick, char *chan)
01576 {
01577     send_cmd(source, "SVSPART %s %s", nick, chan);
01578 }
01579 
01580 void ultimate3_cmd_swhois(char *source, char *who, char *mask)
01581 {
01582     /* not supported */
01583 }
01584 
01585 
01586 void ultimate3_cmd_eob()
01587 {
01588     send_cmd(NULL, "BURST 0");
01589 }
01590 
01591 int anope_event_error(char *source, int ac, char **av)
01592 {
01593     if (ac >= 1) {
01594         if (debug) {
01595             alog("debug: %s", av[0]);
01596         }
01597     }
01598     return MOD_CONT;
01599 }
01600 
01601 
01602 int anope_event_eob(char *source, int ac, char **av)
01603 {
01604     Server *s;
01605 
01606     if (ac == 1) {
01607         s = findserver(servlist, av[0]);
01608         /* If we found a server with the given source, that one just
01609          * finished bursting. If there was no source, then our uplink
01610          * server finished bursting. -GD
01611          */
01612         if (!s && serv_uplink)
01613             s = serv_uplink;
01614         finish_sync(s, 1);
01615     }
01616     return MOD_CONT;
01617 }
01618 
01619 
01620 int anope_event_burst(char *source, int ac, char **av)
01621 {
01622     Server *s;
01623     s = findserver(servlist, source);
01624     if (!ac) {
01625         /* for future use  - start burst */
01626     } else {
01627         /* If we found a server with the given source, that one just
01628          * finished bursting. If there was no source, then our uplink
01629          * server finished bursting. -GD
01630          */
01631         if (!s && serv_uplink)
01632             s = serv_uplink;
01633         finish_sync(s, 1);
01634     }
01635     return MOD_CONT;
01636 }
01637 
01638 int anope_event_rehash(char *source, int ac, char **av)
01639 {
01640     return MOD_CONT;
01641 }
01642 
01643 int anope_event_credits(char *source, int ac, char **av)
01644 {
01645     return MOD_CONT;
01646 }
01647 
01648 int anope_event_admin(char *source, int ac, char **av)
01649 {
01650     return MOD_CONT;
01651 }
01652 
01653 int anope_event_netglobal(char *source, int ac, char **av)
01654 {
01655     return MOD_CONT;
01656 }
01657 
01658 int anope_event_invite(char *source, int ac, char **av)
01659 {
01660     return MOD_CONT;
01661 }
01662 
01663 int ultiamte3_flood_mode_check(char *value)
01664 {
01665     return 0;
01666 }
01667 
01668 void ultimate3_cmd_jupe(char *jserver, char *who, char *reason)
01669 {
01670     char rbuf[256];
01671 
01672     snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
01673              reason ? ": " : "", reason ? reason : "");
01674 
01675     if (findserver(servlist, jserver))
01676         ultimate3_cmd_squit(jserver, rbuf);
01677     ultimate3_cmd_server(jserver, 2, rbuf);
01678     new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
01679 }
01680 
01681 /* GLOBOPS - to handle old WALLOPS */
01682 void ultimate3_cmd_global_legacy(char *source, char *fmt)
01683 {
01684     send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
01685 }
01686 
01687 /* 
01688   1 = valid nick
01689   0 = nick is in valid
01690 */
01691 int ultiamte3_valid_nick(char *nick)
01692 {
01693     /* no hard coded invalid nicks */
01694     return 1;
01695 }
01696 
01697 /* 
01698   1 = valid chan
01699   0 = chan is in valid
01700 */
01701 int ultiamte3_valid_chan(char *chan)
01702 {
01703     /* no hard coded invalid chans */
01704     return 1;
01705 }
01706 
01707 
01708 void ultimate3_cmd_ctcp(char *source, char *dest, char *buf)
01709 {
01710     char *s;
01711 
01712     if (!buf) {
01713         return;
01714     } else {
01715         s = normalizeBuffer(buf);
01716     }
01717 
01718     send_cmd(source, "NOTICE %s :\1%s \1", dest, s);
01719     free(s);
01720 }
01721 
01722 
01727 void moduleAddAnopeCmds()
01728 {
01729     pmodule_cmd_svsnoop(ultimate3_cmd_svsnoop);
01730     pmodule_cmd_remove_akill(ultimate3_cmd_remove_akill);
01731     pmodule_cmd_topic(ultimate3_cmd_topic);
01732     pmodule_cmd_vhost_off(ultimate3_cmd_vhost_off);
01733     pmodule_cmd_akill(ultimate3_cmd_akill);
01734     pmodule_cmd_svskill(ultimate3_cmd_svskill);
01735     pmodule_cmd_svsmode(ultimate3_cmd_svsmode);
01736     pmodule_cmd_372(ultimate3_cmd_372);
01737     pmodule_cmd_372_error(ultimate3_cmd_372_error);
01738     pmodule_cmd_375(ultimate3_cmd_375);
01739     pmodule_cmd_376(ultimate3_cmd_376);
01740     pmodule_cmd_nick(ultimate3_cmd_nick);
01741     pmodule_cmd_guest_nick(ultimate3_cmd_guest_nick);
01742     pmodule_cmd_mode(ultimate3_cmd_mode);
01743     pmodule_cmd_bot_nick(ultimate3_cmd_bot_nick);
01744     pmodule_cmd_kick(ultimate3_cmd_kick);
01745     pmodule_cmd_notice_ops(ultimate3_cmd_notice_ops);
01746     pmodule_cmd_notice(ultimate3_cmd_notice);
01747     pmodule_cmd_notice2(ultimate3_cmd_notice2);
01748     pmodule_cmd_privmsg(ultimate3_cmd_privmsg);
01749     pmodule_cmd_privmsg2(ultimate3_cmd_privmsg2);
01750     pmodule_cmd_serv_notice(ultimate3_cmd_serv_notice);
01751     pmodule_cmd_serv_privmsg(ultimate3_cmd_serv_privmsg);
01752     pmodule_cmd_bot_chan_mode(ultimate3_cmd_bot_chan_mode);
01753     pmodule_cmd_351(ultimate3_cmd_351);
01754     pmodule_cmd_quit(ultimate3_cmd_quit);
01755     pmodule_cmd_pong(ultimate3_cmd_pong);
01756     pmodule_cmd_join(ultimate3_cmd_join);
01757     pmodule_cmd_unsqline(ultimate3_cmd_unsqline);
01758     pmodule_cmd_invite(ultimate3_cmd_invite);
01759     pmodule_cmd_part(ultimate3_cmd_part);
01760     pmodule_cmd_391(ultimate3_cmd_391);
01761     pmodule_cmd_250(ultimate3_cmd_250);
01762     pmodule_cmd_307(ultimate3_cmd_307);
01763     pmodule_cmd_311(ultimate3_cmd_311);
01764     pmodule_cmd_312(ultimate3_cmd_312);
01765     pmodule_cmd_317(ultimate3_cmd_317);
01766     pmodule_cmd_219(ultimate3_cmd_219);
01767     pmodule_cmd_401(ultimate3_cmd_401);
01768     pmodule_cmd_318(ultimate3_cmd_318);
01769     pmodule_cmd_242(ultimate3_cmd_242);
01770     pmodule_cmd_243(ultimate3_cmd_243);
01771     pmodule_cmd_211(ultimate3_cmd_211);
01772     pmodule_cmd_global(ultimate3_cmd_global);
01773     pmodule_cmd_global_legacy(ultimate3_cmd_global_legacy);
01774     pmodule_cmd_sqline(ultimate3_cmd_sqline);
01775     pmodule_cmd_squit(ultimate3_cmd_squit);
01776     pmodule_cmd_svso(ultimate3_cmd_svso);
01777     pmodule_cmd_chg_nick(ultimate3_cmd_chg_nick);
01778     pmodule_cmd_svsnick(ultimate3_cmd_svsnick);
01779     pmodule_cmd_vhost_on(ultimate3_cmd_vhost_on);
01780     pmodule_cmd_connect(ultimate3_cmd_connect);
01781     pmodule_cmd_bob(ultimate3_cmd_bob);
01782     pmodule_cmd_svshold(ultimate3_cmd_svshold);
01783     pmodule_cmd_release_svshold(ultimate3_cmd_release_svshold);
01784     pmodule_cmd_unsgline(ultimate3_cmd_unsgline);
01785     pmodule_cmd_unszline(ultimate3_cmd_unszline);
01786     pmodule_cmd_szline(ultimate3_cmd_szline);
01787     pmodule_cmd_sgline(ultimate3_cmd_sgline);
01788     pmodule_cmd_unban(ultimate3_cmd_unban);
01789     pmodule_cmd_svsmode_chan(ultimate3_cmd_svsmode_chan);
01790     pmodule_cmd_svid_umode(ultimate3_cmd_svid_umode);
01791     pmodule_cmd_nc_change(ultimate3_cmd_nc_change);
01792     pmodule_cmd_svid_umode2(ultimate3_cmd_svid_umode2);
01793     pmodule_cmd_svid_umode3(ultimate3_cmd_svid_umode3);
01794     pmodule_cmd_svsjoin(ultimate3_cmd_svsjoin);
01795     pmodule_cmd_svspart(ultimate3_cmd_svspart);
01796     pmodule_cmd_swhois(ultimate3_cmd_swhois);
01797     pmodule_cmd_eob(ultimate3_cmd_eob);
01798     pmodule_flood_mode_check(ultiamte3_flood_mode_check);
01799     pmodule_cmd_jupe(ultimate3_cmd_jupe);
01800     pmodule_valid_nick(ultiamte3_valid_nick);
01801     pmodule_valid_chan(ultiamte3_valid_chan);
01802     pmodule_cmd_ctcp(ultimate3_cmd_ctcp);
01803     pmodule_set_umode(ultimate3_set_umode);
01804 }
01805 
01809 int AnopeInit(int argc, char **argv)
01810 {
01811 
01812     moduleAddAuthor("Anope");
01813     moduleAddVersion
01814         (VERSION_STRING);
01815     moduleSetType(PROTOCOL);
01816 
01817     pmodule_ircd_version("UltimateIRCd 3.0.0.a26+");
01818     pmodule_ircd_cap(myIrcdcap);
01819     pmodule_ircd_var(myIrcd);
01820     pmodule_ircd_cbmodeinfos(myCbmodeinfos);
01821     pmodule_ircd_cumodes(myCumodes);
01822     pmodule_ircd_flood_mode_char_set("");
01823     pmodule_ircd_flood_mode_char_remove("");
01824     pmodule_ircd_cbmodes(myCbmodes);
01825     pmodule_ircd_cmmodes(myCmmodes);
01826     pmodule_ircd_csmodes(myCsmodes);
01827     pmodule_ircd_useTSMode(0);
01828 
01830     pmodule_invis_umode(UMODE_i);
01831     pmodule_oper_umode(UMODE_o);
01832     pmodule_invite_cmode(CMODE_i);
01833     pmodule_secret_cmode(CMODE_s);
01834     pmodule_private_cmode(CMODE_p);
01835     pmodule_key_mode(CMODE_k);
01836     pmodule_limit_mode(CMODE_l);
01837     pmodule_permchan_mode(0);
01838 
01839     moduleAddAnopeCmds();
01840     moduleAddIRCDMsgs();
01841 
01842     return MOD_CONT;
01843 }