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