xref: /netbsd-src/external/bsd/am-utils/dist/include/am_defs.h (revision 274254cdae52594c1aa480a736aef78313d15c9c)
1 /*	$NetBSD: am_defs.h,v 1.1.1.2 2009/03/20 20:26:55 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  * Actions to take if <sys/errno.h> exists.
326  */
327 #ifdef HAVE_SYS_ERRNO_H
328 # include <sys/errno.h>
329 extern int errno;
330 #endif /* HAVE_SYS_ERRNO_H */
331 
332 /*
333  * Actions to take if <sys/fsid.h> exists.
334  */
335 #ifdef HAVE_SYS_FSID_H
336 # include <sys/fsid.h>
337 #endif /* HAVE_SYS_FSID_H */
338 
339 /*
340  * Actions to take if <sys/utsname.h> exists.
341  */
342 #ifdef HAVE_SYS_UTSNAME_H
343 # include <sys/utsname.h>
344 #endif /* HAVE_SYS_UTSNAME_H */
345 
346 /*
347  * Actions to take if <sys/mntent.h> exists.
348  */
349 #ifdef HAVE_SYS_MNTENT_H
350 # include <sys/mntent.h>
351 #endif /* HAVE_SYS_MNTENT_H */
352 
353 /*
354  * Actions to take if <ndbm.h> or <db1/ndbm.h> exist.
355  * Should be included before <rpcsvc/yp_prot.h> because on some systems
356  * like Linux, it also defines "struct datum".
357  */
358 #ifdef HAVE_MAP_NDBM
359 # include NEW_DBM_H
360 # ifndef DATUM
361 /* ensure that struct datum is not included again from <rpcsvc/yp_prot.h> */
362 #  define DATUM
363 # endif /* not DATUM */
364 #endif /* HAVE_MAP_NDBM */
365 
366 /*
367  * Actions to take if <net/errno.h> exists.
368  */
369 #ifdef HAVE_NET_ERRNO_H
370 # include <net/errno.h>
371 #endif /* HAVE_NET_ERRNO_H */
372 
373 /*
374  * Actions to take if <net/if.h> exists.
375  */
376 #ifdef HAVE_NET_IF_H
377 # include <net/if.h>
378 #endif /* HAVE_NET_IF_H */
379 
380 /*
381  * Actions to take if <net/route.h> exists.
382  */
383 #ifdef HAVE_NET_ROUTE_H
384 # include <net/route.h>
385 #endif /* HAVE_NET_ROUTE_H */
386 
387 /*
388  * Actions to take if <sys/mbuf.h> exists.
389  */
390 #ifdef HAVE_SYS_MBUF_H
391 # include <sys/mbuf.h>
392 /*
393  * OSF4 (DU-4.0) defines m_next and m_data also in <sys/mount.h> so I must
394  # undefine them here to avoid conflicts.
395  */
396 # ifdef m_next
397 #  undef m_next
398 # endif /* m_next */
399 # ifdef m_data
400 #  undef m_data
401 # endif /* m_data */
402 /*
403  * AIX 3 defines MFREE and m_flags also in <sys/mount.h>.
404  */
405 # ifdef m_flags
406 #  undef m_flags
407 # endif /* m_flags */
408 # ifdef MFREE
409 #  undef MFREE
410 # endif /* MFREE */
411 #endif /* HAVE_SYS_MBUF_H */
412 
413 /*
414  * Actions to take if <sys/mman.h> exists.
415  */
416 #ifdef HAVE_SYS_MMAN_H
417 # include <sys/mman.h>
418 #endif /* HAVE_SYS_MMAN_H */
419 
420 /*
421  * Actions to take if <netdb.h> exists.
422  */
423 #ifdef HAVE_NETDB_H
424 # include <netdb.h>
425 #endif /* HAVE_NETDB_H */
426 
427 /*
428  * Actions to take if <netdir.h> exists.
429  */
430 #ifdef HAVE_NETDIR_H
431 # include <netdir.h>
432 #endif /* HAVE_NETDIR_H */
433 
434 /*
435  * Actions to take if <net/if_var.h> exists.
436  */
437 #ifdef HAVE_NET_IF_VAR_H
438 # include <net/if_var.h>
439 #endif /* HAVE_NET_IF_VAR_H */
440 
441 /*
442  * Actions to take if <netinet/if_ether.h> exists.
443  */
444 #ifdef HAVE_NETINET_IF_ETHER_H
445 # include <netinet/if_ether.h>
446 #endif /* HAVE_NETINET_IF_ETHER_H */
447 
448 /*
449  * Actions to take if <netinet/in.h> exists.
450  */
451 #ifdef HAVE_NETINET_IN_H
452 # include <netinet/in.h>
453 #endif /* HAVE_NETINET_IN_H */
454 
455 /*
456  * Actions to take if <rpcsvc/yp_prot.h> exists.
457  */
458 #ifdef HAVE_RPCSVC_YP_PROT_H
459 # ifdef HAVE_BAD_HEADERS
460 /* avoid circular dependency in aix 4.3 with <rpcsvc/ypclnt.h> */
461 struct ypall_callback;
462 # endif /* HAVE_BAD_HEADERS */
463 # include <rpcsvc/yp_prot.h>
464 #endif /* HAVE_RPCSVC_YP_PROT_H */
465 
466 /*
467  * Actions to take if <rpcsvc/ypclnt.h> exists.
468  */
469 #ifdef HAVE_RPCSVC_YPCLNT_H
470 # include <rpcsvc/ypclnt.h>
471 #endif /* HAVE_RPCSVC_YPCLNT_H */
472 
473 /*
474  * Actions to take if <sys/ucred.h> exists.
475  */
476 #ifdef HAVE_SYS_UCRED_H
477 # include <sys/ucred.h>
478 #endif /* HAVE_SYS_UCRED_H */
479 
480 
481 /*
482  * Actions to take if <sys/mount.h> exists.
483  */
484 #ifdef HAVE_SYS_MOUNT_H
485 /*
486  * Some operating systems must define these variables to get
487  * NFS and other definitions included.
488  */
489 # ifndef NFSCLIENT
490 #  define NFSCLIENT 1
491 # endif /* not NFSCLIENT */
492 # ifndef NFS
493 #  define NFS 1
494 # endif /* not NFS */
495 # ifndef PCFS
496 #  define PCFS 1
497 # endif /* not PCFS */
498 # ifndef LOFS
499 #  define LOFS 1
500 # endif /* not LOFS */
501 # ifndef RFS
502 #  define RFS 1
503 # endif /* not RFS */
504 # ifndef MSDOSFS
505 #  define MSDOSFS 1
506 # endif /* not MSDOSFS */
507 # ifndef MFS
508 #  define MFS 1
509 # endif /* not MFS */
510 # ifndef CD9660
511 #  define CD9660 1
512 # endif /* not CD9660 */
513 # include <sys/mount.h>
514 #endif /* HAVE_SYS_MOUNT_H */
515 
516 #ifdef HAVE_SYS_VMOUNT_H
517 # include <sys/vmount.h>
518 #endif /* HAVE_SYS_VMOUNT_H */
519 
520 /*
521  * Actions to take if <linux/fs.h> exists.
522  * There is no point in including this on a glibc2 system,
523  * we're only asking for trouble
524  */
525 #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2)
526 /*
527  * There are various conflicts in definitions between RedHat Linux, newer
528  * 2.2 kernels, and <netinet/in.h> and <linux/fs.h>.
529  */
530 # ifdef HAVE_SOCKETBITS_H
531 /* conflicts with <socketbits.h> */
532 #  define _LINUX_SOCKET_H
533 #  undef BLKFLSBUF
534 #  undef BLKGETSIZE
535 #  undef BLKRAGET
536 #  undef BLKRASET
537 #  undef BLKROGET
538 #  undef BLKROSET
539 #  undef BLKRRPART
540 #  undef MS_MGC_VAL
541 #  undef MS_RMT_MASK
542 #  if defined(__GLIBC__) && __GLIBC__ >= 2
543 /* conflicts with <waitflags.h> */
544 #   undef WNOHANG
545 #   undef WUNTRACED
546 #  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
547 /* conflicts with <statfsbuf.h> */
548 #  define _SYS_STATFS_H
549 # endif /* HAVE_SOCKETBITS_H */
550 
551 # ifdef _SYS_WAIT_H
552 #  if defined(__GLIBC__) && __GLIBC__ >= 2
553 /* conflicts with <bits/waitflags.h> (RedHat/Linux 6.0 and kernels 2.2 */
554 #   undef WNOHANG
555 #   undef WUNTRACED
556 #  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
557 # endif /* _SYS_WAIT_H */
558 
559 # ifdef HAVE_LINUX_POSIX_TYPES_H
560 #  include <linux/posix_types.h>
561 # endif /* HAVE_LINUX_POSIX_TYPES_H */
562 # ifndef _LINUX_BYTEORDER_GENERIC_H
563 #  define _LINUX_BYTEORDER_GENERIC_H
564 # endif /* _LINUX_BYTEORDER_GENERIC_H */
565 /* conflicts with <sys/mount.h> in 2.[12] kernels */
566 # ifdef _SYS_MOUNT_H
567 #  undef BLKFLSBUF
568 #  undef BLKGETSIZE
569 #  undef BLKRAGET
570 #  undef BLKRASET
571 #  undef BLKROGET
572 #  undef BLKROSET
573 #  undef BLKRRPART
574 #  undef BLOCK_SIZE
575 #  undef MS_MANDLOCK
576 #  undef MS_MGC_VAL
577 #  undef MS_NOATIME
578 #  undef MS_NODEV
579 #  undef MS_NODIRATIME
580 #  undef MS_NOEXEC
581 #  undef MS_NOSUID
582 #  undef MS_RDONLY
583 #  undef MS_REMOUNT
584 #  undef MS_RMT_MASK
585 #  undef MS_SYNCHRONOUS
586 #  undef S_APPEND
587 #  undef S_IMMUTABLE
588 /* conflicts with <statfsbuf.h> */
589 #  define _SYS_STATFS_H
590 # endif /* _SYS_MOUNT_H */
591 # ifndef _LINUX_STRING_H_
592 #  define _LINUX_STRING_H_
593 # endif /* not _LINUX_STRING_H_ */
594 # ifdef HAVE_LINUX_KDEV_T_H
595 #  define __KERNEL__
596 #  include <linux/kdev_t.h>
597 #  undef __KERNEL__
598 # endif /* HAVE_LINUX_KDEV_T_H */
599 # ifdef HAVE_LINUX_LIST_H
600 #  define __KERNEL__
601 #  include <linux/list.h>
602 #  undef __KERNEL__
603 # endif /* HAVE_LINUX_LIST_H */
604 # include <linux/fs.h>
605 #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */
606 
607 #ifdef HAVE_CDFS_CDFS_MOUNT_H
608 # include <cdfs/cdfs_mount.h>
609 #endif /* HAVE_CDFS_CDFS_MOUNT_H */
610 
611 #ifdef HAVE_CDFS_CDFSMOUNT_H
612 # include <cdfs/cdfsmount.h>
613 #endif /* HAVE_CDFS_CDFSMOUNT_H */
614 
615 /*
616  * Actions to take if <linux/loop.h> exists.
617  */
618 #ifdef HAVE_LINUX_LOOP_H
619 # ifdef HAVE_LINUX_POSIX_TYPES_H
620 #  include <linux/posix_types.h>
621 # endif /* HAVE_LINUX_POSIX_TYPES_H */
622 /* next dev_t lines needed due to changes in kernel code */
623 # undef dev_t
624 # define dev_t unsigned short	/* compatible with Red Hat and SuSE */
625 # include <linux/loop.h>
626 #endif /* HAVE_LINUX_LOOP_H */
627 
628 /*
629  * AUTOFS PROTOCOL HEADER FILES:
630  */
631 
632 /*
633  * Actions to take if <linux/auto_fs[4].h> exists.
634  * We really don't want <linux/fs.h> pulled in here
635  */
636 #ifndef _LINUX_FS_H
637 #define _LINUX_FS_H
638 #endif /* _LINUX_FS_H */
639 #ifdef HAVE_LINUX_AUTO_FS4_H
640 # include <linux/auto_fs4.h>
641 #else  /* not HAVE_LINUX_AUTO_FS4_H */
642 # ifdef HAVE_LINUX_AUTO_FS_H
643 #  include <linux/auto_fs.h>
644 # endif /* HAVE_LINUX_AUTO_FS_H */
645 #endif /* not HAVE_LINUX_AUTO_FS4_H */
646 
647 /*
648  * Actions to take if <sys/fs/autofs.h> exists.
649  */
650 #ifdef HAVE_SYS_FS_AUTOFS_H
651 # include <sys/fs/autofs.h>
652 #endif /* HAVE_SYS_FS_AUTOFS_H */
653 
654 /*
655  * Actions to take if <rpcsvc/autofs_prot.h> or <sys/fs/autofs_prot.h> exist.
656  */
657 #ifdef HAVE_RPCSVC_AUTOFS_PROT_H
658 # include <rpcsvc/autofs_prot.h>
659 #else  /* not HAVE_RPCSVC_AUTOFS_PROT_H */
660 # ifdef HAVE_SYS_FS_AUTOFS_PROT_H
661 #  include <sys/fs/autofs_prot.h>
662 # endif /* HAVE_SYS_FS_AUTOFS_PROT_H */
663 #endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */
664 
665 /*
666  * Actions to take if <lber.h> exists.
667  * This header file is required before <ldap.h> can be included.
668  */
669 #ifdef HAVE_LBER_H
670 # include <lber.h>
671 #endif /* HAVE_LBER_H */
672 
673 /*
674  * Actions to take if <ldap.h> exists.
675  */
676 #ifdef HAVE_LDAP_H
677 # include <ldap.h>
678 #endif /* HAVE_LDAP_H */
679 
680 /****************************************************************************
681  ** IMPORTANT!!!							   **
682  ** We always include am-utils' amu_autofs_prot.h.			   **
683  ** That is actually defined in "conf/autofs/autofs_${autofs_style}.h"     **
684  ****************************************************************************/
685 #include <amu_autofs_prot.h>
686 
687 
688 /*
689  * NFS PROTOCOL HEADER FILES:
690  */
691 
692 /*
693  * Actions to take if <nfs/export.h> exists.
694  */
695 #ifdef HAVE_NFS_EXPORT_H
696 # include <nfs/export.h>
697 #endif /* HAVE_NFS_EXPORT_H */
698 
699 /****************************************************************************
700  ** IMPORTANT!!!							   **
701  ** We always include am-utils' amu_nfs_prot.h.				   **
702  ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" **
703  ****************************************************************************/
704 #include <amu_nfs_prot.h>
705 
706 /*
707  * DO NOT INCLUDE THESE FILES:
708  * They conflicts with other NFS headers and are generally not needed.
709  */
710 #ifdef DO_NOT_INCLUDE
711 # ifdef HAVE_NFS_NFS_CLNT_H
712 #  include <nfs/nfs_clnt.h>
713 # endif /* HAVE_NFS_NFS_CLNT_H */
714 # ifdef HAVE_LINUX_NFS_H
715 #  include <linux/nfs.h>
716 # endif /* HAVE_LINUX_NFS_H */
717 #endif /* DO NOT INCLUDE */
718 
719 /*
720  * Actions to take if one of the nfs headers exists.
721  */
722 #ifdef HAVE_NFS_NFS_GFS_H
723 # include <nfs/nfs_gfs.h>
724 #endif /* HAVE_NFS_NFS_GFS_H */
725 #ifdef HAVE_NFS_MOUNT_H
726 # include <nfs/mount.h>
727 #endif /* HAVE_NFS_MOUNT_H */
728 #ifdef HAVE_NFS_NFS_MOUNT_H_off
729 /* broken on nextstep3 (includes non-existing headers) */
730 # include <nfs/nfs_mount.h>
731 #endif /* HAVE_NFS_NFS_MOUNT_H */
732 #ifdef HAVE_NFS_PATHCONF_H
733 # include <nfs/pathconf.h>
734 #endif /* HAVE_NFS_PATHCONF_H */
735 #ifdef HAVE_SYS_FS_NFS_MOUNT_H
736 # include <sys/fs/nfs/mount.h>
737 #endif /* HAVE_SYS_FS_NFS_MOUNT_H */
738 #ifdef HAVE_SYS_FS_NFS_NFS_CLNT_H
739 # include <sys/fs/nfs/nfs_clnt.h>
740 #endif /* HAVE_SYS_FS_NFS_NFS_CLNT_H */
741 #ifdef HAVE_SYS_FS_NFS_CLNT_H
742 # include <sys/fs/nfs_clnt.h>
743 #endif /* HAVE_SYS_FS_NFS_CLNT_H */
744 
745 /* complex rules for linux/nfs_mount.h: broken on so many systems */
746 #ifdef HAVE_LINUX_NFS_MOUNT_H
747 # ifndef _LINUX_NFS_H
748 #  define _LINUX_NFS_H
749 # endif /* not _LINUX_NFS_H */
750 # ifndef _LINUX_NFS2_H
751 #  define _LINUX_NFS2_H
752 # endif /* not _LINUX_NFS2_H */
753 # ifndef _LINUX_NFS3_H
754 #  define _LINUX_NFS3_H
755 # endif /* not _LINUX_NFS3_H */
756 # ifndef _LINUX_NFS_FS_H
757 #  define _LINUX_NFS_FS_H
758 # endif /* not _LINUX_NFS_FS_H */
759 # ifndef _LINUX_IN_H
760 #  define _LINUX_IN_H
761 # endif /* not _LINUX_IN_H */
762 # ifndef __KERNEL__
763 #  define __KERNEL__
764 # endif /* __KERNEL__ */
765 # include <linux/nfs_mount.h>
766 # undef __KERNEL__
767 #endif /* HAVE_LINUX_NFS_MOUNT_H */
768 
769 /*
770  * Actions to take if <pwd.h> exists.
771  */
772 #ifdef HAVE_PWD_H
773 # include <pwd.h>
774 #endif /* HAVE_PWD_H */
775 
776 /*
777  * Actions to take if <hesiod.h> exists.
778  */
779 #ifdef HAVE_HESIOD_H
780 # include <hesiod.h>
781 #endif /* HAVE_HESIOD_H */
782 
783 /*
784  * Actions to take if <arpa/nameser.h> exists.
785  * Should be included before <resolv.h>.
786  */
787 #ifdef HAVE_ARPA_NAMESER_H
788 # ifdef NOERROR
789 #  undef NOERROR
790 # endif /* NOERROR */
791 /*
792  * Conflicts with <sys/tpicommon.h> which is included from <sys/tiuser.h>
793  * on Solaris 2.6 systems.  So undefine it first.
794  */
795 # ifdef T_UNSPEC
796 #  undef T_UNSPEC
797 # endif /* T_UNSPEC */
798 # include <arpa/nameser.h>
799 #endif /* HAVE_ARPA_NAMESER_H */
800 
801 /*
802  * Actions to take if <arpa/inet.h> exists.
803  */
804 #ifdef HAVE_ARPA_INET_H
805 # ifdef HAVE_BAD_HEADERS
806 /* aix 4.3: avoid including <net/if_dl.h> */
807 struct sockaddr_dl;
808 # endif /* HAVE_BAD_HEADERS */
809 # include <arpa/inet.h>
810 #endif /* HAVE_ARPA_INET_H */
811 
812 /*
813  * Actions to take if <resolv.h> exists.
814  */
815 #ifdef HAVE_RESOLV_H
816 /*
817  * On AIX 5.2, both <resolv.h> and <arpa/nameser_compat.h> define MAXDNAME,
818  * if compiling with gcc -D_USE_IRS (so that we get extern definitions for
819  * hstrerror() and others).
820  */
821 # if defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS)
822 #  undef MAXDNAME
823 # endif /* defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) */
824 # include <resolv.h>
825 #endif /* HAVE_RESOLV_H */
826 
827 /*
828  * Actions to take if <sys/uio.h> exists.
829  */
830 #ifdef HAVE_SYS_UIO_H
831 # include <sys/uio.h>
832 #endif /* HAVE_SYS_UIO_H */
833 
834 /*
835  * Actions to take if <sys/fs/cachefs_fs.h> exists.
836  */
837 #ifdef HAVE_SYS_FS_CACHEFS_FS_H
838 # include <sys/fs/cachefs_fs.h>
839 #endif /* HAVE_SYS_FS_CACHEFS_FS_H */
840 
841 /*
842  * Actions to take if <sys/fs/pc_fs.h> exists.
843  */
844 #ifdef HAVE_SYS_FS_PC_FS_H
845 # include <sys/fs/pc_fs.h>
846 #endif /* HAVE_SYS_FS_PC_FS_H */
847 
848 /*
849  * Actions to take if <msdosfs/msdosfsmount.h> exists.
850  */
851 #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
852 # include <msdosfs/msdosfsmount.h>
853 #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
854 
855 /*
856  * Actions to take if <fs/msdosfs/msdosfsmount.h> exists.
857  */
858 #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
859 # include <fs/msdosfs/msdosfsmount.h>
860 #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
861 
862 /*
863  * Actions to take if <sys/fs/tmp.h> exists.
864  */
865 #ifdef HAVE_SYS_FS_TMP_H
866 # include <sys/fs/tmp.h>
867 #endif /* HAVE_SYS_FS_TMP_H */
868 #ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H
869 # include <fs/tmpfs/tmpfs_args.h>
870 #endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */
871 
872 
873 /*
874  * Actions to take if <sys/fs/ufs_mount.h> exists.
875  */
876 #ifdef HAVE_SYS_FS_UFS_MOUNT_H
877 # include <sys/fs/ufs_mount.h>
878 #endif /* HAVE_SYS_FS_UFS_MOUNT_H */
879 #ifdef	HAVE_UFS_UFS_UFSMOUNT_H_off
880 # error do not include this file here because on netbsd/openbsd it
881 # error causes errors with other header files.  Instead, add it to the
882 # error specific conf/nfs_prot_*.h file.
883 # include <ufs/ufs/ufsmount.h>
884 #endif	/* HAVE_UFS_UFS_UFSMOUNT_H_off */
885 
886 /*
887  * Actions to take if <sys/fs/efs_clnt.h> exists.
888  */
889 #ifdef HAVE_SYS_FS_EFS_CLNT_H
890 # include <sys/fs/efs_clnt.h>
891 #endif /* HAVE_SYS_FS_EFS_CLNT_H */
892 #ifdef HAVE_FS_EFS_EFS_MOUNT_H
893 # include <fs/efs/efs_mount.h>
894 #endif /* HAVE_FS_EFS_EFS_MOUNT_H */
895 
896 /*
897  * Actions to take if <sys/fs/xfs_clnt.h> exists.
898  */
899 #ifdef HAVE_SYS_FS_XFS_CLNT_H
900 # include <sys/fs/xfs_clnt.h>
901 #endif /* HAVE_SYS_FS_XFS_CLNT_H */
902 
903 /*
904  * Actions to take if <assert.h> exists.
905  */
906 #ifdef HAVE_ASSERT_H
907 # include <assert.h>
908 #endif /* HAVE_ASSERT_H */
909 
910 /*
911  * Actions to take if <cfs.h> exists.
912  */
913 #ifdef HAVE_CFS_H
914 # include <cfs.h>
915 #endif /* HAVE_CFS_H */
916 
917 /*
918  * Actions to take if <cluster.h> exists.
919  */
920 #ifdef HAVE_CLUSTER_H
921 # include <cluster.h>
922 #endif /* HAVE_CLUSTER_H */
923 
924 /*
925  * Actions to take if <ctype.h> exists.
926  */
927 #ifdef HAVE_CTYPE_H
928 # include <ctype.h>
929 #endif /* HAVE_CTYPE_H */
930 
931 /*
932  * Actions to take if <errno.h> exists.
933  */
934 #ifdef HAVE_ERRNO_H
935 # include <errno.h>
936 #endif /* HAVE_ERRNO_H */
937 
938 /*
939  * Actions to take if <grp.h> exists.
940  */
941 #ifdef HAVE_GRP_H
942 # include <grp.h>
943 #endif /* HAVE_GRP_H */
944 
945 /*
946  * Actions to take if <hsfs/hsfs.h> exists.
947  */
948 #ifdef HAVE_HSFS_HSFS_H
949 # include <hsfs/hsfs.h>
950 #endif /* HAVE_HSFS_HSFS_H */
951 
952 /*
953  * Actions to take if <cdfs/cdfsmount.h> exists.
954  */
955 #ifdef HAVE_CDFS_CDFSMOUNT_H
956 # include <cdfs/cdfsmount.h>
957 #endif /* HAVE_CDFS_CDFSMOUNT_H */
958 
959 /*
960  * Actions to take if <isofs/cd9660/cd9660_mount.h> exists.
961  */
962 #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H
963 # include <isofs/cd9660/cd9660_mount.h>
964 #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */
965 
966 /*
967  * Actions to take if <fs/udf/udf_mount.h> exists.
968  */
969 #ifdef HAVE_FS_UDF_UDF_MOUNT_H
970 # include <fs/udf/udf_mount.h>
971 #endif /* HAVE_FS_UDF_UDF_MOUNT_H */
972 
973 /*
974  * Actions to take if <mount.h> exists.
975  */
976 #ifdef HAVE_MOUNT_H
977 # include <mount.h>
978 #endif /* HAVE_MOUNT_H */
979 
980 /*
981  * Actions to take if <nsswitch.h> exists.
982  */
983 #ifdef HAVE_NSSWITCH_H
984 # include <nsswitch.h>
985 #endif /* HAVE_NSSWITCH_H */
986 
987 /*
988  * Actions to take if <rpc/auth_des.h> exists.
989  */
990 #ifdef HAVE_RPC_AUTH_DES_H
991 # include <rpc/auth_des.h>
992 #endif /* HAVE_RPC_AUTH_DES_H */
993 
994 /*
995  * Actions to take if <rpc/pmap_clnt.h> exists.
996  */
997 #ifdef HAVE_RPC_PMAP_CLNT_H
998 # include <rpc/pmap_clnt.h>
999 #endif /* HAVE_RPC_PMAP_CLNT_H */
1000 
1001 /*
1002  * Actions to take if <rpc/pmap_prot.h> exists.
1003  */
1004 #ifdef HAVE_RPC_PMAP_PROT_H
1005 # include <rpc/pmap_prot.h>
1006 #endif /* HAVE_RPC_PMAP_PROT_H */
1007 
1008 
1009 /*
1010  * Actions to take if <rpcsvc/mount.h> exists.
1011  * AIX does not protect against this file doubly included,
1012  * so I have to do my own protection here.
1013  */
1014 #ifdef HAVE_RPCSVC_MOUNT_H
1015 # ifndef _RPCSVC_MOUNT_H
1016 #  include <rpcsvc/mount.h>
1017 # endif /* not _RPCSVC_MOUNT_H */
1018 #endif /* HAVE_RPCSVC_MOUNT_H */
1019 
1020 /*
1021  * Actions to take if <rpcsvc/nis.h> exists.
1022  */
1023 #ifdef HAVE_RPCSVC_NIS_H
1024 /*
1025  * Solaris 10 (build 72) defines GROUP_OBJ in <sys/acl.h>, which is included
1026  * in many other header files.  <rpcsvc/nis.h> uses GROUP_OBJ inside enum
1027  * zotypes.  So if you're unlucky enough to include both headers, you get a
1028  * compile error because the two symbols conflict.
1029  * A similar conflict arises with Sun cc and the definition of "GROUP".
1030  *
1031  * Temp hack: undefine acl.h's GROUP_OBJ and GROUP because they're not needed
1032  * for am-utils.
1033  */
1034 # ifdef GROUP_OBJ
1035 #  undef GROUP_OBJ
1036 # endif /* GROUP_OBJ */
1037 # ifdef GROUP
1038 #  undef GROUP
1039 # endif /* GROUP */
1040 # include <rpcsvc/nis.h>
1041 #endif /* HAVE_RPCSVC_NIS_H */
1042 
1043 /*
1044  * Actions to take if <setjmp.h> exists.
1045  */
1046 #ifdef HAVE_SETJMP_H
1047 # include <setjmp.h>
1048 #endif /* HAVE_SETJMP_H */
1049 
1050 /*
1051  * Actions to take if <signal.h> exists.
1052  */
1053 #ifdef HAVE_SIGNAL_H
1054 # include <signal.h>
1055 #endif /* HAVE_SIGNAL_H */
1056 
1057 /*
1058  * Actions to take if <string.h> exists.
1059  */
1060 #ifdef HAVE_STRING_H
1061 # include <string.h>
1062 #endif /* HAVE_STRING_H */
1063 
1064 /*
1065  * Actions to take if <strings.h> exists.
1066  */
1067 #ifdef HAVE_STRINGS_H
1068 # include <strings.h>
1069 #endif /* HAVE_STRINGS_H */
1070 
1071 /*
1072  * Actions to take if <sys/config.h> exists.
1073  */
1074 #ifdef HAVE_SYS_CONFIG_H
1075 # include <sys/config.h>
1076 #endif /* HAVE_SYS_CONFIG_H */
1077 
1078 /*
1079  * Actions to take if <sys/dg_mount.h> exists.
1080  */
1081 #ifdef HAVE_SYS_DG_MOUNT_H
1082 # include <sys/dg_mount.h>
1083 #endif /* HAVE_SYS_DG_MOUNT_H */
1084 
1085 /*
1086  * Actions to take if <sys/fs_types.h> exists.
1087  */
1088 #ifdef HAVE_SYS_FS_TYPES_H
1089 /*
1090  * Define KERNEL here to avoid multiple definitions of gt_names[] on
1091  * Ultrix 4.3.
1092  */
1093 # define KERNEL
1094 # include <sys/fs_types.h>
1095 # undef KERNEL
1096 #endif /* HAVE_SYS_FS_TYPES_H */
1097 
1098 /*
1099  * Actions to take if <sys/fstyp.h> exists.
1100  */
1101 #ifdef HAVE_SYS_FSTYP_H
1102 # include <sys/fstyp.h>
1103 #endif /* HAVE_SYS_FSTYP_H */
1104 
1105 /*
1106  * Actions to take if <sys/lock.h> exists.
1107  */
1108 #ifdef HAVE_SYS_LOCK_H
1109 # include <sys/lock.h>
1110 #endif /* HAVE_SYS_LOCK_H */
1111 
1112 /*
1113  * Actions to take if <sys/machine.h> exists.
1114  */
1115 #ifdef HAVE_SYS_MACHINE_H
1116 # include <sys/machine.h>
1117 #endif /* HAVE_SYS_MACHINE_H */
1118 
1119 /*
1120  * Actions to take if <sys/mntctl.h> exists.
1121  */
1122 #ifdef HAVE_SYS_MNTCTL_H
1123 # include <sys/mntctl.h>
1124 #endif /* HAVE_SYS_MNTCTL_H */
1125 
1126 /*
1127  * Actions to take if <sys/mnttab.h> exists.
1128  */
1129 #ifdef HAVE_SYS_MNTTAB_H
1130 # include <sys/mnttab.h>
1131 #endif /* HAVE_SYS_MNTTAB_H */
1132 
1133 /*
1134  * Actions to take if <mnttab.h> exists.
1135  * Do not include it if MNTTAB is already defined because it probably
1136  * came from <sys/mnttab.h> and we do not want conflicting definitions.
1137  */
1138 #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB)
1139 # include <mnttab.h>
1140 #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */
1141 
1142 /*
1143  * Actions to take if <netconfig.h> exists.
1144  */
1145 #ifdef HAVE_NETCONFIG_H
1146 # include <netconfig.h>
1147 /* Some systems (Solaris 2.5.1) don't declare this external */
1148 extern char *nc_sperror(void);
1149 #endif /* HAVE_NETCONFIG_H */
1150 
1151 /*
1152  * Actions to take if <sys/netconfig.h> exists.
1153  */
1154 #ifdef HAVE_SYS_NETCONFIG_H
1155 # include <sys/netconfig.h>
1156 #endif /* HAVE_SYS_NETCONFIG_H */
1157 
1158 /*
1159  * Actions to take if <sys/pathconf.h> exists.
1160  */
1161 #ifdef HAVE_SYS_PATHCONF_H
1162 # include <sys/pathconf.h>
1163 #endif /* HAVE_SYS_PATHCONF_H */
1164 
1165 /*
1166  * Actions to take if <sys/resource.h> exists.
1167  */
1168 #ifdef HAVE_SYS_RESOURCE_H
1169 # include <sys/resource.h>
1170 #endif /* HAVE_SYS_RESOURCE_H */
1171 
1172 /*
1173  * Actions to take if <sys/sema.h> exists.
1174  */
1175 #ifdef HAVE_SYS_SEMA_H
1176 # include <sys/sema.h>
1177 #endif /* HAVE_SYS_SEMA_H */
1178 
1179 /*
1180  * Actions to take if <sys/signal.h> exists.
1181  */
1182 #ifdef HAVE_SYS_SIGNAL_H
1183 # include <sys/signal.h>
1184 #endif /* HAVE_SYS_SIGNAL_H */
1185 
1186 /*
1187  * Actions to take if <sys/sockio.h> exists.
1188  */
1189 #ifdef HAVE_SYS_SOCKIO_H
1190 # include <sys/sockio.h>
1191 #endif /* HAVE_SYS_SOCKIO_H */
1192 
1193 /*
1194  * Actions to take if <sys/syscall.h> exists.
1195  */
1196 #ifdef HAVE_SYS_SYSCALL_H
1197 # include <sys/syscall.h>
1198 #endif /* HAVE_SYS_SYSCALL_H */
1199 
1200 /*
1201  * Actions to take if <sys/syslimits.h> exists.
1202  */
1203 #ifdef HAVE_SYS_SYSLIMITS_H
1204 # include <sys/syslimits.h>
1205 #endif /* HAVE_SYS_SYSLIMITS_H */
1206 
1207 /*
1208  * Actions to take if <tiuser.h> exists.
1209  */
1210 #ifdef HAVE_TIUSER_H
1211 /*
1212  * Some systems like AIX have multiple definitions for T_NULL and others
1213  * that are defined first in <arpa/nameser.h>.
1214  */
1215 # ifdef HAVE_ARPA_NAMESER_H
1216 #  ifdef T_NULL
1217 #   undef T_NULL
1218 #  endif /* T_NULL */
1219 #  ifdef T_UNSPEC
1220 #   undef T_UNSPEC
1221 #  endif /* T_UNSPEC */
1222 #  ifdef T_IDLE
1223 #   undef T_IDLE
1224 #  endif /* T_IDLE */
1225 # endif /* HAVE_ARPA_NAMESER_H */
1226 # include <tiuser.h>
1227 #endif /* HAVE_TIUSER_H */
1228 
1229 /*
1230  * Actions to take if <sys/tiuser.h> exists.
1231  */
1232 #ifdef HAVE_SYS_TIUSER_H
1233 # include <sys/tiuser.h>
1234 #endif /* HAVE_SYS_TIUSER_H */
1235 
1236 /*
1237  * Actions to take if <sys/statfs.h> exists.
1238  */
1239 #ifdef HAVE_SYS_STATFS_H
1240 # include <sys/statfs.h>
1241 #endif /* HAVE_SYS_STATFS_H */
1242 
1243 /*
1244  * Actions to take if <sys/statvfs.h> exists.
1245  */
1246 #ifdef HAVE_SYS_STATVFS_H
1247 # include <sys/statvfs.h>
1248 #endif /* HAVE_SYS_STATVFS_H */
1249 
1250 /*
1251  * Actions to take if <sys/vfs.h> exists.
1252  */
1253 #ifdef HAVE_SYS_VFS_H
1254 # include <sys/vfs.h>
1255 #endif /* HAVE_SYS_VFS_H */
1256 
1257 /*
1258  * Actions to take if <sys/vmount.h> exists.
1259  */
1260 #ifdef HAVE_SYS_VMOUNT_H
1261 # include <sys/vmount.h>
1262 #endif /* HAVE_SYS_VMOUNT_H */
1263 
1264 /*
1265  * Actions to take if <ufs/ufs_mount.h> exists.
1266  */
1267 #ifdef HAVE_UFS_UFS_MOUNT_H
1268 # include <ufs/ufs_mount.h>
1269 #endif /* HAVE_UFS_UFS_MOUNT_H */
1270 
1271 /*
1272  * Are S_ISDIR, S_ISREG, et al broken?  If not, include <sys/stat.h>.
1273  * Turned off the not using sys/stat.h based on if the macros are
1274  * "broken", because they incorrectly get reported as broken on
1275  * ncr2.
1276  */
1277 #ifndef STAT_MACROS_BROKEN_notused
1278 /*
1279  * RedHat Linux 4.2 (alpha) has a problem in the headers that causes
1280  * duplicate definitions, and also some other nasty bugs.  Upgrade to Redhat
1281  * 5.0!
1282  */
1283 # ifdef HAVE_SYS_STAT_H
1284 /* avoid duplicates or conflicts with <linux/stat.h> (RedHat alpha linux) */
1285 #  if defined(S_IFREG) && defined(HAVE_STATBUF_H)
1286 #   include <statbuf.h>
1287 #   undef S_IFBLK
1288 #   undef S_IFCHR
1289 #   undef S_IFDIR
1290 #   undef S_IFIFO
1291 #   undef S_IFLNK
1292 #   undef S_IFMT
1293 #   undef S_IFREG
1294 #   undef S_IFSOCK
1295 #   undef S_IRGRP
1296 #   undef S_IROTH
1297 #   undef S_IRUSR
1298 #   undef S_IRWXG
1299 #   undef S_IRWXO
1300 #   undef S_IRWXU
1301 #   undef S_ISBLK
1302 #   undef S_ISCHR
1303 #   undef S_ISDIR
1304 #   undef S_ISFIFO
1305 #   undef S_ISGID
1306 #   undef S_ISLNK
1307 #   undef S_ISREG
1308 #   undef S_ISSOCK
1309 #   undef S_ISUID
1310 #   undef S_ISVTX
1311 #   undef S_IWGRP
1312 #   undef S_IWOTH
1313 #   undef S_IWUSR
1314 #   undef S_IXGRP
1315 #   undef S_IXOTH
1316 #   undef S_IXUSR
1317 #  endif /* defined(S_IFREG) && defined(HAVE_STATBUF_H) */
1318 #  include <sys/stat.h>
1319 # endif /* HAVE_SYS_STAT_H */
1320 #endif /* not STAT_MACROS_BROKEN_notused */
1321 
1322 /*
1323  * Actions to take if <stdio.h> exists.
1324  */
1325 #ifdef HAVE_STDIO_H
1326 # include <stdio.h>
1327 #endif /* HAVE_STDIO_H */
1328 
1329 /*
1330  * Actions to take if <stdlib.h> exists.
1331  */
1332 #ifdef HAVE_STDLIB_H
1333 # include <stdlib.h>
1334 #endif /* HAVE_STDLIB_H */
1335 
1336 /*
1337  * Actions to take if <regex.h> exists.
1338  */
1339 #ifdef HAVE_REGEX_H
1340 # include <regex.h>
1341 #endif /* HAVE_REGEX_H */
1342 
1343 /*
1344  * Actions to take if <tcpd.h> exists.
1345  */
1346 #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP)
1347 # include <tcpd.h>
1348 #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */
1349 
1350 
1351 /****************************************************************************/
1352 /*
1353  * Specific macros we're looking for.
1354  */
1355 #ifndef HAVE_MEMSET
1356 # ifdef HAVE_BZERO
1357 #  define	memset(ptr, val, len)	bzero((ptr), (len))
1358 # else /* not HAVE_BZERO */
1359 #  error Cannot find either memset or bzero!
1360 # endif /* not HAVE_BZERO */
1361 #endif /* not HAVE_MEMSET */
1362 
1363 #ifndef HAVE_MEMMOVE
1364 # ifdef HAVE_BCOPY
1365 #  define	memmove(to, from, len)	bcopy((from), (to), (len))
1366 # else /* not HAVE_BCOPY */
1367 #  error Cannot find either memmove or bcopy!
1368 # endif /* not HAVE_BCOPY */
1369 #endif /* not HAVE_MEMMOVE */
1370 
1371 /*
1372  * memcmp() is more problematic:
1373  * Systems that don't have it, but have bcmp(), will use bcmp() instead.
1374  * Those that have it, but it is bad (SunOS 4 doesn't handle
1375  * 8 bit comparisons correctly), will get to use am_memcmp().
1376  * Otherwise if you have memcmp() and it is good, use it.
1377  */
1378 #ifdef HAVE_MEMCMP
1379 # ifdef HAVE_BAD_MEMCMP
1380 #  define	memcmp		am_memcmp
1381 extern int am_memcmp(const voidp s1, const voidp s2, size_t len);
1382 # endif /* HAVE_BAD_MEMCMP */
1383 #else /* not HAVE_MEMCMP */
1384 # ifdef HAVE_BCMP
1385 #  define	memcmp(a, b, len)	bcmp((a), (b), (len))
1386 # endif /* HAVE_BCMP */
1387 #endif /* not HAVE_MEMCMP */
1388 
1389 #ifndef HAVE_SETEUID
1390 # ifdef HAVE_SETRESUID
1391 #  define	seteuid(x)		setresuid(-1,(x),-1)
1392 # else /* not HAVE_SETRESUID */
1393 #  error Cannot find either seteuid or setresuid!
1394 # endif /* not HAVE_SETRESUID */
1395 #endif /* not HAVE_SETEUID */
1396 
1397 /*
1398  * Define type of mntent_t.
1399  * Defaults to struct mntent, else struct mnttab.  If neither is found, and
1400  * the operating system does keep not mount tables in the kernel, then flag
1401  * it as an error.  If neither is found and the OS keeps mount tables in the
1402  * kernel, then define our own version of mntent; it will be needed for amd
1403  * to keep its own internal version of the mount tables.
1404  */
1405 #ifdef HAVE_STRUCT_MNTENT
1406 typedef struct mntent mntent_t;
1407 #else /* not HAVE_STRUCT_MNTENT */
1408 # ifdef HAVE_STRUCT_MNTTAB
1409 typedef struct mnttab mntent_t;
1410 /* map struct mnttab field names to struct mntent field names */
1411 #  define mnt_fsname	mnt_special
1412 #  define mnt_dir	mnt_mountp
1413 #  define mnt_opts	mnt_mntopts
1414 #  define mnt_type	mnt_fstype
1415 # else /* not HAVE_STRUCT_MNTTAB */
1416 #  ifdef MOUNT_TABLE_ON_FILE
1417 #   error Could not find definition for struct mntent or struct mnttab!
1418 #  else /* not MOUNT_TABLE_ON_FILE */
1419 typedef struct _am_mntent {
1420   char	*mnt_fsname;		/* name of mounted file system */
1421   char	*mnt_dir;		/* file system path prefix */
1422   char	*mnt_type;		/* MNTTAB_TYPE_* */
1423   char	*mnt_opts;		/* MNTTAB_OPT_* */
1424   int	mnt_freq;		/* dump frequency, in days */
1425   int	mnt_passno;		/* pass number on parallel fsck */
1426 } mntent_t;
1427 #  endif /* not MOUNT_TABLE_ON_FILE */
1428 # endif /* not HAVE_STRUCT_MNTTAB */
1429 #endif /* not HAVE_STRUCT_MNTENT */
1430 
1431 /*
1432  * Provide FD_* macros for systems that lack them.
1433  */
1434 #ifndef FD_SET
1435 # define FD_SET(fd, set) (*(set) |= (1 << (fd)))
1436 # define FD_ISSET(fd, set) (*(set) & (1 << (fd)))
1437 # define FD_CLR(fd, set) (*(set) &= ~(1 << (fd)))
1438 # define FD_ZERO(set) (*(set) = 0)
1439 #endif /* not FD_SET */
1440 
1441 
1442 /*
1443  * Complete external definitions missing from some systems.
1444  */
1445 
1446 #ifndef HAVE_EXTERN_SYS_ERRLIST
1447 extern const char *const sys_errlist[];
1448 #endif /* not HAVE_EXTERN_SYS_ERRLIST */
1449 
1450 #ifndef HAVE_EXTERN_OPTARG
1451 extern char *optarg;
1452 extern int optind;
1453 #endif /* not HAVE_EXTERN_OPTARG */
1454 
1455 #if defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR)
1456 extern char *clnt_spcreateerror(const char *s);
1457 #endif /* defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) */
1458 
1459 #if defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO)
1460 extern char *clnt_sperrno(const enum clnt_stat num);
1461 #endif /* defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) */
1462 
1463 #ifndef HAVE_EXTERN_FREE
1464 extern void free(voidp);
1465 #endif /* not HAVE_EXTERN_FREE */
1466 
1467 #if defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS)
1468 extern void get_myaddress(struct sockaddr_in *addr);
1469 #endif /* defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) */
1470 
1471 #if defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME)
1472 # if defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS)
1473 extern int getdomainname(char *name, int namelen);
1474 # endif /* defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) */
1475 #endif /* defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) */
1476 
1477 #if defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE)
1478 extern int getdtablesize(void);
1479 #endif /* defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) */
1480 
1481 #if defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME)
1482 extern int gethostname(char *name, int namelen);
1483 #endif /* defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) */
1484 
1485 #ifndef HAVE_EXTERN_GETLOGIN
1486 extern char *getlogin(void);
1487 #endif /* not HAVE_EXTERN_GETLOGIN */
1488 
1489 #if defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE)
1490 extern int getpagesize(void);
1491 #endif /* defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) */
1492 
1493 #ifndef HAVE_EXTERN_GETWD
1494 extern char *getwd(char *s);
1495 #endif /* not HAVE_EXTERN_GETWD */
1496 
1497 #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL)
1498 extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, char *client_user);
1499 #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) */
1500 
1501 #ifndef HAVE_EXTERN_INNETGR
1502 extern int innetgr(char *, char *, char *, char *);
1503 #endif /* not HAVE_EXTERN_INNETGR */
1504 
1505 #if defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP)
1506 extern int mkstemp(char *);
1507 #endif /* defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) */
1508 
1509 #ifndef HAVE_EXTERN_SBRK
1510 extern caddr_t sbrk(int incr);
1511 #endif /* not HAVE_EXTERN_SBRK */
1512 
1513 #if defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID)
1514 extern int seteuid(uid_t euid);
1515 #endif /* not defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) */
1516 
1517 #if defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER)
1518 extern int setitimer(int, struct itimerval *, struct itimerval *);
1519 #endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */
1520 
1521 #ifndef HAVE_EXTERN_SLEEP
1522 extern unsigned int sleep(unsigned int seconds);
1523 #endif /* not HAVE_EXTERN_SETITIMER */
1524 
1525 #ifndef HAVE_EXTERN_STRCASECMP
1526 /*
1527  * define this extern even if function does not exist, for it will
1528  * be filled in by libamu/strcasecmp.c
1529  */
1530 extern int strcasecmp(const char *s1, const char *s2);
1531 #endif /* not HAVE_EXTERN_STRCASECMP */
1532 
1533 #ifndef HAVE_EXTERN_STRDUP
1534 /*
1535  * define this extern even if function does not exist, for it will
1536  * be filled in by libamu/strdup.c
1537  */
1538 extern char *strdup(const char *s);
1539 #endif /* not HAVE_EXTERN_STRDUP */
1540 
1541 #ifndef HAVE_EXTERN_STRLCAT
1542 /*
1543  * define this extern even if function does not exist, for it will
1544  * be filled in by libamu/strlcat.c
1545  */
1546 extern size_t strlcat(char *dst, const char *src, size_t siz);
1547 #endif /* not HAVE_EXTERN_STRLCAT */
1548 
1549 #ifndef HAVE_EXTERN_STRLCPY
1550 /*
1551  * define this extern even if function does not exist, for it will
1552  * be filled in by libamu/strlcpy.c
1553  */
1554 extern size_t strlcpy(char *dst, const char *src, size_t siz);
1555 #endif /* not HAVE_EXTERN_STRLCPY */
1556 
1557 #if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR)
1558 extern char *strstr(const char *s1, const char *s2);
1559 #endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */
1560 
1561 #if defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP)
1562 extern int usleep(u_int useconds);
1563 #endif /* defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) */
1564 
1565 #ifndef HAVE_EXTERN_UALARM
1566 extern u_int ualarm(u_int usecs, u_int interval);
1567 #endif /* not HAVE_EXTERN_UALARM */
1568 
1569 #if defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3)
1570 extern int wait3(int *statusp, int options, struct rusage *rusage);
1571 #endif /* defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) */
1572 
1573 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF)
1574 extern int vsnprintf(char *, int, const char *, ...);
1575 #endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */
1576 
1577 #ifndef HAVE_EXTERN_XDR_CALLMSG
1578 extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg);
1579 #endif /* not HAVE_EXTERN_XDR_CALLMSG */
1580 
1581 #ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH
1582 extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth);
1583 #endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */
1584 
1585 /****************************************************************************/
1586 /*
1587  * amd-specific header files.
1588  */
1589 #ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE
1590 # include <amu_nfs_prot.h>
1591 #endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */
1592 #include <am_compat.h>
1593 #include <am_xdr_func.h>
1594 #include <am_utils.h>
1595 #include <amq_defs.h>
1596 #include <aux_conf.h>
1597 
1598 
1599 /****************************************************************************/
1600 /*
1601  * External definitions that depend on other macros available (or not)
1602  * and those are probably declared in any of the above headers.
1603  */
1604 
1605 #ifdef HAVE_HASMNTOPT
1606 # ifdef HAVE_BAD_HASMNTOPT
1607 extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
1608 # else /* not HAVE_BAD_HASMNTOPT */
1609 #  define amu_hasmntopt hasmntopt
1610 # endif /* not HAVE_BAD_HASMNTOPT */
1611 #else /* not HAVE_HASMNTOPT */
1612 extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
1613 #endif /* not HAVE_HASMNTOPT */
1614 
1615 #endif /* not _AM_DEFS_H */
1616