ptlink.c

Go to the documentation of this file.
00001 /* PTLink IRCD functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@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 "ptlink.h"
00017 #include "version.h"
00018 
00019 IRCDVar myIrcd[] = {
00020     {"PTlink 6.15.*+",          /* ircd name */
00021      "+o",                      /* nickserv mode */
00022      "+o",                      /* chanserv mode */
00023      "+o",                      /* memoserv mode */
00024      "+o",                      /* hostserv mode */
00025      "+io",                     /* operserv mode */
00026      "+o",                      /* botserv mode  */
00027      "+h",                      /* 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      "+io",                     /* hostserv alias mode */
00034      "+io",                     /* operserv alias mode */
00035      "+o",                      /* botserv alias mode  */
00036      "+h",                      /* helpserv alias mode */
00037      "+i",                      /* Dev/Null alias mode */
00038      "+io",                     /* Global alias mode   */
00039      "+",                       /* Used by BotServ Bots */
00040      2,                         /* Chan Max Symbols     */
00041      "-inpsmtCRKOASdcqBNl",     /* Modes to Remove */
00042      "+ao",                     /* Channel Umode used by Botserv bots */
00043      1,                         /* SVSNICK */
00044      1,                         /* Vhost  */
00045      0,                         /* Has Owner */
00046      NULL,                      /* Mode to set for an owner */
00047      NULL,                      /* Mode to unset for an owner */
00048      "+a",                      /* Mode to set for chan admin */
00049      "-a",                      /* Mode to unset for chan admin */
00050      "+r",                      /* 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",                      /* Mode on UnReg        */
00055      NULL,                      /* Mode on Nick Change  */
00056      1,                         /* Supports SGlines     */
00057      1,                         /* Supports SQlines     */
00058      1,                         /* Supports SZlines     */
00059      0,                         /* Supports Halfop +h   */
00060      4,                         /* Number of server args */
00061      0,                         /* Join 2 Set           */
00062      0,                         /* Join 2 Message       */
00063      1,                         /* Has exceptions +e    */
00064      0,                         /* TS Topic Forward     */
00065      0,                         /* TS Topci Backward    */
00066      0,                         /* Protected Umode      */
00067      0,                         /* Has Admin            */
00068      0,                         /* Chan SQlines         */
00069      0,                         /* Quit on Kill         */
00070      0,                         /* SVSMODE unban        */
00071      1,                         /* Has Protect          */
00072      0,                         /* Reverse              */
00073      1,                         /* Chan Reg             */
00074      CMODE_r,                   /* Channel Mode         */
00075      1,                         /* vidents              */
00076      0,                         /* svshold              */
00077      0,                         /* time stamp on mode   */
00078      0,                         /* NICKIP               */
00079      0,                         /* O:LINE               */
00080      1,                         /* UMODE                */
00081      1,                         /* VHOST ON NICK        */
00082      0,                         /* Change RealName      */
00083      CMODE_K,                   /* No Knock             */
00084      CMODE_A,                   /* Admin Only           */
00085      DEFAULT_MLOCK,             /* Default MLOCK        */
00086      UMODE_VH,                  /* Vhost Mode           */
00087      1,                         /* +f                   */
00088      0,                         /* +L                   */
00089      CMODE_f,
00090      0,
00091      1,
00092      1,                         /* No Knock requires +i */
00093      NULL,                      /* CAPAB Chan Modes             */
00094      0,                         /* We support TOKENS */
00095      1,                         /* TOKENS are CASE inSensitive */
00096      0,                         /* TIME STAMPS are BASE64 */
00097      0,                         /* +I support */
00098      0,                         /* SJOIN ban char */
00099      0,                         /* SJOIN except char */
00100      0,                         /* SJOIN invite char */
00101      0,                         /* Can remove User Channel Modes with SVSMODE */
00102      0,                         /* Sglines are not enforced until user reconnects */
00103      NULL,                      /* vhost char */
00104      0,                         /* ts6 */
00105      1,                         /* support helper umode */
00106      0,                         /* p10 */
00107      NULL,                      /* character set */
00108      0,                         /* reports sync state */
00109      0,                         /* 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      0,                         /* NOQUIT       */
00121      0,                         /* TSMODE       */
00122      0,                         /* UNCONNECT    */
00123      0,                         /* NICKIP       */
00124      0,                         /* SJOIN        */
00125      CAPAB_ZIP,                 /* ZIP          */
00126      0,                         /* BURST        */
00127      0,                         /* TS5          */
00128      0,                         /* TS3          */
00129      0,                         /* DKEY         */
00130      CAPAB_PT4,                 /* PT4          */
00131      CAPAB_SCS,                 /* SCS          */
00132      CAPAB_QS,                  /* QS           */
00133      0,                         /* UID          */
00134      0,                         /* 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 unsigned long umodes[128] = {
00153     0, 0, 0,                    /* Unused */
00154     0, 0, 0,                    /* Unused */
00155     0, 0, 0,                    /* Unused, Unused, Horzontal Tab */
00156     0, 0, 0,                    /* Line Feed, Unused, Unused */
00157     0, 0, 0,                    /* Carriage Return, Unused, Unused */
00158     0, 0, 0,                    /* Unused */
00159     0, 0, 0,                    /* Unused */
00160     0, 0, 0,                    /* Unused */
00161     0, 0, 0,                    /* Unused */
00162     0, 0, 0,                    /* Unused */
00163     0, 0, 0,                    /* Unused, Unused, Space */
00164     0, 0, 0,                    /* ! " #  */
00165     0, 0, 0,                    /* $ % &  */
00166     0, 0, 0,                    /* ! ( )  */
00167     0, 0, 0,                    /* * + ,  */
00168     0, 0, 0,                    /* - . /  */
00169     0, 0,                       /* 0 1 */
00170     0, 0,                       /* 2 3 */
00171     0, 0,                       /* 4 5 */
00172     0, 0,                       /* 6 7 */
00173     0, 0,                       /* 8 9 */
00174     0, 0,                       /* : ; */
00175     0, 0, 0,                    /* < = > */
00176     0, 0,                       /* ? @ */
00177     UMODE_A, UMODE_B, 0,        /* A B C */
00178     0, 0, 0,                    /* D E F */
00179     0, UMODE_H, 0,              /* G H I */
00180     0, 0, 0,                    /* J K L */
00181     0, UMODE_N, UMODE_O,        /* M N O */
00182     0, 0, UMODE_R,              /* P Q R */
00183     UMODE_S, UMODE_T, 0,        /* S T U */
00184     0, 0, 0,                    /* V W X */
00185     0,                          /* Y */
00186     0,                          /* Z */
00187     0, 0, 0,                    /* [ \ ] */
00188     0, 0, 0,                    /* ^ _ ` */
00189     UMODE_a, 0, 0,              /* a b c */
00190     0, 0, 0,                    /* d e f */
00191     0, UMODE_h, UMODE_i,        /* g h i */
00192     0, 0, 0,                    /* j k l */
00193     0, 0, UMODE_o,              /* m n o */
00194     UMODE_p, 0, UMODE_r,        /* p q r */
00195     UMODE_s, 0, 0,              /* s t u */
00196     UMODE_v, UMODE_w, 0,        /* v w x */
00197     UMODE_y,                    /* y */
00198     UMODE_z,                    /* z */
00199     0, 0, 0,                    /* { | } */
00200     0, 0                        /* ~ � */
00201 };
00202 
00203 char myCsmodes[128] = {
00204     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00205     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00206 
00207     0,
00208     0,
00209     0, 0, 0,
00210     0,
00211     0, 0, 0, 0,
00212     0,
00213 
00214     'v', 0, 0, 'a', 0,
00215     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00216 
00217     'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00218     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00219 
00220     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00221     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00222 };
00223 
00224 
00225 CMMode myCmmodes[128] = {
00226     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00227     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00228     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00229     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00230     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00231     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00232     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00233     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00234     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00235     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00236     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00237     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00238     {NULL},
00239     {NULL},
00240     {add_ban, del_ban},
00241     {NULL},
00242     {NULL},
00243     {add_exception, del_exception},
00244     {NULL},
00245     {NULL},
00246     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00247     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00248     {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00249 };
00250 
00251 
00252 CBMode myCbmodes[128] = {
00253     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00254     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00255     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00256     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00257     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00258     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00259     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00260     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00261     {0},
00262     {CMODE_A, 0, NULL, NULL},   /* A */
00263     {CMODE_B, 0, NULL, NULL},   /* B */
00264     {CMODE_C, 0, NULL, NULL},   /* C */
00265     {0},                        /* D */
00266     {0},                        /* E */
00267     {0},                        /* F */
00268     {0},                        /* G */
00269     {0},                        /* H */
00270     {0},                        /* I */
00271     {0},                        /* J */
00272     {CMODE_K, 0, NULL, NULL},   /* K */
00273     {0},                        /* L */
00274     {0},                        /* M */
00275     {CMODE_N, 0, NULL, NULL},   /* N */
00276     {CMODE_O, 0, NULL, NULL},   /* O */
00277     {0},                        /* P */
00278     {0},                        /* Q */
00279     {CMODE_R, 0, NULL, NULL},   /* R */
00280     {CMODE_S, 0, NULL, NULL},   /* S */
00281     {0},                        /* T */
00282     {0},                        /* U */
00283     {0},                        /* V */
00284     {0},                        /* W */
00285     {0},                        /* X */
00286     {0},                        /* Y */
00287     {0},                        /* Z */
00288     {0}, {0}, {0}, {0}, {0}, {0},
00289     {0},                        /* a */
00290     {0},                        /* b */
00291     {CMODE_c, 0, NULL, NULL},
00292     {CMODE_d, 0, NULL, NULL},
00293     {0},                        /* e */
00294     {CMODE_f, 0, set_flood, cs_set_flood},
00295     {0},                        /* g */
00296     {0},                        /* h */
00297     {CMODE_i, 0, NULL, NULL},
00298     {0},                        /* j */
00299     {CMODE_k, 0, chan_set_key, cs_set_key},
00300     {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00301     {CMODE_m, 0, NULL, NULL},
00302     {CMODE_n, 0, NULL, NULL},
00303     {0},                        /* o */
00304     {CMODE_p, 0, NULL, NULL},
00305     {CMODE_q, 0, NULL, NULL},
00306     {CMODE_r, CBM_NO_MLOCK, NULL, NULL},
00307     {CMODE_s, 0, NULL, NULL},
00308     {CMODE_t, 0, NULL, NULL},
00309     {0},
00310     {0},                        /* v */
00311     {0},                        /* w */
00312     {0},                        /* x */
00313     {0},                        /* y */
00314     {0},                        /* z */
00315     {0}, {0}, {0}, {0}
00316 };
00317 
00318 CBModeInfo myCbmodeinfos[] = {
00319     {'c', CMODE_c, 0, NULL, NULL},
00320     {'d', CMODE_d, 0, NULL, NULL},
00321     {'f', CMODE_f, 0, get_flood, cs_get_flood},
00322     {'i', CMODE_i, 0, NULL, NULL},
00323     {'k', CMODE_k, 0, get_key, cs_get_key},
00324     {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00325     {'m', CMODE_m, 0, NULL, NULL},
00326     {'n', CMODE_n, 0, NULL, NULL},
00327     {'p', CMODE_p, 0, NULL, NULL},
00328     {'q', CMODE_q, 0, NULL, NULL},
00329     {'r', CMODE_r, 0, NULL, NULL},
00330     {'s', CMODE_s, 0, NULL, NULL},
00331     {'t', CMODE_t, 0, NULL, NULL},
00332     {'A', CMODE_A, 0, NULL, NULL},
00333     {'B', CMODE_B, 0, NULL, NULL},
00334     {'C', CMODE_C, 0, NULL, NULL},
00335     {'K', CMODE_K, 0, NULL, NULL},
00336     {'N', CMODE_N, 0, NULL, NULL},
00337     {'O', CMODE_O, 0, NULL, NULL},
00338     {'R', CMODE_R, 0, NULL, NULL},
00339     {'S', CMODE_S, 0, NULL, NULL},
00340     {0}
00341 };
00342 
00343 CUMode myCumodes[128] = {
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 
00349     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00350     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00351     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00352     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00353 
00354     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00355     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00356     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00357     {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00358 
00359     {0},
00360 
00361     {0},                        /* a */
00362     {0},                        /* b */
00363     {0},                        /* c */
00364     {0},                        /* d */
00365     {0},                        /* e */
00366     {0},                        /* f */
00367     {0},                        /* g */
00368     {0},                        /* h */
00369     {0},                        /* i */
00370     {0},                        /* j */
00371     {0},                        /* k */
00372     {0},                        /* l */
00373     {0},                        /* m */
00374     {0},                        /* n */
00375     {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op},
00376     {0},                        /* p */
00377     {0},                        /* q */
00378     {0},                        /* r */
00379     {0},                        /* s */
00380     {0},                        /* t */
00381     {0},                        /* u */
00382     {CUS_VOICE, 0, NULL},
00383     {0},                        /* w */
00384     {0},                        /* x */
00385     {0},                        /* y */
00386     {0},                        /* z */
00387     {0}, {0}, {0}, {0}, {0}
00388 };
00389 
00390 
00391 
00392 void ptlink_cmd_bot_chan_mode(char *nick, char *chan)
00393 {
00394     anope_cmd_mode(s_ChanServ, chan, "%s %s %s", ircd->botchanumode, nick,
00395                    nick);
00396 }
00397 
00398 /*
00399   :%s SJOIN %lu %s %s %s :%s
00400         parv[0] = sender
00401         parv[1] = channel TS (channel creation time)
00402         parv[2] = channel
00403         parv[3] = modes + n arguments (key and/or limit) 
00404         ... [n]  = if(key and/or limit) mode arguments
00405         parv[4+n] = flags+nick list (all in one parameter)
00406         NOTE: ignore channel modes if we already have the channel with a gr
00407 */
00408 int anope_event_sjoin(char *source, int ac, char **av)
00409 {
00410     do_sjoin(source, ac, av);
00411     return MOD_CONT;
00412 }
00413 
00414 /*
00415  * Note: This function has no validation whatsoever. Also, as of PTlink6.15.1
00416  * when you /deoper you get to keep your vindent, but you lose your vhost. In
00417  * that case serives will *NOT* modify it's internal record for the vhost. We
00418  * need to address this in the future.
00419  */
00420 /*
00421   :%s NEWMASK %s
00422         parv[0] = sender
00423         parv[1] = new mask (if no '@', hostname is assumed)
00424 */
00425 int anope_event_newmask(char *source, int ac, char **av)
00426 {
00427     User *u;
00428     char *newhost = NULL, *newuser = NULL;
00429     int tofree = 0;
00430 
00431     if (ac != 1)
00432         return MOD_CONT;
00433     u = finduser(source);
00434 
00435     if (!u) {
00436         if (debug) {
00437             alog("debug: NEWMASK for nonexistent user %s", av[0]);
00438         }
00439         return MOD_CONT;
00440     }
00441 
00442     if ((u->mode & (UMODE_NM | UMODE_VH)) == (UMODE_NM | UMODE_VH)) {
00443         /* This NEWMASK should be discarded because it's sent due to a +r by
00444          * someone with a ptlink-masked host. PTlink has our correct host, so
00445          * we can just ignore this :) Or we'll get ptlink's old host which is
00446          * not what we want. -GD
00447          */
00448         u->mode &= ~UMODE_NM;
00449         if (debug)
00450             alog("debug: Ignoring NEWMASK because it's sent because of SVSMODE +r");
00451         return MOD_CONT;
00452     }
00453 
00454     newuser = myStrGetOnlyToken(av[0], '@', 0);
00455     if (newuser) {
00456         newhost = myStrGetTokenRemainder(av[0], '@', 1);
00457         tofree = 1;
00458         change_user_username(u, newuser);
00459         free(newuser);
00460     } else {
00461         newhost = av[0];
00462     }
00463 
00464     if (newhost && *newhost == '@')
00465         newhost++;
00466 
00467     u->mode |= UMODE_VH;
00468 
00469     if (newhost)
00470         change_user_host(u, newhost);
00471 
00472     if (tofree)
00473         free(newhost);
00474 
00475     return MOD_CONT;
00476 }
00477 
00478 /*
00479  NICK %s %d %lu %s %s %s %s %s :%s
00480         parv[0] = nickname
00481         parv[1] = hopcount 
00482         parv[2] = nick TS (nick introduction time)
00483         parv[3] = umodes
00484     parv[4] = username
00485     parv[5] = hostname
00486     parv[6] = spoofed hostname
00487     parv[7] = server
00488     parv[8] = nick info
00489 */
00490 /*
00491  Change NICK
00492         parv[0] = old nick
00493         parv[1] = new nick
00494         parv[2] = TS (timestamp from user's server when nick changed was received)
00495 */
00496 /*
00497  NICK xpto 2 561264 +rw irc num.myisp.pt mask.myisp.pt uc.ptlink.net :Just me
00498        0   1  2      3   4   5            6              7             8
00499 
00500 */
00501 int anope_event_nick(char *source, int ac, char **av)
00502 {
00503     User *user;
00504 
00505     if (ac != 2) {
00506         user = do_nick(source, av[0], av[4], av[5], av[7], av[8],
00507                        strtoul(av[2], NULL, 10), 0, 0, av[6], NULL);
00508         if (user)
00509             anope_set_umode(user, 1, &av[3]);
00510     } else {
00511         do_nick(source, av[0], NULL, NULL, NULL, NULL,
00512                 strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
00513     }
00514     return MOD_CONT;
00515 }
00516 
00517 /*
00518   :%s SERVER %s %d %s :%s
00519         parv[0] = server from where the server was introduced to us 
00520         parv[1] = server name
00521         parv[2] = hop count (1 wen are directly connected)
00522         parv[3] = server version
00523         parv[4] = server description
00524 */
00525 int anope_event_server(char *source, int ac, char **av)
00526 {
00527     if (!stricmp(av[1], "1")) {
00528         uplink = sstrdup(av[0]);
00529     }
00530     do_server(source, av[0], av[1], av[3], NULL);
00531     return MOD_CONT;
00532 }
00533 
00534 int anope_event_436(char *source, int ac, char **av)
00535 {
00536     if (ac < 1)
00537         return MOD_CONT;
00538 
00539     m_nickcoll(av[0]);
00540     return MOD_CONT;
00541 }
00542 
00543 
00544 void moduleAddIRCDMsgs(void)
00545 {
00546     Message *m;
00547 
00548     updateProtectDetails("PROTECT", "PROTECTME", "protect", "deprotect",
00549                          "AUTOPROTECT", "+a", "-a");
00550 
00551     m = createMessage("401", anope_event_null);
00552     addCoreMessage(IRCD, m);
00553     m = createMessage("402", anope_event_null);
00554     addCoreMessage(IRCD, m);
00555     m = createMessage("436", anope_event_436);
00556     addCoreMessage(IRCD, m);
00557     m = createMessage("461", anope_event_null);
00558     addCoreMessage(IRCD, m);
00559     m = createMessage("AWAY", anope_event_away);
00560     addCoreMessage(IRCD, m);
00561     m = createMessage("INVITE", anope_event_invite);
00562     addCoreMessage(IRCD, m);
00563     m = createMessage("JOIN", anope_event_join);
00564     addCoreMessage(IRCD, m);
00565     m = createMessage("KICK", anope_event_kick);
00566     addCoreMessage(IRCD, m);
00567     m = createMessage("KILL", anope_event_kill);
00568     addCoreMessage(IRCD, m);
00569     m = createMessage("MODE", anope_event_mode);
00570     addCoreMessage(IRCD, m);
00571     m = createMessage("MOTD", anope_event_motd);
00572     addCoreMessage(IRCD, m);
00573     m = createMessage("NICK", anope_event_nick);
00574     addCoreMessage(IRCD, m);
00575     m = createMessage("NOTICE", anope_event_notice);
00576     addCoreMessage(IRCD, m);
00577     m = createMessage("PART", anope_event_part);
00578     addCoreMessage(IRCD, m);
00579     m = createMessage("PASS", anope_event_pass);
00580     addCoreMessage(IRCD, m);
00581     m = createMessage("PING", anope_event_ping);
00582     addCoreMessage(IRCD, m);
00583     m = createMessage("PRIVMSG", anope_event_privmsg);
00584     addCoreMessage(IRCD, m);
00585     m = createMessage("QUIT", anope_event_quit);
00586     addCoreMessage(IRCD, m);
00587     m = createMessage("SERVER", anope_event_server);
00588     addCoreMessage(IRCD, m);
00589     m = createMessage("SQUIT", anope_event_squit);
00590     addCoreMessage(IRCD, m);
00591     m = createMessage("TOPIC", anope_event_topic);
00592     addCoreMessage(IRCD, m);
00593     m = createMessage("USER", anope_event_null);
00594     addCoreMessage(IRCD, m);
00595     m = createMessage("WALLOPS", anope_event_null);
00596     addCoreMessage(IRCD, m);
00597     m = createMessage("WHOIS", anope_event_whois);
00598     addCoreMessage(IRCD, m);
00599     m = createMessage("AKILL", anope_event_null);
00600     addCoreMessage(IRCD, m);
00601     m = createMessage("GLOBOPS", anope_event_null);
00602     addCoreMessage(IRCD, m);
00603     m = createMessage("GNOTICE", anope_event_null);
00604     addCoreMessage(IRCD, m);
00605     m = createMessage("GOPER", anope_event_null);
00606     addCoreMessage(IRCD, m);
00607     m = createMessage("RAKILL", anope_event_null);
00608     addCoreMessage(IRCD, m);
00609     m = createMessage("SILENCE", anope_event_null);
00610     addCoreMessage(IRCD, m);
00611     m = createMessage("SVSKILL", anope_event_null);
00612     addCoreMessage(IRCD, m);
00613     m = createMessage("SVSMODE", anope_event_null);
00614     addCoreMessage(IRCD, m);
00615     m = createMessage("SVSNICK", anope_event_null);
00616     addCoreMessage(IRCD, m);
00617     m = createMessage("SVSNOOP", anope_event_null);
00618     addCoreMessage(IRCD, m);
00619     m = createMessage("SQLINE", anope_event_null);
00620     addCoreMessage(IRCD, m);
00621     m = createMessage("UNSQLINE", anope_event_null);
00622     addCoreMessage(IRCD, m);
00623     m = createMessage("NEWMASK", anope_event_newmask);
00624     addCoreMessage(IRCD, m);
00625     m = createMessage("CAPAB", anope_event_capab);
00626     addCoreMessage(IRCD, m);
00627     m = createMessage("SVINFO", anope_event_svinfo);
00628     addCoreMessage(IRCD, m);
00629     m = createMessage("SVSINFO", anope_event_svsinfo);
00630     addCoreMessage(IRCD, m);
00631     m = createMessage("SJOIN", anope_event_sjoin);
00632     addCoreMessage(IRCD, m);
00633     m = createMessage("REHASH", anope_event_rehash);
00634     addCoreMessage(IRCD, m);
00635     m = createMessage("ADMIN", anope_event_admin);
00636     addCoreMessage(IRCD, m);
00637     m = createMessage("CREDITS", anope_event_credits);
00638     addCoreMessage(IRCD, m);
00639     m = createMessage("ERROR", anope_event_error);
00640     addCoreMessage(IRCD, m);
00641     m = createMessage("NJOIN", anope_event_sjoin);
00642     addCoreMessage(IRCD, m);
00643     m = createMessage("NNICK", anope_event_nick);
00644     addCoreMessage(IRCD, m);
00645     m = createMessage("ZLINE", anope_event_null);
00646     addCoreMessage(IRCD, m);
00647     m = createMessage("UNZLINE", anope_event_null);
00648     addCoreMessage(IRCD, m);
00649 }
00650 
00651 int anope_event_svsinfo(char *source, int ac, char **av)
00652 {
00653     return MOD_CONT;
00654 }
00655 
00656 int anope_event_svinfo(char *source, int ac, char **av)
00657 {
00658     return MOD_CONT;
00659 }
00660 
00661 /* Event: PROTOCTL */
00662 int anope_event_capab(char *source, int ac, char **av)
00663 {
00664     capab_parse(ac, av);
00665     return MOD_CONT;
00666 }
00667 
00668 /*
00669    :%s SQLINE %s :%s
00670         parv[0] = sender 
00671         parv[1] = sqlined nick/mask
00672         parv[2] = reason
00673 */
00674 void ptlink_cmd_sqline(char *mask, char *reason)
00675 {
00676     send_cmd(ServerName, "SQLINE %s :%s", mask, reason);
00677 }
00678 
00679 /*
00680   :%s SVSADMIN %s :%s
00681         parv[0] = sender (services client)
00682         parv[1] = target server
00683     parv[2] = operation
00684           operations:
00685                 noopers - remove existing opers and disable o:lines
00686 */
00687 void ptlink_cmd_svsnoop(char *server, int set)
00688 {
00689     send_cmd(NULL, "SVSADMIN %s :%s", server, set ? "noopers" : "rehash");
00690 }
00691 
00692 void ptlink_cmd_svsadmin(char *server, int set)
00693 {
00694     ptlink_cmd_svsnoop(server, set);
00695 }
00696 
00697 /*
00698   :%s UNGLINE %s
00699         parv[0] = sender (server if on network synchronization)
00700         parv[1] = glined usert@host mask or ALL to remove all glines
00701 */
00702 void ptlink_cmd_remove_akill(char *user, char *host)
00703 {
00704     send_cmd(NULL, "UNGLINE %s@%s", user, host);
00705 }
00706 
00707 
00708 void anope_part(char *nick, char *chan)
00709 {
00710     send_cmd(nick, "PART %s", chan);
00711 }
00712 void anope_topic(char *whosets, char *chan, char *whosetit, char *topic,
00713                  time_t when)
00714 {
00715     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
00716              (unsigned long int) when, topic);
00717 }
00718 
00719 /*
00720  :%s UNSQLINE %s
00721         parv[0] = sender 
00722         parv[1] = sqlined nick/mask
00723 */
00724 void ptlink_cmd_unsqline(char *user)
00725 {
00726     send_cmd(NULL, "UNSQLINE %s", user);
00727 }
00728 
00729 void ptlink_cmd_join(char *user, char *channel, time_t chantime)
00730 {
00731     send_cmd(ServerName, "SJOIN %ld %s + :%s", (long int) chantime,
00732              channel, user);
00733 }
00734 
00735 /*
00736    :%s GLINE %s %lu %s %s
00737         parv[0] = sender (server if on network synchronization)
00738         parv[1] = glined usert@host mask
00739         parv[2] = gline duration time (seconds)
00740         parv[3] = who added the gline 
00741         parv[4] = reason
00742 */
00743 void ptlink_cmd_akill(char *user, char *host, char *who, time_t when,
00744                       time_t expires, char *reason)
00745 {
00746     send_cmd(ServerName, "GLINE %s@%s %i %s :%s", user, host, 86400 * 2,
00747              who, reason);
00748 }
00749 
00750 
00751 void ptlink_cmd_svskill(char *source, char *user, char *buf)
00752 {
00753     if (!buf) {
00754         return;
00755     }
00756 
00757     if (!source || !user) {
00758         return;
00759     }
00760 
00761     send_cmd(source, "KILL %s :%s", user, buf);
00762 }
00763 
00764 /*
00765   :%s SVSMODE %s %s :%s
00766         parv[0] = sender (services client)
00767         parv[1] = target client nick
00768         parv[2] = mode changes
00769         parv[3] = extra parameter ( if news setting mode(+n) )
00770   e.g.: :NickServ SVSMODE Lamego +rn 1991234
00771 */
00772 void ptlink_cmd_svsmode(User * u, int ac, char **av)
00773 {
00774     send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0],
00775              (ac == 2 ? " " : ""), (ac == 2 ? av[1] : ""));
00776 
00777     /* If we set +r on someone +NRah (1 or more of those modes), PTlink will
00778      * send us a NEWMASK with their ptlink-masked-host. If we want HostServ
00779      * to work for them, we will need to send our NEWMASK after we receive
00780      * theirs. Thus we make a hack and store in moduleData that we need to
00781      * look out for that.
00782      */
00783     if ((strchr(av[0], 'r')
00784          && ((u->mode & UMODE_N) || (u->mode & UMODE_R)
00785              || (u->mode & UMODE_a) || (u->mode & UMODE_h))))
00786         u->mode |= UMODE_NM;
00787 }
00788 
00789 int anope_event_error(char *source, int ac, char **av)
00790 {
00791     if (ac >= 1) {
00792         if (debug) {
00793             alog("debug: %s", av[0]);
00794         }
00795     }
00796     return MOD_CONT;
00797 }
00798 
00799 void ptlink_cmd_squit(char *servname, char *message)
00800 {
00801     send_cmd(NULL, "SQUIT %s :%s", servname, message);
00802 }
00803 
00804 /* PONG */
00805 void ptlink_cmd_pong(char *servname, char *who)
00806 {
00807     send_cmd(servname, "PONG %s", who);
00808 }
00809 
00810 /*
00811   SVINFO %d %d
00812         parv[0] = server name
00813         parv[1] = current supported protocol version
00814         parv[2] = minimum supported protocol version
00815 
00816   See the ptlink.h for information on PTLINK_TS_CURRENT, and
00817   PTLINK_TS_MIN
00818 */
00819 void ptlink_cmd_svinfo()
00820 {
00821 #if defined(PTLINK_TS_CURRENT) && defined(PTLINK_TS_MIN)
00822     send_cmd(NULL, "SVINFO %d %d %lu", PTLINK_TS_CURRENT, PTLINK_TS_MIN,
00823              (unsigned long int) time(NULL));
00824 #else
00825     /* hardwired if the defs some how go missing */
00826     send_cmd(NULL, "SVINFO 6 3 %lu", (unsigned long int) time(NULL));
00827 #endif
00828 }
00829 
00830 /*
00831   SVSINFO %lu %d
00832         parv[0] = sender (server name)
00833         parv[1] = local services data TS
00834         parv[1] = max global users
00835 */
00836 void ptlink_cmd_svsinfo()
00837 {
00838     send_cmd(NULL, "SVSINFO %lu %d", (unsigned long int) time(NULL),
00839              maxusercnt);
00840 }
00841 
00842 /*
00843   PASS %s :TS
00844         parv[1] = connection password 
00845         (TS indicates this is server uses TS protocol and SVINFO will be sent 
00846         for protocol compatibility checking)
00847 */
00848 void ptlink_cmd_pass(char *pass)
00849 {
00850     send_cmd(NULL, "PASS %s :TS", pass);
00851 }
00852 
00853 /*
00854   CAPAB :%s
00855         parv[1] = capability list 
00856 */
00857 void ptlink_cmd_capab()
00858 {
00859     send_cmd(NULL, "CAPAB :QS PTS4");
00860 }
00861 
00862 
00863 void ptlink_cmd_server(char *servname, int hop, char *descript)
00864 {
00865     send_cmd(NULL, "SERVER %s %d Anope.Services%s :%s", servname, hop,
00866              version_number_dotted, descript);
00867 }
00868 void ptlink_cmd_connect(int servernum)
00869 {
00870     me_server =
00871         new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00872 
00873     if (servernum == 1)
00874         ptlink_cmd_pass(RemotePassword);
00875     else if (servernum == 2)
00876         ptlink_cmd_pass(RemotePassword2);
00877     else if (servernum == 3)
00878         ptlink_cmd_pass(RemotePassword3);
00879 
00880     ptlink_cmd_capab();
00881     ptlink_cmd_server(ServerName, 1, ServerDesc);
00882     ptlink_cmd_svinfo();
00883     ptlink_cmd_svsinfo();
00884 }
00885 
00886 void ptlink_cmd_bob()
00887 {
00888     /* Not used */
00889 }
00890 
00891 
00892 int anope_event_privmsg(char *source, int ac, char **av)
00893 {
00894     if (ac != 2)
00895         return MOD_CONT;
00896     m_privmsg(source, av[0], av[1]);
00897     return MOD_CONT;
00898 }
00899 
00900 int anope_event_part(char *source, int ac, char **av)
00901 {
00902     if (ac < 1 || ac > 2)
00903         return MOD_CONT;
00904     do_part(source, ac, av);
00905     return MOD_CONT;
00906 }
00907 
00908 int anope_event_whois(char *source, int ac, char **av)
00909 {
00910     if (source && ac >= 1) {
00911         m_whois(source, av[0]);
00912     }
00913     return MOD_CONT;
00914 }
00915 
00916 /*
00917   :%s TOPIC %s %s %lu :%s
00918         parv[0] = sender prefix
00919         parv[1] = channel
00920         parv[2] = topic nick
00921     parv[3] = topic time
00922     parv[4] = topic text
00923 */
00924 int anope_event_topic(char *source, int ac, char **av)
00925 {
00926     if (ac != 4)
00927         return MOD_CONT;
00928     do_topic(source, ac, av);
00929     return MOD_CONT;
00930 }
00931 
00932 int anope_event_squit(char *source, int ac, char **av)
00933 {
00934     if (ac != 2)
00935         return MOD_CONT;
00936     do_squit(source, ac, av);
00937     return MOD_CONT;
00938 }
00939 
00940 int anope_event_quit(char *source, int ac, char **av)
00941 {
00942     if (ac != 1)
00943         return MOD_CONT;
00944     do_quit(source, ac, av);
00945     return MOD_CONT;
00946 }
00947 
00948 /*
00949   :%s MODE %s :%s
00950         parv[0] = sender
00951         parv[1] = target nick (==sender)
00952         parv[2] = mode change string
00953 */
00954 int anope_event_mode(char *source, int ac, char **av)
00955 {
00956     if (ac < 2)
00957         return MOD_CONT;
00958 
00959     if (*av[0] == '#' || *av[0] == '&') {
00960         do_cmode(source, ac, av);
00961     } else {
00962         do_umode(source, ac, av);
00963     }
00964     return MOD_CONT;
00965 }
00966 
00967 
00968 int anope_event_kill(char *source, int ac, char **av)
00969 {
00970     if (ac != 2)
00971         return MOD_CONT;
00972 
00973     m_kill(av[0], av[1]);
00974     return MOD_CONT;
00975 }
00976 
00977 int anope_event_kick(char *source, int ac, char **av)
00978 {
00979     if (ac != 3)
00980         return MOD_CONT;
00981     do_kick(source, ac, av);
00982     return MOD_CONT;
00983 }
00984 
00985 
00986 int anope_event_join(char *source, int ac, char **av)
00987 {
00988     if (ac != 1)
00989         return MOD_CONT;
00990     do_join(source, ac, av);
00991     return MOD_CONT;
00992 }
00993 
00994 int anope_event_motd(char *source, int ac, char **av)
00995 {
00996     if (!source) {
00997         return MOD_CONT;
00998     }
00999 
01000     m_motd(source);
01001     return MOD_CONT;
01002 }
01003 
01004 void ptlink_cmd_notice_ops(char *source, char *dest, char *buf)
01005 {
01006     if (!buf) {
01007         return;
01008     }
01009 
01010     send_cmd(NULL, "NOTICE @%s :%s", dest, buf);
01011 }
01012 
01013 
01014 void ptlink_cmd_notice(char *source, char *dest, char *buf)
01015 {
01016     if (!buf) {
01017         return;
01018     }
01019 
01020     if (NSDefFlags & NI_MSG) {
01021         ptlink_cmd_privmsg2(source, dest, buf);
01022     } else {
01023         send_cmd(source, "NOTICE %s :%s", dest, buf);
01024     }
01025 }
01026 
01027 void ptlink_cmd_notice2(char *source, char *dest, char *msg)
01028 {
01029     send_cmd(source, "NOTICE %s :%s", dest, msg);
01030 }
01031 
01032 void ptlink_cmd_privmsg(char *source, char *dest, char *buf)
01033 {
01034     if (!buf) {
01035         return;
01036     }
01037 
01038     send_cmd(source, "PRIVMSG %s :%s", dest, buf);
01039 }
01040 
01041 void ptlink_cmd_privmsg2(char *source, char *dest, char *msg)
01042 {
01043     send_cmd(source, "PRIVMSG %s :%s", dest, msg);
01044 }
01045 
01046 void ptlink_cmd_serv_notice(char *source, char *dest, char *msg)
01047 {
01048     send_cmd(source, "NOTICE $%s :%s", dest, msg);
01049 }
01050 
01051 void ptlink_cmd_serv_privmsg(char *source, char *dest, char *msg)
01052 {
01053     send_cmd(source, "PRIVMSG $%s :%s", dest, msg);
01054 }
01055 
01056 /* GLOBOPS */
01057 void ptlink_cmd_global(char *source, char *buf)
01058 {
01059     if (!buf) {
01060         return;
01061     }
01062 
01063     send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf);
01064 }
01065 
01066 /* 391 */
01067 void ptlink_cmd_391(char *source, char *timestr)
01068 {
01069     if (!timestr) {
01070         return;
01071     }
01072     send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr);
01073 }
01074 
01075 /* 250 */
01076 void ptlink_cmd_250(char *buf)
01077 {
01078     if (!buf) {
01079         return;
01080     }
01081 
01082     send_cmd(NULL, "250 %s", buf);
01083 }
01084 
01085 /* 307 */
01086 void ptlink_cmd_307(char *buf)
01087 {
01088     if (!buf) {
01089         return;
01090     }
01091 
01092     send_cmd(ServerName, "307 %s", buf);
01093 }
01094 
01095 /* 311 */
01096 void ptlink_cmd_311(char *buf)
01097 {
01098     if (!buf) {
01099         return;
01100     }
01101 
01102     send_cmd(ServerName, "311 %s", buf);
01103 }
01104 
01105 /* 312 */
01106 void ptlink_cmd_312(char *buf)
01107 {
01108     if (!buf) {
01109         return;
01110     }
01111 
01112     send_cmd(ServerName, "312 %s", buf);
01113 }
01114 
01115 /* 317 */
01116 void ptlink_cmd_317(char *buf)
01117 {
01118     if (!buf) {
01119         return;
01120     }
01121 
01122     send_cmd(ServerName, "317 %s", buf);
01123 }
01124 
01125 /* 219 */
01126 void ptlink_cmd_219(char *source, char *letter)
01127 {
01128     if (!source) {
01129         return;
01130     }
01131 
01132     if (letter) {
01133         send_cmd(NULL, "219 %s %c :End of /STATS report.", source,
01134                  *letter);
01135     } else {
01136         send_cmd(NULL, "219 %s l :End of /STATS report.", source);
01137     }
01138 }
01139 
01140 /* 401 */
01141 void ptlink_cmd_401(char *source, char *who)
01142 {
01143     if (!source || !who) {
01144         return;
01145     }
01146     send_cmd(ServerName, "401 %s %s :No such service.", source, who);
01147 }
01148 
01149 /* 318 */
01150 void ptlink_cmd_318(char *source, char *who)
01151 {
01152     if (!source || !who) {
01153         return;
01154     }
01155 
01156     send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01157 }
01158 
01159 /* 242 */
01160 void ptlink_cmd_242(char *buf)
01161 {
01162     if (!buf) {
01163         return;
01164     }
01165 
01166     send_cmd(NULL, "242 %s", buf);
01167 }
01168 
01169 /* 243 */
01170 void ptlink_cmd_243(char *buf)
01171 {
01172     if (!buf) {
01173         return;
01174     }
01175 
01176     send_cmd(NULL, "243 %s", buf);
01177 }
01178 
01179 /* 211 */
01180 void ptlink_cmd_211(char *buf)
01181 {
01182     if (!buf) {
01183         return;
01184     }
01185 
01186     send_cmd(NULL, "211 %s", buf);
01187 }
01188 
01189 void ptlink_cmd_mode(char *source, char *dest, char *buf)
01190 {
01191     if (!buf) {
01192         return;
01193     }
01194 
01195     send_cmd(source, "MODE %s %s", dest, buf);
01196 }
01197 
01198 /*
01199  NICK %s %d %lu %s %s %s %s %s :%s
01200         parv[1] = nickname
01201         parv[2] = hopcount 
01202         parv[3] = nick TS (nick introduction time)
01203         parv[4] = umodes
01204     parv[5] = username
01205     parv[6] = hostname
01206     parv[7] = spoofed hostname
01207     parv[8] = server
01208     parv[9] = nick info
01209 */
01210 void ptlink_cmd_nick(char *nick, char *name, char *mode)
01211 {
01212     EnforceQlinedNick(nick, NULL);
01213     send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
01214              (unsigned long int) time(NULL), mode, ServiceUser,
01215              ServiceHost, ServiceHost, ServerName, name);
01216     ptlink_cmd_sqline(nick, "Reserved for services");
01217 }
01218 
01219 void ptlink_cmd_kick(char *source, char *chan, char *user, char *buf)
01220 {
01221     if (!buf) {
01222         return;
01223     }
01224 
01225     if (buf) {
01226         send_cmd(source, "KICK %s %s :%s", chan, user, buf);
01227     } else {
01228         send_cmd(source, "KICK %s %s", chan, user);
01229     }
01230 }
01231 
01232 /* QUIT */
01233 void ptlink_cmd_quit(char *source, char *buf)
01234 {
01235     if (buf) {
01236         send_cmd(source, "QUIT :%s", buf);
01237     } else {
01238         send_cmd(source, "QUIT");
01239     }
01240 }
01241 
01242 void ptlink_cmd_part(char *nick, char *chan, char *buf)
01243 {
01244     if (buf) {
01245         send_cmd(nick, "PART %s :%s", chan, buf);
01246     } else {
01247         send_cmd(nick, "PART %s", chan);
01248     }
01249 }
01250 
01251 /*
01252   :%s TOPIC %s %s %lu :%s
01253         parv[0] = sender prefix
01254         parv[1] = channel
01255         parv[2] = topic nick
01256     parv[3] = topic time
01257     parv[4] = topic text
01258 */
01259 void ptlink_cmd_topic(char *whosets, char *chan, char *whosetit,
01260                       char *topic, time_t when)
01261 {
01262     send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit,
01263              (long int) time(NULL), topic);
01264 }
01265 
01266 void ptlink_cmd_vhost_off(User * u)
01267 {
01268     /* does not support vhosting */
01269 }
01270 
01271 void ptlink_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
01272 {
01273     User *u;
01274 
01275     if (vIdent) {
01276         send_cmd(s_HostServ, "NEWMASK %s@%s %s", vIdent, vhost, nick);
01277     } else {
01278         send_cmd(s_HostServ, "NEWMASK %s %s", vhost, nick);
01279     }
01280 
01281     if ((u = finduser(nick)))
01282         u->mode |= UMODE_VH;
01283 }
01284 
01285 /* INVITE */
01286 void ptlink_cmd_invite(char *source, char *chan, char *nick)
01287 {
01288     if (!source || !chan || !nick) {
01289         return;
01290     }
01291 
01292     send_cmd(source, "INVITE %s %s", nick, chan);
01293 }
01294 
01295 void ptlink_cmd_372(char *source, char *msg)
01296 {
01297     send_cmd(ServerName, "372 %s :- %s", source, msg);
01298 }
01299 
01300 void ptlink_cmd_372_error(char *source)
01301 {
01302     send_cmd(ServerName, "422 %s :- MOTD file not found!  Please "
01303              "contact your IRC administrator.", source);
01304 }
01305 
01306 void ptlink_cmd_375(char *source)
01307 {
01308     send_cmd(ServerName, "375 %s :- %s Message of the Day",
01309              source, ServerName);
01310 }
01311 
01312 void ptlink_cmd_376(char *source)
01313 {
01314     send_cmd(ServerName, "376 %s :End of /MOTD command.", source);
01315 }
01316 
01317 
01318 void ptlink_set_umode(User * user, int ac, char **av)
01319 {
01320     int add = 1;                /* 1 if adding modes, 0 if deleting */
01321     char *modes = av[0];
01322 
01323     ac--;
01324 
01325     if (debug)
01326         alog("debug: Changing mode for %s to %s", user->nick, modes);
01327 
01328     while (*modes) {
01329 
01330         /* This looks better, much better than "add ? (do_add) : (do_remove)".
01331          * At least this is readable without paying much attention :) -GD
01332          */
01333         if (add)
01334             user->mode |= umodes[(int) *modes];
01335         else
01336             user->mode &= ~umodes[(int) *modes];
01337 
01338         switch (*modes++) {
01339         case '+':
01340             add = 1;
01341             break;
01342         case '-':
01343             add = 0;
01344             break;
01345         case 'o':
01346             if (add) {
01347                 opcnt++;
01348 
01349                 if (WallOper)
01350                     anope_cmd_global(s_OperServ,
01351                                      "\2%s\2 is now an IRC operator.",
01352                                      user->nick);
01353                 display_news(user, NEWS_OPER);
01354                 if (is_services_admin(user)) {
01355                     common_svsmode(user, "+a", NULL);
01356                     user->mode |= UMODE_a;
01357                 }
01358 
01359             } else {
01360                 opcnt--;
01361             }
01362             break;
01363         case 'r':
01364             if (add && !nick_identified(user)) {
01365                 common_svsmode(user, "-r", NULL);
01366                 user->mode &= ~UMODE_r;
01367             }
01368             break;
01369         }
01370     }
01371 }
01372 
01373 int anope_event_ping(char *source, int ac, char **av)
01374 {
01375     if (ac < 1)
01376         return MOD_CONT;
01377     ptlink_cmd_pong(ac > 1 ? av[1] : ServerName, av[0]);
01378     return MOD_CONT;
01379 }
01380 
01381 int anope_event_away(char *source, int ac, char **av)
01382 {
01383     if (!source) {
01384         return MOD_CONT;
01385     }
01386     m_away(source, (ac ? av[0] : NULL));
01387     return MOD_CONT;
01388 }
01389 
01390 void ptlink_cmd_bot_nick(char *nick, char *user, char *host, char *real,
01391                          char *modes)
01392 {
01393     EnforceQlinedNick(nick, s_BotServ);
01394     send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
01395              (unsigned long int) time(NULL), modes, user, host, host,
01396              ServerName, real);
01397     ptlink_cmd_sqline(nick, "Reserved for services");
01398 
01399 }
01400 
01401 void ptlink_cmd_351(char *source)
01402 {
01403     send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01404              source, version_number, ServerName, ircd->name, version_flags,
01405              EncModule, version_build);
01406 
01407 
01408 }
01409 
01410 /* SVSHOLD - set */
01411 void ptlink_cmd_svshold(char *nick)
01412 {
01413     /* Not supported by this IRCD */
01414 }
01415 
01416 /* SVSHOLD - release */
01417 void ptlink_cmd_release_svshold(char *nick)
01418 {
01419     /* Not Supported by this IRCD */
01420 }
01421 
01422 /*
01423 :%s UNZLINE %s
01424         parv[0] = sender 
01425         parv[1] = zlined host
01426 */
01427 void ptlink_cmd_unszline(char *mask)
01428 {
01429     send_cmd(s_OperServ, "UNZLINE %s", mask);
01430 }
01431 
01432 /*
01433 :%s ZLINE %s :%s
01434         parv[0] = sender 
01435         parv[1] = zlined host
01436         parv[2] = time
01437         parv[3] = reason
01438 */
01439 void ptlink_cmd_szline(char *mask, char *reason, char *whom)
01440 {
01441     send_cmd(s_OperServ, "ZLINE %s %ld :%s", mask,
01442              (long int) time(NULL) + 86400 * 2, reason);
01443 }
01444 
01445 /*  
01446 :%s UNSXLINE %s
01447         parv[0] = sender 
01448         parv[1] = info ban mask
01449 */
01450 void ptlink_cmd_unsgline(char *mask)
01451 {
01452     send_cmd(ServerName, "UNSXLINE :%s", mask);
01453 }
01454 
01455 
01456 /*
01457  * sxline - add info ban line
01458  *
01459  *      parv[0] = sender prefix
01460  *      parv[1] = mask length
01461  *      parv[2] = real name banned mask:reason
01462  */
01463 void ptlink_cmd_sgline(char *mask, char *reason)
01464 {
01465     send_cmd(ServerName, "SXLINE %d :%s:%s", (int) strlen(mask), mask,
01466              reason);
01467 }
01468 
01469 /* SVSNICK */
01470 /*
01471  :%s SVSNICK %s %s
01472         parv[0] = sender (services client)
01473         parv[1] = target client nick
01474         parv[2] = new nick
01475   e.g.: :NickServ SVSNICK Smiler 67455223 _Smiler-
01476 */
01477 void ptlink_cmd_svsnick(char *source, char *guest, time_t when)
01478 {
01479     if (!source || !guest) {
01480         return;
01481     }
01482     send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when);
01483 }
01484 
01485 void ptlink_cmd_guest_nick(char *nick, char *user, char *host, char *real,
01486                            char *modes)
01487 {
01488     send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick,
01489              (unsigned long int) time(NULL), modes, user, host, host,
01490              ServerName, real);
01491 }
01492 
01493 
01494 void ptlink_cmd_unban(char *name, char *nick)
01495 {
01496     /* Not Supported by this IRCD */
01497 }
01498 
01499 /* SVSMODE channel modes */
01500 
01501 void ptlink_cmd_svsmode_chan(char *name, char *mode, char *nick)
01502 {
01503     /* Not Supported by this IRCD */
01504 }
01505 
01506 void ptlink_cmd_svso(char *source, char *nick, char *flag)
01507 {
01508     /* Not Supported by this IRCD */
01509 }
01510 
01511 
01512 /* SVSMODE +d */
01513 /* sent if svid is something weird */
01514 void ptlink_cmd_svid_umode(char *nick, time_t ts)
01515 {
01516     /* Not Supported by this ircd */
01517 }
01518 
01519 /* SVSMODE +d */
01520 /* nc_change was = 1, and there is no na->status */
01521 void ptlink_cmd_nc_change(User * u)
01522 {
01523     /* Not Supported by this ircd */
01524 }
01525 
01526 /* SVSMODE +d */
01527 /* sent if svid is something weird */
01528 void ptlink_cmd_svid_umode2(User * u, char *ts)
01529 {
01530     common_svsmode(u, "+r", NULL);
01531 }
01532 
01533 void ptlink_cmd_svid_umode3(User * u, char *ts)
01534 {
01535     /* Bahamuts have this extra one, since they can check on even nick changes */
01536 }
01537 
01538 /* NICK <newnick>  */
01539 /*
01540  :%s NICK %s %lu
01541         parv[0] = old nick
01542         parv[1] = new nick
01543         parv[2] = TS (timestamp from user's server when nick changed was received)
01544 */
01545 void ptlink_cmd_chg_nick(char *oldnick, char *newnick)
01546 {
01547     if (!oldnick || !newnick) {
01548         return;
01549     }
01550 
01551     send_cmd(oldnick, "NICK %s %ld", newnick, (long int) time(NULL));
01552 }
01553 
01554 /*
01555  :%s SVSJOIN %s :%s
01556         parv[0] = sender (services client)
01557         parv[1] = target client nick
01558         parv[2] = channels list 
01559         :OperServ SVSJOIN Trystan #Admin
01560 */
01561 void ptlink_cmd_svsjoin(char *source, char *nick, char *chan, char *param)
01562 {
01563     send_cmd(source, "SVSJOIN %s %s", nick, chan);
01564 }
01565 
01566 /*
01567   :%s SVSPART %s :%s
01568         parv[0] = sender (services client)
01569         parv[1] = target client nick
01570         parv[2] = channels list 
01571   e.g.: :ChanServ SVSPART mynick 4163321 #Chan1,#Chan2
01572 */
01573 void ptlink_cmd_svspart(char *source, char *nick, char *chan)
01574 {
01575     send_cmd(source, "SVSPART %s :%s", nick, chan);
01576 }
01577 
01578 void ptlink_cmd_swhois(char *source, char *who, char *mask)
01579 {
01580     /* not supported */
01581 }
01582 
01583 int anope_event_notice(char *source, int ac, char **av)
01584 {
01585     return MOD_CONT;
01586 }
01587 
01588 int anope_event_pass(char *source, int ac, char **av)
01589 {
01590     return MOD_CONT;
01591 }
01592 
01593 int anope_event_rehash(char *source, int ac, char **av)
01594 {
01595     return MOD_CONT;
01596 }
01597 
01598 int anope_event_credits(char *source, int ac, char **av)
01599 {
01600     return MOD_CONT;
01601 }
01602 
01603 int anope_event_admin(char *source, int ac, char **av)
01604 {
01605     return MOD_CONT;
01606 }
01607 
01608 int anope_event_invite(char *source, int ac, char **av)
01609 {
01610     return MOD_CONT;
01611 }
01612 
01613 int ptlink_flood_mode_check(char *value)
01614 {
01615     char *dp, *end;
01616 
01617     if (value && *value != ':'
01618         && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0)
01619         && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0)
01620         && (*end == 0)) {
01621         return 1;
01622     } else {
01623         return 0;
01624     }
01625 }
01626 
01627 void ptlink_cmd_eob()
01628 {
01629     /* not supported  */
01630 }
01631 
01632 void ptlink_cmd_jupe(char *jserver, char *who, char *reason)
01633 {
01634     char rbuf[256];
01635 
01636     snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who,
01637              reason ? ": " : "", reason ? reason : "");
01638 
01639     if (findserver(servlist, jserver))
01640         ptlink_cmd_squit(jserver, rbuf);
01641     ptlink_cmd_server(jserver, 1, rbuf);
01642     new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL);
01643 }
01644 
01645 /* GLOBOPS - to handle old WALLOPS */
01646 void ptlink_cmd_global_legacy(char *source, char *fmt)
01647 {
01648     send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt);
01649 }
01650 
01651 /* 
01652   1 = valid nick
01653   0 = nick is in valid
01654 */
01655 int ptlink_valid_nick(char *nick)
01656 {
01657     /* no hard coded invalid nicks */
01658     return 1;
01659 }
01660 
01661 /* 
01662   1 = valid chan
01663   0 = chan is in valid
01664 */
01665 int ptlink_valid_chan(char *cahn)
01666 {
01667     /* no hard coded invalid chan */
01668     return 1;
01669 }
01670 
01671 
01672 void ptlink_cmd_ctcp(char *source, char *dest, char *buf)
01673 {
01674     char *s;
01675 
01676     if (!buf) {
01677         return;
01678     } else {
01679         s = normalizeBuffer(buf);
01680     }
01681 
01682     send_cmd(source, "NOTICE %s :\1%s \1", dest, s);
01683     free(s);
01684 }
01685 
01686 
01691 void moduleAddAnopeCmds()
01692 {
01693     pmodule_cmd_svsnoop(ptlink_cmd_svsnoop);
01694     pmodule_cmd_remove_akill(ptlink_cmd_remove_akill);
01695     pmodule_cmd_topic(ptlink_cmd_topic);
01696     pmodule_cmd_vhost_off(ptlink_cmd_vhost_off);
01697     pmodule_cmd_akill(ptlink_cmd_akill);
01698     pmodule_cmd_svskill(ptlink_cmd_svskill);
01699     pmodule_cmd_svsmode(ptlink_cmd_svsmode);
01700     pmodule_cmd_372(ptlink_cmd_372);
01701     pmodule_cmd_372_error(ptlink_cmd_372_error);
01702     pmodule_cmd_375(ptlink_cmd_375);
01703     pmodule_cmd_376(ptlink_cmd_376);
01704     pmodule_cmd_nick(ptlink_cmd_nick);
01705     pmodule_cmd_guest_nick(ptlink_cmd_guest_nick);
01706     pmodule_cmd_mode(ptlink_cmd_mode);
01707     pmodule_cmd_bot_nick(ptlink_cmd_bot_nick);
01708     pmodule_cmd_kick(ptlink_cmd_kick);
01709     pmodule_cmd_notice_ops(ptlink_cmd_notice_ops);
01710     pmodule_cmd_notice(ptlink_cmd_notice);
01711     pmodule_cmd_notice2(ptlink_cmd_notice2);
01712     pmodule_cmd_privmsg(ptlink_cmd_privmsg);
01713     pmodule_cmd_privmsg2(ptlink_cmd_privmsg2);
01714     pmodule_cmd_serv_notice(ptlink_cmd_serv_notice);
01715     pmodule_cmd_serv_privmsg(ptlink_cmd_serv_privmsg);
01716     pmodule_cmd_bot_chan_mode(ptlink_cmd_bot_chan_mode);
01717     pmodule_cmd_351(ptlink_cmd_351);
01718     pmodule_cmd_quit(ptlink_cmd_quit);
01719     pmodule_cmd_pong(ptlink_cmd_pong);
01720     pmodule_cmd_join(ptlink_cmd_join);
01721     pmodule_cmd_unsqline(ptlink_cmd_unsqline);
01722     pmodule_cmd_invite(ptlink_cmd_invite);
01723     pmodule_cmd_part(ptlink_cmd_part);
01724     pmodule_cmd_391(ptlink_cmd_391);
01725     pmodule_cmd_250(ptlink_cmd_250);
01726     pmodule_cmd_307(ptlink_cmd_307);
01727     pmodule_cmd_311(ptlink_cmd_311);
01728     pmodule_cmd_312(ptlink_cmd_312);
01729     pmodule_cmd_317(ptlink_cmd_317);
01730     pmodule_cmd_219(ptlink_cmd_219);
01731     pmodule_cmd_401(ptlink_cmd_401);
01732     pmodule_cmd_318(ptlink_cmd_318);
01733     pmodule_cmd_242(ptlink_cmd_242);
01734     pmodule_cmd_243(ptlink_cmd_243);
01735     pmodule_cmd_211(ptlink_cmd_211);
01736     pmodule_cmd_global(ptlink_cmd_global);
01737     pmodule_cmd_global_legacy(ptlink_cmd_global_legacy);
01738     pmodule_cmd_sqline(ptlink_cmd_sqline);
01739     pmodule_cmd_squit(ptlink_cmd_squit);
01740     pmodule_cmd_svso(ptlink_cmd_svso);
01741     pmodule_cmd_chg_nick(ptlink_cmd_chg_nick);
01742     pmodule_cmd_svsnick(ptlink_cmd_svsnick);
01743     pmodule_cmd_vhost_on(ptlink_cmd_vhost_on);
01744     pmodule_cmd_connect(ptlink_cmd_connect);
01745     pmodule_cmd_bob(ptlink_cmd_bob);
01746     pmodule_cmd_svshold(ptlink_cmd_svshold);
01747     pmodule_cmd_release_svshold(ptlink_cmd_release_svshold);
01748     pmodule_cmd_unsgline(ptlink_cmd_unsgline);
01749     pmodule_cmd_unszline(ptlink_cmd_unszline);
01750     pmodule_cmd_szline(ptlink_cmd_szline);
01751     pmodule_cmd_sgline(ptlink_cmd_sgline);
01752     pmodule_cmd_unban(ptlink_cmd_unban);
01753     pmodule_cmd_svsmode_chan(ptlink_cmd_svsmode_chan);
01754     pmodule_cmd_svid_umode(ptlink_cmd_svid_umode);
01755     pmodule_cmd_nc_change(ptlink_cmd_nc_change);
01756     pmodule_cmd_svid_umode2(ptlink_cmd_svid_umode2);
01757     pmodule_cmd_svid_umode3(ptlink_cmd_svid_umode3);
01758     pmodule_cmd_svsjoin(ptlink_cmd_svsjoin);
01759     pmodule_cmd_svspart(ptlink_cmd_svspart);
01760     pmodule_cmd_swhois(ptlink_cmd_swhois);
01761     pmodule_cmd_eob(ptlink_cmd_eob);
01762     pmodule_flood_mode_check(ptlink_flood_mode_check);
01763     pmodule_cmd_jupe(ptlink_cmd_jupe);
01764     pmodule_valid_nick(ptlink_valid_nick);
01765     pmodule_valid_chan(ptlink_valid_chan);
01766     pmodule_cmd_ctcp(ptlink_cmd_ctcp);
01767     pmodule_set_umode(ptlink_set_umode);
01768 }
01769 
01773 int AnopeInit(int argc, char **argv)
01774 {
01775 
01776     moduleAddAuthor("Anope");
01777     moduleAddVersion
01778         (VERSION_STRING);
01779     moduleSetType(PROTOCOL);
01780 
01781 
01782     pmodule_ircd_version("PTlink 6.15.*+");
01783     pmodule_ircd_cap(myIrcdcap);
01784     pmodule_ircd_var(myIrcd);
01785     pmodule_ircd_cbmodeinfos(myCbmodeinfos);
01786     pmodule_ircd_cumodes(myCumodes);
01787     pmodule_ircd_flood_mode_char_set("+f");
01788     pmodule_ircd_flood_mode_char_remove("-f");
01789     pmodule_ircd_cbmodes(myCbmodes);
01790     pmodule_ircd_cmmodes(myCmmodes);
01791     pmodule_ircd_csmodes(myCsmodes);
01792     pmodule_ircd_useTSMode(0);
01793 
01795     pmodule_invis_umode(UMODE_i);
01796     pmodule_oper_umode(UMODE_o);
01797     pmodule_invite_cmode(CMODE_i);
01798     pmodule_secret_cmode(CMODE_s);
01799     pmodule_private_cmode(CMODE_p);
01800     pmodule_key_mode(CMODE_k);
01801     pmodule_limit_mode(CMODE_l);
01802     pmodule_permchan_mode(0);
01803 
01804     moduleAddAnopeCmds();
01805     moduleAddIRCDMsgs();
01806 
01807     return MOD_CONT;
01808 }
01809 
01810 /* EOF */