/[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.7 - (show annotations) (download) (as text)
Sun May 5 16:40:38 2002 UTC (17 years, 8 months ago) by tothwolf
Branch: MAIN
Changes since 1.6: +16 -14 lines
File MIME type: text/x-csrc
Grafted GPL header onto newer files.
Storing rcsid in binary files now.

1 /*
2 * egg.h --
3 *
4 * Eggdrop compile-time settings
5 *
6 * IF YOU ALTER THIS FILE, YOU NEED TO RECOMPILE THE BOT.
7 */
8 /*
9 * Copyright (C) 1997 Robey Pointer
10 * Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26 /*
27 * $Id$
28 */
29
30 #ifndef _EGG_EGG_H
31 #define _EGG_EGG_H
32
33 /*
34 * If you're *only* going to link to new version bots (1.3.0 or higher)
35 * then you can safely define this.
36 */
37 #undef NO_OLD_BOTNET
38
39 /*
40 * HANDLEN note:
41 * HANDLEN defines the maximum length a handle on the bot can be.
42 * Standard (and minimum) is 9 characters long.
43 *
44 * Beware that using lengths over 9 chars is 'non-standard' and if
45 * you wish to link to other bots, they _must_ both have the same
46 * maximum handle length.
47 *
48 * NICKMAX note:
49 * You should leave this at 32 characters and modify nick-len in the
50 * configuration file instead.
51 */
52
53 #define HANDLEN 9 /* valid values 9->NICKMAX */
54 #define NICKMAX 32 /* valid values HANDLEN->32 */
55
56
57 /* Handy string lengths */
58
59 #define ADDRMAX 45
60 #define UHOSTMAX 160 /* reasonable, i think? */
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 NOTENAMELEN ((HANDLEN * 2) + 1)
72 #define BADNICKCHARS "-,+*=:!.@#;$%&"
73
74
75 /* Gettext stuff */
76 #ifdef ENABLE_NLS
77 # include <libintl.h>
78 # define _(x) gettext(x)
79 # define N_(x) gettext_noop(x)
80 # define P_(x1, x2, n) ngettext(x1, x2, n)
81 #else
82 # define _(x) (x)
83 # define N_(x) (x)
84 # define P_(x1, x2, n) ( ((n)!=1) ? (x2) : (x1) )
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 /* Public structure for the listening port map */
178 struct portmap {
179 int realport;
180 int mappedto;
181 struct portmap *next;
182 };
183
184 /* Public structure of all the dcc connections */
185 struct dcc_table {
186 char *name;
187 int flags;
188 void (*eof) (int);
189 void (*activity) (int, char *, int);
190 int *timeout_val;
191 void (*timeout) ();
192 void (*display) (int, char *);
193 void (*kill) (int, void *);
194 void (*output) (int, char *, void *);
195 void (*outdone) (int);
196 };
197
198 struct userrec;
199
200 struct dcc_t {
201 long sock; /* This should be a long to keep 64-bit
202 machines sane */
203 char addr[ADDRLEN]; /* IPv4/v6 address as string :) */
204 unsigned int port;
205 struct userrec *user;
206 char nick[NICKLEN];
207 char host[UHOSTLEN];
208 struct dcc_table *type;
209 time_t timeval; /* Use for any timing stuff
210 - this is used for timeout checking */
211 unsigned long status; /* A LOT of dcc types have status
212 thingos, this makes it more avaliabe */
213 union {
214 struct chat_info *chat;
215 struct file_info *file;
216 struct edit_info *edit;
217 struct xfer_info *xfer;
218 struct bot_info *bot;
219 struct relay_info *relay;
220 struct script_info *script;
221 struct dns_info *dns;
222 struct dupwait_info *dupwait;
223 int ident_sock;
224 void *other;
225 } u; /* Special use depending on type */
226 };
227
228 struct chat_info {
229 char *away; /* non-NULL if user is away */
230 int msgs_per_sec; /* used to stop flooding */
231 int con_flags; /* with console: what to show */
232 int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
233 char con_chan[81]; /* with console: what channel to view */
234 int channel; /* 0=party line, -1=off */
235 struct msgq *buffer; /* a buffer of outgoing lines
236 (for .page cmd) */
237 int max_line; /* maximum lines at once */
238 int line_count; /* number of lines sent since last page */
239 int current_lines; /* number of lines total stored */
240 char *su_nick;
241 };
242
243 struct file_info {
244 struct chat_info *chat;
245 char dir[161];
246 };
247
248 struct xfer_info {
249 char *filename;
250 char *origname;
251 char dir[121]; /* used when uploads go to the current dir */
252 unsigned long length;
253 unsigned long acked;
254 char buf[4]; /* you only need 5 bytes! */
255 unsigned char sofar; /* how much of the byte count received */
256 char from[NICKLEN]; /* [GET] user who offered the file */
257 FILE *f; /* pointer to file being sent/received */
258 unsigned int type; /* xfer connection type, see enum below */
259 unsigned short ack_type; /* type of ack */
260 unsigned long offset; /* offset from beginning of file, during
261 resend. */
262 unsigned long block_pending; /* bytes of this DCC block which weren't
263 sent yet. */
264 time_t start_time; /* Time when a xfer was started. */
265 };
266
267 struct bot_info {
268 char version[121]; /* channel/version info */
269 char linker[NOTENAMELEN + 1]; /* who requested this link */
270 int numver;
271 int port; /* base port */
272 int uff_flags; /* user file feature flags */
273 };
274
275 struct relay_info {
276 struct chat_info *chat;
277 int sock;
278 int port;
279 int old_status;
280 };
281
282 struct script_info {
283 struct dcc_table *type;
284 union {
285 struct chat_info *chat;
286 struct file_info *file;
287 void *other;
288 } u;
289 char command[121];
290 };
291
292 struct dns_info {
293 void (*dns_success)(int); /* is called if the dns request succeeds */
294 void (*dns_failure)(int); /* is called if it fails */
295 char *host; /* hostname or IP addr (as string) */
296 char *cbuf; /* temporary buffer. Memory will be free'd
297 as soon as dns_info is free'd */
298 char *cptr; /* temporary pointer */
299 int ibuf; /* temporary buffer for one integer */
300 char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
301 struct dcc_table *type; /* type of the dcc table we are making the
302 lookup for */
303 };
304
305 struct dupwait_info {
306 int atr; /* the bots attributes */
307 struct chat_info *chat; /* holds current chat data */
308 };
309
310 /* Flags about dcc types
311 */
312 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
313 chatter */
314 #define DCT_MASTER 0x00000002 /* received master chatter */
315 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
316 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
317 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
318 in tcl */
319 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
320 #define DCT_CANBOOT 0x00000040 /* can be booted */
321 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
322 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
323 #define DCT_FORKTYPE 0x00000100 /* a forking type */
324 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
325 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
326 #define DCT_FILESEND 0x00000800 /* a sending file transfer,
327 getting = !this */
328 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
329
330 /* For dcc chat & files:
331 */
332 #define STAT_ECHO 0x00001 /* echo commands back? */
333 #define STAT_DENY 0x00002 /* bad username (ignore password & deny
334 access) */
335 #define STAT_CHAT 0x00004 /* in file-system but may return */
336 #define STAT_TELNET 0x00008 /* connected via telnet */
337 #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
338 #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
339 #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
340 #define STAT_PAGE 0x00080 /* page output to the user */
341
342 /* For stripping out mIRC codes
343 */
344 #define STRIP_COLOR 0x00001 /* remove mIRC color codes */
345 #define STRIP_BOLD 0x00002 /* remove bold codes */
346 #define STRIP_REV 0x00004 /* remove reverse video codes */
347 #define STRIP_UNDER 0x00008 /* remove underline codes */
348 #define STRIP_ANSI 0x00010 /* remove ALL ansi codes */
349 #define STRIP_BELLS 0x00020 /* remote ctrl-g's */
350 #define STRIP_ALL 0x00040 /* remove every damn thing! */
351
352 /* for dcc bot links: */
353 #define STAT_PINGED 0x00001 /* waiting for ping to return */
354 #define STAT_SHARE 0x00002 /* sharing user data with the bot */
355 #define STAT_CALLED 0x00004 /* this bot called me */
356 #define STAT_OFFERED 0x00008 /* offered her the user file */
357 #define STAT_SENDING 0x00010 /* in the process of sending a user list */
358 #define STAT_GETTING 0x00020 /* in the process of getting a user list */
359 #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
360 #define STAT_LEAF 0x00080 /* this bot is a leaf only */
361 #define STAT_LINKING 0x00100 /* the bot is currently going through
362 the linking stage */
363 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
364
365 /* Flags for listening sockets
366 */
367 #define LSTN_PUBLIC 0x000001 /* No access restrictions */
368
369 /* chan & global */
370 #define FLOOD_PRIVMSG 0
371 #define FLOOD_NOTICE 1
372 #define FLOOD_CTCP 2
373 #define FLOOD_NICK 3
374 #define FLOOD_JOIN 4
375 #define FLOOD_KICK 5
376 #define FLOOD_DEOP 6
377
378 #define FLOOD_CHAN_MAX 7
379 #define FLOOD_GLOBAL_MAX 3
380
381 /* For local console: */
382 #define STDIN 0
383 #define STDOUT 1
384 #define STDERR 2
385
386 /* Socket flags:
387 */
388 #define SOCK_UNUSED 0x0001 /* empty socket */
389 #define SOCK_BINARY 0x0002 /* do not buffer input */
390 #define SOCK_LISTEN 0x0004 /* listening port */
391 #define SOCK_CONNECT 0x0008 /* connection attempt */
392 #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
393 #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
394 #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
395 #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
396 #define SOCK_PASS 0x0100 /* passed on; only notify in case
397 of traffic */
398 #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
399 #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
400
401 /* Flags to sock_has_data
402 */
403 enum {
404 SOCK_DATA_OUTGOING, /* Data in out-queue? */
405 SOCK_DATA_INCOMING /* Data in in-queue? */
406 };
407
408 /* Fake idx's for dprintf - these should be ridiculously large +ve nums
409 */
410 #define DP_STDOUT 0x7FF1
411 #define DP_LOG 0x7FF2
412 #define DP_SERVER 0x7FF3
413 #define DP_HELP 0x7FF4
414 #define DP_STDERR 0x7FF5
415 #define DP_MODE 0x7FF6
416 #define DP_MODE_NEXT 0x7FF7
417 #define DP_SERVER_NEXT 0x7FF8
418 #define DP_HELP_NEXT 0x7FF9
419
420 /* Return codes for add_note */
421 #define NOTE_ERROR 0 /* error */
422 #define NOTE_OK 1 /* success */
423 #define NOTE_STORED 2 /* not online; stored */
424 #define NOTE_FULL 3 /* too many notes stored */
425 #define NOTE_TCL 4 /* tcl binding caught it */
426 #define NOTE_AWAY 5 /* away; stored */
427 #define NOTE_FWD 6 /* away; forwarded */
428 #define NOTE_REJECT 7 /* ignore mask matched */
429
430 #define STR_PROTECT 2
431 #define STR_DIR 1
432
433 /* This is used by the net module to keep track of sockets and what's
434 * queued on them
435 */
436 typedef struct {
437 int sock;
438 short flags;
439 char *inbuf;
440 char *outbuf;
441 unsigned long outbuflen; /* Outbuf could be binary data */
442 unsigned long inbuflen; /* Inbuf could be binary data */
443 } sock_list;
444
445 enum {
446 EGG_OPTION_SET = 1, /* Set option(s). */
447 EGG_OPTION_UNSET = 2 /* Unset option(s). */
448 };
449
450 /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
451 * "TELNET Echo Option" (RFC 875) for details.
452 */
453
454 #define TLN_AYT 246 /* Are You There */
455
456 #define TLN_WILL 251 /* Will */
457 #define TLN_WILL_C "\373"
458 #define TLN_WONT 252 /* Won't */
459 #define TLN_WONT_C "\374"
460 #define TLN_DO 253 /* Do */
461 #define TLN_DO_C "\375"
462 #define TLN_DONT 254 /* Don't */
463 #define TLN_DONT_C "\376"
464 #define TLN_IAC 255 /* Interpret As Command */
465 #define TLN_IAC_C "\377"
466
467 #define TLN_ECHO 1 /* Echo */
468 #define TLN_ECHO_C "\001"
469
470 #endif /* !_EGG_EGG_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23