00001
00002
00003
00004
00005
00006
00007
00008
00009
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
00027
00028 #ifndef _GNU_SOURCE
00029 #define _GNU_SOURCE
00030 #endif
00031
00032
00033 #ifdef __sun
00034
00035
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
00059
00060
00061
00062
00063
00064
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]
00091
00092 #include <sys/stat.h>
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
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
00165
00166 extern int strcasecmp(const char *, const char *);
00167 extern int strncasecmp(const char *, const char *, size_t);
00168 # if 0
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
00178
00179
00180
00181 #if !HAVE_STRICMP && HAVE_STRCASECMP
00182 # define stricmp strcasecmp
00183 # define strnicmp strncasecmp
00184 #endif
00185
00186
00187 #include <ctype.h>
00188 #undef tolower
00189 #undef toupper
00190 #define tolower tolower_
00191 #define toupper toupper_
00192
00193
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
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;
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
00251
00252
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
00264
00265
00266
00267
00268
00269
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;
00278 char *nickservmode;
00279 char *chanservmode;
00280 char *memoservmode;
00281 char *hostservmode;
00282 char *operservmode;
00283 char *botservmode;
00284 char *helpservmode;
00285 char *devnullmode;
00286 char *globalmode;
00287 char *nickservaliasmode;
00288 char *chanservaliasmode;
00289 char *memoservaliasmode;
00290 char *hostservaliasmode;
00291 char *operservaliasmode;
00292 char *botservaliasmode;
00293 char *helpservaliasmode;
00294 char *devnullvaliasmode;
00295 char *globalaliasmode;
00296 char *botserv_bot_mode;
00297 int max_symbols;
00298 char *modestoremove;
00299 char *botchanumode;
00300 int svsnick;
00301 int vhost;
00302 int owner;
00303 char *ownerset;
00304 char *ownerunset;
00305 char *adminset;
00306 char *adminunset;
00307 char *modeonreg;
00308 char *rootmodeonid;
00309 char *adminmodeonid;
00310 char *opermodeonid;
00311 char *modeonunreg;
00312 char *modeonnick;
00313 int sgline;
00314 int sqline;
00315 int szline;
00316 int halfop;
00317 int numservargs;
00318 int join2set;
00319 int join2msg;
00320 int except;
00321 int topictsforward;
00322 int topictsbackward;
00323 uint32 protectedumode;
00324 int admin;
00325 int chansqline;
00326 int quitonkill;
00327 int svsmode_unban;
00328
00329
00330
00331
00332
00333 int protect;
00334 int reversekickcheck;
00335 int chanreg;
00336 uint32 regmode;
00337 int vident;
00338 int svshold;
00339 int tsonmode;
00340 int nickip;
00341 int omode;
00342 int umode;
00343 int nickvhost;
00344 int chgreal;
00345 uint32 noknock;
00346 uint32 adminmode;
00347 uint32 defmlock;
00348 uint32 vhostmode;
00349 int fmode;
00350 int Lmode;
00351 uint32 chan_fmode;
00352 uint32 chan_lmode;
00353 int check_nick_id;
00354 int knock_needs_i;
00355 char *chanmodes;
00356 int token;
00357 int tokencaseless;
00358 int sjb64;
00359 int invitemode;
00360 int sjoinbanchar;
00361 int sjoinexchar;
00362 int sjoininvchar;
00363 int svsmode_ucmode;
00364 int sglineenforce;
00365 char *vhostchar;
00366 int ts6;
00367 int supporthelper;
00368 int p10;
00369 char *nickchars;
00370 int sync;
00371 int cidrchanbei;
00372
00373
00374 int jmode;
00375 uint32 chan_jmode;
00376 int delay_cl_intro;
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
00414
00415
00416 struct uid_ {
00417 Uid *next, *prev;
00418 char nick[NICKMAX];
00419 char *uid;
00420 };
00421
00422
00423
00424
00425
00426 #define MAXPARAMS 8
00427
00428
00429
00430 typedef struct {
00431 char *name;
00432 struct {
00433 int type;
00434 int flags;
00435 void *ptr;
00436 } params[MAXPARAMS];
00437 } Directive;
00438
00439 #define PARAM_NONE 0
00440 #define PARAM_INT 1
00441 #define PARAM_POSINT 2
00442 #define PARAM_PORT 3
00443 #define PARAM_STRING 4
00444 #define PARAM_TIME 5
00445 #define PARAM_STRING_ARRAY 6
00446 #define PARAM_SET -1
00447
00448 #define PARAM_DEPRECATED -2
00449
00450
00451
00452 #define PARAM_OPTIONAL 0x01
00453 #define PARAM_FULLONLY 0x02
00454 #define PARAM_RELOAD 0x04
00455
00456
00457
00458
00459
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;
00480 char *key;
00481 char *value;
00482 ModuleData *next;
00483 };
00484
00485
00486
00487
00488
00489
00490 struct memo_ {
00491 uint32 number;
00492 uint16 flags;
00493 time_t time;
00494 char sender[NICKMAX];
00495 char *text;
00496 ModuleData *moduleData;
00497 #ifdef USE_MYSQL
00498 uint32 id;
00499 #endif
00500 };
00501
00502 typedef struct {
00503 int16 memocount, memomax;
00504 Memo *memos;
00505 } MemoInfo;
00506
00507
00508
00509
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;
00520 };
00521
00522 struct nickalias_ {
00523 NickAlias *next, *prev;
00524 char *nick;
00525 char *last_quit;
00526 char *last_realname;
00527 char *last_usermask;
00528 time_t time_registered;
00529 time_t last_seen;
00530 uint16 status;
00531 NickCore *nc;
00532
00533 ModuleData *moduleData;
00534 User *u;
00535 };
00536
00537 struct nickcore_ {
00538 NickCore *next, *prev;
00539
00540 char *display;
00541 char pass[PASSMAX];
00542 char *email;
00543 char *greet;
00544 uint32 icq;
00545 char *url;
00546 uint32 flags;
00547 uint16 language;
00548 uint16 accesscount;
00549 char **access;
00550 MemoInfo memos;
00551 uint16 channelcount;
00552 uint16 channelmax;
00553
00554
00555 ModuleData *moduleData;
00556 time_t lastmail;
00557 SList aliases;
00558 };
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 struct botinfo_ {
00569 BotInfo *next, *prev;
00570
00571 char *nick;
00572 char *user;
00573 char *host;
00574 char *real;
00575 int16 flags;
00576 time_t created;
00577 int16 chancount;
00578
00579 time_t lastmsg;
00580 };
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590 typedef struct {
00591 uint16 in_use;
00592 int16 level;
00593 NickCore *nc;
00594 time_t last_seen;
00595 } ChanAccess;
00596
00597
00598
00599
00600
00601
00602 #define ACCESS_FOUNDER 10000
00603 #define ACCESS_INVALID -10000
00604
00605
00606
00607
00608 #define ACCESS_SUPERADMIN 10001
00609
00610
00611
00612 #define ACCESS_VOP 3
00613 #define ACCESS_HOP 4
00614 #define ACCESS_AOP 5
00615 #define ACCESS_SOP 10
00616
00617
00618 typedef struct {
00619 int16 in_use;
00620 int16 is_nick;
00621 uint16 flags;
00622 union {
00623 char *mask;
00624 NickCore *nc;
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
00637
00638 struct badword_ {
00639 uint16 in_use;
00640 char *word;
00641 uint16 type;
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;
00655
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;
00664 char last_topic_setter[NICKMAX];
00665 time_t last_topic_time;
00666
00667 uint32 flags;
00668 char *forbidby;
00669 char *forbidreason;
00670
00671 int16 bantype;
00672 int16 *levels;
00673
00674 uint16 accesscount;
00675 ChanAccess *access;
00676 uint16 akickcount;
00677 AutoKick *akick;
00678
00679 uint32 mlock_on, mlock_off;
00680 uint32 mlock_limit;
00681 char *mlock_key;
00682 char *mlock_flood;
00683 char *mlock_redirect;
00684 char *mlock_throttle;
00685
00686 char *entry_message;
00687
00688 MemoInfo memos;
00689
00690 struct channel_ *c;
00691
00692
00693 ModuleData *moduleData;
00694
00695
00696
00697 BotInfo *bi;
00698 uint32 botflags;
00699 int16 *ttb;
00700
00701 uint16 bwcount;
00702 BadWord *badwords;
00703 int16 capsmin, capspercent;
00704 int16 floodlines, floodsecs;
00705 int16 repeattimes;
00706 };
00707
00708
00709 #define CI_KEEPTOPIC 0x00000001
00710
00711 #define CI_SECUREOPS 0x00000002
00712
00713 #define CI_PRIVATE 0x00000004
00714
00715 #define CI_TOPICLOCK 0x00000008
00716
00717 #define CI_RESTRICTED 0x00000010
00718
00719 #define CI_PEACE 0x00000020
00720
00721 #define CI_SECURE 0x00000040
00722
00723 #define CI_VERBOTEN 0x00000080
00724
00725 #define CI_ENCRYPTEDPW 0x00000100
00726
00727 #define CI_NO_EXPIRE 0x00000200
00728
00729 #define CI_MEMO_HARDMAX 0x00000400
00730
00731 #define CI_OPNOTICE 0x00000800
00732
00733 #define CI_SECUREFOUNDER 0x00001000
00734
00735 #define CI_SIGNKICK 0x00002000
00736
00737 #define CI_SIGNKICK_LEVEL 0x00004000
00738
00739 #define CI_XOP 0x00008000
00740
00741 #define CI_SUSPENDED 0x00010000
00742
00743
00744 #define CI_INHABIT 0x80000000
00745
00746
00747 #define CA_INVITE 0
00748 #define CA_AKICK 1
00749 #define CA_SET 2
00750 #define CA_UNBAN 3
00751 #define CA_AUTOOP 4
00752 #define CA_AUTODEOP 5
00753 #define CA_AUTOVOICE 6
00754 #define CA_OPDEOP 7
00755 #define CA_ACCESS_LIST 8
00756 #define CA_CLEAR 9
00757 #define CA_NOJOIN 10
00758 #define CA_ACCESS_CHANGE 11
00759 #define CA_MEMO 12
00760 #define CA_ASSIGN 13
00761 #define CA_BADWORDS 14
00762 #define CA_NOKICK 15
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
00780
00781
00782
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
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
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
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
00822
00823 struct csmodeutil_ {
00824 char *name;
00825 char *bsname;
00826 char *mode;
00827 int32 notice;
00828 int level;
00829 int levelself;
00830 };
00831
00832 typedef struct {
00833 int what;
00834 char *name;
00835 int desc;
00836 } LevelInfo;
00837
00838
00839
00840
00841
00842
00843 typedef enum {
00844 SSYNC_UNKNOWN = 0,
00845 SSYNC_IN_PROGRESS = 1,
00846 SSYNC_DONE = 2
00847 } SyncState;
00848
00849 struct server_ {
00850 Server *next, *prev;
00851
00852 char *name;
00853 uint16 hops;
00854 char *desc;
00855 uint16 flags;
00856 char *suid;
00857 SyncState sync;
00858
00859 Server *links;
00860 Server *uplink;
00861 };
00862
00863 #define SERVER_ISME 0x0001
00864 #define SERVER_JUPED 0x0002
00865 #define SERVER_ISUPLINK 0x0004
00866
00867
00868
00869
00870 struct user_ {
00871 User *next, *prev;
00872
00873 char nick[NICKMAX];
00874
00875 char *username;
00876 char *host;
00877 char *hostip;
00878 char *vhost;
00879 char *chost;
00880 char *vident;
00881 char *realname;
00882 Server *server;
00883 char *nickTrack;
00884 time_t timestamp;
00885 time_t my_signon;
00886 uint32 svid;
00887 uint32 mode;
00888 char *uid;
00889
00890 NickAlias *na;
00891
00892 ModuleData *moduleData;
00893
00894 int isSuperAdmin;
00895
00896 struct u_chanlist {
00897 struct u_chanlist *next, *prev;
00898 Channel *chan;
00899 int16 status;
00900 } *chans;
00901
00902 struct u_chaninfolist {
00903 struct u_chaninfolist *next, *prev;
00904 ChannelInfo *chan;
00905 } *founder_chans;
00906
00907 short invalid_pw_count;
00908 time_t invalid_pw_time;
00909
00910 time_t lastmemosend;
00911 time_t lastnickreg;
00912 time_t lastmail;
00913 };
00914
00915
00916
00917 struct cbmode_ {
00918 uint32 flag;
00919 uint16 flags;
00920
00921
00922 void (*setvalue) (Channel *chan, char *value);
00923 void (*cssetvalue) (ChannelInfo *ci, char *value);
00924 };
00925
00926 #define CBM_MINUS_NO_ARG 0x0001
00927 #define CBM_NO_MLOCK 0x0002
00928 #define CBM_NO_USER_MLOCK 0x0004
00929
00930 struct cbmodeinfo_ {
00931 char mode;
00932 uint32 flag;
00933 uint16 flags;
00934
00935
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;
00947 int16 flags;
00948
00949 int (*is_valid) (User *user, Channel *chan, int servermode);
00950 };
00951
00952
00953
00954 #define CUF_PROTECT_BOTSERV 0x0001
00955
00956
00957
00958
00959
00960 struct bandata_ {
00961 BanData *next, *prev;
00962
00963 char *mask;
00964
00965 time_t last_use;
00966
00967 int16 ttb[TTB_SIZE];
00968 };
00969
00970
00971
00972
00973 struct userdata_ {
00974
00975 time_t last_use;
00976
00977
00978 int16 lines;
00979 time_t last_start;
00980
00981
00982 char *lastline;
00983 int16 times;
00984 };
00985
00986
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;
01000 time_t creation_time;
01001 char *topic;
01002 char topic_setter[NICKMAX];
01003 time_t topic_time;
01004 uint32 mode;
01005 uint32 limit;
01006 char *key;
01007 char *redirect;
01008 char *flood;
01009 char *throttle;
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;
01023 time_t chanserv_modetime;
01024 int16 server_modecount;
01025 int16 chanserv_modecount;
01026 int16 bouncy_modes;
01027 int16 topic_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;
01039 uint32 cidr_mask;
01040 char *nick, *user, *host, *mask;
01041 };
01042
01043
01044
01045
01046
01047 #define NEWS_LOGON 0
01048 #define NEWS_OPER 1
01049 #define NEWS_RANDOM 2
01050
01051
01052
01053
01054
01055 typedef struct ignore_data {
01056 struct ignore_data *prev, *next;
01057 char *mask;
01058 time_t time;
01059 } IgnoreData;
01060
01061
01062
01063
01064
01065 struct mailinfo_ {
01066 FILE *pipe;
01067
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;
01079 char *host;
01080
01081 char *by;
01082 char *reason;
01083
01084 time_t seton;
01085 time_t expires;
01086 };
01087
01088
01089
01090
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
01104
01105 struct hostcore_ {
01106 HostCore *next;
01107 char *nick;
01108 char *vIdent;
01109 char *vHost;
01110 char *creator;
01111 time_t time;
01112 };
01113
01114
01115
01116 struct newsitem_ {
01117 uint16 type;
01118 uint32 num;
01119 char *text;
01120 char who[NICKMAX];
01121 time_t time;
01122 };
01123
01124
01125
01126
01127 struct exception_ {
01128 char *mask;
01129 int limit;
01130 char who[NICKMAX];
01131 char *reason;
01132 time_t time;
01133 time_t expires;
01134 int num;
01135
01136
01137
01138 };
01139
01140
01141
01142 struct session_ {
01143 Session *prev, *next;
01144 char *host;
01145 int count;
01146 int hits;
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
01253 #define DEFCON_NO_NEW_NICKS 2
01254 #define DEFCON_NO_MLOCK_CHANGE 4
01255 #define DEFCON_FORCE_CHAN_MODES 8
01256 #define DEFCON_REDUCE_SESSION 16
01257 #define DEFCON_NO_NEW_CLIENTS 32
01258 #define DEFCON_OPER_ONLY 64
01259 #define DEFCON_SILENT_OPER_ONLY 128
01260 #define DEFCON_AKILL_NEW_CLIENTS 256
01261 #define DEFCON_NO_NEW_MEMOS 512
01262
01263
01264
01265
01266 #define MF_UNREAD 0x0001
01267 #define MF_RECEIPT 0x0002
01268 #define MF_NOTIFYS 0x0004
01269
01270
01271 #define NS_VERBOTEN 0x0002
01272 #define NS_NO_EXPIRE 0x0004
01273 #define NS_IDENTIFIED 0x8000
01274 #define NS_RECOGNIZED 0x4000
01275 #define NS_ON_ACCESS 0x2000
01276 #define NS_KILL_HELD 0x1000
01277 #define NS_GUESTED 0x0100
01278
01279
01280 #define NS_MASTER 0x0200
01281 #define NS_TRANSGROUP 0xC000
01282
01283 #define NS_TEMPORARY 0xFF00
01284
01285 #define NS_OLD_ENCRYPTEDPW 0x0001
01286
01287
01288 #define NI_KILLPROTECT 0x00000001
01289 #define NI_SECURE 0x00000002
01290 #define NI_MSG 0x00000004
01291 #define NI_MEMO_HARDMAX 0x00000008
01292 #define NI_MEMO_SIGNON 0x00000010
01293 #define NI_MEMO_RECEIVE 0x00000020
01294 #define NI_PRIVATE 0x00000040
01295 #define NI_HIDE_EMAIL 0x00000080
01296 #define NI_HIDE_MASK 0x00000100
01297 #define NI_HIDE_QUIT 0x00000200
01298 #define NI_KILL_QUICK 0x00000400
01299 #define NI_KILL_IMMED 0x00000800
01300 #define NI_SERVICES_OPER 0x00001000
01301 #define NI_SERVICES_ADMIN 0x00002000
01302 #define NI_ENCRYPTEDPW 0x00004000
01303 #define NI_SERVICES_ROOT 0x00008000
01304 #define NI_MEMO_MAIL 0x00010000
01305 #define NI_HIDE_STATUS 0x00020000
01306 #define NI_SUSPENDED 0x00040000
01307 #define NI_AUTOOP 0x00080000
01308
01309
01310
01311
01312
01313 #define LANG_EN_US 0
01314 #define LANG_JA_JIS 1
01315 #define LANG_JA_EUC 2
01316 #define LANG_JA_SJIS 3
01317 #define LANG_ES 4
01318 #define LANG_PT 5
01319 #define LANG_FR 6
01320 #define LANG_TR 7
01321 #define LANG_IT 8
01322 #define LANG_DE 9
01323 #define LANG_CAT 10
01324 #define LANG_GR 11
01325 #define LANG_NL 12
01326 #define LANG_RU 13
01327 #define LANG_HUN 14
01328 #define LANG_PL 15
01329 #define LANG_JA_UTF8 16
01330
01331 #define NUM_LANGS 17
01332 #define USED_LANGS 14
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
01342 #define CUS_OWNER 0x0008
01343 #define CUS_PROTECT 0x0010
01344 #define CUS_DEOPPED 0x0080
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
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