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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Wed Jan 16 22:09:43 2002 UTC (17 years, 10 months ago) by ite
Branch: MAIN
Changes since 1.1: +2 -30 lines
File MIME type: text/x-csrc
Removed our malloc_strcpy macro sincw it had the same functionality of strdup (provided the respective fallback function)

1 /*
2 * egg.h
3 * Eggdrop compile-time settings
4 *
5 * IF YOU ALTER THIS FILE, YOU NEED TO RECOMPILE THE BOT.
6 *
7 * $Id: egg.h,v 1.1 2002/01/04 02:56:25 ite 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 /* 32 bit type
152 */
153 #ifdef UNSIGNED_LONG32
154 typedef unsigned long u_32int_t;
155 #else
156 # ifdef UNSIGNED_INT32
157 typedef unsigned int u_32int_t;
158 # else
159 typedef unsigned long u_32int_t;
160 # endif
161 #endif
162
163 typedef unsigned short int u_16bit_t;
164 typedef unsigned char u_8bit_t;
165
166 /* IP type */
167 typedef u_32int_t IP;
168
169 #define debug0(x) putlog(LOG_DEBUG,"*",x)
170 #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
171 #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
172 #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
173 #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
174
175 /***********************************************************************/
176
177 /* It's used in so many places, let's put it here */
178 typedef int (*Function) ();
179
180 /* Public structure for the listening port map */
181 struct portmap {
182 int realport;
183 int mappedto;
184 struct portmap *next;
185 };
186
187 /* Public structure of all the dcc connections */
188 struct dcc_table {
189 char *name;
190 int flags;
191 void (*eof) (int);
192 void (*activity) (int, char *, int);
193 int *timeout_val;
194 void (*timeout) ();
195 void (*display) (int, char *);
196 void (*kill) (int, void *);
197 void (*output) (int, char *, void *);
198 void (*outdone) (int);
199 };
200
201 struct userrec;
202
203 struct dcc_t {
204 long sock; /* This should be a long to keep 64-bit
205 machines sane */
206 char addr[ADDRLEN]; /* IPv4/v6 address as string :) */
207 unsigned int port;
208 struct userrec *user;
209 char nick[NICKLEN];
210 char host[UHOSTLEN];
211 struct dcc_table *type;
212 time_t timeval; /* Use for any timing stuff
213 - this is used for timeout checking */
214 unsigned long status; /* A LOT of dcc types have status
215 thingos, this makes it more avaliabe */
216 union {
217 struct chat_info *chat;
218 struct file_info *file;
219 struct edit_info *edit;
220 struct xfer_info *xfer;
221 struct bot_info *bot;
222 struct relay_info *relay;
223 struct script_info *script;
224 struct dns_info *dns;
225 struct dupwait_info *dupwait;
226 int ident_sock;
227 void *other;
228 } u; /* Special use depending on type */
229 };
230
231 struct chat_info {
232 char *away; /* non-NULL if user is away */
233 int msgs_per_sec; /* used to stop flooding */
234 int con_flags; /* with console: what to show */
235 int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
236 char con_chan[81]; /* with console: what channel to view */
237 int channel; /* 0=party line, -1=off */
238 struct msgq *buffer; /* a buffer of outgoing lines
239 (for .page cmd) */
240 int max_line; /* maximum lines at once */
241 int line_count; /* number of lines sent since last page */
242 int current_lines; /* number of lines total stored */
243 char *su_nick;
244 };
245
246 struct file_info {
247 struct chat_info *chat;
248 char dir[161];
249 };
250
251 struct xfer_info {
252 char *filename;
253 char *origname;
254 char dir[121]; /* used when uploads go to the current dir */
255 unsigned long length;
256 unsigned long acked;
257 char buf[4]; /* you only need 5 bytes! */
258 unsigned char sofar; /* how much of the byte count received */
259 char from[NICKLEN]; /* [GET] user who offered the file */
260 FILE *f; /* pointer to file being sent/received */
261 unsigned int type; /* xfer connection type, see enum below */
262 unsigned short ack_type; /* type of ack */
263 unsigned long offset; /* offset from beginning of file, during
264 resend. */
265 unsigned long block_pending; /* bytes of this DCC block which weren't
266 sent yet. */
267 time_t start_time; /* Time when a xfer was started. */
268 };
269
270 struct bot_info {
271 char version[121]; /* channel/version info */
272 char linker[NOTENAMELEN + 1]; /* who requested this link */
273 int numver;
274 int port; /* base port */
275 int uff_flags; /* user file feature flags */
276 };
277
278 struct relay_info {
279 struct chat_info *chat;
280 int sock;
281 int port;
282 int old_status;
283 };
284
285 struct script_info {
286 struct dcc_table *type;
287 union {
288 struct chat_info *chat;
289 struct file_info *file;
290 void *other;
291 } u;
292 char command[121];
293 };
294
295 struct dns_info {
296 void (*dns_success)(int); /* is called if the dns request succeeds */
297 void (*dns_failure)(int); /* is called if it fails */
298 char *host; /* hostname or IP addr (as string) */
299 char *cbuf; /* temporary buffer. Memory will be free'd
300 as soon as dns_info is free'd */
301 char *cptr; /* temporary pointer */
302 int ibuf; /* temporary buffer for one integer */
303 char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
304 struct dcc_table *type; /* type of the dcc table we are making the
305 lookup for */
306 };
307
308 /* Flags for dns_type
309 */
310 #define RES_HOSTBYIP 1 /* hostname to IP address */
311 #define RES_IPBYHOST 2 /* IP address to hostname */
312
313 struct dupwait_info {
314 int atr; /* the bots attributes */
315 struct chat_info *chat; /* holds current chat data */
316 };
317
318 /* Flags about dcc types
319 */
320 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
321 chatter */
322 #define DCT_MASTER 0x00000002 /* received master chatter */
323 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
324 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
325 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
326 in tcl */
327 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
328 #define DCT_CANBOOT 0x00000040 /* can be booted */
329 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
330 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
331 #define DCT_FORKTYPE 0x00000100 /* a forking type */
332 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
333 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
334 #define DCT_FILESEND 0x00000800 /* a sending file transfer,
335 getting = !this */
336 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
337
338 /* For dcc chat & files:
339 */
340 #define STAT_ECHO 0x00001 /* echo commands back? */
341 #define STAT_DENY 0x00002 /* bad username (ignore password & deny
342 access) */
343 #define STAT_CHAT 0x00004 /* in file-system but may return */
344 #define STAT_TELNET 0x00008 /* connected via telnet */
345 #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
346 #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
347 #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
348 #define STAT_PAGE 0x00080 /* page output to the user */
349
350 /* For stripping out mIRC codes
351 */
352 #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
353 #define STRIP_BOLD 0x00002 /* remove bold codes */
354 #define STRIP_REV 0x00004 /* remove reverse video codes */
355 #define STRIP_UNDER 0x00008 /* remove underline codes */
356 #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
357 #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
358 #define STRIP_ALL 0x00040 /* remove every damn thing! */
359
360 /* for dcc bot links: */
361 #define STAT_PINGED 0x00001 /* waiting for ping to return */
362 #define STAT_SHARE 0x00002 /* sharing user data with the bot */
363 #define STAT_CALLED 0x00004 /* this bot called me */
364 #define STAT_OFFERED 0x00008 /* offered her the user file */
365 #define STAT_SENDING 0x00010 /* in the process of sending a user list */
366 #define STAT_GETTING 0x00020 /* in the process of getting a user list */
367 #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
368 #define STAT_LEAF 0x00080 /* this bot is a leaf only */
369 #define STAT_LINKING 0x00100 /* the bot is currently going through
370 the linking stage */
371 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
372
373 /* Flags for listening sockets
374 */
375 #define LSTN_PUBLIC 0x000001 /* No access restrictions */
376
377 /* chan & global */
378 #define FLOOD_PRIVMSG 0
379 #define FLOOD_NOTICE 1
380 #define FLOOD_CTCP 2
381 #define FLOOD_NICK 3
382 #define FLOOD_JOIN 4
383 #define FLOOD_KICK 5
384 #define FLOOD_DEOP 6
385
386 #define FLOOD_CHAN_MAX 7
387 #define FLOOD_GLOBAL_MAX 3
388
389 /* For local console: */
390 #define STDIN 0
391 #define STDOUT 1
392 #define STDERR 2
393
394 /* Logfile display flags
395 */
396 #define LOG_MSGS 0x000001 /* m msgs/notice/ctcps */
397 #define LOG_PUBLIC 0x000002 /* p public msg/notice/ctcps */
398 #define LOG_JOIN 0x000004 /* j channel joins/parts/etc */
399 #define LOG_MODES 0x000008 /* k mode changes/kicks/bans */
400 #define LOG_CMDS 0x000010 /* c user dcc or msg commands */
401 #define LOG_MISC 0x000020 /* o other misc bot things */
402 #define LOG_BOTS 0x000040 /* b bot notices */
403 #define LOG_RAW 0x000080 /* r raw server stuff coming in */
404 #define LOG_FILES 0x000100 /* x file transfer commands and stats */
405 #define LOG_LEV1 0x000200 /* 1 user log level */
406 #define LOG_LEV2 0x000400 /* 2 user log level */
407 #define LOG_LEV3 0x000800 /* 3 user log level */
408 #define LOG_LEV4 0x001000 /* 4 user log level */
409 #define LOG_LEV5 0x002000 /* 5 user log level */
410 #define LOG_LEV6 0x004000 /* 6 user log level */
411 #define LOG_LEV7 0x008000 /* 7 user log level */
412 #define LOG_LEV8 0x010000 /* 8 user log level */
413 #define LOG_SERV 0x020000 /* s server information */
414 #define LOG_DEBUG 0x040000 /* d debug */
415 #define LOG_WALL 0x080000 /* w wallops */
416 #define LOG_SRVOUT 0x100000 /* v server output */
417 #define LOG_BOTNET 0x200000 /* t botnet traffic */
418 #define LOG_BOTSHARE 0x400000 /* h share traffic */
419 #define LOG_ALL 0x7fffff /* (dump to all logfiles) */
420
421 #define FILEDB_HIDE 1
422 #define FILEDB_UNHIDE 2
423 #define FILEDB_SHARE 3
424 #define FILEDB_UNSHARE 4
425
426 /* Socket flags:
427 */
428 #define SOCK_UNUSED 0x0001 /* empty socket */
429 #define SOCK_BINARY 0x0002 /* do not buffer input */
430 #define SOCK_LISTEN 0x0004 /* listening port */
431 #define SOCK_CONNECT 0x0008 /* connection attempt */
432 #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
433 #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
434 #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
435 #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
436 #define SOCK_PASS 0x0100 /* passed on; only notify in case
437 of traffic */
438 #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
439 #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
440
441 /* Flags to sock_has_data
442 */
443 enum {
444 SOCK_DATA_OUTGOING, /* Data in out-queue? */
445 SOCK_DATA_INCOMING /* Data in in-queue? */
446 };
447
448 /* Fake idx's for dprintf - these should be ridiculously large +ve nums
449 */
450 #define DP_STDOUT 0x7FF1
451 #define DP_LOG 0x7FF2
452 #define DP_SERVER 0x7FF3
453 #define DP_HELP 0x7FF4
454 #define DP_STDERR 0x7FF5
455 #define DP_MODE 0x7FF6
456 #define DP_MODE_NEXT 0x7FF7
457 #define DP_SERVER_NEXT 0x7FF8
458 #define DP_HELP_NEXT 0x7FF9
459
460 #define NORMAL 0
461 #define QUICK 1
462
463 /* Return codes for add_note */
464 #define NOTE_ERROR 0 /* error */
465 #define NOTE_OK 1 /* success */
466 #define NOTE_STORED 2 /* not online; stored */
467 #define NOTE_FULL 3 /* too many notes stored */
468 #define NOTE_TCL 4 /* tcl binding caught it */
469 #define NOTE_AWAY 5 /* away; stored */
470 #define NOTE_FWD 6 /* away; forwarded */
471 #define NOTE_REJECT 7 /* ignore mask matched */
472
473 #define STR_PROTECT 2
474 #define STR_DIR 1
475
476 #define HELP_DCC 1
477 #define HELP_TEXT 2
478 #define HELP_IRC 16
479
480 /* This is used by the net module to keep track of sockets and what's
481 * queued on them
482 */
483 typedef struct {
484 int sock;
485 short flags;
486 char *inbuf;
487 char *outbuf;
488 unsigned long outbuflen; /* Outbuf could be binary data */
489 unsigned long inbuflen; /* Inbuf could be binary data */
490 } sock_list;
491
492 enum {
493 EGG_OPTION_SET = 1, /* Set option(s). */
494 EGG_OPTION_UNSET = 2 /* Unset option(s). */
495 };
496
497 /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
498 * "TELNET Echo Option" (RFC 875) for details.
499 */
500
501 #define TLN_AYT 246 /* Are You There */
502
503 #define TLN_WILL 251 /* Will */
504 #define TLN_WILL_C "\373"
505 #define TLN_WONT 252 /* Won't */
506 #define TLN_WONT_C "\374"
507 #define TLN_DO 253 /* Do */
508 #define TLN_DO_C "\375"
509 #define TLN_DONT 254 /* Don't */
510 #define TLN_DONT_C "\376"
511 #define TLN_IAC 255 /* Interpret As Command */
512 #define TLN_IAC_C "\377"
513
514 #define TLN_ECHO 1 /* Echo */
515 #define TLN_ECHO_C "\001"
516
517 #endif /* _EGG_EGGDROP_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23