]>
Commit | Line | Data |
---|---|---|
e52ca1e5 | 1 | /* |
2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * 1. Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * 2. Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * | |
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
23 | */ | |
24 | ||
76a8e733 | 25 | #ifndef _DEFINES_H |
26 | #define _DEFINES_H | |
27 | ||
0b202697 | 28 | /* $Id$ */ |
29 | ||
41cb4569 | 30 | |
ea1970a3 | 31 | /* Constants */ |
32 | ||
cb807f40 | 33 | #ifndef SHUT_RDWR |
34 | enum | |
35 | { | |
36 | SHUT_RD = 0, /* No more receptions. */ | |
37 | SHUT_WR, /* No more transmissions. */ | |
38 | SHUT_RDWR /* No more receptions or transmissions. */ | |
39 | }; | |
40 | # define SHUT_RD SHUT_RD | |
41 | # define SHUT_WR SHUT_WR | |
42 | # define SHUT_RDWR SHUT_RDWR | |
43 | #endif | |
44 | ||
18e92801 | 45 | #ifndef IPTOS_LOWDELAY |
46 | # define IPTOS_LOWDELAY 0x10 | |
47 | # define IPTOS_THROUGHPUT 0x08 | |
48 | # define IPTOS_RELIABILITY 0x04 | |
49 | # define IPTOS_LOWCOST 0x02 | |
50 | # define IPTOS_MINCOST IPTOS_LOWCOST | |
51 | #endif /* IPTOS_LOWDELAY */ | |
52 | ||
509b1f88 | 53 | #ifndef MAXPATHLEN |
54 | # ifdef PATH_MAX | |
55 | # define MAXPATHLEN PATH_MAX | |
56 | # else /* PATH_MAX */ | |
39ff6527 | 57 | # define MAXPATHLEN 64 |
58 | /* realpath uses a fixed buffer of size MAXPATHLEN, so force use of ours */ | |
59 | # ifndef BROKEN_REALPATH | |
60 | # define BROKEN_REALPATH 1 | |
61 | # endif /* BROKEN_REALPATH */ | |
509b1f88 | 62 | # endif /* PATH_MAX */ |
63 | #endif /* MAXPATHLEN */ | |
64 | ||
1a9ecc62 | 65 | #ifndef MAXSYMLINKS |
66 | # define MAXSYMLINKS 5 | |
67 | #endif | |
68 | ||
2b87da3b | 69 | #ifndef STDIN_FILENO |
729bfe59 | 70 | # define STDIN_FILENO 0 |
2b87da3b | 71 | #endif |
72 | #ifndef STDOUT_FILENO | |
729bfe59 | 73 | # define STDOUT_FILENO 1 |
2b87da3b | 74 | #endif |
75 | #ifndef STDERR_FILENO | |
729bfe59 | 76 | # define STDERR_FILENO 2 |
2b87da3b | 77 | #endif |
729bfe59 | 78 | |
99286dc8 | 79 | #ifndef NGROUPS_MAX /* Disable groupaccess if NGROUP_MAX is not set */ |
b81c369b | 80 | #ifdef NGROUPS |
81 | #define NGROUPS_MAX NGROUPS | |
82 | #else | |
99286dc8 | 83 | #define NGROUPS_MAX 0 |
1fc243d1 | 84 | #endif |
b81c369b | 85 | #endif |
1fc243d1 | 86 | |
f1c4659d | 87 | #ifndef O_NONBLOCK /* Non Blocking Open */ |
2b87da3b | 88 | # define O_NONBLOCK 00004 |
f1c4659d | 89 | #endif |
90 | ||
610e8ff5 | 91 | #ifndef S_ISDIR |
729bfe59 | 92 | # define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) |
610e8ff5 | 93 | #endif /* S_ISDIR */ |
94 | ||
aff51935 | 95 | #ifndef S_ISREG |
729bfe59 | 96 | # define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) |
97 | #endif /* S_ISREG */ | |
98 | ||
610e8ff5 | 99 | #ifndef S_ISLNK |
3743cc2f | 100 | # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) |
610e8ff5 | 101 | #endif /* S_ISLNK */ |
102 | ||
729bfe59 | 103 | #ifndef S_IXUSR |
104 | # define S_IXUSR 0000100 /* execute/search permission, */ | |
105 | # define S_IXGRP 0000010 /* execute/search permission, */ | |
106 | # define S_IXOTH 0000001 /* execute/search permission, */ | |
107 | # define _S_IWUSR 0000200 /* write permission, */ | |
108 | # define S_IWUSR _S_IWUSR /* write permission, owner */ | |
109 | # define S_IWGRP 0000020 /* write permission, group */ | |
110 | # define S_IWOTH 0000002 /* write permission, other */ | |
111 | # define S_IRUSR 0000400 /* read permission, owner */ | |
112 | # define S_IRGRP 0000040 /* read permission, group */ | |
113 | # define S_IROTH 0000004 /* read permission, other */ | |
114 | # define S_IRWXU 0000700 /* read, write, execute */ | |
115 | # define S_IRWXG 0000070 /* read, write, execute */ | |
116 | # define S_IRWXO 0000007 /* read, write, execute */ | |
117 | #endif /* S_IXUSR */ | |
118 | ||
7b0737a4 | 119 | #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) |
120 | #define MAP_ANON MAP_ANONYMOUS | |
121 | #endif | |
122 | ||
123 | #ifndef MAP_FAILED | |
124 | # define MAP_FAILED ((void *)-1) | |
125 | #endif | |
126 | ||
41cb4569 | 127 | /* *-*-nto-qnx doesn't define this constant in the system headers */ |
128 | #ifdef MISSING_NFDBITS | |
129 | # define NFDBITS (8 * sizeof(unsigned long)) | |
130 | #endif | |
131 | ||
ddceb1c8 | 132 | /* |
133 | SCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but | |
134 | including rpc/rpc.h breaks Solaris 6 | |
135 | */ | |
136 | #ifndef INADDR_LOOPBACK | |
7f8e513b | 137 | #define INADDR_LOOPBACK ((u_long)0x7f000001) |
ddceb1c8 | 138 | #endif |
139 | ||
b3f87f4f | 140 | #ifndef __unused |
141 | #define __unused | |
142 | #endif | |
143 | ||
ea1970a3 | 144 | /* Types */ |
145 | ||
cb807f40 | 146 | /* If sys/types.h does not supply intXX_t, supply them ourselves */ |
147 | /* (or die trying) */ | |
14a9a859 | 148 | |
30eac028 | 149 | |
14a9a859 | 150 | #ifndef HAVE_U_INT |
151 | typedef unsigned int u_int; | |
152 | #endif | |
153 | ||
cb807f40 | 154 | #ifndef HAVE_INTXX_T |
976f7e19 | 155 | # if (SIZEOF_CHAR == 1) |
156 | typedef char int8_t; | |
157 | # else | |
158 | # error "8 bit int type not found." | |
159 | # endif | |
cb807f40 | 160 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 161 | typedef short int int16_t; |
cb807f40 | 162 | # else |
ef51930f | 163 | # ifdef _UNICOS |
ddceb1c8 | 164 | # if (SIZEOF_SHORT_INT == 4) |
165 | typedef short int16_t; | |
166 | # else | |
3d114925 | 167 | typedef long int16_t; |
ddceb1c8 | 168 | # endif |
3d114925 | 169 | # else |
170 | # error "16 bit int type not found." | |
ef51930f | 171 | # endif /* _UNICOS */ |
cb807f40 | 172 | # endif |
173 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 174 | typedef int int32_t; |
cb807f40 | 175 | # else |
ef51930f | 176 | # ifdef _UNICOS |
3d114925 | 177 | typedef long int32_t; |
178 | # else | |
179 | # error "32 bit int type not found." | |
ef51930f | 180 | # endif /* _UNICOS */ |
cb807f40 | 181 | # endif |
cb807f40 | 182 | #endif |
183 | ||
184 | /* If sys/types.h does not supply u_intXX_t, supply them ourselves */ | |
185 | #ifndef HAVE_U_INTXX_T | |
186 | # ifdef HAVE_UINTXX_T | |
976f7e19 | 187 | typedef uint8_t u_int8_t; |
ea1970a3 | 188 | typedef uint16_t u_int16_t; |
189 | typedef uint32_t u_int32_t; | |
76a8e733 | 190 | # define HAVE_U_INTXX_T 1 |
cb807f40 | 191 | # else |
976f7e19 | 192 | # if (SIZEOF_CHAR == 1) |
193 | typedef unsigned char u_int8_t; | |
194 | # else | |
195 | # error "8 bit int type not found." | |
196 | # endif | |
cb807f40 | 197 | # if (SIZEOF_SHORT_INT == 2) |
ea1970a3 | 198 | typedef unsigned short int u_int16_t; |
cb807f40 | 199 | # else |
ef51930f | 200 | # ifdef _UNICOS |
ddceb1c8 | 201 | # if (SIZEOF_SHORT_INT == 4) |
202 | typedef unsigned short u_int16_t; | |
203 | # else | |
3d114925 | 204 | typedef unsigned long u_int16_t; |
ddceb1c8 | 205 | # endif |
3d114925 | 206 | # else |
207 | # error "16 bit int type not found." | |
208 | # endif | |
cb807f40 | 209 | # endif |
210 | # if (SIZEOF_INT == 4) | |
ea1970a3 | 211 | typedef unsigned int u_int32_t; |
cb807f40 | 212 | # else |
ef51930f | 213 | # ifdef _UNICOS |
3d114925 | 214 | typedef unsigned long u_int32_t; |
215 | # else | |
216 | # error "32 bit int type not found." | |
217 | # endif | |
cb807f40 | 218 | # endif |
bd590612 | 219 | # endif |
224cbdcc | 220 | #define __BIT_TYPES_DEFINED__ |
bd590612 | 221 | #endif |
222 | ||
223 | /* 64-bit types */ | |
224 | #ifndef HAVE_INT64_T | |
225 | # if (SIZEOF_LONG_INT == 8) | |
226 | typedef long int int64_t; | |
227 | # else | |
228 | # if (SIZEOF_LONG_LONG_INT == 8) | |
229 | typedef long long int int64_t; | |
bd590612 | 230 | # endif |
231 | # endif | |
232 | #endif | |
233 | #ifndef HAVE_U_INT64_T | |
234 | # if (SIZEOF_LONG_INT == 8) | |
235 | typedef unsigned long int u_int64_t; | |
236 | # else | |
237 | # if (SIZEOF_LONG_LONG_INT == 8) | |
ea1970a3 | 238 | typedef unsigned long long int u_int64_t; |
cb807f40 | 239 | # endif |
240 | # endif | |
241 | #endif | |
242 | ||
0362750e | 243 | #ifndef HAVE_U_CHAR |
244 | typedef unsigned char u_char; | |
245 | # define HAVE_U_CHAR | |
246 | #endif /* HAVE_U_CHAR */ | |
247 | ||
7d3b91a6 | 248 | #ifndef SIZE_T_MAX |
249 | #define SIZE_T_MAX ULONG_MAX | |
250 | #endif /* SIZE_T_MAX */ | |
251 | ||
e3a93db0 | 252 | #ifndef HAVE_SIZE_T |
253 | typedef unsigned int size_t; | |
a6ddc88b | 254 | # define HAVE_SIZE_T |
56b13279 | 255 | # define SIZE_T_MAX UINT_MAX |
e3a93db0 | 256 | #endif /* HAVE_SIZE_T */ |
257 | ||
c04f75f1 | 258 | #ifndef HAVE_SSIZE_T |
259 | typedef int ssize_t; | |
260 | # define HAVE_SSIZE_T | |
261 | #endif /* HAVE_SSIZE_T */ | |
262 | ||
f1c4659d | 263 | #ifndef HAVE_CLOCK_T |
264 | typedef long clock_t; | |
265 | # define HAVE_CLOCK_T | |
4f771a33 | 266 | #endif /* HAVE_CLOCK_T */ |
f1c4659d | 267 | |
1c04b088 | 268 | #ifndef HAVE_SA_FAMILY_T |
269 | typedef int sa_family_t; | |
270 | # define HAVE_SA_FAMILY_T | |
271 | #endif /* HAVE_SA_FAMILY_T */ | |
272 | ||
729bfe59 | 273 | #ifndef HAVE_PID_T |
274 | typedef int pid_t; | |
275 | # define HAVE_PID_T | |
276 | #endif /* HAVE_PID_T */ | |
277 | ||
ddceb1c8 | 278 | #ifndef HAVE_SIG_ATOMIC_T |
279 | typedef int sig_atomic_t; | |
280 | # define HAVE_SIG_ATOMIC_T | |
281 | #endif /* HAVE_SIG_ATOMIC_T */ | |
282 | ||
729bfe59 | 283 | #ifndef HAVE_MODE_T |
284 | typedef int mode_t; | |
285 | # define HAVE_MODE_T | |
286 | #endif /* HAVE_MODE_T */ | |
287 | ||
48e671d5 | 288 | #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) |
289 | # define ss_family __ss_family | |
290 | #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ | |
291 | ||
77bb0bca | 292 | #ifndef HAVE_SYS_UN_H |
293 | struct sockaddr_un { | |
294 | short sun_family; /* AF_UNIX */ | |
295 | char sun_path[108]; /* path name (gag) */ | |
296 | }; | |
297 | #endif /* HAVE_SYS_UN_H */ | |
298 | ||
7b578f7d | 299 | #ifndef HAVE_IN_ADDR_T |
300 | typedef u_int32_t in_addr_t; | |
301 | #endif | |
302 | ||
77bb0bca | 303 | #if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE) |
304 | #define _STRUCT_WINSIZE | |
305 | struct winsize { | |
306 | unsigned short ws_row; /* rows, in characters */ | |
307 | unsigned short ws_col; /* columns, in character */ | |
308 | unsigned short ws_xpixel; /* horizontal size, pixels */ | |
309 | unsigned short ws_ypixel; /* vertical size, pixels */ | |
310 | }; | |
311 | #endif | |
312 | ||
41cb4569 | 313 | /* *-*-nto-qnx does not define this type in the system headers */ |
314 | #ifdef MISSING_FD_MASK | |
315 | typedef unsigned long int fd_mask; | |
316 | #endif | |
317 | ||
ea1970a3 | 318 | /* Paths */ |
319 | ||
cb807f40 | 320 | #ifndef _PATH_BSHELL |
321 | # define _PATH_BSHELL "/bin/sh" | |
322 | #endif | |
7cdb79d4 | 323 | #ifndef _PATH_CSHELL |
324 | # define _PATH_CSHELL "/bin/csh" | |
325 | #endif | |
326 | #ifndef _PATH_SHELLS | |
327 | # define _PATH_SHELLS "/etc/shells" | |
328 | #endif | |
cb807f40 | 329 | |
330 | #ifdef USER_PATH | |
331 | # ifdef _PATH_STDPATH | |
332 | # undef _PATH_STDPATH | |
333 | # endif | |
334 | # define _PATH_STDPATH USER_PATH | |
335 | #endif | |
336 | ||
337 | #ifndef _PATH_STDPATH | |
338 | # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" | |
339 | #endif | |
340 | ||
95b99395 | 341 | #ifndef SUPERUSER_PATH |
342 | # define SUPERUSER_PATH _PATH_STDPATH | |
343 | #endif | |
344 | ||
cb807f40 | 345 | #ifndef _PATH_DEVNULL |
346 | # define _PATH_DEVNULL "/dev/null" | |
347 | #endif | |
348 | ||
c04f75f1 | 349 | #ifndef MAIL_DIRECTORY |
350 | # define MAIL_DIRECTORY "/var/spool/mail" | |
351 | #endif | |
352 | ||
cb807f40 | 353 | #ifndef MAILDIR |
354 | # define MAILDIR MAIL_DIRECTORY | |
355 | #endif | |
356 | ||
357 | #if !defined(_PATH_MAILDIR) && defined(MAILDIR) | |
358 | # define _PATH_MAILDIR MAILDIR | |
359 | #endif /* !defined(_PATH_MAILDIR) && defined(MAILDIR) */ | |
360 | ||
2e73a022 | 361 | #ifndef _PATH_NOLOGIN |
362 | # define _PATH_NOLOGIN "/etc/nologin" | |
363 | #endif | |
364 | ||
2f125ca1 | 365 | /* Define this to be the path of the xauth program. */ |
fef01705 | 366 | #ifdef XAUTH_PATH |
367 | #define _PATH_XAUTH XAUTH_PATH | |
2f125ca1 | 368 | #endif /* XAUTH_PATH */ |
369 | ||
1d2a4613 | 370 | /* derived from XF4/xc/lib/dps/Xlibnet.h */ |
371 | #ifndef X_UNIX_PATH | |
5cbceb3f | 372 | # ifdef __hpux |
373 | # define X_UNIX_PATH "/var/spool/sockets/X11/%u" | |
374 | # else | |
375 | # define X_UNIX_PATH "/tmp/.X11-unix/X%u" | |
376 | # endif | |
1d2a4613 | 377 | #endif /* X_UNIX_PATH */ |
378 | #define _PATH_UNIX_X X_UNIX_PATH | |
379 | ||
bc79ed5c | 380 | #ifndef _PATH_TTY |
381 | # define _PATH_TTY "/dev/tty" | |
382 | #endif | |
383 | ||
ea1970a3 | 384 | /* Macros */ |
385 | ||
2e73a022 | 386 | #if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) |
387 | # define HAVE_LOGIN_CAP | |
388 | #endif | |
389 | ||
cb807f40 | 390 | #ifndef MAX |
391 | # define MAX(a,b) (((a)>(b))?(a):(b)) | |
392 | # define MIN(a,b) (((a)<(b))?(a):(b)) | |
393 | #endif | |
394 | ||
0ae4fe1d | 395 | #ifndef roundup |
396 | # define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | |
397 | #endif | |
398 | ||
cb807f40 | 399 | #ifndef timersub |
0ae4fe1d | 400 | #define timersub(a, b, result) \ |
401 | do { \ | |
402 | (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | |
403 | (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | |
404 | if ((result)->tv_usec < 0) { \ | |
405 | --(result)->tv_sec; \ | |
406 | (result)->tv_usec += 1000000; \ | |
407 | } \ | |
cb807f40 | 408 | } while (0) |
409 | #endif | |
410 | ||
c7578bb6 | 411 | #ifndef TIMEVAL_TO_TIMESPEC |
412 | #define TIMEVAL_TO_TIMESPEC(tv, ts) { \ | |
413 | (ts)->tv_sec = (tv)->tv_sec; \ | |
414 | (ts)->tv_nsec = (tv)->tv_usec * 1000; \ | |
415 | } | |
416 | #endif | |
417 | ||
418 | #ifndef TIMESPEC_TO_TIMEVAL | |
419 | #define TIMESPEC_TO_TIMEVAL(tv, ts) { \ | |
420 | (tv)->tv_sec = (ts)->tv_sec; \ | |
421 | (tv)->tv_usec = (ts)->tv_nsec / 1000; \ | |
422 | } | |
423 | #endif | |
424 | ||
cb807f40 | 425 | #ifndef __P |
426 | # define __P(x) x | |
427 | #endif | |
428 | ||
a8ed9fd9 | 429 | #if !defined(IN6_IS_ADDR_V4MAPPED) |
430 | # define IN6_IS_ADDR_V4MAPPED(a) \ | |
84afc958 | 431 | ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ |
432 | (((u_int32_t *) (a))[2] == htonl (0xffff))) | |
a8ed9fd9 | 433 | #endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ |
434 | ||
cb807f40 | 435 | #if !defined(__GNUC__) || (__GNUC__ < 2) |
976f7e19 | 436 | # define __attribute__(x) |
cb807f40 | 437 | #endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ |
438 | ||
8a946417 | 439 | #ifndef __dead |
440 | # define __dead __attribute__((noreturn)) | |
441 | #endif | |
442 | ||
5b7b5e23 | 443 | #if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__) |
444 | # define __sentinel__ | |
445 | #endif | |
446 | ||
41cb4569 | 447 | /* *-*-nto-qnx doesn't define this macro in the system headers */ |
448 | #ifdef MISSING_HOWMANY | |
449 | # define howmany(x,y) (((x)+((y)-1))/(y)) | |
450 | #endif | |
451 | ||
2805b943 | 452 | #ifndef OSSH_ALIGNBYTES |
453 | #define OSSH_ALIGNBYTES (sizeof(int) - 1) | |
cfadc43b | 454 | #endif |
455 | #ifndef __CMSG_ALIGN | |
2805b943 | 456 | #define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES) |
cfadc43b | 457 | #endif |
458 | ||
459 | /* Length of the contents of a control message of length len */ | |
460 | #ifndef CMSG_LEN | |
461 | #define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) | |
462 | #endif | |
463 | ||
464 | /* Length of the space taken up by a padded control message of length len */ | |
465 | #ifndef CMSG_SPACE | |
466 | #define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len)) | |
467 | #endif | |
468 | ||
a814ba4d | 469 | /* given pointer to struct cmsghdr, return pointer to data */ |
470 | #ifndef CMSG_DATA | |
471 | #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr))) | |
472 | #endif /* CMSG_DATA */ | |
473 | ||
474 | /* | |
475 | * RFC 2292 requires to check msg_controllen, in case that the kernel returns | |
476 | * an empty list for some reasons. | |
477 | */ | |
478 | #ifndef CMSG_FIRSTHDR | |
479 | #define CMSG_FIRSTHDR(mhdr) \ | |
480 | ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ | |
481 | (struct cmsghdr *)(mhdr)->msg_control : \ | |
482 | (struct cmsghdr *)NULL) | |
483 | #endif /* CMSG_FIRSTHDR */ | |
484 | ||
5e96b616 | 485 | #ifndef offsetof |
486 | # define offsetof(type, member) ((size_t) &((type *)0)->member) | |
487 | #endif | |
a814ba4d | 488 | |
ea1970a3 | 489 | /* Function replacement / compatibility hacks */ |
490 | ||
520b41b2 | 491 | #if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) |
492 | # define HAVE_GETADDRINFO | |
493 | #endif | |
494 | ||
7b0737a4 | 495 | #ifndef HAVE_GETOPT_OPTRESET |
d76aa6fb | 496 | # undef getopt |
497 | # undef opterr | |
498 | # undef optind | |
499 | # undef optopt | |
500 | # undef optreset | |
501 | # undef optarg | |
502 | # define getopt(ac, av, o) BSDgetopt(ac, av, o) | |
503 | # define opterr BSDopterr | |
504 | # define optind BSDoptind | |
505 | # define optopt BSDoptopt | |
506 | # define optreset BSDoptreset | |
507 | # define optarg BSDoptarg | |
7b0737a4 | 508 | #endif |
509 | ||
ea1970a3 | 510 | /* In older versions of libpam, pam_strerror takes a single argument */ |
511 | #ifdef HAVE_OLD_PAM | |
512 | # define PAM_STRERROR(a,b) pam_strerror((b)) | |
513 | #else | |
514 | # define PAM_STRERROR(a,b) pam_strerror((a),(b)) | |
515 | #endif | |
516 | ||
adeebd37 | 517 | #ifdef PAM_SUN_CODEBASE |
518 | # define PAM_MSG_MEMBER(msg, n, member) ((*(msg))[(n)].member) | |
519 | #else | |
520 | # define PAM_MSG_MEMBER(msg, n, member) ((msg)[(n)]->member) | |
521 | #endif | |
522 | ||
4c8ef3fb | 523 | #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) |
524 | # undef HAVE_GETADDRINFO | |
488c06c8 | 525 | #endif |
526 | #if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO) | |
527 | # undef HAVE_FREEADDRINFO | |
528 | #endif | |
529 | #if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR) | |
530 | # undef HAVE_GAI_STRERROR | |
531 | #endif | |
4c8ef3fb | 532 | |
3d59832f | 533 | #if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX) |
534 | # undef HAVE_UPDWTMPX | |
535 | #endif | |
536 | ||
c04f75f1 | 537 | #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) |
538 | # define memmove(s1, s2, n) bcopy((s2), (s1), (n)) | |
539 | #endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ | |
540 | ||
86c9e193 | 541 | #if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) |
3c62e7eb | 542 | # define USE_VHANGUP |
86c9e193 | 543 | #endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ |
3c62e7eb | 544 | |
7f8f5e00 | 545 | #ifndef GETPGRP_VOID |
546 | # define getpgrp() getpgrp(0) | |
547 | #endif | |
548 | ||
7b578f7d | 549 | #ifdef USE_BSM_AUDIT |
550 | # define SSH_AUDIT_EVENTS | |
551 | # define CUSTOM_SSH_AUDIT_EVENTS | |
552 | #endif | |
553 | ||
58389b85 | 554 | /* OPENSSL_free() is Free() in versions before OpenSSL 0.9.6 */ |
555 | #if !defined(OPENSSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x0090600f) | |
556 | # define OPENSSL_free(x) Free(x) | |
557 | #endif | |
558 | ||
d4d77d64 | 559 | #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) |
560 | # define __func__ __FUNCTION__ | |
561 | #elif !defined(HAVE___func__) | |
562 | # define __func__ "" | |
c921ee00 | 563 | #endif |
564 | ||
749560dd | 565 | #if defined(KRB5) && !defined(HEIMDAL) |
566 | # define krb5_get_err_text(context,code) error_message(code) | |
567 | #endif | |
568 | ||
f2b7b5c8 | 569 | #if defined(SKEYCHALLENGE_4ARG) |
570 | # define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d) | |
571 | #else | |
572 | # define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c) | |
573 | #endif | |
574 | ||
341c3efe | 575 | /* Maximum number of file descriptors available */ |
576 | #ifdef HAVE_SYSCONF | |
577 | # define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX) | |
578 | #else | |
579 | # define SSH_SYSFDMAX 10000 | |
580 | #endif | |
581 | ||
157b6700 | 582 | #if defined(__Lynx__) |
583 | /* | |
584 | * LynxOS defines these in param.h which we do not want to include since | |
585 | * it will also pull in a bunch of kernel definitions. | |
586 | */ | |
587 | # define ALIGNBYTES (sizeof(int) - 1) | |
588 | # define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) | |
589 | /* Missing prototypes on LynxOS */ | |
590 | int snprintf (char *, size_t, const char *, ...); | |
591 | int mkstemp (char *); | |
592 | char *crypt (const char *, const char *); | |
593 | int seteuid (uid_t); | |
594 | int setegid (gid_t); | |
595 | char *mkdtemp (char *); | |
596 | int rresvport_af (int *, sa_family_t); | |
597 | int innetgr (const char *, const char *, const char *, const char *); | |
598 | #endif | |
341c3efe | 599 | |
2f125ca1 | 600 | /* |
601 | * Define this to use pipes instead of socketpairs for communicating with the | |
602 | * client program. Socketpairs do not seem to work on all systems. | |
603 | * | |
40d0f6b9 | 604 | * configure.ac sets this for a few OS's which are known to have problems |
2f125ca1 | 605 | * but you may need to set it yourself |
606 | */ | |
607 | /* #define USE_PIPES 1 */ | |
608 | ||
1d7b9b20 | 609 | /** |
610 | ** login recorder definitions | |
611 | **/ | |
612 | ||
1d7b9b20 | 613 | /* FIXME: put default paths back in */ |
32eec038 | 614 | #ifndef UTMP_FILE |
615 | # ifdef _PATH_UTMP | |
616 | # define UTMP_FILE _PATH_UTMP | |
617 | # else | |
618 | # ifdef CONF_UTMP_FILE | |
619 | # define UTMP_FILE CONF_UTMP_FILE | |
620 | # endif | |
621 | # endif | |
1d7b9b20 | 622 | #endif |
32eec038 | 623 | #ifndef WTMP_FILE |
624 | # ifdef _PATH_WTMP | |
625 | # define WTMP_FILE _PATH_WTMP | |
626 | # else | |
627 | # ifdef CONF_WTMP_FILE | |
628 | # define WTMP_FILE CONF_WTMP_FILE | |
629 | # endif | |
630 | # endif | |
1d7b9b20 | 631 | #endif |
632 | /* pick up the user's location for lastlog if given */ | |
32eec038 | 633 | #ifndef LASTLOG_FILE |
634 | # ifdef _PATH_LASTLOG | |
635 | # define LASTLOG_FILE _PATH_LASTLOG | |
636 | # else | |
637 | # ifdef CONF_LASTLOG_FILE | |
638 | # define LASTLOG_FILE CONF_LASTLOG_FILE | |
639 | # endif | |
640 | # endif | |
d7c0f3d5 | 641 | #endif |
1d7b9b20 | 642 | |
5a8bd0c3 | 643 | #if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) |
644 | # define USE_SHADOW | |
645 | #endif | |
1d7b9b20 | 646 | |
647 | /* The login() library function in libutil is first choice */ | |
648 | #if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) | |
649 | # define USE_LOGIN | |
650 | ||
651 | #else | |
652 | /* Simply select your favourite login types. */ | |
653 | /* Can't do if-else because some systems use several... <sigh> */ | |
654 | # if defined(UTMPX_FILE) && !defined(DISABLE_UTMPX) | |
655 | # define USE_UTMPX | |
656 | # endif | |
657 | # if defined(UTMP_FILE) && !defined(DISABLE_UTMP) | |
658 | # define USE_UTMP | |
659 | # endif | |
660 | # if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) | |
661 | # define USE_WTMPX | |
662 | # endif | |
663 | # if defined(WTMP_FILE) && !defined(DISABLE_WTMP) | |
664 | # define USE_WTMP | |
665 | # endif | |
666 | ||
667 | #endif | |
668 | ||
074c4cbc | 669 | #ifndef UT_LINESIZE |
670 | # define UT_LINESIZE 8 | |
671 | #endif | |
672 | ||
1d7b9b20 | 673 | /* I hope that the presence of LASTLOG_FILE is enough to detect this */ |
674 | #if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) | |
675 | # define USE_LASTLOG | |
676 | #endif | |
677 | ||
69a20cff | 678 | #ifdef HAVE_OSF_SIA |
679 | # ifdef USE_SHADOW | |
680 | # undef USE_SHADOW | |
681 | # endif | |
682 | # define CUSTOM_SYS_AUTH_PASSWD 1 | |
683 | #endif | |
684 | ||
b6610e8f | 685 | /* HP-UX 11.11 */ |
686 | #ifdef BTMP_FILE | |
687 | # define _PATH_BTMP BTMP_FILE | |
688 | #endif | |
689 | ||
690 | #if defined(USE_BTMP) && defined(_PATH_BTMP) | |
691 | # define CUSTOM_FAILED_LOGIN | |
692 | #endif | |
693 | ||
1d7b9b20 | 694 | /** end of login recorder definitions */ |
695 | ||
35fc74ed | 696 | #ifdef BROKEN_GETGROUPS |
697 | # define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b))) | |
698 | #endif | |
699 | ||
700 | #if defined(HAVE_MMAP) && defined(BROKEN_MMAP) | |
701 | # undef HAVE_MMAP | |
702 | #endif | |
703 | ||
76a8e733 | 704 | #endif /* _DEFINES_H */ |