services.h

Go to the documentation of this file.
00001 /*
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 #ifndef SERVICES_H
00015 #define SERVICES_H
00016 
00017 /*************************************************************************/
00018 
00019 #include "sysconf.h"
00020 #include "config.h"
00021 
00022 #ifndef MAX_CMD_HASH
00023 #define MAX_CMD_HASH 1024
00024 #endif
00025 
00026 /* Some Linux boxes (or maybe glibc includes) require this for the
00027  * prototype of strsignal(). */
00028 #ifndef _GNU_SOURCE
00029 #define _GNU_SOURCE
00030 #endif
00031 
00032 /* Some SUN fixs */
00033 #ifdef __sun
00034 /* Solaris specific code, types that do not exist in Solaris'
00035  * sys/types.h
00036  **/
00037 #undef u_int8_t
00038 #undef u_int16_t
00039 #undef u_int32_t
00040 #undef u_int_64_t
00041 #define u_int8_t uint8_t
00042 #define u_int16_t uint16_t
00043 #define u_int32_t uint32_t
00044 #define u_int64_t uint64_t
00045 
00046 #ifndef INADDR_NONE
00047 #define INADDR_NONE (-1)
00048 #endif
00049 
00050 #endif
00051 
00052 
00053 #include <stdarg.h>
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <string.h>
00057 
00058 /* Windows does not have:
00059  * unistd.h, grp.h,
00060  * netdb.h, netinet/in.h,
00061  * sys/socket.h, sys/time.h
00062  * Windows requires:
00063  * winsock.h
00064  * -- codemastr
00065  */
00066 
00067 #ifndef _WIN32
00068 #include <unistd.h>
00069 #endif
00070 
00071 #include <signal.h>
00072 #include <time.h>
00073 #include <errno.h>
00074 
00075 #ifndef _WIN32
00076 #include <grp.h>
00077 #endif
00078 
00079 #include <limits.h>
00080 
00081 #ifndef _WIN32
00082 #include <netdb.h>
00083 #include <netinet/in.h>
00084 #include <arpa/inet.h>
00085 #include <sys/socket.h>
00086 #else
00087 #include <winsock.h>
00088 #include <windows.h>
00089 #endif
00090 #define h_addr h_addr_list[0]   /* for backwards compatability, see man gethostbyname */
00091 
00092 #include <sys/stat.h>   /* for umask() on some systems */
00093 #include <sys/types.h>
00094 
00095 #ifndef _WIN32
00096 #include <sys/time.h>
00097 #endif
00098 
00099 #ifdef _WIN32
00100 #include <sys/timeb.h>
00101 #include <direct.h>
00102 #include <io.h>
00103 #endif
00104 
00105 #include <fcntl.h>
00106 
00107 #ifndef _WIN32
00108 #ifdef HAVE_BACKTRACE
00109 #include <execinfo.h>
00110 #endif
00111 #endif
00112 
00113 #ifndef _WIN32
00114 #include <dirent.h>
00115 #endif
00116 
00117 #ifdef _WIN32
00118 /* VS2008 hates having this define before its own */
00119 #define vsnprintf               _vsnprintf
00120 #endif
00121 
00122 #ifdef USE_RDB
00123 # define MAX_SQL_BUF   4096
00124 #endif
00125 
00126 #ifdef USE_MYSQL
00127 # define MYSQL_WARNING 2
00128 # define MYSQL_ERROR   4
00129 # define MYSQL_DEFAULT_PORT 3306
00130 #ifdef MYSQL_HEADER_PREFIX
00131 # include <mysql/mysql.h>
00132 # include <mysql/errmsg.h>
00133 #else
00134 # include <mysql.h>
00135 # include <errmsg.h>
00136 #endif
00137 #endif
00138 
00139 #if HAVE_STRINGS_H
00140 # include <strings.h>
00141 #endif
00142 
00143 #if HAVE_SYS_SELECT_H
00144 # include <sys/select.h>
00145 #endif
00146 
00147 #include "sockets.h"
00148 
00149 #ifndef va_copy
00150 # ifdef __va_copy
00151 #  define VA_COPY(DEST,SRC) __va_copy((DEST),(SRC))
00152 # else
00153 #  define VA_COPY(DEST, SRC) memcpy ((&DEST), (&SRC), sizeof(va_list))
00154 # endif
00155 #else
00156 # ifdef HAVE_VA_LIST_AS_ARRAY
00157 #   define VA_COPY(DEST,SRC) (*(DEST) = *(SRC))
00158 # else
00159 #   define VA_COPY(DEST, SRC) va_copy(DEST, SRC)
00160 # endif
00161 #endif 
00162 
00163 #ifdef _AIX
00164 /* Some AIX boxes seem to have bogus includes that don't have these
00165  * prototypes. */
00166 extern int strcasecmp(const char *, const char *);
00167 extern int strncasecmp(const char *, const char *, size_t);
00168 # if 0  /* These break on some AIX boxes (4.3.1 reported). */
00169 extern int gettimeofday(struct timeval *, struct timezone *);
00170 extern int socket(int, int, int);
00171 extern int bind(int, struct sockaddr *, int);
00172 extern int connect(int, struct sockaddr *, int);
00173 extern int shutdown(int, int);
00174 # endif
00175 # undef FD_ZERO
00176 # define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
00177 #endif /* _AIX */
00178 
00179 /* Alias stricmp/strnicmp to strcasecmp/strncasecmp if we have the latter
00180  * but not the former. */
00181 #if !HAVE_STRICMP && HAVE_STRCASECMP
00182 # define stricmp strcasecmp
00183 # define strnicmp strncasecmp
00184 #endif
00185 
00186 /* We have our own versions of toupper()/tolower(). */
00187 #include <ctype.h>
00188 #undef tolower
00189 #undef toupper
00190 #define tolower tolower_
00191 #define toupper toupper_
00192 
00193 /* We also have our own encrypt(). */
00194 #define encrypt encrypt_
00195 
00196 
00197 #ifdef __WINS__
00198 #ifndef BKCHECK
00199 #define BKCHECK
00200   extern "C" void __pfnBkCheck() {}
00201 #endif
00202 #endif
00203 
00204 
00205 #if INTTYPE_WORKAROUND
00206 # undef int16
00207 # undef int32
00208 #endif
00209 
00210 
00211 /* Miscellaneous definitions. */
00212 #include "defs.h"
00213 #include "slist.h"
00214 #include "events.h"
00215 
00216 /*************************************************************************/
00217 
00218 typedef struct server_ Server;
00219 typedef struct user_ User;
00220 typedef struct channel_ Channel;
00221 typedef struct c_elist EList;
00222 typedef struct c_elist_entry Entry;
00223 typedef struct ModuleData_ ModuleData;                  /* ModuleData struct */
00224 typedef struct memo_ Memo;
00225 typedef struct nickrequest_ NickRequest;
00226 typedef struct nickalias_ NickAlias;
00227 typedef struct nickcore_ NickCore;
00228 typedef struct botinfo_ BotInfo;
00229 typedef struct chaninfo_ ChannelInfo;
00230 typedef struct badword_ BadWord;
00231 typedef struct bandata_ BanData;
00232 typedef struct userdata_ UserData;
00233 typedef struct mailinfo_ MailInfo;
00234 typedef struct akill_ Akill;
00235 typedef struct sxline_ SXLine;
00236 typedef struct hostcore_ HostCore;
00237 typedef struct newsitem_ NewsItem;
00238 typedef struct exception_ Exception;
00239 typedef struct cbmode_ CBMode;
00240 typedef struct cbmodeinfo_ CBModeInfo;
00241 typedef struct cmmode_ CMMode;
00242 typedef struct csmode_ CSMode;
00243 typedef struct cumode_ CUMode;
00244 typedef struct csmodeutil_ CSModeUtil;
00245 typedef struct session_ Session;
00246 typedef struct uid_ Uid;
00247 
00248 /*************************************************************************/
00249 
00250 /* Windows defines a boolean type as an 
00251  * unsigned char. It does however need
00252  * true/false. -- codemastr
00253  */
00254 #ifndef _WIN32
00255 typedef enum { false, true } boolean;
00256 #else
00257  #ifndef true
00258   #define true 1
00259  #endif
00260  #ifndef false
00261   #define false 0
00262  #endif
00263 #endif /* _WIN32 */
00264 
00265 /*************************************************************************/
00266 
00267 /* Protocol tweaks */
00268 
00269 /* If the IRCd supports TS6 / p10 and it s being used, this selects the uid instead of the nick.. */
00270 #define GET_USER(u) ((ircd->p10 || (UseTS6 && ircd->ts6)) ? (u->uid ? u->uid : u->nick) : u->nick)
00271 #define GET_BOT(bot) ((ircd->p10 || (UseTS6 && ircd->ts6)) ? (find_uid(bot) ? find_uid(bot)->uid : bot) : bot)
00272 
00273 typedef struct ircdvars_ IRCDVar;
00274 typedef struct ircdcapab_ IRCDCAPAB;
00275 
00276 struct ircdvars_ {
00277         char *name;                             /* Name of the ChanServ command */
00278         char *nickservmode;                     /* Mode used by NickServ        */
00279         char *chanservmode;                     /* Mode used by ChanServ        */
00280         char *memoservmode;                     /* Mode used by MemoServ        */
00281         char *hostservmode;                     /* Mode used by HostServ        */
00282         char *operservmode;                     /* Mode used by OperServ        */
00283         char *botservmode;                      /* Mode used by BotServ         */
00284         char *helpservmode;                     /* Mode used by HelpServ        */
00285         char *devnullmode;                      /* Mode used by Dev/Null        */
00286         char *globalmode;                       /* Mode used by Global          */
00287         char *nickservaliasmode;                /* Mode used by NickServ Alias  */
00288         char *chanservaliasmode;                /* Mode used by ChanServ Alias  */
00289         char *memoservaliasmode;                /* Mode used by MemoServ Alias  */
00290         char *hostservaliasmode;                /* Mode used by HostServ Alias  */
00291         char *operservaliasmode;                /* Mode used by OperServ Alias  */
00292         char *botservaliasmode;                 /* Mode used by BotServ  Alias  */
00293         char *helpservaliasmode;                /* Mode used by HelpServ Alias  */
00294         char *devnullvaliasmode;                /* Mode used by Dev/Null Alias  */
00295         char *globalaliasmode;                  /* Mode used by Global   Alias  */
00296         char *botserv_bot_mode;                 /* Mode used by BotServ Bots    */
00297         int max_symbols;                        /* Chan Max Symbols             */
00298         char *modestoremove;                    /* Channel Modes to remove      */
00299         char *botchanumode;                     /* Modes set when botserv joins a channel */
00300         int svsnick;                            /* Supports SVSNICK             */
00301         int vhost;                              /* Supports vhost               */
00302         int owner;                              /* Supports Owner               */
00303         char *ownerset;                         /* Mode to set for owner        */
00304         char *ownerunset;                       /* Mode to unset for a owner    */
00305         char *adminset;                         /* Mode to set for admin        */
00306         char *adminunset;                       /* Mode to unset for admin      */
00307         char *modeonreg;                        /* Mode on Register             */
00308         char *rootmodeonid;                     /* Mode on ID for ROOTS         */
00309         char *adminmodeonid;                    /* Mode on ID for ADMINS        */
00310         char *opermodeonid;                     /* Mode on ID for OPERS         */
00311         char *modeonunreg;                      /* Mode on Unregister           */
00312         char *modeonnick;                       /* Mode on nick change          */
00313         int sgline;                             /* Supports SGline              */
00314         int sqline;                             /* Supports SQline              */
00315         int szline;                             /* Supports SZline              */
00316         int halfop;                             /* Supports HalfOp              */
00317         int numservargs;                        /* Number of Server Args        */
00318         int join2set;                           /* Join 2 Set Modes             */
00319         int join2msg;                           /* Join 2 Message               */
00320         int except;                             /* exception +e                 */
00321         int topictsforward;                     /* TS on Topics Forward         */
00322         int topictsbackward;                    /* TS on Topics Backward        */
00323         uint32 protectedumode;                  /* What is the Protected Umode  */
00324         int admin;                              /* Has Admin                    */
00325         int chansqline;                         /* Supports Channel Sqlines     */
00326         int quitonkill;                         /* IRCD sends QUIT when kill    */
00327         int svsmode_unban;                      /* svsmode can be used to unban
00328                                                  * Note the core no longer uses
00329                                                  * this because it can lead to
00330                                                  * users gaining other users IPs.
00331                                                  * It is kept for API compatability.
00332                                                  */
00333         int protect;                            /* Has protect modes            */
00334         int reversekickcheck;                   /* Can reverse ban check        */
00335         int chanreg;                            /* channel mode +r for register */
00336         uint32 regmode;                         /* Mode to use for +r           */
00337         int vident;                             /* Supports vidents             */
00338         int svshold;                            /* Supports svshold             */
00339         int tsonmode;                           /* Timestamp on mode changes    */
00340         int nickip;                                     /* Sends IP on NICK             */
00341         int omode;                                      /* On the fly o:lines           */
00342         int umode;                                      /* change user modes            */
00343         int nickvhost;                          /* Users vhost sent during NICK */
00344         int chgreal;                            /* Change RealName              */
00345         uint32 noknock;                         /* Channel Mode for no knock    */
00346         uint32 adminmode;                       /* Admin Only Channel Mode      */
00347         uint32 defmlock;                        /* Default mlock modes          */
00348         uint32 vhostmode;                       /* Vhost mode                   */
00349         int fmode;                                      /* +f                           */
00350         int Lmode;                                      /* +L                           */
00351         uint32 chan_fmode;                      /* Mode                         */
00352         uint32 chan_lmode;                      /* Mode                         */
00353         int check_nick_id;                      /* On nick change check if they could be identified */
00354         int knock_needs_i;                      /* Check if we needed +i when setting NOKNOCK */
00355         char *chanmodes;                        /* If the ircd sends CHANMODE in CAPAB this is where we store it */
00356         int token;                                      /* Does Anope support the tokens for the ircd */
00357         int tokencaseless;                      /* TOKEN are not case senstive - most its Unreal that is case senstive */
00358         int sjb64;                                      /* Base 64 encode TIMESTAMP */
00359     int invitemode;                             /* +I  */
00360     int sjoinbanchar;                   /* use single quotes to define it */
00361     int sjoinexchar;                    /* use single quotes to define it */
00362     int sjoininvchar;                   /* use single quotes to define it */
00363         int svsmode_ucmode;                     /* Can remove User Channel Modes with SVSMODE */
00364         int sglineenforce;
00365         char *vhostchar;                        /* char used for vhosting */
00366         int ts6;                                        /* ircd is TS6 */
00367         int supporthelper;                      /* +h helper umodes */
00368         int p10;                                        /* ircd is P10  */
00369         char *nickchars;                        /* character set */
00370         int sync;                                       /* reports sync state */
00371         int cidrchanbei;                        /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15)
00372                                                                 * 0 for no support, 1 for strict cidr support, anything else
00373                                                                 * for ircd specific support (nefarious only cares about first /mask) */
00374         int jmode;                                      /* +j join throttle */
00375         uint32 chan_jmode;                      /* Mode */
00376         int delay_cl_intro;                     /*Delay client introduction till after receiving CAPAB. */
00377 };
00378 
00379 struct ircdcapab_ {
00380   uint32 noquit;
00381   uint32 tsmode;
00382   uint32 unconnect;
00383   uint32 nickip;
00384   uint32 nsjoin;
00385   uint32 zip;
00386   uint32 burst;
00387   uint32 ts5;
00388   uint32 ts3;
00389   uint32 dkey;
00390   uint32 pt4;
00391   uint32 scs;
00392   uint32 qs;
00393   uint32 uid;
00394   uint32 knock;
00395   uint32 client;
00396   uint32 ipv6;
00397   uint32 ssj5;
00398   uint32 sn2;
00399   uint32 token;
00400   uint32 vhost;
00401   uint32 ssj3;
00402   uint32 nick2;
00403   uint32 umode2;
00404   uint32 vl;
00405   uint32 tlkext;
00406   uint32 dodkey;
00407   uint32 dozip;
00408   uint32 chanmodes;
00409   uint32 sjb64;
00410   uint32 nickchars;
00411 };
00412 
00413 /* tiny struct needed for P10 and other UID servers so we can track 
00414    services UID
00415 */
00416 struct uid_ {
00417     Uid *next, *prev;
00418     char nick[NICKMAX];
00419     char *uid;
00420 };
00421 
00422 /*************************************************************************/
00423 /* Config Details */
00424 /*************************************************************************/
00425 
00426 #define MAXPARAMS       8
00427 
00428 /* Configuration directives */
00429 
00430 typedef struct {
00431     char *name;
00432     struct {
00433         int type;               /* PARAM_* below */
00434         int flags;              /* Same */
00435         void *ptr;              /* Pointer to where to store the value */
00436     } params[MAXPARAMS];
00437 } Directive;
00438 
00439 #define PARAM_NONE      0
00440 #define PARAM_INT       1
00441 #define PARAM_POSINT    2       /* Positive integer only */
00442 #define PARAM_PORT      3       /* 1..65535 only */
00443 #define PARAM_STRING    4
00444 #define PARAM_TIME      5
00445 #define PARAM_STRING_ARRAY 6    /* Array of string */
00446 #define PARAM_SET       -1      /* Not a real parameter; just set the
00447                                  *    given integer variable to 1 */
00448 #define PARAM_DEPRECATED -2     /* Set for deprecated directives; `ptr'
00449                                  *    is a function pointer to call */
00450 
00451 /* Flags: */
00452 #define PARAM_OPTIONAL  0x01
00453 #define PARAM_FULLONLY  0x02    /* Directive only allowed if !STREAMLINED */
00454 #define PARAM_RELOAD    0x04    /* Directive is reloadable */
00455 
00456 /*************************************************************************/
00457 
00458 /* File version for each database. Was one version for all before but was
00459    changed so they are now easier to maintain. =) */
00460 
00461 #define BOT_VERSION             10
00462 #define CHAN_VERSION            16
00463 #define EXCEPTION_VERSION       9
00464 #define NEWS_VERSION            9
00465 #define NICK_VERSION            14
00466 #define PRE_NICK_VERSION        2
00467 #define OPER_VERSION            13
00468 #define HELP_VERSION            1
00469 #define HOST_VERSION            3
00470 
00471 /*************************************************************************/
00472 
00473 
00478 struct ModuleData_ {
00479         char *moduleName;                                               /* Which module we belong to */
00480         char *key;                                                              /* The key */
00481         char *value;                                                    /* The Value */
00482         ModuleData *next;                                               /* The next ModuleData record */
00483 };
00484  
00485  /*************************************************************************/
00486 
00487 /* Memo info structures.  Since both nicknames and channels can have memos,
00488  * we encapsulate memo data in a MemoList to make it easier to handle. */
00489 
00490 struct memo_ {
00491     uint32 number;      /* Index number -- not necessarily array position! */
00492     uint16 flags;
00493     time_t time;        /* When it was sent */
00494     char sender[NICKMAX];
00495     char *text;
00496     ModuleData *moduleData;     /* Module saved data attached to the Memo */
00497 #ifdef USE_MYSQL
00498         uint32 id;              /* Database ID; see mysql.c */
00499 #endif
00500 };
00501 
00502 typedef struct {
00503     int16 memocount, memomax;
00504     Memo *memos;
00505 } MemoInfo;
00506 
00507 /*************************************************************************/
00508 
00509 /* NickServ nickname structures. */
00510 
00511 
00512 struct nickrequest_ {
00513         NickRequest *next, *prev;
00514         char *nick;
00515         char *passcode;
00516         char password[PASSMAX];
00517         char *email;
00518         time_t requested;
00519         time_t lastmail;                        /* Unsaved */
00520 };
00521 
00522 struct nickalias_ {
00523         NickAlias *next, *prev;
00524         char *nick;                             /* Nickname */
00525         char *last_quit;                        /* Last quit message */
00526         char *last_realname;                    /* Last realname */
00527         char *last_usermask;                    /* Last usermask */
00528         time_t time_registered;                 /* When the nick was registered */
00529         time_t last_seen;                       /* When it was seen online for the last time */
00530         uint16 status;                          /* See NS_* below */
00531         NickCore *nc;                           /* I'm an alias of this */
00532         /* Not saved */
00533         ModuleData *moduleData;                 /* Module saved data attached to the nick alias */
00534         User *u;                                /* Current online user that has me */
00535 };
00536 
00537 struct nickcore_ {
00538         NickCore *next, *prev;
00539 
00540         char *display;                          /* How the nick is displayed */
00541         char pass[PASSMAX];                             /* Password of the nicks */
00542         char *email;                            /* E-mail associated to the nick */
00543         char *greet;                            /* Greet associated to the nick */
00544         uint32 icq;                             /* ICQ # associated to the nick */
00545         char *url;                              /* URL associated to the nick */
00546         uint32 flags;                           /* See NI_* below */
00547         uint16 language;                        /* Language selected by nickname owner (LANG_*) */
00548         uint16 accesscount;                     /* # of entries */
00549         char **access;                          /* Array of strings */
00550         MemoInfo memos;
00551         uint16 channelcount;                    /* Number of channels currently registered */
00552         uint16 channelmax;                      /* Maximum number of channels allowed */
00553 
00554         /* Unsaved data */
00555         ModuleData *moduleData;         /* Module saved data attached to the NickCore */
00556         time_t lastmail;                        /* Last time this nick record got a mail */
00557         SList aliases;                          /* List of aliases */
00558 };
00559 
00560 
00561 /*************************************************************************/
00562 
00563 /* Bot info structures. Note that since there won't be many bots,
00564  * they're not in a hash list.
00565  *      --lara
00566  */
00567 
00568 struct botinfo_ {
00569         BotInfo *next, *prev;
00570 
00571         char *nick;                     /* Nickname of the bot */
00572         char *user;                     /* Its user name */
00573         char *host;                     /* Its hostname */
00574         char *real;                     /* Its real name */
00575         int16 flags;                    /* Bot flags -- see BI_* below */
00576         time_t created;                 /* Birth date ;) */
00577         int16 chancount;                /* Number of channels that use the bot. */
00578         /* Dynamic data */
00579         time_t lastmsg;                 /* Last time we said something */
00580 };
00581 
00582 
00583 
00584 /* Channel info structures.  Stored similarly to the nicks, except that
00585  * the second character of the channel name, not the first, is used to
00586  * determine the list.  (Hashing based on the first character of the name
00587  * wouldn't get very far. ;) ) */
00588 
00589 /* Access levels for users. */
00590 typedef struct {
00591     uint16 in_use;      /* 1 if this entry is in use, else 0 */
00592     int16 level;
00593     NickCore *nc;       /* Guaranteed to be non-NULL if in use, NULL if not */
00594     time_t last_seen;
00595 } ChanAccess;
00596 
00597 /* Note that these two levels also serve as exclusive boundaries for valid
00598  * access levels.  ACCESS_FOUNDER may be assumed to be strictly greater
00599  * than any valid access level, and ACCESS_INVALID may be assumed to be
00600  * strictly less than any valid access level. Also read below.
00601  */
00602 #define ACCESS_FOUNDER  10000   /* Numeric level indicating founder access */
00603 #define ACCESS_INVALID  -10000  /* Used in levels[] for disabled settings */
00604 /* There is one exception to the above access levels: SuperAdmins will have
00605  * access level 10001. This level is never stored, however; it is only used
00606  * in comparison and to let SuperAdmins win from founders where needed
00607  */
00608 #define ACCESS_SUPERADMIN 10001
00609 
00610 /* Levels for xOP */
00611 
00612 #define ACCESS_VOP              3
00613 #define ACCESS_HOP              4
00614 #define ACCESS_AOP              5
00615 #define ACCESS_SOP              10
00616 
00617 /* AutoKick data. */
00618 typedef struct {
00619     int16 in_use;   /* Always 0 if not in use */
00620     int16 is_nick;      /* 1 if a regged nickname, 0 if a nick!user@host mask */
00621     uint16 flags;
00622     union {
00623                 char *mask;             /* Guaranteed to be non-NULL if in use, NULL if not */
00624                 NickCore *nc;   /* Same */
00625     } u;
00626     char *reason;
00627 
00628     char *creator;
00629     time_t addtime;
00630 } AutoKick;
00631 
00632 #define AK_USED         0x0001
00633 #define AK_ISNICK       0x0002
00634 #define AK_STUCK        0x0004
00635 
00636 /* Structure used to contain bad words. */
00637 
00638 struct badword_ {
00639         uint16 in_use;
00640         char *word;
00641         uint16 type;            /* BW_* below */
00642 };
00643 
00644 #define BW_ANY          0
00645 #define BW_SINGLE       1
00646 #define BW_START        2
00647 #define BW_END          3
00648 
00649 
00650 struct chaninfo_ {
00651     ChannelInfo *next, *prev;
00652     char name[CHANMAX];
00653     NickCore *founder;
00654     NickCore *successor;                /* Who gets the channel if the founder
00655                                                                  * nick is dropped or expires */
00656     char founderpass[PASSMAX];
00657     char *desc;
00658     char *url;
00659     char *email;
00660 
00661     time_t time_registered;
00662     time_t last_used;
00663     char *last_topic;                   /* Last topic on the channel */
00664     char last_topic_setter[NICKMAX];    /* Who set the last topic */
00665     time_t last_topic_time;             /* When the last topic was set */
00666 
00667     uint32 flags;                               /* See below */
00668     char *forbidby;
00669     char *forbidreason;
00670 
00671     int16 bantype;
00672     int16 *levels;                              /* Access levels for commands */
00673 
00674     uint16 accesscount;
00675     ChanAccess *access;                 /* List of authorized users */
00676     uint16 akickcount;
00677     AutoKick *akick;                    /* List of users to kickban */
00678 
00679     uint32 mlock_on, mlock_off;         /* See channel modes below */
00680     uint32 mlock_limit;                 /* 0 if no limit */
00681     char *mlock_key;                    /* NULL if no key */
00682     char *mlock_flood;                  /* NULL if no +f */
00683     char *mlock_redirect;               /* NULL if no +L */
00684     char *mlock_throttle;               /* NULL if no +j */
00685 
00686     char *entry_message;                /* Notice sent on entering channel */
00687 
00688     MemoInfo memos;
00689 
00690     struct channel_ *c;                 /* Pointer to channel record (if   *
00691                                                                  *    channel is currently in use) */
00692                                                                  
00693     ModuleData *moduleData;     /* Module saved data attached to the ChannelInfo */
00694 
00695     /* For BotServ */
00696 
00697     BotInfo *bi;                                        /* Bot used on this channel */
00698     uint32 botflags;                            /* BS_* below */
00699     int16 *ttb;                                         /* Times to ban for each kicker */
00700 
00701     uint16 bwcount;
00702     BadWord *badwords;                          /* For BADWORDS kicker */
00703     int16 capsmin, capspercent;         /* For CAPS kicker */
00704     int16 floodlines, floodsecs;        /* For FLOOD kicker */
00705     int16 repeattimes;                          /* For REPEAT kicker */
00706 };
00707 
00708 /* Retain topic even after last person leaves channel */
00709 #define CI_KEEPTOPIC    0x00000001
00710 /* Don't allow non-authorized users to be opped */
00711 #define CI_SECUREOPS    0x00000002
00712 /* Hide channel from ChanServ LIST command */
00713 #define CI_PRIVATE      0x00000004
00714 /* Topic can only be changed by SET TOPIC */
00715 #define CI_TOPICLOCK    0x00000008
00716 /* Those not allowed ops are kickbanned */
00717 #define CI_RESTRICTED   0x00000010
00718 /* Don't allow ChanServ and BotServ commands to do bad things to bigger levels */
00719 #define CI_PEACE  0x00000020
00720 /* Don't allow any privileges unless a user is IDENTIFY'd with NickServ */
00721 #define CI_SECURE       0x00000040
00722 /* Don't allow the channel to be registered or used */
00723 #define CI_VERBOTEN     0x00000080
00724 /* Channel password is encrypted */
00725 #define CI_ENCRYPTEDPW  0x00000100
00726 /* Channel does not expire */
00727 #define CI_NO_EXPIRE    0x00000200
00728 /* Channel memo limit may not be changed */
00729 #define CI_MEMO_HARDMAX 0x00000400
00730 /* Send notice to channel on use of OP/DEOP */
00731 #define CI_OPNOTICE     0x00000800
00732 /* Stricter control of channel founder status */
00733 #define CI_SECUREFOUNDER 0x00001000
00734 /* Always sign kicks */
00735 #define CI_SIGNKICK 0x00002000
00736 /* Sign kicks if level is < than the one defined by the SIGNKICK level */
00737 #define CI_SIGNKICK_LEVEL 0x00004000
00738 /* Use the xOP lists */
00739 #define CI_XOP 0x00008000
00740 /* Channel is suspended */
00741 #define CI_SUSPENDED 0x00010000
00742 
00743 /* TEMPORARY - ChanServ is on the channel. */
00744 #define CI_INHABIT 0x80000000
00745 
00746 /* Indices for cmd_access[]: */
00747 #define CA_INVITE                       0
00748 #define CA_AKICK                        1
00749 #define CA_SET                          2       /* but not FOUNDER or PASSWORD */
00750 #define CA_UNBAN                        3
00751 #define CA_AUTOOP                       4
00752 #define CA_AUTODEOP                     5       /* Maximum, not minimum */
00753 #define CA_AUTOVOICE                    6
00754 #define CA_OPDEOP                       7       /* ChanServ commands OP and DEOP */
00755 #define CA_ACCESS_LIST                  8
00756 #define CA_CLEAR                        9
00757 #define CA_NOJOIN                       10      /* Maximum */
00758 #define CA_ACCESS_CHANGE                11
00759 #define CA_MEMO                         12
00760 #define CA_ASSIGN                       13  /* BotServ ASSIGN command */
00761 #define CA_BADWORDS                     14  /* BotServ BADWORDS command */
00762 #define CA_NOKICK                       15  /* Not kicked by the bot */
00763 #define CA_FANTASIA                     16
00764 #define CA_SAY                          17
00765 #define CA_GREET                        18
00766 #define CA_VOICEME                      19
00767 #define CA_VOICE                        20
00768 #define CA_GETKEY                       21
00769 #define CA_AUTOHALFOP                   22
00770 #define CA_AUTOPROTECT                  23
00771 #define CA_OPDEOPME                     24
00772 #define CA_HALFOPME                     25
00773 #define CA_HALFOP                       26
00774 #define CA_PROTECTME                    27
00775 #define CA_PROTECT                      28
00776 #define CA_KICKME                       29
00777 #define CA_KICK                         30
00778 #define CA_SIGNKICK                     31
00779 /* #define CA_AUTOADMIN                 32
00780 #define CA_ADMINME                      33
00781 #define CA_ADMIN                        34 */
00782         /* Why are these commented out and not removed? -GD */
00783 #define CA_BANME                        32
00784 #define CA_BAN                          33
00785 #define CA_TOPIC                        34
00786 #define CA_INFO                         35
00787 
00788 #define CA_SIZE         36
00789 
00790 /* BotServ SET flags */
00791 #define BS_DONTKICKOPS          0x00000001
00792 #define BS_DONTKICKVOICES       0x00000002
00793 #define BS_FANTASY              0x00000004
00794 #define BS_SYMBIOSIS            0x00000008
00795 #define BS_GREET                0x00000010
00796 #define BS_NOBOT                0x00000020
00797 
00798 /* BotServ Kickers flags */
00799 #define BS_KICK_BOLDS           0x80000000
00800 #define BS_KICK_COLORS          0x40000000
00801 #define BS_KICK_REVERSES        0x20000000
00802 #define BS_KICK_UNDERLINES      0x10000000
00803 #define BS_KICK_BADWORDS        0x08000000
00804 #define BS_KICK_CAPS            0x04000000
00805 #define BS_KICK_FLOOD           0x02000000
00806 #define BS_KICK_REPEAT          0x01000000
00807 
00808 /* Indices for TTB (Times To Ban) */
00809 #define TTB_BOLDS               0
00810 #define TTB_COLORS              1
00811 #define TTB_REVERSES            2
00812 #define TTB_UNDERLINES          3
00813 #define TTB_BADWORDS            4
00814 #define TTB_CAPS                5
00815 #define TTB_FLOOD               6
00816 #define TTB_REPEAT              7
00817 #define TTB_SIZE                8
00818 
00819 /*************************************************************************/
00820 
00821 /* ChanServ mode utilities commands */
00822 
00823 struct csmodeutil_ {
00824         char *name;                     /* Name of the ChanServ command */
00825         char *bsname;                   /* Name of the BotServ fantasy command */
00826         char *mode;                     /* Mode (ie. +o) */
00827         int32 notice;                   /* Notice flag (for the damn OPNOTICE) */
00828         int level;                      /* Level required to use the command */
00829         int levelself;                  /* Level required to use the command for himself */
00830 };
00831 
00832 typedef struct {
00833     int what;
00834     char *name;
00835     int desc;
00836 } LevelInfo;
00837 
00838 
00839 /*************************************************************************/
00840 
00841 /* Server data */
00842 
00843 typedef enum {
00844         SSYNC_UNKNOWN       = 0,        /* We can't get the sync state   */
00845         SSYNC_IN_PROGRESS   = 1,        /* Sync is currently in progress */
00846         SSYNC_DONE          = 2         /* We're in sync                 */
00847 } SyncState;
00848 
00849 struct server_ {
00850     Server *next, *prev;
00851     
00852     char *name;     /* Server name                        */
00853     uint16 hops;    /* Hops between services and server   */
00854     char *desc;     /* Server description                 */
00855     uint16 flags;   /* Some info flags, as defined below  */
00856     char *suid;     /* Server Univeral ID                 */
00857     SyncState sync; /* Server sync state (see above)      */
00858 
00859     Server *links;      /* Linked list head for linked servers    */
00860     Server *uplink;     /* Server which pretends to be the uplink */
00861 };
00862 
00863 #define SERVER_ISME  0x0001
00864 #define SERVER_JUPED 0x0002
00865 #define SERVER_ISUPLINK 0x0004
00866 
00867 /*************************************************************************/
00868 
00869 /* Online user and channel data. */
00870 struct user_ {
00871     User *next, *prev;
00872 
00873     char nick[NICKMAX];
00874 
00875     char *username;             /* ident                        */
00876     char *host;                 /* User's real hostname         */
00877     char *hostip;               /* User's IP number             */
00878     char *vhost;                /* User's virtual hostname      */
00879     char *chost;                /* User's cloaked hostname      */
00880     char *vident;               /* User's virtual ident         */
00881     char *realname;             /* Realname                     */
00882     Server *server;             /* Server user is connected to  */
00883     char *nickTrack;            /* Nick Tracking                */
00884     time_t timestamp;           /* Timestamp of the nick        */
00885     time_t my_signon;           /* When did _we_ see the user?  */
00886     uint32 svid;                /* Services ID                  */
00887     uint32 mode;                /* See below                    */
00888     char *uid;                  /* Univeral ID                  */
00889 
00890     NickAlias *na;
00891 
00892     ModuleData *moduleData;             /* defined for it, it should allow the module Add/Get */        
00893     
00894     int isSuperAdmin;           /* is SuperAdmin on or off? */
00895 
00896     struct u_chanlist {
00897                 struct u_chanlist *next, *prev;
00898                 Channel *chan;
00899                 int16 status;           /* Associated flags; see CSTATUS_* below. */
00900     } *chans;                           /* Channels user has joined */
00901 
00902     struct u_chaninfolist {
00903                 struct u_chaninfolist *next, *prev;
00904                 ChannelInfo *chan;
00905     } *founder_chans;                   /* Channels user has identified for */
00906 
00907     short invalid_pw_count;             /* # of invalid password attempts */
00908     time_t invalid_pw_time;             /* Time of last invalid password */
00909 
00910     time_t lastmemosend;                /* Last time MS SEND command used */
00911     time_t lastnickreg;                 /* Last time NS REGISTER cmd used */
00912     time_t lastmail;                    /* Last time this user sent a mail */
00913 };
00914 
00915 
00916 
00917 struct cbmode_ {
00918         uint32 flag;                    /* Long value that represents the mode */
00919         uint16 flags;                   /* Flags applying to this mode (CBM_* below) */
00920 
00921         /* Function to associate a value with the mode */
00922         void (*setvalue)        (Channel *chan, char *value);
00923         void (*cssetvalue)      (ChannelInfo *ci, char *value);
00924 };
00925 
00926 #define CBM_MINUS_NO_ARG        0x0001          /* No argument for unset */
00927 #define CBM_NO_MLOCK            0x0002          /* Can't be MLOCKed */
00928 #define CBM_NO_USER_MLOCK       0x0004          /* Can't be MLOCKed by non-opers */
00929 
00930 struct cbmodeinfo_ {
00931         char mode;                              /* The mode */
00932         uint32 flag;                    /* Long value that represents the mode */
00933         uint16 flags;                   /* CBM_* above */
00934 
00935         /* Function to retrieve the value associated to the mode (optional) */
00936         char * (*getvalue)              (Channel *chan);
00937         char * (*csgetvalue)    (ChannelInfo *ci);
00938 };
00939 
00940 struct cmmode_ {
00941         void (*addmask) (Channel *chan, char *mask);
00942         void (*delmask) (Channel *chan, char *mask);
00943 };
00944 
00945 struct cumode_ {
00946         int16 status;                   /* CUS_* below */
00947         int16 flags;                    /* CUF_* below */
00948 
00949         int (*is_valid) (User *user, Channel *chan, int servermode);
00950 };
00951 
00952 /* Channel user mode flags */
00953 
00954 #define CUF_PROTECT_BOTSERV     0x0001
00955 
00956 /* This structure stocks ban data since it must not be removed when
00957  * user is kicked.
00958  */
00959 
00960 struct bandata_ {
00961     BanData *next, *prev;
00962 
00963     char *mask;                         /* Since a nick is unsure and a User structure
00964                                                    is unsafe */
00965     time_t last_use;            /* Since time is the only way to check
00966                                                    whether it's still useful */
00967     int16 ttb[TTB_SIZE];
00968 };
00969 
00970 /* This structure stocks information on every user that will be used by
00971  * BotServ. */
00972 
00973 struct userdata_ {
00974     /* Data validity */
00975     time_t last_use;
00976 
00977     /* for flood kicker */
00978     int16 lines;
00979     time_t last_start;
00980 
00981     /* for repeat kicker */
00982     char *lastline;
00983     int16 times;
00984 };
00985 
00986 /* Channelban type flags */
00987 #define ENTRYTYPE_NONE           0x00000000
00988 #define ENTRYTYPE_CIDR4          0x00000001
00989 #define ENTRYTYPE_NICK_WILD      0x00000004
00990 #define ENTRYTYPE_NICK           0x00000008
00991 #define ENTRYTYPE_USER_WILD      0x00000010
00992 #define ENTRYTYPE_USER           0x00000020
00993 #define ENTRYTYPE_HOST_WILD      0x00000040
00994 #define ENTRYTYPE_HOST           0x00000080
00995 
00996 struct channel_ {
00997     Channel *next, *prev;
00998     char name[CHANMAX];
00999     ChannelInfo *ci;                    /* Corresponding ChannelInfo */
01000     time_t creation_time;               /* When channel was created */
01001     char *topic;
01002     char topic_setter[NICKMAX];         /* Who set the topic */
01003     time_t topic_time;                  /* When topic was set */
01004     uint32 mode;                        /* Binary modes only */
01005     uint32 limit;                       /* 0 if none */
01006     char *key;                          /* NULL if none */
01007     char *redirect;                     /* +L; NULL if none */
01008     char *flood;                        /* +f; NULL if none */
01009     char *throttle;                     /* +j: NULL if none */
01010     EList *bans;
01011     EList *excepts;
01012     EList *invites;
01013     struct c_userlist {
01014                 struct c_userlist *next, *prev;
01015                 User *user;
01016                 UserData *ud;
01017     } *users;
01018     int16 usercount;
01019 
01020     BanData *bd;
01021 
01022     time_t server_modetime;             /* Time of last server MODE */
01023     time_t chanserv_modetime;   /* Time of last check_modes() */
01024     int16 server_modecount;             /* Number of server MODEs this second */
01025     int16 chanserv_modecount;   /* Number of check_mode()'s this sec */
01026     int16 bouncy_modes;                 /* Did we fail to set modes here? */
01027         int16 topic_sync;           /* Is the topic in sync? */
01028 };
01029 
01030 struct c_elist {
01031         Entry *entries;
01032         int32 count;
01033 };
01034 
01035 struct c_elist_entry {
01036     Entry *next, *prev;
01037     uint32 type;
01038     uint32 cidr_ip;             /* IP mask for CIDR matching */
01039     uint32 cidr_mask;           /* Netmask for CIDR matching */
01040     char *nick, *user, *host, *mask;
01041 };
01042 
01043 /*************************************************************************/
01044 
01045 /* Constants for news types. */
01046 
01047 #define NEWS_LOGON              0
01048 #define NEWS_OPER               1
01049 #define NEWS_RANDOM             2
01050 
01051 /*************************************************************************/
01052 
01053 /* Ignorance list data. */
01054 
01055 typedef struct ignore_data {
01056     struct ignore_data *prev, *next;
01057     char *mask;
01058     time_t time;        /* When do we stop ignoring them? */
01059 } IgnoreData;
01060 
01061 /*************************************************************************/
01062 
01063 /* Mail data */
01064 
01065 struct mailinfo_ {
01066         FILE *pipe;
01067         /* Used only with mail forking */
01068         FILE *writepipe;
01069         FILE *readpipe;
01070         User *sender;
01071         NickCore *recipient;
01072         NickRequest *recip;
01073 };
01074 
01075 /*************************************************************************/
01076 
01077 struct akill_ {
01078         char *user;                     /* User part of the AKILL */
01079         char *host;                     /* Host part of the AKILL */
01080 
01081         char *by;                       /* Who set the akill */
01082         char *reason;           /* Why they got akilled */
01083 
01084         time_t seton;           /* When it was set */
01085         time_t expires;         /* When it expires */
01086 };
01087 
01088 /*************************************************************************/
01089 
01090 /* Structure for OperServ SGLINE and SZLINE commands */
01091 
01092 struct sxline_ {
01093         char *mask;
01094         char *by;
01095         char *reason;
01096         time_t seton;
01097         time_t expires;
01098 };
01099 
01100 
01101 /************************************************************************/
01102 
01103 /* Host serv structures */
01104 
01105 struct hostcore_ {
01106     HostCore *next;
01107     char *nick;                         /* Owner of the vHost */
01108     char *vIdent;                       /* vIdent for the user */
01109     char *vHost;                        /* Vhost for this user */
01110     char *creator;                      /* Oper Nick of the oper who set the vhost */
01111     time_t time;                        /* Date/Time vHost was set */
01112 };
01113 
01114 /*************************************************************************/
01115 
01116 struct newsitem_ {
01117     uint16 type;
01118     uint32 num;                  /* Numbering is separate for login and oper news */
01119     char *text;
01120     char who[NICKMAX];
01121     time_t time;
01122 };
01123 
01124 /*************************************************************************/
01125 
01126 
01127 struct exception_ {
01128     char *mask;                 /* Hosts to which this exception applies */
01129     int limit;                  /* Session limit for exception */
01130     char who[NICKMAX];          /* Nick of person who added the exception */
01131     char *reason;               /* Reason for exception's addition */
01132     time_t time;                /* When this exception was added */
01133     time_t expires;             /* Time when it expires. 0 == no expiry */
01134     int num;                    /* Position in exception list; used to track
01135                                  * positions when deleting entries. It is
01136                                  * symbolic and used internally. It is
01137                                  * calculated at load time and never saved. */
01138 };
01139 
01140 /*************************************************************************/
01141 
01142 struct session_ {
01143     Session *prev, *next;
01144     char *host;
01145     int count;                  /* Number of clients with this host */
01146     int hits;                   /* Number of subsequent kills for a host */
01147 };
01148 
01149 /*************************************************************************/
01155 typedef struct ircd_proto_ {
01156     void (*ircd_set_mod_current_buffer)(int ac, char **av);
01157     void (*ircd_cmd_svsnoop)(char *server, int set);
01158     void (*ircd_cmd_remove_akill)(char *user, char *host);
01159     void (*ircd_cmd_topic)(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
01160     void (*ircd_cmd_vhost_off)(User * u);
01161     void (*ircd_cmd_akill)(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
01162     void (*ircd_cmd_svskill)(char *source, char *user, char *buf);
01163     void (*ircd_cmd_svsmode)(User * u, int ac, char **av);
01164     void (*ircd_cmd_372)(char *source, char *msg);
01165     void (*ircd_cmd_372_error)(char *source);
01166     void (*ircd_cmd_375)(char *source);
01167     void (*ircd_cmd_376)(char *source);
01168     void (*ircd_cmd_nick)(char *nick, char *name, char *modes);
01169     void (*ircd_cmd_guest_nick)(char *nick, char *user, char *host, char *real, char *modes);
01170     void (*ircd_cmd_mode)(char *source, char *dest, char *buf);
01171     void (*ircd_cmd_bot_nick)(char *nick, char *user, char *host, char *real, char *modes);
01172     void (*ircd_cmd_kick)(char *source, char *chan, char *user, char *buf);
01173     void (*ircd_cmd_notice_ops)(char *source, char *dest, char *buf);
01174     void (*ircd_cmd_notice)(char *source, char *dest, char *buf);
01175     void (*ircd_cmd_notice2)(char *source, char *dest, char *msg);
01176     void (*ircd_cmd_privmsg)(char *source, char *dest, char *buf);
01177     void (*ircd_cmd_privmsg2)(char *source, char *dest, char *msg);
01178     void (*ircd_cmd_serv_notice)(char *source, char *dest, char *msg);
01179     void (*ircd_cmd_serv_privmsg)(char *source, char *dest, char *msg);
01180     void (*ircd_cmd_bot_chan_mode)(char *nick, char *chan);
01181     void (*ircd_cmd_351)(char *source);
01182     void (*ircd_cmd_quit)(char *source, char *buf);
01183     void (*ircd_cmd_pong)(char *servname, char *who);
01184     void (*ircd_cmd_join)(char *user, char *channel, time_t chantime);
01185     void (*ircd_cmd_unsqline)(char *user);
01186     void (*ircd_cmd_invite)(char *source, char *chan, char *nick);
01187     void (*ircd_cmd_part)(char *nick, char *chan, char *buf);
01188     void (*ircd_cmd_391)(char *source, char *timestr);
01189     void (*ircd_cmd_250)(char *buf);
01190     void (*ircd_cmd_307)(char *buf);
01191     void (*ircd_cmd_311)(char *buf);
01192     void (*ircd_cmd_312)(char *buf);
01193     void (*ircd_cmd_317)(char *buf);
01194     void (*ircd_cmd_219)(char *source, char *letter);
01195     void (*ircd_cmd_401)(char *source, char *who);
01196     void (*ircd_cmd_318)(char *source, char *who);
01197     void (*ircd_cmd_242)(char *buf);
01198     void (*ircd_cmd_243)(char *buf);
01199     void (*ircd_cmd_211)(char *buf);
01200     void (*ircd_cmd_global)(char *source, char *buf);
01201     void (*ircd_cmd_global_legacy)(char *source, char *fmt);
01202     void (*ircd_cmd_sqline)(char *mask, char *reason);
01203     void (*ircd_cmd_squit)(char *servname, char *message);
01204     void (*ircd_cmd_svso)(char *source, char *nick, char *flag);
01205     void (*ircd_cmd_chg_nick)(char *oldnick, char *newnick);
01206     void (*ircd_cmd_svsnick)(char *source, char *guest, time_t when);
01207     void (*ircd_cmd_vhost_on)(char *nick, char *vIdent, char *vhost);
01208     void (*ircd_cmd_connect)(int servernum);
01209     void (*ircd_cmd_bob)();
01210     void (*ircd_cmd_svshold)(char *nick);
01211     void (*ircd_cmd_release_svshold)(char *nick);
01212     void (*ircd_cmd_unsgline)(char *mask);
01213     void (*ircd_cmd_unszline)(char *mask);
01214     void (*ircd_cmd_szline)(char *mask, char *reason, char *whom);
01215     void (*ircd_cmd_sgline)(char *mask, char *reason);
01216     void (*ircd_cmd_unban)(char *name, char *nick);
01217     void (*ircd_cmd_svsmode_chan)(char *name, char *mode, char *nick);
01218     void (*ircd_cmd_svid_umode)(char *nick, time_t ts);
01219     void (*ircd_cmd_nc_change)(User * u);
01220     void (*ircd_cmd_svid_umode2)(User * u, char *ts);
01221     void (*ircd_cmd_svid_umode3)(User * u, char *ts);
01222     void (*ircd_cmd_ctcp)(char *source, char *dest, char *buf);
01223     void (*ircd_cmd_svsjoin)(char *source, char *nick, char *chan, char *param);
01224     void (*ircd_cmd_svspart)(char *source, char *nick, char *chan);
01225     void (*ircd_cmd_swhois)(char *source, char *who, char *mask);
01226     void (*ircd_cmd_eob)();
01227     void (*ircd_cmd_jupe)(char *jserver, char *who, char *reason);
01228     void (*ircd_set_umode)(User *user, int ac, char **av);
01229     int (*ircd_valid_nick)(char *nick);
01230     int (*ircd_valid_chan)(char *chan);
01231     int (*ircd_flood_mode_check)(char *value);
01232     int (*ircd_jointhrottle_mode_check)(char *value);
01233 } IRCDProto;
01234 
01235 typedef struct ircd_modes_ {
01236         int user_invis;
01237         int user_oper;
01238         int chan_invite;
01239         int chan_secret;
01240         int chan_private;
01241         int chan_key;
01242         int chan_limit;
01243         int chan_perm;
01244 } IRCDModes;
01245 
01246 
01247 
01248 /*************************************************************************/
01252 #define DEFCON_NO_NEW_CHANNELS          1       /* No New Channel Registrations */
01253 #define DEFCON_NO_NEW_NICKS             2       /* No New Nick Registrations */
01254 #define DEFCON_NO_MLOCK_CHANGE          4       /* No MLOCK changes */
01255 #define DEFCON_FORCE_CHAN_MODES         8       /* Force Chan Mode */
01256 #define DEFCON_REDUCE_SESSION           16      /* Reduce Session Limit */
01257 #define DEFCON_NO_NEW_CLIENTS           32      /* Kill any NEW clients */
01258 #define DEFCON_OPER_ONLY                64      /* Restrict services to oper's only */
01259 #define DEFCON_SILENT_OPER_ONLY         128     /* Silently ignore non-opers */
01260 #define DEFCON_AKILL_NEW_CLIENTS        256     /* AKILL any new clients */
01261 #define DEFCON_NO_NEW_MEMOS             512     /* No New Memos Sent */
01262 
01263 /*************************************************************************/
01264 
01265 /* Memo Flags */
01266 #define MF_UNREAD       0x0001  /* Memo has not yet been read */
01267 #define MF_RECEIPT      0x0002  /* Sender requested receipt */
01268 #define MF_NOTIFYS      0x0004  /* Memo is a notification of receitp */
01269 
01270 /* Nickname status flags: */
01271 #define NS_VERBOTEN     0x0002      /* Nick may not be registered or used */
01272 #define NS_NO_EXPIRE    0x0004      /* Nick never expires */
01273 #define NS_IDENTIFIED   0x8000      /* User has IDENTIFY'd */
01274 #define NS_RECOGNIZED   0x4000      /* ON_ACCESS true && SECURE flag not set */
01275 #define NS_ON_ACCESS    0x2000      /* User comes from a known address */
01276 #define NS_KILL_HELD    0x1000      /* Nick is being held after a kill */
01277 #define NS_GUESTED      0x0100      /* SVSNICK has been sent but nick has not
01278                                                                  * yet changed. An enforcer will be
01279                                                                  * introduced when it does change. */
01280 #define NS_MASTER       0x0200          /* Was a master nick; used to import old databases */
01281 #define NS_TRANSGROUP   0xC000          /* Status flags that can be passed to a nick of the
01282                                                                            same group during nick change */
01283 #define NS_TEMPORARY    0xFF00      /* All temporary status flags */
01284 /* These two are not used anymore */
01285 #define NS_OLD_ENCRYPTEDPW      0x0001  /* Nickname password is encrypted */
01286 
01287 /* Nickname setting flags: */
01288 #define NI_KILLPROTECT          0x00000001  /* Kill others who take this nick */
01289 #define NI_SECURE               0x00000002  /* Don't recognize unless IDENTIFY'd */
01290 #define NI_MSG                  0x00000004  /* Use PRIVMSGs instead of NOTICEs */
01291 #define NI_MEMO_HARDMAX         0x00000008  /* Don't allow user to change memo limit */
01292 #define NI_MEMO_SIGNON          0x00000010  /* Notify of memos at signon and un-away */
01293 #define NI_MEMO_RECEIVE         0x00000020  /* Notify of new memos when sent */
01294 #define NI_PRIVATE              0x00000040  /* Don't show in LIST to non-servadmins */
01295 #define NI_HIDE_EMAIL           0x00000080  /* Don't show E-mail in INFO */
01296 #define NI_HIDE_MASK            0x00000100  /* Don't show last seen address in INFO */
01297 #define NI_HIDE_QUIT            0x00000200  /* Don't show last quit message in INFO */
01298 #define NI_KILL_QUICK           0x00000400  /* Kill in 20 seconds instead of 60 */
01299 #define NI_KILL_IMMED           0x00000800  /* Kill immediately instead of in 60 sec */
01300 #define NI_SERVICES_OPER        0x00001000  /* User is a Services operator */
01301 #define NI_SERVICES_ADMIN       0x00002000  /* User is a Services admin */
01302 #define NI_ENCRYPTEDPW          0x00004000  /* Nickname password is encrypted */
01303 #define NI_SERVICES_ROOT        0x00008000  /* User is a Services root */
01304 #define NI_MEMO_MAIL            0x00010000  /* User gets email on memo */
01305 #define NI_HIDE_STATUS          0x00020000  /* Don't show services access status */
01306 #define NI_SUSPENDED            0x00040000  /* Nickname is suspended */
01307 #define NI_AUTOOP               0x00080000  /* Autoop nickname in channels */
01308 /* Languages.  Never insert anything in the middle of this list, or
01309  * everybody will start getting the wrong language!  If you want to change
01310  * the order the languages are displayed in for NickServ HELP SET LANGUAGE,
01311  * do it in language.c.
01312  */
01313 #define LANG_EN_US              0       /* United States English */
01314 #define LANG_JA_JIS             1       /* Japanese (JIS encoding) */
01315 #define LANG_JA_EUC             2       /* Japanese (EUC encoding) */
01316 #define LANG_JA_SJIS            3       /* Japanese (SJIS encoding) */
01317 #define LANG_ES                 4       /* Spanish */
01318 #define LANG_PT                 5       /* Portugese */
01319 #define LANG_FR                 6       /* French */
01320 #define LANG_TR                 7       /* Turkish */
01321 #define LANG_IT                 8       /* Italian */
01322 #define LANG_DE                 9       /* German */
01323 #define LANG_CAT               10       /* Catalan */
01324 #define LANG_GR                11       /* Greek */
01325 #define LANG_NL                12       /* Dutch */
01326 #define LANG_RU                13       /* Russian */
01327 #define LANG_HUN               14       /* Hungarian */
01328 #define LANG_PL                15       /* Polish */
01329 #define LANG_JA_UTF8           16       /* Japanese (UTF-8 encoding) */
01330 
01331 #define NUM_LANGS              17       /* Number of languages */
01332 #define USED_LANGS             14       /* Number of languages provided */
01333 
01334 
01335 #define DEF_LANGUAGE    LANG_EN_US
01336 
01337 #define BI_PRIVATE              0x0001
01338 
01339 #define CUS_OP                  0x0001
01340 #define CUS_VOICE               0x0002
01341 #define CUS_HALFOP              0x0004          /* Halfop (+h) */
01342 #define CUS_OWNER               0x0008          /* Owner/Founder (+q) */
01343 #define CUS_PROTECT             0x0010          /* Protected users (+a) */
01344 #define CUS_DEOPPED             0x0080          /* User has been specifically deopped */
01345 
01346 #define MUT_DEOP                0
01347 #define MUT_OP                  1
01348 #define MUT_DEVOICE             2
01349 #define MUT_VOICE               3
01350 #define MUT_DEHALFOP            4
01351 #define MUT_HALFOP              5
01352 #define MUT_DEPROTECT           6
01353 #define MUT_PROTECT             7
01354 
01355 /*************************************************************************/
01356 /* CAPAB stuffs */
01357 
01358 typedef struct capabinfo_ CapabInfo;
01359 struct capabinfo_ {
01360         char *token;
01361         uint32 flag;
01362 };
01363 
01364 #define CAPAB_NOQUIT    0x00000001
01365 #define CAPAB_TSMODE    0x00000002
01366 #define CAPAB_UNCONNECT 0x00000004
01367 #define CAPAB_NICKIP    0x00000008
01368 #define CAPAB_NSJOIN    0x00000010
01369 #define CAPAB_ZIP       0x00000020
01370 #define CAPAB_BURST     0x00000040
01371 #define CAPAB_TS3       0x00000080
01372 #define CAPAB_TS5       0x00000100
01373 #define CAPAB_DKEY      0x00000200
01374 #define CAPAB_DOZIP     0x00000400
01375 #define CAPAB_DODKEY    0x00000800
01376 #define CAPAB_QS        0x00001000
01377 #define CAPAB_SCS       0x00002000
01378 #define CAPAB_PT4       0x00004000
01379 #define CAPAB_UID       0x00008000
01380 #define CAPAB_KNOCK     0x00010000
01381 #define CAPAB_CLIENT    0x00020000
01382 #define CAPAB_IPV6      0x00040000
01383 #define CAPAB_SSJ5      0x00080000
01384 #define CAPAB_SN2       0x00100000
01385 #define CAPAB_VHOST     0x00200000
01386 #define CAPAB_TOKEN     0x00400000
01387 #define CAPAB_SSJ3      0x00800000
01388 #define CAPAB_NICK2     0x01000000
01389 #define CAPAB_UMODE2    0x02000000
01390 #define CAPAB_VL        0x04000000
01391 #define CAPAB_TLKEXT    0x08000000
01392 #define CAPAB_CHANMODE  0x10000000
01393 #define CAPAB_SJB64     0x20000000
01394 #define CAPAB_NICKCHARS 0x40000000
01395 
01396 /*************************************************************************/
01397 
01405 #define isvalidnick(c) ( isalnum(c) || ((c) >='\x5B' && (c) <='\x60') || ((c) >='\x7B' && (c) <='\x7D') || (c)=='-' )
01406 
01407 /*************************************************************************/
01408 
01409 #include "extern.h"
01410 
01411 /*************************************************************************/
01412 
01413 #endif  /* SERVICES_H */