unreal31.c

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