/[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.18 - (show annotations) (download) (as text)
Sun May 11 02:40:28 2003 UTC (16 years, 7 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.17: +1 -1 lines
File MIME type: text/x-csrc
FILE REMOVED
* Remove some stray files

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23