/[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.3 - (show annotations) (download) (as text)
Sat Jan 19 20:08:58 2002 UTC (17 years, 10 months ago) by ite
Branch: MAIN
Changes since 1.2: +1 -49 lines
File MIME type: text/x-csrc
* varoius header inclusion cleanups
* moved FILEDB* defines from src/egg.h to a more suitable place in modules/filesys/filesys.h
* moved NORMAL and QUICK defines from src/egg.h to a more suitable place in modules/irc/irc.h
* fixed a warning in modules/perlscript/perlscript.c
* created src/misc.h and src/logfile.h. Moved in them the respective prototypes from src/proto.h, and the respective defines from src/egg.h
* moved private structures from src/dns.h to src/dns.c
* moved src/dns.c's related prototypes from src/egg.h to src/dns.h
* moved RES_* defines from src/egg.h to dns.h
* removed some unneeded defines here and there
* moved LOG_* defines from src/egg.h to src/logfile.h
* dns_events wasn't static

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.2 2002/01/16 22:09:43 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 BADHANDCHARS "-,+*=:!.@#;$%&"
60
61
62 /*
63 * The 'configure' script should make this next part automatic,
64 * so you shouldn't need to adjust anything below.
65 */
66
67 #define NICKLEN NICKMAX + 1
68 #define UHOSTLEN UHOSTMAX + 1
69 #define NOTENAMELEN ((HANDLEN * 2) + 1)
70 #define BADNICKCHARS "-,+*=:!.@#;$%&"
71
72
73 /* Gettext stuff */
74 #ifdef ENABLE_NLS
75 # include <libintl.h>
76 # define _(x) gettext(x)
77 # define N_(x) gettext_noop (x)
78 #else
79 # define N_(x) (x)
80 # define _(x) (x)
81 #endif
82
83 #ifdef HAVE_UNISTD_H
84 # include <unistd.h>
85 #endif
86
87 #define ADDRLEN (ADDRMAX + 1)
88
89 #if (NICKMAX < 9) || (NICKMAX > 32)
90 # include "invalid NICKMAX value"
91 #endif
92
93 #if (HANDLEN < 9) || (HANDLEN > 32)
94 # include "invalid HANDLEN value"
95 #endif
96
97 #if HANDLEN > NICKMAX
98 # include "HANDLEN MUST BE <= NICKMAX"
99 #endif
100
101 /* NAME_MAX is what POSIX defines, but BSD calls it MAXNAMLEN.
102 * Use 255 if we can't find anything else.
103 */
104 #ifndef NAME_MAX
105 # ifdef MAXNAMLEN
106 # define NAME_MAX MAXNAMLEN
107 # else
108 # define NAME_MAX 255
109 # endif
110 #endif
111
112 /* Almost every module needs some sort of time thingy, so... */
113 #if TIME_WITH_SYS_TIME
114 # include <sys/time.h>
115 # include <time.h>
116 #else
117 # if HAVE_SYS_TIME_H
118 # include <sys/time.h>
119 # else
120 # include <time.h>
121 # endif
122 #endif
123
124 #ifndef HAVE_SRANDOM
125 # define srandom(x) srand(x)
126 #endif
127
128 #ifndef HAVE_RANDOM
129 # define random() (rand()/16)
130 #endif
131
132 #ifndef HAVE_SIGACTION /* old "weird signals" */
133 # define sigaction sigvec
134 # ifndef sa_handler
135 # define sa_handler sv_handler
136 # define sa_mask sv_mask
137 # define sa_flags sv_flags
138 # endif
139 #endif
140
141 #ifndef HAVE_SIGEMPTYSET
142 /* and they probably won't have sigemptyset, dammit */
143 # define sigemptyset(x) ((*(int *)(x))=0)
144 #endif
145
146
147 /* 32 bit type
148 */
149 #ifdef UNSIGNED_LONG32
150 typedef unsigned long u_32int_t;
151 #else
152 # ifdef UNSIGNED_INT32
153 typedef unsigned int u_32int_t;
154 # else
155 typedef unsigned long u_32int_t;
156 # endif
157 #endif
158
159 typedef unsigned short int u_16bit_t;
160 typedef unsigned char u_8bit_t;
161
162 /* IP type */
163 typedef u_32int_t IP;
164
165 #define debug0(x) putlog(LOG_DEBUG,"*",x)
166 #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
167 #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
168 #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
169 #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
170
171 /***********************************************************************/
172
173 /* It's used in so many places, let's put it here */
174 typedef int (*Function) ();
175
176 /* Public structure for the listening port map */
177 struct portmap {
178 int realport;
179 int mappedto;
180 struct portmap *next;
181 };
182
183 /* Public structure of all the dcc connections */
184 struct dcc_table {
185 char *name;
186 int flags;
187 void (*eof) (int);
188 void (*activity) (int, char *, int);
189 int *timeout_val;
190 void (*timeout) ();
191 void (*display) (int, char *);
192 void (*kill) (int, void *);
193 void (*output) (int, char *, void *);
194 void (*outdone) (int);
195 };
196
197 struct userrec;
198
199 struct dcc_t {
200 long sock; /* This should be a long to keep 64-bit
201 machines sane */
202 char addr[ADDRLEN]; /* IPv4/v6 address as string :) */
203 unsigned int port;
204 struct userrec *user;
205 char nick[NICKLEN];
206 char host[UHOSTLEN];
207 struct dcc_table *type;
208 time_t timeval; /* Use for any timing stuff
209 - this is used for timeout checking */
210 unsigned long status; /* A LOT of dcc types have status
211 thingos, this makes it more avaliabe */
212 union {
213 struct chat_info *chat;
214 struct file_info *file;
215 struct edit_info *edit;
216 struct xfer_info *xfer;
217 struct bot_info *bot;
218 struct relay_info *relay;
219 struct script_info *script;
220 struct dns_info *dns;
221 struct dupwait_info *dupwait;
222 int ident_sock;
223 void *other;
224 } u; /* Special use depending on type */
225 };
226
227 struct chat_info {
228 char *away; /* non-NULL if user is away */
229 int msgs_per_sec; /* used to stop flooding */
230 int con_flags; /* with console: what to show */
231 int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
232 char con_chan[81]; /* with console: what channel to view */
233 int channel; /* 0=party line, -1=off */
234 struct msgq *buffer; /* a buffer of outgoing lines
235 (for .page cmd) */
236 int max_line; /* maximum lines at once */
237 int line_count; /* number of lines sent since last page */
238 int current_lines; /* number of lines total stored */
239 char *su_nick;
240 };
241
242 struct file_info {
243 struct chat_info *chat;
244 char dir[161];
245 };
246
247 struct xfer_info {
248 char *filename;
249 char *origname;
250 char dir[121]; /* used when uploads go to the current dir */
251 unsigned long length;
252 unsigned long acked;
253 char buf[4]; /* you only need 5 bytes! */
254 unsigned char sofar; /* how much of the byte count received */
255 char from[NICKLEN]; /* [GET] user who offered the file */
256 FILE *f; /* pointer to file being sent/received */
257 unsigned int type; /* xfer connection type, see enum below */
258 unsigned short ack_type; /* type of ack */
259 unsigned long offset; /* offset from beginning of file, during
260 resend. */
261 unsigned long block_pending; /* bytes of this DCC block which weren't
262 sent yet. */
263 time_t start_time; /* Time when a xfer was started. */
264 };
265
266 struct bot_info {
267 char version[121]; /* channel/version info */
268 char linker[NOTENAMELEN + 1]; /* who requested this link */
269 int numver;
270 int port; /* base port */
271 int uff_flags; /* user file feature flags */
272 };
273
274 struct relay_info {
275 struct chat_info *chat;
276 int sock;
277 int port;
278 int old_status;
279 };
280
281 struct script_info {
282 struct dcc_table *type;
283 union {
284 struct chat_info *chat;
285 struct file_info *file;
286 void *other;
287 } u;
288 char command[121];
289 };
290
291 struct dns_info {
292 void (*dns_success)(int); /* is called if the dns request succeeds */
293 void (*dns_failure)(int); /* is called if it fails */
294 char *host; /* hostname or IP addr (as string) */
295 char *cbuf; /* temporary buffer. Memory will be free'd
296 as soon as dns_info is free'd */
297 char *cptr; /* temporary pointer */
298 int ibuf; /* temporary buffer for one integer */
299 char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
300 struct dcc_table *type; /* type of the dcc table we are making the
301 lookup for */
302 };
303
304 struct dupwait_info {
305 int atr; /* the bots attributes */
306 struct chat_info *chat; /* holds current chat data */
307 };
308
309 /* Flags about dcc types
310 */
311 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
312 chatter */
313 #define DCT_MASTER 0x00000002 /* received master chatter */
314 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
315 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
316 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
317 in tcl */
318 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
319 #define DCT_CANBOOT 0x00000040 /* can be booted */
320 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
321 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
322 #define DCT_FORKTYPE 0x00000100 /* a forking type */
323 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
324 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
325 #define DCT_FILESEND 0x00000800 /* a sending file transfer,
326 getting = !this */
327 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
328
329 /* For dcc chat & files:
330 */
331 #define STAT_ECHO 0x00001 /* echo commands back? */
332 #define STAT_DENY 0x00002 /* bad username (ignore password & deny
333 access) */
334 #define STAT_CHAT 0x00004 /* in file-system but may return */
335 #define STAT_TELNET 0x00008 /* connected via telnet */
336 #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
337 #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
338 #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
339 #define STAT_PAGE 0x00080 /* page output to the user */
340
341 /* For stripping out mIRC codes
342 */
343 #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
344 #define STRIP_BOLD 0x00002 /* remove bold codes */
345 #define STRIP_REV 0x00004 /* remove reverse video codes */
346 #define STRIP_UNDER 0x00008 /* remove underline codes */
347 #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
348 #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
349 #define STRIP_ALL 0x00040 /* remove every damn thing! */
350
351 /* for dcc bot links: */
352 #define STAT_PINGED 0x00001 /* waiting for ping to return */
353 #define STAT_SHARE 0x00002 /* sharing user data with the bot */
354 #define STAT_CALLED 0x00004 /* this bot called me */
355 #define STAT_OFFERED 0x00008 /* offered her the user file */
356 #define STAT_SENDING 0x00010 /* in the process of sending a user list */
357 #define STAT_GETTING 0x00020 /* in the process of getting a user list */
358 #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
359 #define STAT_LEAF 0x00080 /* this bot is a leaf only */
360 #define STAT_LINKING 0x00100 /* the bot is currently going through
361 the linking stage */
362 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
363
364 /* Flags for listening sockets
365 */
366 #define LSTN_PUBLIC 0x000001 /* No access restrictions */
367
368 /* chan & global */
369 #define FLOOD_PRIVMSG 0
370 #define FLOOD_NOTICE 1
371 #define FLOOD_CTCP 2
372 #define FLOOD_NICK 3
373 #define FLOOD_JOIN 4
374 #define FLOOD_KICK 5
375 #define FLOOD_DEOP 6
376
377 #define FLOOD_CHAN_MAX 7
378 #define FLOOD_GLOBAL_MAX 3
379
380 /* For local console: */
381 #define STDIN 0
382 #define STDOUT 1
383 #define STDERR 2
384
385 /* Socket flags:
386 */
387 #define SOCK_UNUSED 0x0001 /* empty socket */
388 #define SOCK_BINARY 0x0002 /* do not buffer input */
389 #define SOCK_LISTEN 0x0004 /* listening port */
390 #define SOCK_CONNECT 0x0008 /* connection attempt */
391 #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
392 #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
393 #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
394 #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
395 #define SOCK_PASS 0x0100 /* passed on; only notify in case
396 of traffic */
397 #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
398 #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
399
400 /* Flags to sock_has_data
401 */
402 enum {
403 SOCK_DATA_OUTGOING, /* Data in out-queue? */
404 SOCK_DATA_INCOMING /* Data in in-queue? */
405 };
406
407 /* Fake idx's for dprintf - these should be ridiculously large +ve nums
408 */
409 #define DP_STDOUT 0x7FF1
410 #define DP_LOG 0x7FF2
411 #define DP_SERVER 0x7FF3
412 #define DP_HELP 0x7FF4
413 #define DP_STDERR 0x7FF5
414 #define DP_MODE 0x7FF6
415 #define DP_MODE_NEXT 0x7FF7
416 #define DP_SERVER_NEXT 0x7FF8
417 #define DP_HELP_NEXT 0x7FF9
418
419 /* Return codes for add_note */
420 #define NOTE_ERROR 0 /* error */
421 #define NOTE_OK 1 /* success */
422 #define NOTE_STORED 2 /* not online; stored */
423 #define NOTE_FULL 3 /* too many notes stored */
424 #define NOTE_TCL 4 /* tcl binding caught it */
425 #define NOTE_AWAY 5 /* away; stored */
426 #define NOTE_FWD 6 /* away; forwarded */
427 #define NOTE_REJECT 7 /* ignore mask matched */
428
429 #define STR_PROTECT 2
430 #define STR_DIR 1
431
432 /* This is used by the net module to keep track of sockets and what's
433 * queued on them
434 */
435 typedef struct {
436 int sock;
437 short flags;
438 char *inbuf;
439 char *outbuf;
440 unsigned long outbuflen; /* Outbuf could be binary data */
441 unsigned long inbuflen; /* Inbuf could be binary data */
442 } sock_list;
443
444 enum {
445 EGG_OPTION_SET = 1, /* Set option(s). */
446 EGG_OPTION_UNSET = 2 /* Unset option(s). */
447 };
448
449 /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
450 * "TELNET Echo Option" (RFC 875) for details.
451 */
452
453 #define TLN_AYT 246 /* Are You There */
454
455 #define TLN_WILL 251 /* Will */
456 #define TLN_WILL_C "\373"
457 #define TLN_WONT 252 /* Won't */
458 #define TLN_WONT_C "\374"
459 #define TLN_DO 253 /* Do */
460 #define TLN_DO_C "\375"
461 #define TLN_DONT 254 /* Don't */
462 #define TLN_DONT_C "\376"
463 #define TLN_IAC 255 /* Interpret As Command */
464 #define TLN_IAC_C "\377"
465
466 #define TLN_ECHO 1 /* Echo */
467 #define TLN_ECHO_C "\001"
468
469 #endif /* _EGG_EGGDROP_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23