File: irc.h

package info (click to toggle)
ircii 20051015-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,996 kB
  • ctags: 3,193
  • sloc: ansic: 44,257; makefile: 1,144; sh: 522; perl: 127; lex: 26
file content (409 lines) | stat: -rw-r--r-- 10,487 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/*
 * irc.h: header file for all of ircII! 
 *
 * Written By Michael Sandrof
 *
 * Copyright (c) 1990 Michael Sandrof.
 * Copyright (c) 1991, 1992 Troy Rollo.
 * Copyright (c) 1992-2004 Matthew R. Green.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * @(#)$eterna: irc.h,v 1.87 2005/09/21 20:17:38 mrg Exp $
 */

#ifndef __irc_h
#define __irc_h

#define IRCII_COMMENT   "this is a bug free client.  honest"

#ifdef __MSDOS__
#define IRCRC_NAME "/irc.rc"
#else
#define IRCRC_NAME "/.ircrc"
#endif

#ifdef __MSDOS__
#define IRCQUICK_NAME "/ircquick.rc"
#else
#define IRCQUICK_NAME "/.ircquick"
#endif

/*
 * Here you can set the in-line quote character, normally backslash, to
 * whatever you want.  Note that we use two backslashes since a backslash is
 * also C's quote character.  You do not need two of any other character.
 */
#define QUOTE_CHAR '\\'

#if defined(ISC30)		/* for some reason it doesn't get defined */
# define _POSIX_SOURCE
#endif /* ISC30 */

#include "defs.h"
#include "config.h"
#ifdef NeXT
#   include <libc.h>
#endif
#include <stdio.h>
#include <ctype.h>
#ifdef _Windows
#include <winsock.h>
#include <signal.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#ifndef WINS
#include <netinet/in.h>
#else
#include <sys/twg_config.h>
#include <sys/in.h>
#undef server
#endif /* WINS */
#include <arpa/inet.h>
#include <signal.h>
#include <sys/param.h>
#endif

#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif /* HAVE_SYS_TIME_H */
#endif /* TIME_WITH_SYS_TIME */

#ifdef HAVE_SYS_FCNTL_H
# include <sys/fcntl.h>
#endif /* HAVE_SYS_FCNTL_H */
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif /* HAVE_FCNTL_H */

/* machines we don't want to use <unistd.h> on 'cause its broken */
#if defined(pyr) || defined(_SEQUENT_)
# undef HAVE_UNISTD_H
#endif /* pyr || _SEQUENT_ */

#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */

#ifdef HAVE_SYS_FILE_H
# include <sys/file.h>
#endif /* HAVE_SYS_FILE_H */

#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif /* HAVE_NETDB_H */

#ifdef HAVE_PROCESS_H
# include <process.h>
#endif /* HAVE_PROCESS_H */

#ifdef HAVE_TERMCAP_H
# include <termcap.h>
#endif /* HAVE_TERMCAP_H */

#include <stdarg.h>

#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H */

#include "irc_std.h"
#include "debug.h"

/* these define what characters do, colour inverse, underline, bold and all off */
#define COLOUR_TAG	'\003'		/* ^C */
#define REV_TOG		'\026'		/* ^V */
#define UND_TOG		'\037'		/* ^_ */
#define BOLD_TOG	'\002'		/* ^B */
#define ALL_OFF		'\017'		/* ^O */
#define FULL_OFF	'\004'		/* internal, should be different than all others */

#define IRCD_BUFFER_SIZE	1024
#define BIG_BUFFER_SIZE		(IRCD_BUFFER_SIZE * 4)

