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