1 /*	$NetBSD: sys_defs.h,v 1.13 2022/10/08 16:12:50 christos Exp $	*/
2 
3 #ifndef _SYS_DEFS_H_INCLUDED_
4 #define _SYS_DEFS_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	sys_defs 3h
9 /* SUMMARY
10 /*	portability header
11 /* SYNOPSIS
12 /*	#include <sys_defs.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Specific platforms. Major release numbers differ for a good reason. So be
18   * a good girl, plan for the future, and at least include the major release
19   * number in the system type (for example, SUNOS5 or FREEBSD2). The system
20   * type is determined by the makedefs shell script in the top-level
21   * directory. Adding support for a new system type means updating the
22   * makedefs script, and adding a section below for the new system.
23   */
24 #ifdef SUNOS5
25 #define _SVID_GETTOD			/* Solaris 2.5, XSH4.2 versus SVID */
26 #endif
27 #include <sys/types.h>
28 
29  /*
30   * 4.4BSD and close derivatives.
31   */
32 #if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4) \
33     || defined(FREEBSD5) || defined(FREEBSD6) || defined(FREEBSD7) \
34     || defined(FREEBSD8) || defined(FREEBSD9) || defined(FREEBSD10) \
35     || defined(FREEBSD11) || defined(FREEBSD12) || defined(FREEBSD13) \
36     || defined(FREEBSD14) \
37     || defined(BSDI2) || defined(BSDI3) || defined(BSDI4) \
38     || defined(OPENBSD2) || defined(OPENBSD3) || defined(OPENBSD4) \
39     || defined(OPENBSD5) || defined(OPENBSD6) || defined(OPENBSD7) \
40     || defined(NETBSD1) || defined(NETBSD2) || defined(NETBSD3) \
41     || defined(NETBSD4) || defined(NETBSD5) || defined(NETBSD6) \
42     || defined(NETBSD7) | defined(NETBSD8) || defined(NETBSD9) \
43     || defined(NETBSD10) \
44     || defined(EKKOBSD1) || defined(DRAGONFLY)
45 #define SUPPORTED
46 #include <sys/param.h>
47 #define UINT32_TYPE	unsigned int
48 #define UINT16_TYPE	unsigned short
49 #define USE_PATHS_H
50 #define HAS_FLOCK_LOCK
51 #define HAS_FCNTL_LOCK
52 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
53 #define DEF_MAILBOX_LOCK "flock, dotlock"
54 #define HAS_SUN_LEN
55 #define HAS_FSYNC
56 #define HAS_DB
57 #define HAS_SA_LEN
58 #define NATIVE_DB_TYPE	"hash"
59 #if (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104250000)
60 #define ALIAS_DB_MAP   DEF_DB_TYPE ":/etc/mail/aliases"	/* sendmail 8.10 */
61 #endif
62 #if (defined(OpenBSD) && OpenBSD >= 200006)
63 #define ALIAS_DB_MAP   DEF_DB_TYPE ":/etc/mail/aliases"	/* OpenBSD 2.7 */
64 #endif
65 #ifndef ALIAS_DB_MAP
66 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
67 #endif
68 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
69 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin"
70 #if (defined(__NetBSD_Version__) && __NetBSD_Version__ > 299000900)
71 #define USE_STATVFS
72 #define STATVFS_IN_SYS_STATVFS_H
73 #else
74 #define USE_STATFS
75 #define STATFS_IN_SYS_MOUNT_H
76 #endif
77 #define HAS_POSIX_REGEXP
78 #define HAS_ST_GEN			/* struct stat contains inode
79 					 * generation number */
80 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
81 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
82 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
83 #define NATIVE_COMMAND_DIR "/usr/sbin"
84 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
85 #define HAS_DLOPEN
86 #endif
87 
88 #ifdef FREEBSD2
89 #define getsid(p) getpgrp()
90 #ifndef CMSG_SPACE
91 #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
92 #endif
93 #ifndef CMSG_LEN
94 #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
95 #endif
96 #ifndef CMSG_ALIGN
97 #define CMSG_ALIGN(n) ALIGN(n)
98 #endif
99 #endif					/* FREEBSD2 */
100 
101 #ifdef BSDI4
102 /* #define HAS_IPV6 find out interface lookup method */
103 #endif
104 
105 /* __FreeBSD_version version is major+minor */
106 
107 #if __FreeBSD_version >= 220000
108 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"	/* introduced 2.1.5 */
109 #endif
110 
111 #if __FreeBSD_version >= 300000
112 #define HAS_ISSETUGID
113 #define HAS_FUTIMES
114 #endif
115 
116 #if __FreeBSD_version >= 400000
117 #define SOCKADDR_SIZE	socklen_t
118 #define SOCKOPT_SIZE	socklen_t
119 #endif
120 
121 #if __FreeBSD_version >= 420000
122 #define HAS_DUPLEX_PIPE			/* 4.1 breaks with kqueue(2) */
123 #endif
124 
125 #if (__FreeBSD_version >= 702104 && __FreeBSD_version <= 800000) \
126     || __FreeBSD_version >= 800100
127 #define HAS_CLOSEFROM
128 #endif
129 
130 /* OpenBSD version is year+month */
131 
132 #if OpenBSD >= 199805			/* XXX */
133 #define HAS_FUTIMES			/* XXX maybe earlier */
134 #endif
135 
136 #if (defined(OpenBSD) && OpenBSD >= 199608 && OpenBSD < 201105)
137 #define PREFERRED_RAND_SOURCE	"dev:/dev/arandom"	/* XXX earlier */
138 #endif
139 
140 #if OpenBSD >= 200000			/* XXX */
141 #define HAS_ISSETUGID
142 #endif
143 
144 #if OpenBSD >= 200200			/* XXX */
145 #define SOCKADDR_SIZE	socklen_t
146 #define SOCKOPT_SIZE	socklen_t
147 #endif
148 
149 #if OpenBSD >= 200405			/* 3.5 */
150 #define HAS_CLOSEFROM
151 #endif
152 
153 /* __NetBSD_Version__ is major+minor */
154 
155 #if __NetBSD_Version__ >= 103000000	/* XXX maybe earlier */
156 #undef DEF_MAILBOX_LOCK
157 #define DEF_MAILBOX_LOCK "flock, dotlock"
158 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"	/* XXX maybe earlier */
159 #endif
160 
161 #if __NetBSD_Version__ >= 105000000
162 #define HAS_ISSETUGID			/* XXX maybe earlier */
163 #endif
164 
165 #if __NetBSD_Version__ >= 106000000	/* XXX maybe earlier */
166 #define SOCKADDR_SIZE	socklen_t
167 #define SOCKOPT_SIZE	socklen_t
168 #endif
169 
170 #if __NetBSD_Version__ >= 299000900	/* 2.99.9 */
171 #define HAS_CLOSEFROM
172 #endif
173 
174 #if (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 102000000)
175 #define HAS_FUTIMES
176 #endif
177 
178 #if defined(__DragonFly__)
179 #define HAS_DEV_URANDOM
180 #define HAS_ISSETUGID
181 #define HAS_FUTIMES
182 #define SOCKADDR_SIZE	socklen_t
183 #define SOCKOPT_SIZE	socklen_t
184 #define HAS_DUPLEX_PIPE
185 #endif
186 
187 #if (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 105000000) \
188     || (defined(__FreeBSD__) && __FreeBSD__ >= 4) \
189     || (defined(OpenBSD) && OpenBSD >= 200003) \
190     || defined(__DragonFly__) \
191     || defined(USAGI_LIBINET6)
192 #ifndef NO_IPV6
193 #define HAS_IPV6
194 #endif
195 #if !defined(NO_IPV6) || defined(__NetBSD__)
196 #define HAVE_GETIFADDRS
197 #endif
198 #endif
199 
200 #if (defined(__FreeBSD_version) && __FreeBSD_version >= 300000) \
201     || (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 103000000) \
202     || (defined(OpenBSD) && OpenBSD >= 199700)	/* OpenBSD 2.0?? */ \
203     || defined(__DragonFly__)
204 #define USE_SYSV_POLL
205 #endif
206 
207 #ifndef NO_KQUEUE
208 #if (defined(__FreeBSD_version) && __FreeBSD_version >= 410000) \
209     || (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 200000000) \
210     || (defined(OpenBSD) && OpenBSD >= 200105)	/* OpenBSD 2.9 */ \
211     || defined(__DragonFly__)
212 #define EVENTS_STYLE	EVENTS_STYLE_KQUEUE
213 #endif
214 #endif
215 
216 #ifndef NO_POSIX_GETPW_R
217 #if (defined(__FreeBSD_version) && __FreeBSD_version >= 510000) \
218     || (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 300000000) \
219     || (defined(OpenBSD) && OpenBSD >= 200811)	/* OpenBSD 4.4 */
220 #define HAVE_POSIX_GETPW_R
221 #endif
222 #endif
223 
224  /*
225   * UNIX on MAC.
226   */
227 #if defined(RHAPSODY5) || defined(MACOSX)
228 #define SUPPORTED
229 #define UINT32_TYPE	unsigned int
230 #define UINT16_TYPE	unsigned short
231 #define USE_PATHS_H
232 #define HAS_FLOCK_LOCK
233 #define HAS_FCNTL_LOCK
234 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
235 #define DEF_MAILBOX_LOCK "flock, dotlock"
236 #define HAS_SUN_LEN
237 #define HAS_FSYNC
238 #define HAS_DB
239 #define HAS_SA_LEN
240 #define NATIVE_DB_TYPE	"hash"
241 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
242 #define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
243 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin"
244 #define USE_STATFS
245 #define STATFS_IN_SYS_MOUNT_H
246 #define HAS_POSIX_REGEXP
247 #ifndef NO_NETINFO
248 #define HAS_NETINFO
249 #endif
250 #ifndef NO_IPV6
251 #define HAS_IPV6
252 #define HAVE_GETIFADDRS
253 #endif
254 #define HAS_FUTIMES			/* XXX Guessing */
255 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
256 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
257 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
258 #define NATIVE_COMMAND_DIR "/usr/sbin"
259 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
260 #define SOCKADDR_SIZE	socklen_t
261 #define SOCKOPT_SIZE	socklen_t
262 #ifndef NO_KQUEUE
263 #define EVENTS_STYLE	EVENTS_STYLE_KQUEUE
264 #define USE_SYSV_POLL_THEN_SELECT
265 #endif
266 #define USE_MAX_FILES_PER_PROC
267 #ifndef NO_POSIX_GETPW_R
268 #define HAVE_POSIX_GETPW_R
269 #endif
270 #define HAS_DLOPEN
271 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"
272 #endif
273 
274  /*
275   * Ultrix 4.x, a sort of 4.[1-2] BSD system with System V.2 compatibility
276   * and POSIX.
277   */
278 #ifdef ULTRIX4
279 #define SUPPORTED
280 #define UINT32_TYPE	unsigned int
281 #define UINT16_TYPE	unsigned short
282 /* Ultrix by default has only 64 descriptors per process */
283 #ifndef FD_SETSIZE
284 #define FD_SETSIZE	96
285 #endif
286 #define _PATH_MAILDIR	"/var/spool/mail"
287 #define _PATH_BSHELL	"/bin/sh"
288 #define _PATH_DEFPATH	"/bin:/usr/bin:/usr/ucb"
289 #define _PATH_STDPATH	"/bin:/usr/bin:/usr/etc:/usr/ucb"
290 #define HAS_FLOCK_LOCK
291 #define HAS_FCNTL_LOCK
292 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
293 #define DEF_MAILBOX_LOCK "flock, dotlock"
294 #define HAS_FSYNC
295 /* might be set by makedef */
296 #ifdef HAS_DB
297 #define NATIVE_DB_TYPE	"hash"
298 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
299 #else
300 #define HAS_DBM
301 #define	NATIVE_DB_TYPE	"dbm"
302 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
303 #endif
304 extern int optind;
305 extern char *optarg;
306 extern int opterr;
307 extern int h_errno;
308 
309 #define MISSING_STRFTIME_E
310 #ifndef NO_NIS
311 #define HAS_NIS
312 #endif
313 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
314 #define ROOT_PATH	"/bin:/usr/bin:/etc:/usr/etc:/usr/ucb"
315 #define USE_STATFS
316 #define USE_STRUCT_FS_DATA
317 #define STATFS_IN_SYS_MOUNT_H
318 /* Ultrix misses just S_ISSOCK, the others are there */
319 #define S_ISSOCK(mode)	(((mode) & (S_IFMT)) == (S_IFSOCK))
320 #define DUP2_DUPS_CLOSE_ON_EXEC
321 #define MISSING_USLEEP
322 #define NO_HERRNO
323 #define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
324 #define NATIVE_COMMAND_DIR "/usr/etc"
325 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
326 #endif
327 
328  /*
329   * OSF, then Digital UNIX, then Compaq. A BSD-flavored hybrid.
330   */
331 #ifdef OSF1
332 #define SUPPORTED
333 #define UINT32_TYPE	unsigned int
334 #define UINT16_TYPE	unsigned short
335 #define MISSING_SETENV
336 #define USE_PATHS_H
337 #define _PATH_DEFPATH "/usr/bin:/usr/ucb"
338 #define HAS_FLOCK_LOCK
339 #define HAS_FCNTL_LOCK
340 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
341 #define DEF_MAILBOX_LOCK "flock, dotlock"
342 #define HAS_FSYNC
343 #define HAVE_BASENAME
344 #define HAS_DBM
345 #define NATIVE_DB_TYPE	"dbm"
346 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/var/adm/sendmail/aliases"
347 extern int optind;			/* XXX use <getopt.h> */
348 extern char *optarg;			/* XXX use <getopt.h> */
349 extern int opterr;			/* XXX use <getopt.h> */
350 
351 #ifndef NO_NIS
352 #define HAS_NIS
353 #endif
354 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
355 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
356 #define USE_STATFS
357 #define STATFS_IN_SYS_MOUNT_H
358 #define HAS_POSIX_REGEXP
359 #define BROKEN_WRITE_SELECT_ON_NON_BLOCKING_PIPE
360 #define NO_MSGHDR_MSG_CONTROL
361 #ifndef NO_IPV6
362 #define HAS_IPV6
363 #endif
364 
365 #endif
366 
367  /*
368   * SunOS 4.x, a mostly 4.[2-3] BSD system with System V.2 compatibility and
369   * POSIX support.
370   */
371 #ifdef SUNOS4
372 #define SUPPORTED
373 #include <memory.h>
374 #define UINT32_TYPE	unsigned int
375 #define UINT16_TYPE	unsigned short
376 #define UNSAFE_CTYPE
377 #define fpos_t	long
378 #define MISSING_SETENV
379 #define MISSING_STRERROR
380 #define MISSING_STRTOUL
381 #define _PATH_MAILDIR	"/var/spool/mail"
382 #define _PATH_BSHELL	"/bin/sh"
383 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
384 #define _PATH_STDPATH	"/usr/bin:/usr/etc:/usr/ucb"
385 #define HAS_FLOCK_LOCK
386 #define HAS_FCNTL_LOCK
387 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
388 #define DEF_MAILBOX_LOCK "flock, dotlock"
389 #define HAS_FSYNC
390 #define HAS_DBM
391 #define NATIVE_DB_TYPE	"dbm"
392 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
393 extern int optind;
394 extern char *optarg;
395 extern int opterr;
396 
397 #ifndef NO_NIS
398 #define HAS_NIS
399 #endif
400 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
401 #define ROOT_PATH	"/bin:/usr/bin:/etc:/usr/etc:/usr/ucb"
402 #define USE_STATFS
403 #define STATFS_IN_SYS_VFS_H
404 #define memmove(d,s,l)	bcopy(s,d,l)
405 #define NO_HERRNO
406 #define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
407 #define NATIVE_MAILQ_PATH "/usr/ucb/mailq"
408 #define NATIVE_NEWALIAS_PATH "/usr/ucb/newaliases"
409 #define NATIVE_COMMAND_DIR "/usr/etc"
410 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
411 #define STRCASECMP_IN_STRINGS_H
412 #define OCTAL_TO_UNSIGNED(res, str) sscanf((str), "%o", &(res))
413 #define size_t	unsigned
414 #define ssize_t	int
415 #define getsid	getpgrp
416 #define NO_SNPRINTF
417 #endif
418 
419  /*
420   * SunOS 5.x, mostly System V Release 4.
421   */
422 #ifdef SUNOS5
423 #define SUPPORTED
424 #define UINT32_TYPE	unsigned int
425 #define UINT16_TYPE	unsigned short
426 #define _PATH_MAILDIR	"/var/mail"
427 #define _PATH_BSHELL	"/bin/sh"
428 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
429 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
430 #define HAS_FCNTL_LOCK
431 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
432 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
433 #define HAS_FSYNC
434 #define HAS_DBM
435 #define NATIVE_DB_TYPE	"dbm"
436 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
437 #ifndef NO_NIS
438 #define HAS_NIS
439 #ifndef NO_NISPLUS
440 #define HAS_NISPLUS
441 #endif					/* NO_NISPLUS */
442 #endif
443 #define USE_SYS_SOCKIO_H		/* Solaris 2.5, changed sys/ioctl.h */
444 #define GETTIMEOFDAY(t)	gettimeofday(t)
445 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
446 #define FIONREAD_IN_SYS_FILIO_H
447 #define USE_STATVFS
448 #define STATVFS_IN_SYS_STATVFS_H
449 #define INT_MAX_IN_LIMITS_H
450 #ifdef STREAM_CONNECTIONS		/* avoid UNIX-domain sockets */
451 #define LOCAL_LISTEN	stream_listen
452 #define LOCAL_ACCEPT	stream_accept
453 #define LOCAL_CONNECT	stream_connect
454 #define LOCAL_TRIGGER	stream_trigger
455 #define LOCAL_SEND_FD	stream_send_fd
456 #define LOCAL_RECV_FD	stream_recv_fd
457 #endif
458 #define HAS_VOLATILE_LOCKS
459 #define BROKEN_READ_SELECT_ON_TCP_SOCKET
460 #define CANT_WRITE_BEFORE_SENDING_FD
461 #ifndef NO_POSIX_REGEXP
462 #define HAS_POSIX_REGEXP
463 #endif
464 #ifndef NO_IPV6
465 #define HAS_IPV6
466 #define HAS_SIOCGLIF
467 #endif
468 #ifndef NO_CLOSEFROM
469 #define HAS_CLOSEFROM
470 #endif
471 #ifndef NO_DEV_URANDOM
472 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"
473 #endif
474 #ifndef NO_FUTIMESAT
475 #define HAS_FUTIMESAT
476 #endif
477 #define USE_SYSV_POLL
478 #ifndef NO_DEVPOLL
479 #define EVENTS_STYLE	EVENTS_STYLE_DEVPOLL
480 #endif
481 #ifndef NO_POSIX_GETPW_R
482 #define HAVE_POSIX_GETPW_R
483 #define GETPW_R_NEEDS_POSIX_PTHREAD_SEMANTICS
484 #endif
485 
486 /*
487  * Allow build environment to override paths.
488  */
489 #define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
490 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
491 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
492 #define NATIVE_COMMAND_DIR "/usr/sbin"
493 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
494 
495 #define HAS_DLOPEN
496 #endif
497 
498  /*
499   * UnixWare, System Release 4.
500   */
501 #ifdef UW7				/* UnixWare 7 */
502 #define SUPPORTED
503 #define UINT32_TYPE	unsigned int
504 #define UINT16_TYPE	unsigned short
505 #define _PATH_MAILDIR	"/var/mail"
506 #define _PATH_BSHELL	"/bin/sh"
507 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
508 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
509 #define MISSING_SETENV
510 #define HAS_FCNTL_LOCK
511 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
512 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
513 #define HAS_FSYNC
514 #define HAS_DBM
515 #define NATIVE_DB_TYPE	"dbm"
516 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
517 #ifndef NO_NIS
518 #define HAS_NIS
519 #endif
520 #define USE_SYS_SOCKIO_H
521 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
522 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
523 #define FIONREAD_IN_SYS_FILIO_H
524 #define DBM_NO_TRAILING_NULL
525 #define USE_STATVFS
526 #define STATVFS_IN_SYS_STATVFS_H
527 #define STRCASECMP_IN_STRINGS_H
528 #define USE_SET_H_ERRNO
529 #endif
530 
531 #ifdef UW21				/* UnixWare 2.1.x */
532 #define SUPPORTED
533 #define UINT32_TYPE	unsigned int
534 #define UINT16_TYPE	unsigned short
535 #define _PATH_MAILDIR   "/var/mail"
536 #define _PATH_BSHELL    "/bin/sh"
537 #define _PATH_DEFPATH   "/usr/bin:/usr/ucb"
538 #define _PATH_STDPATH   "/usr/bin:/usr/sbin:/usr/ucb"
539 #define MISSING_SETENV
540 #define HAS_FCNTL_LOCK
541 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
542 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
543 #define HAS_FSYNC
544 #define HAS_DBM
545 #define NATIVE_DB_TYPE     "dbm"
546 #define ALIAS_DB_MAP    DEF_DB_TYPE ":/etc/mail/aliases"
547 #ifndef NO_NIS
548 #define HAS_NIS */
549 #endif
550 #define USE_SYS_SOCKIO_H
551 #define GETTIMEOFDAY(t) gettimeofday(t,NULL)
552 #define ROOT_PATH       "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
553 #define FIONREAD_IN_SYS_FILIO_H
554 #define DBM_NO_TRAILING_NULL
555 #define USE_STATVFS
556 #define STATVFS_IN_SYS_STATVFS_H
557 #endif
558 
559  /*
560   * AIX: a SYSV-flavored hybrid. NB: fcntl() and flock() access the same
561   * underlying locking primitives.
562   */
563 #if defined(AIX5) || defined(AIX6)
564 #define SUPPORTED
565 #define UINT32_TYPE	unsigned int
566 #define UINT16_TYPE	unsigned short
567 #define MISSING_SETENV
568 #define USE_PATHS_H
569 #ifndef _PATH_BSHELL
570 #define _PATH_BSHELL	"/bin/sh"
571 #endif
572 #ifndef _PATH_MAILDIR
573 #define _PATH_MAILDIR   "/var/spool/mail"	/* paths.h lies */
574 #endif
575 #ifndef _PATH_DEFPATH
576 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
577 #endif
578 #ifndef _PATH_STDPATH
579 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
580 #endif
581 #define HAS_FCNTL_LOCK
582 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
583 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
584 #define USE_SYS_SELECT_H
585 #define HAS_FSYNC
586 #define HAS_DBM
587 #define NATIVE_DB_TYPE	"dbm"
588 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
589 #ifndef NO_NIS
590 #define HAS_NIS
591 #endif
592 #define HAS_SA_LEN
593 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
594 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
595 #define SOCKADDR_SIZE	socklen_t
596 #define SOCKOPT_SIZE	socklen_t
597 #define USE_STATVFS
598 #define STATVFS_IN_SYS_STATVFS_H
599 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
600 #define NATIVE_MAILQ_PATH "/usr/sbin/mailq"
601 #define NATIVE_NEWALIAS_PATH "/usr/sbin/newaliases"
602 #define NATIVE_COMMAND_DIR "/usr/sbin"
603 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
604 
605  /*
606   * XXX Need CMSG_SPACE() and CMSG_LEN() but don't want to drag in everything
607   * that comes with _LINUX_SOURCE_COMPAT.
608   */
609 #include <sys/socket.h>
610 #ifndef CMSG_SPACE
611 #define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
612 #endif
613 #ifndef CMSG_LEN
614 #define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
615 #endif
616 #ifndef NO_IPV6
617 #define HAS_IPV6
618 #endif
619 #define BROKEN_AI_PASSIVE_NULL_HOST
620 #define BROKEN_AI_NULL_SERVICE
621 #define USE_SYSV_POLL
622 #define MYMALLOC_FUZZ	1
623 #endif
624 
625 #ifdef AIX4
626 #define SUPPORTED
627 #define UINT32_TYPE	unsigned int
628 #define UINT16_TYPE	unsigned short
629 #define MISSING_SETENV
630 #define _PATH_BSHELL	"/bin/sh"
631 #define _PATH_MAILDIR   "/var/spool/mail"	/* paths.h lies */
632 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
633 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
634 #define HAS_FCNTL_LOCK
635 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
636 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
637 #define USE_SYS_SELECT_H
638 #define HAS_FSYNC
639 #define HAS_DBM
640 #define NATIVE_DB_TYPE	"dbm"
641 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
642 #ifndef NO_NIS
643 #define HAS_NIS
644 #endif
645 #define HAS_SA_LEN
646 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
647 #define RESOLVE_H_NEEDS_STDIO_H
648 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
649 #define SOCKADDR_SIZE	size_t
650 #define SOCKOPT_SIZE	size_t
651 #define USE_STATVFS
652 #define STATVFS_IN_SYS_STATVFS_H
653 #define STRCASECMP_IN_STRINGS_H
654 #if 0
655 extern time_t time(time_t *);
656 extern int seteuid(uid_t);
657 extern int setegid(gid_t);
658 extern int initgroups(const char *, int);
659 
660 #endif
661 #define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
662 #define NATIVE_MAILQ_PATH "/usr/sbin/mailq"
663 #define NATIVE_NEWALIAS_PATH "/usr/sbin/newaliases"
664 #define NATIVE_COMMAND_DIR "/usr/sbin"
665 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
666 
667 #define CANT_USE_SEND_RECV_MSG
668 #endif
669 
670 #ifdef AIX3
671 #define SUPPORTED
672 #define UINT32_TYPE	unsigned int
673 #define UINT16_TYPE	unsigned short
674 #define MISSING_SETENV
675 #define _PATH_BSHELL	"/bin/sh"
676 #define _PATH_MAILDIR   "/var/spool/mail"	/* paths.h lies */
677 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
678 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
679 #define HAS_FCNTL_LOCK
680 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
681 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
682 #define USE_SYS_SELECT_H
683 #define HAS_FSYNC
684 #define HAS_DBM
685 #define NATIVE_DB_TYPE	"dbm"
686 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
687 #ifndef NO_NIS
688 #define HAS_NIS
689 #endif
690 #define HAS_SA_LEN
691 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
692 #define RESOLVE_H_NEEDS_STDIO_H
693 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
694 #define SOCKADDR_SIZE	size_t
695 #define SOCKOPT_SIZE	size_t
696 #define USE_STATFS
697 #define STATFS_IN_SYS_STATFS_H
698 #define STRCASECMP_IN_STRINGS_H
699 extern time_t time(time_t *);
700 extern int seteuid(uid_t);
701 extern int setegid(gid_t);
702 extern int initgroups(const char *, int);
703 
704 #define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
705 
706 #define CANT_USE_SEND_RECV_MSG
707 #endif
708 
709  /*
710   * IRIX, a mix of System V Releases.
711   */
712 #if defined(IRIX5) || defined(IRIX6)
713 #define SUPPORTED
714 #define UINT32_TYPE	unsigned int
715 #define UINT16_TYPE	unsigned short
716 #define MISSING_SETENV
717 #define _PATH_MAILDIR	"/var/mail"
718 #define _PATH_BSHELL	"/bin/sh"
719 #define _PATH_DEFPATH	"/usr/bin:/usr/bsd"
720 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/bsd"
721 #define HAS_FCNTL_LOCK
722 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
723 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
724 #define HAS_FSYNC
725 #define HAS_DBM
726 #define NATIVE_DB_TYPE	"dbm"
727 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
728 #ifndef NO_NIS
729 #define HAS_NIS
730 #endif
731 #define USE_SYS_SOCKIO_H		/* XXX check */
732 #define GETTIMEOFDAY(t)	gettimeofday(t)
733 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/bsd"
734 #define FIONREAD_IN_SYS_FILIO_H		/* XXX check */
735 #define DBM_NO_TRAILING_NULL		/* XXX check */
736 #define USE_STATVFS
737 #define STATVFS_IN_SYS_STATVFS_H
738 #define BROKEN_WRITE_SELECT_ON_NON_BLOCKING_PIPE
739 #define CANT_USE_SEND_RECV_MSG
740 #endif
741 
742 #if defined(IRIX5)
743 #define MISSING_USLEEP
744 #endif
745 
746 #if defined(IRIX6)
747 #ifndef NO_IPV6
748 #define HAS_IPV6
749 #endif
750 #define HAS_POSIX_REGEXP
751 #define PIPES_CANT_FIONREAD
752 #endif
753 
754  /*
755   * LINUX.
756   */
757 #if defined(LINUX2) || defined(LINUX3) || defined(LINUX4) || defined(LINUX5)
758 #define SUPPORTED
759 #define UINT32_TYPE	unsigned int
760 #define UINT16_TYPE	unsigned short
761 #include <features.h>
762 #define USE_PATHS_H
763 #define HAS_FLOCK_LOCK
764 #define HAS_FCNTL_LOCK
765 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
766 #define DEF_MAILBOX_LOCK "fcntl, dotlock"	/* RedHat >= 4.x */
767 #define HAS_FSYNC
768 #define HAS_DB
769 #define NATIVE_DB_TYPE	"hash"
770 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
771 #ifndef NO_NIS
772 #define HAS_NIS
773 #endif
774 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
775 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin"
776 #define FIONREAD_IN_TERMIOS_H
777 #define USE_STATFS
778 #define STATFS_IN_SYS_VFS_H
779 #define PREPEND_PLUS_TO_OPTSTRING
780 #define HAS_POSIX_REGEXP
781 #define HAS_DLOPEN
782 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
783 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
784 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
785 #define NATIVE_COMMAND_DIR "/usr/sbin"
786 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
787 #ifdef __GLIBC_PREREQ
788 #define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) __GLIBC_PREREQ(maj, min)
789 #else
790 #define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) \
791     (defined(__GLIBC__) && \
792 	((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)))
793 #endif
794 #if HAVE_GLIBC_API_VERSION_SUPPORT(2, 1)
795 #define SOCKADDR_SIZE	socklen_t
796 #define SOCKOPT_SIZE	socklen_t
797 #else
798 #define NO_SNPRINTF
799 #endif
800 #ifndef NO_IPV6
801 #define HAS_IPV6
802 #if HAVE_GLIBC_API_VERSION_SUPPORT(2, 4)
803 /* Really 2.3.3 or later, but there's no __GLIBC_MICRO version macro. */
804 #define HAVE_GETIFADDRS
805 #else
806 #define HAS_PROCNET_IFINET6
807 #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
808 #endif
809 #endif
810 #include <linux/version.h>
811 #if !defined(KERNEL_VERSION)
812 #define KERNEL_VERSION(a,b,c) (LINUX_VERSION_CODE + 1)
813 #endif
814 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)) \
815 	|| (defined(__GLIBC__) && __GLIBC__ < 2)
816 #define CANT_USE_SEND_RECV_MSG
817 #define DEF_SMTP_CACHE_DEMAND	0
818 #else
819 #define CANT_WRITE_BEFORE_SENDING_FD
820 #endif
821 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"	/* introduced in 1.1 */
822 #ifndef NO_EPOLL
823 #define EVENTS_STYLE	EVENTS_STYLE_EPOLL	/* introduced in 2.5 */
824 #endif
825 #define USE_SYSV_POLL
826 #ifndef NO_POSIX_GETPW_R
827 #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) \
828 	|| (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 1) \
829 	|| (defined(_BSD_SOURCE) && _BSD_SOURCE >= 1) \
830 	|| (defined(_SVID_SOURCE) && _SVID_SOURCE >= 1) \
831 	|| (defined(_POSIX_SOURCE) && _POSIX_SOURCE >= 1)
832 #define HAVE_POSIX_GETPW_R
833 #endif
834 #endif
835 #if HAVE_GLIBC_API_VERSION_SUPPORT(2, 34)
836 #define HAS_CLOSEFROM
837 #endif
838 
839 #endif
840 
841 #ifdef LINUX1
842 #define SUPPORTED
843 #define UINT32_TYPE	unsigned int
844 #define UINT16_TYPE	unsigned short
845 #define USE_PATHS_H
846 #define HAS_FLOCK_LOCK
847 #define HAS_FCNTL_LOCK
848 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
849 #define DEF_MAILBOX_LOCK "dotlock"	/* verified RedHat 3.03 */
850 #define HAS_FSYNC
851 #define HAS_DB
852 #define NATIVE_DB_TYPE	"hash"
853 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
854 #ifndef NO_NIS
855 #define HAS_NIS
856 #endif
857 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
858 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin"
859 #define FIONREAD_IN_TERMIOS_H		/* maybe unnecessary */
860 #define USE_STATFS
861 #define STATFS_IN_SYS_VFS_H
862 #define PREPEND_PLUS_TO_OPTSTRING
863 #define HAS_POSIX_REGEXP
864 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
865 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
866 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
867 #define NATIVE_COMMAND_DIR "/usr/sbin"
868 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
869 #define CANT_USE_SEND_RECV_MSG
870 #define DEF_SMTP_CACHE_DEMAND	0
871 #endif
872 
873  /*
874   * GNU.
875   */
876 #ifdef GNU0
877 #define SUPPORTED
878 #include <features.h>
879 #define USE_PATHS_H
880 #define HAS_FCNTL_LOCK
881 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
882 #define DEF_MAILBOX_LOCK "fcntl, dotlock"	/* RedHat >= 4.x */
883 #define HAS_FSYNC
884 #define HAS_DB
885 #define NATIVE_DB_TYPE	"hash"
886 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
887 #ifndef NO_NIS
888 #define HAS_NIS
889 #endif
890 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
891 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin"
892 #define FIONREAD_IN_TERMIOS_H
893 #define USE_STATFS
894 #define STATFS_IN_SYS_VFS_H
895 #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
896 #define PREPEND_PLUS_TO_OPTSTRING
897 #define HAS_POSIX_REGEXP
898 #define HAS_DLOPEN
899 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
900 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
901 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
902 #define NATIVE_COMMAND_DIR "/usr/sbin"
903 #ifdef DEBIAN
904 #define NATIVE_DAEMON_DIR	"/usr/lib/postfix"
905 #ifndef DEF_MANPAGE_DIR
906 #define DEF_MANPAGE_DIR		"/usr/share/man"
907 #endif
908 #ifndef DEF_SAMPLE_DIR
909 #define DEF_SAMPLE_DIR		"/usr/share/doc/postfix/examples"
910 #endif
911 #ifndef DEF_README_DIR
912 #define DEF_README_DIR		"/usr/share/doc/postfix"
913 #endif
914 #else
915 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
916 #endif
917 #define SOCKADDR_SIZE	socklen_t
918 #define SOCKOPT_SIZE	socklen_t
919 #ifdef __FreeBSD_kernel__
920 #define HAS_DUPLEX_PIPE
921 #define HAS_ISSETUGID
922 #endif
923 #ifndef NO_IPV6
924 #define HAS_IPV6
925 #ifdef __FreeBSD_kernel__
926 #define HAVE_GETIFADDRS
927 #else
928 #define HAS_PROCNET_IFINET6
929 #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
930 #endif
931 #endif
932 #define CANT_USE_SEND_RECV_MSG
933 #define DEF_SMTP_CACHE_DEMAND	0
934 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"
935 #endif
936 
937  /*
938   * HPUX11 was copied from HPUX10, but can perhaps be trimmed down a bit.
939   */
940 #ifdef HPUX11
941 #define SUPPORTED
942 #define USE_SIG_RETURN
943 #define UINT32_TYPE	unsigned int
944 #define UINT16_TYPE	unsigned short
945 #define HAS_DBM
946 #define HAS_FCNTL_LOCK
947 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
948 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
949 #define HAS_FSYNC
950 #define NATIVE_DB_TYPE	"dbm"
951 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
952 #define ROOT_PATH	"/usr/bin:/sbin:/usr/sbin"
953 #define MISSING_SETENV
954 #ifndef NO_NIS
955 #define HAS_NIS
956 #endif
957 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
958 #define _PATH_BSHELL	"/bin/sh"
959 #define _PATH_MAILDIR	"/var/mail"
960 #define _PATH_DEFPATH	"/usr/bin"
961 #define _PATH_STDPATH	"/usr/bin:/sbin:/usr/sbin"
962 #define MISSING_SETEUID
963 #define HAVE_SETRESUID
964 #define MISSING_SETEGID
965 #define HAVE_SETRESGID
966 extern int h_errno;			/* <netdb.h> imports too much stuff */
967 
968 #define USE_STATFS
969 #define STATFS_IN_SYS_VFS_H
970 #define HAS_POSIX_REGEXP
971 #define HAS_DLOPEN
972 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
973 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
974 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
975 #define NATIVE_COMMAND_DIR "/usr/sbin"
976 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
977 #endif
978 
979 #ifdef HPUX10
980 #define SUPPORTED
981 #define USE_SIG_RETURN
982 #define UINT32_TYPE	unsigned int
983 #define UINT16_TYPE	unsigned short
984 #define HAS_DBM
985 #define HAS_FCNTL_LOCK
986 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
987 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
988 #define HAS_FSYNC
989 #define NATIVE_DB_TYPE	"dbm"
990 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
991 #define ROOT_PATH	"/usr/bin:/sbin:/usr/sbin"
992 #define MISSING_SETENV
993 #ifndef NO_NIS
994 #define HAS_NIS
995 #endif
996 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
997 #define _PATH_BSHELL	"/bin/sh"
998 #define _PATH_MAILDIR	"/var/mail"
999 #define _PATH_DEFPATH	"/usr/bin"
1000 #define _PATH_STDPATH	"/usr/bin:/sbin:/usr/sbin"
1001 #define MISSING_SETEUID
1002 #define HAVE_SETRESUID
1003 #define MISSING_SETEGID
1004 #define HAVE_SETRESGID
1005 extern int h_errno;			/* <netdb.h> imports too much stuff */
1006 
1007 #define USE_STATFS
1008 #define STATFS_IN_SYS_VFS_H
1009 #define HAS_POSIX_REGEXP
1010 #define HAS_SHL_LOAD
1011 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
1012 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
1013 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
1014 #define NATIVE_COMMAND_DIR "/usr/sbin"
1015 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
1016 #endif
1017 
1018 #ifdef HPUX9
1019 #define SUPPORTED
1020 #define USE_SIG_RETURN
1021 #define UINT32_TYPE	unsigned int
1022 #define UINT16_TYPE	unsigned short
1023 #define HAS_DBM
1024 #define HAS_FCNTL_LOCK
1025 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
1026 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
1027 #define HAS_FSYNC
1028 #ifndef NO_NIS
1029 #define HAS_NIS
1030 #endif
1031 #define MISSING_SETENV
1032 #define MISSING_RLIMIT_FSIZE
1033 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
1034 #define NATIVE_DB_TYPE	"dbm"
1035 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/usr/lib/aliases"
1036 #define ROOT_PATH	"/bin:/usr/bin:/etc"
1037 #define _PATH_BSHELL	"/bin/sh"
1038 #define _PATH_MAILDIR	"/usr/mail"
1039 #define _PATH_DEFPATH	"/bin:/usr/bin"
1040 #define _PATH_STDPATH	"/bin:/usr/bin:/etc"
1041 #define MISSING_SETEUID
1042 #define HAVE_SETRESUID
1043 #define MISSING_SETEGID
1044 #define HAVE_SETRESGID
1045 extern int h_errno;
1046 
1047 #define USE_ULIMIT			/* no setrlimit() */
1048 #define USE_STATFS
1049 #define STATFS_IN_SYS_VFS_H
1050 #define HAS_POSIX_REGEXP
1051 #define HAS_SHL_LOAD
1052 #define NATIVE_SENDMAIL_PATH "/usr/bin/sendmail"
1053 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
1054 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
1055 #define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
1056 #endif
1057 
1058  /*
1059   * NEXTSTEP3, without -lposix, because its naming service is broken.
1060   */
1061 #ifdef NEXTSTEP3
1062 #define SUPPORTED
1063 #define UINT32_TYPE	unsigned int
1064 #define UINT16_TYPE	unsigned short
1065 #define HAS_DBM
1066 #define HAS_FLOCK_LOCK
1067 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
1068 #define DEF_MAILBOX_LOCK "flock, dotlock"
1069 #define USE_STATFS
1070 #define HAVE_SYS_DIR_H
1071 #define STATFS_IN_SYS_VFS_H
1072 #define HAS_FSYNC
1073 #ifndef NO_NIS
1074 #define HAS_NIS
1075 #endif
1076 #define HAS_NETINFO
1077 #define MISSING_SETENV_PUTENV
1078 #define MISSING_MKFIFO
1079 #define MISSING_SIGSET_T
1080 #define MISSING_SIGACTION
1081 #define MISSING_STD_FILENOS
1082 #define MISSING_SETSID
1083 #define MISSING_WAITPID
1084 #define MISSING_UTIMBUF
1085 #define HAS_WAIT4
1086 #define WAIT_STATUS_T union wait
1087 #define NORMAL_EXIT_STATUS(x) (WIFEXITED(x) && !WEXITSTATUS (x))
1088 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
1089 #define _PATH_MAILDIR	"/usr/spool/mail"
1090 #define _PATH_BSHELL	"/bin/sh"
1091 #define _PATH_DEFPATH	"/bin:/usr/bin:/usr/ucb"
1092 #define _PATH_STDPATH	"/bin:/usr/bin:/usr/ucb"
1093 #define ROOT_PATH	"/bin:/usr/bin:/usr/etc:/usr/ucb"
1094 #define NATIVE_DB_TYPE	"dbm"
1095 #define ALIAS_DB_MAP	"netinfo:/aliases"
1096 #include <libc.h>
1097 #define MISSING_POSIX_S_IS
1098 #define MISSING_POSIX_S_MODES
1099 /* It's amazing what is all missing...	*/
1100 #define isascii(c)	((unsigned)(c)<=0177)
1101 extern int opterr;
1102 typedef unsigned short mode_t;
1103 
1104 #define MISSING_PID_T
1105 #define MISSING_STRFTIME_E
1106 #define FD_CLOEXEC	1
1107 #define O_NONBLOCK	O_NDELAY
1108 #define WEXITSTATUS(x)	((x).w_retcode)
1109 #define WTERMSIG(x)	((x).w_termsig)
1110 #endif
1111 
1112  /*
1113   * OPENSTEP does not have posix (some fix...)
1114   */
1115 #ifdef OPENSTEP4
1116 #define SUPPORTED
1117 #define UINT32_TYPE	unsigned int
1118 #define UINT16_TYPE	unsigned short
1119 #define HAS_DBM
1120 #define HAS_FLOCK_LOCK
1121 #define INTERNAL_LOCK	MYFLOCK_STYLE_FLOCK
1122 #define DEF_MAILBOX_LOCK "flock, dotlock"
1123 #define USE_STATFS
1124 #define HAVE_SYS_DIR_H
1125 #define STATFS_IN_SYS_VFS_H
1126 #define HAS_FSYNC
1127 #ifndef NO_NIS
1128 #define HAS_NIS
1129 #endif
1130 #define HAS_NETINFO
1131 #define MISSING_SETENV_PUTENV
1132 #define MISSING_MKFIFO
1133 #define MISSING_SIGSET_T
1134 #define MISSING_SIGACTION
1135 #define MISSING_STD_FILENOS
1136 #define MISSING_SETSID
1137 #define MISSING_WAITPID
1138 #define MISSING_UTIMBUF
1139 #define HAS_WAIT4
1140 #define WAIT_STATUS_T union wait
1141 #define NORMAL_EXIT_STATUS(x) (WIFEXITED(x) && !WEXITSTATUS (x))
1142 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
1143 #define _PATH_MAILDIR	"/usr/spool/mail"
1144 #define _PATH_BSHELL	"/bin/sh"
1145 #define _PATH_DEFPATH	"/bin:/usr/bin:/usr/ucb"
1146 #define _PATH_STDPATH	"/bin:/usr/bin:/usr/ucb"
1147 #define ROOT_PATH	"/bin:/usr/bin:/usr/etc:/usr/ucb"
1148 #define NATIVE_DB_TYPE	"dbm"
1149 #define ALIAS_DB_MAP	"netinfo:/aliases"
1150 #include <libc.h>
1151 #define MISSING_POSIX_S_IS
1152 #define MISSING_POSIX_S_MODES
1153 /* It's amazing what is all missing...	*/
1154 #define isascii(c)	((unsigned)(c)<=0177)
1155 extern int opterr;
1156 typedef unsigned short mode_t;
1157 
1158 #define MISSING_PID_T
1159 #define MISSING_STRFTIME_E
1160 #define FD_CLOEXEC	1
1161 #define O_NONBLOCK	O_NDELAY
1162 #define WEXITSTATUS(x)	((x).w_retcode)
1163 #define WTERMSIG(x)	((x).w_termsig)
1164 #endif
1165 
1166 #ifdef ReliantUnix543
1167 #define SUPPORTED
1168 #define UINT32_TYPE	unsigned int
1169 #define UINT16_TYPE	unsigned short
1170 #define MISSING_SETENV
1171 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
1172 #define _PATH_BSHELL	"/bin/sh"
1173 #define _PATH_MAILDIR	"/var/spool/mail"
1174 #define HAS_FCNTL_LOCK
1175 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
1176 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
1177 #define HAS_FSYNC
1178 #define FIONREAD_IN_SYS_FILIO_H
1179 #define USE_SYS_SOCKIO_H
1180 #define HAS_DBM
1181 #define NATIVE_DB_TYPE	"dbm"
1182 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/var/adm/sendmail/aliases"
1183 extern int optind;			/* XXX use <getopt.h> */
1184 extern char *optarg;			/* XXX use <getopt.h> */
1185 extern int opterr;			/* XXX use <getopt.h> */
1186 
1187 #ifndef NO_NIS
1188 #define HAS_NIS
1189 #endif
1190 #define GETTIMEOFDAY(t) gettimeofday(t)
1191 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
1192 #define USE_STATVFS
1193 #define STATVFS_IN_SYS_STATVFS_H
1194 #define MISSING_USLEEP
1195 #endif
1196 
1197 #ifdef DCOSX1				/* Siemens Pyramid */
1198 #define SUPPORTED
1199 #define UINT32_TYPE	unsigned int
1200 #define UINT16_TYPE	unsigned short
1201 #define _PATH_MAILDIR	"/var/mail"
1202 #define _PATH_BSHELL	"/bin/sh"
1203 #define _PATH_DEFPATH	"/usr/bin:/usr/ucb"
1204 #define _PATH_STDPATH	"/usr/bin:/usr/sbin:/usr/ucb"
1205 #define MISSING_SETENV
1206 #define HAS_FCNTL_LOCK
1207 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
1208 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
1209 #define HAS_FSYNC
1210 #define NATIVE_DB_TYPE	"hash"
1211 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
1212 /* Uncomment the following line if you have NIS package installed */
1213 /* #define HAS_NIS */
1214 #define USE_SYS_SOCKIO_H
1215 #define GETTIMEOFDAY(t) gettimeofday(t,NULL)
1216 #define ROOT_PATH	"/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
1217 #define FIONREAD_IN_SYS_FILIO_H
1218 #define DBM_NO_TRAILING_NULL
1219 #define USE_STATVFS
1220 #define STATVFS_IN_SYS_STATVFS_H
1221 #ifndef S_ISSOCK
1222 #define S_ISSOCK(mode)	((mode&0xF000) == 0xC000)
1223 #endif
1224 #endif
1225 
1226 #ifdef SCO5
1227 #define SUPPORTED
1228 #include <sys/socket.h>
1229 extern int h_errno;
1230 
1231 #define UINT32_TYPE	unsigned int
1232 #define UINT16_TYPE	unsigned short
1233 #define _PATH_MAILDIR	"/usr/spool/mail"
1234 #define _PATH_BSHELL	"/bin/sh"
1235 #define _PATH_DEFPATH	"/bin:/usr/bin"
1236 #define USE_PATHS_H
1237 #define HAS_FCNTL_LOCK
1238 #define INTERNAL_LOCK	MYFLOCK_STYLE_FCNTL
1239 #define DEF_MAILBOX_LOCK "fcntl, dotlock"
1240 #define HAS_FSYNC
1241 #define HAS_DBM
1242 #define NATIVE_DB_TYPE	"dbm"
1243 #define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
1244 #define DBM_NO_TRAILING_NULL
1245 #ifndef NO_NIS
1246 #define HAS_NIS
1247 #endif
1248 #define GETTIMEOFDAY(t)	gettimeofday(t,(struct timezone *) 0)
1249 #define ROOT_PATH	"/bin:/etc:/usr/bin:/tcb/bin"
1250 #define USE_STATVFS
1251 #define STATVFS_IN_SYS_STATVFS_H
1252 #define MISSING_SETENV
1253 #define STRCASECMP_IN_STRINGS_H
1254 /* SCO5 misses just S_ISSOCK, the others are there
1255  * Use C_ISSOCK definition from cpio.h.
1256  */
1257 #include <cpio.h>
1258 #define S_ISSOCK(mode)	(((mode) & (S_IFMT)) == (C_ISSOCK))
1259 #define CANT_USE_SEND_RECV_MSG
1260 #define DEF_SMTP_CACHE_DEMAND	0
1261 #endif
1262 
1263  /*
1264   * We're not going to try to guess like configure does.
1265   */
1266 #ifndef SUPPORTED
1267 #error "unsupported platform"
1268 #endif
1269 
1270  /*
1271   * Allow command line flags to override native settings
1272   */
1273 #ifndef DEF_COMMAND_DIR
1274 #ifdef NATIVE_COMMAND_DIR
1275 #define DEF_COMMAND_DIR NATIVE_COMMAND_DIR
1276 #endif
1277 #endif
1278 
1279 #ifndef DEF_DAEMON_DIR
1280 #ifdef NATIVE_DAEMON_DIR
1281 #define DEF_DAEMON_DIR NATIVE_DAEMON_DIR
1282 #endif
1283 #endif
1284 
1285 #ifndef DEF_SENDMAIL_PATH
1286 #ifdef NATIVE_SENDMAIL_PATH
1287 #define DEF_SENDMAIL_PATH NATIVE_SENDMAIL_PATH
1288 #endif
1289 #endif
1290 
1291 #ifndef DEF_MAILQ_PATH
1292 #ifdef NATIVE_MAILQ_PATH
1293 #define DEF_MAILQ_PATH NATIVE_MAILQ_PATH
1294 #endif
1295 #endif
1296 
1297 #ifndef DEF_NEWALIAS_PATH
1298 #ifdef NATIVE_NEWALIAS_PATH
1299 #define DEF_NEWALIAS_PATH NATIVE_NEWALIAS_PATH
1300 #endif
1301 #endif
1302 
1303 #ifndef DEF_DB_TYPE
1304 #define DEF_DB_TYPE	NATIVE_DB_TYPE
1305 #endif
1306 
1307 #define CAST_ANY_PTR_TO_INT(cptr)	((int) (long) (cptr))
1308 #define CAST_INT_TO_VOID_PTR(ival)	((void *) (long) (ival))
1309 
1310 #ifdef DUP2_DUPS_CLOSE_ON_EXEC
1311 /* dup2_pass_on_exec() can be found in util/sys_compat.c */
1312 extern int dup2_pass_on_exec(int oldd, int newd);
1313 
1314 #define DUP2 dup2_pass_on_exec
1315 #else
1316 #define DUP2 dup2
1317 #endif
1318 
1319 #ifdef PREPEND_PLUS_TO_OPTSTRING
1320 #define GETOPT(argc, argv, str)	getopt((argc), (argv), "+" str)
1321 #else
1322 #define GETOPT(argc, argv, str) getopt((argc), (argv), (str))
1323 #endif
1324 #define OPTIND  (optind > 0 ? optind : 1)
1325 
1326 #if !defined(__UCLIBC__) && !defined(NO_RES_SEND)
1327 #define HAVE_RES_SEND
1328 #else
1329 #undef HAVE_RES_SEND
1330 #endif
1331 
1332  /*
1333   * Check for required but missing definitions.
1334   */
1335 #if !defined(HAS_FCNTL_LOCK) && !defined(HAS_FLOCK_LOCK)
1336 #error "define HAS_FCNTL_LOCK and/or HAS_FLOCK_LOCK"
1337 #endif
1338 
1339 #if !defined(DEF_MAILBOX_LOCK)
1340 #error "define DEF_MAILBOX_LOCK"
1341 #endif
1342 
1343 #if !defined(INTERNAL_LOCK)
1344 #error "define INTERNAL_LOCK"
1345 #endif
1346 
1347 #if defined(USE_STATFS) && defined(USE_STATVFS)
1348 #error "define USE_STATFS or USE_STATVFS, not both"
1349 #endif
1350 
1351 #if !defined(USE_STATFS) && !defined(USE_STATVFS)
1352 #error "define USE_STATFS or USE_STATVFS"
1353 #endif
1354 
1355  /*
1356   * Defaults for systems that pre-date IPv6 support.
1357   */
1358 #ifndef __NetBSD__
1359 #ifndef HAS_IPV6
1360 #include <sys/socket.h>
1361 #define EMULATE_IPV4_ADDRINFO
1362 #define MISSING_INET_PTON
1363 #define MISSING_INET_NTOP
1364 extern const char *inet_ntop(int, const void *, char *, SOCKADDR_SIZE);
1365 extern int inet_pton(int, const char *, void *);
1366 
1367 #endif
1368 #endif
1369 
1370  /*
1371   * Workaround: after a watchdog alarm signal, wake up from select/poll/etc.
1372   * by writing to a pipe. Solaris needs this, and HP-UX apparently, too. The
1373   * run-time cost is negligible so we just turn it on for all systems. As a
1374   * side benefit, making this code system-independent will simplify the
1375   * detection of bit-rot problems.
1376   */
1377 #ifndef NO_WATCHDOG_PIPE
1378 #define USE_WATCHDOG_PIPE
1379 #endif
1380 
1381  /*
1382   * If we don't have defined a preferred random device above, but the system
1383   * has /dev/urandom, then we use that.
1384   */
1385 #if !defined(PREFERRED_RAND_SOURCE) && defined(HAS_DEV_URANDOM)
1386 #define PREFERRED_RAND_SOURCE	"dev:/dev/urandom"
1387 #endif
1388 
1389  /*
1390   * Defaults for systems without kqueue, /dev/poll or epoll support.
1391   * master/multi-server.c and *qmgr/qmgr_transport.c depend on this.
1392   */
1393 #if !defined(EVENTS_STYLE)
1394 #define EVENTS_STYLE	EVENTS_STYLE_SELECT
1395 #endif
1396 
1397 #define EVENTS_STYLE_SELECT	1	/* Traditional BSD select */
1398 #define EVENTS_STYLE_KQUEUE	2	/* FreeBSD kqueue */
1399 #define EVENTS_STYLE_DEVPOLL	3	/* Solaris /dev/poll */
1400 #define EVENTS_STYLE_EPOLL	4	/* Linux epoll */
1401 
1402  /*
1403   * We use poll() for read/write time limit enforcement on modern systems. We
1404   * use select() on historical systems without poll() support. And on systems
1405   * where poll() is not implemented for some file handle types, we try to use
1406   * select() as a fall-back solution (MacOS X needs this).
1407   */
1408 #if !defined(USE_SYSV_POLL) && !defined(USE_SYSV_POLL_THEN_SELECT)
1409 #define USE_BSD_SELECT
1410 #endif
1411 
1412  /*
1413   * The Postfix 2.9 post-install workaround assumes that the inet_protocols
1414   * default value is "ipv4" when Postfix is compiled without IPv6 support.
1415   */
1416 #ifndef DEF_INET_PROTOCOLS
1417 #ifdef HAS_IPV6
1418 #define DEF_INET_PROTOCOLS	INET_PROTO_NAME_ALL
1419 #else
1420 #define DEF_INET_PROTOCOLS	INET_PROTO_NAME_IPV4
1421 #endif
1422 #endif
1423 
1424  /*
1425   * Defaults for systems that pre-date POSIX socklen_t.
1426   */
1427 #ifndef SOCKADDR_SIZE
1428 #define SOCKADDR_SIZE	int
1429 #endif
1430 
1431 #ifndef SOCKOPT_SIZE
1432 #define SOCKOPT_SIZE	int
1433 #endif
1434 
1435  /*
1436   * Defaults for normal systems.
1437   */
1438 #ifndef LOCAL_LISTEN
1439 #define LOCAL_LISTEN	unix_listen
1440 #define LOCAL_ACCEPT	unix_accept
1441 #define LOCAL_CONNECT	unix_connect
1442 #define LOCAL_TRIGGER	unix_trigger
1443 #define LOCAL_SEND_FD	unix_send_fd
1444 #define LOCAL_RECV_FD	unix_recv_fd
1445 #endif
1446 
1447 #if !defined (HAVE_SYS_NDIR_H) && !defined (HAVE_SYS_DIR_H) \
1448 	&& !defined (HAVE_NDIR_H)
1449 #define HAVE_DIRENT_H
1450 #endif
1451 
1452 #ifndef WAIT_STATUS_T
1453 typedef int WAIT_STATUS_T;
1454 
1455 #define NORMAL_EXIT_STATUS(status)	((status) == 0)
1456 #endif
1457 
1458 #ifdef NO_POSIX_GETPW_R
1459 #undef HAVE_POSIX_GETPW_R
1460 #endif
1461 
1462 #ifdef NO_DB
1463 #undef HAS_DB
1464 #endif
1465 
1466 #ifndef OCTAL_TO_UNSIGNED
1467 #define OCTAL_TO_UNSIGNED(res, str)	((res) = strtoul((str), (char **) 0, 8))
1468 #endif
1469 
1470  /*
1471   * Avoid useless type mis-matches when using sizeof in an integer context.
1472   */
1473 #define INT_SIZEOF(foo)	((int) sizeof(foo))
1474 
1475  /*
1476   * Turn on the compatibility stuff.
1477   */
1478 #ifdef MISSING_UTIMBUF
1479 struct utimbuf {
1480     time_t  actime;
1481     time_t  modtime;
1482 };
1483 
1484 #endif
1485 
1486 #ifdef MISSING_STRERROR
1487 extern const char *strerror(int);
1488 
1489 #endif
1490 
1491 #if defined (MISSING_SETENV) || defined (MISSING_SETENV_PUTENV)
1492 extern int setenv(const char *, const char *, int);
1493 
1494 #endif
1495 
1496 #ifdef MISSING_SETEUID
1497 extern int seteuid(uid_t euid);
1498 
1499 #endif
1500 
1501 #ifdef MISSING_SETEGID
1502 extern int setegid(gid_t egid);
1503 
1504 #endif
1505 
1506 #ifdef MISSING_MKFIFO
1507 extern int mkfifo(char *, int);
1508 
1509 #endif
1510 
1511 #ifdef MISSING_WAITPID
1512 extern int waitpid(int, WAIT_STATUS_T *status, int options);
1513 
1514 #endif
1515 
1516 #ifdef MISSING_SETSID
1517 extern int setsid(void);
1518 
1519 #endif
1520 
1521 #ifndef HAS_CLOSEFROM
1522 extern int closefrom(int);
1523 
1524 #endif
1525 
1526 #ifdef MISSING_STD_FILENOS
1527 #define STDIN_FILENO	0
1528 #define STDOUT_FILENO	1
1529 #define STDERR_FILENO	2
1530 #endif
1531 
1532 #ifdef MISSING_PID_T
1533 typedef int pid_t;
1534 
1535 #endif
1536 
1537 #ifdef MISSING_POSIX_S_IS
1538 #define S_ISBLK(mode)	(((mode) & (_S_IFMT)) == (_S_IFBLK))
1539 #define S_ISCHR(mode)	(((mode) & (_S_IFMT)) == (_S_IFCHR))
1540 #define S_ISDIR(mode)	(((mode) & (_S_IFMT)) == (_S_IFDIR))
1541 #define S_ISSOCK(mode)	(((mode) & (_S_IFMT)) == (_S_IFSOCK))
1542 #define S_ISFIFO(mode)	(((mode) & (_S_IFMT)) == (_S_IFIFO))
1543 #define S_ISREG(mode)	(((mode) & (_S_IFMT)) == (_S_IFREG))
1544 #define S_ISLNK(mode)	(((mode) & (_S_IFMT)) == (_S_IFLNK))
1545 #endif
1546 
1547 #ifdef MISSING_POSIX_S_MODES
1548 #define S_IRUSR	_S_IRUSR
1549 #define S_IRGRP	0000040
1550 #define S_IROTH	0000004
1551 #define S_IWUSR	_S_IWUSR
1552 #define S_IWGRP	0000020
1553 #define S_IWOTH	0000002
1554 #define S_IXUSR	_S_IXUSR
1555 #define S_IXGRP	0000010
1556 #define S_IXOTH	0000001
1557 #define	S_IRWXU	(S_IRUSR | S_IWUSR | S_IXUSR)
1558 #endif
1559 
1560  /*
1561   * Memory alignment of memory allocator results. By default we align for
1562   * doubles.
1563   */
1564 #ifndef ALIGN_TYPE
1565 #if defined(__hpux) && defined(__ia64)
1566 #define ALIGN_TYPE	__float80
1567 #elif defined(__ia64__)
1568 #define ALIGN_TYPE	long double
1569 #else
1570 #define ALIGN_TYPE	double
1571 #endif
1572 #endif
1573 
1574  /*
1575   * Clang-style attribute tests.
1576   *
1577   * XXX Without the unconditional test below, gcc 4.6 will barf on ``elif
1578   * defined(__clang__) && __has_attribute(__whatever__)'' with error message
1579   * ``missing binary operator before token "("''.
1580   */
1581 #ifndef __has_attribute
1582 #define __has_attribute(x) 0
1583 #endif					/* __has_attribute */
1584 
1585  /*
1586   * Need to specify what functions never return, so that the compiler can
1587   * warn for missing initializations and other trouble. However, OPENSTEP4
1588   * gcc 2.7.x cannot handle this so we define this only if NORETURN isn't
1589   * already defined above.
1590   *
1591   * Data point: gcc 2.7.2 has __attribute__ (Wietse Venema) but gcc 2.6.3 does
1592   * not (Clive Jones). So we'll set the threshold at 2.7.
1593   */
1594 #ifndef NORETURN
1595 #if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3
1596 #define NORETURN	void __attribute__((__noreturn__))
1597 #elif defined(__clang__) && __has_attribute(__noreturn__)
1598 #define NORETURN	void __attribute__((__noreturn__))
1599 #else
1600 #define NORETURN	void
1601 #endif
1602 #endif					/* NORETURN */
1603 
1604  /*
1605   * Turn on format string argument checking. This is more accurate than
1606   * printfck, but it misses #ifdef-ed code. XXX I am just guessing at what
1607   * gcc versions support this. In order to turn this off for some platforms,
1608   * specify #define PRINTFLIKE and #define SCANFLIKE in the system-dependent
1609   * sections above.
1610   */
1611 #ifndef PRINTFLIKE
1612 #if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3
1613 #define PRINTFLIKE(x,y) __attribute__ ((format (printf, (x), (y))))
1614 #elif defined(__clang__) && __has_attribute(__format__)
1615 #define PRINTFLIKE(x,y)	__attribute__ ((__format__ (__printf__, (x), (y))))
1616 #else
1617 #define PRINTFLIKE(x,y)
1618 #endif
1619 #endif					/* PRINTFLIKE */
1620 
1621 #ifndef SCANFLIKE
1622 #if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ >= 3
1623 #define SCANFLIKE(x,y) __attribute__ ((format (scanf, (x), (y))))
1624 #elif defined(__clang__) && __has_attribute(__format__)
1625 #define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, (x), (y))))
1626 #else
1627 #define SCANFLIKE(x,y)
1628 #endif
1629 #endif					/* SCANFLIKE */
1630 
1631  /*
1632   * Some gcc implementations don't grok these attributes with pointer to
1633   * function. Again, wild guess of what is supported. To override, specify
1634   * #define PRINTFPTRLIKE  in the system-dependent sections above.
1635   */
1636 #ifndef PRINTFPTRLIKE
1637 #if (__GNUC__ >= 3)			/* XXX Rough estimate */
1638 #define PRINTFPTRLIKE(x,y) PRINTFLIKE(x,y)
1639 #elif defined(__clang__) && __has_attribute(__format__)
1640 #define PRINTFPTRLIKE(x,y) __attribute__ ((__format__ (__printf__, (x), (y))))
1641 #else
1642 #define PRINTFPTRLIKE(x,y)
1643 #endif
1644 #endif
1645 
1646  /*
1647   * Compiler optimization hint. This makes sense only for code in a
1648   * performance-critical loop.
1649   */
1650 #ifndef EXPECTED
1651 #if defined(__GNUC__) && (__GNUC__ > 2)
1652 #define EXPECTED(x)	__builtin_expect(!!(x), 1)
1653 #define UNEXPECTED(x)	__builtin_expect(!!(x), 0)
1654 #else
1655 #define EXPECTED(x)	(x)
1656 #define UNEXPECTED(x)	(x)
1657 #endif
1658 #endif
1659 
1660  /*
1661   * Warn about ignored function result values that must never be ignored.
1662   * Typically, this is for error results from "read" functions that normally
1663   * write to output parameters (for example, stat- or scanf-like functions)
1664   * or from functions that have other useful side effects (for example,
1665   * fseek- or rename-like functions).
1666   *
1667   * DO NOT use this for functions that write to a stream; it is entirely
1668   * legitimate to detect write errors with fflush() or fclose() only. On the
1669   * other hand most (but not all) functions that read from a stream must
1670   * never ignore result values.
1671   *
1672   * XXX Prepending "(void)" won't shut up GCC. Clang behaves as expected.
1673   */
1674 #if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ > 3)
1675 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
1676 #elif defined(__clang__) && __has_attribute(warn_unused_result)
1677 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
1678 #else
1679 #define WARN_UNUSED_RESULT
1680 #endif
1681 
1682  /*
1683   * ISO C says that the "volatile" qualifier protects against optimizations
1684   * that cause longjmp() to clobber local variables.
1685   */
1686 #ifndef NOCLOBBER
1687 #define NOCLOBBER volatile
1688 #endif
1689 
1690  /*
1691   * Bit banging!! There is no official constant that defines the INT_MAX
1692   * equivalent for off_t, ssize_t, etc. Wietse came up with the following
1693   * macro that works as long as off_t, ssize_t, etc. use one's or two's
1694   * complement logic (that is, the maximum value is binary 01...1). Don't use
1695   * right-shift for signed types: the result is implementation-defined.
1696   */
1697 #include <limits.h>
1698 #define __MAXINT__(T) ((T) ~(((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)))
1699 #ifndef OFF_T_MAX
1700 #define OFF_T_MAX __MAXINT__(off_t)
1701 #endif
1702 
1703 #ifndef SSIZE_T_MAX
1704 #define SSIZE_T_MAX __MAXINT__(ssize_t)
1705 #endif
1706 
1707  /*
1708   * Consistent enforcement of size limits.
1709   */
1710 #define ENFORCING_SIZE_LIMIT(param)	((param) > 0)
1711 
1712  /*
1713   * Don't mix socket message send/receive calls with socket stream read/write
1714   * calls. The fact that you can get away with it only on some stacks implies
1715   * that there is no long-term guarantee.
1716   */
1717 #ifndef CAN_WRITE_BEFORE_SENDING_FD
1718 #define CANT_WRITE_BEFORE_SENDING_FD
1719 #endif
1720 
1721  /*
1722   * FreeBSD sendmsg(2) says that after sending a file descriptor, the sender
1723   * must not immediately close the descriptor, otherwise it may close the
1724   * descriptor before it is actually sent.
1725   */
1726 #ifndef DONT_WAIT_AFTER_SENDING_FD
1727 #define MUST_READ_AFTER_SENDING_FD
1728 #endif
1729 
1730  /*
1731   * Hope for the best.
1732   */
1733 #ifndef UINT32_TYPE
1734 #define	UINT32_TYPE uint32_t
1735 #define UINT16_TYPE uint16_t
1736 #endif
1737 #define UINT32_SIZE	4
1738 #define UINT16_SIZE	2
1739 
1740  /*
1741   * For the sake of clarity.
1742   */
1743 #ifndef HAVE_CONST_CHAR_STAR
1744 typedef const char *CONST_CHAR_STAR;
1745 
1746 #endif
1747 
1748  /*
1749   * Safety. On some systems, ctype.h misbehaves with non-ASCII or negative
1750   * characters. More importantly, Postfix uses the ISXXX() macros to ensure
1751   * protocol compliance, so we have to rule out non-ASCII characters.
1752   *
1753   * XXX The (unsigned char) casts in isalnum() etc arguments are unnecessary
1754   * because the ISASCII() guard already ensures that the values are
1755   * non-negative; the casts are done anyway to shut up chatty compilers.
1756   */
1757 #define ISASCII(c)	isascii(_UCHAR_(c))
1758 #define _UCHAR_(c)	((unsigned char)(c))
1759 #define ISALNUM(c)	(ISASCII(c) && isalnum((unsigned char)(c)))
1760 #define ISALPHA(c)	(ISASCII(c) && isalpha((unsigned char)(c)))
1761 #define ISCNTRL(c)	(ISASCII(c) && iscntrl((unsigned char)(c)))
1762 #define ISDIGIT(c)	(ISASCII(c) && isdigit((unsigned char)(c)))
1763 #define ISGRAPH(c)	(ISASCII(c) && isgraph((unsigned char)(c)))
1764 #define ISLOWER(c)	(ISASCII(c) && islower((unsigned char)(c)))
1765 #define ISPRINT(c)	(ISASCII(c) && isprint((unsigned char)(c)))
1766 #define ISPUNCT(c)	(ISASCII(c) && ispunct((unsigned char)(c)))
1767 #define ISSPACE(c)	(ISASCII(c) && isspace((unsigned char)(c)))
1768 #define ISUPPER(c)	(ISASCII(c) && isupper((unsigned char)(c)))
1769 #define TOLOWER(c)	(ISUPPER(c) ? tolower((unsigned char)(c)) : (c))
1770 #define TOUPPER(c)	(ISLOWER(c) ? toupper((unsigned char)(c)) : (c))
1771 
1772  /*
1773   * Character sets for parsing.
1774   */
1775 #define CHARS_COMMA_SP	", \t\r\n"	/* list separator */
1776 #define CHARS_SPACE	" \t\r\n"	/* word separator */
1777 #define CHARS_BRACE	"{}"		/* grouping */
1778 
1779  /*
1780   * Scaffolding. I don't want to lose messages while the program is under
1781   * development.
1782   */
1783 extern int REMOVE(const char *);
1784 
1785 /* LICENSE
1786 /* .ad
1787 /* .fi
1788 /*	The Secure Mailer license must be distributed with this software.
1789 /* AUTHOR(S)
1790 /*	Wietse Venema
1791 /*	IBM T.J. Watson Research
1792 /*	P.O. Box 704
1793 /*	Yorktown Heights, NY 10598, USA
1794 /*
1795 /*	Wietse Venema
1796 /*	Google, Inc.
1797 /*	111 8th Avenue
1798 /*	New York, NY 10011, USA
1799 /*--*/
1800 
1801 #endif
1802