/[cvs]/eggdrop1.9/src/eggdrop.h
ViewVC logotype

Contents of /eggdrop1.9/src/eggdrop.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.53 - (show annotations) (download) (as text)
Fri Jan 4 02:56:25 2002 UTC (17 years, 11 months ago) by ite
Branch: MAIN
CVS Tags: HEAD
Changes since 1.52: +1 -1 lines
File MIME type: text/x-csrc
FILE REMOVED
* Moved some botnet utility functions from the core to libeggdrop.
* Moved some common macros to libeggdrop.
* Created lib/eggdrop/eggdrop.h and renamed src/eggdrop.h to src/egg.h to avoid ambiguities.
* Added a couple of macros to be c++ friendly

1 /*
2 * eggdrop.h
3 * Eggdrop compile-time settings
4 *
5 * IF YOU ALTER THIS FILE, YOU NEED TO RECOMPILE THE BOT.
6 *
7 * $Id: eggdrop.h,v 1.52 2001/12/18 07:04:21 guppy Exp $
8 */
9 /*
10 * Copyright (C) 1997 Robey Pointer
11 * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28 #ifndef _EGG_EGGDROP_H
29 #define _EGG_EGGDROP_H
30
31 /*
32 * If you're *only* going to link to new version bots (1.3.0 or higher)
33 * then you can safely define this.
34 */
35 #undef NO_OLD_BOTNET
36
37 /*
38 * HANDLEN note:
39 * HANDLEN defines the maximum length a handle on the bot can be.
40 * Standard (and minimum) is 9 characters long.
41 *
42 * Beware that using lengths over 9 chars is 'non-standard' and if
43 * you wish to link to other bots, they _must_ both have the same
44 * maximum handle length.
45 *
46 * NICKMAX note:
47 * You should leave this at 32 characters and modify nick-len in the
48 * configuration file instead.
49 */
50
51 #define HANDLEN 9 /* valid values 9->NICKMAX */
52 #define NICKMAX 32 /* valid values HANDLEN->32 */
53
54
55 /* Handy string lengths */
56
57 #define ADDRMAX 45
58 #define UHOSTMAX 160 /* reasonable, i think? */
59 #define DIRMAX 256 /* paranoia */
60 #define LOGLINEMAX 767 /* for misc.c/putlog() <cybah> */
61 #define BADHANDCHARS "-,+*=:!.@#;$%&"
62
63
64 /*
65 * The 'configure' script should make this next part automatic,
66 * so you shouldn't need to adjust anything below.
67 */
68
69 #define NICKLEN NICKMAX + 1
70 #define UHOSTLEN UHOSTMAX + 1
71 #define DIRLEN DIRMAX + 1
72 #define LOGLINELEN LOGLINEMAX + 1
73 #define NOTENAMELEN ((HANDLEN * 2) + 1)
74 #define BADNICKCHARS "-,+*=:!.@#;$%&"
75
76
77 /* Gettext stuff */
78 #ifdef ENABLE_NLS
79 # include <libintl.h>
80 # define _(x) gettext(x)
81 # define N_(x) gettext_noop (x)
82 #else
83 # define N_(x) (x)
84 # define _(x) (x)
85 #endif
86
87 #ifdef HAVE_UNISTD_H
88 # include <unistd.h>
89 #endif
90
91 #define ADDRLEN (ADDRMAX + 1)
92
93 #if (NICKMAX < 9) || (NICKMAX > 32)
94 # include "invalid NICKMAX value"
95 #endif
96
97 #if (HANDLEN < 9) || (HANDLEN > 32)
98 # include "invalid HANDLEN value"
99 #endif
100
101 #if HANDLEN > NICKMAX
102 # include "HANDLEN MUST BE <= NICKMAX"
103 #endif
104
105 /* NAME_MAX is what POSIX defines, but BSD calls it MAXNAMLEN.
106 * Use 255 if we can't find anything else.
107 */
108 #ifndef NAME_MAX
109 # ifdef MAXNAMLEN
110 # define NAME_MAX MAXNAMLEN
111 # else
112 # define NAME_MAX 255
113 # endif
114 #endif
115
116 /* Almost every module needs some sort of time thingy, so... */
117 #if TIME_WITH_SYS_TIME
118 # include <sys/time.h>
119 # include <time.h>
120 #else
121 # if HAVE_SYS_TIME_H
122 # include <sys/time.h>
123 # else
124 # include <time.h>
125 # endif
126 #endif
127
128 #ifndef HAVE_SRANDOM
129 # define srandom(x) srand(x)
130 #endif
131
132 #ifndef HAVE_RANDOM
133 # define random() (rand()/16)
134 #endif
135
136 #ifndef HAVE_SIGACTION /* old "weird signals" */
137 # define sigaction sigvec
138 # ifndef sa_handler
139 # define sa_handler sv_handler
140 # define sa_mask sv_mask
141 # define sa_flags sv_flags
142 # endif
143 #endif
144
145 #ifndef HAVE_SIGEMPTYSET
146 /* and they probably won't have sigemptyset, dammit */
147 # define sigemptyset(x) ((*(int *)(x))=0)
148 #endif
149
150
151 /* Macros for commonly used commands.
152 */
153
154 #define free_null(ptr) \
155 if (ptr) { \
156 free(ptr); \
157 ptr = NULL; \
158 }
159
160 #define malloc_strcpy(target, entry) \
161 do { \
162 (target) = malloc(strlen(entry) + 1); \
163 strcpy((target), (entry)); \
164 } while (0)
165
166 /* Copy entry to target -- Uses dynamic memory allocation, which
167 * means you'll eventually have to free the memory again. 'target'
168 * will be overwritten.
169 */
170 #define realloc_strcpy(target, entry) \
171 do { \
172 if (entry) { \
173 (target) = realloc((target), strlen(entry) + 1); \
174 strcpy((target), (entry)); \
175 } else \
176 free_null(target); \
177 } while (0)
178
179 /* 32 bit type
180 */
181 #ifdef UNSIGNED_LONG32
182 typedef unsigned long u_32int_t;
183 #else
184 # ifdef UNSIGNED_INT32
185 typedef unsigned int u_32int_t;
186 # else
187 typedef unsigned long u_32int_t;
188 # endif
189 #endif
190
191 typedef unsigned short int u_16bit_t;
192 typedef unsigned char u_8bit_t;
193
194 /* IP type */
195 typedef u_32int_t IP;
196
197 #define debug0(x) putlog(LOG_DEBUG,"*",x)
198 #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
199 #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
200 #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
201 #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
202
203 /***********************************************************************/
204
205 /* It's used in so many places, let's put it here */
206 typedef int (*Function) ();
207
208 /* Public structure for the listening port map */
209 struct portmap {
210 int realport;
211 int mappedto;
212 struct portmap *next;
213 };
214
215 /* Public structure of all the dcc connections */
216 struct dcc_table {
217 char *name;
218 int flags;
219 void (*eof) (int);
220 void (*activity) (int, char *, int);
221 int *timeout_val;
222 void (*timeout) ();
223 void (*display) (int, char *);
224 void (*kill) (int, void *);
225 void (*output) (int, char *, void *);
226 void (*outdone) (int);
227 };
228
229 struct userrec;
230
231 struct dcc_t {
232 long sock; /* This should be a long to keep 64-bit
233 machines sane */
234 char addr[ADDRLEN]; /* IPv4/v6 address as string :) */
235 unsigned int port;
236 struct userrec *user;
237 char nick[NICKLEN];
238 char host[UHOSTLEN];
239 struct dcc_table *type;
240 time_t timeval; /* Use for any timing stuff
241 - this is used for timeout checking */
242 unsigned long status; /* A LOT of dcc types have status
243 thingos, this makes it more avaliabe */
244 union {
245 struct chat_info *chat;
246 struct file_info *file;
247 struct edit_info *edit;
248 struct xfer_info *xfer;
249 struct bot_info *bot;
250 struct relay_info *relay;
251 struct script_info *script;
252 struct dns_info *dns;
253 struct dupwait_info *dupwait;
254 int ident_sock;
255 void *other;
256 } u; /* Special use depending on type */
257 };
258
259 struct chat_info {
260 char *away; /* non-NULL if user is away */
261 int msgs_per_sec; /* used to stop flooding */
262 int con_flags; /* with console: what to show */
263 int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
264 char con_chan[81]; /* with console: what channel to view */
265 int channel; /* 0=party line, -1=off */
266 struct msgq *buffer; /* a buffer of outgoing lines
267 (for .page cmd) */
268 int max_line; /* maximum lines at once */
269 int line_count; /* number of lines sent since last page */
270 int current_lines; /* number of lines total stored */
271 char *su_nick;
272 };
273
274 struct file_info {
275 struct chat_info *chat;
276 char dir[161];
277 };
278
279 struct xfer_info {
280 char *filename;
281 char *origname;
282 char dir[121]; /* used when uploads go to the current dir */
283 unsigned long length;
284 unsigned long acked;
285 char buf[4]; /* you only need 5 bytes! */
286 unsigned char sofar; /* how much of the byte count received */
287 char from[NICKLEN]; /* [GET] user who offered the file */
288 FILE *f; /* pointer to file being sent/received */
289 unsigned int type; /* xfer connection type, see enum below */
290 unsigned short ack_type; /* type of ack */
291 unsigned long offset; /* offset from beginning of file, during
292 resend. */
293 unsigned long block_pending; /* bytes of this DCC block which weren't
294 sent yet. */
295 time_t start_time; /* Time when a xfer was started. */
296 };
297
298 struct bot_info {
299 char version[121]; /* channel/version info */
300 char linker[NOTENAMELEN + 1]; /* who requested this link */
301 int numver;
302 int port; /* base port */
303 int uff_flags; /* user file feature flags */
304 };
305
306 struct relay_info {
307 struct chat_info *chat;
308 int sock;
309 int port;
310 int old_status;
311 };
312
313 struct script_info {
314 struct dcc_table *type;
315 union {
316 struct chat_info *chat;
317 struct file_info *file;
318 void *other;
319 } u;
320 char command[121];
321 };
322
323 struct dns_info {
324 void (*dns_success)(int); /* is called if the dns request succeeds */
325 void (*dns_failure)(int); /* is called if it fails */
326 char *host; /* hostname or IP addr (as string) */
327 char *cbuf; /* temporary buffer. Memory will be free'd
328 as soon as dns_info is free'd */
329 char *cptr; /* temporary pointer */
330 int ibuf; /* temporary buffer for one integer */
331 char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
332 struct dcc_table *type; /* type of the dcc table we are making the
333 lookup for */
334 };
335
336 /* Flags for dns_type
337 */
338 #define RES_HOSTBYIP 1 /* hostname to IP address */
339 #define RES_IPBYHOST 2 /* IP address to hostname */
340
341 struct dupwait_info {
342 int atr; /* the bots attributes */
343 struct chat_info *chat; /* holds current chat data */
344 };
345
346 /* Flags about dcc types
347 */
348 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
349 chatter */
350 #define DCT_MASTER 0x00000002 /* received master chatter */
351 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
352 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
353 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
354 in tcl */
355 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
356 #define DCT_CANBOOT 0x00000040 /* can be booted */
357 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
358 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
359 #define DCT_FORKTYPE 0x00000100 /* a forking type */
360 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
361 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
362 #define DCT_FILESEND 0x00000800 /* a sending file transfer,
363 getting = !this */
364 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
365
366 /* For dcc chat & files:
367 */
368 #define STAT_ECHO 0x00001 /* echo commands back? */
369 #define STAT_DENY 0x00002 /* bad username (ignore password & deny
370 access) */
371 #define STAT_CHAT 0x00004 /* in file-system but may return */
372 #define STAT_TELNET 0x00008 /* connected via telnet */
373 #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
374 #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
375 #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
376 #define STAT_PAGE 0x00080 /* page output to the user */
377
378 /* For stripping out mIRC codes
379 */
380 #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
381 #define STRIP_BOLD 0x00002 /* remove bold codes */
382 #define STRIP_REV 0x00004 /* remove reverse video codes */
383 #define STRIP_UNDER 0x00008 /* remove underline codes */
384 #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
385 #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
386 #define STRIP_ALL 0x00040 /* remove every damn thing! */
387
388 /* for dcc bot links: */
389 #define STAT_PINGED 0x00001 /* waiting for ping to return */
390 #define STAT_SHARE 0x00002 /* sharing user data with the bot */
391 #define STAT_CALLED 0x00004 /* this bot called me */
392 #define STAT_OFFERED 0x00008 /* offered her the user file */
393 #define STAT_SENDING 0x00010 /* in the process of sending a user list */
394 #define STAT_GETTING 0x00020 /* in the process of getting a user list */
395 #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
396 #define STAT_LEAF 0x00080 /* this bot is a leaf only */
397 #define STAT_LINKING 0x00100 /* the bot is currently going through
398 the linking stage */
399 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
400
401 /* Flags for listening sockets
402 */
403 #define LSTN_PUBLIC 0x000001 /* No access restrictions */
404
405 /* chan & global */
406 #define FLOOD_PRIVMSG 0
407 #define FLOOD_NOTICE 1
408 #define FLOOD_CTCP 2
409 #define FLOOD_NICK 3
410 #define FLOOD_JOIN 4
411 #define FLOOD_KICK 5
412 #define FLOOD_DEOP 6
413
414 #define FLOOD_CHAN_MAX 7
415 #define FLOOD_GLOBAL_MAX 3
416
417 /* For local console: */
418 #define STDIN 0
419 #define STDOUT 1
420 #define STDERR 2
421
422 /* Logfile display flags
423 */
424 #define LOG_MSGS 0x000001 /* m msgs/notice/ctcps */
425 #define LOG_PUBLIC 0x000002 /* p public msg/notice/ctcps */
426 #define LOG_JOIN 0x000004 /* j channel joins/parts/etc */
427 #define LOG_MODES 0x000008 /* k mode changes/kicks/bans */
428 #define LOG_CMDS 0x000010 /* c user dcc or msg commands */
429 #define LOG_MISC 0x000020 /* o other misc bot things */
430 #define LOG_BOTS 0x000040 /* b bot notices */
431 #define LOG_RAW 0x000080 /* r raw server stuff coming in */
432 #define LOG_FILES 0x000100 /* x file transfer commands and stats */
433 #define LOG_LEV1 0x000200 /* 1 user log level */
434 #define LOG_LEV2 0x000400 /* 2 user log level */
435 #define LOG_LEV3 0x000800 /* 3 user log level */
436 #define LOG_LEV4 0x001000 /* 4 user log level */
437 #define LOG_LEV5 0x002000 /* 5 user log level */
438 #define LOG_LEV6 0x004000 /* 6 user log level */
439 #define LOG_LEV7 0x008000 /* 7 user log level */
440 #define LOG_LEV8 0x010000 /* 8 user log level */
441 #define LOG_SERV 0x020000 /* s server information */
442 #define LOG_DEBUG 0x040000 /* d debug */
443 #define LOG_WALL 0x080000 /* w wallops */
444 #define LOG_SRVOUT 0x100000 /* v server output */
445 #define LOG_BOTNET 0x200000 /* t botnet traffic */
446 #define LOG_BOTSHARE 0x400000 /* h share traffic */
447 #define LOG_ALL 0x7fffff /* (dump to all logfiles) */
448
449 #define FILEDB_HIDE 1
450 #define FILEDB_UNHIDE 2
451 #define FILEDB_SHARE 3
452 #define FILEDB_UNSHARE 4
453
454 /* Socket flags:
455 */
456 #define SOCK_UNUSED 0x0001 /* empty socket */
457 #define SOCK_BINARY 0x0002 /* do not buffer input */
458 #define SOCK_LISTEN 0x0004 /* listening port */
459 #define SOCK_CONNECT 0x0008 /* connection attempt */
460 #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
461 #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
462 #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
463 #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
464 #define SOCK_PASS 0x0100 /* passed on; only notify in case
465 of traffic */
466 #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
467 #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
468
469 /* Flags to sock_has_data
470 */
471 enum {
472 SOCK_DATA_OUTGOING, /* Data in out-queue? */
473 SOCK_DATA_INCOMING /* Data in in-queue? */
474 };
475
476 /* Fake idx's for dprintf - these should be ridiculously large +ve nums
477 */
478 #define DP_STDOUT 0x7FF1
479 #define DP_LOG 0x7FF2
480 #define DP_SERVER 0x7FF3
481 #define DP_HELP 0x7FF4
482 #define DP_STDERR 0x7FF5
483 #define DP_MODE 0x7FF6
484 #define DP_MODE_NEXT 0x7FF7
485 #define DP_SERVER_NEXT 0x7FF8
486 #define DP_HELP_NEXT 0x7FF9
487
488 #define NORMAL 0
489 #define QUICK 1
490
491 /* Return codes for add_note */
492 #define NOTE_ERROR 0 /* error */
493 #define NOTE_OK 1 /* success */
494 #define NOTE_STORED 2 /* not online; stored */
495 #define NOTE_FULL 3 /* too many notes stored */
496 #define NOTE_TCL 4 /* tcl binding caught it */
497 #define NOTE_AWAY 5 /* away; stored */
498 #define NOTE_FWD 6 /* away; forwarded */
499 #define NOTE_REJECT 7 /* ignore mask matched */
500
501 #define STR_PROTECT 2
502 #define STR_DIR 1
503
504 #define HELP_DCC 1
505 #define HELP_TEXT 2
506 #define HELP_IRC 16
507
508 /* This is used by the net module to keep track of sockets and what's
509 * queued on them
510 */
511 typedef struct {
512 int sock;
513 short flags;
514 char *inbuf;
515 char *outbuf;
516 unsigned long outbuflen; /* Outbuf could be binary data */
517 unsigned long inbuflen; /* Inbuf could be binary data */
518 } sock_list;
519
520 enum {
521 EGG_OPTION_SET = 1, /* Set option(s). */
522 EGG_OPTION_UNSET = 2 /* Unset option(s). */
523 };
524
525 /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
526 * "TELNET Echo Option" (RFC 875) for details.
527 */
528
529 #define TLN_AYT 246 /* Are You There */
530
531 #define TLN_WILL 251 /* Will */
532 #define TLN_WILL_C "\373"
533 #define TLN_WONT 252 /* Won't */
534 #define TLN_WONT_C "\374"
535 #define TLN_DO 253 /* Do */
536 #define TLN_DO_C "\375"
537 #define TLN_DONT 254 /* Don't */
538 #define TLN_DONT_C "\376"
539 #define TLN_IAC 255 /* Interpret As Command */
540 #define TLN_IAC_C "\377"
541
542 #define TLN_ECHO 1 /* Echo */
543 #define TLN_ECHO_C "\001"
544
545 #endif /* _EGG_EGGDROP_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23