/[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.6 - (show annotations) (download) (as text)
Fri Mar 22 16:01:20 2002 UTC (17 years, 8 months ago) by ite
Branch: MAIN
Changes since 1.5: +1 -4 lines
File MIME type: text/x-csrc
* Created eggdrop's library context.
* Moved registry stuff to libeggdrop.
* Some headers vs. prototypes cleanups.

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23