hybrid.c

Go to the documentation of this file.
00001 /* ircd-hybrid-8 protocol module
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * (C) 2012 by the Hybrid Development Team
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 #include "version.h"
00018 
00019 IRCDVar myIrcd[] = {
00020     {"Hybrid 8.0.*",            /* ircd name */
00021      "+o",                      /* nickserv mode */
00022      "+o",                      /* chanserv mode */
00023      "+o",                      /* memoserv mode */
00024      "+",                       /* hostserv mode */
00025      "+io",                     /* operserv mode */
00026      "+o",                      /* botserv mode  */
00027      "+i",                      /* helpserv mode */
00028      "+i",                      /* Dev/Null mode */
00029      "+io",                     /* Global mode   */
00030      "+o",                      /* nickserv alias mode */
00031      "+o",                      /* chanserv alias mode */
00032      "+o",                      /* memoserv alias mode */
00033      "+",                       /* hostserv alias mode */
00034      "+io",                     /* operserv alias mode */
00035      "+o",                      /* botserv alias mode  */
00036      "+i",                      /* helpserv alias mode */
00037      "+i",                      /* Dev/Null alias mode */
00038      "+io",                     /* Global alias mode   */
00039      "+",                       /* Used by BotServ Bots */
00040      3,                         /* Chan Max Symbols     */
00041      "-ilmnpstORS",             /* Modes to Remove */
00042      "+o",                      /* Channel Umode used by Botserv bots */
00043      1,                         /* SVSNICK */
00044      0,                         /* Vhost  */
00045      0,                         /* Has Owner */
00046      NULL,                      /* Mode to set for an owner */
00047      NULL,                      /* Mode to unset for an owner */
00048      NULL,                      /* Mode to set for admin */
00049      NULL,                      /* Mode to unset for 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      "+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      1,                         /* Join 2 Set           */
00062      1,                         /* Join 2 Message       */
00063      1,                         /* Has exceptions +e    */
00064      0,                         /* TS Topic Forward     */
00065      0,                         /* TS Topic Backward    */
00066      0,                         /* Protected Umode      */
00067      0,                         /* Has Admin            */
00068      1,                         /* Chan SQlines         */
00069      0,                         /* Quit on Kill         */
00070      0,                         /* SVSMODE unban        */
00071      0,                         /* Has Protect          */
00072      0,                         /* Reverse              */
00073      1,                         /* Chan Reg             */
00074      CMODE_r,                   /* Channel Mode         */
00075      0,                         /* vidents              */
00076      0,                         /* svshold              */
00077      0,                         /* time stamp on mode   */
00078      0,                         /* NICKIP               */
00079      0,                         /* UMODE                */
00080      0,                         /* O:LINE               */
00081      0,                         /* VHOST ON NICK        */
00082      0,                         /* Change RealName      */
00083      CMODE_p,                   /* No Knock             */
00084      0,                         /* Admin Only           */
00085      DEFAULT_MLOCK,             /* Default MLOCK        */
00086      0,                         /* Vhost Mode           */
00087      0,                         /* +f                   */
00088      0,                         /* +L                   */
00089      0,                         /* +f Mode                          */
00090      0,                         /* +L Mode                              */
00091      1,                         /* On nick change check if they could be identified */
00092      0,                         /* 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      1,                         /* +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      NULL,                      /* vhost char */
00104      0,                         /* ts6 */
00105      0,                         /* support helper umode */
00106      0,                         /* p10 */
00107      NULL,                      /* character set */
00108      1,                         /* reports sync state */
00109      1,                         /* CIDR channelbans */
00110      0,                         /* +j */
00111      0,                         /* +j mode */
00112      0,                         /* Use delayed client introduction. */
00113      }
00114     ,
00115     {NULL}
00116 };
00117 
00118 IRCDCAPAB myIrcdcap[] = {
00119     {
00120      CAPAB_NOQUIT,              /* NOQUIT       */
00121      0,                         /* TSMODE       */
00122      0,                         /* UNCONNECT    */
00123      0,                         /* NICKIP       */
00124      0,                         /* SJOIN        */
00125      0,                         /* ZIP          */
00126      0,                         /* BURST        */
00127      CAPAB_TS5,                 /* TS5          */
00128      0,                         /* TS3          */
00129      0,                         /* DKEY         */
00130      0,                         /* PT4          */
00131      0,                         /* SCS          */
00132      CAPAB_QS,                  /* QS           */
00133      0,                         /* UID          */
00134      CAPAB_KNOCK,               /* KNOCK        */
00135      0,                         /* CLIENT       */
00136      0,                         /* IPV6         */
00137      0,                         /* SSJ5         */
00138      0,                         /* SN2          */
00139      0,                         /* TOKEN        */
00140      0,                         /* VHOST        */
00141      0,                         /* SSJ3         */
00142      0,                         /* NICK2        */
00143      0,                         /* UMODE2       */
00144      0,                         /* VL           */
00145      0,                         /* TLKEXT       */
00146      0,                         /* DODKEY       */
00147      0,                         /* DOZIP        */
00148      0, 0, 0}
00149 };
00150 
00151 
00152 
00153 void hybrid_set_umode(User *user, int ac, char **av)
00154 {
00155     int add = 1;                /* 1 if adding modes, 0 if deleting */
00156     char *modes = av[0];
00157 
00158     ac--;
00159 
00160     if (debug)
00161         alog("debug: Changing mode for %s to %s", user->nick, modes);
00162 
00163     while (*modes) {
00164 
00165         /* This looks better, much better than "add ? (do_add) : (do_remove)".
00166          * At least this is readable without paying much attention :) -GD
00167          */
00168         if (add)
00169             user->mode |= umodes[(int) *modes];
00170         else
00171             user->mode &= ~umodes[(int) *modes];
00172 
00173         switch (*modes++) {
00174         case '+':
00175             add = 1;
00176             break;
00177         case '-':
00178             add = 0;
00179             break;
00180         case 'd':
00181             if (ac == 0) {
00182                 alog("user: umode +d with no parameter (?) for user %s",
00183                      user->nick);
00184                 break;
00185             }
00186 
00187             ac--;
00188             av++;
00189             user->svid = strtoul(*av, NULL, 0);
00190             break;
00191         case 'o':
00192             if (add) {
00193                 opcnt++;
00194 
00195                 if (WallOper)
00196                     anope_cmd_global(s_OperServ,
00197                                      "\2%s\2 is now an IRC operator.",
00198                                      user->nick);
00199                 display_news(user, NEWS_OPER);
00200 
00201             } else {
00202                 opcnt--;
00203             }
00204             break;
00205         case 'r':
00206             if (add && !nick_identified(user)) {
00207                 send_cmd(ServerName, "SVSMODE %s -r", user->nick);
00208                 user->mode &= ~UMODE_r;
00209             }
00210             break;
00211 
00212         }
00213     }
00214 }
00215 
00216 unsigned long umodes[128] = {
00217     0, 0, 0,                    /* Unused */
00218     0, 0, 0,                    /* Unused */
00219     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00220     0, 0, 0,                    /* Line Feed, Unused, Unused */
00221     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00222     0, 0, 0,                    /* Unused */
00223     0, 0, 0,                    /* Unused */
00224     0, 0, 0,                    /* Unused */
00225     0, 0, 0,                    /* Unused */
00226     0, 0, 0,                    /* Unused */
00227     0, 0, 0,                    /* Unused, Unused, Space */
00228     0, 0, 0,                    /* ! " #  */
00229     0, 0, 0,                    /* $ % &  */
00230     0, 0, 0,                    /* ! ( )  */
00231     0, 0, 0,                    /* * + ,  */
00232     0, 0, 0,                    /* - . /  */
00233     0, 0,                       /* 0 1 */
00234     0, 0,                       /* 2 3 */
00235     0, 0,                       /* 4 5 */
00236     0, 0,                       /* 6 7 */
00237     0, 0,                       /* 8 9 */
00238     0, 0,                       /* : ; */
00239     0, 0, 0,                    /* < = > */
00240     0, 0,                       /* ? @ */
00241     0, 0, 0,                    /* A B C */
00242     0, 0, 0,                    /* D E F */
00243     0, 0, 0,                    /* G H I */
00244     0, 0, 0,                    /* J K L */
00245     0, 0, 0,                    /* M N O */
00246     0, 0, UMODE_R,              /* P Q R */
00247     0, 0, 0,                    /* S T U */
00248     0, 0, 0,                    /* V W X */
00249     0,                          /* Y */
00250     0,                          /* Z */
00251     0, 0, 0,                    /* [ \ ] */
00252     0, 0, 0,                    /* ^ _ ` */
00253     UMODE_a, UMODE_b, UMODE_c,  /* a b c */
00254     UMODE_d, 0, UMODE_f,        /* d e f */
00255     UMODE_g, 0, UMODE_i,        /* g h i */
00256     0, UMODE_k, UMODE_l,        /* j k l */
00257     0, UMODE_n, UMODE_o,        /* m n o */
00258     0, 0, UMODE_r,              /* p q r */
00259     UMODE_s, 0, UMODE_u,        /* s t u */
00260     0, UMODE_w, UMODE_x,        /* v w x */
00261     UMODE_y,                    /* y */
00262     UMODE_z,                    /* z */
00263     0, 0, 0,                    /* { | } */
00264     0, 0                        /* ~ � */
00265 };
00266 
00267 
00268 char myCsmodes[128] = {
00269     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00270     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00271 
00272     0,
00273     0,
00274     0, 0, 0,
00275     'h',
00276     0, 0, 0, 0,
00277     0,
00278 
00279     'v', 0, 0, 0, 0,
00280     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00281 
00282     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00283     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00284 
00285     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00286     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00287 };
00288 
00289 CMMode myCmmodes[128] = {
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},
00309     {NULL}, {NULL}, {NULL},
00310     {NULL}, {NULL}, {NULL},
00311     {NULL}, {NULL}, {NULL},
00312     {NULL}, {NULL}, {NULL},     /* BCD */
00313     {NULL}, {NULL}, {NULL},     /* EFG */
00314     {NULL},                     /* H */
00315     {add_invite, del_invite},
00316     {NULL},                     /* J */
00317     {NULL}, {NULL}, {NULL},     /* KLM */
00318     {NULL}, {NULL}, {NULL},     /* NOP */
00319     {NULL}, {NULL}, {NULL},     /* QRS */
00320     {NULL}, {NULL}, {NULL},     /* TUV */
00321     {NULL}, {NULL}, {NULL},     /* WXY */
00322     {NULL},                     /* Z */
00323     {NULL}, {NULL},             /* (char 91 - 92) */
00324     {NULL}, {NULL}, {NULL},     /* (char 93 - 95) */
00325     {NULL},                     /* ` (char 96) */
00326     {NULL},                     /* a (char 97) */
00327     {add_ban, del_ban},
00328     {NULL},
00329     {NULL},
00330     {add_exception, del_exception},
00331     {NULL},
00332     {NULL},
00333     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00334     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00335     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00336 };
00337 
00338 
00339 CBMode myCbmodes[128] = {
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}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00345     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00346     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00347     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00348     {0},
00349     {0},                        /* A */
00350     {0},                        /* B */
00351     {0},                        /* C */
00352     {0},                        /* D */
00353     {0},                        /* E */
00354     {0},                        /* F */
00355     {0},                        /* G */
00356     {0},                        /* H */
00357     {0},                        /* I */
00358     {0},                        /* J */
00359     {0},                        /* K */
00360     {0},                        /* L */
00361     {0},                        /* M */
00362     {0},                        /* N */
00363     {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},   /* O */
00364     {0},                        /* P */
00365     {0},                        /* Q */
00366     {CMODE_R, 0, NULL, NULL},   /* R */
00367     {CMODE_S, 0, NULL, NULL},   /* S */
00368     {0},                        /* T */
00369     {0},                        /* U */
00370     {0},                        /* V */
00371     {0},                        /* W */
00372     {0},                        /* X */
00373     {0},                        /* Y */
00374     {0},                        /* Z */
00375     {0}, {0}, {0}, {0}, {0}, {0},
00376     {0},                        /* a */
00377     {0},                        /* b */
00378     {0},                        /* c */
00379     {0},                        /* d */
00380     {0},                        /* e */
00381     {0},                        /* f */
00382     {0},                        /* g */
00383     {0},                        /* h */
00384     {CMODE_i, 0, NULL, NULL},
00385     {0},                        /* j */
00386     {CMODE_k, 0, chan_set_key, cs_set_key},
00387     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00388     {CMODE_m, 0, NULL, NULL},
00389     {CMODE_n, 0, NULL, NULL},
00390     {0},                        /* o */
00391     {CMODE_p, 0, NULL, NULL},
00392     {0},                        /* q */
00393     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00394     {CMODE_s, 0, NULL, NULL},
00395     {CMODE_t, 0, NULL, NULL},
00396     {0},
00397     {0},                        /* v */
00398     {0},                        /* w */
00399     {0},                        /* x */
00400     {0},                        /* y */
00401     {0},                        /* z */
00402     {0}, {0}, {0}, {0}
00403 };
00404 
00405 CBModeInfo myCbmodeinfos[] = {
00406     {'i', CMODE_i, 0, NULL, NULL},
00407     {'k', CMODE_k, 0, get_key, cs_get_key},
00408     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00409     {'m', CMODE_m, 0, NULL, NULL},
00410     {'n', CMODE_n, 0, NULL, NULL},
00411     {'p', CMODE_p, 0, NULL, NULL},
00412     {'r', CMODE_r, 0, NULL, NULL},
00413     {'s', CMODE_s, 0, NULL, NULL},
00414     {'t', CMODE_t, 0, NULL, NULL},
00415     {'O', CMODE_O, 0, NULL, NULL},
00416     {'R', CMODE_R, 0, NULL, NULL},
00417     {'S', CMODE_S, 0, NULL, NULL},
00418     {0}
00419 };
00420 
00421 CUMode myCumodes[128] = {
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     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00426 
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     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00431 
00432     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00433     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00434     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00435     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00436 
00437     {0},
00438 
00439     {0},                        /* a */
00440     {0},                        /* b */
00441     {0},                        /* c */
00442     {0},                        /* d */
00443     {0},                        /* e */
00444     {0},                        /* f */
00445     {0},                        /* g */
00446     {CUS_HALFOP, 0, check_valid_op},
00447     {0},                        /* i */
00448     {0},                        /* j */
00449     {0},                        /* k */
00450     {0},                        /* l */
00451     {0},                        /* m */
00452     {0},                        /* n */
00453     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00454     {0},                        /* p */
00455     {0},                        /* q */
00456     {0},                        /* r */
00457     {0},                        /* s */
00458     {0},                        /* t */
00459     {0},                        /* u */
00460     {CUS_VOICE, 0, NULL},
00461     {0},                        /* w */
00462     {0},                        /* x */
00463     {0},                        /* y */
00464     {0},                        /* z */
00465     {0}, {0}, {0}, {0}, {0}
00466 };
00467 
00468 
00469 
00470 void hybrid_cmd_notice(char *source, char *dest, char *buf)
00471 {
00472     if (!buf)
00473         return;
00474 
00475     if (NSDefFlags & NI_MSG)
00476         hybrid_cmd_privmsg2(source, dest, buf);
00477     else
00478         send_cmd(source, "NOTICE %s :%s", dest, buf);
00479 }
00480 
00481 void hybrid_cmd_notice2(char *source, char *dest, char *msg)
00482 {
00483     send_cmd(source, "NOTICE %s :%s", dest, msg);
00484 }
00485 
00486 void hybrid_cmd_privmsg(char *source, char *dest, char *buf)
00487 {
00488     if (!buf)
00489         return;
00490 
00491     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
00492 }
00493 
00494 void hybrid_cmd_privmsg2(char *source, char *dest, char *msg)
00495 {
00496     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
00497 }
00498 
00499 void hybrid_cmd_serv_notice(char *source, char *dest, char *msg)
00500 {
00501     send_cmd(source, "NOTICE $$%s :%s", dest, msg);
00502 }
00503 
00504 void hybrid_cmd_serv_privmsg(char *source, char *dest, char *msg)
00505 {
00506     send_cmd(source, "PRIVMSG $$%s :%s", dest, msg);
00507 }
00508 
00509 void hybrid_cmd_global(char *source, char *buf)
00510 {
00511     if (!buf)
00512         return;
00513 
00514     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
00515 }
00516 
00517 /* GLOBOPS - to handle old WALLOPS */
00518 void hybrid_cmd_global_legacy(char *source, char *fmt)
00519 {
00520     send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
00521 }
00522 
00523 int anope_event_sjoin(char *source, int ac, char **av)
00524 {
00525     do_sjoin(source, ac, av);
00526     return MOD_CONT;
00527 }
00528 
00529 /*
00530 ** NICK - new
00531 **      source  = NULL
00532 **      parv[0] = nickname
00533 **      parv[1] = hopcount
00534 **      parv[2] = timestamp
00535 **      parv[3] = modes
00536 **      parv[4] = username
00537 **      parv[5] = hostname
00538 **      parv[6] = server
00539 **      parv[7] = servicestamp
00540 **      parv[8] = info
00541 ** NICK - change 
00542 **      source  = oldnick
00543 **      parv[0] = new nickname
00544 **      parv[1] = timestamp
00545 */
00546 int anope_event_nick(char *source, int ac, char **av)
00547 {
00548     if (ac != 2)
00549     {
00550         User *user = do_nick(source, av[0], av[4], av[5], av[6], av[8],
00551                              strtoul(av[2], NULL, 10),
00552                              strtoul(av[7], NULL, 0), 0, NULL, NULL);
00553         if (user)
00554             anope_set_umode(user, 1, &av[3]);
00555     }
00556     else
00557         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00558                 strtoul(av[1], NULL, 10),
00559                 0, 0, NULL, NULL);
00560 
00561     return MOD_CONT;
00562 }
00563 
00564 int anope_event_topic(char *source, int ac, char **av)
00565 {
00566     if (ac == 4)
00567         do_topic(source, ac, av);
00568     else {
00569         Channel *c = findchan(av[0]);
00570         time_t topic_time = time(NULL);
00571 
00572         if (!c) {
00573             if (debug)
00574                 alog("debug: TOPIC %s for nonexistent channel %s",
00575                      merge_args(ac - 1, av + 1), av[0]);
00576 
00577             return MOD_CONT;
00578         }
00579 
00580         if (check_topiclock(c, topic_time))
00581             return MOD_CONT;
00582 
00583         if (c->topic) {
00584             free(c->topic);
00585             c->topic = NULL;
00586         }
00587         if (ac > 1 && *av[1])
00588             c->topic = sstrdup(av[1]);
00589 
00590         strscpy(c->topic_setter, source, sizeof(c->topic_setter));
00591         c->topic_time = topic_time;
00592 
00593         record_topic(av[0]);
00594 
00595         if (ac > 1 && *av[1])
00596           send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]);
00597         else
00598           send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
00599     }
00600 
00601     return MOD_CONT;
00602 }
00603 
00604 int anope_event_tburst(char *source, int ac, char **av)
00605 {
00606     if (ac != 5)
00607         return MOD_CONT;
00608 
00609     av[0] = av[1];
00610     av[1] = av[3];
00611     av[3] = av[4];
00612 
00613     do_topic(source, 4, av);
00614     return MOD_CONT;
00615 }
00616 
00617 int anope_event_436(char *source, int ac, char **av)
00618 {
00619     if (ac < 1)
00620         return MOD_CONT;
00621 
00622     m_nickcoll(av[0]);
00623     return MOD_CONT;
00624 }
00625 
00626 
00627 void hybrid_cmd_sqline(char *mask, char *reason)
00628 {
00629     if (!mask || !reason)
00630         return;
00631 
00632     send_cmd(s_OperServ, "RESV * %s :%s", mask, reason);
00633 }
00634 
00635 void hybrid_cmd_unsqline(char *user)
00636 {
00637     if (!user)
00638         return;
00639 
00640     send_cmd(s_OperServ, "UNRESV * %s", user);
00641 }
00642 
00643 void hybrid_cmd_sgline(char *mask, char *reason)
00644 {
00645     if (!mask || !reason)
00646         return;
00647 
00648     send_cmd(s_OperServ, "XLINE * %s 0 :%s", mask, reason);
00649 }
00650 
00651 void hybrid_cmd_unsgline(char *mask)
00652 {
00653     if (!mask)
00654         return;
00655 
00656     send_cmd(s_OperServ, "UNXLINE * %s", mask);
00657 }
00658 
00659 void hybrid_cmd_szline(char *mask, char *reason, char *whom)
00660 {
00661     if (!mask || !reason)
00662         return;
00663 
00664     send_cmd(s_OperServ, "DLINE * 172800 %s :%s", mask, reason);
00665 }
00666 
00667 void hybrid_cmd_unszline(char *mask)
00668 {
00669     if (!mask)
00670         return;
00671 
00672     send_cmd(s_OperServ, "UNDLINE * %s", mask);
00673 }
00674 
00675 /*
00676 oper:           the nick of the oper performing the kline
00677 target.server:  the server(s) this kline is destined for
00678 duration:       the duration if a tkline, 0 if permanent.
00679 user:           the 'user' portion of the kline
00680 host:           the 'host' portion of the kline
00681 reason:         the reason for the kline.
00682 */
00683 
00684 void hybrid_cmd_akill(char *user, char *host, char *who, time_t when,
00685                       time_t expires, char *reason)
00686 {
00687     send_cmd(s_OperServ, "KLINE * %ld %s %s :%s",
00688              (long int) (expires - (long) time(NULL)), user, host, reason);
00689 }
00690 
00691 void hybrid_cmd_remove_akill(char *user, char *host)
00692 {
00693     send_cmd(s_OperServ, "UNKLINE * %s %s", user, host);
00694 }
00695 
00696 void hybrid_cmd_svsnoop(char *server, int set)
00697 {
00698     /* does not support */
00699 }
00700 
00701 void hybrid_cmd_svsadmin(char *server, int set)
00702 {
00703     hybrid_cmd_svsnoop(server, set);
00704 }
00705 
00706 void hybrid_cmd_topic(char *whosets, char *chan, char *whosetit,
00707                       char *topic, time_t when)
00708 {
00709     send_cmd(whosets, "TOPIC %s :%s", chan, topic);
00710 }
00711 
00712 void hybrid_cmd_vhost_off(User * u)
00713 {
00714     /* Not Supported by this IRCD */
00715 }
00716 
00717 void hybrid_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
00718 {
00719     /* Not Supported by this IRCD */
00720 }
00721 
00722 void hybrid_cmd_join(char *user, char *channel, time_t chantime)
00723 {
00724     send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) chantime, channel,
00725              user);
00726 }
00727 
00728 void hybrid_cmd_svskill(char *source, char *user, char *buf)
00729 {
00730     if (!buf || !source || !user)
00731         return;
00732 
00733     send_cmd(source, "KILL %s :%s", user, buf);
00734 }
00735 
00736 void hybrid_cmd_svsmode(User * u, int ac, char **av)
00737 {
00738     send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick,
00739              (long int)u->timestamp, av[0], (ac == 2 ? " " : ""),
00740              (ac == 2 ? av[1] : ""));
00741 }
00742 
00743 /*
00744  * SVINFO
00745  *      parv[0] = sender prefix
00746  *      parv[1] = TS_CURRENT for the server
00747  *      parv[2] = TS_MIN for the server
00748  *      parv[3] = server is standalone or connected to non-TS only
00749  *      parv[4] = server's idea of UTC time
00750  */
00751 void hybrid_cmd_svinfo()
00752 {
00753     send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL));
00754 }
00755 
00756 /* CAPAB */
00757 /*
00758  * As of December 21, 2012, ircd-hybrid-8 does support the following capabilities
00759  * which are required to work with IRC-services:
00760  *
00761  * QS     - Can handle quit storm removal
00762  * EX     - Can do channel +e exemptions
00763  * CHW    - Can do channel wall @#
00764  * IE     - Can do invite exceptions
00765  * KNOCK  - Supports KNOCK
00766  * TBURST - Supports topic burst
00767  * ENCAP  - Supports ENCAP
00768  * HOPS   - Supports HalfOps
00769  * SVS    - Supports services
00770  * EOB    - Supports End Of Burst message
00771  */
00772 void hybrid_cmd_capab()
00773 {
00774     send_cmd(NULL, "CAPAB :QS EX CHW IE ENCAP TBURST SVS HOPS EOB");
00775 }
00776 
00777 /* PASS */
00778 void hybrid_cmd_pass(char *pass)
00779 {
00780     send_cmd(NULL, "PASS %s :TS", pass);
00781 }
00782 
00783 /* SERVER name hop descript */
00784 void hybrid_cmd_server(char *servname, int hop, char *descript)
00785 {
00786     send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript);
00787 }
00788 
00789 void hybrid_cmd_connect(int servernum)
00790 {
00791     me_server =
00792         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00793 
00794     if (servernum == 1)
00795         hybrid_cmd_pass(RemotePassword);
00796     else if (servernum == 2)
00797         hybrid_cmd_pass(RemotePassword2);
00798     else if (servernum == 3)
00799         hybrid_cmd_pass(RemotePassword3);
00800 
00801     hybrid_cmd_capab();
00802     hybrid_cmd_server(ServerName, 1, ServerDesc);
00803     hybrid_cmd_svinfo();
00804 }
00805 
00806 void hybrid_cmd_bob()
00807 {
00808     /* Not used */
00809 }
00810 
00811 void hybrid_cmd_svsinfo()
00812 {
00813     /* not used */
00814 }
00815 
00816 void hybrid_cmd_bot_nick(char *nick, char *user, char *host, char *real,
00817                          char *modes)
00818 {
00819     EnforceQlinedNick(nick, s_BotServ);
00820     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 :%s", nick,
00821              (long int) time(NULL), modes, user, host, ServerName, real);
00822 
00823 }
00824 
00825 void hybrid_cmd_part(char *nick, char *chan, char *buf)
00826 {
00827     if (buf)
00828         send_cmd(nick, "PART %s :%s", chan, buf);
00829     else
00830         send_cmd(nick, "PART %s", chan);
00831 }
00832 
00833 int anope_event_ping(char *source, int ac, char **av)
00834 {
00835     if (ac < 1)
00836         return MOD_CONT;
00837 
00838     hybrid_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
00839     return MOD_CONT;
00840 }
00841 
00842 int anope_event_away(char *source, int ac, char **av)
00843 {
00844     if (!source)
00845         return MOD_CONT;
00846 
00847     m_away(source, (ac ? av[0] : NULL));
00848     return MOD_CONT;
00849 }
00850 
00851 int anope_event_kill(char *source, int ac, char **av)
00852 {
00853     if (ac != 2)
00854         return MOD_CONT;
00855 
00856     m_kill(av[0], av[1]);
00857     return MOD_CONT;
00858 }
00859 
00860 int anope_event_kick(char *source, int ac, char **av)
00861 {
00862     if (ac != 3)
00863         return MOD_CONT;
00864 
00865     do_kick(source, ac, av);
00866     return MOD_CONT;
00867 }
00868 
00869 int anope_event_eob(char *source, int ac, char **av)
00870 {
00871     Server *s = findserver(servlist, source);
00872 
00873     /* If we found a server with the given source, that one just
00874      * finished bursting. If there was no source, then our uplink
00875      * server finished bursting. -GD
00876      */
00877     if (!s && serv_uplink)
00878         s = serv_uplink;
00879 
00880     finish_sync(s, 1);
00881     return MOD_CONT;
00882 }
00883 
00884 void hybrid_cmd_eob()
00885 {
00886     send_cmd(ServerName, "EOB");
00887 }
00888 
00889 int anope_event_join(char *source, int ac, char **av)
00890 {
00891     if (ac != 1)
00892         return MOD_CONT;
00893 
00894     do_join(source, ac, av);
00895     return MOD_CONT;
00896 }
00897 
00898 int anope_event_motd(char *source, int ac, char **av)
00899 {
00900     if (!source)
00901         return MOD_CONT;
00902 
00903     m_motd(source);
00904     return MOD_CONT;
00905 }
00906 
00907 int anope_event_privmsg(char *source, int ac, char **av)
00908 {
00909     if (ac != 2)
00910         return MOD_CONT;
00911 
00912     m_privmsg(source, av[0], av[1]);
00913     return MOD_CONT;
00914 }
00915 
00916 int anope_event_part(char *source, int ac, char **av)
00917 {
00918     if (ac < 1 || ac > 2)
00919         return MOD_CONT;
00920 
00921     do_part(source, ac, av);
00922     return MOD_CONT;
00923 }
00924 
00925 int anope_event_whois(char *source, int ac, char **av)
00926 {
00927     if (source && ac >= 1)
00928         m_whois(source, av[0]);
00929 
00930     return MOD_CONT;
00931 }
00932 
00933 /* EVENT: SERVER */
00934 int anope_event_server(char *source, int ac, char **av)
00935 {
00936     if (!stricmp(av[1], "1"))
00937         uplink = sstrdup(av[0]);
00938 
00939     do_server(source, av[0], av[1], av[2], NULL);
00940     return MOD_CONT;
00941 }
00942 
00943 int anope_event_squit(char *source, int ac, char **av)
00944 {
00945     if (ac != 2)
00946         return MOD_CONT;
00947 
00948     do_squit(source, ac, av);
00949     return MOD_CONT;
00950 }
00951 
00952 int anope_event_quit(char *source, int ac, char **av)
00953 {
00954     if (ac != 1)
00955         return MOD_CONT;
00956 
00957     do_quit(source, ac, av);
00958     return MOD_CONT;
00959 }
00960 
00961 void hybrid_cmd_372(char *source, char *msg)
00962 {
00963     send_cmd(ServerName, "372 %s :- %s", source, msg);
00964 }
00965 
00966 void hybrid_cmd_372_error(char *source)
00967 {
00968     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
00969              "contact your IRC administrator.", source);
00970 }
00971 
00972 void hybrid_cmd_375(char *source)
00973 {
00974     send_cmd(ServerName, "375 %s :- %s Message of the Day",
00975              source, ServerName);
00976 }
00977 
00978 void hybrid_cmd_376(char *source)
00979 {
00980     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
00981 }
00982 
00983 /* 391 */
00984 void hybrid_cmd_391(char *source, char *timestr)
00985 {
00986     if (!timestr)
00987         return;
00988 
00989     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
00990 }
00991 
00992 /* 250 */
00993 void hybrid_cmd_250(char *buf)
00994 {
00995     if (!buf)
00996         return;
00997 
00998     send_cmd(NULL, "250 %s", buf);
00999 }
01000 
01001 /* 307 */
01002 void hybrid_cmd_307(char *buf)
01003 {
01004     if (!buf)
01005         return;
01006 
01007     send_cmd(ServerName, "307 %s", buf);
01008 }
01009 
01010 /* 311 */
01011 void hybrid_cmd_311(char *buf)
01012 {
01013     if (!buf)
01014         return;
01015 
01016     send_cmd(ServerName, "311 %s", buf);
01017 }
01018 
01019 /* 312 */
01020 void hybrid_cmd_312(char *buf)
01021 {
01022     if (!buf)
01023         return;
01024 
01025     send_cmd(ServerName, "312 %s", buf);
01026 }
01027 
01028 /* 317 */
01029 void hybrid_cmd_317(char *buf)
01030 {
01031     if (!buf)
01032         return;
01033 
01034     send_cmd(ServerName, "317 %s", buf);
01035 }
01036 
01037 /* 219 */
01038 void hybrid_cmd_219(char *source, char *letter)
01039 {
01040     if (!source)
01041         return;
01042 
01043     if (letter)
01044         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
01045                  *letter);
01046     else
01047         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
01048 }
01049 
01050 /* 401 */
01051 void hybrid_cmd_401(char *source, char *who)
01052 {
01053     if (!source || !who)
01054         return;
01055 
01056     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
01057 }
01058 
01059 /* 318 */
01060 void hybrid_cmd_318(char *source, char *who)
01061 {
01062     if (!source || !who)
01063         return;
01064 
01065     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01066 }
01067 
01068 /* 242 */
01069 void hybrid_cmd_242(char *buf)
01070 {
01071     if (!buf)
01072         return;
01073 
01074     send_cmd(NULL, "242 %s", buf);
01075 }
01076 
01077 /* 243 */
01078 void hybrid_cmd_243(char *buf)
01079 {
01080     if (!buf)
01081         return;
01082 
01083     send_cmd(NULL, "243 %s", buf);
01084 }
01085 
01086 /* 211 */
01087 void hybrid_cmd_211(char *buf)
01088 {
01089     if (!buf)
01090         return;
01091 
01092     send_cmd(NULL, "211 %s", buf);
01093 }
01094 
01095 void hybrid_cmd_mode(char *source, char *dest, char *buf)
01096 {
01097     if (!buf)
01098         return;
01099 
01100     send_cmd(source, "MODE %s %s", dest, buf);
01101 }
01102 
01103 void hybrid_cmd_nick(char *nick, char *name, char *mode)
01104 {
01105     EnforceQlinedNick(nick, NULL);
01106     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 :%s", nick,
01107              (long int) time(NULL), mode, ServiceUser, ServiceHost,
01108              ServerName, (name));
01109 }
01110 
01111 void hybrid_cmd_kick(char *source, char *chan, char *user, char *buf)
01112 {
01113     if (buf)
01114         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
01115     else
01116         send_cmd(source, "KICK %s %s", chan, user);
01117 }
01118 
01119 void hybrid_cmd_notice_ops(char *source, char *dest, char *buf)
01120 {
01121     if (!buf)
01122         return;
01123 
01124     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
01125 }
01126 
01127 void hybrid_cmd_bot_chan_mode(char *nick, char *chan)
01128 {
01129     anope_cmd_mode(nick, chan, "%s %s", ircd->botchanumode, nick);
01130 }
01131 
01132 /* QUIT */
01133 void hybrid_cmd_quit(char *source, char *buf)
01134 {
01135     if (buf)
01136         send_cmd(source, "QUIT :%s", buf);
01137     else
01138         send_cmd(source, "QUIT");
01139 }
01140 
01141 /* PONG */
01142 void hybrid_cmd_pong(char *servname, char *who)
01143 {
01144     send_cmd(servname, "PONG %s", who);
01145 }
01146 
01147 /* INVITE */
01148 void hybrid_cmd_invite(char *source, char *chan, char *nick)
01149 {
01150     if (!source || !chan || !nick)
01151         return;
01152 
01153     send_cmd(source, "INVITE %s %s", nick, chan);
01154 }
01155 
01156 /* SQUIT */
01157 void hybrid_cmd_squit(char *servname, char *message)
01158 {
01159     if (!servname || !message)
01160         return;
01161 
01162     send_cmd(NULL, "SQUIT %s :%s", servname, message);
01163 }
01164 
01165 int anope_event_mode(char *source, int ac, char **av)
01166 {
01167     if (ac < 2)
01168         return MOD_CONT;
01169 
01170     if (*av[0] == '#' || *av[0] == '&')
01171         do_cmode(source, ac, av);
01172     else
01173         do_umode(source, ac, av);
01174 
01175     return MOD_CONT;
01176 }
01177 
01178 void hybrid_cmd_351(char *source)
01179 {
01180     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01181              source, version_number, ServerName, ircd->name, version_flags,
01182              EncModule, version_build);
01183 }
01184 
01185 /* Event: PROTOCTL */
01186 int anope_event_capab(char *source, int ac, char **av)
01187 {
01188     int argvsize = 8;
01189     int argc;
01190     char **argv;
01191     char *str;
01192 
01193     if (ac < 1)
01194         return MOD_CONT;
01195 
01196     /* We get the params as one arg, we should split it for capab_parse */
01197     argv = scalloc(argvsize, sizeof(char *));
01198     argc = 0;
01199 
01200     while ((str = myStrGetToken(av[0], ' ', argc))) {
01201         if (argc == argvsize) {
01202             argvsize += 8;
01203             argv = srealloc(argv, argvsize * sizeof(char *));
01204         }
01205 
01206         argv[argc] = str;
01207         argc++;
01208     }
01209 
01210     capab_parse(argc, argv);
01211 
01212     /* Free our built ac/av */
01213     for (argvsize = 0; argvsize < argc; argvsize++)
01214         free(argv[argvsize]);
01215 
01216     free(argv);
01217 
01218     return MOD_CONT;
01219 }
01220 
01221 /* SVSHOLD - set */
01222 void hybrid_cmd_svshold(char *nick)
01223 {
01224     /* Not supported by this IRCD */
01225 }
01226 
01227 /* SVSHOLD - release */
01228 void hybrid_cmd_release_svshold(char *nick)
01229 {
01230     /* Not Supported by this IRCD */
01231 }
01232 
01233 /* SVSNICK */
01234 /* parv[0] = sender
01235  * parv[1] = old nickname
01236  * parv[2] = new nickname
01237  * parv[3] = timestamp
01238  */
01239 void hybrid_cmd_svsnick(char *nick, char *newnick, time_t when)
01240 {
01241     send_cmd(NULL, "SVSNICK %s %s :%ld", nick, newnick, (long int) when);
01242 }
01243 
01244 void hybrid_cmd_guest_nick(char *nick, char *user, char *host, char *real,
01245                            char *modes)
01246 {
01247     send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 :%s", nick,
01248              (long int) time(NULL), modes, user, host, ServerName, real);
01249 }
01250 
01251 void hybrid_cmd_svso(char *source, char *nick, char *flag)
01252 {
01253     /* Not Supported by this IRCD */
01254 }
01255 
01256 void hybrid_cmd_unban(char *name, char *nick)
01257 {
01258     /* Not Supported by this IRCD */
01259 }
01260 
01261 /* SVSMODE channel modes */
01262 
01263 void hybrid_cmd_svsmode_chan(char *name, char *mode, char *nick)
01264 {
01265     /* Not Supported by this IRCD */
01266 }
01267 
01268 /* SVSMODE +d */
01269 /* sent if svid is something weird */
01270 void hybrid_cmd_svid_umode(char *nick, time_t ts)
01271 {
01272   send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick,
01273            (unsigned long int) ts);
01274 }
01275 
01276 /* SVSMODE +d */
01277 /* nc_change was = 1, and there is no na->status */
01278 void hybrid_cmd_nc_change(User *u)
01279 {
01280     common_svsmode(u, "+d", "1");
01281 }
01282 
01283 /* SVSMODE +d */
01284 void hybrid_cmd_svid_umode2(User *u, char *ts)
01285 {
01286     /* not used */
01287 }
01288 
01289 void hybrid_cmd_svid_umode3(User *u, char *ts)
01290 {
01291     if (u->svid != u->timestamp)
01292         common_svsmode(u, "+rd", ts);
01293     else
01294         common_svsmode(u, "+r", NULL);
01295 }
01296 
01297 /* NICK <newnick>  */
01298 void hybrid_cmd_chg_nick(char *oldnick, char *newnick)
01299 {
01300     if (!oldnick || !newnick)
01301         return;
01302 
01303     send_cmd(oldnick, "NICK %s", newnick);
01304 }
01305 
01306 /*
01307  * SVINFO
01308  *      parv[0] = sender prefix
01309  *      parv[1] = TS_CURRENT for the server
01310  *      parv[2] = TS_MIN for the server
01311  *      parv[3] = server is standalone or connected to non-TS only
01312  *      parv[4] = server's idea of UTC time
01313  */
01314 int anope_event_svinfo(char *source, int ac, char **av)
01315 {
01316     /* currently not used but removes the message : unknown message from server */
01317     return MOD_CONT;
01318 }
01319 
01320 int anope_event_pass(char *source, int ac, char **av)
01321 {
01322     /* currently not used but removes the message : unknown message from server */
01323     return MOD_CONT;
01324 }
01325 
01326 void hybrid_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
01327 {
01328     /* Not Supported by this IRCD */
01329 }
01330 
01331 void hybrid_cmd_svspart(char *source, char *nick, char *chan)
01332 {
01333     /* Not Supported by this IRCD */
01334 }
01335 
01336 void hybrid_cmd_swhois(char *source, char *who, char *mask)
01337 {
01338     /* not supported */
01339 }
01340 
01341 int anope_event_notice(char *source, int ac, char **av)
01342 {
01343     return hybrid_event_notice(source, ac, av);
01344 }
01345 
01346 int anope_event_admin(char *source, int ac, char **av)
01347 {
01348     return MOD_CONT;
01349 }
01350 
01351 int anope_event_invite(char *source, int ac, char **av)
01352 {
01353     return MOD_CONT;
01354 }
01355 
01356 int hybrid_flood_mode_check(char *value)
01357 {
01358     return 0;
01359 }
01360 
01361 int anope_event_error(char *source, int ac, char **av)
01362 {
01363     if (ac >= 1)
01364         if (debug)
01365             alog("debug: %s", av[0]);
01366 
01367     return MOD_CONT;
01368 }
01369 
01370 void hybrid_cmd_jupe(char *jserver, char *who, char *reason)
01371 {
01372     char rbuf[256];
01373 
01374     snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
01375              reason ? ": " : "", reason ? reason : "");
01376 
01377     if (findserver(servlist, jserver))
01378         hybrid_cmd_squit(jserver, rbuf);
01379 
01380     hybrid_cmd_server(jserver, 2, rbuf);
01381     new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
01382 }
01383 
01384 /* 
01385   1 = valid nick
01386   0 = nick is in valid
01387 */
01388 int hybrid_valid_nick(char *nick)
01389 {
01390     /* no hard coded invalid nicks */
01391     return 1;
01392 }
01393 
01394 /* 
01395   1 = valid chan
01396   0 = chan is in valid
01397 */
01398 int hybrid_valid_chan(char *chan)
01399 {
01400     /* no hard coded invalid chans */
01401     return 1;
01402 }
01403 
01404 
01405 void hybrid_cmd_ctcp(char *source, char *dest, char *buf)
01406 {
01407     char *s = NULL;
01408 
01409     if (!buf)
01410         return;
01411 
01412     s = normalizeBuffer(buf);
01413 
01414     send_cmd(source, "NOTICE %s :\1%s \1", dest, s);
01415     free(s);
01416 }
01417 
01418 int hybrid_event_notice(char *source, int argc, char **argv)
01419 {
01420     return MOD_CONT;
01421 }
01422 
01423 /* *INDENT-OFF* */
01424 void moduleAddIRCDMsgs(void)
01425 {
01426     Message *m;
01427 
01428     updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-");
01429 
01430     m = createMessage("401",       anope_event_null); addCoreMessage(IRCD,m);
01431     m = createMessage("402",       anope_event_null); addCoreMessage(IRCD,m);
01432     m = createMessage("436",       anope_event_436); addCoreMessage(IRCD,m);
01433     m = createMessage("ADMIN",     anope_event_admin); addCoreMessage(IRCD,m);
01434     m = createMessage("AWAY",      anope_event_away); addCoreMessage(IRCD,m);
01435     m = createMessage("CAPAB",     anope_event_capab); addCoreMessage(IRCD,m);
01436     m = createMessage("EOB",       anope_event_eob); addCoreMessage(IRCD,m);
01437     m = createMessage("ERROR",     anope_event_error); addCoreMessage(IRCD,m);
01438     m = createMessage("GLOBOPS",   anope_event_null); addCoreMessage(IRCD,m);
01439     m = createMessage("INVITE",    anope_event_invite); addCoreMessage(IRCD,m);
01440     m = createMessage("JOIN",      anope_event_join); addCoreMessage(IRCD,m);
01441     m = createMessage("KICK",      anope_event_kick); addCoreMessage(IRCD,m);
01442     m = createMessage("KILL",      anope_event_kill); addCoreMessage(IRCD,m);
01443     m = createMessage("MODE",      anope_event_mode); addCoreMessage(IRCD,m);
01444     m = createMessage("MOTD",      anope_event_motd); addCoreMessage(IRCD,m);
01445     m = createMessage("NICK",      anope_event_nick); addCoreMessage(IRCD,m);
01446     m = createMessage("NOTICE",    anope_event_notice); addCoreMessage(IRCD,m);
01447     m = createMessage("PART",      anope_event_part); addCoreMessage(IRCD,m);
01448     m = createMessage("PASS",      anope_event_pass); addCoreMessage(IRCD,m);
01449     m = createMessage("PING",      anope_event_ping); addCoreMessage(IRCD,m);
01450     m = createMessage("PRIVMSG",   anope_event_privmsg); addCoreMessage(IRCD,m);
01451     m = createMessage("QUIT",      anope_event_quit); addCoreMessage(IRCD,m);
01452     m = createMessage("SERVER",    anope_event_server); addCoreMessage(IRCD,m);
01453     m = createMessage("SQUIT",     anope_event_squit); addCoreMessage(IRCD,m);
01454     m = createMessage("TOPIC",     anope_event_topic); addCoreMessage(IRCD,m);
01455     m = createMessage("TBURST",    anope_event_tburst); addCoreMessage(IRCD,m);
01456     m = createMessage("USER",      anope_event_null); addCoreMessage(IRCD,m);
01457     m = createMessage("WALLOPS",   anope_event_null); addCoreMessage(IRCD,m);
01458     m = createMessage("WHOIS",     anope_event_whois); addCoreMessage(IRCD,m);
01459     m = createMessage("SVSMODE",   anope_event_null); addCoreMessage(IRCD,m);
01460     m = createMessage("SVSNICK",   anope_event_null); addCoreMessage(IRCD,m);
01461     m = createMessage("SJOIN",     anope_event_sjoin); addCoreMessage(IRCD,m);
01462     m = createMessage("SVINFO",    anope_event_svinfo); addCoreMessage(IRCD,m);
01463 }
01464 /* *INDENT-ON* */
01465 
01470 void moduleAddAnopeCmds()
01471 {
01472     pmodule_cmd_svsnoop(hybrid_cmd_svsnoop);
01473     pmodule_cmd_remove_akill(hybrid_cmd_remove_akill);
01474     pmodule_cmd_topic(hybrid_cmd_topic);
01475     pmodule_cmd_vhost_off(hybrid_cmd_vhost_off);
01476     pmodule_cmd_akill(hybrid_cmd_akill);
01477     pmodule_cmd_svskill(hybrid_cmd_svskill);
01478     pmodule_cmd_svsmode(hybrid_cmd_svsmode);
01479     pmodule_cmd_372(hybrid_cmd_372);
01480     pmodule_cmd_372_error(hybrid_cmd_372_error);
01481     pmodule_cmd_375(hybrid_cmd_375);
01482     pmodule_cmd_376(hybrid_cmd_376);
01483     pmodule_cmd_nick(hybrid_cmd_nick);
01484     pmodule_cmd_guest_nick(hybrid_cmd_guest_nick);
01485     pmodule_cmd_mode(hybrid_cmd_mode);
01486     pmodule_cmd_bot_nick(hybrid_cmd_bot_nick);
01487     pmodule_cmd_kick(hybrid_cmd_kick);
01488     pmodule_cmd_notice_ops(hybrid_cmd_notice_ops);
01489     pmodule_cmd_notice(hybrid_cmd_notice);
01490     pmodule_cmd_notice2(hybrid_cmd_notice2);
01491     pmodule_cmd_privmsg(hybrid_cmd_privmsg);
01492     pmodule_cmd_privmsg2(hybrid_cmd_privmsg2);
01493     pmodule_cmd_serv_notice(hybrid_cmd_serv_notice);
01494     pmodule_cmd_serv_privmsg(hybrid_cmd_serv_privmsg);
01495     pmodule_cmd_bot_chan_mode(hybrid_cmd_bot_chan_mode);
01496     pmodule_cmd_351(hybrid_cmd_351);
01497     pmodule_cmd_quit(hybrid_cmd_quit);
01498     pmodule_cmd_pong(hybrid_cmd_pong);
01499     pmodule_cmd_join(hybrid_cmd_join);
01500     pmodule_cmd_unsqline(hybrid_cmd_unsqline);
01501     pmodule_cmd_invite(hybrid_cmd_invite);
01502     pmodule_cmd_part(hybrid_cmd_part);
01503     pmodule_cmd_391(hybrid_cmd_391);
01504     pmodule_cmd_250(hybrid_cmd_250);
01505     pmodule_cmd_307(hybrid_cmd_307);
01506     pmodule_cmd_311(hybrid_cmd_311);
01507     pmodule_cmd_312(hybrid_cmd_312);
01508     pmodule_cmd_317(hybrid_cmd_317);
01509     pmodule_cmd_219(hybrid_cmd_219);
01510     pmodule_cmd_401(hybrid_cmd_401);
01511     pmodule_cmd_318(hybrid_cmd_318);
01512     pmodule_cmd_242(hybrid_cmd_242);
01513     pmodule_cmd_243(hybrid_cmd_243);
01514     pmodule_cmd_211(hybrid_cmd_211);
01515     pmodule_cmd_global(hybrid_cmd_global);
01516     pmodule_cmd_global_legacy(hybrid_cmd_global_legacy);
01517     pmodule_cmd_sqline(hybrid_cmd_sqline);
01518     pmodule_cmd_squit(hybrid_cmd_squit);
01519     pmodule_cmd_svso(hybrid_cmd_svso);
01520     pmodule_cmd_chg_nick(hybrid_cmd_chg_nick);
01521     pmodule_cmd_svsnick(hybrid_cmd_svsnick);
01522     pmodule_cmd_vhost_on(hybrid_cmd_vhost_on);
01523     pmodule_cmd_connect(hybrid_cmd_connect);
01524     pmodule_cmd_bob(hybrid_cmd_bob);
01525     pmodule_cmd_svshold(hybrid_cmd_svshold);
01526     pmodule_cmd_release_svshold(hybrid_cmd_release_svshold);
01527     pmodule_cmd_unsgline(hybrid_cmd_unsgline);
01528     pmodule_cmd_unszline(hybrid_cmd_unszline);
01529     pmodule_cmd_szline(hybrid_cmd_szline);
01530     pmodule_cmd_sgline(hybrid_cmd_sgline);
01531     pmodule_cmd_unban(hybrid_cmd_unban);
01532     pmodule_cmd_svsmode_chan(hybrid_cmd_svsmode_chan);
01533     pmodule_cmd_svid_umode(hybrid_cmd_svid_umode);
01534     pmodule_cmd_nc_change(hybrid_cmd_nc_change);
01535     pmodule_cmd_svid_umode2(hybrid_cmd_svid_umode2);
01536     pmodule_cmd_svid_umode3(hybrid_cmd_svid_umode3);
01537     pmodule_cmd_svsjoin(hybrid_cmd_svsjoin);
01538     pmodule_cmd_svspart(hybrid_cmd_svspart);
01539     pmodule_cmd_swhois(hybrid_cmd_swhois);
01540     pmodule_cmd_eob(hybrid_cmd_eob);
01541     pmodule_flood_mode_check(hybrid_flood_mode_check);
01542     pmodule_cmd_jupe(hybrid_cmd_jupe);
01543     pmodule_valid_nick(hybrid_valid_nick);
01544     pmodule_valid_chan(hybrid_valid_chan);
01545     pmodule_cmd_ctcp(hybrid_cmd_ctcp);
01546     pmodule_set_umode(hybrid_set_umode);
01547 }
01548 
01552 int AnopeInit(int argc, char **argv)
01553 {
01554     moduleAddAuthor("Anope");
01555     moduleAddVersion(VERSION_STRING);
01556     moduleSetType(PROTOCOL);
01557 
01558     pmodule_ircd_version("Hybrid 8.0.*");
01559     pmodule_ircd_cap(myIrcdcap);
01560     pmodule_ircd_var(myIrcd);
01561     pmodule_ircd_cbmodeinfos(myCbmodeinfos);
01562     pmodule_ircd_cumodes(myCumodes);
01563     pmodule_ircd_flood_mode_char_set("");
01564     pmodule_ircd_flood_mode_char_remove("");
01565     pmodule_ircd_cbmodes(myCbmodes);
01566     pmodule_ircd_cmmodes(myCmmodes);
01567     pmodule_ircd_csmodes(myCsmodes);
01568     pmodule_ircd_useTSMode(0);
01569 
01571     pmodule_invis_umode(UMODE_i);
01572     pmodule_oper_umode(UMODE_o);
01573     pmodule_invite_cmode(CMODE_i);
01574     pmodule_secret_cmode(CMODE_s);
01575     pmodule_private_cmode(CMODE_p);
01576     pmodule_key_mode(CMODE_k);
01577     pmodule_limit_mode(CMODE_l);
01578     pmodule_permchan_mode(0);
01579 
01580     moduleAddAnopeCmds();
01581     moduleAddIRCDMsgs();
01582 
01583     return MOD_CONT;
01584 }