plexus3.c

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