#ifndef INPUT_BUFFER_SIZE
#define INPUT_BUFFER_SIZE	1536
/* INPUT_BUFFER_SIZE:
   irc servers generally accept 512 bytes of input per line.
   Assuming the shortest considerable command begins
   with "PRIVMSG x :" and ends with a linefeed, this
   leaves 500 bytes of space for text.
   In dcc-chats, the line length is unlimited.
   In ircII, the input buffer is utf-8 encoded. This means
   that certain european characters take two bytes of space
   and most asian characters take three bytes of space.
   ( Reference: http://www.utf-8.com/ )
   However, in some encodings that are used in IRC
   (such as ISO-8859-1 and SHIFT-JIS), some to most
   of those characters only take 1 byte of space.
   ( References: http://en.wikipedia.com/wiki/ISO_8859-1
     http://en.wikipeda.com/wiki/SJIS )
   Therefore, to be able to send a full 500-character line
   regardless of what characters it contains, we need 1500
   bytes of free buffer space.
   We also need room for the command used to send the message
   - for example, "/msg bisqwit,#nipponfever,#gurb ".
   For that space, we use an arbitrarily chosen number
   that is bigger than 20.
   As a result, INPUT_BUFFER_SIZE is now set to 1536 (0x600).
                         - Bisqwit
 */
#endif /* INPUT_BUFFER_SIZE */

#include "struct.h"

#ifdef notdef
# define DAEMON_UID 1
#endif

#if 0 /* blundernet */
#define NICKNAME_LEN 9
#endif
#define NAME_LEN 255
#define REALNAME_LEN 50
#define PATH_LEN 1024

#if defined(__hpux) || defined(hpux) || defined(_HPUX_SOURCE)
# undef HPUX
# define HPUX
# ifndef HPUX7
#  define killpg(pgrp,sig) kill(-pgrp,sig)
# endif /* !HPUX7 */
#endif /* __hpux || hpux || _HPUX_SOURCE */

#if defined(__sgi)
# define USE_TERMIO
#endif /* __sgi */

#ifdef DGUX
# define USE_TERMIO
# define inet_addr(x) inet_network(x)	/* dgux lossage */
#endif /* DGUX */

/*
 * Lame Linux doesn't define X_OK in a non-broken header file, so
 * we define it here.. 
 */
#if !defined(X_OK)
# define X_OK  1
#endif

#ifdef __BORLANDC__
# define F_OK 0
# define W_OK 2
# define R_OK 4
#endif

#ifdef __osf__
# if __osf__
#  define _BSD
# endif /* __osf__ */
#endif /* __osf__ */

#if defined(UNICOS) && !defined(USE_TERMIO)
# define USE_TERMIO
#endif /* UNICOS */

/* systems without getwd() can lose, if this dies */
#if defined(NEED_GETCWD)
# define getcwd(b, c)	getwd(b);
#endif /* NEED_GETCWD */

#if defined(ISC22) || defined(ISC30)
# define USE_TERMIO
# define ISC
#endif /* ISC22 || ISC30 */

#if defined(_AUX_SOURCE) && !defined(USE_TERMIO)
# define USE_TERMIO
#endif /* _AUX_SOURCE && !USE_TERMIO */

#ifdef MAIL_DIR
# undef UNIX_MAIL
# define UNIX_MAIL MAIL_DIR
#endif /* MAIL_DIR */

#ifndef MIN
# define MIN(a,b) ((a < b) ? (a) : (b))
#endif /* MIN */

#ifndef MAX
# define MAX(a,b) ((a < b) ? (b) : (a))
#endif /* MAX */

/* flags used by who() and whoreply() for who_mask */
#define WHO_OPS		0x0001
#define WHO_NAME	0x0002
#define WHO_ZERO	0x0004
#define WHO_CHOPS	0x0008
#define WHO_FILE	0x0010
#define WHO_HOST	0x0020
#define WHO_SERVER	0x0040
#define	WHO_HERE	0x0080
#define	WHO_AWAY	0x0100
#define	WHO_NICK	0x0200
#define	WHO_LUSERS	0x0400
#define	WHO_REAL	0x0800

#ifndef _Windows
# define FAR
#endif

#ifdef ICONV_CONST_ARG2
#define iconv_const const
#else
#define iconv_const
#endif

/*
 * declared in irc.c 
 */
