viagra.c

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