bahamut.c

Go to the documentation of this file.
00001 /* Bahamut functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 
00014 /*************************************************************************/
00015 
00016 #include "services.h"
00017 #include "pseudo.h"
00018 #include "bahamut.h"
00019 
00020 IRCDVar myIrcd[] = {
00021     {"BahamutIRCd 1.4.*/1.8.*", /* ircd name */
00022      "+o",                      /* nickserv mode */
00023      "+o",                      /* chanserv mode */
00024      "+o",                      /* memoserv mode */
00025      "+",                       /* hostserv mode */
00026      "+io",                     /* operserv mode */
00027      "+o",                      /* botserv mode  */
00028      "+h",                      /* helpserv mode */
00029      "+i",                      /* Dev/Null mode */
00030      "+io",                     /* Global mode   */
00031      "+o",                      /* nickserv alias mode */
00032      "+o",                      /* chanserv alias mode */
00033      "+o",                      /* memoserv alias mode */
00034      "+",                       /* hostserv alias mode */
00035      "+io",                     /* operserv alias mode */
00036      "+o",                      /* botserv alias mode  */
00037      "+h",                      /* helpserv alias mode */
00038      "+i",                      /* Dev/Null alias mode */
00039      "+io",                     /* Global alias mode   */
00040      "+",                       /* Used by BotServ Bots */
00041      2,                         /* Chan Max Symbols     */
00042      "-cilmnpstOR",             /* Modes to Remove */
00043      "+o",                      /* Channel Umode used by Botserv bots */
00044      1,                         /* SVSNICK */
00045      0,                         /* Vhost  */
00046      0,                         /* Has Owner */
00047      NULL,                      /* Mode to set for an owner */
00048      NULL,                      /* Mode to unset for an owner */
00049      NULL,                      /* Mode to set for channel admin */
00050      NULL,                      /* Mode to unset for channel admin */
00051      "+rd",                     /* Mode On Reg          */
00052      NULL,                      /* Mode on ID for Roots */
00053      NULL,                      /* Mode on ID for Admins */
00054      NULL,                      /* Mode on ID for Opers */
00055      "-r+d",                    /* Mode on UnReg        */
00056      "+d",                      /* Mode on Nick Change  */
00057      1,                         /* Supports SGlines     */
00058      1,                         /* Supports SQlines     */
00059      1,                         /* Supports SZlines     */
00060      0,                         /* Supports Halfop +h   */
00061      3,                         /* Number of server args */
00062      0,                         /* Join 2 Set           */
00063      0,                         /* Join 2 Message       */
00064      1,                         /* Has exceptions +e    */
00065      0,                         /* TS Topic Forward     */
00066      0,                         /* TS Topci Backward    */
00067      0,                         /* Protected Umode      */
00068      0,                         /* Has Admin            */
00069      1,                         /* Chan SQlines         */
00070      1,                         /* Quit on Kill         */
00071      1,                         /* SVSMODE unban        */
00072      0,                         /* Has Protect          */
00073      0,                         /* Reverse              */
00074      1,                         /* Chan Reg             */
00075      CMODE_r,                   /* Channel Mode         */
00076      0,                         /* vidents              */
00077      1,                         /* svshold              */
00078      1,                         /* time stamp on mode   */
00079      1,                         /* NICKIP               */
00080      0,                         /* O:LINE               */
00081      1,                         /* UMODE               */
00082      0,                         /* VHOST ON NICK        */
00083      0,                         /* Change RealName      */
00084      0,                         /* No Knock             */
00085      0,                         /* Admin Only           */
00086      DEFAULT_MLOCK,             /* Default MLOCK       */
00087      0,                         /* Vhost Mode           */
00088      1,                         /* +f                   */
00089      0,                         /* +L                   */
00090      CMODE_j,                   /* Mode */
00091      0,                         /* Mode */
00092      1,
00093      1,                         /* No Knock requires +i */
00094      NULL,                      /* CAPAB Chan Modes             */
00095      0,                         /* We support TOKENS */
00096      1,                         /* TOKENS are CASE inSensitive */
00097      0,                         /* TIME STAMPS are BASE64 */
00098      1,                         /* +I support */
00099      0,                         /* SJOIN ban char */
00100      0,                         /* SJOIN except char */
00101      0,                         /* SJOIN invite char */
00102      0,                         /* Can remove User Channel Modes with SVSMODE */
00103      0,                         /* Sglines are not enforced until user reconnects */
00104      NULL,                      /* vhost char */
00105      0,                         /* ts6 */
00106      1,                         /* support helper umode */
00107      0,                         /* p10 */
00108      NULL,                      /* character set */
00109      1,                         /* reports sync state */
00110      }
00111     ,
00112     {NULL}
00113 };
00114 
00115 IRCDCAPAB myIrcdcap[] = {
00116     {
00117      CAPAB_NOQUIT,              /* NOQUIT       */
00118      CAPAB_TSMODE,              /* TSMODE       */
00119      CAPAB_UNCONNECT,           /* UNCONNECT    */
00120      0,                         /* NICKIP       */
00121      0,                         /* SJOIN        */
00122      0,                         /* ZIP          */
00123      CAPAB_BURST,               /* BURST        */
00124      0,                         /* TS5          */
00125      0,                         /* TS3          */
00126      CAPAB_DKEY,                /* DKEY         */
00127      0,                         /* PT4          */
00128      0,                         /* SCS          */
00129      0,                         /* QS           */
00130      0,                         /* UID          */
00131      0,                         /* KNOCK        */
00132      0,                         /* CLIENT       */
00133      0,                         /* IPV6         */
00134      0,                         /* SSJ5         */
00135      0,                         /* SN2          */
00136      0,                         /* TOKEN        */
00137      0,                         /* VHOST        */
00138      0,                         /* SSJ3         */
00139      0,                         /* NICK2        */
00140      0,                         /* UMODE2       */
00141      0,                         /* VL           */
00142      0,                         /* TLKEXT       */
00143      0,                         /* DODKEY       */
00144      CAPAB_DOZIP,               /* DOZIP        */
00145      0, 0, 0}
00146 };
00147 
00148 
00149 void bahamut_set_umode(User * user, int ac, char **av)
00150 {
00151     int add = 1;                /* 1 if adding modes, 0 if deleting */
00152     char *modes = av[0];
00153 
00154     ac--;
00155 
00156     if (debug)
00157         alog("debug: Changing mode for %s to %s", user->nick, modes);
00158 
00159     while (*modes) {
00160 
00161         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00162          * At least this is readable without paying much attention :) -GD
00163          */
00164         if (add)
00165             user->mode |= umodes[(int) *modes];
00166         else
00167             user->mode &= ~umodes[(int) *modes];
00168 
00169         switch (*modes++) {
00170         case '+':
00171             add = 1;
00172             break;
00173         case '-':
00174             add = 0;
00175             break;
00176         case 'a':
00177             if (UnRestrictSAdmin) {
00178                 break;
00179             }
00180             if (add && !is_services_admin(user)) {
00181                 common_svsmode(user, "-a", NULL);
00182                 user->mode &= ~UMODE_a;
00183             }
00184             break;
00185         case 'd':
00186             if (ac == 0) {
00187                 alog("user: umode +d with no parameter (?) for user %s",
00188                      user->nick);
00189                 break;
00190             }
00191 
00192             ac--;
00193             av++;
00194             user->svid = strtoul(*av, NULL, 0);
00195             break;
00196         case 'o':
00197             if (add) {
00198                 opcnt++;
00199 
00200                 if (WallOper)
00201                     anope_cmd_global(s_OperServ,
00202                                      "\2%s\2 is now an IRC operator.",
00203                                      user->nick);
00204                 display_news(user, NEWS_OPER);
00205 
00206             } else {
00207                 opcnt--;
00208             }
00209             break;
00210         case 'r':
00211             if (add && !nick_identified(user)) {
00212                 common_svsmode(user, "-r", NULL);
00213                 user->mode &= ~UMODE_r;
00214             }
00215             break;
00216         }
00217     }
00218 }
00219 
00220 
00221 unsigned long umodes[128] = {
00222     0, 0, 0,                    /* Unused */
00223     0, 0, 0,                    /* Unused */
00224     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00225     0, 0, 0,                    /* Line Feed, Unused, Unused */
00226     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00227     0, 0, 0,                    /* Unused */
00228     0, 0, 0,                    /* Unused */
00229     0, 0, 0,                    /* Unused */
00230     0, 0, 0,                    /* Unused */
00231     0, 0, 0,                    /* Unused */
00232     0, 0, 0,                    /* Unused, Unused, Space */
00233     0, 0, 0,                    /* ! " #  */
00234     0, 0, 0,                    /* $ % &  */
00235     0, 0, 0,                    /* ! ( )  */
00236     0, 0, 0,                    /* * + ,  */
00237     0, 0, 0,                    /* - . /  */
00238     0, 0,                       /* 0 1 */
00239     0, 0,                       /* 2 3 */
00240     0, 0,                       /* 4 5 */
00241     0, 0,                       /* 6 7 */
00242     0, 0,                       /* 8 9 */
00243     0, 0,                       /* : ; */
00244     0, 0, 0,                    /* < = > */
00245     0, 0,                       /* ? @ */
00246     UMODE_A, 0, 0,              /* A B C */
00247     UMODE_D, 0, UMODE_F,        /* D E F */
00248     0, 0, UMODE_I,              /* G H I */
00249     0, UMODE_K, 0,              /* J K L */
00250     0, 0, UMODE_O,              /* M N O */
00251     0, 0, UMODE_R,              /* P Q R */
00252     0, 0, 0,                    /* S T U */
00253     0, 0, UMODE_X,              /* V W X */
00254     0,                          /* Y */
00255     0,                          /* Z */
00256     0, 0, 0,                    /* [ \ ] */
00257     0, 0, 0,                    /* ^ _ ` */
00258     UMODE_a, UMODE_b, UMODE_c,  /* a b c */
00259     UMODE_d, UMODE_e, UMODE_f,  /* d e f */
00260     UMODE_g, UMODE_h, UMODE_i,  /* g h i */
00261     UMODE_j, UMODE_k, 0,        /* j k l */
00262     UMODE_m, UMODE_n, UMODE_o,  /* m n o */
00263     0, 0, UMODE_r,              /* p q r */
00264     UMODE_s, 0, 0,              /* s t u */
00265     0, UMODE_w, UMODE_x,        /* v w x */
00266     UMODE_y,                    /* y */
00267     0,                          /* z */
00268     0, 0, 0,                    /* { | } */
00269     0, 0                        /* ~ � */
00270 };
00271 
00272 char myCsmodes[128] = {
00273     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00274     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00275 
00276     0,
00277     0,
00278     0, 0, 0,
00279     0,
00280     0, 0, 0, 0,
00281     0,
00282 
00283     'v', 0, 0, 0, 0,
00284     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00285 
00286     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00287     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00288 
00289     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00290     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00291 };
00292 
00293 
00294 CMMode myCmmodes[128] = {
00295     {NULL}, {NULL}, {NULL},
00296     {NULL}, {NULL}, {NULL},
00297     {NULL}, {NULL}, {NULL},
00298     {NULL}, {NULL}, {NULL},
00299     {NULL}, {NULL}, {NULL},
00300     {NULL}, {NULL}, {NULL},
00301     {NULL}, {NULL}, {NULL},
00302     {NULL}, {NULL}, {NULL},
00303     {NULL}, {NULL}, {NULL},
00304     {NULL}, {NULL}, {NULL},
00305     {NULL}, {NULL}, {NULL},
00306     {NULL}, {NULL}, {NULL},
00307     {NULL}, {NULL}, {NULL},
00308     {NULL}, {NULL}, {NULL},
00309     {NULL}, {NULL}, {NULL},
00310     {NULL}, {NULL}, {NULL},
00311     {NULL}, {NULL}, {NULL},
00312     {NULL}, {NULL}, {NULL},
00313     {NULL}, {NULL}, {NULL},
00314     {NULL}, {NULL}, {NULL},
00315     {NULL}, {NULL}, {NULL},
00316     {NULL}, {NULL}, {NULL},
00317     {NULL}, {NULL}, {NULL},     /* BCD */
00318     {NULL}, {NULL}, {NULL},     /* EFG */
00319     {NULL},                     /* H */
00320     {add_invite, del_invite},   /* I */
00321     {NULL},                     /* J */
00322     {NULL}, {NULL}, {NULL},     /* KLM */
00323     {NULL}, {NULL}, {NULL},     /* NOP */
00324     {NULL}, {NULL}, {NULL},     /* QRS */
00325     {NULL}, {NULL}, {NULL},     /* TUV */
00326     {NULL}, {NULL}, {NULL},     /* WXY */
00327     {NULL},                     /* Z */
00328     {NULL}, {NULL},             /* (char 91 - 92) */
00329     {NULL}, {NULL}, {NULL},     /* (char 93 - 95) */
00330     {NULL},                     /* ` (char 96) */
00331     {NULL},                     /* a (char 97) */
00332     {add_ban, del_ban},         /* b */
00333     {NULL}, {NULL},             /* cd */
00334     {add_exception, del_exception},
00335     {NULL}, {NULL},
00336     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00337     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00338     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00339 };
00340 
00341 CBMode myCbmodes[128] = {
00342     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00343     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00344     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00345     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00346     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00347     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00348     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00349     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00350     {0},
00351     {0},                        /* A */
00352     {0},                        /* B */
00353     {0},                        /* C */
00354     {0},                        /* D */
00355     {0},                        /* E */
00356     {0},                        /* F */
00357     {0},                        /* G */
00358     {0},                        /* H */
00359     {0},                        /* I */
00360     {0},                        /* J */
00361     {0},                        /* K */
00362     {0},                        /* L */
00363     {CMODE_M, 0, NULL, NULL},   /* M */
00364     {0},                        /* N */
00365     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00366     {0},                        /* P */
00367     {0},                        /* Q */
00368     {CMODE_R, 0, NULL, NULL},   /* R */
00369     {0},                        /* S */
00370     {0},                        /* T */
00371     {0},                        /* U */
00372     {0},                        /* V */
00373     {0},                        /* W */
00374     {0},                        /* X */
00375     {0},                        /* Y */
00376     {0},                        /* Z */
00377     {0}, {0}, {0}, {0}, {0}, {0},
00378     {0},                        /* a */
00379     {0},                        /* b */
00380     {CMODE_c, 0, NULL, NULL},
00381     {0},                        /* d */
00382     {0},                        /* e */
00383     {0},                        /* f */
00384     {0},                        /* g */
00385     {0},                        /* h */
00386     {CMODE_i, 0, NULL, NULL},
00387     {CMODE_j, 0, set_flood, cs_set_flood},      /* j */
00388     {CMODE_k, 0, chan_set_key, cs_set_key},
00389     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00390     {CMODE_m, 0, NULL, NULL},
00391     {CMODE_n, 0, NULL, NULL},
00392     {0},                        /* o */
00393     {CMODE_p, 0, NULL, NULL},
00394     {0},                        /* q */
00395     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00396     {CMODE_s, 0, NULL, NULL},
00397     {CMODE_t, 0, NULL, NULL},
00398     {0},
00399     {0},                        /* v */
00400     {0},                        /* w */
00401     {0},                        /* x */
00402     {0},                        /* y */
00403     {0},                        /* z */
00404     {0}, {0}, {0}, {0}
00405 };
00406 
00407 CBModeInfo myCbmodeinfos[] = {
00408     {'c', CMODE_c, 0, NULL, NULL},
00409     {'i', CMODE_i, 0, NULL, NULL},
00410     {'j', CMODE_j, 0, get_flood, cs_get_flood},
00411     {'k', CMODE_k, 0, get_key, cs_get_key},
00412     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00413     {'m', CMODE_m, 0, NULL, NULL},
00414     {'n', CMODE_n, 0, NULL, NULL},
00415     {'p', CMODE_p, 0, NULL, NULL},
00416     {'r', CMODE_r, 0, NULL, NULL},
00417     {'s', CMODE_s, 0, NULL, NULL},
00418     {'t', CMODE_t, 0, NULL, NULL},
00419     {'M', CMODE_M, 0, NULL, NULL},
00420     {'O', CMODE_O, 0, NULL, NULL},
00421     {'R', CMODE_R, 0, NULL, NULL},
00422     {0}
00423 };
00424 
00425 CUMode myCumodes[128] = {
00426     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00427     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00428     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00429     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00430 
00431     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00432     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00433     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00434     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00435 
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     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00440 
00441     {0},
00442     {0},                        /* a */
00443     {0},                        /* b */
00444     {0},                        /* c */
00445     {0},                        /* d */
00446     {0},                        /* e */
00447     {0},                        /* f */
00448     {0},                        /* g */
00449     {0},                        /* h */
00450     {0},                        /* i */
00451     {0},                        /* j */
00452     {0},                        /* k */
00453     {0},                        /* l */
00454     {0},                        /* m */
00455     {0},                        /* n */
00456     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00457     {0},                        /* p */
00458     {0},                        /* q */
00459     {0},                        /* r */
00460     {0},                        /* s */
00461     {0},                        /* t */
00462     {0},                        /* u */
00463     {CUS_VOICE, 0, NULL},
00464     {0},                        /* w */
00465     {0},                        /* x */
00466     {0},                        /* y */
00467     {0},                        /* z */
00468     {0}, {0}, {0}, {0}, {0}
00469 };
00470 
00471 
00472 
00473 void bahamut_cmd_mode(char *source, char *dest, char *buf)
00474 {
00475     if (!buf) {
00476         return;
00477     }
00478 
00479     if (ircdcap->tsmode) {
00480         if (uplink_capab & ircdcap->tsmode) {
00481             send_cmd(source, "MODE %s 0 %s", dest, buf);
00482         } else {
00483             send_cmd(source, "MODE %s %s", dest, buf);
00484         }
00485     } else {
00486         send_cmd(source, "MODE %s %s", dest, buf);
00487     }
00488 }
00489 
00490 /* SVSHOLD - set */
00491 void bahamut_cmd_svshold(char *nick)
00492 {
00493     send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout,
00494              "Being held for registered user");
00495 }
00496 
00497 /* SVSHOLD - release */
00498 void bahamut_cmd_release_svshold(char *nick)
00499 {
00500     send_cmd(ServerName, "SVSHOLD %s 0", nick);
00501 }
00502 
00503 /* SVSMODE -b */
00504 void bahamut_cmd_unban(char *name, char *nick)
00505 {
00506     bahamut_cmd_svsmode_chan(name, "-b", nick);
00507 }
00508 
00509 
00510 /* SVSMODE channel modes */
00511 
00512 void bahamut_cmd_svsmode_chan(char *name, char *mode, char *nick)
00513 {
00514     if (nick) {
00515         send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
00516     } else {
00517         send_cmd(ServerName, "SVSMODE %s %s", name, mode);
00518     }
00519 }
00520 
00521 void bahamut_cmd_bot_chan_mode(char *nick, char *chan)
00522 {
00523     anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
00524 }
00525 
00526 /* EVENT: SJOIN */
00527 int anope_event_sjoin(char *source, int ac, char **av)
00528 {
00529     do_sjoin(source, ac, av);
00530     return MOD_CONT;
00531 }
00532 
00533 /*
00534 ** NICK - new
00535 **      source  = NULL
00536 **  parv[0] = nickname
00537 **      parv[1] = hopcount
00538 **      parv[2] = timestamp
00539 **      parv[3] = modes
00540 **      parv[4] = username
00541 **      parv[5] = hostname
00542 **      parv[6] = server
00543 **  parv[7] = servicestamp
00544 **      parv[8] = IP
00545 **  parv[9] = info
00546 ** NICK - change 
00547 **      source  = oldnick
00548 **  parv[0] = new nickname
00549 **      parv[1] = hopcount
00550 */
00551 int anope_event_nick(char *source, int ac, char **av)
00552 {
00553     User *user;
00554 
00555     if (ac != 2) {
00556         user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
00557                        strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0),
00558                        strtoul(av[8], NULL, 0), NULL, NULL);
00559         if (user) {
00560             anope_set_umode(user, 1, &av[3]);
00561         }
00562     } else {
00563         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00564                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00565     }
00566     return MOD_CONT;
00567 }
00568 
00569 /* EVENT : CAPAB */
00570 int anope_event_capab(char *source, int ac, char **av)
00571 {
00572     capab_parse(ac, av);
00573     return MOD_CONT;
00574 }
00575 
00576 /* EVENT : OS */
00577 int anope_event_os(char *source, int ac, char **av)
00578 {
00579     if (ac < 1)
00580         return MOD_CONT;
00581     m_privmsg(source, s_OperServ, av[0]);
00582     return MOD_CONT;
00583 }
00584 
00585 /* EVENT : NS */
00586 int anope_event_ns(char *source, int ac, char **av)
00587 {
00588     if (ac < 1)
00589         return MOD_CONT;
00590     m_privmsg(source, s_NickServ, av[0]);
00591     return MOD_CONT;
00592 }
00593 
00594 /* EVENT : MS */
00595 int anope_event_ms(char *source, int ac, char **av)
00596 {
00597     if (ac < 1)
00598         return MOD_CONT;
00599     m_privmsg(source, s_MemoServ, av[0]);
00600     return MOD_CONT;
00601 }
00602 
00603 /* EVENT : HS */
00604 int anope_event_hs(char *source, int ac, char **av)
00605 {
00606     if (ac < 1)
00607         return MOD_CONT;
00608     m_privmsg(source, s_HostServ, av[0]);
00609     return MOD_CONT;
00610 }
00611 
00612 /* EVENT : CS */
00613 int anope_event_cs(char *source, int ac, char **av)
00614 {
00615     if (ac < 1)
00616         return MOD_CONT;
00617     m_privmsg(source, s_ChanServ, av[0]);
00618     return MOD_CONT;
00619 }
00620 
00621 int anope_event_436(char *source, int ac, char **av)
00622 {
00623     if (ac < 1)
00624         return MOD_CONT;
00625 
00626     m_nickcoll(av[0]);
00627     return MOD_CONT;
00628 }
00629 
00630 /* *INDENT-OFF* */
00631 void moduleAddIRCDMsgs(void) {
00632     Message *m;
00633 
00634 
00635     /* first update the cs protect info about this ircd */
00636     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
00637     
00638     /* now add the commands */
00639     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00640     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00641     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00642     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00643     m = createMessage("INVITE",    anope_event_null); addCoreMessage(IRCD,m);
00644     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00645     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00646     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00647     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00648     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00649     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00650     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00651     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00652     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00653     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00654     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00655     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00656     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00657     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00658     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00659     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00660     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00661     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00662     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00663     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00664     m = createMessage("GNOTICE",   anope_event_gnotice); addCoreMessage(IRCD,m);
00665     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00666     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00667     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00668     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00669     m = createMessage("SVSMODE",   anope_event_mode); addCoreMessage(IRCD,m);
00670     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00671     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00672     m = createMessage("SQLINE",    anope_event_sqline); addCoreMessage(IRCD,m);
00673     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00674     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
00675     m = createMessage("CS",        anope_event_cs); addCoreMessage(IRCD,m);
00676     m = createMessage("HS",        anope_event_hs); addCoreMessage(IRCD,m);
00677     m = createMessage("MS",        anope_event_ms); addCoreMessage(IRCD,m);
00678     m = createMessage("NS",        anope_event_ns); addCoreMessage(IRCD,m);
00679     m = createMessage("OS",        anope_event_os); addCoreMessage(IRCD,m);
00680     m = createMessage("RS",        anope_event_null); addCoreMessage(IRCD,m);
00681     m = createMessage("SGLINE",    anope_event_null); addCoreMessage(IRCD,m);
00682     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
00683     m = createMessage("SS",        anope_event_null); addCoreMessage(IRCD,m);
00684     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
00685     m = createMessage("SZLINE",    anope_event_null); addCoreMessage(IRCD,m);
00686     m = createMessage("UNSGLINE",  anope_event_null); addCoreMessage(IRCD,m);
00687     m = createMessage("UNSZLINE",  anope_event_null); addCoreMessage(IRCD,m);
00688     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
00689     m = createMessage("LUSERSLOCK",anope_event_luserslock); addCoreMessage(IRCD,m);
00690     m = createMessage("BURST",     anope_event_burst); addCoreMessage(IRCD,m);
00691     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00692 
00693 }
00694 
00695 /* *INDENT-ON* */
00696 
00697 /* SQLINE */
00698 void bahamut_cmd_sqline(char *mask, char *reason)
00699 {
00700     if (!mask || !reason) {
00701         return;
00702     }
00703 
00704     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00705 }
00706 
00707 /* UNSGLINE */
00708 void bahamut_cmd_unsgline(char *mask)
00709 {
00710     send_cmd(NULL, "UNSGLINE 0 :%s", mask);
00711 }
00712 
00713 /* UNSZLINE */
00714 void bahamut_cmd_unszline(char *mask)
00715 {
00716     /* this will likely fail so its only here for legacy */
00717     send_cmd(NULL, "UNSZLINE 0 %s", mask);
00718     /* this is how we are supposed to deal with it */
00719     send_cmd(NULL, "RAKILL %s *", mask);
00720 }
00721 
00722 /* SZLINE */
00723 void bahamut_cmd_szline(char *mask, char *reason, char *whom)
00724 {
00725     /* this will likely fail so its only here for legacy */
00726     send_cmd(NULL, "SZLINE %s :%s", mask, reason);
00727     /* this is how we are supposed to deal with it */
00728     send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom,
00729              (long int) time(NULL), reason);
00730 }
00731 
00732 /* SVSNOOP */
00733 void bahamut_cmd_svsnoop(char *server, int set)
00734 {
00735     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00736 }
00737 
00738 void bahamut_cmd_svsadmin(char *server, int set)
00739 {
00740     bahamut_cmd_svsnoop(server, set);
00741 }
00742 
00743 /* SGLINE */
00744 void bahamut_cmd_sgline(char *mask, char *reason)
00745 {
00746     send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason);
00747 }
00748 
00749 /* RAKILL */
00750 void bahamut_cmd_remove_akill(char *user, char *host)
00751 {
00752     send_cmd(NULL, "RAKILL %s %s", host, user);
00753 }
00754 
00755 /* PART */
00756 void bahamut_cmd_part(char *nick, char *chan, char *buf)
00757 {
00758     if (!nick || !chan) {
00759         return;
00760     }
00761 
00762     if (buf) {
00763         send_cmd(nick, "PART %s :%s", chan, buf);
00764     } else {
00765         send_cmd(nick, "PART %s", chan);
00766     }
00767 }
00768 
00769 /* TOPIC */
00770 void bahamut_cmd_topic(char *whosets, char *chan, char *whosetit,
00771                        char *topic, time_t when)
00772 {
00773     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
00774              (unsigned long int) when, topic);
00775 }
00776 
00777 /* UNSQLINE */
00778 void bahamut_cmd_unsqline(char *user)
00779 {
00780     send_cmd(NULL, "UNSQLINE %s", user);
00781 }
00782 
00783 /* JOIN - SJOIN */
00784 void bahamut_cmd_join(char *user, char *channel, time_t chantime)
00785 {
00786     send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
00787 }
00788 
00789 void bahamut_cmd_burst()
00790 {
00791     send_cmd(NULL, "BURST");
00792 }
00793 
00794 /* AKILL */
00795 /* parv[1]=host 
00796  * parv[2]=user
00797  * parv[3]=length
00798  * parv[4]=akiller
00799  * parv[5]=time set
00800  * parv[6]=reason
00801  */
00802 void bahamut_cmd_akill(char *user, char *host, char *who, time_t when,
00803                        time_t expires, char *reason)
00804 {
00805     send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
00806              (long int) time(NULL), reason);
00807 }
00808 
00809 /* SVSKILL */
00810 /* parv[0] = servername
00811  * parv[1] = client
00812  * parv[2] = nick stamp
00813  * parv[3] = kill message
00814  */
00815 /*
00816   Note: if the stamp is null 0, the below usage is correct of Bahamut
00817 */
00818 void bahamut_cmd_svskill(char *source, char *user, char *buf)
00819 {
00820 
00821     if (!source || !user || !buf) {
00822         return;
00823     }
00824 
00825     send_cmd(source, "SVSKILL %s :%s", user, buf);
00826 }
00827 
00828 /* SVSMODE */
00829 /* parv[0] - sender
00830  * parv[1] - nick
00831  * parv[2] - TS (or mode, depending on svs version)
00832  * parv[3] - mode (or services id if old svs version)
00833  * parv[4] - optional arguement (services id)
00834  */
00835 void bahamut_cmd_svsmode(User * u, int ac, char **av)
00836 {
00837     send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
00838              (long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
00839              (ac == 2 ? av[1] : ""));
00840 }
00841 
00842 /* SQUIT */
00843 /*
00844  *        parv[0] = sender prefix 
00845  *        parv[1] = server name 
00846  *        parv[2] = comment
00847 */
00848 void bahamut_cmd_squit(char *servname, char *message)
00849 {
00850     send_cmd(NULL, "SQUIT %s :%s", servname, message);
00851 }
00852 
00853 /* PONG */
00854 void bahamut_cmd_pong(char *servname, char *who)
00855 {
00856     send_cmd(servname, "PONG %s", who);
00857 }
00858 
00859 /*
00860  * SVINFO 
00861  *       parv[0] = sender prefix 
00862  *       parv[1] = TS_CURRENT for the server 
00863  *       parv[2] = TS_MIN for the server 
00864  *       parv[3] = server is standalone or connected to non-TS only 
00865  *       parv[4] = server's idea of UTC time
00866  */
00867 void bahamut_cmd_svinfo()
00868 {
00869     send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL));
00870 }
00871 
00872 /* PASS */
00873 void bahamut_cmd_pass(char *pass)
00874 {
00875     send_cmd(NULL, "PASS %s :TS", pass);
00876 }
00877 
00878 /* SERVER */
00879 void bahamut_cmd_server(char *servname, int hop, char *descript)
00880 {
00881     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00882 }
00883 
00884 /* CAPAB */
00885 void bahamut_cmd_capab()
00886 {
00887     send_cmd(NULL,
00888              "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
00889 }
00890 
00891 void bahamut_cmd_connect(int servernum)
00892 {
00893     me_server =
00894         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00895 
00896     if (servernum == 1) {
00897         bahamut_cmd_pass(RemotePassword);
00898     } else if (servernum == 2) {
00899         bahamut_cmd_pass(RemotePassword2);
00900     } else if (servernum == 3) {
00901         bahamut_cmd_pass(RemotePassword3);
00902     }
00903     bahamut_cmd_capab();
00904     bahamut_cmd_server(ServerName, 1, ServerDesc);
00905     bahamut_cmd_svinfo();
00906     bahamut_cmd_burst();
00907 }
00908 
00909 
00910 
00911 
00912 
00913 /* EVENT : SERVER */
00914 int anope_event_server(char *source, int ac, char **av)
00915 {
00916     if (!stricmp(av[1], "1")) {
00917         uplink = sstrdup(av[0]);
00918     }
00919 
00920     do_server(source, av[0], av[1], av[2], NULL);
00921     return MOD_CONT;
00922 }
00923 
00924 /* EVENT : PRIVMSG */
00925 int anope_event_privmsg(char *source, int ac, char **av)
00926 {
00927     if (ac != 2)
00928         return MOD_CONT;
00929     m_privmsg(source, av[0], av[1]);
00930     return MOD_CONT;
00931 }
00932 
00933 /* EVENT : SVINFO */
00934 /*
00935  *       parv[0] = sender prefix 
00936  *       parv[1] = TS_CURRENT for the server 
00937  *       parv[2] = TS_MIN for the server 
00938  *       parv[3] = server is standalone or connected to non-TS only 
00939  *       parv[4] = server's idea of UTC time
00940  */
00941 int anope_event_svinfo(char *source, int ac, char **av)
00942 {
00943     return MOD_CONT;
00944 }
00945 
00946 
00947 int anope_event_part(char *source, int ac, char **av)
00948 {
00949     if (ac < 1 || ac > 2)
00950         return MOD_CONT;
00951     do_part(source, ac, av);
00952     return MOD_CONT;
00953 }
00954 
00955 int anope_event_whois(char *source, int ac, char **av)
00956 {
00957     if (source && ac >= 1) {
00958         m_whois(source, av[0]);
00959     }
00960     return MOD_CONT;
00961 }
00962 
00963 int anope_event_topic(char *source, int ac, char **av)
00964 {
00965     if (ac != 4)
00966         return MOD_CONT;
00967     do_topic(source, ac, av);
00968     return MOD_CONT;
00969 }
00970 
00971 int anope_event_squit(char *source, int ac, char **av)
00972 {
00973     if (ac != 2)
00974         return MOD_CONT;
00975     do_squit(source, ac, av);
00976     return MOD_CONT;
00977 }
00978 
00979 int anope_event_quit(char *source, int ac, char **av)
00980 {
00981     if (ac != 1)
00982         return MOD_CONT;
00983     do_quit(source, ac, av);
00984     return MOD_CONT;
00985 }
00986 
00987 /* EVENT: MODE */
00988 int anope_event_mode(char *source, int ac, char **av)
00989 {
00990     if (ac < 2)
00991         return MOD_CONT;
00992 
00993     if (*av[0] == '#' || *av[0] == '&') {
00994         do_cmode(source, ac, av);
00995     } else {
00996         do_umode(source, ac, av);
00997     }
00998     return MOD_CONT;
00999 }
01000 
01001 /* EVENT: KILL */