Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: am_defs.h,v 1.4 2015/01/17 17:46:31 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997-2014 Erez Zadok
      5  * Copyright (c) 1990 Jan-Simon Pendry
      6  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
      7  * Copyright (c) 1990 The Regents of the University of California.
      8  * All rights reserved.
      9  *
     10  * This code is derived from software contributed to Berkeley by
     11  * Jan-Simon Pendry at Imperial College, London.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. Neither the name of the University nor the names of its contributors
     22  *    may be used to endorse or promote products derived from this software
     23  *    without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35  * SUCH DAMAGE.
     36  *
     37  *
     38  * File: am-utils/include/am_defs.h
     39  *
     40  */
     41 
     42 /*
     43  * Definitions that are not specific to the am-utils package, but
     44  * are rather generic, and can be used elsewhere.
     45  */
     46 
     47 #ifndef _AM_DEFS_H
     48 #define _AM_DEFS_H
     49 
     50 /*
     51  * Actions to take if ANSI C.
     52  */
     53 #if STDC_HEADERS
     54 # include <string.h>
     55 /* for function prototypes */
     56 # define P(x) x
     57 # define P_void void
     58 #else /* not STDC_HEADERS */
     59 /* empty function prototypes */
     60 # define P(x) ()
     61 # define P_void
     62 # ifndef HAVE_STRCHR
     63 #  define strchr index
     64 #  define strrchr rindex
     65 # endif /* not HAVE_STRCHR */
     66 char *strchr(), *strrchr();
     67 #endif /* not STDC_HEADERS */
     68 
     69 /*
     70  * Handle gcc __attribute__ if available.
     71  */
     72 #ifndef __attribute__
     73 /* This feature is available in gcc versions 2.5 and later.  */
     74 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
     75 #  define __attribute__(Spec) /* empty */
     76 # endif /* __GNUC__ < 2 ... */
     77 /*
     78  * The __-protected variants of `format' and `printf' attributes
     79  * are accepted by gcc versions 2.6.4 (effectively 2.7) and later.
     80  */
     81 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
     82 #  define __format__ format
     83 #  define __printf__ printf
     84 # endif /* __GNUC__ < 2 ... */
     85 #endif /* not __attribute__ */
     86 
     87 #define __IGNORE(result) \
     88     __ignore((unsigned long)result)
     89 
     90 static inline void
     91 __ignore(unsigned long result) {
     92     (void)&result;
     93 }
     94 
     95 /*
     96  * How to handle signals of any type
     97  */
     98 #ifdef HAVE_SYS_WAIT_H
     99 # include <sys/wait.h>
    100 #endif /* HAVE_SYS_WAIT_H */
    101 #ifndef WEXITSTATUS
    102 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
    103 #endif /* not WEXITSTATUS */
    104 #ifndef WIFEXITED
    105 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
    106 #endif /* not WIFEXITED */
    107 
    108 /*
    109  * Actions to take regarding <time.h> and <sys/time.h>.
    110  */
    111 #if TIME_WITH_SYS_TIME
    112 # include <sys/time.h>
    113 # ifdef _ALL_SOURCE
    114 /*
    115  * AIX 5.2 needs struct sigevent from signal.h to be defined, but I
    116  * don't want to move the inclusion of signal.h this early into this
    117  * file.  Luckily, amd doesn't need the size of this structure in any
    118  * other structure that it uses.  So we sidestep it for now.
    119  */
    120 struct sigevent;
    121 # endif /* _ALL_SOURCE */
    122 # include <time.h>
    123 #else /* not TIME_WITH_SYS_TIME */
    124 # if HAVE_SYS_TIME_H
    125 #  include <sys/time.h>
    126 # else /* not HAVE_SYS_TIME_H */
    127 #  include <time.h>
    128 # endif /* not HAVE_SYS_TIME_H */
    129 #endif /* not TIME_WITH_SYS_TIME */
    130 
    131 /*
    132  * Actions to take if <machine/endian.h> exists.
    133  */
    134 #ifdef HAVE_MACHINE_ENDIAN_H
    135 # include <machine/endian.h>
    136 #endif /* HAVE_MACHINE_ENDIAN_H */
    137 
    138 /*
    139  * Big-endian or little-endian?
    140  */
    141 #ifndef BYTE_ORDER
    142 # if defined(WORDS_BIGENDIAN)
    143 #  define ARCH_ENDIAN "big"
    144 # else /* not WORDS_BIGENDIAN */
    145 #  define ARCH_ENDIAN "little"
    146 # endif /* not WORDS_BIGENDIAN */
    147 #else
    148 # if BYTE_ORDER == BIG_ENDIAN
    149 #  define ARCH_ENDIAN "big"
    150 # else
    151 #  define ARCH_ENDIAN "little"
    152 # endif
    153 #endif
    154 
    155 /*
    156  * Actions to take if HAVE_SYS_TYPES_H is defined.
    157  */
    158 #if HAVE_SYS_TYPES_H
    159 # include <sys/types.h>
    160 #endif /* HAVE_SYS_TYPES_H */
    161 
    162 /*
    163  * Actions to take if HAVE_LIMITS_H is defined.
    164  */
    165 #if HAVE_LIMITS_H_H
    166 # include <limits.h>
    167 #endif /* HAVE_LIMITS_H */
    168 
    169 /*
    170  * Actions to take if HAVE_UNISTD_H is defined.
    171  */
    172 #if HAVE_UNISTD_H
    173 # include <unistd.h>
    174 #endif /* HAVE_UNISTD_H */
    175 
    176 /* after <unistd.h>, check if this is a POSIX.1 system */
    177 #ifdef _POSIX_VERSION
    178 /* Code for POSIX.1 systems. */
    179 #endif /* _POSIX_VERSION */
    180 
    181 /*
    182  * Variable length argument lists.
    183  * Must use only one of the two!
    184  */
    185 #ifdef HAVE_STDARG_H
    186 # include <stdarg.h>
    187 /*
    188  * On Solaris 2.6, <sys/varargs.h> is included in <sys/fs/autofs.h>
    189  * So this ensures that only one is included.
    190  */
    191 # ifndef _SYS_VARARGS_H
    192 #  define _SYS_VARARGS_H
    193 # endif /* not _SYS_VARARGS_H */
    194 #else /* not HAVE_STDARG_H */
    195 # ifdef HAVE_VARARGS_H
    196 #  include <varargs.h>
    197 # endif /* HAVE_VARARGS_H */
    198 #endif /* not HAVE_STDARG_H */
    199 
    200 /*
    201  * Pick the right header file and macros for directory processing functions.
    202  */
    203 #if HAVE_DIRENT_H
    204 # include <dirent.h>
    205 # define NAMLEN(dirent) strlen((dirent)->d_name)
    206 #else /* not HAVE_DIRENT_H */
    207 # define dirent direct
    208 # define NAMLEN(dirent) (dirent)->d_namlen
    209 # if HAVE_SYS_NDIR_H
    210 #  include <sys/ndir.h>
    211 # endif /* HAVE_SYS_NDIR_H */
    212 # if HAVE_SYS_DIR_H
    213 #  include <sys/dir.h>
    214 # endif /* HAVE_SYS_DIR_H */
    215 # if HAVE_NDIR_H
    216 #  include <ndir.h>
    217 # endif /* HAVE_NDIR_H */
    218 #endif /* not HAVE_DIRENT_H */
    219 
    220 /*
    221  * Actions to take if HAVE_FCNTL_H is defined.
    222  */
    223 #if HAVE_FCNTL_H
    224 # include <fcntl.h>
    225 #endif /* HAVE_FCNTL_H */
    226 
    227 /*
    228  * Actions to take if HAVE_MEMORY_H is defined.
    229  */
    230 #if HAVE_MEMORY_H
    231 # include <memory.h>
    232 #endif /* HAVE_MEMORY_H */
    233 
    234 /*
    235  * Actions to take if HAVE_SYS_FILE_H is defined.
    236  */
    237 #if HAVE_SYS_FILE_H
    238 # include <sys/file.h>
    239 #endif /* HAVE_SYS_FILE_H */
    240 
    241 /*
    242  * Actions to take if HAVE_SYS_IOCTL_H is defined.
    243  */
    244 #if HAVE_SYS_IOCTL_H
    245 # include <sys/ioctl.h>
    246 #endif /* HAVE_SYS_IOCTL_H */
    247 
    248 /*
    249  * Actions to take if HAVE_SYSLOG_H or HAVE_SYS_SYSLOG_H is defined.
    250  */
    251 #ifdef HAVE_SYSLOG_H
    252 # include <syslog.h>
    253 #else /* not HAVE_SYSLOG_H */
    254 # if HAVE_SYS_SYSLOG_H
    255 #  include <sys/syslog.h>
    256 # endif /* HAVE_SYS_SYSLOG_H */
    257 #endif /* HAVE_SYSLOG_H */
    258 
    259 /*
    260  * Actions to take if <sys/param.h> exists.
    261  */
    262 #ifdef HAVE_SYS_PARAM_H
    263 # include <sys/param.h>
    264 #endif /* HAVE_SYS_PARAM_H */
    265 
    266 /*
    267  * Actions to take if <sys/socket.h> exists.
    268  */
    269 #ifdef HAVE_SYS_SOCKET_H
    270 # include <sys/socket.h>
    271 #endif /* HAVE_SYS_SOCKET_H */
    272 
    273 /*
    274  * Actions to take if <rpc/rpc.h> exists.
    275  */
    276 #ifdef HAVE_RPC_RPC_H
    277 /*
    278  * Turn on PORTMAP, so that additional header files would get included
    279  * and the important definition for UDPMSGSIZE is included too.
    280  */
    281 # ifndef PORTMAP
    282 #  define PORTMAP
    283 # endif /* not PORTMAP */
    284 # include <rpc/rpc.h>
    285 # ifndef XDRPROC_T_TYPE
    286 typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...));
    287 # endif /* not XDRPROC_T_TYPE */
    288 #endif /* HAVE_RPC_RPC_H */
    289 
    290 /*
    291  * Actions to take if <rpc/types.h> exists.
    292  */
    293 #ifdef HAVE_RPC_TYPES_H
    294 # include <rpc/types.h>
    295 #endif /* HAVE_RPC_TYPES_H */
    296 
    297 /*
    298  * Actions to take if <rpc/xdr.h> exists.
    299  */
    300 /* Prevent multiple inclusion on Ultrix 4 */
    301 #if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__)
    302 # include <rpc/xdr.h>
    303 #endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */
    304 
    305 /*
    306  * Actions to take if <malloc.h> exists.
    307  * Don't include malloc.h if stdlib.h exists, because modern
    308  * systems complain if you use malloc.h instead of stdlib.h.
    309  * XXX: let's hope there are no systems out there that need both.
    310  */
    311 #if defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H)
    312 # include <malloc.h>
    313 #endif /* defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H) */
    314 
    315 /*
    316  * Actions to take if <mntent.h> exists.
    317  */
    318 #ifdef HAVE_MNTENT_H
    319 /* some systems need <stdio.h> before <mntent.h> is included */
    320 # ifdef HAVE_STDIO_H
    321 #  include <stdio.h>
    322 # endif /* HAVE_STDIO_H */
    323 # include <mntent.h>
    324 #endif /* HAVE_MNTENT_H */
    325 
    326 /*
    327  * Actions to take if <sys/fsid.h> exists.
    328  */
    329 #ifdef HAVE_SYS_FSID_H
    330 # include <sys/fsid.h>
    331 #endif /* HAVE_SYS_FSID_H */
    332 
    333 /*
    334  * Actions to take if <sys/utsname.h> exists.
    335  */
    336 #ifdef HAVE_SYS_UTSNAME_H
    337 # include <sys/utsname.h>
    338 #endif /* HAVE_SYS_UTSNAME_H */
    339 
    340 /*
    341  * Actions to take if <sys/mntent.h> exists.
    342  */
    343 #ifdef HAVE_SYS_MNTENT_H
    344 # include <sys/mntent.h>
    345 #endif /* HAVE_SYS_MNTENT_H */
    346 
    347 /*
    348  * Actions to take if <ndbm.h> or <db1/ndbm.h> exist.
    349  * Should be included before <rpcsvc/yp_prot.h> because on some systems
    350  * like Linux, it also defines "struct datum".
    351  */
    352 #ifdef HAVE_MAP_NDBM
    353 # include NEW_DBM_H
    354 # ifndef DATUM
    355 /* ensure that struct datum is not included again from <rpcsvc/yp_prot.h> */
    356 #  define DATUM
    357 # endif /* not DATUM */
    358 #endif /* HAVE_MAP_NDBM */
    359 
    360 /*
    361  * Actions to take if <net/errno.h> exists.
    362  */
    363 #ifdef HAVE_NET_ERRNO_H
    364 # include <net/errno.h>
    365 #endif /* HAVE_NET_ERRNO_H */
    366 
    367 /*
    368  * Actions to take if <net/if.h> exists.
    369  */
    370 #ifdef HAVE_NET_IF_H
    371 # include <net/if.h>
    372 #endif /* HAVE_NET_IF_H */
    373 
    374 /*
    375  * Actions to take if <net/route.h> exists.
    376  */
    377 #ifdef HAVE_NET_ROUTE_H
    378 # include <net/route.h>
    379 #endif /* HAVE_NET_ROUTE_H */
    380 
    381 /*
    382  * Actions to take if <sys/mbuf.h> exists.
    383  */
    384 #ifdef HAVE_SYS_MBUF_H
    385 # include <sys/mbuf.h>
    386 /*
    387  * OSF4 (DU-4.0) defines m_next and m_data also in <sys/mount.h> so I must
    388  # undefine them here to avoid conflicts.
    389  */
    390 # ifdef m_next
    391 #  undef m_next
    392 # endif /* m_next */
    393 # ifdef m_data
    394 #  undef m_data
    395 # endif /* m_data */
    396 /*
    397  * AIX 3 defines MFREE and m_flags also in <sys/mount.h>.
    398  */
    399 # ifdef m_flags
    400 #  undef m_flags
    401 # endif /* m_flags */
    402 # ifdef MFREE
    403 #  undef MFREE
    404 # endif /* MFREE */
    405 #endif /* HAVE_SYS_MBUF_H */
    406 
    407 /*
    408  * Actions to take if <sys/mman.h> exists.
    409  */
    410 #ifdef HAVE_SYS_MMAN_H
    411 # include <sys/mman.h>
    412 #endif /* HAVE_SYS_MMAN_H */
    413 
    414 /*
    415  * Actions to take if <netdb.h> exists.
    416  */
    417 #ifdef HAVE_NETDB_H
    418 # include <netdb.h>
    419 #endif /* HAVE_NETDB_H */
    420 
    421 /*
    422  * Actions to take if <netdir.h> exists.
    423  */
    424 #ifdef HAVE_NETDIR_H
    425 # include <netdir.h>
    426 #endif /* HAVE_NETDIR_H */
    427 
    428 /*
    429  * Actions to take if <net/if_var.h> exists.
    430  */
    431 #ifdef HAVE_NET_IF_VAR_H
    432 # include <net/if_var.h>
    433 #endif /* HAVE_NET_IF_VAR_H */
    434 
    435 /*
    436  * Actions to take if <netinet/if_ether.h> exists.
    437  */
    438 #ifdef HAVE_NETINET_IF_ETHER_H
    439 # include <netinet/if_ether.h>
    440 #endif /* HAVE_NETINET_IF_ETHER_H */
    441 
    442 /*
    443  * Actions to take if <netinet/in.h> exists.
    444  */
    445 #ifdef HAVE_NETINET_IN_H
    446 # include <netinet/in.h>
    447 #endif /* HAVE_NETINET_IN_H */
    448 
    449 /*
    450  * Actions to take if <rpcsvc/yp_prot.h> exists.
    451  */
    452 #ifdef HAVE_RPCSVC_YP_PROT_H
    453 # ifdef HAVE_BAD_HEADERS
    454 /* avoid circular dependency in aix 4.3 with <rpcsvc/ypclnt.h> */
    455 struct ypall_callback;
    456 # endif /* HAVE_BAD_HEADERS */
    457 # include <rpcsvc/yp_prot.h>
    458 #endif /* HAVE_RPCSVC_YP_PROT_H */
    459 
    460 /*
    461  * Actions to take if <rpcsvc/ypclnt.h> exists.
    462  */
    463 #ifdef HAVE_RPCSVC_YPCLNT_H
    464 # include <rpcsvc/ypclnt.h>
    465 #endif /* HAVE_RPCSVC_YPCLNT_H */
    466 
    467 /*
    468  * Actions to take if <sys/ucred.h> exists.
    469  */
    470 #ifdef HAVE_SYS_UCRED_H
    471 # include <sys/ucred.h>
    472 #endif /* HAVE_SYS_UCRED_H */
    473 
    474 
    475 /*
    476  * Actions to take if <sys/mount.h> exists.
    477  */
    478 #ifdef HAVE_SYS_MOUNT_H
    479 /*
    480  * Some operating systems must define these variables to get
    481  * NFS and other definitions included.
    482  */
    483 # ifndef NFSCLIENT
    484 #  define NFSCLIENT 1
    485 # endif /* not NFSCLIENT */
    486 # ifndef NFS
    487 #  define NFS 1
    488 # endif /* not NFS */
    489 # ifndef PCFS
    490 #  define PCFS 1
    491 # endif /* not PCFS */
    492 # ifndef LOFS
    493 #  define LOFS 1
    494 # endif /* not LOFS */
    495 # ifndef RFS
    496 #  define RFS 1
    497 # endif /* not RFS */
    498 # ifndef MSDOSFS
    499 #  define MSDOSFS 1
    500 # endif /* not MSDOSFS */
    501 # ifndef MFS
    502 #  define MFS 1
    503 # endif /* not MFS */
    504 # ifndef CD9660
    505 #  define CD9660 1
    506 # endif /* not CD9660 */
    507 # include <sys/mount.h>
    508 #endif /* HAVE_SYS_MOUNT_H */
    509 
    510 #ifdef HAVE_SYS_VMOUNT_H
    511 # include <sys/vmount.h>
    512 #endif /* HAVE_SYS_VMOUNT_H */
    513 
    514 /*
    515  * Actions to take if <linux/fs.h> exists.
    516  * There is no point in including this on a glibc2 system,
    517  * we're only asking for trouble
    518  */
    519 #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2)
    520 /*
    521  * There are various conflicts in definitions between RedHat Linux, newer
    522  * 2.2 kernels, and <netinet/in.h> and <linux/fs.h>.
    523  */
    524 # ifdef HAVE_SOCKETBITS_H
    525 /* conflicts with <socketbits.h> */
    526 #  define _LINUX_SOCKET_H
    527 #  undef BLKFLSBUF
    528 #  undef BLKGETSIZE
    529 #  undef BLKRAGET
    530 #  undef BLKRASET
    531 #  undef BLKROGET
    532 #  undef BLKROSET
    533 #  undef BLKRRPART
    534 #  undef MS_MGC_VAL
    535 #  undef MS_RMT_MASK
    536 #  if defined(__GLIBC__) && __GLIBC__ >= 2
    537 /* conflicts with <waitflags.h> */
    538 #   undef WNOHANG
    539 #   undef WUNTRACED
    540 #  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
    541 /* conflicts with <statfsbuf.h> */
    542 #  define _SYS_STATFS_H
    543 # endif /* HAVE_SOCKETBITS_H */
    544 
    545 # ifdef _SYS_WAIT_H
    546 #  if defined(__GLIBC__) && __GLIBC__ >= 2
    547 /* conflicts with <bits/waitflags.h> (RedHat/Linux 6.0 and kernels 2.2 */
    548 #   undef WNOHANG
    549 #   undef WUNTRACED
    550 #  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
    551 # endif /* _SYS_WAIT_H */
    552 
    553 # ifdef HAVE_LINUX_POSIX_TYPES_H
    554 #  include <linux/posix_types.h>
    555 # endif /* HAVE_LINUX_POSIX_TYPES_H */
    556 # ifndef _LINUX_BYTEORDER_GENERIC_H
    557 #  define _LINUX_BYTEORDER_GENERIC_H
    558 # endif /* _LINUX_BYTEORDER_GENERIC_H */
    559 /* conflicts with <sys/mount.h> in 2.[12] kernels */
    560 # ifdef _SYS_MOUNT_H
    561 #  undef BLKFLSBUF
    562 #  undef BLKGETSIZE
    563 #  undef BLKRAGET
    564 #  undef BLKRASET
    565 #  undef BLKROGET
    566 #  undef BLKROSET
    567 #  undef BLKRRPART
    568 #  undef BLOCK_SIZE
    569 #  undef MS_MANDLOCK
    570 #  undef MS_MGC_VAL
    571 #  undef MS_NOATIME
    572 #  undef MS_NODEV
    573 #  undef MS_NODIRATIME
    574 #  undef MS_NOEXEC
    575 #  undef MS_NOSUID
    576 #  undef MS_RDONLY
    577 #  undef MS_REMOUNT
    578 #  undef MS_RMT_MASK
    579 #  undef MS_SYNCHRONOUS
    580 #  undef S_APPEND
    581 #  undef S_IMMUTABLE
    582 /* conflicts with <statfsbuf.h> */
    583 #  define _SYS_STATFS_H
    584 # endif /* _SYS_MOUNT_H */
    585 # ifndef _LINUX_STRING_H_
    586 #  define _LINUX_STRING_H_
    587 # endif /* not _LINUX_STRING_H_ */
    588 # ifdef HAVE_LINUX_KDEV_T_H
    589 #  define __KERNEL__
    590 #  include <linux/kdev_t.h>
    591 #  undef __KERNEL__
    592 # endif /* HAVE_LINUX_KDEV_T_H */
    593 # ifdef HAVE_LINUX_LIST_H
    594 #  define __KERNEL__
    595 #  include <linux/list.h>
    596 #  undef __KERNEL__
    597 # endif /* HAVE_LINUX_LIST_H */
    598 # include <linux/fs.h>
    599 #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */
    600 
    601 #ifdef HAVE_CDFS_CDFS_MOUNT_H
    602 # include <cdfs/cdfs_mount.h>
    603 #endif /* HAVE_CDFS_CDFS_MOUNT_H */
    604 
    605 #ifdef HAVE_CDFS_CDFSMOUNT_H
    606 # include <cdfs/cdfsmount.h>
    607 #endif /* HAVE_CDFS_CDFSMOUNT_H */
    608 
    609 /*
    610  * Actions to take if <linux/loop.h> exists.
    611  */
    612 #ifdef HAVE_LINUX_LOOP_H
    613 # ifdef HAVE_LINUX_POSIX_TYPES_H
    614 #  include <linux/posix_types.h>
    615 # endif /* HAVE_LINUX_POSIX_TYPES_H */
    616 /* next dev_t lines needed due to changes in kernel code */
    617 # undef dev_t
    618 # define dev_t unsigned short	/* compatible with Red Hat and SuSE */
    619 # include <linux/loop.h>
    620 #endif /* HAVE_LINUX_LOOP_H */
    621 
    622 /*
    623  * AUTOFS PROTOCOL HEADER FILES:
    624  */
    625 
    626 /*
    627  * Actions to take if <linux/auto_fs[4].h> exists.
    628  * We really don't want <linux/fs.h> pulled in here
    629  */
    630 #ifndef _LINUX_FS_H
    631 #define _LINUX_FS_H
    632 #endif /* _LINUX_FS_H */
    633 #ifdef HAVE_LINUX_AUTO_FS4_H
    634 # include <linux/auto_fs4.h>
    635 #else  /* not HAVE_LINUX_AUTO_FS4_H */
    636 # ifdef HAVE_LINUX_AUTO_FS_H
    637 #  include <linux/auto_fs.h>
    638 # endif /* HAVE_LINUX_AUTO_FS_H */
    639 #endif /* not HAVE_LINUX_AUTO_FS4_H */
    640 
    641 /*
    642  * Actions to take if <sys/fs/autofs.h> exists.
    643  */
    644 #ifdef HAVE_SYS_FS_AUTOFS_H
    645 # include <sys/fs/autofs.h>
    646 #endif /* HAVE_SYS_FS_AUTOFS_H */
    647 
    648 /*
    649  * Actions to take if <rpcsvc/autofs_prot.h> or <sys/fs/autofs_prot.h> exist.
    650  */
    651 #ifdef HAVE_RPCSVC_AUTOFS_PROT_H
    652 # include <rpcsvc/autofs_prot.h>
    653 #else  /* not HAVE_RPCSVC_AUTOFS_PROT_H */
    654 # ifdef HAVE_SYS_FS_AUTOFS_PROT_H
    655 #  include <sys/fs/autofs_prot.h>
    656 # endif /* HAVE_SYS_FS_AUTOFS_PROT_H */
    657 #endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */
    658 
    659 /*
    660  * Actions to take if <lber.h> exists.
    661  * This header file is required before <ldap.h> can be included.
    662  */
    663 #ifdef HAVE_LBER_H
    664 # include <lber.h>
    665 #endif /* HAVE_LBER_H */
    666 
    667 /*
    668  * Actions to take if <ldap.h> exists.
    669  */
    670 #ifdef HAVE_LDAP_H
    671 # include <ldap.h>
    672 #endif /* HAVE_LDAP_H */
    673 
    674 /****************************************************************************
    675  ** IMPORTANT!!!							   **
    676  ** We always include am-utils' amu_autofs_prot.h.			   **
    677  ** That is actually defined in "conf/autofs/autofs_${autofs_style}.h"     **
    678  ****************************************************************************/
    679 #include <amu_autofs_prot.h>
    680 
    681 
    682 /*
    683  * NFS PROTOCOL HEADER FILES:
    684  */
    685 
    686 /*
    687  * Actions to take if <nfs/export.h> exists.
    688  */
    689 #ifdef HAVE_NFS_EXPORT_H
    690 # include <nfs/export.h>
    691 #endif /* HAVE_NFS_EXPORT_H */
    692 
    693 /****************************************************************************
    694  ** IMPORTANT!!!							   **
    695  ** We always include am-utils' amu_nfs_prot.h.				   **
    696  ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" **
    697  ****************************************************************************/
    698 #include <amu_nfs_prot.h>
    699 
    700 /*
    701  * DO NOT INCLUDE THESE FILES:
    702  * They conflicts with other NFS headers and are generally not needed.
    703  */
    704 #ifdef DO_NOT_INCLUDE
    705 # ifdef HAVE_NFS_NFS_CLNT_H
    706 #  include <nfs/nfs_clnt.h>
    707 # endif /* HAVE_NFS_NFS_CLNT_H */
    708 # ifdef HAVE_LINUX_NFS_H
    709 #  include <linux/nfs.h>
    710 # endif /* HAVE_LINUX_NFS_H */
    711 #endif /* DO NOT INCLUDE */
    712 
    713 /*
    714  * Actions to take if one of the nfs headers exists.
    715  */
    716 #ifdef HAVE_NFS_NFS_GFS_H
    717 # include <nfs/nfs_gfs.h>
    718 #endif /* HAVE_NFS_NFS_GFS_H */
    719 #ifdef HAVE_NFS_MOUNT_H
    720 # include <nfs/mount.h>
    721 #endif /* HAVE_NFS_MOUNT_H */
    722 #ifdef HAVE_NFS_NFS_MOUNT_H_off
    723 /* broken on nextstep3 (includes non-existing headers) */
    724 # include <nfs/nfs_mount.h>
    725 #endif /* HAVE_NFS_NFS_MOUNT_H */
    726 #ifdef HAVE_NFS_PATHCONF_H
    727 # include <nfs/pathconf.h>
    728 #endif /* HAVE_NFS_PATHCONF_H */
    729 #ifdef HAVE_SYS_FS_NFS_MOUNT_H
    730 # include <sys/fs/nfs/mount.h>
    731 #endif /* HAVE_SYS_FS_NFS_MOUNT_H */
    732 #ifdef HAVE_SYS_FS_NFS_NFS_CLNT_H
    733 # include <sys/fs/nfs/nfs_clnt.h>
    734 #endif /* HAVE_SYS_FS_NFS_NFS_CLNT_H */
    735 #ifdef HAVE_SYS_FS_NFS_CLNT_H
    736 # include <sys/fs/nfs_clnt.h>
    737 #endif /* HAVE_SYS_FS_NFS_CLNT_H */
    738 
    739 /* complex rules for linux/nfs_mount.h: broken on so many systems */
    740 #ifdef HAVE_LINUX_NFS_MOUNT_H
    741 # ifndef _LINUX_NFS_H
    742 #  define _LINUX_NFS_H
    743 # endif /* not _LINUX_NFS_H */
    744 # ifndef _LINUX_NFS2_H
    745 #  define _LINUX_NFS2_H
    746 # endif /* not _LINUX_NFS2_H */
    747 # ifndef _LINUX_NFS3_H
    748 #  define _LINUX_NFS3_H
    749 # endif /* not _LINUX_NFS3_H */
    750 # ifndef _LINUX_NFS_FS_H
    751 #  define _LINUX_NFS_FS_H
    752 # endif /* not _LINUX_NFS_FS_H */
    753 # ifndef _LINUX_IN_H
    754 #  define _LINUX_IN_H
    755 # endif /* not _LINUX_IN_H */
    756 # ifndef __KERNEL__
    757 #  define __KERNEL__
    758 # endif /* __KERNEL__ */
    759 # include <linux/nfs_mount.h>
    760 # undef __KERNEL__
    761 #endif /* HAVE_LINUX_NFS_MOUNT_H */
    762 
    763 /*
    764  * Actions to take if <pwd.h> exists.
    765  */
    766 #ifdef HAVE_PWD_H
    767 # include <pwd.h>
    768 #endif /* HAVE_PWD_H */
    769 
    770 /*
    771  * Actions to take if <hesiod.h> exists.
    772  */
    773 #ifdef HAVE_HESIOD_H
    774 # include <hesiod.h>
    775 #endif /* HAVE_HESIOD_H */
    776 
    777 /*
    778  * Actions to take if <arpa/nameser.h> exists.
    779  * Should be included before <resolv.h>.
    780  */
    781 #ifdef HAVE_ARPA_NAMESER_H
    782 # ifdef NOERROR
    783 #  undef NOERROR
    784 # endif /* NOERROR */
    785 /*
    786  * Conflicts with <sys/tpicommon.h> which is included from <sys/tiuser.h>
    787  * on Solaris 2.6 systems.  So undefine it first.
    788  */
    789 # ifdef T_UNSPEC
    790 #  undef T_UNSPEC
    791 # endif /* T_UNSPEC */
    792 # include <arpa/nameser.h>
    793 #endif /* HAVE_ARPA_NAMESER_H */
    794 
    795 /*
    796  * Actions to take if <arpa/inet.h> exists.
    797  */
    798 #ifdef HAVE_ARPA_INET_H
    799 # ifdef HAVE_BAD_HEADERS
    800 /* aix 4.3: avoid including <net/if_dl.h> */
    801 struct sockaddr_dl;
    802 # endif /* HAVE_BAD_HEADERS */
    803 # include <arpa/inet.h>
    804 #endif /* HAVE_ARPA_INET_H */
    805 
    806 /*
    807  * Actions to take if <resolv.h> exists.
    808  */
    809 #ifdef HAVE_RESOLV_H
    810 /*
    811  * On AIX 5.2, both <resolv.h> and <arpa/nameser_compat.h> define MAXDNAME,
    812  * if compiling with gcc -D_USE_IRS (so that we get extern definitions for
    813  * hstrerror() and others).
    814  */
    815 # if defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS)
    816 #  undef MAXDNAME
    817 # endif /* defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) */
    818 # include <resolv.h>
    819 #endif /* HAVE_RESOLV_H */
    820 
    821 /*
    822  * Actions to take if <sys/uio.h> exists.
    823  */
    824 #ifdef HAVE_SYS_UIO_H
    825 # include <sys/uio.h>
    826 #endif /* HAVE_SYS_UIO_H */
    827 
    828 /*
    829  * Actions to take if <sys/fs/cachefs_fs.h> exists.
    830  */
    831 #ifdef HAVE_SYS_FS_CACHEFS_FS_H
    832 # include <sys/fs/cachefs_fs.h>
    833 #endif /* HAVE_SYS_FS_CACHEFS_FS_H */
    834 
    835 /*
    836  * Actions to take if <sys/fs/pc_fs.h> exists.
    837  */
    838 #ifdef HAVE_SYS_FS_PC_FS_H
    839 # include <sys/fs/pc_fs.h>
    840 #endif /* HAVE_SYS_FS_PC_FS_H */
    841 
    842 /*
    843  * Actions to take if <msdosfs/msdosfsmount.h> exists.
    844  */
    845 #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
    846 # include <msdosfs/msdosfsmount.h>
    847 #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
    848 
    849 /*
    850  * Actions to take if <fs/msdosfs/msdosfsmount.h> exists.
    851  */
    852 #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
    853 # include <fs/msdosfs/msdosfsmount.h>
    854 #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
    855 
    856 /*
    857  * Actions to take if <sys/fs/tmp.h> exists.
    858  */
    859 #ifdef HAVE_SYS_FS_TMP_H
    860 # include <sys/fs/tmp.h>
    861 #endif /* HAVE_SYS_FS_TMP_H */
    862 #ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H
    863 # include <fs/tmpfs/tmpfs_args.h>
    864 #endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */
    865 
    866 
    867 /*
    868  * Actions to take if <sys/fs/ufs_mount.h> exists.
    869  */
    870 #ifdef HAVE_SYS_FS_UFS_MOUNT_H
    871 # include <sys/fs/ufs_mount.h>
    872 #endif /* HAVE_SYS_FS_UFS_MOUNT_H */
    873 #ifdef	HAVE_UFS_UFS_UFSMOUNT_H_off
    874 # error do not include this file here because on netbsd/openbsd it
    875 # error causes errors with other header files.  Instead, add it to the
    876 # error specific conf/nfs_prot_*.h file.
    877 # include <ufs/ufs/ufsmount.h>
    878 #endif	/* HAVE_UFS_UFS_UFSMOUNT_H_off */
    879 
    880 /*
    881  * Actions to take if <sys/fs/efs_clnt.h> exists.
    882  */
    883 #ifdef HAVE_SYS_FS_EFS_CLNT_H
    884 # include <sys/fs/efs_clnt.h>
    885 #endif /* HAVE_SYS_FS_EFS_CLNT_H */
    886 #ifdef HAVE_FS_EFS_EFS_MOUNT_H
    887 # include <fs/efs/efs_mount.h>
    888 #endif /* HAVE_FS_EFS_EFS_MOUNT_H */
    889 
    890 /*
    891  * Actions to take if <sys/fs/xfs_clnt.h> exists.
    892  */
    893 #ifdef HAVE_SYS_FS_XFS_CLNT_H
    894 # include <sys/fs/xfs_clnt.h>
    895 #endif /* HAVE_SYS_FS_XFS_CLNT_H */
    896 
    897 /*
    898  * Actions to take if <assert.h> exists.
    899  */
    900 #ifdef HAVE_ASSERT_H
    901 # include <assert.h>
    902 #endif /* HAVE_ASSERT_H */
    903 
    904 /*
    905  * Actions to take if <cfs.h> exists.
    906  */
    907 #ifdef HAVE_CFS_H
    908 # include <cfs.h>
    909 #endif /* HAVE_CFS_H */
    910 
    911 /*
    912  * Actions to take if <cluster.h> exists.
    913  */
    914 #ifdef HAVE_CLUSTER_H
    915 # include <cluster.h>
    916 #endif /* HAVE_CLUSTER_H */
    917 
    918 /*
    919  * Actions to take if <ctype.h> exists.
    920  */
    921 #ifdef HAVE_CTYPE_H
    922 # include <ctype.h>
    923 #endif /* HAVE_CTYPE_H */
    924 
    925 /*
    926  * Actions to take if <errno.h> exists.
    927  */
    928 #ifdef HAVE_ERRNO_H
    929 # include <errno.h>
    930 #else
    931 /*
    932  * Actions to take if <sys/errno.h> exists.
    933  */
    934 # ifdef HAVE_SYS_ERRNO_H
    935 #  include <sys/errno.h>
    936 extern int errno;
    937 # endif /* HAVE_SYS_ERRNO_H */
    938 #endif /* HAVE_ERRNO_H */
    939 
    940 /*
    941  * Actions to take if <grp.h> exists.
    942  */
    943 #ifdef HAVE_GRP_H
    944 # include <grp.h>
    945 #endif /* HAVE_GRP_H */
    946 
    947 /*
    948  * Actions to take if <hsfs/hsfs.h> exists.
    949  */
    950 #ifdef HAVE_HSFS_HSFS_H
    951 # include <hsfs/hsfs.h>
    952 #endif /* HAVE_HSFS_HSFS_H */
    953 
    954 /*
    955  * Actions to take if <cdfs/cdfsmount.h> exists.
    956  */
    957 #ifdef HAVE_CDFS_CDFSMOUNT_H
    958 # include <cdfs/cdfsmount.h>
    959 #endif /* HAVE_CDFS_CDFSMOUNT_H */
    960 
    961 /*
    962  * Actions to take if <isofs/cd9660/cd9660_mount.h> exists.
    963  */
    964 #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H
    965 # include <isofs/cd9660/cd9660_mount.h>
    966 #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */
    967 
    968 /*
    969  * Actions to take if <fs/udf/udf_mount.h> exists.
    970  */
    971 #ifdef HAVE_FS_UDF_UDF_MOUNT_H
    972 # include <fs/udf/udf_mount.h>
    973 #endif /* HAVE_FS_UDF_UDF_MOUNT_H */
    974 
    975 /*
    976  * Actions to take if <mount.h> exists.
    977  */
    978 #ifdef HAVE_MOUNT_H
    979 # include <mount.h>
    980 #endif /* HAVE_MOUNT_H */
    981 
    982 /*
    983  * Actions to take if <nsswitch.h> exists.
    984  */
    985 #ifdef HAVE_NSSWITCH_H
    986 # include <nsswitch.h>
    987 #endif /* HAVE_NSSWITCH_H */
    988 
    989 /*
    990  * Actions to take if <rpc/auth_des.h> exists.
    991  */
    992 #ifdef HAVE_RPC_AUTH_DES_H
    993 # include <rpc/auth_des.h>
    994 #endif /* HAVE_RPC_AUTH_DES_H */
    995 
    996 /*
    997  * Actions to take if <rpc/pmap_clnt.h> exists.
    998  */
    999 #ifdef HAVE_RPC_PMAP_CLNT_H
   1000 # include <rpc/pmap_clnt.h>
   1001 #endif /* HAVE_RPC_PMAP_CLNT_H */
   1002 
   1003 /*
   1004  * Actions to take if <rpc/pmap_prot.h> exists.
   1005  */
   1006 #ifdef HAVE_RPC_PMAP_PROT_H
   1007 # include <rpc/pmap_prot.h>
   1008 #endif /* HAVE_RPC_PMAP_PROT_H */
   1009 
   1010 
   1011 /*
   1012  * Actions to take if <rpcsvc/mount.h> exists.
   1013  * AIX does not protect against this file doubly included,
   1014  * so I have to do my own protection here.
   1015  */
   1016 #ifdef HAVE_RPCSVC_MOUNT_H
   1017 # ifndef _RPCSVC_MOUNT_H
   1018 #  include <rpcsvc/mount.h>
   1019 # endif /* not _RPCSVC_MOUNT_H */
   1020 #endif /* HAVE_RPCSVC_MOUNT_H */
   1021 
   1022 /*
   1023  * Actions to take if <rpcsvc/nis.h> exists.
   1024  */
   1025 #ifdef HAVE_RPCSVC_NIS_H
   1026 /*
   1027  * Solaris 10 (build 72) defines GROUP_OBJ in <sys/acl.h>, which is included
   1028  * in many other header files.  <rpcsvc/nis.h> uses GROUP_OBJ inside enum
   1029  * zotypes.  So if you're unlucky enough to include both headers, you get a
   1030  * compile error because the two symbols conflict.
   1031  * A similar conflict arises with Sun cc and the definition of "GROUP".
   1032  *
   1033  * Temp hack: undefine acl.h's GROUP_OBJ and GROUP because they're not needed
   1034  * for am-utils.
   1035  */
   1036 # ifdef GROUP_OBJ
   1037 #  undef GROUP_OBJ
   1038 # endif /* GROUP_OBJ */
   1039 # ifdef GROUP
   1040 #  undef GROUP
   1041 # endif /* GROUP */
   1042 # include <rpcsvc/nis.h>
   1043 #endif /* HAVE_RPCSVC_NIS_H */
   1044 
   1045 /*
   1046  * Actions to take if <setjmp.h> exists.
   1047  */
   1048 #ifdef HAVE_SETJMP_H
   1049 # include <setjmp.h>
   1050 #endif /* HAVE_SETJMP_H */
   1051 
   1052 /*
   1053  * Actions to take if <signal.h> exists.
   1054  */
   1055 #ifdef HAVE_SIGNAL_H
   1056 # include <signal.h>
   1057 #endif /* HAVE_SIGNAL_H */
   1058 
   1059 /*
   1060  * Actions to take if <string.h> exists.
   1061  */
   1062 #ifdef HAVE_STRING_H
   1063 # include <string.h>
   1064 #endif /* HAVE_STRING_H */
   1065 
   1066 /*
   1067  * Actions to take if <strings.h> exists.
   1068  */
   1069 #ifdef HAVE_STRINGS_H
   1070 # include <strings.h>
   1071 #endif /* HAVE_STRINGS_H */
   1072 
   1073 /*
   1074  * Actions to take if <sys/config.h> exists.
   1075  */
   1076 #ifdef HAVE_SYS_CONFIG_H
   1077 # include <sys/config.h>
   1078 #endif /* HAVE_SYS_CONFIG_H */
   1079 
   1080 /*
   1081  * Actions to take if <sys/dg_mount.h> exists.
   1082  */
   1083 #ifdef HAVE_SYS_DG_MOUNT_H
   1084 # include <sys/dg_mount.h>
   1085 #endif /* HAVE_SYS_DG_MOUNT_H */
   1086 
   1087 /*
   1088  * Actions to take if <sys/fs_types.h> exists.
   1089  */
   1090 #ifdef HAVE_SYS_FS_TYPES_H
   1091 /*
   1092  * Define KERNEL here to avoid multiple definitions of gt_names[] on
   1093  * Ultrix 4.3.
   1094  */
   1095 # define KERNEL
   1096 # include <sys/fs_types.h>
   1097 # undef KERNEL
   1098 #endif /* HAVE_SYS_FS_TYPES_H */
   1099 
   1100 /*
   1101  * Actions to take if <sys/fstyp.h> exists.
   1102  */
   1103 #ifdef HAVE_SYS_FSTYP_H
   1104 # include <sys/fstyp.h>
   1105 #endif /* HAVE_SYS_FSTYP_H */
   1106 
   1107 /*
   1108  * Actions to take if <sys/lock.h> exists.
   1109  */
   1110 #ifdef HAVE_SYS_LOCK_H
   1111 # include <sys/lock.h>
   1112 #endif /* HAVE_SYS_LOCK_H */
   1113 
   1114 /*
   1115  * Actions to take if <sys/machine.h> exists.
   1116  */
   1117 #ifdef HAVE_SYS_MACHINE_H
   1118 # include <sys/machine.h>
   1119 #endif /* HAVE_SYS_MACHINE_H */
   1120 
   1121 /*
   1122  * Actions to take if <sys/mntctl.h> exists.
   1123  */
   1124 #ifdef HAVE_SYS_MNTCTL_H
   1125 # include <sys/mntctl.h>
   1126 #endif /* HAVE_SYS_MNTCTL_H */
   1127 
   1128 /*
   1129  * Actions to take if <sys/mnttab.h> exists.
   1130  */
   1131 #ifdef HAVE_SYS_MNTTAB_H
   1132 # include <sys/mnttab.h>
   1133 #endif /* HAVE_SYS_MNTTAB_H */
   1134 
   1135 /*
   1136  * Actions to take if <mnttab.h> exists.
   1137  * Do not include it if MNTTAB is already defined because it probably
   1138  * came from <sys/mnttab.h> and we do not want conflicting definitions.
   1139  */
   1140 #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB)
   1141 # include <mnttab.h>
   1142 #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */
   1143 
   1144 /*
   1145  * Actions to take if <netconfig.h> exists.
   1146  */
   1147 #ifdef HAVE_NETCONFIG_H
   1148 # include <netconfig.h>
   1149 /* Some systems (Solaris 2.5.1) don't declare this external */
   1150 extern char *nc_sperror(void);
   1151 #endif /* HAVE_NETCONFIG_H */
   1152 
   1153 /*
   1154  * Actions to take if <sys/netconfig.h> exists.
   1155  */
   1156 #ifdef HAVE_SYS_NETCONFIG_H
   1157 # include <sys/netconfig.h>
   1158 #endif /* HAVE_SYS_NETCONFIG_H */
   1159 
   1160 /*
   1161  * Actions to take if <sys/pathconf.h> exists.
   1162  */
   1163 #ifdef HAVE_SYS_PATHCONF_H
   1164 # include <sys/pathconf.h>
   1165 #endif /* HAVE_SYS_PATHCONF_H */
   1166 
   1167 /*
   1168  * Actions to take if <sys/resource.h> exists.
   1169  */
   1170 #ifdef HAVE_SYS_RESOURCE_H
   1171 # include <sys/resource.h>
   1172 #endif /* HAVE_SYS_RESOURCE_H */
   1173 
   1174 /*
   1175  * Actions to take if <sys/sema.h> exists.
   1176  */
   1177 #ifdef HAVE_SYS_SEMA_H
   1178 # include <sys/sema.h>
   1179 #endif /* HAVE_SYS_SEMA_H */
   1180 
   1181 /*
   1182  * Actions to take if <sys/signal.h> exists.
   1183  */
   1184 #ifdef HAVE_SYS_SIGNAL_H
   1185 # include <sys/signal.h>
   1186 #endif /* HAVE_SYS_SIGNAL_H */
   1187 
   1188 /*
   1189  * Actions to take if <sys/sockio.h> exists.
   1190  */
   1191 #ifdef HAVE_SYS_SOCKIO_H
   1192 # include <sys/sockio.h>
   1193 #endif /* HAVE_SYS_SOCKIO_H */
   1194 
   1195 /*
   1196  * Actions to take if <sys/syscall.h> exists.
   1197  */
   1198 #ifdef HAVE_SYS_SYSCALL_H
   1199 # include <sys/syscall.h>
   1200 #endif /* HAVE_SYS_SYSCALL_H */
   1201 
   1202 /*
   1203  * Actions to take if <sys/syslimits.h> exists.
   1204  */
   1205 #ifdef HAVE_SYS_SYSLIMITS_H
   1206 # include <sys/syslimits.h>
   1207 #endif /* HAVE_SYS_SYSLIMITS_H */
   1208 
   1209 /*
   1210  * Actions to take if <tiuser.h> exists.
   1211  */
   1212 #ifdef HAVE_TIUSER_H
   1213 /*
   1214  * Some systems like AIX have multiple definitions for T_NULL and others
   1215  * that are defined first in <arpa/nameser.h>.
   1216  */
   1217 # ifdef HAVE_ARPA_NAMESER_H
   1218 #  ifdef T_NULL
   1219 #   undef T_NULL
   1220 #  endif /* T_NULL */
   1221 #  ifdef T_UNSPEC
   1222 #   undef T_UNSPEC
   1223 #  endif /* T_UNSPEC */
   1224 #  ifdef T_IDLE
   1225 #   undef T_IDLE
   1226 #  endif /* T_IDLE */
   1227 # endif /* HAVE_ARPA_NAMESER_H */
   1228 # include <tiuser.h>
   1229 #endif /* HAVE_TIUSER_H */
   1230 
   1231 /*
   1232  * Actions to take if <sys/tiuser.h> exists.
   1233  */
   1234 #ifdef HAVE_SYS_TIUSER_H
   1235 # include <sys/tiuser.h>
   1236 #endif /* HAVE_SYS_TIUSER_H */
   1237 
   1238 /*
   1239  * Actions to take if <sys/statfs.h> exists.
   1240  */
   1241 #ifdef HAVE_SYS_STATFS_H
   1242 # include <sys/statfs.h>
   1243 #endif /* HAVE_SYS_STATFS_H */
   1244 
   1245 /*
   1246  * Actions to take if <sys/statvfs.h> exists.
   1247  */
   1248 #ifdef HAVE_SYS_STATVFS_H
   1249 # include <sys/statvfs.h>
   1250 #endif /* HAVE_SYS_STATVFS_H */
   1251 
   1252 /*
   1253  * Actions to take if <sys/vfs.h> exists.
   1254  */
   1255 #ifdef HAVE_SYS_VFS_H
   1256 # include <sys/vfs.h>
   1257 #endif /* HAVE_SYS_VFS_H */
   1258 
   1259 /*
   1260  * Actions to take if <sys/vmount.h> exists.
   1261  */
   1262 #ifdef HAVE_SYS_VMOUNT_H
   1263 # include <sys/vmount.h>
   1264 #endif /* HAVE_SYS_VMOUNT_H */
   1265 
   1266 /*
   1267  * Actions to take if <ufs/ufs_mount.h> exists.
   1268  */
   1269 #ifdef HAVE_UFS_UFS_MOUNT_H
   1270 # include <ufs/ufs_mount.h>
   1271 #endif /* HAVE_UFS_UFS_MOUNT_H */
   1272 
   1273 /*
   1274  * Are S_ISDIR, S_ISREG, et al broken?  If not, include <sys/stat.h>.
   1275  * Turned off the not using sys/stat.h based on if the macros are
   1276  * "broken", because they incorrectly get reported as broken on
   1277  * ncr2.
   1278  */
   1279 #ifndef STAT_MACROS_BROKEN_notused
   1280 /*
   1281  * RedHat Linux 4.2 (alpha) has a problem in the headers that causes
   1282  * duplicate definitions, and also some other nasty bugs.  Upgrade to Redhat
   1283  * 5.0!
   1284  */
   1285 # ifdef HAVE_SYS_STAT_H
   1286 /* avoid duplicates or conflicts with <linux/stat.h> (RedHat alpha linux) */
   1287 #  if defined(S_IFREG) && defined(HAVE_STATBUF_H)
   1288 #   include <statbuf.h>
   1289 #   undef S_IFBLK
   1290 #   undef S_IFCHR
   1291 #   undef S_IFDIR
   1292 #   undef S_IFIFO
   1293 #   undef S_IFLNK
   1294 #   undef S_IFMT
   1295 #   undef S_IFREG
   1296 #   undef S_IFSOCK
   1297 #   undef S_IRGRP
   1298 #   undef S_IROTH
   1299 #   undef S_IRUSR
   1300 #   undef S_IRWXG
   1301 #   undef S_IRWXO
   1302 #   undef S_IRWXU
   1303 #   undef S_ISBLK
   1304 #   undef S_ISCHR
   1305 #   undef S_ISDIR
   1306 #   undef S_ISFIFO
   1307 #   undef S_ISGID
   1308 #   undef S_ISLNK
   1309 #   undef S_ISREG
   1310 #   undef S_ISSOCK
   1311 #   undef S_ISUID
   1312 #   undef S_ISVTX
   1313 #   undef S_IWGRP
   1314 #   undef S_IWOTH
   1315 #   undef S_IWUSR
   1316 #   undef S_IXGRP
   1317 #   undef S_IXOTH
   1318 #   undef S_IXUSR
   1319 #  endif /* defined(S_IFREG) && defined(HAVE_STATBUF_H) */
   1320 #  include <sys/stat.h>
   1321 # endif /* HAVE_SYS_STAT_H */
   1322 #endif /* not STAT_MACROS_BROKEN_notused */
   1323 
   1324 /*
   1325  * Actions to take if <stdio.h> exists.
   1326  */
   1327 #ifdef HAVE_STDIO_H
   1328 # include <stdio.h>
   1329 #endif /* HAVE_STDIO_H */
   1330 
   1331 /*
   1332  * Actions to take if <stdlib.h> exists.
   1333  */
   1334 #ifdef HAVE_STDLIB_H
   1335 # include <stdlib.h>
   1336 #endif /* HAVE_STDLIB_H */
   1337 
   1338 /*
   1339  * Actions to take if <regex.h> exists.
   1340  */
   1341 #ifdef HAVE_REGEX_H
   1342 # include <regex.h>
   1343 #endif /* HAVE_REGEX_H */
   1344 
   1345 /*
   1346  * Actions to take if <tcpd.h> exists.
   1347  */
   1348 #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP)
   1349 # include <tcpd.h>
   1350 #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */
   1351 
   1352 
   1353 /****************************************************************************/
   1354 /*
   1355  * Specific macros we're looking for.
   1356  */
   1357 #ifndef HAVE_MEMSET
   1358 # ifdef HAVE_BZERO
   1359 #  define	memset(ptr, val, len)	bzero((ptr), (len))
   1360 # else /* not HAVE_BZERO */
   1361 #  error Cannot find either memset or bzero!
   1362 # endif /* not HAVE_BZERO */
   1363 #endif /* not HAVE_MEMSET */
   1364 
   1365 #ifndef HAVE_MEMMOVE
   1366 # ifdef HAVE_BCOPY
   1367 #  define	memmove(to, from, len)	bcopy((from), (to), (len))
   1368 # else /* not HAVE_BCOPY */
   1369 #  error Cannot find either memmove or bcopy!
   1370 # endif /* not HAVE_BCOPY */
   1371 #endif /* not HAVE_MEMMOVE */
   1372 
   1373 /*
   1374  * memcmp() is more problematic:
   1375  * Systems that don't have it, but have bcmp(), will use bcmp() instead.
   1376  * Those that have it, but it is bad (SunOS 4 doesn't handle
   1377  * 8 bit comparisons correctly), will get to use am_memcmp().
   1378  * Otherwise if you have memcmp() and it is good, use it.
   1379  */
   1380 #ifdef HAVE_MEMCMP
   1381 # ifdef HAVE_BAD_MEMCMP
   1382 #  define	memcmp		am_memcmp
   1383 extern int am_memcmp(const voidp s1, const voidp s2, size_t len);
   1384 # endif /* HAVE_BAD_MEMCMP */
   1385 #else /* not HAVE_MEMCMP */
   1386 # ifdef HAVE_BCMP
   1387 #  define	memcmp(a, b, len)	bcmp((a), (b), (len))
   1388 # endif /* HAVE_BCMP */
   1389 #endif /* not HAVE_MEMCMP */
   1390 
   1391 #ifndef HAVE_SETEUID
   1392 # ifdef HAVE_SETRESUID
   1393 #  define	seteuid(x)		setresuid(-1,(x),-1)
   1394 # else /* not HAVE_SETRESUID */
   1395 #  error Cannot find either seteuid or setresuid!
   1396 # endif /* not HAVE_SETRESUID */
   1397 #endif /* not HAVE_SETEUID */
   1398 
   1399 /*
   1400  * Define type of mntent_t.
   1401  * Defaults to struct mntent, else struct mnttab.  If neither is found, and
   1402  * the operating system does keep not mount tables in the kernel, then flag
   1403  * it as an error.  If neither is found and the OS keeps mount tables in the
   1404  * kernel, then define our own version of mntent; it will be needed for amd
   1405  * to keep its own internal version of the mount tables.
   1406  */
   1407 #ifdef HAVE_STRUCT_MNTENT
   1408 typedef struct mntent mntent_t;
   1409 #else /* not HAVE_STRUCT_MNTENT */
   1410 # ifdef HAVE_STRUCT_MNTTAB
   1411 typedef struct mnttab mntent_t;
   1412 /* map struct mnttab field names to struct mntent field names */
   1413 #  define mnt_fsname	mnt_special
   1414 #  define mnt_dir	mnt_mountp
   1415 #  define mnt_opts	mnt_mntopts
   1416 #  define mnt_type	mnt_fstype
   1417 # else /* not HAVE_STRUCT_MNTTAB */
   1418 #  ifdef MOUNT_TABLE_ON_FILE
   1419 #   error Could not find definition for struct mntent or struct mnttab!
   1420 #  else /* not MOUNT_TABLE_ON_FILE */
   1421 typedef struct _am_mntent {
   1422   char	*mnt_fsname;		/* name of mounted file system */
   1423   char	*mnt_dir;		/* file system path prefix */
   1424   char	*mnt_type;		/* MNTTAB_TYPE_* */
   1425   char	*mnt_opts;		/* MNTTAB_OPT_* */
   1426   int	mnt_freq;		/* dump frequency, in days */
   1427   int	mnt_passno;		/* pass number on parallel fsck */
   1428 } mntent_t;
   1429 #  endif /* not MOUNT_TABLE_ON_FILE */
   1430 # endif /* not HAVE_STRUCT_MNTTAB */
   1431 #endif /* not HAVE_STRUCT_MNTENT */
   1432 
   1433 /*
   1434  * Provide FD_* macros for systems that lack them.
   1435  */
   1436 #ifndef FD_SET
   1437 # define FD_SET(fd, set) (*(set) |= (1 << (fd)))
   1438 # define FD_ISSET(fd, set) (*(set) & (1 << (fd)))
   1439 # define FD_CLR(fd, set) (*(set) &= ~(1 << (fd)))
   1440 # define FD_ZERO(set) (*(set) = 0)
   1441 #endif /* not FD_SET */
   1442 
   1443 
   1444 /*
   1445  * Complete external definitions missing from some systems.
   1446  */
   1447 
   1448 #ifndef HAVE_EXTERN_SYS_ERRLIST
   1449 extern const char *const sys_errlist[];
   1450 #endif /* not HAVE_EXTERN_SYS_ERRLIST */
   1451 
   1452 #ifndef HAVE_EXTERN_OPTARG
   1453 extern char *optarg;
   1454 extern int optind;
   1455 #endif /* not HAVE_EXTERN_OPTARG */
   1456 
   1457 #if defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR)
   1458 extern char *clnt_spcreateerror(const char *s);
   1459 #endif /* defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) */
   1460 
   1461 #if defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO)
   1462 extern char *clnt_sperrno(const enum clnt_stat num);
   1463 #endif /* defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) */
   1464 
   1465 #ifndef HAVE_EXTERN_FREE
   1466 extern void free(voidp);
   1467 #endif /* not HAVE_EXTERN_FREE */
   1468 
   1469 #if defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS)
   1470 extern void get_myaddress(struct sockaddr_in *addr);
   1471 #endif /* defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) */
   1472 
   1473 #if defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME)
   1474 # if defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS)
   1475 extern int getdomainname(char *name, int namelen);
   1476 # endif /* defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) */
   1477 #endif /* defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) */
   1478 
   1479 #if defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE)
   1480 extern int getdtablesize(void);
   1481 #endif /* defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) */
   1482 
   1483 #if defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME)
   1484 extern int gethostname(char *name, int namelen);
   1485 #endif /* defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) */
   1486 
   1487 #ifndef HAVE_EXTERN_GETLOGIN
   1488 extern char *getlogin(void);
   1489 #endif /* not HAVE_EXTERN_GETLOGIN */
   1490 
   1491 #if defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE)
   1492 extern int getpagesize(void);
   1493 #endif /* defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) */
   1494 
   1495 #ifndef HAVE_EXTERN_GETWD
   1496 extern char *getwd(char *s);
   1497 #endif /* not HAVE_EXTERN_GETWD */
   1498 
   1499 #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL)
   1500 extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, char *client_user);
   1501 #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) */
   1502 
   1503 #ifndef HAVE_EXTERN_INNETGR
   1504 extern int innetgr(char *, char *, char *, char *);
   1505 #endif /* not HAVE_EXTERN_INNETGR */
   1506 
   1507 #if defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP)
   1508 extern int mkstemp(char *);
   1509 #endif /* defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) */
   1510 
   1511 #ifndef HAVE_EXTERN_SBRK
   1512 extern caddr_t sbrk(int incr);
   1513 #endif /* not HAVE_EXTERN_SBRK */
   1514 
   1515 #if defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID)
   1516 extern int seteuid(uid_t euid);
   1517 #endif /* not defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) */
   1518 
   1519 #if defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER)
   1520 extern int setitimer(int, struct itimerval *, struct itimerval *);
   1521 #endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */
   1522 
   1523 #ifndef HAVE_EXTERN_SLEEP
   1524 extern unsigned int sleep(unsigned int seconds);
   1525 #endif /* not HAVE_EXTERN_SETITIMER */
   1526 
   1527 #ifndef HAVE_EXTERN_STRCASECMP
   1528 /*
   1529  * define this extern even if function does not exist, for it will
   1530  * be filled in by libamu/strcasecmp.c
   1531  */
   1532 extern int strcasecmp(const char *s1, const char *s2);
   1533 #endif /* not HAVE_EXTERN_STRCASECMP */
   1534 
   1535 #ifndef HAVE_EXTERN_STRLCAT
   1536 /*
   1537  * define this extern even if function does not exist, for it will
   1538  * be filled in by libamu/strlcat.c
   1539  */
   1540 extern size_t strlcat(char *dst, const char *src, size_t siz);
   1541 #endif /* not HAVE_EXTERN_STRLCAT */
   1542 
   1543 #ifndef HAVE_EXTERN_STRLCPY
   1544 /*
   1545  * define this extern even if function does not exist, for it will
   1546  * be filled in by libamu/strlcpy.c
   1547  */
   1548 extern size_t strlcpy(char *dst, const char *src, size_t siz);
   1549 #endif /* not HAVE_EXTERN_STRLCPY */
   1550 
   1551 #if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR)
   1552 extern char *strstr(const char *s1, const char *s2);
   1553 #endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */
   1554 
   1555 #if defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP)
   1556 extern int usleep(u_int useconds);
   1557 #endif /* defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) */
   1558 
   1559 #ifndef HAVE_EXTERN_UALARM
   1560 extern u_int ualarm(u_int usecs, u_int interval);
   1561 #endif /* not HAVE_EXTERN_UALARM */
   1562 
   1563 #if defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3)
   1564 extern int wait3(int *statusp, int options, struct rusage *rusage);
   1565 #endif /* defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) */
   1566 
   1567 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF)
   1568 extern int vsnprintf(char *, int, const char *, ...);
   1569 #endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */
   1570 
   1571 #ifndef HAVE_EXTERN_XDR_CALLMSG
   1572 extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg);
   1573 #endif /* not HAVE_EXTERN_XDR_CALLMSG */
   1574 
   1575 #ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH
   1576 extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth);
   1577 #endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */
   1578 
   1579 /****************************************************************************/
   1580 /*
   1581  * amd-specific header files.
   1582  */
   1583 #ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE
   1584 # include <amu_nfs_prot.h>
   1585 #endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */
   1586 #include <am_compat.h>
   1587 #include <am_xdr_func.h>
   1588 #include <am_utils.h>
   1589 #include <amq_defs.h>
   1590 #include <aux_conf.h>
   1591 
   1592 
   1593 /****************************************************************************/
   1594 /*
   1595  * External definitions that depend on other macros available (or not)
   1596  * and those are probably declared in any of the above headers.
   1597  */
   1598 
   1599 #ifdef HAVE_HASMNTOPT
   1600 # ifdef HAVE_BAD_HASMNTOPT
   1601 extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
   1602 # else /* not HAVE_BAD_HASMNTOPT */
   1603 #  define amu_hasmntopt hasmntopt
   1604 # endif /* not HAVE_BAD_HASMNTOPT */
   1605 #else /* not HAVE_HASMNTOPT */
   1606 extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
   1607 #endif /* not HAVE_HASMNTOPT */
   1608 
   1609 #endif /* not _AM_DEFS_H */
   1610