1 /*
2  * struct.h: header file for structures needed for prototypes
3  *
4  * Written by Scott Reynolds, based on code by Michael Sandrof
5  * Heavily modified by Colten Edwards for BitchX
6  *
7  * Copyright(c) 1997
8  *
9  */
10 
11 #ifndef __struct_h_
12 #define	__struct_h_
13 
14 #ifdef WINNT
15 #include <windows.h>
16 #endif
17 
18 #include "alist.h"
19 #include "hash.h"
20 #include "config.h"
21 #include "ssl.h"
22 #include <netinet/in.h>
23 
24 /*
25  * struct sockaddr_storage isn't avaiable on all ipv6-ready-systems, bleh ;(
26  * and i'm too lazy to #ifdef every sockaddr declaration. --wojtekka
27  */
28 
29 struct sockaddr_foobar
30 {
31        union {
32                struct sockaddr_in sin;
33 #ifdef IPV6
34            struct sockaddr_in6 sin6;
35 #endif
36        } sins;
37 };
38 
39 #define sf_family sins.sin.sin_family
40 #define sf_port sins.sin.sin_port
41 #define sf_addr sins.sin.sin_addr
42 #ifdef IPV6
43 #      define sf_addr6 sins.sin6.sin6_addr
44 #endif
45 
46 
47 #ifdef GUI
48 typedef struct _menuref {
49 	int refnum, menuid;
50 #if defined(__EMXPM__) || defined(WIN32)
51 	HWND menuhandle;
52 #elif defined(GTK)
53 	GtkWidget *menuhandle;
54 	char *menutext;
55 	int checked;
56 #endif
57 	struct _menuref *next;
58 } MenuRef;
59 
60 typedef struct _menu_item
61 {
62 	struct _menu_item	*next;
63 	char			*name;
64 	char			*alias;
65 	char			*submenu;
66 	int			menuid;
67 	int			menutype;
68 	int			refnum;
69 } MenuList;
70 
71 typedef struct	_menu_struct
72 {
73 	struct _menu_struct	*next;
74 	char			*name;
75 	MenuList		*menuorigin;
76 #if defined(__EMXPM__) || defined(WIN32)
77 	HWND			sharedhandle;
78 #elif defined(GTK)
79 	GtkWidget		*sharedhandle;
80 #endif
81 	 MenuRef		*root;
82 } MenuStruct;
83 #endif
84 
85 
86 typedef struct
87 {
88 	int is_read;
89 	int is_write;
90 	int port;
91 	char *server;
92 	unsigned long flags;
93 	time_t time;
94 	void (*func_read) (int);
95 	void (*func_write) (int);
96 	void (*cleanup) (int);
97 	void *info;
98 #if defined(HAVE_SSL) && !defined(IN_MODULE)
99 	SSL_CTX* ctx;
100 	int ssl_error;
101 	SSL* ssl_fd;
102 #endif
103 } SocketList;
104 
105 typedef char *(bf) (char *, char *);
106 typedef struct
107 {
108 	char    *name;
109 	bf      *func;
110 }       BuiltInFunctions;
111 
112 typedef struct _BuiltInDllFunctions
113 {
114 	struct _BuiltInDllFunctions *next;
115 	char    *name;
116 	char	*module;
117 	bf      *func;
118 }       BuiltInDllFunctions;
119 
120 typedef enum NoiseEnum {
121 	UNKNOWN = 0,
122 	SILENT,
123 	QUIET,
124 	NORMAL,
125 	NOISY
126 } Noise;
127 
128 /* Hook: The structure of the entries of the hook functions lists */
129 typedef struct	hook_stru
130 {
131 struct	hook_stru *next;
132 
133 	char	*nick;			/* /on type NICK stuff */
134 	char	*stuff;			/* /on type nick STUFF */
135 
136 	int	not;			/* /on type ^nick stuff */
137 	Noise	noisy;			/* /on [^-+]type nick stuff */
138 
139 	int	sernum;			/* /on #type NUM nick stuff */
140 					/* Default sernum is 0. */
141 
142 	int	global;			/* set if loaded from `global' */
143 	int	flexible;		/* on type 'NICK' stuff */
144 	int	debug;			/* turn debug on/off */
145 	char	*filename;		/* Where it was loaded */
146 	int	(*hook_func) (char *, char *, char **);
147 	int	(*num_func) (int, char *, char **);
148 }	Hook;
149 
150 /* HookFunc: A little structure to keep track of the various hook functions */
151 typedef struct
152 {
153 	char	*name;			/* name of the function */
154 	Hook	*list;			/* pointer to head of the list for this
155 					 * function */
156 	int	params;			/* number of parameters expected */
157 	int	mark;
158 	unsigned flags;
159 }	HookFunc;
160 
161 typedef struct _NumericFunction
162 {
163 	struct _NumericFunction *next;
164 	char	*name;
165 	char	*module;
166 	int	number;
167 	Hook	*list;
168 }       NumericFunction;
169 
170 typedef struct _RawFunction
171 {
172 	struct _RawFunction *next;
173 	char	*name;
174 	char	*module;
175 	int	(*func) (char *, char *, char *, char **);
176 } RawDll;
177 
178 /* UrlList: structure for the urls in your Url List */
179 typedef struct  urllist_stru
180 {
181 	struct  urllist_stru *next;     /* pointer to next url entry */
182 	char    *name;                  /* name */
183 } UrlList;
184 
185 /* IrcCommand: structure for each command in the command table */
186 typedef	struct
187 {
188 	char	*name;					/* what the user types */
189 	char	*server_func;				/* what gets sent to the server
190 							 * (if anything) */
191 	void	(*func) (char *, char *, char *, char *);	/* function that is the command */
192 	unsigned	flags;
193 	char	*help;
194 }	IrcCommand;
195 
196 
197 typedef	struct _IrcCommandDll
198 {
199 	struct  _IrcCommandDll *next;			/* pointer to next record. */
200 	char	*name;					/* what the user types */
201 	char	*module;
202 	char	*server_func;				/* what gets sent to the server
203 							 * (if anything) */
204 	void	(*func) (struct _IrcCommandDll *, char *, char *, char *, char *);	/* function that is the command */
205 	unsigned	flags;
206 	char	*result;
207 	char	*help;
208 }	IrcCommandDll;
209 
210 typedef struct _WindowDll
211 {
212 	struct _WindowDll *next;
213 	char	*name;
214 	char	*module;
215 	struct WindowStru *(*func) (struct WindowStru *, char **, char *);
216 	char	*help;
217 } WindowDll;
218 
219 typedef struct _last_msg_stru
220 {
221 	struct _last_msg_stru *next;
222 	char    *from;
223 	char	*uh;
224 	char	*to;
225 	char    *last_msg;
226 	char	*time;
227 	int     count;
228 } LastMsg;
229 
230 typedef struct  userlist_stru
231 {
232 	struct	userlist_stru	*next;	/* pointer to next user entry */
233 	char	*nick;			/* user's name in nick!user@host */
234 	char	*host;
235 	char	*comment;
236 	char	*channels;		/* channel for list to take effect */
237 	char	*password;		/* users password */
238 unsigned long	flags;			/* this users flags */
239 	time_t	time;			/* time when put on list */
240 }	UserList;
241 
242 /* ShitList: structure proto for the shitlist */
243 typedef struct  shitlist_stru
244 {
245 	struct	shitlist_stru	*next;	/* pointer to next shit entry */
246 	char	*filter;		/* filter in nick!user@host */
247 	int	level;			/* level of shitted */
248 	char	*channels;		/* channel for list to take effect */
249 	char	*reason;		/* Reason */
250 	time_t	time;			/* time shit was put on */
251 }	ShitList;
252 
253 /* WordKickList: structure for your wordkick list */
254 typedef struct  wordkicklist_stru
255 {
256 	struct	wordkicklist_stru *next;	/* pointer to next user entry */
257 	char	*string;			/* string */
258 	char	*channel;			/* channel */
259 }	WordKickList;
260 
261 /* LameList: structure for the users on your LameNick Kick*/
262 typedef struct  lamelist_stru
263 {
264 	struct	lamelist_stru	*next;	/* pointer to next lame entry */
265 	char	*nick;			/* Lame Nick */
266 }	LameList;
267 
268 /* invitetoList: structure for the invitetolist list */
269 typedef struct  invitetolist_stru
270 {
271 	struct	invitetolistlist_stru	*next;	/* pointer to next entry */
272 	char    *channel;			/* channel */
273 	int     times;				/* times I have been invited */
274 	time_t  time;				/* time of last invite */
275 }	InviteToList;
276 
277 typedef struct server_split
278 {
279 	struct server_split *next;
280 	char *name;	/* name of this server. */
281 	char *link;	/* linked to what server */
282 	int status;	/* split or not */
283 	int count;	/* number of times we have not found this one */
284 	int hopcount; 	/* number of hops away */
285 	time_t time; 	/* time of split */
286 } irc_server;
287 
288 /*
289  * ctcp_entry: the format for each ctcp function.   note that the function
290  * described takes 4 parameters, a pointer to the ctcp entry, who the message
291  * was from, who the message was to (nickname, channel, etc), and the rest of
292  * the ctcp message.  it can return null, or it can return a malloced string
293  * that will be inserted into the oringal message at the point of the ctcp.
294  * if null is returned, nothing is added to the original message
295 
296  */
297 struct _CtcpEntry;
298 
299 typedef char *((*CTCP_Handler) (struct _CtcpEntry *, char *, char *, char *));
300 
301 typedef	struct _CtcpEntry
302 {
303 	char		*name;  /* name of ctcp datatag */
304 	int		id;	/* index of this ctcp command */
305 	int		flag;	/* Action modifiers */
306 	char		*desc;  /* description returned by ctcp clientinfo */
307 	CTCP_Handler 	func;	/* function that does the dirty deed */
308 	CTCP_Handler 	repl;	/* Function that is called for reply */
309 }	CtcpEntry;
310 
311 struct _CtcpEntryDll;
312 
313 typedef char *((*CTCP_DllHandler) (struct _CtcpEntryDll *, char *, char *, char *));
314 
315 typedef	struct _CtcpEntryDll
316 {
317 	struct		_CtcpEntryDll *next;
318 	char		*name;  /* name of ctcp datatag */
319 	char		*module; /* name of module associated with */
320 	int		id;	/* index of this ctcp command */
321 	int		flag;	/* Action modifiers */
322 	char		*desc;  /* description returned by ctcp clientinfo */
323 	CTCP_DllHandler	func;	/* function that does the dirty deed */
324 	CTCP_DllHandler	repl;	/* Function that is called for reply */
325 }	CtcpEntryDll;
326 
327 
328 
329 
330 struct transfer_struct {
331 	unsigned short packet_id;
332 	unsigned char byteorder;
333 	u_32int_t byteoffset;
334 };
335 
336 
337 typedef struct _File_Stat {
338 	struct _File_Stat *next;
339 	char *filename;
340 	long filesize;
341 } FileStat;
342 
343 typedef struct _File_List {
344 	struct _File_List *next;
345 	char * description;
346 	char * notes;
347 	FileStat *filename;
348 	char * nick;
349 	int packnumber;
350 	int numberfiles;
351 	double filesize;
352 	double minspeed;
353 	int gets;
354 	time_t timequeue;
355 } FileList;
356 
357 #if 0
358 typedef	struct	DCC_struct
359 {
360 	struct DCC_struct *next;
361 	char		*user;
362 	char		*userhost;
363 	unsigned int	flags;
364 	int		read;
365 	int		write;
366 	int		file;
367 
368 	u_32int_t	filesize;
369 
370 	int		dccnum;
371 	int		eof;
372 	char		*description;
373 	char		*othername;
374 	struct in_addr	remote;
375 	u_short		remport;
376 	u_short		local_port;
377 	u_32int_t	bytes_read;
378 	u_32int_t	bytes_sent;
379 
380 	int				window_sent;
381 	int				window_max;
382 
383 	int		in_dcc_chat;
384 	int		echo;
385 	int		in_ftp;
386 	int		dcc_fast;
387 
388 
389 	struct timeval	lasttime;
390 	struct timeval	starttime;
391 	char		*buffer;
392 	char		*cksum;
393 	char		*encrypt;
394 	char		*dccbuffer;
395 
396 	u_32int_t	packets_total;
397 	u_32int_t	packets_transfer;
398 	struct transfer_struct transfer_orders;
399 	void (*dcc_handler) (struct DCC_struct *, char *);
400 
401 }	DCC_list;
402 #endif
403 
404 /* Hold: your general doubly-linked list type structure */
405 
406 typedef struct HoldStru
407 {
408 	char	*str;
409 	struct	HoldStru	*next;
410 	struct	HoldStru	*prev;
411 	int	logged;
412 }	Hold;
413 
414 typedef struct	lastlog_stru
415 {
416 	int	level;
417 	char	*msg;
418 	time_t	time;
419 	struct	lastlog_stru	*next;
420 	struct	lastlog_stru	*prev;
421 }	Lastlog;
422 
423 struct	ScreenStru;	/* ooh! */
424 
425 #define NICK_CHANOP 	0x0001
426 #define NICK_HALFOP	0x0002
427 #define NICK_AWAY	0x0004
428 #define NICK_VOICE	0x0008
429 #define NICK_IRCOP	0x0010
430 
431 #define nick_isop(s) (s->flags & NICK_CHANOP)
432 #define nick_isvoice(s) (s->flags & NICK_VOICE)
433 #define nick_ishalfop(s) (s->flags & NICK_HALFOP)
434 #define nick_isaway(s) (s->flags & NICK_AWAY)
435 #define nick_isircop(s) (s->flags & NICK_IRCOP)
436 
437 typedef unsigned int my_uint;
438 
439 /* NickList: structure for the list of nicknames of people on a channel */
440 typedef struct nick_stru
441 {
442 	struct	nick_stru	*next;	/* pointer to next nickname entry */
443 	char	*nick;			/* nickname of person on channel */
444 	char	*host;
445 	char	*ip;
446 	char	*server;
447 	int	serverhops;
448 	my_uint	ip_count;
449 	UserList *userlist;
450 	ShitList *shitlist;
451 
452 	my_uint flags;
453 #if 0
454 	int	chanop;			/* True if the given nick has chanop */
455 	int	halfop;
456 	int	away;
457 	int	voice;
458 	int	ircop;
459 #endif
460 	time_t	idle_time;
461 
462 	my_uint	floodcount;
463 	time_t	floodtime;
464 
465 	my_uint	nickcount;
466 	time_t  nicktime;
467 
468 	my_uint	kickcount;
469 	time_t	kicktime;
470 
471 	my_uint	joincount;
472 	time_t	jointime;
473 
474 	my_uint	dopcount;
475 	time_t	doptime;
476 
477 	my_uint	bancount;
478 	time_t	bantime;
479 
480 
481 	time_t	created;
482 
483 	my_uint	stat_kicks;		/* Total kicks done by user */
484 	my_uint	stat_dops;		/* Total deops done by user */
485 	my_uint	stat_ops;		/* Total ops done by user */
486 	my_uint	stat_hops;
487 	my_uint	stat_dhops;
488 	my_uint	stat_eban;
489 	my_uint	stat_uneban;
490 	my_uint	stat_bans;		/* Total bans done by user */
491 	my_uint	stat_unbans;		/* Total unbans done by user */
492 	my_uint	stat_nicks;		/* Total nicks done by user */
493 	my_uint	stat_pub;		/* Total publics sent by user */
494 	my_uint	stat_topics;		/* Total topics set by user */
495 
496 	my_uint	sent_reop;
497 	time_t	sent_reop_time;
498 	my_uint	sent_voice;
499 	time_t	sent_voice_time;
500 
501 	my_uint	sent_deop;
502 	time_t	sent_deop_time;
503 	my_uint	need_userhost;		/* on join we send a userhost for this nick */
504 	my_uint	check_clone;		/* added for builtin clone detect */
505 }	NickList;
506 
507 typedef	struct	DisplayStru
508 {
509 	char	*line;
510 	int	linetype;
511 	struct	DisplayStru	*next;
512 	struct	DisplayStru	*prev;
513 }	Display;
514 
515 typedef struct WinSetStru
516 {
517 /* These are copied over from /set's */
518 	char	*status_mode;
519 	char	*status_topic;
520 	char	*status_umode;
521 	char	*status_hold_lines;
522 	char	*status_hold;
523 	char	*status_voice;
524 	char	*status_channel;
525 	char	*status_notify;
526 	char	*status_oper_kills;
527 	char	*status_lag;
528 	char	*status_mail;
529 	char	*status_query;
530 	char	*status_server;
531 	char	*status_clock;
532 	char	*status_users;
533 	char	*status_away;
534 	char	*status_dcccount;
535 	char	*status_cdcccount;
536 	char	*status_chanop;
537 	char	*status_cpu_saver;
538 	char	*status_msgcount;
539 	char	*status_nick;
540 	char	*status_flag;
541 	char	*status_halfop;
542 
543 /* These are the various formats from a window make_status() creates these */
544 	char    *mode_format;
545 	char    *umode_format;
546 	char    *topic_format;
547 	char    *query_format;
548 	char    *clock_format;
549 	char    *hold_lines_format;
550 	char    *channel_format;
551 	char    *mail_format;
552 	char    *server_format;
553 	char    *notify_format;
554 	char    *kills_format;
555 	char    *status_users_format;
556 	char    *lag_format;
557 	char	*cpu_saver_format;
558 	char	*msgcount_format;
559 	char	*dcccount_format;
560 	char	*cdcc_format;
561 	char	*nick_format;
562 	char	*flag_format;
563 	char	*away_format;
564 
565 #define MAX_FUNCTIONS		36
566 	char	*status_user_formats0;
567 	char	*status_user_formats1;
568 	char	*status_user_formats2;
569 	char	*status_user_formats3;
570 	char	*status_user_formats4;
571 	char	*status_user_formats5;
572 	char	*status_user_formats6;
573 	char	*status_user_formats7;
574 	char	*status_user_formats8;
575 	char	*status_user_formats9;
576 	char	*status_user_formats10;
577 	char	*status_user_formats11;
578 	char	*status_user_formats12;
579 	char	*status_user_formats13;
580 	char	*status_user_formats14;
581 	char	*status_user_formats15;
582 	char	*status_user_formats16;
583 	char	*status_user_formats17;
584 	char	*status_user_formats18;
585 	char	*status_user_formats19;
586 	char	*status_user_formats20;
587 	char	*status_user_formats21;
588 	char	*status_user_formats22;
589 	char	*status_user_formats23;
590 	char	*status_user_formats24;
591 	char	*status_user_formats25;
592 	char	*status_user_formats26;
593 	char	*status_user_formats27;
594 	char	*status_user_formats28;
595 	char	*status_user_formats29;
596 	char	*status_user_formats30;
597 	char	*status_user_formats31;
598 	char	*status_user_formats32;
599 	char	*status_user_formats33;
600 	char	*status_user_formats34;
601 	char	*status_user_formats35;
602 	char	*status_user_formats36;
603 	char	*status_user_formats37;
604 	char	*status_user_formats38;
605 	char	*status_user_formats39;
606 	char	*status_scrollback;
607 	char	*status_window;
608 
609 	char	*status_line[3];	/* The status lines string current display */
610 	char	*status_format[4];	/* holds formated status info from build_status */
611 	char	*format_status[4];	/* holds raw format for window from /set */
612 
613 	char	*window_special_format;
614 }	 WSet;
615 
616 typedef	struct	WindowStru
617 {
618 	char			*name;
619 	unsigned int	refnum;		/* the unique reference number,
620 					 * assigned by IRCII */
621 	int	server;			/* server index */
622 	int	last_server;		/* previous server index */
623 	int	top;			/* The top line of the window, screen
624 					 * coordinates */
625 	int	bottom;			/* The botton line of the window, screen
626 					 * coordinates */
627 	int	cursor;			/* The cursor position in the window, window
628 					 * relative coordinates */
629 	int	line_cnt;		/* counter of number of lines displayed in
630 					 * window */
631 	int	absolute_size;
632 	int	noscroll;		/* true, window scrolls... false window wraps */
633 	int	scratch_line;		/* True if a scratch window */
634 	int	old_size;		/* if new_size != display_size, resize_display */
635 	int	visible;		/* true, window ise, window is drawn... false window is hidden */
636 	int	update;			/* window needs updating flag */
637 	int	repaint_start;
638 	int	repaint_end;
639 	unsigned miscflags;		/* Miscellaneous flags. */
640 	int	beep_always;		/* should this window beep when hidden */
641 	unsigned long notify_level;
642 	unsigned long window_level;		/* The LEVEL of the window, determines what
643 						 * messages go to it */
644 	int	skip;
645 	int	columns;
646 	char	*prompt;		/* A prompt string, usually set by EXEC'd process */
647 	int	double_status;		/* number of status lines */
648 	int	status_split;		/* split status to top and bottom */
649 	int	status_lines;		/* replacement for menu struct */
650 
651 	char    *(*status_func[4][MAX_FUNCTIONS]) (struct WindowStru *);
652 	int	func_cnt[4];
653 	WSet	*wset;
654 
655 
656 	Display *top_of_scrollback,	/* Start of the scrollback buffer */
657 		*top_of_display,	/* Where the viewport starts */
658 		*ceiling_of_display,	/* the furthest top of display */
659 		*display_ip,		/* Where next line goes in rite() */
660 		*scrollback_point,
661 		*screen_hold;	/* Where t_o_d was at start of sb */
662 	int	display_buffer_size;	/* How big the scrollback buffer is */
663 	int	display_buffer_max;	/* How big its supposed to be */
664 	int	display_size;		/* How big the window is - status */
665 
666 	int	lines_scrolled_back;	/* Where window is relatively */
667 
668 	int	hold_mode;		/* True if we want to hold stuff */
669 	int	holding_something;	/* True if we ARE holding something */
670 	int	held_displayed;		/* lines displayed since last hold */
671 	int	lines_displayed;	/* Lines held since last unhold */
672 	int	lines_held;		/* Lines currently being held */
673 	int	last_lines_held;	/* Last time we updated "lines held" */
674 	int	distance_from_display;
675 
676 	char	*current_channel;	/* Window's current channel */
677 	char	*waiting_channel;
678 	char	*bind_channel;
679 	char	*query_nick;		/* User being QUERY'ied in this window */
680 	char	*query_host;
681 	char	*query_cmd;
682 
683 	NickList *nicks;		/* List of nicks that will go to window */
684 
685 	/* lastlog stuff */
686 	Lastlog	*lastlog_head;		/* pointer to top of lastlog list */
687 	Lastlog	*lastlog_tail;		/* pointer to bottom of lastlog list */
688 	unsigned long lastlog_level;	/* The LASTLOG_LEVEL, determines what
689 					 * messages go to lastlog */
690 	int	lastlog_size;		/* number of messages in lastlog */
691 	int	lastlog_max;		/* Max number of msgs in lastlog */
692 
693 	char	*logfile;		/* window's logfile name */
694 	/* window log stuff */
695 	int	log;			/* true, file logging for window is on */
696 	FILE	*log_fp;		/* file pointer for the log file */
697 
698 	int	window_display;		/* should we display to this window */
699 
700 	void	(*output_func)	(struct WindowStru *, const unsigned char *);
701 	void	(*status_output_func)	(struct WindowStru *);
702 
703 	struct	ScreenStru	*screen;
704 	struct	WindowStru	*next;	/* pointer to next entry in window list (null
705 					 * is end) */
706 	struct	WindowStru	*prev;	/* pointer to previous entry in window list
707 					 * (null is end) */
708 	int	deceased;		/* set when window is killed */
709 	int	in_more;
710 	int	save_hold_mode;
711 	int	mangler;
712 	void	(*update_status)	(struct WindowStru *);
713 	void	(*update_input) (struct WindowStru *);
714 }	Window;
715 
716 /*
717  * WindowStack: The structure for the POP, PUSH, and STACK functions. A
718  * simple linked list with window refnums as the data
719  */
720 typedef	struct	window_stack_stru
721 {
722 	unsigned int	refnum;
723 	struct	window_stack_stru	*next;
724 }	WindowStack;
725 
726 typedef	struct
727 {
728 	int	top;
729 	int	bottom;
730 	int	position;
731 }	ShrinkInfo;
732 
733 typedef struct PromptStru
734 {
735 	char	*prompt;
736 	char	*data;
737 	int	type;
738 	int	echo;
739 	void	(*func) (char *, char *);
740 	struct	PromptStru	*next;
741 }	WaitPrompt;
742 
743 
744 typedef	struct	ScreenStru
745 {
746 	int	screennum;
747 	Window	*current_window;
748 	unsigned int	last_window_refnum;	/* reference number of the
749 						 * window that was last
750 						 * the current_window */
751 	Window	*window_list;			/* List of all visible
752 						 * windows */
753 	Window	*window_list_end;		/* end of visible window
754 						 * list */
755 	Window	*cursor_window;			/* Last window to have
756 						 * something written to it */
757 	int	visible_windows;		/* total number of windows */
758 	WindowStack	*window_stack;		/* the windows here */
759 
760 	struct	ScreenStru *prev;		/* These are the Screen list */
761 	struct	ScreenStru *next;		/* pointers */
762 
763 
764 	FILE	*fpin;				/* These are the file pointers */
765 	int	fdin;				/* and descriptions for the */
766 	FILE	*fpout;				/* screen's input/output */
767 	int	fdout;
768 
769 	char	input_buffer[INPUT_BUFFER_SIZE+2];	/* the input buffer */
770 	int	buffer_pos;			/* and the positions for the */
771 	int	buffer_min_pos;			/* screen */
772 
773 	int	input_cursor;
774 	char	*input_prompt;
775 
776 	int     input_visible;
777 	int     input_zone_len;
778 	int     input_start_zone;
779 	int     input_end_zone;
780 	int     input_prompt_len;
781 	int     input_prompt_malloc;
782 	int     input_line;
783 	Lastlog *lastlog_hold;
784 
785 	char	saved_input_buffer[INPUT_BUFFER_SIZE+2];
786 	int	saved_buffer_pos;
787 	int	saved_min_buffer_pos;
788 
789 	WaitPrompt	*promptlist;
790 
791 
792 
793 	int	meta_hit;
794 	int	quote_hit;			/* true if a key bound to
795 						 * QUOTE_CHARACTER has been
796 						 * hit. */
797 	int	digraph_hit;			/* A digraph key has been hit */
798 	unsigned char	digraph_first;
799 
800 
801 	char	*redirect_name;
802 	char	*redirect_token;
803 	int	redirect_server;
804 
805 	char	*tty_name;
806 	int	co;
807 	int	li;
808 	int	old_co;
809 	int	old_li;
810 #ifdef WINNT
811 	HANDLE  hStdin;
812 	HANDLE  hStdout;
813 #endif
814 #ifdef GUI
815 	int     nicklist;
816 #endif
817 #if defined(__EMXPM__) || defined(WIN32)
818 #ifndef WIN32
819 	HVPS	hvps,
820 			hvpsnick;
821 #endif
822 	HWND	hwndFrame,
823 			hwndClient,
824 			hwndMenu,
825 			hwndLeft,
826 			hwndRight,
827 			hwndnickscroll,
828 			hwndscroll;
829 	int		VIO_font_width,
830 			VIO_font_height,
831 			spos, mpos, codepage;
832 	char	aviokbdbuffer[256];
833 #elif defined(GTK)
834 	GtkWidget	*window,
835 			*viewport,
836 			*menubar,
837 			*scroller,
838 			*clist,
839 			*scrolledwindow,
840 			*box;
841 	GdkFont			*font;
842 	char            *fontname;
843 	GtkAdjustment	*adjust;
844 	GtkNotebookPage	*page;
845 	gint		gtkio;
846 	int 		pipe[2];
847 	int 		maxfontwidth,
848 				maxfontheight;
849 #endif
850 
851 	char	*menu;		/* windows menu struct */
852 
853 	int	alive;
854 }	Screen;
855 
856 /* BanList: structure for the list of bans on a channel */
857 typedef struct ban_stru
858 {
859 	struct	ban_stru	*next;  /* pointer to next ban entry */
860 	char	*ban;			/* the ban */
861 	char	*setby;			/* person who set the ban */
862 	int	sent_unban;		/* flag if sent unban or not */
863 	time_t	sent_unban_time;	/* sent unban's time */
864 	time_t	time;			/* time ban was set */
865 	int	count;
866 }	BanList;
867 
868 typedef struct _cset_stru
869 {
870 	struct _cset_stru *next;
871 	char	*channel;
872 	int	set_aop;		/* channel specific /set */
873 	int	set_annoy_kick;		/* channel specific /set */
874 	int	set_ainv;		/* channel specific /set */
875 	int	set_auto_join_on_invite;
876 	int	set_auto_rejoin;	/* channel specific /set */
877 	int	set_ctcp_flood_ban;
878 	int	set_deop_on_deopflood;	/* channel specific /set */
879 	int	set_deop_on_kickflood;	/* channel specific /set */
880 	int	set_deopflood;		/* channel specific /set */
881 	int	set_deopflood_time;	/* channel specific /set */
882 	int	set_hacking;		/* channel specific /set */
883 	int	set_kick_on_deopflood;	/* channel specific /set */
884 	int	set_kick_on_joinflood;
885 	int	set_kick_on_kickflood;	/* channel specific /set */
886 	int	set_kick_on_nickflood;	/* channel specific /set */
887 	int	set_kick_on_pubflood;	/* channel specific /set */
888 	int	set_kickflood;		/* channel specific /set */
889 	int	set_kickflood_time;	/* channel specific /set */
890 	int	set_nickflood;		/* channel specific /set */
891 	int	set_nickflood_time;	/* channel specific /set */
892 	int	set_joinflood;		/* channel specific /set */
893 	int	set_joinflood_time;	/* channel specific /set */
894 	int	set_pubflood;		/* channel specific /set */
895 	int	set_pubflood_ignore;	/* channel ignore time val */
896 	int	set_pubflood_time;	/* channel specific /set */
897 	int	set_userlist;		/* channel specific /set */
898 	int	set_shitlist;		/* channel specific /set */
899 	int	set_lame_ident;		/* channel specific /set */
900 	int	set_lamelist;		/* channel specific /set */
901 	int	set_kick_if_banned;     /* channel specific /set */
902 	int	bitch_mode;		/* channel specific /set */
903 	int	compress_modes;		/* channel specific /set */
904 	int	set_kick_ops;
905 	int	set_auto_limit;
906 	int	channel_log;
907 	int	set_bantime;
908 	char	*channel_log_file;
909 	char	*chanmode;
910 	unsigned long channel_log_level;
911 	char	*log_level;
912 } CSetList;
913 
914 typedef struct chan_flags_stru {
915 
916 	unsigned int got_modes : 1;
917 	unsigned int got_who : 1;
918 	unsigned int got_bans : 1;
919 	unsigned int got_exempt : 1;
920 } chan_flags;
921 
922 /* ChannelList: structure for the list of channels you are current on */
923 typedef	struct	channel_stru
924 {
925 	struct	channel_stru	*next;	/* pointer to next channel entry */
926 	char	*channel;		/* channel name */
927 	Window	*window;		/* the window that the channel is "on" */
928 	int	refnum;			/* window refnum */
929 	int	server;			/* server index for this channel */
930 	u_long	mode;			/* Current mode settings for channel */
931 	u_long	i_mode;			/* channel mode for cached string */
932 	char	*s_mode;		/* cached string version of modes */
933 	char	*topic;
934 	int	topic_lock;
935 
936 	char 	*modelock_key;
937 	long	modelock_val;
938 
939 	int	limit;			/* max users for the channel */
940 	time_t	limit_time;		/* time of last limit set */
941 	char	*key;			/* key for this channel */
942 	char	have_op;		/* true if you are a channel op */
943 	char	hop;			/* true if you are a half op */
944 	char	voice;			/* true if you are voice */
945 	char	bound;			/* true if channel is bound */
946 	char	*chanpass;		/* if TS4 then this has the channel pass */
947 	char	connected;		/* true if this channel is actually connected */
948 
949 	HashEntry	NickListTable[NICKLIST_HASHSIZE];
950 
951 	chan_flags	flags;
952 
953 	time_t	max_idle;		/* max idle time for this channel */
954 	int	tog_limit;
955 	int	check_idle;		/* toggle idle check */
956 	int	do_scan;		/* flag for checking auto stuff */
957 	struct timeval	channel_create;		/* time for channel creation */
958 	struct timeval	join_time;		/* time of last join */
959 
960 	int	stats_ops;		/* total ops I have seen in channel */
961 	int	stats_dops;		/* total dops I have seen in channel */
962 	int	stats_bans;		/* total bans I have seen in channel */
963 	int	stats_unbans;		/* total unbans I have seen in channel */
964 
965 	int	stats_sops;		/* total server ops I have seen in channel */
966 	int	stats_sdops;		/* total server dops I have seen in channel */
967 	int	stats_shops;
968 	int	stats_sdehops;
969 	int	stats_sebans;
970 	int	stats_sunebans;
971 	int	stats_sbans;		/* total server bans I have seen in channel */
972 	int	stats_sunbans;		/* total server unbans I have seen in channel */
973 
974 	int	stats_topics;		/* total topics I have seen in channel */
975 	int	stats_kicks;		/* total kicks I have seen in channel */
976 	int	stats_pubs;		/* total pubs I have seen in channel */
977 	int	stats_parts;		/* total parts I have seen in channel */
978 	int	stats_signoffs;		/* total signoffs I have seen in channel */
979 	int	stats_joins;		/* total joins I have seen in channel */
980 	int	stats_ebans;
981 	int	stats_unebans;
982 	int	stats_chanpass;
983 	int	stats_hops;
984 	int	stats_dhops;
985 
986 	CSetList *csets;		/* All Channel sets */
987 
988 	int	msglog_on;
989 	FILE	*msglog_fp;
990 	char	*logfile;
991 
992 	int	totalnicks;		/* total number of users in channel */
993 	int	maxnicks;		/* max number of users I have seen */
994 	time_t	maxnickstime;		/* time of max users */
995 
996 	int	totalbans;		/* total numbers of bans on channel */
997 
998 	BanList	*bans;			/* pointer to list of bans on channel */
999 	BanList	*exemptbans;		/* pointer to list of bans on channel */
1000 	int	maxbans;		/* max number of bans I have seen */
1001 	time_t	maxbanstime;		/* time of max bans */
1002 	struct {
1003 		char 	*op;
1004 		int	type;
1005 	} cmode[4];
1006 
1007 	char	*mode_buf;
1008 	int	mode_len;
1009 
1010 }	ChannelList;
1011 
1012 typedef	struct	list_stru
1013 {
1014 	struct	list_stru	*next;
1015 	char	*name;
1016 }	List;
1017 
1018 typedef struct	flood_stru
1019 {
1020 	struct flood_stru	*next;
1021 	char	*name;
1022 	char	*host;
1023 	char	*channel;
1024 	int	type;
1025 	char	flood;
1026 	unsigned long	cnt;
1027 	time_t	start;
1028 }	Flooding;
1029 
1030 
1031 typedef	struct	_ajoin_list
1032 {
1033 	struct	_ajoin_list *next;
1034 	char	*name;
1035 	char	*key;
1036 	char	*group;
1037 	int	server;
1038 	int	window;
1039 	int	ajoin_list;
1040 }	AJoinList;
1041 
1042 /* a structure for the timer list */
1043 typedef struct	timerlist_stru
1044 {
1045 	struct	timerlist_stru *next;
1046 	char	ref[REFNUM_MAX + 1];
1047 	unsigned long refno;
1048 struct	timeval	time;
1049 	int	(*callback) (void *, char *);
1050 	char	*command;
1051 	char	*subargs;
1052 	int	events;
1053 	time_t	interval;
1054 	int	server;
1055 	int	window;
1056 	char	*whom;
1057 	int	delete;
1058 }	TimerList;
1059 
1060 typedef struct nicktab_stru
1061 {
1062 	struct nicktab_stru *next;
1063 	char *nick;
1064 	char *type;
1065 } NickTab;
1066 
1067 typedef struct clonelist_stru
1068 {
1069 	struct clonelist_stru *next;
1070 	char *number;
1071 	char *server;
1072 	int  port;
1073 	int  socket_num;
1074 	int  warn;
1075 } CloneList;
1076 
1077 typedef struct IgnoreStru
1078 {
1079 	struct IgnoreStru *next;
1080 	char *nick;
1081 	long type;
1082 	long dont;
1083 	long high;
1084 	long cgrep;
1085 	int num;
1086 	char *pre_msg_high;
1087 	char *pre_nick_high;
1088 	char *post_high;
1089 	struct IgnoreStru *looking;
1090 	struct IgnoreStru *except;
1091 } Ignore;
1092 
1093 /* IrcVariable: structure for each variable in the variable table */
1094 typedef struct
1095 {
1096 	char	*name;			/* what the user types */
1097 	u_32int_t hash;
1098 	int	type;			/* variable types, see below */
1099 	int	integer;		/* int value of variable */
1100 	char	*string;		/* string value of variable */
1101 	void	(*func)(Window *, char *, int);		/* function to do every time variable is set */
1102 	char	int_flags;		/* internal flags to the variable */
1103 	unsigned short	flags;		/* flags for this variable */
1104 }	IrcVariable;
1105 
1106 /* IrcVariableDll: structure for each variable in the dll variable table */
1107 typedef struct _ircvariable
1108 {
1109 	struct _ircvariable *next;
1110 	char	*name;			/* what the user types */
1111 	char	*module;
1112 	int	type;			/* variable types, see below */
1113 	int	integer;		/* int value of variable */
1114 	char	*string;		/* string value of variable */
1115 	void	(*func)(Window *, char *, int);	/* function to do every time variable is set */
1116 	char	int_flags;		/* internal flags to the variable */
1117 	unsigned short	flags;		/* flags for this variable */
1118 }	IrcVariableDll;
1119 
1120 typedef struct _virtuals_struc
1121 {
1122 	struct _virtuals_struc *next;
1123 	char *address;      /* IPv4 or IPv6 address */
1124 	char *hostname;
1125 } Virtuals;
1126 
1127 
1128 #define ALIAS_MAXARGS 32
1129 
1130 struct ArgListT {
1131 	char *	vars[ALIAS_MAXARGS];
1132 	char *	defaults[ALIAS_MAXARGS];
1133 	int	void_flag;
1134 	int	dot_flag;
1135 };
1136 
1137 typedef struct ArgListT ArgList;
1138 
1139 typedef struct  AliasItemStru
1140 {
1141 	char    *name;                  /* name of alias */
1142 	u_32int_t hash;
1143 	char    *stuff;                 /* what the alias is */
1144 	char    *stub;                  /* the file its stubbed to */
1145 	int     global;                 /* set if loaded from global' */
1146 	int	cache_revoked;		/* Cache revocation index. */
1147 	int	debug;			/* debug invoke? */
1148 	ArgList *arglist;
1149 }	Alias;
1150 
1151 typedef	struct	notify_stru
1152 {
1153 	char	*nick;			/* Who are we watching? */
1154 	u_32int_t hash;
1155 	char 	*host;
1156 	char	*looking;
1157 	int	times;
1158 	time_t	lastseen;
1159 	time_t	period;
1160 	time_t	added;
1161 	int	flag;			/* Is the person on irc? */
1162 } NotifyItem;
1163 
1164 
1165 typedef struct notify_alist
1166 {
1167 	struct notify_stru	**list;
1168 	int			max;
1169 	int			max_alloc;
1170 	alist_func 		func;
1171 	hash_type		hash;
1172 	char *			ison;
1173 } NotifyList;
1174 
1175 typedef Window *(*window_func) (Window *, char **args, char *usage);
1176 
1177 typedef struct window_ops_T {
1178 	char		*command;
1179 	window_func	func;
1180 	char		*usage;
1181 } window_ops;
1182 
1183 
1184 typedef struct command_struct
1185 {
1186 	IrcCommand		*command_list;
1187 	window_ops		*window_commands;
1188 	BuiltInFunctions	*functions;
1189 	IrcVariable		*variables;
1190 	IrcVariable		*fsets;
1191 /*	CSetArray		*csets;
1192 	WSetArray		*wsets;*/
1193 	HashEntry		*parse;
1194 } CommandStruct;
1195 
1196 typedef void (*dcc_function) (char *, char *);
1197 
1198 typedef struct _DCC_dllcommands
1199 {
1200 	struct	_DCC_dllcommands *next;
1201 	char		*name;
1202 	dcc_function	function;
1203 	char		*help;
1204 	char		*module;
1205 } DCC_dllcommands;
1206 
1207 typedef struct _dcc_internal {
1208 	u_32int_t	struct_type;		/* type of socket */
1209 	char		*user;			/* user being dcc'd */
1210 	char		*userhost;		/* possible userhost */
1211 	int		server;			/* server from which this user came from */
1212 	char		*encrypt;		/* password used */
1213 	char		*filename;		/* filename without path or type*/
1214 	char		*othername;		/* possible other info */
1215 	u_32int_t	bytes_read;		/* number of bytes read */
1216 	u_32int_t	bytes_sent;		/* number of bytes sent */
1217 	struct timeval	starttime;		/* when did this dcc start */
1218 	struct timeval	lasttime;		/* last time of activity */
1219 	struct transfer_struct transfer_orders;	/* structure for resending files */
1220 	int		file;			/* file handle open file */
1221 	u_32int_t	filesize;		/* the filesize to get */
1222 	u_32int_t	packets;		/* number of blocksize packets recieved */
1223 	int		eof;			/* in EOF condition. */
1224 	int		blocksize;		/* this dcc's blocksize */
1225 	int		dcc_fast;		/* set if non-blocking used */
1226 	short		readwaiting; 		/* expect a data on the port */
1227 	unsigned short	remport;		/* the remport we are connected to */
1228 	unsigned short	localport;		/* the localport we are on */
1229 	struct	in_addr	remote;			/* this dcc's remote address */
1230 	unsigned int	dccnum;			/* dcc number we are at */
1231 	UserList	*ul;			/* is this person on the userlist */
1232 } DCC_int;
1233 
1234 typedef struct _dcc_struct_type {
1235 	u_32int_t 	struct_type;
1236 } dcc_struct_type;
1237 
1238 #endif /* __struct_h_ */
1239