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