Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/include/irc_std.h
1069 views
1
/*
2
* irc_std.h: header to define things used in all the programs ircii
3
* comes with
4
*
5
* hacked together from various other files by matthew green
6
* copyright(c) 1993
7
*
8
* See the copyright file, or do a help ircii copyright
9
*
10
* @(#)$Id: irc_std.h 171 2012-05-10 12:31:04Z keaston $
11
*/
12
13
#ifndef __irc_std_h
14
#define __irc_std_h
15
#include "defs.h"
16
17
/*
18
* Everybody needs these ANSI headers...
19
*/
20
#include <stdio.h>
21
#include <string.h>
22
#include <stdlib.h>
23
#include <ctype.h>
24
#include <stdarg.h>
25
#include <stddef.h>
26
27
/*
28
* Everybody needs these POSIX headers...
29
*/
30
#include <sys/types.h>
31
#include <unistd.h>
32
#include <signal.h>
33
#include <limits.h>
34
#include <sys/param.h>
35
#include <errno.h>
36
37
/*
38
* Everybody needs these INET headers...
39
*/
40
#include <netinet/in.h>
41
#ifdef HAVE_ARPA_INET_H
42
#include <arpa/inet.h>
43
#endif
44
#ifdef HAVE_NETDB_H
45
#include <netdb.h>
46
#endif
47
48
/*
49
* Deal with brokenness in <time.h> and <sys/time.h>
50
*/
51
#ifdef TIME_WITH_SYS_TIME
52
# include <sys/time.h>
53
# include <time.h>
54
#else
55
# ifdef HAVE_SYS_TIME_H
56
# include <sys/time.h>
57
# else
58
# include <time.h>
59
# endif
60
#endif
61
62
/*
63
* Deal with brokenness in <fcntl.h> and <sys/fcntl.h>
64
*/
65
#ifdef HAVE_SYS_FCNTL_H
66
# include <sys/fcntl.h>
67
#else
68
# ifdef HAVE_FCNTL_H
69
# include <fcntl.h>
70
# endif
71
#endif
72
73
/*
74
* Deal with brokenness figuring out struct direct
75
*/
76
#if HAVE_DIRENT_H
77
# include <dirent.h>
78
# define NAMLEN(dirent) strlen((dirent)->d_name)
79
#else
80
# define dirent direct
81
# define NAMLEN(dirent) (dirent)->d_namlen
82
# if HAVE_SYS_NDIR_H
83
# include <sys/ndir.h>
84
# endif
85
# if HAVE_SYS_DIR_H
86
# include <sys/dir.h>
87
# endif
88
# if HAVE_NDIR_H
89
# include <ndir.h>
90
# endif
91
#endif
92
93
/*
94
* First try to figure out if we can use GNU CC special features...
95
*/
96
#ifndef __GNUC__
97
# define __inline /* delete gcc keyword */
98
# define __A(x)
99
# define __N
100
# define __inline__
101
#else
102
# if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))
103
# define __A(x) __attribute__ ((format (printf, x, x + 1)))
104
# define __N __attribute__ ((noreturn))
105
# else
106
# define __A(x)
107
# define __N
108
# define __inline
109
# endif
110
#endif
111
112
/*
113
* Figure out how to make alloca work
114
* I took this from the autoconf documentation
115
*/
116
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
117
# ifndef alloca
118
# define alloca __builtin_alloca
119
# endif
120
#else
121
# if HAVE_ALLOCA_H
122
# include <alloca.h>
123
# else
124
# ifdef _AIX
125
#pragma alloca
126
# else
127
# ifndef alloca
128
char *alloca();
129
# endif
130
# endif
131
# endif
132
#endif
133
134
# include <errno.h>
135
#ifndef ERRNO_DECLARED
136
extern int errno;
137
#endif
138
139
#ifndef NBBY
140
# define NBBY 8 /* number of bits in a byte */
141
#endif /* NBBY */
142
143
#ifndef NFDBITS
144
# define NFDBITS (sizeof(long) * NBBY) /* bits per mask */
145
#endif /* NFDBITS */
146
147
#ifndef FD_SETSIZE
148
#define FD_SETSIZE 256
149
#endif
150
151
#ifndef howmany
152
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
153
#endif
154
155
#include <limits.h>
156
157
typedef RETSIGTYPE sigfunc (int);
158
sigfunc *my_signal (int, sigfunc *, int);
159
160
#define SIGNAL_HANDLER(x) \
161
RETSIGTYPE x (int unused)
162
163
#include <stdlib.h>
164
#define index strchr
165
166
#ifndef MAXPATHLEN
167
#ifndef PATHSIZE
168
#define PATHSIZE 1024
169
#endif
170
#define MAXPATHLEN PATHSIZE
171
#endif
172
173
/*
174
* Dont trust anyone else's NULLs.
175
*/
176
#ifdef NULL
177
#undef NULL
178
#endif
179
#define NULL (void *) 0
180
181
#ifndef HAVE_STRERROR
182
#ifndef SYS_ERRLIST_DECLARED
183
extern char *sys_errlist[];
184
#endif
185
#define strerror(x) (char *)sys_errlist[x]
186
#endif
187
188
#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
189
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
190
#endif
191
192
#ifndef GETPGID_DECLARED
193
pid_t getpgid (pid_t pid);
194
#endif
195
196
#ifndef KILLPG_DECLARED
197
int killpg (int pgrp, int sig);
198
#endif
199
200
#ifndef GETPASS_DECLARED
201
char * getpass (const char * prompt);
202
#endif
203
204
#ifndef BCOPY_DECLARED
205
void bcopy (const void *src, void *dest, size_t n);
206
#endif
207
208
#define BUILT_IN_COMMAND(x) \
209
void x (char *command, char *args, char *subargs, char *helparg)
210
211
#define BUILT_IN_FUNCTION(x) \
212
char * x (char *fn, char *input)
213
214
#if defined(_AIX)
215
int getpeername (int s, struct sockaddr *, int *);
216
int getsockname (int s, struct sockaddr *, int *);
217
int socket (int, int, int);
218
int bind (int, struct sockaddr *, int);
219
int listen (int, int);
220
int accept (int, struct sockaddr *, int *);
221
int recv (int, void *, int, unsigned int);
222
int send (int, void *, int, unsigned int);
223
int gettimeofday (struct timeval *, struct timezone *);
224
int gethostname (char *, int);
225
int setsockopt (int, int, int, void *, int);
226
int setitimer (int, struct itimerval *, struct itimerval *);
227
int ioctl (int, int, ...);
228
#endif
229
230
#ifdef __EMX__
231
#define strcasecmp stricmp
232
#define strncasecmp strnicmp
233
#endif
234
235
#define ltoa(a) my_ltoa(a)
236
237
/*
238
* DCC specification requires exactly a 32 bit checksum.
239
* Kind of lame, actually.
240
*/
241
#ifdef UNSIGNED_LONG32
242
typedef unsigned long u_32int_t;
243
#else
244
# ifdef UNSIGNED_INT32
245
typedef unsigned int u_32int_t;
246
# else
247
typedef unsigned long u_32int_t;
248
# endif
249
#endif
250
251
#if !HAVE_DECL_SYS_SIGLIST && HAVE_DECL__SYS_SIGLIST
252
#define sys_siglist _sys_siglist
253
#endif
254
#endif /* __irc_std_h */
255
256