00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _EGG_EGGDROP_H
00029 #define _EGG_EGGDROP_H
00030
00031
00032
00033
00034
00035 #undef NO_OLD_BOTNET
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #define HANDLEN 9
00053 #define NICKMAX 32
00054
00055
00056
00057 #define UHOSTMAX 291 + NICKMAX
00058 #define DIRMAX 512
00059 #define LOGLINEMAX 767
00060
00061
00062 #define BADNICKCHARS "-,+*=:!.@#;$%&"
00063 #define BADHANDCHARS "-,+*=:!.@#;$%&"
00064
00065
00066
00067 #define LANGDIR "./language"
00068 #define BASELANG "english"
00069
00070
00071
00072
00073
00074
00075
00076 #define NICKLEN NICKMAX + 1
00077 #define UHOSTLEN UHOSTMAX + 1
00078 #define DIRLEN DIRMAX + 1
00079 #define LOGLINELEN LOGLINEMAX + 1
00080 #define NOTENAMELEN ((HANDLEN * 2) + 1)
00081
00082
00083
00084
00085 #ifndef STDC_HEADERS
00086 # include "Error: Your system must have standard ANSI C headers."
00087 #endif
00088
00089 #ifndef HAVE_VPRINTF
00090 # include "Error: You need vsprintf to compile eggdrop."
00091 #endif
00092
00093 #ifdef HAVE_UNISTD_H
00094 # include <unistd.h>
00095 #endif
00096
00097
00098 #ifndef STATIC
00099 # if !defined(MODULES_OK) || (!defined(MOD_USE_DL) && !defined(MOD_USE_SHL) && !defined(MOD_USE_DYLD) && !defined(MOD_USE_RLD) && !defined(MOD_USE_LOADER))
00100 # include "Error: You can't compile with module support on this system (try make static)."
00101 # else
00102 # ifdef MOD_USE_DL
00103 # ifndef HAVE_DLOPEN
00104 # include "Error: We have detected that dlopen() should be used to load modules on this OS; but it was not found. Please use 'make static'."
00105 # endif
00106 # undef MOD_USE_SHL
00107 # undef MOD_USE_DYLD
00108 # undef MOD_USE_RLD
00109 # undef MOD_USE_LOADER
00110 # endif
00111 # ifdef MOD_USE_SHL
00112 # ifndef HAVE_SHL_LOAD
00113 # include "Error: We have detected that shl_load() should be used to load modules on this OS; but it was not found. Please use 'make static'."
00114 # endif
00115 # undef MOD_USE_DL
00116 # undef MOD_USE_DYLD
00117 # undef MOD_USE_RLD
00118 # undef MOD_USE_LOADER
00119 # endif
00120 # ifdef MOD_USE_DYLD
00121 # ifndef HAVE_NSLINKMODULE
00122 # include "Error: We have detected that NSLinkModule() should be used to load modules on this OS; but it was not found. Please use 'make static'."
00123 # endif
00124 # undef MOD_USE_DL
00125 # undef MOD_USE_SHL
00126 # undef MOD_USE_RLD
00127 # undef MOD_USE_LOADER
00128 # endif
00129 # ifdef MOD_USE_RLD
00130 # ifndef HAVE_RLD_LOAD
00131 # include "Error: We have detected that rld_load() should be used to load modules on this OS; but it was not found. Please use 'make static'."
00132 # endif
00133 # undef MOD_USE_DL
00134 # undef MOD_USE_SHL
00135 # undef MOD_USE_DYLD
00136 # undef MOD_USE_LOADER
00137 # endif
00138 # ifdef MOD_USE_LOADER
00139 # ifndef HAVE_LOAD
00140 # include "Error: We have detected that load() should be used to load modules on this OS; but it was not found. Please use 'make static'."
00141 # endif
00142 # undef MOD_USE_DL
00143 # undef MOD_USE_SHL
00144 # undef MOD_USE_DYLD
00145 # undef MOD_USE_RLD
00146 # endif
00147 # endif
00148 #endif
00149
00150 #ifdef EGG_HANDLEN
00151 # undef HANDLEN
00152 # define HANDLEN EGG_HANDLEN
00153 #endif
00154
00155 #if (NICKMAX < 9) || (NICKMAX > 32)
00156 # include "Error: Invalid NICKMAX value."
00157 #endif
00158
00159 #if (HANDLEN < 9) || (HANDLEN > 32)
00160 # include "Error: Invalid HANDLEN value."
00161 #endif
00162
00163 #if HANDLEN > NICKMAX
00164 # include "Error: HANDLEN must be <= NICKMAX."
00165 #endif
00166
00167 #ifdef HAVE_SYS_PARAM_H
00168 # include <sys/param.h>
00169 #endif
00170
00171
00172
00173
00174 #ifndef NAME_MAX
00175 # ifdef MAXNAMLEN
00176 # define NAME_MAX MAXNAMLEN
00177 # else
00178 # define NAME_MAX 255
00179 # endif
00180 #endif
00181
00182
00183 #ifdef TIME_WITH_SYS_TIME
00184 # include <sys/time.h>
00185 # include <time.h>
00186 #else
00187 # ifdef HAVE_SYS_TIME_H
00188 # include <sys/time.h>
00189 # else
00190 # include <time.h>
00191 # endif
00192 #endif
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 #if defined QNX_HACKS && defined MAKING_MODS
00203 # undef HAVE_RANDOM
00204 # undef HAVE_SRANDOM
00205 #endif
00206
00207 #ifdef HAVE_RANDOM
00208
00209
00210
00211
00212
00213
00214 # ifndef RANDOM_MAX
00215 # define RANDOM_MAX 0x7FFFFFFF
00216 # endif
00217 #else
00218
00219 # ifdef RANDOM_MAX
00220 # undef RANDOM_MAX
00221 # endif
00222
00223
00224
00225 # ifdef HAVE_RAND
00226 # define random() rand()
00227 # define srandom(x) srand(x)
00228
00229
00230
00231
00232
00233
00234 # define RANDOM_MAX RAND_MAX
00235 # else
00236 # ifdef HAVE_LRAND48
00237 # define random() lrand48()
00238 # define srandom(x) srand48(x)
00239
00240
00241
00242
00243
00244 # define RANDOM_MAX 0x7FFFFFFF
00245 # else
00246 # include "Error: Must define one of HAVE_RANDOM, HAVE_RAND, or HAVE_LRAND48"
00247 # endif
00248 # endif
00249 #endif
00250
00251
00252
00253
00254
00255
00256
00257 #define randint(n) (unsigned long) (random() / (RANDOM_MAX + 1.0) * n)
00258
00259
00260 #ifndef HAVE_SIGACTION
00261 # define sigaction sigvec
00262 # ifndef sa_handler
00263 # define sa_handler sv_handler
00264 # define sa_mask sv_mask
00265 # define sa_flags sv_flags
00266 # endif
00267 #endif
00268
00269 #ifndef HAVE_SIGEMPTYSET
00270 # define sigemptyset(x) ((*(int *)(x))=0)
00271 #endif
00272
00273 #ifndef HAVE_SOCKLEN_T
00274 typedef int socklen_t;
00275 #endif
00276
00277
00278
00279
00280
00281 #define nstrdup(x) n_strdup((x),__FILE__,__LINE__)
00282 #define nmalloc(x) n_malloc((x),__FILE__,__LINE__)
00283 #define nrealloc(x,y) n_realloc((x),(y),__FILE__,__LINE__)
00284 #define nfree(x) n_free((x),__FILE__,__LINE__)
00285
00286 #ifdef DEBUG_CONTEXT
00287 # define Context eggContext(__FILE__, __LINE__, NULL)
00288 # define ContextNote(note) eggContextNote(__FILE__, __LINE__, NULL, note)
00289 #else
00290 # define Context do {} while (0)
00291 # define ContextNote(note) do {} while (0)
00292 #endif
00293
00294 #ifdef DEBUG_ASSERT
00295 # define Assert(expr) do { \
00296 if (!(expr)) \
00297 eggAssert(__FILE__, __LINE__, NULL); \
00298 } while (0)
00299 #else
00300 # define Assert(expr) do {} while (0)
00301 #endif
00302
00303 #ifndef COMPILING_MEM
00304 # undef malloc
00305 # define malloc(x) dont_use_old_malloc(x)
00306 # undef free
00307 # define free(x) dont_use_old_free(x)
00308 #endif
00309
00310
00311 #if (SIZEOF_INT == 4)
00312 typedef unsigned int u_32bit_t;
00313 #else
00314 # if (SIZEOF_LONG == 4)
00315 typedef unsigned long u_32bit_t;
00316 # else
00317 # include "Error: Can't find 32bit type."
00318 # endif
00319 #endif
00320
00321 typedef unsigned short int u_16bit_t;
00322 typedef unsigned char u_8bit_t;
00323
00324
00325 typedef u_32bit_t IP;
00326
00327
00328 #define debug0(x) putlog(LOG_DEBUG,"*",x)
00329 #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
00330 #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
00331 #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
00332 #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
00333
00334
00335 #define egg_isdigit(x) isdigit((int) (unsigned char) (x))
00336 #define egg_isxdigit(x) isxdigit((int) (unsigned char) (x))
00337 #define egg_isascii(x) isascii((int) (unsigned char) (x))
00338 #define egg_isspace(x) isspace((int) (unsigned char) (x))
00339 #define egg_islower(x) islower((int) (unsigned char) (x))
00340
00341
00342
00343
00344 typedef intptr_t (*Function) ();
00345 typedef int (*IntFunc) ();
00346
00347
00348 struct portmap {
00349 int realport;
00350 int mappedto;
00351 struct portmap *next;
00352 };
00353
00354
00355 struct dcc_table {
00356 char *name;
00357 int flags;
00358 void (*eof) (int);
00359 void (*activity) (int, char *, int);
00360 int *timeout_val;
00361 void (*timeout) (int);
00362 void (*display) (int, char *);
00363 int (*expmem) (void *);
00364 void (*kill) (int, void *);
00365 void (*output) (int, char *, void *);
00366 void (*outdone) (int);
00367 };
00368
00369 struct userrec;
00370
00371 struct dcc_t {
00372 long sock;
00373 IP addr;
00374 unsigned int port;
00375 struct userrec *user;
00376 char nick[NICKLEN];
00377 char host[UHOSTLEN];
00378 struct dcc_table *type;
00379 time_t timeval;
00380 unsigned long status;
00381 union {
00382 struct chat_info *chat;
00383 struct file_info *file;
00384 struct edit_info *edit;
00385 struct xfer_info *xfer;
00386 struct bot_info *bot;
00387 struct relay_info *relay;
00388 struct script_info *script;
00389 struct dns_info *dns;
00390 struct dupwait_info *dupwait;
00391 int ident_sock;
00392 void *other;
00393 } u;
00394 };
00395
00396 struct chat_info {
00397 char *away;
00398 int msgs_per_sec;
00399 int con_flags;
00400 int strip_flags;
00401 char con_chan[81];
00402 int channel;
00403 struct msgq *buffer;
00404
00405 int max_line;
00406 int line_count;
00407 int current_lines;
00408 char *su_nick;
00409 };
00410
00411 struct file_info {
00412 struct chat_info *chat;
00413 char dir[161];
00414 };
00415
00416 struct xfer_info {
00417 char *filename;
00418 char *origname;
00419 char dir[DIRLEN];
00420 unsigned long length;
00421 unsigned long acked;
00422 char buf[4];
00423 unsigned char sofar;
00424 char from[NICKLEN];
00425 FILE *f;
00426 unsigned int type;
00427 unsigned short ack_type;
00428 unsigned long offset;
00429
00430 unsigned long block_pending;
00431
00432 time_t start_time;
00433 };
00434
00435 enum {
00436 XFER_SEND,
00437 XFER_RESEND,
00438 XFER_RESEND_PEND,
00439 XFER_RESUME,
00440 XFER_RESUME_PEND,
00441 XFER_GET
00442 };
00443
00444 enum {
00445 XFER_ACK_UNKNOWN,
00446 XFER_ACK_WITH_OFFSET,
00447
00448 XFER_ACK_WITHOUT_OFFSET
00449 };
00450
00451 struct bot_info {
00452 char version[121];
00453 char linker[NOTENAMELEN + 1];
00454 int numver;
00455 int port;
00456 int uff_flags;
00457 };
00458
00459 struct relay_info {
00460 struct chat_info *chat;
00461 int sock;
00462 int port;
00463 int old_status;
00464 };
00465
00466 struct script_info {
00467 struct dcc_table *type;
00468 union {
00469 struct chat_info *chat;
00470 struct file_info *file;
00471 void *other;
00472 } u;
00473 char command[121];
00474 };
00475
00476 struct dns_info {
00477 void (*dns_success) (int);
00478 void (*dns_failure) (int);
00479 char *host;
00480 char *cbuf;
00481
00482 char *cptr;
00483 IP ip;
00484 int ibuf;
00485 char dns_type;
00486 struct dcc_table *type;
00487
00488 };
00489
00490
00491 #define RES_HOSTBYIP 1
00492 #define RES_IPBYHOST 2
00493
00494 struct dupwait_info {
00495 int atr;
00496 struct chat_info *chat;
00497 };
00498
00499
00500 #define DCT_CHAT 0x00000001
00501
00502 #define DCT_MASTER 0x00000002
00503 #define DCT_SHOWWHO 0x00000004
00504 #define DCT_REMOTEWHO 0x00000008
00505 #define DCT_VALIDIDX 0x00000010
00506
00507 #define DCT_SIMUL 0x00000020
00508 #define DCT_CANBOOT 0x00000040
00509 #define DCT_GETNOTES DCT_CHAT
00510 #define DCT_FILES 0x00000080
00511 #define DCT_FORKTYPE 0x00000100
00512 #define DCT_BOT 0x00000200
00513 #define DCT_FILETRAN 0x00000400
00514 #define DCT_FILESEND 0x00000800
00515
00516 #define DCT_LISTEN 0x00001000
00517
00518
00519 #define STAT_ECHO 0x00001
00520 #define STAT_DENY 0x00002
00521
00522 #define STAT_CHAT 0x00004
00523 #define STAT_TELNET 0x00008
00524 #define STAT_PARTY 0x00010
00525 #define STAT_BOTONLY 0x00020
00526 #define STAT_USRONLY 0x00040
00527 #define STAT_PAGE 0x00080
00528
00529
00530 #define STRIP_COLOR 0x00001
00531 #define STRIP_BOLD 0x00002
00532 #define STRIP_REV 0x00004
00533 #define STRIP_UNDER 0x00008
00534 #define STRIP_ANSI 0x00010
00535 #define STRIP_BELLS 0x00020
00536 #define STRIP_ALL 0x0007F
00537
00538
00539 #define STAT_PINGED 0x00001
00540 #define STAT_SHARE 0x00002
00541 #define STAT_CALLED 0x00004
00542 #define STAT_OFFERED 0x00008
00543 #define STAT_SENDING 0x00010
00544 #define STAT_GETTING 0x00020
00545 #define STAT_WARNED 0x00040
00546 #define STAT_LEAF 0x00080
00547 #define STAT_LINKING 0x00100
00548
00549 #define STAT_AGGRESSIVE 0x00200
00550
00551
00552 #define LSTN_PUBLIC 0x000001
00553
00554
00555 #define FLOOD_PRIVMSG 0
00556 #define FLOOD_NOTICE 1
00557 #define FLOOD_CTCP 2
00558 #define FLOOD_NICK 3
00559 #define FLOOD_JOIN 4
00560 #define FLOOD_KICK 5
00561 #define FLOOD_DEOP 6
00562
00563 #define FLOOD_CHAN_MAX 7
00564 #define FLOOD_GLOBAL_MAX 3
00565
00566
00567 #define STDIN 0
00568 #define STDOUT 1
00569 #define STDERR 2
00570
00571
00572 typedef struct {
00573 char *filename;
00574 unsigned int mask;
00575 char *chname;
00576 char szlast[LOGLINELEN];
00577
00578 int repeats;
00579 unsigned int flags;
00580 FILE *f;
00581 } log_t;
00582
00583
00584
00585 #define LOG_MSGS 0x000001
00586 #define LOG_PUBLIC 0x000002
00587 #define LOG_JOIN 0x000004
00588 #define LOG_MODES 0x000008
00589 #define LOG_CMDS 0x000010
00590 #define LOG_MISC 0x000020
00591 #define LOG_BOTS 0x000040
00592 #define LOG_RAW 0x000080
00593 #define LOG_FILES 0x000100
00594 #define LOG_LEV1 0x000200
00595 #define LOG_LEV2 0x000400
00596 #define LOG_LEV3 0x000800
00597 #define LOG_LEV4 0x001000
00598 #define LOG_LEV5 0x002000
00599 #define LOG_LEV6 0x004000
00600 #define LOG_LEV7 0x008000
00601 #define LOG_LEV8 0x010000
00602 #define LOG_SERV 0x020000
00603 #define LOG_DEBUG 0x040000
00604 #define LOG_WALL 0x080000
00605 #define LOG_SRVOUT 0x100000
00606 #define LOG_BOTNET 0x200000
00607 #define LOG_BOTSHARE 0x400000
00608 #define LOG_ALL 0x7fffff
00609
00610
00611
00612 #define LF_EXPIRING 0x000001
00613
00614 #define FILEDB_HIDE 1
00615 #define FILEDB_UNHIDE 2
00616 #define FILEDB_SHARE 3
00617 #define FILEDB_UNSHARE 4
00618
00619
00620
00621 #define SOCK_UNUSED 0x0001
00622 #define SOCK_BINARY 0x0002
00623 #define SOCK_LISTEN 0x0004
00624 #define SOCK_CONNECT 0x0008
00625 #define SOCK_NONSOCK 0x0010
00626 #define SOCK_STRONGCONN 0x0020
00627 #define SOCK_EOFD 0x0040
00628 #define SOCK_PROXYWAIT 0x0080
00629 #define SOCK_PASS 0x0100
00630
00631 #define SOCK_VIRTUAL 0x0200
00632 #define SOCK_BUFFER 0x0400
00633 #define SOCK_TCL 0x0800
00634
00635
00636
00637 enum {
00638 SOCK_DATA_OUTGOING,
00639 SOCK_DATA_INCOMING
00640 };
00641
00642
00643
00644 #define DP_STDOUT 0x7FF1
00645 #define DP_LOG 0x7FF2
00646 #define DP_SERVER 0x7FF3
00647 #define DP_HELP 0x7FF4
00648 #define DP_STDERR 0x7FF5
00649 #define DP_MODE 0x7FF6
00650 #define DP_MODE_NEXT 0x7FF7
00651 #define DP_SERVER_NEXT 0x7FF8
00652 #define DP_HELP_NEXT 0x7FF9
00653
00654 #define NORMAL 0
00655 #define QUICK 1
00656
00657
00658 #define NOTE_ERROR 0
00659 #define NOTE_OK 1
00660 #define NOTE_STORED 2
00661 #define NOTE_FULL 3
00662 #define NOTE_TCL 4
00663 #define NOTE_AWAY 5
00664 #define NOTE_FWD 6
00665 #define NOTE_REJECT 7
00666
00667 #define STR_PROTECT 2
00668 #define STR_DIR 1
00669
00670 #define HELP_DCC 1
00671 #define HELP_TEXT 2
00672 #define HELP_IRC 16
00673
00674
00675
00676
00677 struct sock_handler {
00678 char *inbuf;
00679 char *outbuf;
00680 unsigned long outbuflen;
00681 unsigned long inbuflen;
00682 };
00683
00684 struct tclsock_handler {
00685 int mask;
00686 Tcl_FileProc *proc;
00687 ClientData cd;
00688 };
00689
00690 typedef struct sock_list {
00691 int sock;
00692 short flags;
00693 union {
00694 struct sock_handler sock;
00695 struct tclsock_handler tclsock;
00696 } handler;
00697 } sock_list;
00698
00699 enum {
00700 EGG_OPTION_SET = 1,
00701 EGG_OPTION_UNSET = 2
00702 };
00703
00704
00705
00706
00707
00708 #define TLN_AYT 246
00709 #define TLN_WILL 251
00710 #define TLN_WILL_C "\373"
00711 #define TLN_WONT 252
00712 #define TLN_WONT_C "\374"
00713 #define TLN_DO 253
00714 #define TLN_DO_C "\375"
00715 #define TLN_DONT 254
00716 #define TLN_DONT_C "\376"
00717 #define TLN_IAC 255
00718 #define TLN_IAC_C "\377"
00719
00720
00721 #define TLN_ECHO 1
00722 #define TLN_ECHO_C "\001"
00723 #define TLN_STATUS 5
00724 #define TLN_STATUS_C "\005"
00725
00726 #endif