/[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.9 - (show annotations) (download) (as text)
Tue Jun 18 06:12:32 2002 UTC (17 years, 6 months ago) by guppy
Branch: MAIN
Changes since 1.8: +1 -12 lines
File MIME type: text/x-csrc

- removed userflag +k
- removed userflag +h
- removed all the code related to .strip since stdarg is going to redo it in a
better fashion using network filters.
- removed woobie since woobie is useless and we would be much better suited with
a "sample" module that actually does something useful

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: egg.h,v 1.8 2002/05/09 07:37:49 stdarg Exp $
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 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_callback_b;
282
283 struct script_info {
284 struct dcc_table *type;
285 union {
286 struct chat_info *chat;
287 struct file_info *file;
288 void *other;
289 } u;
290 struct script_callback_b *callback;
291 };
292
293 struct dns_info {
294 void (*dns_success)(int); /* is called if the dns request succeeds */
295 void (*dns_failure)(int); /* is called if it fails */
296 char *host; /* hostname or IP addr (as string) */
297 char *cbuf; /* temporary buffer. Memory will be free'd
298 as soon as dns_info is free'd */
299 char *cptr; /* temporary pointer */
300 int ibuf; /* temporary buffer for one integer */
301 char dns_type; /* lookup type, e.g. RES_HOSTBYIP */
302 struct dcc_table *type; /* type of the dcc table we are making the
303 lookup for */
304 };
305
306 struct dupwait_info {
307 int atr; /* the bots attributes */
308 struct chat_info *chat; /* holds current chat data */
309 };
310
311 /* Flags about dcc types
312 */
313 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet
314 chatter */
315 #define DCT_MASTER 0x00000002 /* received master chatter */
316 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
317 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
318 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to
319 in tcl */
320 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
321 #define DCT_CANBOOT 0x00000040 /* can be booted */
322 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
323 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
324 #define DCT_FORKTYPE 0x00000100 /* a forking type */
325 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
326 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
327 #define DCT_FILESEND 0x00000800 /* a sending file transfer,
328 getting = !this */
329 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
330
331 /* For dcc chat & files:
332 */
333 #define STAT_ECHO 0x00001 /* echo commands back? */
334 #define STAT_DENY 0x00002 /* bad username (ignore password & deny
335 access) */
336 #define STAT_CHAT 0x00004 /* in file-system but may return */
337 #define STAT_TELNET 0x00008 /* connected via telnet */
338 #define STAT_PARTY 0x00010 /* only on party line via 'p' flag */
339 #define STAT_BOTONLY 0x00020 /* telnet on bots-only connect */
340 #define STAT_USRONLY 0x00040 /* telnet on users-only connect */
341 #define STAT_PAGE 0x00080 /* page output to the user */
342
343 /* for dcc bot links: */
344 #define STAT_PINGED 0x00001 /* waiting for ping to return */
345 #define STAT_SHARE 0x00002 /* sharing user data with the bot */
346 #define STAT_CALLED 0x00004 /* this bot called me */
347 #define STAT_OFFERED 0x00008 /* offered her the user file */
348 #define STAT_SENDING 0x00010 /* in the process of sending a user list */
349 #define STAT_GETTING 0x00020 /* in the process of getting a user list */
350 #define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
351 #define STAT_LEAF 0x00080 /* this bot is a leaf only */
352 #define STAT_LINKING 0x00100 /* the bot is currently going through
353 the linking stage */
354 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
355
356 /* Flags for listening sockets
357 */
358 #define LSTN_PUBLIC 0x000001 /* No access restrictions */
359
360 /* chan & global */
361 #define FLOOD_PRIVMSG 0
362 #define FLOOD_NOTICE 1
363 #define FLOOD_CTCP 2
364 #define FLOOD_NICK 3
365 #define FLOOD_JOIN 4
366 #define FLOOD_KICK 5
367 #define FLOOD_DEOP 6
368
369 #define FLOOD_CHAN_MAX 7
370 #define FLOOD_GLOBAL_MAX 3
371
372 /* For local console: */
373 #define STDIN 0
374 #define STDOUT 1
375 #define STDERR 2
376
377 /* Socket flags:
378 */
379 #define SOCK_UNUSED 0x0001 /* empty socket */
380 #define SOCK_BINARY 0x0002 /* do not buffer input */
381 #define SOCK_LISTEN 0x0004 /* listening port */
382 #define SOCK_CONNECT 0x0008 /* connection attempt */
383 #define SOCK_NONSOCK 0x0010 /* used for file i/o on debug */
384 #define SOCK_STRONGCONN 0x0020 /* don't report success until sure */
385 #define SOCK_EOFD 0x0040 /* it EOF'd recently during a write */
386 #define SOCK_PROXYWAIT 0x0080 /* waiting for SOCKS traversal */
387 #define SOCK_PASS 0x0100 /* passed on; only notify in case
388 of traffic */
389 #define SOCK_VIRTUAL 0x0200 /* not-connected socket (dont read it!) */
390 #define SOCK_BUFFER 0x0400 /* buffer data; don't notify dcc funcs */
391
392 /* Flags to sock_has_data
393 */
394 enum {
395 SOCK_DATA_OUTGOING, /* Data in out-queue? */
396 SOCK_DATA_INCOMING /* Data in in-queue? */
397 };
398
399 /* Fake idx's for dprintf - these should be ridiculously large +ve nums
400 */
401 #define DP_STDOUT 0x7FF1
402 #define DP_LOG 0x7FF2
403 #define DP_SERVER 0x7FF3
404 #define DP_HELP 0x7FF4
405 #define DP_STDERR 0x7FF5
406 #define DP_MODE 0x7FF6
407 #define DP_MODE_NEXT 0x7FF7
408 #define DP_SERVER_NEXT 0x7FF8
409 #define DP_HELP_NEXT 0x7FF9
410
411 /* Return codes for add_note */
412 #define NOTE_ERROR 0 /* error */
413 #define NOTE_OK 1 /* success */
414 #define NOTE_STORED 2 /* not online; stored */
415 #define NOTE_FULL 3 /* too many notes stored */
416 #define NOTE_TCL 4 /* tcl binding caught it */
417 #define NOTE_AWAY 5 /* away; stored */
418 #define NOTE_FWD 6 /* away; forwarded */
419 #define NOTE_REJECT 7 /* ignore mask matched */
420
421 #define STR_PROTECT 2
422 #define STR_DIR 1
423
424 /* This is used by the net module to keep track of sockets and what's
425 * queued on them
426 */
427 typedef struct {
428 int sock;
429 short flags;
430 char *inbuf;
431 char *outbuf;
432 unsigned long outbuflen; /* Outbuf could be binary data */
433 unsigned long inbuflen; /* Inbuf could be binary data */
434 } sock_list;
435
436 enum {
437 EGG_OPTION_SET = 1, /* Set option(s). */
438 EGG_OPTION_UNSET = 2 /* Unset option(s). */
439 };
440
441 /* Telnet codes. See "TELNET Protocol Specification" (RFC 854) and
442 * "TELNET Echo Option" (RFC 875) for details.
443 */
444
445 #define TLN_AYT 246 /* Are You There */
446
447 #define TLN_WILL 251 /* Will */
448 #define TLN_WILL_C "\373"
449 #define TLN_WONT 252 /* Won't */
450 #define TLN_WONT_C "\374"
451 #define TLN_DO 253 /* Do */
452 #define TLN_DO_C "\375"
453 #define TLN_DONT 254 /* Don't */
454 #define TLN_DONT_C "\376"
455 #define TLN_IAC 255 /* Interpret As Command */
456 #define TLN_IAC_C "\377"
457
458 #define TLN_ECHO 1 /* Echo */
459 #define TLN_ECHO_C "\001"
460
461 #endif /* !_EGG_EGG_H */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23