unreal31.c

Go to the documentation of this file.
00001 /* Unreal IRCD 3.1.x functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 
00014 /*************************************************************************/
00015 
00016 #include "services.h"
00017 #include "pseudo.h"
00018 #include "unreal31.h"
00019 
00020 IRCDVar myIrcd[] = {
00021     {"UnrealIRCd 3.1.x",        /* ircd name */
00022      "+oS",                     /* nickserv mode */
00023      "+oS",                     /* chanserv mode */
00024      "+oS",                     /* memoserv mode */
00025      "+oS",                     /* hostserv mode */
00026      "+ioS",                    /* operserv mode */
00027      "+oS",                     /* botserv mode  */
00028      "+oS",                     /* helpserv mode */
00029      "+iS",                     /* Dev/Null mode */
00030      "+ioS",                    /* Global mode   */
00031      "+oS",                     /* nickserv alias mode */
00032      "+oS",                     /* chanserv alias mode */
00033      "+oS",                     /* memoserv alias mode */
00034      "+ioS",                    /* hostserv alias mode */
00035      "+ioS",                    /* operserv alias mode */
00036      "+oS",                     /* botserv alias mode  */
00037      "+oS",                     /* helpserv alias mode */
00038      "+iS",                     /* Dev/Null alias mode */
00039      "+ioS",                    /* Global alias mode   */
00040      "+qS",                     /* Used by BotServ Bots */
00041      5,                         /* Chan Max Symbols     */
00042      "-cilmnpstuzACGHKNOQRSV",  /* Modes to Remove */
00043      "+ao",                     /* Channel Umode used by Botserv bots */
00044      1,                         /* SVSNICK */
00045      1,                         /* Vhost  */
00046      1,                         /* Has Owner */
00047      "+q",                      /* Mode to set for an owner */
00048      "-q",                      /* Mode to unset for an owner */
00049      "+a",                      /* Mode to set for channel admin */
00050      "-a",                      /* Mode to unset for channel admin */
00051      "+rd",                     /* Mode On Reg          */
00052      NULL,                      /* Mode on ID for Roots */
00053      NULL,                      /* Mode on ID for Admins */
00054      NULL,                      /* Mode on ID for Opers */
00055      "-r+d",                    /* Mode on UnReg        */
00056      "-r+d",                    /* Mode on Nick Change  */
00057      0,                         /* Supports SGlines     */
00058      1,                         /* Supports SQlines     */
00059      1,                         /* Supports SZlines     */
00060      1,                         /* Supports Halfop +h   */
00061      3,                         /* Number of server args */
00062      0,                         /* Join 2 Set           */
00063      0,                         /* Join 2 Message       */
00064      1,                         /* Has exceptions +e    */
00065      1,                         /* TS Topic Forward     */
00066      0,                         /* TS Topci Backward    */
00067      0,                         /* Protected Umode      */
00068      0,                         /* Has Admin            */
00069      0,                         /* Chan SQlines         */
00070      0,                         /* Quit on Kill         */
00071      0,                         /* SVSMODE unban        */
00072      1,                         /* Has Protect          */
00073      1,                         /* Reverse              */
00074      1,                         /* Chan Reg             */
00075      CMODE_r,                   /* Channel Mode         */
00076      1,                         /* vidents              */
00077      1,                         /* svshold              */
00078      1,                         /* time stamp on mode   */
00079      0,                         /* NICKIP               */
00080      1,                         /* O:LINE               */
00081      1,                         /* UMODE               */
00082      1,                         /* VHOST ON NICK        */
00083      1,                         /* Change RealName      */
00084      CMODE_K,                   /* No Knock             */
00085      CMODE_A,                   /* Admin Only           */
00086      DEFAULT_MLOCK,             /* Default MLOCK       */
00087      UMODE_x,                   /* Vhost Mode           */
00088      1,                         /* +f                   */
00089      1,                         /* +L                   */
00090      CMODE_f,
00091      CMODE_L,
00092      0,
00093      1,                         /* No Knock requires +i */
00094      NULL,                      /* CAPAB Chan Modes             */
00095      0,                         /* We support Unreal TOKENS */
00096      1,                         /* TOKENS are CASE inSensitive */
00097      0,                         /* TIME STAMPS are BASE64 */
00098      0,                         /* +I support */
00099      0,                         /* SJOIN ban char */
00100      0,                         /* SJOIN except char */
00101      0,                         /* SJOIN invite char */
00102      0,                         /* Can remove User Channel Modes with SVSMODE */
00103      0,                         /* Sglines are not enforced until user reconnects */
00104      "x",                       /* vhost char */
00105      0,                         /* ts6 */
00106      1,                         /* support helper umode */
00107      0,                         /* p10 */
00108      NULL,                      /* character set */
00109      0,                         /* reports sync state */
00110      }
00111     ,
00112     {NULL}
00113 };
00114 
00115 
00116 IRCDCAPAB myIrcdcap[] = {
00117     {
00118      CAPAB_NOQUIT,              /* NOQUIT       */
00119      0,                         /* TSMODE       */
00120      0,                         /* UNCONNECT    */
00121      0,                         /* NICKIP       */
00122      0,                         /* SJOIN        */
00123      CAPAB_ZIP,                 /* ZIP          */
00124      0,                         /* BURST        */
00125      0,                         /* TS5          */
00126      0,                         /* TS3          */
00127      0,                         /* DKEY         */
00128      0,                         /* PT4          */
00129      0,                         /* SCS          */
00130      0,                         /* QS           */
00131      0,                         /* UID          */
00132      0,                         /* KNOCK        */
00133      0,                         /* CLIENT       */
00134      0,                         /* IPV6         */
00135      0,                         /* SSJ5         */
00136      0,                         /* SN2          */
00137      CAPAB_TOKEN,               /* TOKEN        */
00138      0,                         /* VHOST        */
00139      CAPAB_SSJ3,                /* SSJ3         */
00140      CAPAB_NICK2,               /* NICK2        */
00141      CAPAB_UMODE2,              /* UMODE2       */
00142      CAPAB_VL,                  /* VL           */
00143      CAPAB_TLKEXT,              /* TLKEXT       */
00144      0,                         /* DODKEY       */
00145      0,                         /* DOZIP        */
00146      0,
00147      0, 0}
00148 };
00149 
00150 unsigned long umodes[128] = {
00151     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00152     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00153     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00154     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00155     0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00156     0,
00157     0,
00158     0,
00159     0, 0, 0, 0, 0, 0, 0,
00160     0,
00161     0, 0, 0, 0, 0,
00162     0, UMODE_a, 0, 0, 0, 0, 0,
00163     UMODE_g,
00164     UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o,
00165     0,
00166     0, UMODE_r, 0, 0, 0, 0, UMODE_w,
00167     UMODE_x,
00168     0,
00169     0,
00170     0, 0, 0, 0, 0
00171 };
00172 
00173 
00174 char myCsmodes[128] = {
00175     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00176     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00177 
00178     0,
00179     0,
00180     0, 0, 0,
00181     'h',                        /* (37) % Channel halfops */
00182     0,
00183     0, 0, 0,
00184     'q',
00185 
00186     'v', 0, 0, 0, 0,
00187     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00188 
00189     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00190     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00191 
00192     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00193     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0
00194 };
00195 
00196 CMMode myCmmodes[128] = {
00197     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00198     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00199     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00200     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00201     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
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},
00210     {NULL},
00211     {add_ban, del_ban},
00212     {NULL},
00213     {NULL},
00214     {add_exception, del_exception},
00215     {NULL},
00216     {NULL},
00217     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00218     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00219     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00220 };
00221 
00222 
00223 
00224 CBMode myCbmodes[128] = {
00225     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00226     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00227     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00228     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00229     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
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},
00234     {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL},
00235     {0},                        /* B */
00236     {CMODE_C, 0, NULL, NULL},   /* C */
00237     {0},                        /* D */
00238     {0},                        /* E */
00239     {0},                        /* F */
00240     {CMODE_G, 0, NULL, NULL},   /* G */
00241     {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL},
00242     {0},                        /* I */
00243     {0},                        /* J */
00244     {CMODE_K, 0, NULL, NULL},   /* K */
00245     {CMODE_L, 0, set_redirect, cs_set_redirect},
00246     {0},                        /* M */
00247     {CMODE_N, 0, NULL, NULL},   /* N */
00248     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},
00249     {0},                        /* P */
00250     {CMODE_Q, 0, NULL, NULL},   /* Q */
00251     {CMODE_R, 0, NULL, NULL},   /* R */
00252     {CMODE_S, 0, NULL, NULL},   /* S */
00253     {0},                        /* T */
00254     {0},                        /* U */
00255     {CMODE_V, 0, NULL, NULL},   /* V */
00256     {0},                        /* W */
00257     {0},                        /* X */
00258     {0},                        /* Y */
00259     {0},                        /* Z */
00260     {0}, {0}, {0}, {0}, {0}, {0},
00261     {0},                        /* a */
00262     {0},                        /* b */
00263     {CMODE_c, 0, NULL, NULL},
00264     {0},                        /* d */
00265     {0},                        /* e */
00266     {CMODE_f, 0, set_flood, cs_set_flood},
00267     {0},                        /* g */
00268     {0},                        /* h */
00269     {CMODE_i, 0, NULL, NULL},
00270     {0},                        /* j */
00271     {CMODE_k, 0, chan_set_key, cs_set_key},
00272     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00273     {CMODE_m, 0, NULL, NULL},
00274     {CMODE_n, 0, NULL, NULL},
00275     {0},                        /* o */
00276     {CMODE_p, 0, NULL, NULL},
00277     {0},                        /* q */
00278     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00279     {CMODE_s, 0, NULL, NULL},
00280     {CMODE_t, 0, NULL, NULL},
00281     {CMODE_u, 0, NULL, NULL},
00282     {0},                        /* v */
00283     {0},                        /* w */
00284     {0},                        /* x */
00285     {0},                        /* y */
00286     {CMODE_z, 0, NULL, NULL},
00287     {0}, {0}, {0}, {0}
00288 };
00289 
00290 CBModeInfo myCbmodeinfos[] = {
00291     {'c', CMODE_c, 0, NULL, NULL},
00292     {'f', CMODE_f, 0, get_flood, cs_get_flood},
00293     {'i', CMODE_i, 0, NULL, NULL},
00294     {'k', CMODE_k, 0, get_key, cs_get_key},
00295     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00296     {'m', CMODE_m, 0, NULL, NULL},
00297     {'n', CMODE_n, 0, NULL, NULL},
00298     {'p', CMODE_p, 0, NULL, NULL},
00299     {'r', CMODE_r, 0, NULL, NULL},
00300     {'s', CMODE_s, 0, NULL, NULL},
00301     {'t', CMODE_t, 0, NULL, NULL},
00302     {'u', CMODE_u, 0, NULL, NULL},
00303     {'z', CMODE_z, 0, NULL, NULL},
00304     {'A', CMODE_A, 0, NULL, NULL},
00305     {'C', CMODE_C, 0, NULL, NULL},
00306     {'G', CMODE_G, 0, NULL, NULL},
00307     {'H', CMODE_H, 0, NULL, NULL},
00308     {'K', CMODE_K, 0, NULL, NULL},
00309     {'L', CMODE_L, 0, get_redirect, cs_get_redirect},
00310     {'N', CMODE_N, 0, NULL, NULL},
00311     {'O', CMODE_O, 0, NULL, NULL},
00312     {'Q', CMODE_Q, 0, NULL, NULL},
00313     {'R', CMODE_R, 0, NULL, NULL},
00314     {'S', CMODE_S, 0, NULL, NULL},
00315     {'V', CMODE_V, 0, NULL, NULL},
00316     {0}
00317 };
00318 
00319 CUMode myCumodes[128] = {
00320     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00321     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00322     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00323     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00324 
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},
00336 
00337     {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op},
00338     {0},                        /* b */
00339     {0},                        /* c */
00340     {0},                        /* d */
00341     {0},                        /* e */
00342     {0},                        /* f */
00343     {0},                        /* g */
00344     {CUS_HALFOP, 0, check_valid_op},
00345     {0},                        /* i */
00346     {0},                        /* j */
00347     {0},                        /* k */
00348     {0},                        /* l */
00349     {0},                        /* m */
00350     {0},                        /* n */
00351     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00352     {0},                        /* p */
00353     {CUS_OWNER, 0, check_valid_op},
00354     {0},                        /* r */
00355     {0},                        /* s */
00356     {0},                        /* t */
00357     {0},                        /* u */
00358     {CUS_VOICE, 0, NULL},
00359     {0},                        /* w */
00360     {0},                        /* x */
00361     {0},                        /* y */
00362     {0},                        /* z */
00363     {0}, {0}, {0}, {0}, {0}
00364 };
00365 
00366 
00367 void unreal_set_umode(User * user, int ac, char **av)
00368 {
00369     int add = 1;                /* 1 if adding modes, 0 if deleting */
00370     char *modes = av[0];
00371 
00372     ac--;
00373 
00374     if (debug)
00375         alog("debug: Changing mode for %s to %s", user->nick, modes);
00376 
00377     while (*modes) {
00378 
00379         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00380          * At least this is readable without paying much attention :) -GD
00381          */
00382         if (add)
00383             user->mode |= umodes[(int) *modes];
00384         else
00385             user->mode &= ~umodes[(int) *modes];
00386 
00387         switch (*modes++) {
00388         case '+':
00389             add = 1;
00390             break;
00391         case '-':
00392             add = 0;
00393             break;
00394         case 'd':
00395             if (ac == 0) {
00396                 break;
00397             }
00398 
00399             ac--;
00400             av++;
00401             user->svid = strtoul(*av, NULL, 0);
00402             break;
00403         case 'o':
00404             if (add) {
00405                 opcnt++;
00406                 if (WallOper) {
00407                     anope_cmd_global(s_OperServ,
00408                                      "\2%s\2 is now an IRC operator.",
00409                                      user->nick);
00410                 }
00411                 display_news(user, NEWS_OPER);
00412             } else {
00413                 opcnt--;
00414             }
00415             break;
00416         case 'r':
00417             if (add && !nick_identified(user)) {
00418                 common_svsmode(user, "-r", NULL);
00419                 user->mode &= ~UMODE_r;
00420             }
00421             break;
00422         case 'x':
00423             update_host(user);
00424             break;
00425         }
00426     }
00427 }
00428 
00429 
00430 /* *INDENT-OFF* */
00431 void moduleAddIRCDMsgs(void) {
00432     Message *m;
00433 
00434     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a");
00435 
00436     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00437     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00438     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00439     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00440     m = createMessage("INVITE",    anope_event_null); addCoreMessage(IRCD,m);
00441     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00442     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00443     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00444     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00445     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00446     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00447     m = createMessage("NOTICE",    anope_event_null); addCoreMessage(IRCD,m);
00448     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00449     m = createMessage("PASS",      anope_event_null); addCoreMessage(IRCD,m);
00450     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00451     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00452     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00453     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00454     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00455     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00456     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00457     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00458     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00459     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00460     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00461     m = createMessage("GNOTICE",   anope_event_null); addCoreMessage(IRCD,m);
00462     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00463     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00464     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00465     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00466     m = createMessage("SVSMODE",   anope_event_null); addCoreMessage(IRCD,m);
00467     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00468     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00469     m = createMessage("SQLINE",    anope_event_null); addCoreMessage(IRCD,m);
00470     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00471     m = createMessage("PROTOCTL",  anope_event_capab); addCoreMessage(IRCD,m);
00472     m = createMessage("CHGHOST",   anope_event_chghost); addCoreMessage(IRCD,m);
00473     m = createMessage("CHGIDENT",  anope_event_chgident); addCoreMessage(IRCD,m);
00474     m = createMessage("CHGNAME",   anope_event_chgname); addCoreMessage(IRCD,m);
00475     m = createMessage("NETINFO",   anope_event_null); addCoreMessage(IRCD,m);
00476     m = createMessage("SETHOST",   anope_event_sethost); addCoreMessage(IRCD,m);
00477     m = createMessage("SETIDENT",  anope_event_setident); addCoreMessage(IRCD,m);
00478     m = createMessage("SETNAME",   anope_event_setname); addCoreMessage(IRCD,m);
00479     m = createMessage("REHASH",    anope_event_rehash); addCoreMessage(IRCD,m);
00480     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00481     m = createMessage("CREDITS",   anope_event_credits); addCoreMessage(IRCD,m);
00482 }
00483 
00484 /* *INDENT-ON* */
00485 
00486 /* Event: PROTOCTL */
00487 int anope_event_capab(char *source, int ac, char **av)
00488 {
00489     capab_parse(ac, av);
00490     return MOD_CONT;
00491 }
00492 
00493 void unreal_cmd_svsnoop(char *server, int set)
00494 {
00495     send_cmd(NULL, "SVSNOOP %s %s", server, (set ? "+" : "-"));
00496 }
00497 
00498 void unreal_cmd_svsadmin(char *server, int set)
00499 {
00500     unreal_cmd_svsnoop(server, set);
00501 }
00502 
00503 void unreal_cmd_remove_akill(char *user, char *host)
00504 {
00505     send_cmd(NULL, "TKL - G %s %s %s", user, host, s_OperServ);
00506 }
00507 
00508 void unreal_cmd_topic(char *whosets, char *chan, char *whosetit,
00509                       char *topic, time_t when)
00510 {
00511     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
00512              (unsigned long int) when, topic);
00513 }
00514 
00515 void unreal_cmd_vhost_off(User * u)
00516 {
00517     send_cmd(s_HostServ, "SVSMODE %s -xt", u->nick);
00518     notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar);
00519 }
00520 
00521 void unreal_cmd_akill(char *user, char *host, char *who, time_t when,
00522                       time_t expires, char *reason)
00523 {
00524     send_cmd(NULL, "TKL + G %s %s %s %ld %ld :%s", user, host, who,
00525              (long int) time(NULL) + 86400 * 2, (long int) when, reason);
00526 }
00527 
00528 void unreal_cmd_svskill(char *source, char *user, char *buf)
00529 {
00530     if (!buf) {
00531         return;
00532     }
00533 
00534     if (!source || !user) {
00535         return;
00536     }
00537 
00538     send_cmd(source, "SVSKILL %s :%s", user, buf);
00539 }
00540 
00541 void unreal_cmd_svsmode(User * u, int ac, char **av)
00542 {
00543     send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
00544              (ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
00545 }
00546 
00547 
00548 void unreal_cmd_372(char *source, char *msg)
00549 {
00550     send_cmd(ServerName, "372 %s :- %s", source, msg);
00551 }
00552 
00553 void unreal_cmd_372_error(char *source)
00554 {
00555     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
00556              "contact your IRC administrator.", source);
00557 }
00558 
00559 void unreal_cmd_375(char *source)
00560 {
00561     send_cmd(ServerName, "375 %s :- %s Message of the Day",
00562              source, ServerName);
00563 }
00564 
00565 void unreal_cmd_376(char *source)
00566 {
00567     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
00568 }
00569 
00570 void unreal_cmd_nick(char *nick, char *name, char *modes)
00571 {
00572     EnforceQlinedNick(nick, NULL);
00573     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
00574              (long int) time(NULL), ServiceUser, ServiceHost, ServerName,
00575              modes, name);
00576     unreal_cmd_sqline(nick, "Reserved for services");
00577 }
00578 
00579 void unreal_cmd_guest_nick(char *nick, char *user, char *host, char *real,
00580                            char *modes)
00581 {
00582     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
00583              (long int) time(NULL), user, host, ServerName, modes, real);
00584 }
00585 
00586 void unreal_cmd_mode(char *source, char *dest, char *buf)
00587 {
00588     if (!buf) {
00589         return;
00590     }
00591 
00592     send_cmd(source, "MODE %s %s", dest, buf);
00593 }
00594 
00595 void unreal_cmd_bot_nick(char *nick, char *user, char *host, char *real,
00596                          char *modes)
00597 {
00598     EnforceQlinedNick(nick, s_BotServ);
00599     send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", nick,
00600              (long int) time(NULL), user, host, ServerName, modes, real);
00601     unreal_cmd_sqline(nick, "Reserved for services");
00602 }
00603 
00604 void unreal_cmd_kick(char *source, char *chan, char *user, char *buf)
00605 {
00606     if (buf) {
00607         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
00608     } else {
00609         send_cmd(source, "KICK %s %s", chan, user);
00610     }
00611 }
00612 
00613 void unreal_cmd_notice_ops(char *source, char *dest, char *buf)
00614 {
00615     if (!buf) {
00616         return;
00617     }
00618 
00619     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
00620 }
00621 
00622 
00623 void unreal_cmd_notice(char *source, char *dest, char *buf)
00624 {
00625     if (!buf) {
00626         return;
00627     }
00628 
00629     if (NSDefFlags & NI_MSG) {
00630         unreal_cmd_privmsg2(source, dest, buf);
00631     } else {
00632         send_cmd(source, "NOTICE %s :%s", dest, buf);
00633     }
00634 }
00635 
00636 void unreal_cmd_notice2(char *source, char *dest, char *msg)
00637 {
00638     send_cmd(source, "NOTICE %s :%s", dest, msg);
00639 }
00640 
00641 void unreal_cmd_privmsg(char *source, char *dest, char *buf)
00642 {
00643     if (!buf) {
00644         return;
00645     }
00646 
00647     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
00648 }
00649 
00650 void unreal_cmd_privmsg2(char *source, char *dest, char *msg)
00651 {
00652     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
00653 }
00654 
00655 void unreal_cmd_serv_notice(char *source, char *dest, char *msg)
00656 {
00657     send_cmd(source, "NOTICE $%s :%s", dest, msg);
00658 }
00659 
00660 void unreal_cmd_serv_privmsg(char *source, char *dest, char *msg)
00661 {
00662     send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
00663 }
00664 
00665 
00666 void unreal_cmd_bot_chan_mode(char *nick, char *chan)
00667 {
00668     anope_cmd_mode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick);
00669 }
00670 
00671 void unreal_cmd_351(char *source)
00672 {
00673     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
00674              source, version_number, ServerName, ircd->name, version_flags,
00675              EncModule, version_build);
00676 }
00677 
00678 /* QUIT */
00679 void unreal_cmd_quit(char *source, char *buf)
00680 {
00681     if (buf) {
00682         send_cmd(source, "QUIT :%s", buf);
00683     } else {
00684         send_cmd(source, "QUIT");
00685     }
00686 }
00687 
00688 /* PROTOCTL */
00689 void unreal_cmd_protoctl()
00690 {
00691     /*
00692        See Unreal's protoctl.txt for reference
00693        VHP - Send hostnames in NICKv2 even if not sethosted 
00694      */
00695     send_cmd(NULL, "PROTOCTL NICKv2 VHP");
00696 }
00697 
00698 /* PASS */
00699 void unreal_cmd_pass(char *pass)
00700 {
00701     send_cmd(NULL, "PASS :%s", pass);
00702 }
00703 
00704 /* SERVER name hop descript */
00705 /* Unreal 3.2 actually sends some info about itself in the descript area */
00706 void unreal_cmd_server(char *servname, int hop, char *descript)
00707 {
00708     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00709 }
00710 
00711 /* PONG */
00712 void unreal_cmd_pong(char *servname, char *who)
00713 {
00714     send_cmd(servname, "PONG %s", who);
00715 }
00716 
00717 /* JOIN */
00718 /* Althought Unreal 3.2 does not need the timestamp others do so
00719    we get it in the common function call */
00720 void unreal_cmd_join(char *user, char *channel, time_t chantime)
00721 {
00722     send_cmd(user, "JOIN %s", channel);
00723 }
00724 
00725 /* UNSQLINE */
00726 void unreal_cmd_unsqline(char *user)
00727 {
00728     if (!user) {
00729         return;
00730     }
00731     send_cmd(NULL, "UNSQLINE %s", user);
00732 }
00733 
00734 /* CHGHOST */
00735 void unreal_cmd_chghost(char *nick, char *vhost)
00736 {
00737     if (!nick || !vhost) {
00738         return;
00739     }
00740     send_cmd(ServerName, "CHGHOST %s %s", nick, vhost);
00741 }
00742 
00743 /* CHGIDENT */
00744 void unreal_cmd_chgident(char *nick, char *vIdent)
00745 {
00746     if (!nick || !vIdent) {
00747         return;
00748     }
00749     send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent);
00750 }
00751 
00752 /* INVITE */
00753 void unreal_cmd_invite(char *source, char *chan, char *nick)
00754 {
00755     if (!source || !chan || !nick) {
00756         return;
00757     }
00758 
00759     send_cmd(source, "INVITE %s %s", nick, chan);
00760 }
00761 
00762 /* PART */
00763 void unreal_cmd_part(char *nick, char *chan, char *buf)
00764 {
00765     if (!nick || !chan) {
00766         return;
00767     }
00768 
00769     if (buf) {
00770         send_cmd(nick, "PART %s :%s", chan, buf);
00771     } else {
00772         send_cmd(nick, "PART %s", chan);
00773     }
00774 }
00775 
00776 /* 391 */
00777 void unreal_cmd_391(char *source, char *timestr)
00778 {
00779     if (!timestr) {
00780         return;
00781     }
00782     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
00783 }
00784 
00785 /* 250 */
00786 void unreal_cmd_250(char *buf)
00787 {
00788     if (!buf) {
00789         return;
00790     }
00791 
00792     send_cmd(NULL, "250 %s", buf);
00793 }
00794 
00795 /* 307 */
00796 void unreal_cmd_307(char *buf)
00797 {
00798     if (!buf) {
00799         return;
00800     }
00801 
00802     send_cmd(ServerName, "307 %s", buf);
00803 }
00804 
00805 /* 311 */
00806 void unreal_cmd_311(char *buf)
00807 {
00808     if (!buf) {
00809         return;
00810     }
00811 
00812     send_cmd(ServerName, "311 %s", buf);
00813 }
00814 
00815 /* 312 */
00816 void unreal_cmd_312(char *buf)
00817 {
00818     if (!buf) {
00819         return;
00820     }
00821 
00822     send_cmd(ServerName, "312 %s", buf);
00823 }
00824 
00825 /* 317 */
00826 void unreal_cmd_317(char *buf)
00827 {
00828     if (!buf) {
00829         return;
00830     }
00831 
00832     send_cmd(ServerName, "317 %s", buf);
00833 }
00834 
00835 /* 219 */
00836 void unreal_cmd_219(char *source, char *letter)
00837 {
00838     if (!source) {
00839         return;
00840     }
00841 
00842     if (letter) {
00843         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
00844                  *letter);
00845     } else {
00846         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
00847     }
00848 }
00849 
00850 /* 401 */
00851 void unreal_cmd_401(char *source, char *who)
00852 {
00853     if (!source || !who) {
00854         return;
00855     }
00856     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
00857 }
00858 
00859 /* 318 */
00860 void unreal_cmd_318(char *source, char *who)
00861 {
00862     if (!source || !who) {
00863         return;
00864     }
00865 
00866     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
00867 }
00868 
00869 /* 242 */
00870 void unreal_cmd_242(char *buf)
00871 {
00872     if (!buf) {
00873         return;
00874     }
00875 
00876     send_cmd(NULL, "242 %s", buf);
00877 }
00878 
00879 /* 243 */
00880 void unreal_cmd_243(char *buf)
00881 {
00882     if (!buf) {
00883         return;
00884     }
00885 
00886     send_cmd(NULL, "243 %s", buf);
00887 }
00888 
00889 /* 211 */
00890 void unreal_cmd_211(char *buf)
00891 {
00892     if (!buf) {
00893         return;
00894     }
00895 
00896     send_cmd(NULL, "211 %s", buf);
00897 }
00898 
00899 /* GLOBOPS */
00900 void unreal_cmd_global(char *source, char *buf)
00901 {
00902     if (!buf) {
00903         return;
00904     }
00905 
00906     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
00907 }
00908 
00909 /* SQLINE */
00910 void unreal_cmd_sqline(char *mask, char *reason)
00911 {
00912     if (!mask || !reason) {
00913         return;
00914     }
00915 
00916     send_cmd(NULL, "SQLINE %s :%s", mask, reason);
00917 }
00918 
00919 /* SQUIT */
00920 void unreal_cmd_squit(char *servname, char *message)
00921 {
00922     if (!servname || !message) {
00923         return;
00924     }
00925 
00926     send_cmd(NULL, "SQUIT %s :%s", servname, message);
00927 }
00928 
00929 /* SVSO */
00930 void unreal_cmd_svso(char *source, char *nick, char *flag)
00931 {
00932     if (!source || !nick || !flag) {
00933         return;
00934     }
00935 
00936     send_cmd(source, "SVSO %s %s", nick, flag);
00937 }
00938 
00939 /* NICK <newnick>  */
00940 void unreal_cmd_chg_nick(char *oldnick, char *newnick)
00941 {
00942     if (!oldnick || !newnick) {
00943         return;
00944     }
00945 
00946     send_cmd(oldnick, "NICK %s", newnick);
00947 }
00948 
00949 /* SVSNICK */
00950 void unreal_cmd_svsnick(char *source, char *guest, time_t when)
00951 {
00952     if (!source || !guest) {
00953         return;
00954     }
00955     send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
00956 }
00957 
00958 /* Functions that use serval cmd functions */
00959 
00960 void unreal_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00961 {
00962     if (!nick) {
00963         return;
00964     }
00965     if (vIdent) {
00966         unreal_cmd_chgident(nick, vIdent);
00967     }
00968     unreal_cmd_chghost(nick, vhost);
00969 }
00970 
00971 void unreal_cmd_connect(int servernum)
00972 {
00973     me_server =
00974         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00975 
00976     unreal_cmd_protoctl();
00977     if (servernum == 1) {
00978         unreal_cmd_pass(RemotePassword);
00979     }
00980     if (servernum == 2) {
00981         unreal_cmd_pass(RemotePassword2);
00982     }
00983     if (servernum == 3) {
00984         unreal_cmd_pass(RemotePassword3);
00985     }
00986     unreal_cmd_server(ServerName, 1, ServerDesc);
00987 }
00988 
00989 /* Events */
00990 
00991 int anope_event_ping(char *source, int ac, char **av)
00992 {
00993     if (ac < 1)
00994         return MOD_CONT;
00995     unreal_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
00996     return MOD_CONT;
00997 }
00998 
00999 int anope_event_436(char *source, int ac, char **av)
01000 {
01001     if (ac < 1)
01002         return MOD_CONT;
01003 
01004     m_nickcoll(av[0]);
01005     return MOD_CONT;
01006 }
01007 
01008 int anope_event_away(char *source, int ac, char **av)
01009 {
01010     if (!source) {
01011         return MOD_CONT;
01012     }
01013     m_away(source, (ac ? av[0] : NULL));
01014     return MOD_CONT;
01015 }
01016 
01017 int anope_event_topic(char *source, int ac, char **av)
01018 {
01019     if (ac != 4)
01020         return MOD_CONT;
01021     do_topic(source, ac, av);
01022     return MOD_CONT;
01023 }
01024 
01025 int anope_event_squit(char *source, int ac, char **av)
01026 {
01027     if (ac != 2)
01028         return