rageircd.c

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