forked from unrealircd/unrealircd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys.h
297 lines (261 loc) · 6.89 KB
/
sys.h
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
/*
* Unreal Internet Relay Chat Daemon, include/sys.h
* Copyright (C) 1990 University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
#ifndef __sys_include__
#define __sys_include__
/* PATH_MAX */
#include <limits.h>
/* alloca stuff */
#ifdef _WIN32
# include <malloc.h>
# define alloca _alloca
#else /* _WIN32 */
# ifdef HAVE_ALLOCA
# if defined(_AIX) && !defined(__GNUC__)
#pragma alloca
# endif /* _AIX */
# if defined(HAVE_ALLOCA_H)
# include <alloca.h>
# endif /* HAVE_ALLOCA_H */
# if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && !defined(alloca)
# define alloca __builtin_alloca
# endif /* __GNUC__ */
# endif /* HAVE_ALLOCA */
#endif /* !_WIN32 */
#ifdef ISC202
#include <net/errno.h>
#else
#include <errno.h>
#endif
#include "setup.h"
#include <stdio.h>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/param.h>
#else
#include <stdarg.h>
#endif
#ifdef UNISTDH
#include <unistd.h>
#endif
#ifdef STDLIBH
#include <stdlib.h>
#endif
#ifdef STRINGSH
#include <strings.h>
#else
# ifdef STRINGH
# include <string.h>
# endif
#endif
/* get intptr_t if the system provides it -- otherwise, ./configure will define it for us */
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#endif /* HAVE_STDINT_H */
#ifdef SSL
#include <openssl/ssl.h>
#endif
#ifdef INET6
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#ifndef GOT_STRCASECMP
#define strcasecmp mycmp
#define strncasecmp myncmp
#endif
#ifdef NOINDEX
#define index strchr
#define rindex strrchr
/*
extern char *index(char *, char);
extern char *rindex(char *, char);
*/
#endif
#ifdef NOBCOPY
#define bcopy(x,y,z) memcpy(y,x,z)
#define bcmp(x,y,z) memcmp(x,y,z)
#define bzero(p,s) memset(p,0,s)
#endif
#ifdef AIX
#include <sys/select.h>
#endif
#if defined(HPUX )|| defined(AIX) || defined(_WIN32)
#include <time.h>
#ifdef AIX
#include <sys/time.h>
#endif
#else
#include <sys/time.h>
#endif
#ifdef NEXT
#define VOIDSIG int /* whether signal() returns int of void */
#else
#define VOIDSIG void /* whether signal() returns int of void */
#endif
#ifdef _SOLARIS
#define OPT_TYPE char /* opt type for get/setsockopt */
#else
#define OPT_TYPE void
#endif
/*
* Different name on NetBSD, FreeBSD, and BSDI
*/
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__linux__) || defined(__APPLE__)
#define dn_skipname __dn_skipname
#endif
/*
* Mac OS X Tiger Support (Intel Only)
*/
#if defined(macosx) || defined(__APPLE__)
#define OSXTIGER
#endif
#ifndef _WIN32
extern VOIDSIG dummy();
#endif
#ifdef NO_U_TYPES
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned long u_long;
typedef unsigned int u_int;
#endif
#ifdef _WIN32
#define MYOSNAME OSName
extern char OSName[256];
#define PATH_MAX MAX_PATH
#else
#define MYOSNAME getosname()
#endif
#ifdef DEBUGMODE
#endif
#ifdef _WIN32
typedef unsigned short u_int16_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
#endif
/*
* IPv4 or IPv6 structures?
*/
# define MYDUMMY_SIZE 128
#ifdef INET6
# define AND16(x) ((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5]&(x)[6]&(x)[7]&(x)[8]&(x)[9]&(x)[10]&(x)[11]&(x)[12]&(x)[13]&(x)[14]&(x)[15])
# define WHOSTENTP(x) ((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5]|(x)[6]|(x)[7]|(x)[8]|(x)[9]|(x)[10]|(x)[11]|(x)[12]|(x)[13]|(x)[14]|(x)[15])
# define AFINET AF_INET6
# define SOCKADDR_IN sockaddr_in6
# define SOCKADDR sockaddr
# define SIN_FAMILY sin6_family
# define SIN_PORT sin6_port
# define SIN_ADDR sin6_addr
# define S_ADDR s6_addr
# define IN_ADDR in6_addr
// # ifndef uint32_t
//# define uint32_t __u32
// # endif
char mydummy[MYDUMMY_SIZE];
char mydummy2[MYDUMMY_SIZE];
# if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(bsdi)
# ifndef s6_laddr
# define s6_laddr s6_addr32
# endif
# endif
# if defined(linux) && defined(NO_IN6ADDR_ANY)
static const struct in6_addr in6addr_any = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
};
# endif
# define IRCDCONF_DELIMITER '%'
#else
# define AFINET AF_INET
# define SOCKADDR_IN sockaddr_in
# define SOCKADDR sockaddr
# define SIN_FAMILY sin_family
# define SIN_PORT sin_port
# define SIN_ADDR sin_addr
# define S_ADDR s_addr
# define IN_ADDR in_addr
# define WHOSTENTP(x) (x)
# define IRCDCONF_DELIMITER ':'
#endif
/*
* Socket, File, and Error portability macros
*/
#ifndef _WIN32
#define SET_ERRNO(x) errno = x
#define READ_SOCK(fd, buf, len) read((fd), (buf), (len))
#define WRITE_SOCK(fd, buf, len) write((fd), (buf), (len))
#define CLOSE_SOCK(fd) close(fd)
#define IOCTL(x, y, z) ioctl((x), (y), (z))
#define ERRNO errno
#define STRERROR(x) strerror(x)
/* error constant portability */
#define P_EMFILE EMFILE
#define P_ENOBUFS ENOBUFS
#define P_EWOULDBLOCK EWOULDBLOCK
#define P_EAGAIN EAGAIN
#define P_EINPROGRESS EINPROGRESS
#define P_EWORKING EINPROGRESS
#define P_EINTR EINTR
#define P_ETIMEDOUT ETIMEDOUT
#define P_ENOTSOCK ENOTSOCK
#define P_EIO EIO
#define P_ECONNABORTED ECONNABORTED
#define P_ECONNRESET ECONNRESET
#define P_ENOTCONN ENOTCONN
#define P_EMSGSIZE EMSGSIZE
#else
/* WIN32 */
#define NETDB_INTERNAL -1 /* see errno */
#define NETDB_SUCCESS 0 /* no problem */
/* IO and Error portability macros */
#define READ_SOCK(fd, buf, len) recv((fd), (buf), (len), 0)
#define WRITE_SOCK(fd, buf, len) send((fd), (buf), (len), 0)
#define CLOSE_SOCK(fd) closesocket(fd)
#define IOCTL(x, y, z) ioctlsocket((x), (y), (z))
#define ERRNO WSAGetLastError()
#define STRERROR(x) sock_strerror(x)
#define SET_ERRNO(x) WSASetLastError(x)
/* Error constant portability */
#define P_EMFILE WSAEMFILE
#define P_ENOBUFS WSAENOBUFS
#define P_EWOULDBLOCK WSAEWOULDBLOCK
#define P_EAGAIN WSAEWOULDBLOCK
#define P_EINPROGRESS WSAEINPROGRESS
#define P_EWORKING WSAEWOULDBLOCK
#define P_EINTR WSAEINTR
#define P_ETIMEDOUT WSAETIMEDOUT
#define P_ENOTSOCK WSAENOTSOCK
#define P_EIO EIO
#define P_ECONNABORTED WSAECONNABORTED
#define P_ECONNRESET WSAECONNRESET
#define P_ENOTCONN WSAENOTCONN
#define P_EMSGSIZE WSAEMSGSIZE
#endif
#ifndef __GNUC__
#define __attribute__(x) /* nothing */
#endif
#endif /* __sys_include__ */