/[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.9 - (show annotations) (download) (as text)
Tue Oct 12 21:25:15 1999 UTC (20 years ago) by guppy
Branch: MAIN
Changes since 1.8: +14 -9 lines
File MIME type: text/x-csrc
come on rc2

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23