extern	u_char	*cut_buffer;
extern	u_char	oper_command;
extern	int	irc_port;
extern	int	send_text_flag;
extern	int	irc_io_loop;
extern	int	break_io_processing;
extern	int	use_flow_control;
extern	u_char	*joined_nick;
extern	u_char	*public_nick;
extern	u_char	empty_string[];
extern	u_char	*zero;
extern	u_char	*one;

extern	u_char	irc_version[];
extern	u_char	*nickname;
extern	u_char	*ircrc_file;
extern	u_char	*ircquick_file;
extern	u_char	FAR hostname[];
extern	u_char	FAR realname[];
extern	u_char	FAR username[];
extern	u_char	*send_umode;
extern	u_char	*last_notify_nick;
extern	int	away_set;
extern	int	background;
extern	u_char	*my_path;
extern	u_char	*irc_path;
extern	u_char	*irc_lib;
extern	u_char	*args_str;
extern	u_char	*invite_channel;
extern	int	who_mask;
extern	u_char	*who_name;
extern	u_char	*who_host;
extern	u_char	*who_server;
extern	u_char	*who_file;
extern	u_char	*who_nick;
extern	u_char	*who_real;
extern	u_char	*cannot_open;
extern	int	dumb;
extern	int	use_input;
extern	time_t	idle_time;
extern	int	waiting;
extern	u_char	wait_nick[];
extern	u_char	whois_nick[];
extern	u_char	lame_wait_nick[];
extern	char	**environ;
extern	int	current_numeric;
extern	int	qflag;
extern	int	bflag;
extern	int	tflag;
extern	int	client_default_icb;
extern	u_char	*source_host;
extern	u_char	*dcc_source_host;

/*
 * XXX some of these should move to a new notice.h
 */
	int	irc_io(u_char *, void (*)(u_int, u_char *), int, int);
	void	set_irchost(u_char *);
	void	set_dcchost(u_char *);
	int	wild_match(u_char *, u_char *);
	RETSIGTYPE	irc_exit(void);
	void	beep_em(int);
	void	got_initial_version(u_char *);
	void	maybe_load_ircrc(void);
	void	load_ircrc(void);
	void	load_ircquick(void);
	void	parse_notice(u_char *, u_char **);
	void	irc_quit(u_int, u_char *);
	void	on_signal_occurred(int);

typedef	struct	WhoisStuffStru
{
	u_char	*nick;
	u_char	*user;
	u_char	*host;
	u_char	*channel;
	u_char	*channels;
	u_char	*name;
	u_char	*server;
	u_char	*server_stuff;
	u_char	*away;
	int	oper;
	int	chop;
	int	not_on;
}	WhoisStuff;

/* Moved into here, because some weird CC's can't do (void *) */
typedef	struct	WhoisQueueStru
{
	u_char	*nick;			/* nickname of whois'ed person(s) */
	u_char	*text;			/* additional text */
	int	type;			/* Type of WHOIS queue entry */
	/*
	 * called with func((WhoisStuff *)stuff, nick, text) 
	 */
	void	 (*func)(WhoisStuff *, u_char *, u_char *);
	struct	WhoisQueueStru	*next;	/* next element in queue */
}	WhoisQueue;

char	*getenv(const char *);
#ifdef _Windows
typedef long off_t;
extern u_char *get_path(int iVal);
#endif

#ifdef _Windows
#define	define_big_buffer(x)	u_char *x = (u_char *) new_malloc(BIG_BUFFER_SIZE + 1)
#define	free_big_buffer(x)	new_free(&x)
#else
#define	define_big_buffer(x)	u_char x[BIG_BUFFER_SIZE + 1]
#define	free_big_buffer(x)	(0)
#endif

#ifdef _Windows
#define IS_FULL_PATH(x) (x[0] == '/' || x[0] == '\\' || (x[0] && x[1] == ':'))
#else
#define IS_FULL_PATH(x) (x[0] == '/')
#endif

#endif /* __irc_h */