/[cvs]/eggdrop1.4/src/eggdrop.h
ViewVC logotype

Contents of /eggdrop1.4/src/eggdrop.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.15 - (show annotations) (download) (as text)
Tue Dec 14 21:00:05 1999 UTC (19 years, 11 months ago) by guppy
Branch: MAIN
Changes since 1.14: +1 -1 lines
File MIME type: text/x-csrc
assert nulls patch, 1.4.1 is only 3 days away

1 /*
2 * EGGDROP compile-time settings
3 *
4 * IF YOU ALTER THIS FILE, YOU NEED TO RECOMPILE THE BOT.
5 */
6 /*
7 * This file is part of the eggdrop source code
8 * copyright (c) 1997 Robey Pointer
9 * and is distributed according to the GNU general public license.
10 * For full details, read the top of 'main.c' or the file called
11 * COPYING that was distributed with this code.
12 */
13
14 #ifndef _H_EGGDROP
15 #define _H_EGGDROP
16
17 /*
18 * If you're *only* going to link to new version bots (1.3.0 or higher)
19 * then you can safely define this.
20 */
21 #undef NO_OLD_BOTNET
22
23 /*
24 * Undefine this to completely disable context debugging.
25 * WARNING: DO NOT send in bug reports if you undefine this!
26 */
27 #define DEBUG_CONTEXT
28
29 /*
30 * define the maximum length a handle on the bot can be.
31 * (standard is 9 characters long)
32 * (DO NOT MAKE THIS VALUE LESS THAN 9 UNLESS YOU WANT TROUBLE!)
33 * (beware that using lengths over 9 chars is 'non-standard' and if you
34 * wish to link to other bots, they _must_ both have the same maximum
35 * handle length)
36 */
37
38 /* handy string lengths */
39
40 #define HANDLEN 9 /* valid values 9->NICKMAX */
41 #define BADHANDCHARS "-,+*=:!.@#;$%&"
42 #define NICKMAX 9 /* valid values HANDLEN->32 */
43 #define UHOSTMAX 160 /* reasonable, i think? */
44 #define DIRMAX 256 /* paranoia */
45 #define MAX_LOG_LINE 767 /* for misc.c/putlog() <cybah> */
46
47 /* language stuff */
48
49 #define LANGDIR "./language" /* language file directory */
50 #define BASELANG "english" /* language which always gets loaded before
51 all other languages. You don't want to
52 change this. */
53
54 /***********************************************************************/
55 /***** the 'configure' script should make this next part automatic *****/
56 /***********************************************************************/
57
58 #define NICKLEN NICKMAX + 1
59 #define UHOSTLEN UHOSTMAX + 1
60 #define DIRLEN DIRMAX + 1
61 #define NOTENAMELEN ((HANDLEN * 2) + 1)
62 #define BADNICKCHARS "-,+*=:!.@#;$%&"
63
64 /* have to use a weird way to make the compiler error out cos not all
65 * compilers support #error or error */
66 #if !HAVE_VSPRINTF
67 #include "error_you_need_vsprintf_to_compile_eggdrop"
68 #endif
69
70 #if HAVE_UNISTD_H
71 #include <unistd.h>
72 #endif
73
74 #ifndef STATIC
75 #if (!defined(MODULES_OK) || !defined(HAVE_DLOPEN)) && !defined(HPUX_HACKS)
76 #include "you_can't_compile_with_module_support_on_this_system_try_make_static"
77 #endif
78 #endif
79
80 #if !defined(STDC_HEADERS)
81 #include "you_need_to_upgrade_your_compiler_to_a_standard_c_one_mate!"
82 #endif
83
84 #if (NICKMAX < 9) || (NICKMAX > 32)
85 #include "invalid NICKMAX value"
86 #endif
87
88 #if (HANDLEN < 9) || (HANDLEN > 32)
89 #include "invalid HANDLEN value"
90 #endif
91
92 #if HANDLEN > NICKMAX
93 #include "HANDLEN MUST BE <= NICKMAX"
94 #endif
95
96 /* almost every module needs some sort of time thingy, so... */
97 #if TIME_WITH_SYS_TIME
98 #include <sys/time.h>
99 #include <time.h>
100 #else
101 #if HAVE_SYS_TIME_H
102 #include <sys/time.h>
103 #else
104 #include <time.h>
105 #endif
106 #endif
107
108 #if !HAVE_SRANDOM
109 #define srandom(x) srand(x)
110 #endif
111
112 #if !HAVE_RANDOM
113 #define random() (rand()/16)
114 #endif
115
116 #if !HAVE_SIGACTION /* old "weird signals" */
117 #define sigaction sigvec
118 #ifndef sa_handler
119 #define sa_handler sv_handler
120 #define sa_mask sv_mask
121 #define sa_flags sv_flags
122 #endif
123 #endif
124
125 #if !HAVE_SIGEMPTYSET
126 /* and they probably won't have sigemptyset, dammit */
127 #define sigemptyset(x) ((*(int *)(x))=0)
128 #endif
129
130 /* handy aliases for memory tracking and core dumps */
131 #define nmalloc(x) n_malloc((x),__FILE__,__LINE__)
132 #define nrealloc(x,y) n_realloc((x),(y),__FILE__,__LINE__)
133 #define nfree(x) n_free((x),__FILE__,__LINE__)
134
135 #ifdef DEBUG_CONTEXT
136 # define Context eggContext(__FILE__, __LINE__, NULL)
137 # define ContextNote(note) eggContextNote(__FILE__, __LINE__, NULL, note)
138 #else
139 # define Context {}
140 # define ContextNote(note) {}
141 #endif
142
143 #ifdef DEBUG_ASSERT
144 # define Assert(expr) eggAssert(__FILE__, __LINE__, NULL, (int)(expr))
145 #else
146 # define Assert(expr) {}
147 #endif
148
149 #undef malloc
150 #define malloc(x) dont_use_old_malloc(x)
151 #undef free
152 #define free(x) dont_use_old_free(x)
153
154 /* 32 bit type */
155 #if (SIZEOF_INT == 4)
156 typedef unsigned int u_32bit_t;
157 #else
158 # if (SIZEOF_LONG == 4)
159 typedef unsigned int u_32bit_t;
160 # else
161 # include "cant/find/32bit/type"
162 # endif
163 #endif
164
165 #if (SIZEOF_SHORT_INT == 2)
166 typedef unsigned short int u_16bit_t;
167 #else
168 # include "cant/find/16bit/type"
169 #endif
170
171 #if (SIZEOF_CHAR == 1)
172 typedef unsigned char u_8bit_t;
173 #else
174 # include "cant/find/8bit/type"
175 #endif
176
177 typedef u_8bit_t byte;
178 typedef u_16bit_t word;
179 typedef u_32bit_t dword;
180
181 /* IP type */
182 typedef u_32bit_t IP;
183
184 #define debug0(x) putlog(LOG_DEBUG,"*",x)
185 #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
186 #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
187 #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
188 #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
189
190 /***********************************************************************/
191
192 /* public structure for the listening port map */
193 struct portmap {
194 int realport;
195 int mappedto;
196 struct portmap *next;
197 };
198
199 /* public structure of all the dcc connections */
200 struct dcc_table {
201 char *name;
202 int flags;
203 void (*eof) (int);
204 void (*activity) (int, char *, int);
205 int *timeout_val;
206 void (*timeout) ();
207 void (*display) (int, char *);
208 int (*expmem) (void *);
209 void (*kill) (int, void *);
210 void (*output) (int, char *, void *);
211 };
212
213 struct userrec;
214
215 struct dcc_t {
216 long sock; /* this should be a long to keep 64-bit
217 * machines sane */
218 IP addr; /* IP address in host byte order */
219 unsigned int port;
220 struct userrec *user;
221 char nick[NICKLEN];
222 char host[UHOSTLEN];
223 struct dcc_table *type;
224 time_t timeval; /* use for any timing stuff
225 * - this is used for timeout checking */
226 unsigned long status; /* A LOT of dcc types have status thingos,
227 * this makes it more avaliabe */
228 union {
229 struct chat_info *chat;
230 struct file_info *file;
231 struct edit_info *edit;
232 struct xfer_info *xfer;
233 struct bot_info *bot;
234 struct relay_info *relay;
235 struct script_info *script;
236 int ident_sock;
237 void *other;
238 } u; /* special use depending on type */
239 };
240
241 struct chat_info {
242 char *away; /* non-NULL if user is away */
243 int msgs_per_sec; /* used to stop flooding */
244 int con_flags; /* with console: what to show */
245 int strip_flags; /* what codes to strip (b,r,u,c,a,g,*) */
246 char con_chan[81]; /* with console: what channel to view */
247 int channel; /* 0=party line, -1=off */
248 struct msgq *buffer; /* a buffer of outgoing lines (for .page cmd) */
249 int max_line; /* maximum lines at once */
250 int line_count; /* number of lines sent since last page */
251 int current_lines; /* number of lines total stored */
252 char *su_nick;
253 };
254
255 struct file_info {
256 struct chat_info *chat;
257 char dir[161];
258 };
259
260 struct xfer_info {
261 char filename[121];
262 char dir[121]; /* used when uploads go to the current dir */
263 unsigned long length;
264 unsigned long acked;
265 char buf[4]; /* you only need 5 bytes! */
266 unsigned char sofar; /* how much of the byte count received */
267 char from[NICKLEN]; /* [GET] user who offered the file */
268 FILE *f; /* pointer to file being sent/received */
269 };
270
271 struct bot_info {
272 char version[121]; /* channel/version info */
273 char linker[NOTENAMELEN + 1]; /* who requested this link */
274 int numver;
275 int port; /* base port */
276 };
277
278 struct relay_info {
279 struct chat_info *chat;
280 int sock;
281 int port;
282 int old_status;
283 };
284
285 struct script_info {
286 struct dcc_table *type;
287 union {
288 struct chat_info *chat;
289 struct file_info *file;
290 void *other;
291 } u;
292 char command[121];
293 };
294
295 /* flags about dcc types */
296 #define DCT_CHAT 0x00000001 /* this dcc type receives botnet chatter */
297 #define DCT_MASTER 0x00000002 /* received master chatter */
298 #define DCT_SHOWWHO 0x00000004 /* show the user in .who */
299 #define DCT_REMOTEWHO 0x00000008 /* show in remote who */
300 #define DCT_VALIDIDX 0x00000010 /* valid idx for outputting to in tcl */
301 #define DCT_SIMUL 0x00000020 /* can be tcl_simul'd */
302 #define DCT_CANBOOT 0x00000040 /* can be booted */
303 #define DCT_GETNOTES DCT_CHAT /* can receive notes */
304 #define DCT_FILES 0x00000080 /* gratuitous hack ;) */
305 #define DCT_FORKTYPE 0x00000100 /* a forking type */
306 #define DCT_BOT 0x00000200 /* a bot connection of some sort... */
307 #define DCT_FILETRAN 0x00000400 /* a file transfer of some sort */
308 #define DCT_FILESEND 0x00000800 /* a sending file transfer, getting = !this */
309 #define DCT_LISTEN 0x00001000 /* a listening port of some sort */
310
311 /* for dcc chat & files: */
312 #define STAT_ECHO 1 /* echo commands back? */
313 #define STAT_DENY 2 /* bad username (ignore password & deny access) */
314 /*#define STAT_XFER 4 has 'x' flag on chat line */
315 #define STAT_CHAT 8 /* in file-system but may return */
316 #define STAT_TELNET 16 /* connected via telnet */
317 #define STAT_PARTY 32 /* only on party line via 'p' flag */
318 #define STAT_BOTONLY 64 /* telnet on bots-only connect */
319 #define STAT_USRONLY 128 /* telnet on users-only connect */
320 #define STAT_PAGE 256 /* page output to the user */
321
322 /* for stripping out mIRC codes */
323 #define STRIP_COLOR 1 /* remove mIRC color codes */
324 #define STRIP_BOLD 2 /* remove bold codes */
325 #define STRIP_REV 4 /* remove reverse video codes */
326 #define STRIP_UNDER 8 /* remove underline codes */
327 #define STRIP_ANSI 16 /* remove ALL ansi codes */
328 #define STRIP_BELLS 32 /* remote ctrl-g's */
329 #define STRIP_ALL 63 /* remove every damn thing! */
330
331 /* for dcc bot links: */
332 #define STAT_PINGED 0x01 /* waiting for ping to return */
333 #define STAT_SHARE 0x02 /* sharing user data with the bot */
334 #define STAT_CALLED 0x04 /* this bot called me */
335 #define STAT_OFFERED 0x08 /* offered her the user file */
336 #define STAT_SENDING 0x10 /* in the process of sending a user list */
337 #define STAT_GETTING 0x20 /* in the process of getting a user list */
338 #define STAT_WARNED 0x40 /* warned him about unleaflike behavior */
339 #define STAT_LEAF 0x80 /* this bot is a leaf only */
340 #define STAT_LINKING 0x100 /* the bot is currently going through the
341 * linking stage */
342 #define STAT_AGGRESSIVE 0x200 /* aggressively sharing with this bot */
343
344 /* chan & global */
345 #define FLOOD_PRIVMSG 0
346 #define FLOOD_NOTICE 1
347 #define FLOOD_CTCP 2
348 #define FLOOD_NICK 3
349 #define FLOOD_JOIN 4
350 #define FLOOD_KICK 5
351 #define FLOOD_DEOP 6
352 #define FLOOD_CHAN_MAX 7
353 #define FLOOD_GLOBAL_MAX 3
354
355 /* for local console: */
356 #define STDIN 0
357 #define STDOUT 1
358 #define STDERR 2
359
360 /* structure for internal logs */
361 typedef struct {
362 char *filename;
363 unsigned int mask; /* what to send to this log */
364 char *chname; /* which channel */
365 char szLast[MAX_LOG_LINE + 1]; /* for 'Last message repeated n times'
366 * stuff in misc.c/putlog() <cybah> */
367 int Repeats; /* number of times szLast has been repeated */
368 unsigned int flags; /* other flags <rtc> */
369 FILE *f; /* existing file */
370 } log_t;
371
372 /* logfile display flags */
373 #define LOG_MSGS 0x000001 /* m msgs/notice/ctcps */
374 #define LOG_PUBLIC 0x000002 /* p public msg/notice/ctcps */
375 #define LOG_JOIN 0x000004 /* j channel joins/parts/etc */
376 #define LOG_MODES 0x000008 /* k mode changes/kicks/bans */
377 #define LOG_CMDS 0x000010 /* c user dcc or msg commands */
378 #define LOG_MISC 0x000020 /* o other misc bot things */
379 #define LOG_BOTS 0x000040 /* b bot notices */
380 #define LOG_RAW 0x000080 /* r raw server stuff coming in */
381 #define LOG_FILES 0x000100 /* x file transfer commands and stats */
382 #define LOG_LEV1 0x000200 /* 1 user log level */
383 #define LOG_LEV2 0x000400 /* 2 user log level */
384 #define LOG_LEV3 0x000800 /* 3 user log level */
385 #define LOG_LEV4 0x001000 /* 4 user log level */
386 #define LOG_LEV5 0x002000 /* 5 user log level */
387 #define LOG_LEV6 0x004000 /* 6 user log level */
388 #define LOG_LEV7 0x008000 /* 7 user log level */
389 #define LOG_LEV8 0x010000 /* 8 user log level */
390 #define LOG_SERV 0x020000 /* s server information */
391 #define LOG_DEBUG 0x040000 /* d debug */
392 #define LOG_WALL 0x080000 /* w wallops */
393 #define LOG_SRVOUT 0x100000 /* v server output */
394 #define LOG_BOTNET 0x200000 /* t botnet traffic */
395 #define LOG_BOTSHARE 0x400000 /* h share traffic */
396 #define LOG_ALL 0x7fffff /* (dump to all logfiles) */
397 /* internal logfile flags */
398 #define LF_EXPIRING 0x000001 /* Logfile will be closed soon */
399
400 #define FILEDB_HIDE 1
401 #define FILEDB_UNHIDE 2
402 #define FILEDB_SHARE 3
403 #define FILEDB_UNSHARE 4
404
405 /* socket flags: */
406 #define SOCK_UNUSED 0x001 /* empty socket */
407 #define SOCK_BINARY 0x002 /* do not buffer input */
408 #define SOCK_LISTEN 0x004 /* listening port */
409 #define SOCK_CONNECT 0x008 /* connection attempt */
410 #define SOCK_NONSOCK 0x010 /* used for file i/o on debug */
411 #define SOCK_STRONGCONN 0x020 /* don't report success until sure */
412 #define SOCK_EOFD 0x040 /* it EOF'd recently during a write */
413 #define SOCK_PROXYWAIT 0x080 /* waiting for SOCKS traversal */
414
415 /* fake idx's for dprintf - these should be ridiculously large +ve nums */
416 #define DP_STDOUT 0x7FF1
417 #define DP_LOG 0x7FF2
418 #define DP_SERVER 0x7FF3
419 #define DP_HELP 0x7FF4
420 #define DP_STDERR 0x7FF5
421 #define DP_MODE 0x7FF6
422
423 #define NORMAL 0
424 #define QUICK 1
425
426 /* return codes for add_note */
427 #define NOTE_ERROR 0 /* error */
428 #define NOTE_OK 1 /* success */
429 #define NOTE_STORED 2 /* not online; stored */
430 #define NOTE_FULL 3 /* too many notes stored */
431 #define NOTE_TCL 4 /* tcl binding caught it */
432 #define NOTE_AWAY 5 /* away; stored */
433 #define NOTE_FWD 6 /* away; forwarded */
434 #define NOTE_REJECT 7 /* ignore mask matched */
435
436 #define STR_PROTECT 2
437 #define STR_DIR 1
438
439 #define HELP_DCC 1
440 #define HELP_TEXT 2
441 #define HELP_IRC 16
442
443 /* it's used in so many places, let's put it here */
444 typedef int (*Function) ();
445
446 /* this is used by the net module to keep track of sockets and what's
447 * queued on them */
448 typedef struct {
449 int sock;
450 char flags;
451 char *inbuf;
452 char *outbuf;
453 unsigned long outbuflen; /* outbuf could be binary data */
454 } sock_list;
455
456 #endif

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23