bahamut.c

Go to the documentation of this file.
00001 /* Bahamut 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 /*************************************************************************/
00015 
00016 #include "services.h"
00017 #include "pseudo.h"
00018 #include "bahamut.h"
00019 #include "version.h"
00020 
00021 IRCDVar myIrcd[] = {
00022     {"BahamutIRCd 1.4.*/1.8.*", /* ircd name */
00023      "+o",                      /* nickserv mode */
00024      "+o",                      /* chanserv mode */
00025      "+o",                      /* memoserv mode */
00026      "+",                       /* hostserv mode */
00027      "+io",                     /* operserv mode */
00028      "+o",                      /* botserv mode  */
00029      "+h",                      /* helpserv mode */
00030      "+i",                      /* Dev/Null mode */
00031      "+io",                     /* Global mode   */
00032      "+o",                      /* nickserv alias mode */
00033      "+o",                      /* chanserv alias mode */
00034      "+o",                      /* memoserv alias mode */
00035      "+",                       /* hostserv alias mode */
00036      "+io",                     /* operserv alias mode */
00037      "+o",                      /* botserv alias mode  */
00038      "+h",                      /* helpserv alias mode */
00039      "+i",                      /* Dev/Null alias mode */
00040      "+io",                     /* Global alias mode   */
00041      "+",                       /* Used by BotServ Bots */
00042      2,                         /* Chan Max Symbols     */
00043      "-cilmnpstOR",             /* Modes to Remove */
00044      "+o",                      /* Channel Umode used by Botserv bots */
00045      1,                         /* SVSNICK */
00046      0,                         /* Vhost  */
00047      0,                         /* Has Owner */
00048      NULL,                      /* Mode to set for an owner */
00049      NULL,                      /* Mode to unset for an owner */
00050      NULL,                      /* Mode to set for channel admin */
00051      NULL,                      /* Mode to unset for channel admin */
00052      "+rd",                     /* Mode On Reg          */
00053      NULL,                      /* Mode on ID for Roots */
00054      NULL,                      /* Mode on ID for Admins */
00055      NULL,                      /* Mode on ID for Opers */
00056      "-r+d",                    /* Mode on UnReg        */
00057      "+d",                      /* Mode on Nick Change  */
00058      1,                         /* Supports SGlines     */
00059      1,                         /* Supports SQlines     */
00060      1,                         /* Supports SZlines     */
00061      0,                         /* Supports Halfop +h   */
00062      3,                         /* Number of server args */
00063      0,                         /* Join 2 Set           */
00064      0,                         /* Join 2 Message       */
00065      1,                         /* Has exceptions +e    */
00066      0,                         /* TS Topic Forward     */
00067      0,                         /* TS Topci Backward    */
00068      0,                         /* Protected Umode      */
00069      0,                         /* Has Admin            */
00070      1,                         /* Chan SQlines         */
00071      1,                         /* Quit on Kill         */
00072      1,                         /* SVSMODE unban        */
00073      0,                         /* Has Protect          */
00074      0,                         /* Reverse              */
00075      1,                         /* Chan Reg             */
00076      CMODE_r,                   /* Channel Mode         */
00077      0,                         /* vidents              */
00078      1,                         /* svshold              */
00079      1,                         /* time stamp on mode   */
00080      1,                         /* NICKIP               */
00081      0,                         /* O:LINE               */
00082      1,                         /* UMODE               */
00083      0,                         /* VHOST ON NICK        */
00084      0,                         /* Change RealName      */
00085      0,                         /* No Knock             */
00086      0,                         /* Admin Only           */
00087      DEFAULT_MLOCK,             /* Default MLOCK       */
00088      0,                         /* Vhost Mode           */
00089      1,                         /* +f                   */
00090      0,                         /* +L                   */
00091      CMODE_j,                   /* Mode */
00092      0,                         /* Mode */
00093      1,
00094      1,                         /* No Knock requires +i */
00095      NULL,                      /* CAPAB Chan Modes             */
00096      0,                         /* We support TOKENS */
00097      1,                         /* TOKENS are CASE inSensitive */
00098      0,                         /* TIME STAMPS are BASE64 */
00099      1,                         /* +I support */
00100      0,                         /* SJOIN ban char */
00101      0,                         /* SJOIN except char */
00102      0,                         /* SJOIN invite char */
00103      0,                         /* Can remove User Channel Modes with SVSMODE */
00104      0,                         /* Sglines are not enforced until user reconnects */
00105      NULL,                      /* vhost char */
00106      0,                         /* ts6 */
00107      1,                         /* support helper umode */
00108      0,                         /* p10 */
00109      NULL,                      /* character set */
00110      1,                         /* reports sync state */
00111      0,                         /* CIDR channelbans */
00112      0,                         /* +j */
00113      0,                         /* +j mode */
00114      0,                         /* Use delayed client introduction. */
00115      }
00116     ,
00117     {NULL}
00118 };
00119 
00120 IRCDCAPAB myIrcdcap[] = {
00121     {
00122      CAPAB_NOQUIT,              /* NOQUIT       */
00123      CAPAB_TSMODE,              /* TSMODE       */
00124      CAPAB_UNCONNECT,           /* UNCONNECT    */
00125      0,                         /* NICKIP       */
00126      0,                         /* SJOIN        */
00127      0,                         /* ZIP          */
00128      CAPAB_BURST,               /* BURST        */
00129      0,                         /* TS5          */
00130      0,                         /* TS3          */
00131      CAPAB_DKEY,                /* DKEY         */
00132      0,                         /* PT4          */
00133      0,                         /* SCS          */
00134      0,                         /* QS           */
00135      0,                         /* UID          */
00136      0,                         /* KNOCK        */
00137      0,                         /* CLIENT       */
00138      0,                         /* IPV6         */
00139      0,                         /* SSJ5         */
00140      0,                         /* SN2          */
00141      0,                         /* TOKEN        */
00142      0,                         /* VHOST        */
00143      0,                         /* SSJ3         */
00144      0,                         /* NICK2        */
00145      0,                         /* UMODE2       */
00146      0,                         /* VL           */
00147      0,                         /* TLKEXT       */
00148      0,                         /* DODKEY       */
00149      CAPAB_DOZIP,               /* DOZIP        */
00150      0, 0, 0}
00151 };
00152 
00153 
00154 void bahamut_set_umode(User * user, int ac, char **av)
00155 {
00156     int add = 1;                /* 1 if adding modes, 0 if deleting */
00157     char *modes = av[0];
00158 
00159     ac--;
00160 
00161     if (debug)
00162         alog("debug: Changing mode for %s to %s", user->nick, modes);
00163 
00164     while (*modes) {
00165 
00166         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00167          * At least this is readable without paying much attention :) -GD
00168          */
00169         if (add)
00170             user->mode |= umodes[(int) *modes];
00171         else
00172             user->mode &= ~umodes[(int) *modes];
00173 
00174         switch (*modes++) {
00175         case '+':
00176             add = 1;
00177             break;
00178         case '-':
00179             add = 0;
00180             break;
00181         case 'a':
00182             if (UnRestrictSAdmin) {
00183                 break;
00184             }
00185             if (add && !is_services_admin(user)) {
00186                 common_svsmode(user, "-a", NULL);
00187                 user->mode &= ~UMODE_a;
00188             }
00189             break;
00190         case 'd':
00191             if (ac == 0) {
00192                 alog("user: umode +d with no parameter (?) for user %s",
00193                      user->nick);
00194                 break;
00195             }
00196 
00197             ac--;
00198             av++;
00199             user->svid = strtoul(*av, NULL, 0);
00200             break;
00201         case 'o':
00202             if (add) {
00203                 opcnt++;
00204 
00205                 if (WallOper)
00206                     anope_cmd_global(s_OperServ,
00207                                      "\2%s\2 is now an IRC operator.",
00208                                      user->nick);
00209                 display_news(user, NEWS_OPER);
00210 
00211             } else {
00212                 opcnt--;
00213             }
00214             break;
00215         case 'r':
00216             if (add && !nick_identified(user)) {
00217                 common_svsmode(user, "-r", NULL);
00218                 user->mode &= ~UMODE_r;
00219             }
00220             break;
00221         }
00222     }
00223 }
00224 
00225 
00226 unsigned long umodes[128] = {
00227     0, 0, 0,                    /* Unused */
00228     0, 0, 0,                    /* Unused */
00229     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00230     0, 0, 0,                    /* Line Feed, Unused, Unused */
00231     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00232     0, 0, 0,                    /* Unused */
00233     0, 0, 0,                    /* Unused */
00234     0, 0, 0,                    /* Unused */
00235     0, 0, 0,                    /* Unused */
00236     0, 0, 0,                    /* Unused */
00237     0, 0, 0,                    /* Unused, Unused, Space */
00238     0, 0, 0,                    /* ! " #  */
00239     0, 0, 0,                    /* $ % &  */
00240     0, 0, 0,                    /* ! ( )  */
00241     0, 0, 0,                    /* * + ,  */
00242     0, 0, 0,                    /* - . /  */
00243     0, 0,                       /* 0 1 */
00244     0, 0,                       /* 2 3 */
00245     0, 0,                       /* 4 5 */
00246     0, 0,                       /* 6 7 */
00247     0, 0,                       /* 8 9 */
00248     0, 0,                       /* : ; */
00249     0, 0, 0,                    /* < = > */
00250     0, 0,                       /* ? @ */
00251     UMODE_A, 0, 0,              /* A B C */
00252     UMODE_D, 0, UMODE_F,        /* D E F */
00253     0, 0, UMODE_I,              /* G H I */
00254     0, UMODE_K, 0,              /* J K L */
00255     0, 0, UMODE_O,              /* M N O */
00256     0, 0, UMODE_R,              /* P Q R */
00257     0, 0, 0,                    /* S T U */
00258     0, 0, UMODE_X,              /* V W X */
00259     0,                          /* Y */
00260     0,                          /* Z */
00261     0, 0, 0,                    /* [ \ ] */
00262     0, 0, 0,                    /* ^ _ ` */
00263     UMODE_a, UMODE_b, UMODE_c,  /* a b c */
00264     UMODE_d, UMODE_e, UMODE_f,  /* d e f */
00265     UMODE_g, UMODE_h, UMODE_i,  /* g h i */
00266     UMODE_j, UMODE_k, 0,        /* j k l */
00267     UMODE_m, UMODE_n, UMODE_o,  /* m n o */
00268     0, 0, UMODE_r,              /* p q r */
00269     UMODE_s, 0, 0,              /* s t u */
00270     0, UMODE_w, UMODE_x,        /* v w x */
00271     UMODE_y,                    /* y */
00272     0,                          /* z */
00273     0, 0, 0,                    /* { | } */
00274     0, 0                        /* ~ � */
00275 };
00276 
00277 char myCsmodes[128] = {
00278     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00279     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00280 
00281     0,
00282     0,
00283     0, 0, 0,
00284     0,
00285     0, 0, 0, 0,
00286     0,
00287 
00288     'v', 0, 0, 0, 0,
00289     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00290 
00291     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00292     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00293 
00294     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00295     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00296 };
00297 
00298 
00299 CMMode myCmmodes[128] = {
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},
00318     {NULL}, {NULL}, {NULL},
00319     {NULL}, {NULL}, {NULL},
00320     {NULL}, {NULL}, {NULL},
00321     {NULL}, {NULL}, {NULL},
00322     {NULL}, {NULL}, {NULL},     /* BCD */
00323     {NULL}, {NULL}, {NULL},     /* EFG */
00324     {NULL},                     /* H */
00325     {add_invite, del_invite},   /* I */
00326     {NULL},                     /* J */
00327     {NULL}, {NULL}, {NULL},     /* KLM */
00328     {NULL}, {NULL}, {NULL},     /* NOP */
00329     {NULL}, {NULL}, {NULL},     /* QRS */
00330     {NULL}, {NULL}, {NULL},     /* TUV */
00331     {NULL}, {NULL}, {NULL},     /* WXY */
00332     {NULL},                     /* Z */
00333     {NULL}, {NULL},             /* (char 91 - 92) */
00334     {NULL}, {NULL}, {NULL},     /* (char 93 - 95) */
00335     {NULL},                     /* ` (char 96) */
00336     {NULL},                     /* a (char 97) */
00337     {add_ban, del_ban},         /* b */
00338     {NULL}, {NULL},             /* cd */
00339     {add_exception, del_exception},
00340     {NULL}, {NULL},
00341     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00342     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00343     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
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     {0},                        /* A */
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     {0},                        /* K */
00367     {0},                        /* L */
00368     {CMODE_M, 0, NULL, NULL},   /* M */
00369     {0},                        /* N */
00370     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00371     {0},                        /* P */
00372     {0},                        /* Q */
00373     {CMODE_R, 0, NULL, NULL},   /* R */
00374     {0},                        /* 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},
00386     {0},                        /* d */
00387     {0},                        /* e */
00388     {0},                        /* f */
00389     {0},                        /* g */
00390     {0},                        /* h */
00391     {CMODE_i, 0, NULL, NULL},
00392     {CMODE_j, 0, set_flood, cs_set_flood},      /* 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},
00396     {CMODE_n, 0, NULL, NULL},
00397     {0},                        /* o */
00398     {CMODE_p, 0, NULL, NULL},
00399     {0},                        /* q */
00400     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00401     {CMODE_s, 0, NULL, NULL},
00402     {CMODE_t, 0, NULL, NULL},
00403     {0},
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     {'j', CMODE_j, 0, get_flood, cs_get_flood},
00416     {'k', CMODE_k, 0, get_key, cs_get_key},
00417     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00418     {'m', CMODE_m, 0, NULL, NULL},
00419     {'n', CMODE_n, 0, NULL, NULL},
00420     {'p', CMODE_p, 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     {'M', CMODE_M, 0, NULL, NULL},
00425     {'O', CMODE_O, 0, NULL, NULL},
00426     {'R', CMODE_R, 0, NULL, NULL},
00427     {0}
00428 };
00429 
00430 CUMode myCumodes[128] = {
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}, {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     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00445 
00446     {0},
00447     {0},                        /* a */
00448     {0},                        /* b */
00449     {0},                        /* c */
00450     {0},                        /* d */
00451     {0},                        /* e */
00452     {0},                        /* f */
00453     {0},                        /* g */
00454     {0},                        /* h */
00455     {0},                        /* i */
00456     {0},                        /* j */
00457     {0},                        /* k */
00458     {0},                        /* l */
00459     {0},                        /* m */
00460     {0},                        /* n */
00461     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00462     {0},                        /* p */
00463     {0},                        /* q */
00464     {0},                        /* r */
00465     {0},                        /* s */
00466     {0},                        /* t */
00467     {0},                        /* u */
00468     {CUS_VOICE, 0, NULL},
00469     {0},                        /* w */
00470     {0},                        /* x */
00471     {0},                        /* y */
00472     {0},                        /* z */
00473     {0}, {0}, {0}, {0}, {0}
00474 };
00475 
00476 
00477 
00478 void bahamut_cmd_mode(char *source, char *dest, char *buf)
00479 {
00480     if (!buf) {
00481         return;
00482     }
00483 
00484     if (ircdcap->tsmode) {
00485         if (uplink_capab & ircdcap->tsmode) {
00486             send_cmd(source, "MODE %s 0 %s", dest, buf);
00487         } else {
00488             send_cmd(source, "MODE %s %s", dest, buf);
00489         }
00490     } else {
00491         send_cmd(source, "MODE %s %s", dest, buf);
00492     }
00493 }
00494 
00495 /* SVSHOLD - set */
00496 void bahamut_cmd_svshold(char *nick)
00497 {
00498     send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout,
00499              "Being held for registered user");
00500 }
00501 
00502 /* SVSHOLD - release */
00503 void bahamut_cmd_release_svshold(char *nick)
00504 {
00505     send_cmd(ServerName, "SVSHOLD %s 0", nick);
00506 }
00507 
00508 /* SVSMODE -b */
00509 void bahamut_cmd_unban(char *name, char *nick)
00510 {
00511     bahamut_cmd_svsmode_chan(name, "-b", nick);
00512 }
00513 
00514 
00515 /* SVSMODE channel modes */
00516 
00517 void bahamut_cmd_svsmode_chan(char *name, char *mode, char *nick)
00518 {
00519     if (nick) {
00520         send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick);
00521     } else {
00522         send_cmd(ServerName, "SVSMODE %s %s", name, mode);
00523     }
00524 }
00525 
00526 void bahamut_cmd_bot_chan_mode(char *nick, char *chan)
00527 {
00528     anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
00529 }
00530 
00531 /* EVENT: SJOIN */
00532 int anope_event_sjoin(char *source, int ac, char **av)
00533 {
00534     do_sjoin(source, ac, av);
00535     return MOD_CONT;
00536 }
00537 
00538 /*
00539 ** NICK - new
00540 **      source  = NULL
00541 **      parv[0] = nickname
00542 **      parv[1] = hopcount
00543 **      parv[2] = timestamp
00544 **      parv[3] = modes
00545 **      parv[4] = username
00546 **      parv[5] = hostname
00547 **      parv[6] = server
00548 **      parv[7] = servicestamp
00549 **      parv[8] = IP
00550 **      parv[9] = info
00551 ** NICK - change 
00552 **      source  = oldnick
00553 **      parv[0] = new nickname
00554 **      parv[1] = hopcount
00555 */
00556 int anope_event_nick(char *source, int ac, char **av)
00557 {
00558     User *user;
00559 
00560     if (ac != 2) {
00561         user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
00562                        strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0),
00563                        strtoul(av[8], NULL, 0), NULL, NULL);
00564         if (user) {
00565             anope_set_umode(user, 1, &av[3]);
00566         }
00567     } else {
00568         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00569                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00570     }
00571     return MOD_CONT;
00572 }
00573 
00574 /* EVENT : CAPAB */
00575 int anope_event_capab(char *source, int ac, char **av)
00576 {
00577     capab_parse(ac, av);
00578     return MOD_CONT;
00579 }
00580 
00581 /* EVENT : OS */
00582 int anope_event_os(char *source, int ac, char **av)
00583 {
00584     if (ac < 1)
00585         return MOD_CONT;
00586     m_privmsg(source, s_OperServ, av[0]);
00587     return MOD_CONT;
00588 }
00589 
00590 /* EVENT : NS */
00591 int anope_event_ns(char *source, int ac, char **av)
00592 {
00593     if (ac < 1)
00594         return MOD_CONT;
00595     m_privmsg(source, s_NickServ, av[0]);
00596     return MOD_CONT;
00597 }
00598 
00599 /* EVENT : MS */
00600 int anope_event_ms(char *source, int ac, char **av)
00601 {
00602     if (ac < 1)
00603         return MOD_CONT;
00604     m_privmsg(source, s_MemoServ, av[0]);
00605     return MOD_CONT;
00606 }
00607 
00608 /* EVENT : HS */
00609 int anope_event_hs(char *source, int ac, char **av)
00610 {
00611     if (ac < 1)
00612         return MOD_CONT;
00613     m_privmsg(source, s_HostServ, av[0]);
00614     return MOD_CONT;
00615 }
00616 
00617 /* EVENT : CS */
00618 int anope_event_cs(char *source, int ac, char **av)
00619 {
00620     if (ac < 1)
00621         return MOD_CONT;
00622     m_privmsg(source, s_ChanServ, av[0]);
00623     return MOD_CONT;
00624 }
00625 
00626 int anope_event_436(char *source, int ac, char **av)
00627 {
00628     if (ac < 1)
00629         return MOD_CONT;
00630 
00631     m_nickcoll(av[0]);
00632     return MOD_CONT;
00633 }
00634 
00635 /* *INDENT-OFF* */
00636 void moduleAddIRCDMsgs(void) {
00637     Message *m;
00638 
00639 
00640     /* first update the cs protect info about this ircd */
00641     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
00642 
00643     /* now add the commands */
00644     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00645     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00646     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00647     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00648     m = createMessage("INVITE",    anope_event_null); addCoreMessage(IRCD,m);
00649     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00650     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00651     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00652     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00653     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00654     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00655     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00656     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00657     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00658     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00659     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00660     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00661     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00662     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00663     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00664     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00665     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00666     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00667     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00668     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00669     m = createMessage("GNOTICE",   anope_event_gnotice); addCoreMessage(IRCD,m);
00670     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00671     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00672     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00673     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00674     m = createMessage("SVSMODE",   anope_event_mode); addCoreMessage(IRCD,m);
00675     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00676     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00677     m = createMessage("SQLINE",    anope_event_sqline); addCoreMessage(IRCD,m);
00678     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00679     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
00680     m = createMessage("CS",        anope_event_cs); addCoreMessage(IRCD,m);
00681     m = createMessage("HS",        anope_event_hs); addCoreMessage(IRCD,m);
00682     m = createMessage("MS",        anope_event_ms); addCoreMessage(IRCD,m);
00683     m = createMessage("NS",        anope_event_ns); addCoreMessage(IRCD,m);
00684     m = createMessage("OS",        anope_event_os); addCoreMessage(IRCD,m);
00685     m = createMessage("RS",        anope_event_null); addCoreMessage(IRCD,m);
00686     m = createMessage("SGLINE",    anope_event_null); addCoreMessage(IRCD,m);
00687     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
00688     m = createMessage("SS",        anope_event_null); addCoreMessage(IRCD,m);
00689     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
00690     m = createMessage("SZLINE",    anope_event_null); addCoreMessage(IRCD,m);
00691     m = createMessage("UNSGLINE",  anope_event_null); addCoreMessage(IRCD,m);
00692     m = createMessage("UNSZLINE",  anope_event_null); addCoreMessage(IRCD,m);
00693     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
00694     m = createMessage("LUSERSLOCK",anope_event_luserslock); addCoreMessage(IRCD,m);
00695     m = createMessage("BURST",     anope_event_burst); addCoreMessage(IRCD,m);
00696     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00697 
00698 }
00699 
00700 /* *INDENT-ON* */
00701 
00702 /* SQLINE */
00703 void bahamut_cmd_sqline(char *mask, char *reason)
00704 {
00705     if (!mask || !reason) {
00706         return;
00707     }
00708 
00709     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00710 }
00711 
00712 /* UNSGLINE */
00713 void bahamut_cmd_unsgline(char *mask)
00714 {
00715     send_cmd(NULL, "UNSGLINE 0 :%s", mask);
00716 }
00717 
00718 /* UNSZLINE */
00719 void bahamut_cmd_unszline(char *mask)
00720 {
00721     /* this will likely fail so its only here for legacy */
00722     send_cmd(NULL, "UNSZLINE 0 %s", mask);
00723     /* this is how we are supposed to deal with it */
00724     send_cmd(NULL, "RAKILL %s *", mask);
00725 }
00726 
00727 /* SZLINE */
00728 void bahamut_cmd_szline(char *mask, char *reason, char *whom)
00729 {
00730     /* this will likely fail so its only here for legacy */
00731     send_cmd(NULL, "SZLINE %s :%s", mask, reason);
00732     /* this is how we are supposed to deal with it */
00733     send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom,
00734              (long int) time(NULL), reason);
00735 }
00736 
00737 /* SVSNOOP */
00738 void bahamut_cmd_svsnoop(char *server, int set)
00739 {
00740     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00741 }
00742 
00743 void bahamut_cmd_svsadmin(char *server, int set)
00744 {
00745     bahamut_cmd_svsnoop(server, set);
00746 }
00747 
00748 /* SGLINE */
00749 void bahamut_cmd_sgline(char *mask, char *reason)
00750 {
00751     send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason);
00752 }
00753 
00754 /* RAKILL */
00755 void bahamut_cmd_remove_akill(char *user, char *host)
00756 {
00757     send_cmd(NULL, "RAKILL %s %s", host, user);
00758 }
00759 
00760 /* PART */
00761 void bahamut_cmd_part(char *nick, char *chan, char *buf)
00762 {
00763     if (!nick || !chan) {
00764         return;
00765     }
00766 
00767     if (buf) {
00768         send_cmd(nick, "PART %s :%s", chan, buf);
00769     } else {
00770         send_cmd(nick, "PART %s", chan);
00771     }
00772 }
00773 
00774 /* TOPIC */
00775 void bahamut_cmd_topic(char *whosets, char *chan, char *whosetit,
00776                        char *topic, time_t when)
00777 {
00778     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
00779              (unsigned long int) when, topic);
00780 }
00781 
00782 /* UNSQLINE */
00783 void bahamut_cmd_unsqline(char *user)
00784 {
00785     send_cmd(NULL, "UNSQLINE %s", user);
00786 }
00787 
00788 /* JOIN - SJOIN */
00789 void bahamut_cmd_join(char *user, char *channel, time_t chantime)
00790 {
00791     send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel);
00792 }
00793 
00794 void bahamut_cmd_burst()
00795 {
00796     send_cmd(NULL, "BURST");
00797 }
00798 
00799 /* AKILL */
00800 /* parv[1]=host 
00801  * parv[2]=user
00802  * parv[3]=length
00803  * parv[4]=akiller
00804  * parv[5]=time set
00805  * parv[6]=reason
00806  */
00807 void bahamut_cmd_akill(char *user, char *host, char *who, time_t when,
00808                        time_t expires, char *reason)
00809 {
00810     send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who,
00811              (long int) time(NULL), reason);
00812 }
00813 
00814 /* SVSKILL */
00815 /* parv[0] = servername
00816  * parv[1] = client
00817  * parv[2] = nick stamp
00818  * parv[3] = kill message
00819  */
00820 /*
00821   Note: if the stamp is null 0, the below usage is correct of Bahamut
00822 */
00823 void bahamut_cmd_svskill(char *source, char *user, char *buf)
00824 {
00825 
00826     if (!source || !user || !buf) {
00827         return;
00828     }
00829 
00830     send_cmd(source, "SVSKILL %s :%s", user, buf);
00831 }
00832 
00833 /* SVSMODE */
00834 /* parv[0] - sender
00835  * parv[1] - nick
00836  * parv[2] - TS (or mode, depending on svs version)
00837  * parv[3] - mode (or services id if old svs version)
00838  * parv[4] - optional arguement (services id)
00839  */
00840 void bahamut_cmd_svsmode(User * u, int ac, char **av)
00841 {
00842     send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
00843              (long int) u->timestamp, av[0], (ac == 2 ? " " : ""),
00844              (ac == 2 ? av[1] : ""));
00845 }
00846 
00847 /* SQUIT */
00848 /*
00849  *        parv[0] = sender prefix 
00850  *        parv[1] = server name 
00851  *        parv[2] = comment
00852 */
00853 void bahamut_cmd_squit(char *servname, char *message)
00854 {
00855     send_cmd(NULL, "SQUIT %s :%s", servname, message);
00856 }
00857 
00858 /* PONG */
00859 void bahamut_cmd_pong(char *servname, char *who)
00860 {
00861     send_cmd(servname, "PONG %s", who);
00862 }
00863 
00864 /*
00865  * SVINFO 
00866  *       parv[0] = sender prefix 
00867  *       parv[1] = TS_CURRENT for the server 
00868  *       parv[2] = TS_MIN for the server 
00869  *       parv[3] = server is standalone or connected to non-TS only 
00870  *       parv[4] = server's idea of UTC time
00871  */
00872 void bahamut_cmd_svinfo()
00873 {
00874     send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL));
00875 }
00876 
00877 /* PASS */
00878 void bahamut_cmd_pass(char *pass)
00879 {
00880     send_cmd(NULL, "PASS %s :TS", pass);
00881 }
00882 
00883 /* SERVER */
00884 void bahamut_cmd_server(char *servname, int hop, char *descript)
00885 {
00886     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00887 }
00888 
00889 /* CAPAB */
00890 void bahamut_cmd_capab()
00891 {
00892     send_cmd(NULL,
00893              "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3");
00894 }
00895 
00896 void bahamut_cmd_connect(int servernum)
00897 {
00898     me_server =
00899         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00900 
00901     if (servernum == 1) {
00902         bahamut_cmd_pass(RemotePassword);
00903     } else if (servernum == 2) {
00904         bahamut_cmd_pass(RemotePassword2);
00905     } else if (servernum == 3) {
00906         bahamut_cmd_pass(RemotePassword3);
00907     }
00908     bahamut_cmd_capab();
00909     bahamut_cmd_server(ServerName, 1, ServerDesc);
00910     bahamut_cmd_svinfo();
00911     bahamut_cmd_burst();
00912 }
00913 
00914 void bahamut_cmd_bob()
00915 {
00916     /* Not used */
00917 }
00918 
00919 
00920 /* EVENT : SERVER */
00921 int anope_event_server(char *source, int ac, char **av)
00922 {
00923     if (!stricmp(av[1], "1")) {
00924         uplink = sstrdup(av[0]);
00925     }
00926 
00927     do_server(source, av[0], av[1], av[2], NULL);
00928     return MOD_CONT;
00929 }
00930 
00931 /* EVENT : PRIVMSG */
00932 int anope_event_privmsg(char *source, int ac, char **av)
00933 {
00934     if (ac != 2)
00935         return MOD_CONT;
00936     m_privmsg(source, av[0], av[1]);
00937     return MOD_CONT;
00938 }
00939 
00940 /* EVENT : SVINFO */
00941 /*
00942  *       parv[0] = sender prefix 
00943  *       parv[1] = TS_CURRENT for the server 
00944  *       parv[2] = TS_MIN for the server 
00945  *       parv[3] = server is standalone or connected to non-TS only 
00946  *       parv[4] = server's idea of UTC time
00947  */
00948 int anope_event_svinfo(char *source, int ac, char **av)
00949 {
00950     return MOD_CONT;
00951 }
00952 
00953 
00954 int anope_event_part(char *source, int ac, char **av)
00955 {
00956     if (ac < 1 || ac > 2)
00957         return MOD_CONT;
00958     do_part(source, ac, av);
00959     return MOD_CONT;
00960 }
00961 
00962 int anope_event_whois(char *source, int ac, char **av)
00963 {
00964     if (source && ac >= 1) {
00965         m_whois(source, av[0]);
00966     }
00967     return MOD_CONT;
00968 }
00969 
00970 int anope_event_topic(char *source, int ac, char **av)
00971 {
00972     if (ac != 4)
00973         return MOD_CONT;
00974     do_topic(source, ac, av);
00975     return MOD_CONT;
00976 }
00977 
00978 int anope_event_squit(char *source, int ac, char **av)
00979 {
00980     if (ac != 2)
00981         return MOD_CONT;
00982     do_squit(source, ac, av);
00983     return MOD_CONT;
00984 }
00985 
00986 int anope_event_quit(char *source, int ac, char **av)
00987 {
00988     if (ac != 1)
00989         return MOD_CONT;
00990     do_quit(source, ac, av);
00991     return MOD_CONT;
00992 }
00993 
00994 /* EVENT: MODE */
00995 int anope_event_mode(char *source, int ac, char **av)
00996 {
00997     if (ac < 2)
00998         return MOD_CONT;
00999 
01000     if (*av[0] == '#' || *av[0] == '&') {
01001         do_cmode(source, ac, av);
01002     } else {
01003         do_umode(source, ac, av);
01004     }
01005     return MOD_CONT;
01006 }
01007 
01008 /* EVENT: KILL */
01009 int anope_event_kill(char *source, int ac, char **av)
01010 {
01011     if (ac != 2)
01012         return MOD_CONT;
01013 
01014     m_kill(av[0], av[1]);
01015     return MOD_CONT;
01016 }
01017 
01018 /* EVENT: KICK */
01019 int anope_event_kick(char *source, int ac, char **av)
01020 {
01021     if (ac != 3)
01022         return MOD_CONT;
01023     do_kick(source, ac, av);
01024     return MOD_CONT;
01025 }
01026 
01027 /* EVENT: JOIN */
01028 int anope_event_join(char *source, int ac, char **av)
01029 {
01030     if (ac != 1)
01031         return MOD_CONT;
01032     do_join(source, ac, av);
01033     return MOD_CONT;
01034 }
01035 
01036 /* EVENT: MOTD */
01037 int anope_event_motd(char *source, int ac, char **av)
01038 {
01039     if (!source) {
01040         return MOD_CONT;
01041     }
01042 
01043     m_motd(source);
01044     return MOD_CONT;
01045 }
01046 
01047 void bahamut_cmd_notice_ops(char *source, char *dest, char *buf)
01048 {
01049     if (!buf) {
01050         return;
01051     }
01052     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
01053 }
01054 
01055 /* NOTICE */
01056 void bahamut_cmd_notice(char *source, char *dest, char *buf)
01057 {
01058     if (!buf) {
01059         return;
01060     }
01061 
01062     if (NSDefFlags & NI_MSG) {
01063         bahamut_cmd_privmsg2(source, dest, buf);
01064     } else {
01065         send_cmd(source, "NOTICE %s :%s", dest, buf);
01066     }
01067 }
01068 
01069 void bahamut_cmd_notice2(char *source, char *dest, char *msg)
01070 {
01071     send_cmd(source, "NOTICE %s :%s", dest, msg);
01072 }
01073 
01074 void bahamut_cmd_privmsg(char *source, char *dest, char *buf)
01075 {
01076     if (!buf) {
01077         return;
01078     }
01079 
01080     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
01081 }
01082 
01083 void bahamut_cmd_privmsg2(char *source, char *dest, char *msg)
01084 {
01085     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
01086 }
01087 
01088 void bahamut_cmd_serv_notice(char *source, char *dest, char *msg)
01089 {
01090     send_cmd(source, "NOTICE $%s :%s", dest, msg);
01091 }
01092 
01093 void bahamut_cmd_serv_privmsg(char *source, char *dest, char *msg)
01094 {
01095     send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
01096 }
01097 
01098 /* GLOBOPS */
01099 void bahamut_cmd_global(char *source, char *buf)
01100 {
01101     if (!buf) {
01102         return;
01103     }
01104 
01105     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
01106 }
01107 
01108 /* 391 */
01109 void bahamut_cmd_391(char *source, char *timestr)
01110 {
01111     if (!timestr) {
01112         return;
01113     }
01114     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
01115 }
01116 
01117 /* 250 */
01118 void bahamut_cmd_250(char *buf)
01119 {
01120     if (!buf) {
01121         return;
01122     }
01123 
01124     send_cmd(NULL, "250 %s", buf);
01125 }
01126 
01127 /* 307 */
01128 void bahamut_cmd_307(char *buf)
01129 {
01130     if (!buf) {
01131         return;
01132     }
01133 
01134     send_cmd(ServerName, "307 %s", buf);
01135 }
01136 
01137 /* 311 */
01138 void bahamut_cmd_311(char *buf)
01139 {
01140     if (!buf) {
01141         return;
01142     }
01143 
01144     send_cmd(ServerName, "311 %s", buf);
01145 }
01146 
01147 /* 312 */
01148 void bahamut_cmd_312(char *buf)
01149 {
01150     if (!buf) {
01151         return;
01152     }
01153 
01154     send_cmd(ServerName, "312 %s", buf);
01155 }
01156 
01157 /* 317 */
01158 void bahamut_cmd_317(char *buf)
01159 {
01160     if (!buf) {
01161         return;
01162     }
01163 
01164     send_cmd(ServerName, "317 %s", buf);
01165 }
01166 
01167 /* 219 */
01168 void bahamut_cmd_219(char *source, char *letter)
01169 {
01170     if (!source) {
01171         return;
01172     }
01173 
01174     if (letter) {
01175         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
01176                  *letter);
01177     } else {
01178         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
01179     }
01180 }
01181 
01182 /* 401 */
01183 void bahamut_cmd_401(char *source, char *who)
01184 {
01185     if (!source || !who) {
01186         return;
01187     }
01188     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
01189 }
01190 
01191 /* 318 */
01192 void bahamut_cmd_318(char *source, char *who)
01193 {
01194     if (!source || !who) {
01195         return;
01196     }
01197 
01198     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01199 }
01200 
01201 /* 242 */
01202 void bahamut_cmd_242(char *buf)
01203 {
01204     if (!buf) {
01205         return;
01206     }
01207 
01208     send_cmd(NULL, "242 %s", buf);
01209 }
01210 
01211 /* 243 */
01212 void bahamut_cmd_243(char *buf)
01213 {
01214     if (!buf) {
01215         return;
01216     }
01217 
01218     send_cmd(NULL, "243 %s", buf);
01219 }
01220 
01221 /* 211 */
01222 void bahamut_cmd_211(char *buf)
01223 {
01224     if (!buf) {
01225         return;
01226     }
01227 
01228     send_cmd(NULL, "211 %s", buf);
01229 }
01230 
01231 void bahamut_cmd_nick(char *nick, char *name, char *modes)
01232 {
01233     EnforceQlinedNick(nick, NULL);
01234     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
01235              (long int) time(NULL), modes, ServiceUser, ServiceHost,
01236              ServerName, name);
01237     bahamut_cmd_sqline(nick, "Reserved for services");
01238 }
01239 
01240 void bahamut_cmd_kick(char *source, char *chan, char *user, char *buf)
01241 {
01242     if (buf) {
01243         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
01244     } else {
01245         send_cmd(source, "KICK %s %s", chan, user);
01246     }
01247 }
01248 
01249 void bahamut_cmd_372(char *source, char *msg)
01250 {
01251     send_cmd(ServerName, "372 %s :- %s", source, msg);
01252 }
01253 
01254 void bahamut_cmd_372_error(char *source)
01255 {
01256     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
01257              "contact your IRC administrator.", source);
01258 }
01259 
01260 void bahamut_cmd_375(char *source)
01261 {
01262     send_cmd(ServerName, "375 %s :- %s Message of the Day",
01263              source, ServerName);
01264 }
01265 
01266 void bahamut_cmd_376(char *source)
01267 {
01268     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
01269 }
01270 
01271 /* INVITE */
01272 void bahamut_cmd_invite(char *source, char *chan, char *nick)
01273 {
01274     if (!source || !chan || !nick) {
01275         return;
01276     }
01277 
01278     send_cmd(source, "INVITE %s %s", nick, chan);
01279 }
01280 
01281 /* QUIT */
01282 void bahamut_cmd_quit(char *source, char *buf)
01283 {
01284     if (buf) {
01285         send_cmd(source, "QUIT :%s", buf);
01286     } else {
01287         send_cmd(source, "QUIT");
01288     }
01289 }
01290 
01291 int anope_event_away(char *source, int ac, char **av)
01292 {
01293     if (!source) {
01294         return MOD_CONT;
01295     }
01296     m_away(source, (ac ? av[0] : NULL));
01297     return MOD_CONT;
01298 }
01299 
01300 int anope_event_ping(char *source, int ac, char **av)
01301 {
01302     if (ac < 1)
01303         return MOD_CONT;
01304     bahamut_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
01305     return MOD_CONT;
01306 }
01307 
01308 void bahamut_cmd_351(char *source)
01309 {
01310     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01311              source, version_number, ServerName, ircd->name, version_flags,
01312              EncModule, version_build);
01313 
01314 }
01315 
01316 void bahamut_cmd_bot_nick(char *nick, char *user, char *host, char *real,
01317                           char *modes)
01318 {
01319     EnforceQlinedNick(nick, s_BotServ);
01320     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
01321              (long int) time(NULL), modes, user, host, ServerName, real);
01322     bahamut_cmd_sqline(nick, "Reserved for services");
01323 }
01324 
01325 /* SVSNICK */
01326 /* parv[0] = sender
01327  * parv[1] = old nickname
01328  * parv[2] = new nickname
01329  * parv[3] = timestamp
01330  */
01331 void bahamut_cmd_svsnick(char *source, char *guest, time_t when)
01332 {
01333     if (!source || !guest) {
01334         return;
01335     }
01336     send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
01337 }
01338 
01339 void bahamut_cmd_guest_nick(char *nick, char *user, char *host, char *real,
01340                             char *modes)
01341 {
01342     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick,
01343              (long int) time(NULL), modes, user, host, ServerName, real);
01344 }
01345 
01346 void bahamut_cmd_svso(char *source, char *nick, char *flag)
01347 {
01348     /* Not Supported by this IRCD */
01349 }
01350 
01351 void bahamut_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
01352 {
01353     /* Not Supported by this IRCD */
01354 }
01355 
01356 void bahamut_cmd_vhost_off(User * u)
01357 {
01358     /* Not Supported by this IRCD */
01359 }
01360 
01361 /* SVSMODE +d */
01362 /* sent if svid is something weird */
01363 void bahamut_cmd_svid_umode(char *nick, time_t ts)
01364 {
01365     send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
01366              (unsigned long int) ts);
01367 }
01368 
01369 
01370 /* SVSMODE +d */
01371 /* nc_change was = 1, and there is no na->status */
01372 void bahamut_cmd_nc_change(User * u)
01373 {
01374     common_svsmode(u, "+d", "1");
01375 }
01376 
01377 /* SVSMODE +d */
01378 void bahamut_cmd_svid_umode2(User * u, char *ts)
01379 {
01380     /* not used by bahamut ircds */
01381 }
01382 
01383 
01384 void bahamut_cmd_svid_umode3(User * u, char *ts)
01385 {
01386     if (u->svid != u->timestamp) {
01387         common_svsmode(u, "+rd", ts);
01388     } else {
01389         common_svsmode(u, "+r", NULL);
01390     }
01391 }
01392 
01393 /* NICK <newnick>  */
01394 void bahamut_cmd_chg_nick(char *oldnick, char *newnick)
01395 {
01396     if (!oldnick || !newnick) {
01397         return;
01398     }
01399 
01400     send_cmd(oldnick, "NICK %s", newnick);
01401 }
01402 
01403 int anope_event_error(char *source, int ac, char **av)
01404 {
01405     if (ac >= 1) {
01406         if (debug) {
01407             alog("debug: %s", av[0]);
01408         }
01409     }
01410     return MOD_CONT;
01411 }
01412 
01413 int anope_event_notice(char *source, int ac, char **av)
01414 {
01415     return MOD_CONT;
01416 }
01417 
01418 int anope_event_sqline(char *source, int ac, char **av)
01419 {
01420     return MOD_CONT;
01421 }
01422 
01423 
01424 int anope_event_gnotice(char *source, int ac, char **av)
01425 {
01426     return MOD_CONT;
01427 }
01428 
01429 int anope_event_pass(char *source, int ac, char **av)
01430 {
01431     return MOD_CONT;
01432 }
01433 
01434 void bahamut_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
01435 {
01436     /* Can not find any reference to these in Bahamut */
01437 }
01438 
01439 void bahamut_cmd_svspart(char *source, char *nick, char *chan)
01440 {
01441     /* Can not find any reference to these in Bahamut */
01442 }
01443 
01444 void bahamut_cmd_swhois(char *source, char *who, char *mask)
01445 {
01446     /* not supported */
01447 }
01448 
01449 
01450 void bahamut_cmd_eob()
01451 {
01452     send_cmd(NULL, "BURST 0");
01453 }
01454 
01455 int anope_event_burst(char *source, int ac, char **av)
01456 {
01457     Server *s;
01458     s = findserver(servlist, source);
01459     if (!ac) {
01460         /* for future use  - start burst */
01461     } else {
01462         /* If we found a server with the given source, that one just
01463          * finished bursting. If there was no source, then our uplink
01464          * server finished bursting. -GD
01465          */
01466         if (!s && serv_uplink)
01467             s = serv_uplink;
01468         finish_sync(s, 1);
01469     }
01470     return MOD_CONT;
01471 }
01472 
01473 int anope_event_luserslock(char *source, int ac, char **av)
01474 {
01475     return MOD_CONT;
01476 }
01477 
01478 int anope_event_rehash(char *source, int ac, char **av)
01479 {
01480     return MOD_CONT;
01481 }
01482 
01483 int anope_event_credits(char *source, int ac, char **av)
01484 {
01485     return MOD_CONT;
01486 }
01487 
01488 int anope_event_admin(char *source, int ac, char **av)
01489 {
01490     return MOD_CONT;
01491 }
01492 
01493 int bahamut_flood_mode_check(char *value)
01494 {
01495     char *dp, *end;
01496 
01497     if (value && *value != ':'
01498         && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0)
01499         && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0)
01500         && (*end == 0)) {
01501         return 1;
01502     } else {
01503         return 0;
01504     }
01505 }
01506 
01507 void bahamut_cmd_jupe(char *jserver, char *who, char *reason)
01508 {
01509     char rbuf[256];
01510 
01511     snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
01512              reason ? ": " : "", reason ? reason : "");
01513 
01514     if (findserver(servlist, jserver))
01515         bahamut_cmd_squit(jserver, rbuf);
01516     bahamut_cmd_server(jserver, 2, rbuf);
01517     new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
01518 }
01519 
01520 /* GLOBOPS - to handle old WALLOPS */
01521 void bahamut_cmd_global_legacy(char *source, char *fmt)
01522 {
01523     send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
01524 }
01525 
01526 /* 
01527   1 = valid nick
01528   0 = nick is in valid
01529 */
01530 int bahamut_valid_nick(char *nick)
01531 {
01532     /* no hard coded invalid nicks */
01533     return 1;
01534 }
01535 
01536 /* 
01537   1 = valid chan
01538   0 = nick is in chan
01539 */
01540 int bahamut_valid_chan(char *chan)
01541 {
01542     /* no silly invalid chans */
01543     return 1;
01544 }
01545 
01546 void bahamut_cmd_ctcp(char *source, char *dest, char *buf)
01547 {
01548     char *s;
01549     if (!buf) {
01550         return;
01551     } else {
01552         s = normalizeBuffer(buf);
01553     }
01554 
01555     send_cmd(source, "NOTICE %s :\1%s \1", dest, s);
01556     free(s);
01557 }
01558 
01559 /* this avoids "undefined symbol" messages of those whom try to load mods that
01560    call on this function */
01561 void bahamut_cmd_chghost(char *nick, char *vhost)
01562 {
01563     if (debug) {
01564         alog("debug: This IRCD does not support vhosting");
01565     }
01566 }
01567 
01572 void moduleAddAnopeCmds()
01573 {
01574     pmodule_cmd_svsnoop(bahamut_cmd_svsnoop);
01575     pmodule_cmd_remove_akill(bahamut_cmd_remove_akill);
01576     pmodule_cmd_topic(bahamut_cmd_topic);
01577     pmodule_cmd_vhost_off(bahamut_cmd_vhost_off);
01578     pmodule_cmd_akill(bahamut_cmd_akill);
01579     pmodule_cmd_svskill(bahamut_cmd_svskill);
01580     pmodule_cmd_svsmode(bahamut_cmd_svsmode);
01581     pmodule_cmd_372(bahamut_cmd_372);
01582     pmodule_cmd_372_error(bahamut_cmd_372_error);
01583     pmodule_cmd_375(bahamut_cmd_375);
01584     pmodule_cmd_376(bahamut_cmd_376);
01585     pmodule_cmd_nick(bahamut_cmd_nick);
01586     pmodule_cmd_guest_nick(bahamut_cmd_guest_nick);
01587     pmodule_cmd_mode(bahamut_cmd_mode);
01588     pmodule_cmd_bot_nick(bahamut_cmd_bot_nick);
01589     pmodule_cmd_kick(bahamut_cmd_kick);
01590     pmodule_cmd_notice_ops(bahamut_cmd_notice_ops);
01591     pmodule_cmd_notice(bahamut_cmd_notice);
01592     pmodule_cmd_notice2(bahamut_cmd_notice2);
01593     pmodule_cmd_privmsg(bahamut_cmd_privmsg);
01594     pmodule_cmd_privmsg2(bahamut_cmd_privmsg2);
01595     pmodule_cmd_serv_notice(bahamut_cmd_serv_notice);
01596     pmodule_cmd_serv_privmsg(bahamut_cmd_serv_privmsg);
01597     pmodule_cmd_bot_chan_mode(bahamut_cmd_bot_chan_mode);
01598     pmodule_cmd_351(bahamut_cmd_351);
01599     pmodule_cmd_quit(bahamut_cmd_quit);
01600     pmodule_cmd_pong(bahamut_cmd_pong);
01601     pmodule_cmd_join(bahamut_cmd_join);
01602     pmodule_cmd_unsqline(bahamut_cmd_unsqline);
01603     pmodule_cmd_invite(bahamut_cmd_invite);
01604     pmodule_cmd_part(bahamut_cmd_part);
01605     pmodule_cmd_391(bahamut_cmd_391);
01606     pmodule_cmd_250(bahamut_cmd_250);
01607     pmodule_cmd_307(bahamut_cmd_307);
01608     pmodule_cmd_311(bahamut_cmd_311);
01609     pmodule_cmd_312(bahamut_cmd_312);
01610     pmodule_cmd_317(bahamut_cmd_317);
01611     pmodule_cmd_219(bahamut_cmd_219);
01612     pmodule_cmd_401(bahamut_cmd_401);
01613     pmodule_cmd_318(bahamut_cmd_318);
01614     pmodule_cmd_242(bahamut_cmd_242);
01615     pmodule_cmd_243(bahamut_cmd_243);
01616     pmodule_cmd_211(bahamut_cmd_211);
01617     pmodule_cmd_global(bahamut_cmd_global);
01618     pmodule_cmd_global_legacy(bahamut_cmd_global_legacy);
01619     pmodule_cmd_sqline(bahamut_cmd_sqline);
01620     pmodule_cmd_squit(bahamut_cmd_squit);
01621     pmodule_cmd_svso(bahamut_cmd_svso);
01622     pmodule_cmd_chg_nick(bahamut_cmd_chg_nick);
01623     pmodule_cmd_svsnick(bahamut_cmd_svsnick);
01624     pmodule_cmd_vhost_on(bahamut_cmd_vhost_on);
01625     pmodule_cmd_connect(bahamut_cmd_connect);
01626     pmodule_cmd_bob(bahamut_cmd_bob);
01627     pmodule_cmd_svshold(bahamut_cmd_svshold);
01628     pmodule_cmd_release_svshold(bahamut_cmd_release_svshold);
01629     pmodule_cmd_unsgline(bahamut_cmd_unsgline);
01630     pmodule_cmd_unszline(bahamut_cmd_unszline);
01631     pmodule_cmd_szline(bahamut_cmd_szline);
01632     pmodule_cmd_sgline(bahamut_cmd_sgline);
01633     pmodule_cmd_unban(bahamut_cmd_unban);
01634     pmodule_cmd_svsmode_chan(bahamut_cmd_svsmode_chan);
01635     pmodule_cmd_svid_umode(bahamut_cmd_svid_umode);
01636     pmodule_cmd_nc_change(bahamut_cmd_nc_change);
01637     pmodule_cmd_svid_umode2(bahamut_cmd_svid_umode2);
01638     pmodule_cmd_svid_umode3(bahamut_cmd_svid_umode3);
01639     pmodule_cmd_svsjoin(bahamut_cmd_svsjoin);
01640     pmodule_cmd_svspart(bahamut_cmd_svspart);
01641     pmodule_cmd_swhois(bahamut_cmd_swhois);
01642     pmodule_cmd_eob(bahamut_cmd_eob);
01643     pmodule_flood_mode_check(bahamut_flood_mode_check);
01644     pmodule_cmd_jupe(bahamut_cmd_jupe);
01645     pmodule_valid_nick(bahamut_valid_nick);
01646     pmodule_valid_chan(bahamut_valid_chan);
01647     pmodule_cmd_ctcp(bahamut_cmd_ctcp);
01648     pmodule_set_umode(bahamut_set_umode);
01649 }
01650 
01654 int AnopeInit(int argc, char **argv)
01655 {
01656 
01657     moduleAddAuthor("Anope");
01658     moduleAddVersion
01659         (VERSION_STRING);
01660     moduleSetType(PROTOCOL);
01661 
01662     pmodule_ircd_version("BahamutIRCd 1.4.*/1.8.*");
01663     pmodule_ircd_cap(myIrcdcap);
01664     pmodule_ircd_var(myIrcd);
01665     pmodule_ircd_cbmodeinfos(myCbmodeinfos);
01666     pmodule_ircd_cumodes(myCumodes);
01667     pmodule_ircd_flood_mode_char_set("+j");
01668     pmodule_ircd_flood_mode_char_remove("-j");
01669     pmodule_ircd_cbmodes(myCbmodes);
01670     pmodule_ircd_cmmodes(myCmmodes);
01671     pmodule_ircd_csmodes(myCsmodes);
01672     pmodule_ircd_useTSMode(0);
01673 
01675     pmodule_invis_umode(UMODE_i);
01676     pmodule_oper_umode(UMODE_o);
01677     pmodule_invite_cmode(CMODE_i);
01678     pmodule_secret_cmode(CMODE_s);
01679     pmodule_private_cmode(CMODE_p);
01680     pmodule_key_mode(CMODE_k);
01681     pmodule_limit_mode(CMODE_l);
01682     pmodule_permchan_mode(0);
01683 
01684     moduleAddAnopeCmds();
01685     moduleAddIRCDMsgs();
01686 
01687     return MOD_CONT;
01688 }