rageircd.c

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