hybrid.c

Go to the documentation of this file.
00001 /* Hybrid 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  *
00012  */
00013 
00014 #include "services.h"
00015 #include "pseudo.h"
00016 #include "hybrid.h"
00017 
00018 IRCDVar myIrcd[] = {
00019     {"HybridIRCd 7.*",          /* ircd name */
00020      "+o",                      /* nickserv mode */
00021      "+o",                      /* chanserv mode */
00022      "+o",                      /* memoserv mode */
00023      NULL,                      /* hostserv mode */
00024      "+aio",                    /* operserv mode */
00025      "+o",                      /* botserv mode  */
00026      "+h",                      /* helpserv mode */
00027      "+i",                      /* Dev/Null mode */
00028      "+io",                     /* Global mode   */
00029      "+o",                      /* nickserv alias mode */
00030      "+o",                      /* chanserv alias mode */
00031      "+o",                      /* memoserv alias mode */
00032      NULL,                      /* hostserv alias mode */
00033      "+aio",                    /* operserv alias mode */
00034      "+o",                      /* botserv alias mode  */
00035      "+h",                      /* helpserv alias mode */
00036      "+i",                      /* Dev/Null alias mode */
00037      "+io",                     /* Global alias mode   */
00038      "+",                       /* Used by BotServ Bots */
00039      3,                         /* Chan Max Symbols     */
00040      "-ailmnpst",               /* Modes to Remove */
00041      "+o",                      /* Channel Umode used by Botserv bots */
00042      0,                         /* SVSNICK */
00043      0,                         /* Vhost  */
00044      0,                         /* Has Owner */
00045      NULL,                      /* Mode to set for an owner */
00046      NULL,                      /* Mode to unset for an owner */
00047      NULL,                      /* Mode to set for admin */
00048      NULL,                      /* Mode to unset for admin */
00049      NULL,                      /* Mode On Reg          */
00050      NULL,                      /* Mode on ID for Roots */
00051      NULL,                      /* Mode on ID for Admins */
00052      NULL,                      /* Mode on ID for Opers */
00053      NULL,                      /* Mode on UnReg        */
00054      NULL,                      /* Mode on Nick Change  */
00055      1,                         /* Supports SGlines     */
00056      1,                         /* Supports SQlines     */
00057      0,                         /* Supports SZlines     */
00058      1,                         /* Supports Halfop +h   */
00059      3,                         /* Number of server args */
00060      1,                         /* Join 2 Set           */
00061      1,                         /* Join 2 Message       */
00062      1,                         /* Has exceptions +e    */
00063      0,                         /* TS Topic Forward     */
00064      0,                         /* TS Topci Backward    */
00065      0,                         /* Protected Umode      */
00066      0,                         /* Has Admin            */
00067      0,                         /* Chan SQlines         */
00068      0,                         /* Quit on Kill         */
00069      0,                         /* SVSMODE unban        */
00070      0,                         /* Has Protect          */
00071      0,                         /* Reverse              */
00072      0,                         /* Chan Reg             */
00073      0,                         /* Channel Mode         */
00074      0,                         /* vidents              */
00075      0,                         /* svshold              */
00076      0,                         /* time stamp on mode   */
00077      0,                         /* NICKIP               */
00078      0,                         /* UMODE                */
00079      0,                         /* O:LINE               */
00080      0,                         /* VHOST ON NICK        */
00081      0,                         /* Change RealName      */
00082      CMODE_p,                   /* No Knock             */
00083      0,                         /* Admin Only           */
00084      DEFAULT_MLOCK,             /* Default MLOCK        */
00085      0,                         /* Vhost Mode           */
00086      0,                         /* +f                   */
00087      0,                         /* +L                   */
00088      0,                         /* +f Mode                          */
00089      0,                         /* +L Mode                              */
00090      0,                         /* On nick change check if they could be identified */
00091      0,                         /* No Knock requires +i */
00092      NULL,                      /* CAPAB Chan Modes             */
00093      0,                         /* We support TOKENS */
00094      1,                         /* TOKENS are CASE inSensitive */
00095      0,                         /* TIME STAMPS are BASE64 */
00096      0,                         /* +I support */
00097      0,                         /* SJOIN ban char */
00098      0,                         /* SJOIN except char */
00099      0,                         /* SJOIN invite char */
00100      0,                         /* Can remove User Channel Modes with SVSMODE */
00101      0,                         /* Sglines are not enforced until user reconnects */
00102      NULL,                      /* vhost char */
00103      0,                         /* ts6 */
00104      0,                         /* support helper umode */
00105      0,                         /* p10 */
00106      NULL,                      /* character set */
00107      0,                         /* reports sync state */
00108      0,                         /* CIDR channelbans */
00109      }
00110     ,
00111     {NULL}
00112 };
00113 
00114 IRCDCAPAB myIrcdcap[] = {
00115     {
00116      CAPAB_NOQUIT,              /* NOQUIT       */
00117      0,                         /* TSMODE       */
00118      0,                         /* UNCONNECT    */
00119      0,                         /* NICKIP       */
00120      0,                         /* SJOIN        */
00121      CAPAB_ZIP,                 /* ZIP          */
00122      0,                         /* BURST        */
00123      CAPAB_TS5,                 /* TS5          */
00124      0,                         /* TS3          */
00125      0,                         /* DKEY         */
00126      0,                         /* PT4          */
00127      0,                         /* SCS          */
00128      CAPAB_QS,                  /* QS           */
00129      CAPAB_UID,                 /* UID          */
00130      CAPAB_KNOCK,               /* KNOCK        */
00131      0,                         /* CLIENT       */
00132      0,                         /* IPV6         */
00133      0,                         /* SSJ5         */
00134      0,                         /* SN2          */
00135      0,                         /* TOKEN        */
00136      0,                         /* VHOST        */
00137      0,                         /* SSJ3         */
00138      0,                         /* NICK2        */
00139      0,                         /* UMODE2       */
00140      0,                         /* VL           */
00141      0,                         /* TLKEXT       */
00142      0,                         /* DODKEY       */
00143      0,                         /* DOZIP        */
00144      0, 0, 0}
00145 };
00146 
00147 
00148 
00149 void hybrid_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 'd':
00177             if (ac == 0) {
00178                 alog("user: umode +d with no parameter (?) for user %s",
00179                      user->nick);
00180                 break;
00181             }
00182 
00183             ac--;
00184             av++;
00185             user->svid = strtoul(*av, NULL, 0);
00186             break;
00187         case 'o':
00188             if (add) {
00189                 opcnt++;
00190 
00191                 if (WallOper)
00192                     anope_cmd_global(s_OperServ,
00193                                      "\2%s\2 is now an IRC operator.",
00194                                      user->nick);
00195                 display_news(user, NEWS_OPER);
00196 
00197             } else {
00198                 opcnt--;
00199             }
00200             break;
00201         case 'r':
00202             if (add && !nick_identified(user)) {
00203                 send_cmd(ServerName, "SVSMODE %s -r", user->nick);
00204                 user->mode &= ~UMODE_r;
00205             }
00206             break;
00207 
00208         }
00209     }
00210 }
00211 
00212 unsigned long umodes[128] = {
00213     0, 0, 0,                    /* Unused */
00214     0, 0, 0,                    /* Unused */
00215     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00216     0, 0, 0,                    /* Line Feed, Unused, Unused */
00217     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00218     0, 0, 0,                    /* Unused */
00219     0, 0, 0,                    /* Unused */
00220     0, 0, 0,                    /* Unused */
00221     0, 0, 0,                    /* Unused */
00222     0, 0, 0,                    /* Unused */
00223     0, 0, 0,                    /* Unused, Unused, Space */
00224     0, 0, 0,                    /* ! " #  */
00225     0, 0, 0,                    /* $ % &  */
00226     0, 0, 0,                    /* ! ( )  */
00227     0, 0, 0,                    /* * + ,  */
00228     0, 0, 0,                    /* - . /  */
00229     0, 0,                       /* 0 1 */
00230     0, 0,                       /* 2 3 */
00231     0, 0,                       /* 4 5 */
00232     0, 0,                       /* 6 7 */
00233     0, 0,                       /* 8 9 */
00234     0, 0,                       /* : ; */
00235     0, 0, 0,                    /* < = > */
00236     0, 0,                       /* ? @ */
00237     0, 0, 0,                    /* A B C */
00238     0, 0, 0,                    /* D E F */
00239     0, 0, 0,                    /* G H I */
00240     0, 0, 0,                    /* J K L */
00241     0, 0, 0,                    /* M N O */
00242     0, 0, 0,                    /* P Q R */
00243     0, 0, 0,                    /* S T U */
00244     0, 0, 0,                    /* V W X */
00245     0,                          /* Y */
00246     0,                          /* Z */
00247     0, 0, 0,                    /* [ \ ] */
00248     0, 0, 0,                    /* ^ _ ` */
00249     UMODE_a, UMODE_b, UMODE_c,  /* a b c */
00250     UMODE_d, 0, UMODE_f,        /* d e f */
00251     UMODE_g, 0, UMODE_i,        /* g h i */
00252     0, UMODE_k, UMODE_l,        /* j k l */
00253     0, UMODE_n, UMODE_o,        /* m n o */
00254     0, 0, UMODE_r,              /* p q r */
00255     UMODE_s, 0, UMODE_u,        /* s t u */
00256     0, UMODE_w, UMODE_x,        /* v w x */
00257     UMODE_y,                    /* y */
00258     UMODE_z,                    /* z */
00259     0, 0, 0,                    /* { | } */
00260     0, 0                        /* ~ � */
00261 };
00262 
00263 
00264 char myCsmodes[128] = {
00265     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00266     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00267 
00268     0,
00269     'a',                        /* (33) !  */
00270     0, 0, 0,
00271     'h',
00272     0, 0, 0, 0,
00273     0,
00274 
00275     'v', 0, 0, 0, 0,
00276     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00277 
00278     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00279     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00280 
00281     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00282     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00283 };
00284 
00285 CMMode myCmmodes[128] = {
00286     {NULL}, {NULL}, {NULL},
00287     {NULL}, {NULL}, {NULL},
00288     {NULL}, {NULL}, {NULL},
00289     {NULL}, {NULL}, {NULL},
00290     {NULL}, {NULL}, {NULL},
00291     {NULL}, {NULL}, {NULL},
00292     {NULL}, {NULL}, {NULL},
00293     {NULL}, {NULL}, {NULL},
00294     {NULL}, {NULL}, {NULL},
00295     {NULL}, {NULL}, {NULL},
00296     {NULL}, {NULL}, {NULL},
00297     {NULL}, {NULL}, {NULL},
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},     /* BCD */
00309     {NULL}, {NULL}, {NULL},     /* EFG */
00310     {NULL},                     /* H */
00311     {add_invite, del_invite},
00312     {NULL},                     /* J */
00313     {NULL}, {NULL}, {NULL},     /* KLM */
00314     {NULL}, {NULL}, {NULL},     /* NOP */
00315     {NULL}, {NULL}, {NULL},     /* QRS */
00316     {NULL}, {NULL}, {NULL},     /* TUV */
00317     {NULL}, {NULL}, {NULL},     /* WXY */
00318     {NULL},                     /* Z */
00319     {NULL}, {NULL},             /* (char 91 - 92) */
00320     {NULL}, {NULL}, {NULL},     /* (char 93 - 95) */
00321     {NULL},                     /* ` (char 96) */
00322     {NULL},                     /* a (char 97) */
00323     {add_ban, del_ban},
00324     {NULL},
00325     {NULL},
00326     {add_exception, del_exception},
00327     {NULL},
00328     {NULL},
00329     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00330     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00331     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00332 };
00333 
00334 
00335 CBMode myCbmodes[128] = {
00336     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00337     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00338     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00339     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00340     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00341     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00342     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00343     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00344     {0},
00345     {0},                        /* A */
00346     {0},                        /* B */
00347     {0},                        /* C */
00348     {0},                        /* D */
00349     {0},                        /* E */
00350     {0},                        /* F */
00351     {0},                        /* G */
00352     {0},                        /* H */
00353     {0},                        /* I */
00354     {0},                        /* J */
00355     {0},                        /* K */
00356     {0},                        /* L */
00357     {0},                        /* M */
00358     {0},                        /* N */
00359     {0},                        /* O */
00360     {0},                        /* P */
00361     {0},                        /* Q */
00362     {0},
00363     {0},                        /* S */
00364     {0},                        /* T */
00365     {0},                        /* U */
00366     {0},                        /* V */
00367     {0},                        /* W */
00368     {0},                        /* X */
00369     {0},                        /* Y */
00370     {0},                        /* Z */
00371     {0}, {0}, {0}, {0}, {0}, {0},
00372     {CMODE_a, 0, NULL, NULL},
00373     {0},                        /* b */
00374     {0},                        /* c */
00375     {0},                        /* d */
00376     {0},                        /* e */
00377     {0},                        /* f */
00378     {0},                        /* g */
00379     {0},                        /* h */
00380     {CMODE_i, 0, NULL, NULL},
00381     {0},                        /* j */
00382     {CMODE_k, 0, chan_set_key, cs_set_key},
00383     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00384     {CMODE_m, 0, NULL, NULL},
00385     {CMODE_n, 0, NULL, NULL},
00386     {0},                        /* o */
00387     {CMODE_p, 0, NULL, NULL},
00388     {0},                        /* q */
00389     {0},
00390     {CMODE_s, 0, NULL, NULL},
00391     {CMODE_t, 0, NULL, NULL},
00392     {0},
00393     {0},                        /* v */
00394     {0},                        /* w */
00395     {0},                        /* x */
00396     {0},                        /* y */
00397     {0},                        /* z */
00398     {0}, {0}, {0}, {0}
00399 };
00400 
00401 CBModeInfo myCbmodeinfos[] = {
00402     {'a', CMODE_a, 0, NULL, NULL},
00403     {'i', CMODE_i, 0, NULL, NULL},
00404     {'k', CMODE_k, 0, get_key, cs_get_key},
00405     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00406     {'m', CMODE_m, 0, NULL, NULL},
00407     {'n', CMODE_n, 0, NULL, NULL},
00408     {'p', CMODE_p, 0, NULL, NULL},
00409     {'s', CMODE_s, 0, NULL, NULL},
00410     {'t', CMODE_t, 0, NULL, NULL},
00411     {0}
00412 };
00413 
00414 
00415 CUMode myCumodes[128] = {
00416     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00417     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00418     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00419     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00420 
00421     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00422     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00423     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00424     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00425 
00426     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00427     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00428     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00429     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00430 
00431     {0},
00432 
00433     {0},                        /* a */
00434     {0},                        /* b */
00435     {0},                        /* c */
00436     {0},                        /* d */
00437     {0},                        /* e */
00438     {0},                        /* f */
00439     {0},                        /* g */
00440     {CUS_HALFOP, 0, check_valid_op},
00441     {0},                        /* i */
00442     {0},                        /* j */
00443     {0},                        /* k */
00444     {0},                        /* l */
00445     {0},                        /* m */
00446     {0},                        /* n */
00447     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00448     {0},                        /* p */
00449     {0},                        /* q */
00450     {0},                        /* r */
00451     {0},                        /* s */
00452     {0},                        /* t */
00453     {0},                        /* u */
00454     {CUS_VOICE, 0, NULL},
00455     {0},                        /* w */
00456     {0},                        /* x */
00457     {0},                        /* y */
00458     {0},                        /* z */
00459     {0}, {0}, {0}, {0}, {0}
00460 };
00461 
00462 
00463 
00464 void hybrid_cmd_notice(char *source, char *dest, char *buf)
00465 {
00466     if (!buf) {
00467         return;
00468     }
00469 
00470     if (NSDefFlags & NI_MSG) {
00471         hybrid_cmd_privmsg2(source, dest, buf);
00472     } else {
00473         send_cmd(source, "NOTICE %s :%s", dest, buf);
00474     }
00475 }
00476 
00477 void hybrid_cmd_notice2(char *source, char *dest, char *msg)
00478 {
00479     send_cmd(source, "NOTICE %s :%s", dest, msg);
00480 }
00481 
00482 void hybrid_cmd_privmsg(char *source, char *dest, char *buf)
00483 {
00484     if (!buf) {
00485         return;
00486     }
00487 
00488     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
00489 }
00490 
00491 void hybrid_cmd_privmsg2(char *source, char *dest, char *msg)
00492 {
00493     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
00494 }
00495 
00496 void hybrid_cmd_serv_notice(char *source, char *dest, char *msg)
00497 {
00498     send_cmd(source, "NOTICE $$%s :%s", dest, msg);
00499 }
00500 
00501 void hybrid_cmd_serv_privmsg(char *source, char *dest, char *msg)
00502 {
00503     send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
00504 }
00505 
00506 
00507 void hybrid_cmd_global(char *source, char *buf)
00508 {
00509     if (!buf) {
00510         return;
00511     }
00512 
00513     send_cmd(source ? source : ServerName, "OPERWALL :%s", buf);
00514 }
00515 
00516 /* GLOBOPS - to handle old WALLOPS */
00517 void hybrid_cmd_global_legacy(char *source, char *fmt)
00518 {
00519     send_cmd(source ? source : ServerName, "OPERWALL :%s", fmt);
00520 }
00521 
00522 int anope_event_sjoin(char *source, int ac, char **av)
00523 {
00524     do_sjoin(source, ac, av);
00525     return MOD_CONT;
00526 }
00527 
00528 int anope_event_nick(char *source, int ac, char **av)
00529 {
00530     if (ac != 2) {
00531         User *user = do_nick(source, av[0], av[4], av[5], av[6], av[7],
00532                              strtoul(av[2], NULL, 10), 0, 0, NULL, NULL);
00533         if (user)
00534             anope_set_umode(user, 1, &av[3]);
00535     } else {
00536         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00537                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00538     }
00539     return MOD_CONT;
00540 }
00541 
00542 int anope_event_topic(char *source, int ac, char **av)
00543 {
00544     if (ac == 4) {
00545         do_topic(source, ac, av);
00546     } else {
00547         Channel *c = findchan(av[0]);
00548         time_t topic_time = time(NULL);
00549 
00550         if (!c) {
00551             if (debug) {
00552                 alog("debug: TOPIC %s for nonexistent channel %s",
00553                      merge_args(ac - 1, av + 1), av[0]);
00554             }
00555             return MOD_CONT;
00556         }
00557 
00558         if (check_topiclock(c, topic_time))
00559             return MOD_CONT;
00560 
00561         if (c->topic) {
00562             free(c->topic);
00563             c->topic = NULL;
00564         }
00565         if (ac > 1 && *av[1])
00566             c->topic = sstrdup(av[1]);
00567 
00568         strscpy(c->topic_setter, source, sizeof(c->topic_setter));
00569         c->topic_time = topic_time;
00570 
00571         record_topic(av[0]);
00572 
00573                 if (ac > 1 && *av[1])
00574                     send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]);
00575                 else
00576                     send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
00577     }
00578     return MOD_CONT;
00579 }
00580 
00581 int anope_event_tburst(char *source, int ac, char **av)
00582 {
00583     if (ac != 5)
00584         return MOD_CONT;
00585 
00586     av[0] = av[1];
00587     av[1] = av[3];
00588     av[3] = av[4];
00589     do_topic(source, 4, av);
00590     return MOD_CONT;
00591 }
00592 
00593 int anope_event_436(char *source, int ac, char **av)
00594 {
00595     if (ac < 1)
00596         return MOD_CONT;
00597 
00598     m_nickcoll(av[0]);
00599     return MOD_CONT;
00600 }
00601 
00602 
00603 /* *INDENT-OFF* */
00604 void moduleAddIRCDMsgs(void) {
00605     Message *m;
00606 
00607     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
00608 
00609     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
00610     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
00611     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
00612     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
00613     m = createMessage("INVITE",    anope_event_invite); addCoreMessage(IRCD,m);
00614     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
00615     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
00616     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
00617     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
00618     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
00619     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
00620     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
00621     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
00622     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
00623     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
00624     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
00625     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
00626     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
00627     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
00628     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
00629     m = createMessage("TBURST",    anope_event_tburst); addCoreMessage(IRCD,m);
00630     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
00631     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
00632     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
00633     m = createMessage("AKILL",     anope_event_null); addCoreMessage(IRCD,m);
00634     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
00635     m = createMessage("GNOTICE",   anope_event_null); addCoreMessage(IRCD,m);
00636     m = createMessage("GOPER",     anope_event_null); addCoreMessage(IRCD,m);
00637     m = createMessage("RAKILL",    anope_event_null); addCoreMessage(IRCD,m);
00638     m = createMessage("SILENCE",   anope_event_null); addCoreMessage(IRCD,m);
00639     m = createMessage("SVSKILL",   anope_event_null); addCoreMessage(IRCD,m);
00640     m = createMessage("SVSMODE",   anope_event_null); addCoreMessage(IRCD,m);
00641     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
00642     m = createMessage("SVSNOOP",   anope_event_null); addCoreMessage(IRCD,m);
00643     m = createMessage("SQLINE",    anope_event_null); addCoreMessage(IRCD,m);
00644     m = createMessage("UNSQLINE",  anope_event_null); addCoreMessage(IRCD,m);
00645     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
00646     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
00647     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
00648 /*    m = createMessage("EOB",       anope_event_eob); addCoreMessage(IRCD,m); */
00649     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
00650     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
00651 }
00652 
00653 /* *INDENT-ON* */
00654 
00655 
00656 void hybrid_cmd_sqline(char *mask, char *reason)
00657 {
00658     if (!mask || !reason) {
00659         return;
00660     }
00661     
00662     send_cmd(ServerName, "RESV * %s :%s", mask, reason);
00663 }
00664 void hybrid_cmd_unsgline(char *mask)
00665 {
00666     if (!mask) {
00667         return;
00668     }
00669     
00670     send_cmd(ServerName, "UNXLINE * %s", mask);
00671 }
00672 
00673 void hybrid_cmd_unszline(char *mask)
00674 {
00675     /* Does not support */
00676 }
00677 void hybrid_cmd_szline(char *mask, char *reason, char *whom)
00678 {
00679     /* Does not support */
00680 }
00681 
00682 void hybrid_cmd_svsnoop(char *server, int set)
00683 {
00684     /* does not support */
00685 }
00686 
00687 void hybrid_cmd_svsadmin(char *server, int set)
00688 {
00689     hybrid_cmd_svsnoop(server, set);
00690 }
00691 
00692 void hybrid_cmd_sgline(char *mask, char *reason)
00693 {
00694     if (!mask || !reason) {
00695         return;
00696     }
00697     
00698     send_cmd(ServerName, "XLINE * %s 0 :%s", mask, reason);
00699 }
00700 
00701 void hybrid_cmd_remove_akill(char *user, char *host)
00702 {
00703     /* hybrid seems to support UNKLINE  -Certus */
00704     send_cmd(s_OperServ, "UNKLINE * %s %s", user, host);
00705 }
00706 
00707 void hybrid_cmd_topic(char *whosets, char *chan, char *whosetit,
00708                       char *topic, time_t when)
00709 {
00710     send_cmd(whosets, "TOPIC %s :%s", chan, topic);
00711 }
00712 
00713 void hybrid_cmd_vhost_off(User * u)
00714 {
00715     /* does not support vhosting */
00716 }
00717 
00718 void hybrid_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00719 {
00720     /* does not support vhosting */
00721 }
00722 
00723 void hybrid_cmd_unsqline(char *user)
00724 {
00725     if (!user) {
00726         return;
00727     }
00728     
00729     send_cmd(ServerName, "UNRESV * %s", user);
00730 }
00731 
00732 void hybrid_cmd_join(char *user, char *channel, time_t chantime)
00733 {
00734     send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) chantime, channel,
00735              user);
00736 }
00737 
00738 /*
00739 oper:           the nick of the oper performing the kline
00740 target.server:  the server(s) this kline is destined for
00741 duration:       the duration if a tkline, 0 if permanent.
00742 user:           the 'user' portion of the kline
00743 host:           the 'host' portion of the kline
00744 reason:         the reason for the kline.
00745 */
00746 
00747 void hybrid_cmd_akill(char *user, char *host, char *who, time_t when,
00748                       time_t expires, char *reason)
00749 {
00750     send_cmd(s_OperServ, "KLINE * %ld %s %s :%s",
00751              (long int) (expires - (long) time(NULL)), user, host, reason);
00752 }
00753 
00754 void hybrid_cmd_svskill(char *source, char *user, char *buf)
00755 {
00756     if (!buf) {
00757         return;
00758     }
00759 
00760     if (!source || !user) {
00761         return;
00762     }
00763 
00764     send_cmd(source, "KILL %s :%s", user, buf);
00765 }
00766 
00767 
00768 void hybrid_cmd_svsmode(User * u, int ac, char **av)
00769 {
00770     /* Hybrid does not support SVSMODE */
00771 }
00772 
00773 /*
00774  * SVINFO
00775  *      parv[0] = sender prefix
00776  *      parv[1] = TS_CURRENT for the server
00777  *      parv[2] = TS_MIN for the server
00778  *      parv[3] = server is standalone or connected to non-TS only
00779  *      parv[4] = server's idea of UTC time
00780  */
00781 void hybrid_cmd_svinfo()
00782 {
00783     send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL));
00784 }
00785 
00786 /* CAPAB */
00787 /*
00788   QS     - Can handle quit storm removal
00789   EX     - Can do channel +e exemptions 
00790   CHW    - Can do channel wall @#
00791   LL     - Can do lazy links 
00792   IE     - Can do invite exceptions 
00793   EOB    - Can do EOB message
00794   KLN    - Can do KLINE message 
00795   GLN    - Can do GLINE message 
00796   HOPS   - can do half ops (+h)
00797   HUB    - This server is a HUB 
00798   AOPS   - Can do anon ops (+a) 
00799   UID    - Can do UIDs
00800   ZIP    - Can do ZIPlinks
00801   ENC    - Can do ENCrypted links 
00802   KNOCK  -  supports KNOCK 
00803   TBURST - supports TBURST
00804   PARA   - supports invite broadcasting for +p
00805   ENCAP  - ?
00806 */
00807 void hybrid_cmd_capab()
00808 {
00809     send_cmd(NULL,
00810              "CAPAB :QS EX CHW IE KLN GLN HOPS HUB AOPS KNOCK TBURST PARA");
00811 }
00812 
00813 /* PASS */
00814 void hybrid_cmd_pass(char *pass)
00815 {
00816     send_cmd(NULL, "PASS %s :TS", pass);
00817 }
00818 
00819 /* SERVER name hop descript */
00820 void hybrid_cmd_server(char *servname, int hop, char *descript)
00821 {
00822     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00823 }
00824 void hybrid_cmd_connect(int servernum)
00825 {
00826     me_server =
00827         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00828 
00829     if (servernum == 1)
00830         hybrid_cmd_pass(RemotePassword);
00831     else if (servernum == 2)
00832         hybrid_cmd_pass(RemotePassword2);
00833     else if (servernum == 3)
00834         hybrid_cmd_pass(RemotePassword3);
00835 
00836     hybrid_cmd_capab();
00837     hybrid_cmd_server(ServerName, 1, ServerDesc);
00838     hybrid_cmd_svinfo();
00839 }
00840 
00841 void hybrid_cmd_svsinfo()
00842 {
00843     /* not used */
00844 }
00845 
00846 
00847 
00848 void hybrid_cmd_bot_nick(char *nick, char *user, char *host, char *real,
00849                          char *modes)
00850 {
00851     EnforceQlinedNick(nick, s_BotServ);
00852     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick,
00853              (long int) time(NULL), modes, user, host, ServerName, real);
00854 
00855 }
00856 
00857 void hybrid_cmd_part(char *nick, char *chan, char *buf)
00858 {
00859     if (buf) {
00860         send_cmd(nick, "PART %s :%s", chan, buf);
00861     } else {
00862         send_cmd(nick, "PART %s", chan);
00863     }
00864 }
00865 
00866 int anope_event_ping(char *source, int ac, char **av)
00867 {
00868     if (ac < 1)
00869         return MOD_CONT;
00870     hybrid_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
00871     return MOD_CONT;
00872 }
00873 
00874 int anope_event_away(char *source, int ac, char **av)
00875 {
00876     if (!source) {
00877         return MOD_CONT;
00878     }
00879     m_away(source, (ac ? av[0] : NULL));
00880     return MOD_CONT;
00881 }
00882 
00883 int anope_event_kill(char *source, int ac, char **av)
00884 {
00885     if (ac != 2)
00886         return MOD_CONT;
00887 
00888     m_kill(av[0], av[1]);
00889     return MOD_CONT;
00890 }
00891 
00892 int anope_event_kick(char *source, int ac, char **av)
00893 {
00894     if (ac != 3)
00895         return MOD_CONT;
00896     do_kick(source, ac, av);
00897     return MOD_CONT;
00898 }
00899 
00900 int anope_event_eob(char *source, int ac, char **av)
00901 {
00902     Server *s;
00903     s = findserver(servlist, source);
00904     /* If we found a server with the given source, that one just
00905      * finished bursting. If there was no source, then our uplink
00906      * server finished bursting. -GD
00907      */
00908     if (!s && serv_uplink)
00909         s = serv_uplink;
00910     finish_sync(s, 1);
00911 
00912     return MOD_CONT;
00913 }
00914 
00915 void hybrid_cmd_eob()
00916 {
00917 /*    send_cmd(ServerName, "EOB"); */
00918 }
00919 
00920 
00921 int anope_event_join(char *source, int ac, char **av)
00922 {
00923     if (ac != 1)
00924         return MOD_CONT;
00925     do_join(source, ac, av);
00926     return MOD_CONT;
00927 }
00928 
00929 int anope_event_motd(char *source, int ac, char **av)
00930 {
00931     if (!source) {
00932         return MOD_CONT;
00933     }
00934 
00935     m_motd(source);
00936     return MOD_CONT;
00937 }
00938 
00939 int anope_event_privmsg(char *source, int ac, char **av)
00940 {
00941     if (ac != 2)
00942         return MOD_CONT;
00943     m_privmsg(source, av[0], av[1]);
00944     return MOD_CONT;
00945 }
00946 
00947 int anope_event_part(char *source, int ac, char **av)
00948 {
00949     if (ac < 1 || ac > 2)
00950         return MOD_CONT;
00951     do_part(source, ac, av);
00952     return MOD_CONT;
00953 }
00954 
00955 int anope_event_whois(char *source, int ac, char **av)
00956 {
00957     if (source && ac >= 1) {
00958         m_whois(source, av[0]);
00959     }
00960     return MOD_CONT;
00961 }
00962 
00963 /* EVENT: SERVER */
00964 int anope_event_server(char *source, int ac, char **av)
00965 {
00966     if (!stricmp(av[1], "1")) {
00967         uplink = sstrdup(av[0]);
00968     }
00969     do_server(source, av[0], av[1], av[2], NULL);
00970     return MOD_CONT;
00971 }
00972 
00973 int anope_event_squit(char *source, int ac, char **av)
00974 {
00975     if (ac != 2)
00976         return MOD_CONT;
00977     do_squit(source, ac, av);
00978     return MOD_CONT;
00979 }
00980 
00981 int anope_event_quit(char *source, int ac, char **av)
00982 {
00983     if (ac != 1)
00984         return MOD_CONT;
00985     do_quit(source, ac, av);
00986     return MOD_CONT;
00987 }
00988 
00989 void hybrid_cmd_372(char *source, char *msg)
00990 {
00991     send_cmd(ServerName, "372 %s :- %s", source, msg);
00992 }
00993 
00994 void hybrid_cmd_372_error(char *source)
00995 {
00996     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
00997              "contact your IRC administrator.", source);
00998 }
00999 
01000 void hybrid_cmd_375(char *source)
01001 {
01002     send_cmd(ServerName, "375 %s :- %s Message of the Day",
01003              source, ServerName);
01004 }
01005 
01006 void hybrid_cmd_376(char *source)
01007 {
01008     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
01009 }
01010 
01011 /* 391 */
01012 void hybrid_cmd_391(char *source, char *timestr)
01013 {
01014     if (!timestr) {
01015         return;
01016     }
01017     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
01018 }
01019 
01020 /* 250 */
01021 void hybrid_cmd_250(char *buf)
01022 {
01023     if (!buf) {
01024         return;
01025     }
01026 
01027     send_cmd(NULL, "250 %s", buf);
01028 }
01029 
01030 /* 307 */
01031 void hybrid_cmd_307(char *buf)
01032 {
01033     if (!buf) {
01034         return;
01035     }
01036 
01037     send_cmd(ServerName, "307 %s", buf);
01038 }
01039 
01040 /* 311 */
01041 void hybrid_cmd_311(char *buf)
01042 {
01043     if (!buf) {
01044         return;
01045     }
01046 
01047     send_cmd(ServerName, "311 %s", buf);
01048 }
01049 
01050 /* 312 */
01051 void hybrid_cmd_312(char *buf)
01052 {
01053     if (!buf) {
01054         return;
01055     }
01056 
01057     send_cmd(ServerName, "312 %s", buf);
01058 }
01059 
01060 /* 317 */
01061 void hybrid_cmd_317(char *buf)
01062 {
01063     if (!buf) {
01064         return;
01065     }
01066 
01067     send_cmd(ServerName, "317 %s", buf);
01068 }
01069 
01070 /* 219 */
01071 void