solidircd.c

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