am_defs.h revision 310490
1146773Ssam/*
2146773Ssam * Copyright (c) 1997-2014 Erez Zadok
3146773Ssam * Copyright (c) 1990 Jan-Simon Pendry
4146773Ssam * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5251158Sdelphij * Copyright (c) 1990 The Regents of the University of California.
6146773Ssam * All rights reserved.
7146773Ssam *
8146773Ssam * This code is derived from software contributed to Berkeley by
9146773Ssam * Jan-Simon Pendry at Imperial College, London.
10146773Ssam *
11146773Ssam * Redistribution and use in source and binary forms, with or without
12146773Ssam * modification, are permitted provided that the following conditions
13146773Ssam * are met:
14146773Ssam * 1. Redistributions of source code must retain the above copyright
15146773Ssam *    notice, this list of conditions and the following disclaimer.
16146773Ssam * 2. Redistributions in binary form must reproduce the above copyright
17146773Ssam *    notice, this list of conditions and the following disclaimer in the
18146773Ssam *    documentation and/or other materials provided with the distribution.
19146773Ssam * 3. Neither the name of the University nor the names of its contributors
20146773Ssam *    may be used to endorse or promote products derived from this software
21146773Ssam *    without specific prior written permission.
22146773Ssam *
23146773Ssam * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24214478Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25146773Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26146773Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27146773Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28146773Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29146773Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30146773Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31146773Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32146773Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33146773Ssam * SUCH DAMAGE.
34146773Ssam *
35146773Ssam *
36146773Ssam * File: am-utils/include/am_defs.h
37146773Ssam * $Id: am_defs.h,v 1.15.2.16 2004/05/12 15:54:31 ezk Exp $
38146773Ssam * $FreeBSD: stable/10/contrib/amd/include/am_defs.h 310490 2016-12-23 22:42:14Z cy $
39146773Ssam *
40146773Ssam */
41146773Ssam
42146773Ssam/*
43146773Ssam * Definitions that are not specific to the am-utils package, but
44146773Ssam * are rather generic, and can be used elsewhere.
45146773Ssam */
46146773Ssam
47146773Ssam#ifndef _AM_DEFS_H
48146773Ssam#define _AM_DEFS_H
49146773Ssam
50146773Ssam/*
51146773Ssam * Actions to take if ANSI C.
52146773Ssam */
53146773Ssam#if STDC_HEADERS
54146773Ssam# include <string.h>
55146773Ssam/* for function prototypes */
56146773Ssam# define P(x) x
57146773Ssam# define P_void void
58146773Ssam#else /* not STDC_HEADERS */
59146773Ssam/* empty function prototypes */
60146773Ssam# define P(x) ()
61146773Ssam# define P_void
62146773Ssam# ifndef HAVE_STRCHR
63146773Ssam#  define strchr index
64146773Ssam#  define strrchr rindex
65146773Ssam# endif /* not HAVE_STRCHR */
66146773Ssamchar *strchr(), *strrchr();
67146773Ssam#endif /* not STDC_HEADERS */
68146773Ssam
69146773Ssam/*
70146773Ssam * Handle gcc __attribute__ if available.
71146773Ssam */
72146773Ssam#ifndef __attribute__
73146773Ssam/* This feature is available in gcc versions 2.5 and later.  */
74146773Ssam# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
75146773Ssam#  define __attribute__(Spec) /* empty */
76146773Ssam# endif /* __GNUC__ < 2 ... */
77146773Ssam/*
78146773Ssam * The __-protected variants of `format' and `printf' attributes
79146773Ssam * are accepted by gcc versions 2.6.4 (effectively 2.7) and later.
80190207Srpaulo */
81146773Ssam# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
82146773Ssam#  define __format__ format
83146773Ssam#  define __printf__ printf
84146773Ssam# endif /* __GNUC__ < 2 ... */
85146773Ssam#endif /* not __attribute__ */
86146773Ssam
87214478Srpaulo#define __IGNORE(result) \
88146773Ssam    __ignore((unsigned long)result)
89146773Ssam
90190207Srpaulostatic inline void
91146773Ssam__ignore(unsigned long result) {
92146773Ssam    (void)&result;
93146773Ssam}
94146773Ssam
95146773Ssam/*
96146773Ssam * How to handle signals of any type
97146773Ssam */
98146773Ssam#ifdef HAVE_SYS_WAIT_H
99146773Ssam# include <sys/wait.h>
100146773Ssam#endif /* HAVE_SYS_WAIT_H */
101146773Ssam#ifndef WEXITSTATUS
102146773Ssam# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
103146773Ssam#endif /* not WEXITSTATUS */
104146773Ssam#ifndef WIFEXITED
105146773Ssam# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
106190207Srpaulo#endif /* not WIFEXITED */
107190207Srpaulo
108146773Ssam/*
109146773Ssam * Actions to take regarding <time.h> and <sys/time.h>.
110235530Sdelphij */
111146773Ssam#if TIME_WITH_SYS_TIME
112146773Ssam# include <sys/time.h>
113251158Sdelphij# ifdef _ALL_SOURCE
114146773Ssam/*
115190207Srpaulo * AIX 5.2 needs struct sigevent from signal.h to be defined, but I
116190207Srpaulo * don't want to move the inclusion of signal.h this early into this
117190207Srpaulo * file.  Luckily, amd doesn't need the size of this structure in any
118146773Ssam * other structure that it uses.  So we sidestep it for now.
119162017Ssam */
120235530Sdelphijstruct sigevent;
121162017Ssam# endif /* _ALL_SOURCE */
122146773Ssam# include <time.h>
123146773Ssam#else /* not TIME_WITH_SYS_TIME */
124146773Ssam# if HAVE_SYS_TIME_H
125146773Ssam#  include <sys/time.h>
126146773Ssam# else /* not HAVE_SYS_TIME_H */
127146773Ssam#  include <time.h>
128214478Srpaulo# endif /* not HAVE_SYS_TIME_H */
129146773Ssam#endif /* not TIME_WITH_SYS_TIME */
130146773Ssam
131146773Ssam/*
132146773Ssam * Actions to take if <machine/endian.h> exists.
133146773Ssam */
134146773Ssam#ifdef HAVE_MACHINE_ENDIAN_H
135146773Ssam# include <machine/endian.h>
136146773Ssam#endif /* HAVE_MACHINE_ENDIAN_H */
137146773Ssam
138146773Ssam/*
139146773Ssam * Big-endian or little-endian?
140146773Ssam */
141146773Ssam#ifndef BYTE_ORDER
142146773Ssam# if defined(WORDS_BIGENDIAN)
143146773Ssam#  define ARCH_ENDIAN "big"
144146773Ssam# else /* not WORDS_BIGENDIAN */
145146773Ssam#  define ARCH_ENDIAN "little"
146146773Ssam# endif /* not WORDS_BIGENDIAN */
147146773Ssam#else
148146773Ssam# if BYTE_ORDER == BIG_ENDIAN
149146773Ssam#  define ARCH_ENDIAN "big"
150146773Ssam# else
151146773Ssam#  define ARCH_ENDIAN "little"
152146773Ssam# endif
153146773Ssam#endif
154214478Srpaulo
155214478Srpaulo/*
156214478Srpaulo * Actions to take if HAVE_SYS_TYPES_H is defined.
157214478Srpaulo */
158214478Srpaulo#if HAVE_SYS_TYPES_H
159146773Ssam# include <sys/types.h>
160214478Srpaulo#endif /* HAVE_SYS_TYPES_H */
161214478Srpaulo
162235530Sdelphij/*
163214478Srpaulo * Actions to take if HAVE_LIMITS_H is defined.
164214478Srpaulo */
165146773Ssam#if HAVE_LIMITS_H_H
166214478Srpaulo# include <limits.h>
167214478Srpaulo#endif /* HAVE_LIMITS_H */
168214478Srpaulo
169214478Srpaulo/*
170214478Srpaulo * Actions to take if HAVE_UNISTD_H is defined.
171146773Ssam */
172146773Ssam#if HAVE_UNISTD_H
173146773Ssam# include <unistd.h>
174146773Ssam#endif /* HAVE_UNISTD_H */
175146773Ssam
176146773Ssam/* after <unistd.h>, check if this is a POSIX.1 system */
177146773Ssam#ifdef _POSIX_VERSION
178146773Ssam/* Code for POSIX.1 systems. */
179146773Ssam#endif /* _POSIX_VERSION */
180251158Sdelphij
181251158Sdelphij/*
182251158Sdelphij * Variable length argument lists.
183251158Sdelphij * Must use only one of the two!
184251158Sdelphij */
185251158Sdelphij#ifdef HAVE_STDARG_H
186146773Ssam# include <stdarg.h>
187146773Ssam/*
188146773Ssam * On Solaris 2.6, <sys/varargs.h> is included in <sys/fs/autofs.h>
189146773Ssam * So this ensures that only one is included.
190146773Ssam */
191146773Ssam# ifndef _SYS_VARARGS_H
192146773Ssam#  define _SYS_VARARGS_H
193146773Ssam# endif /* not _SYS_VARARGS_H */
194146773Ssam#else /* not HAVE_STDARG_H */
195214478Srpaulo# ifdef HAVE_VARARGS_H
196214478Srpaulo#  include <varargs.h>
197214478Srpaulo# endif /* HAVE_VARARGS_H */
198214478Srpaulo#endif /* not HAVE_STDARG_H */
199214478Srpaulo
200214478Srpaulo/*
201214478Srpaulo * Pick the right header file and macros for directory processing functions.
202146773Ssam */
203214478Srpaulo#if HAVE_DIRENT_H
204146773Ssam# include <dirent.h>
205214478Srpaulo# define NAMLEN(dirent) strlen((dirent)->d_name)
206214478Srpaulo#else /* not HAVE_DIRENT_H */
207214478Srpaulo# define dirent direct
208214478Srpaulo# define NAMLEN(dirent) (dirent)->d_namlen
209146773Ssam# if HAVE_SYS_NDIR_H
210146773Ssam#  include <sys/ndir.h>
211146773Ssam# endif /* HAVE_SYS_NDIR_H */
212146773Ssam# if HAVE_SYS_DIR_H
213146773Ssam#  include <sys/dir.h>
214146773Ssam# endif /* HAVE_SYS_DIR_H */
215146773Ssam# if HAVE_NDIR_H
216146773Ssam#  include <ndir.h>
217146773Ssam# endif /* HAVE_NDIR_H */
218146773Ssam#endif /* not HAVE_DIRENT_H */
219146773Ssam
220146773Ssam/*
221146773Ssam * Actions to take if HAVE_FCNTL_H is defined.
222146773Ssam */
223146773Ssam#if HAVE_FCNTL_H
224146773Ssam# include <fcntl.h>
225146773Ssam#endif /* HAVE_FCNTL_H */
226146773Ssam
227146773Ssam/*
228146773Ssam * Actions to take if HAVE_MEMORY_H is defined.
229146773Ssam */
230146773Ssam#if HAVE_MEMORY_H
231146773Ssam# include <memory.h>
232146773Ssam#endif /* HAVE_MEMORY_H */
233146773Ssam
234146773Ssam/*
235146773Ssam * Actions to take if HAVE_SYS_FILE_H is defined.
236146773Ssam */
237146773Ssam#if HAVE_SYS_FILE_H
238146773Ssam# include <sys/file.h>
239146773Ssam#endif /* HAVE_SYS_FILE_H */
240146773Ssam
241146773Ssam/*
242146773Ssam * Actions to take if HAVE_SYS_IOCTL_H is defined.
243251158Sdelphij */
244146773Ssam#if HAVE_SYS_IOCTL_H
245146773Ssam# include <sys/ioctl.h>
246146773Ssam#endif /* HAVE_SYS_IOCTL_H */
247146773Ssam
248146773Ssam/*
249146773Ssam * Actions to take if HAVE_SYSLOG_H or HAVE_SYS_SYSLOG_H is defined.
250146773Ssam */
251146773Ssam#ifdef HAVE_SYSLOG_H
252146773Ssam# include <syslog.h>
253146773Ssam#else /* not HAVE_SYSLOG_H */
254146773Ssam# if HAVE_SYS_SYSLOG_H
255146773Ssam#  include <sys/syslog.h>
256146773Ssam# endif /* HAVE_SYS_SYSLOG_H */
257146773Ssam#endif /* HAVE_SYSLOG_H */
258146773Ssam
259146773Ssam/*
260146773Ssam * Actions to take if <sys/param.h> exists.
261172683Smlaier */
262146773Ssam#ifdef HAVE_SYS_PARAM_H
263235530Sdelphij# include <sys/param.h>
264235530Sdelphij#endif /* HAVE_SYS_PARAM_H */
265235530Sdelphij
266146773Ssam/*
267146773Ssam * Actions to take if <sys/socket.h> exists.
268146773Ssam */
269146773Ssam#ifdef HAVE_SYS_SOCKET_H
270146773Ssam# include <sys/socket.h>
271146773Ssam#endif /* HAVE_SYS_SOCKET_H */
272146773Ssam
273146773Ssam/*
274146773Ssam * Actions to take if <rpc/rpc.h> exists.
275146773Ssam */
276146773Ssam#ifdef HAVE_RPC_RPC_H
277235530Sdelphij/*
278235530Sdelphij * Turn on PORTMAP, so that additional header files would get included
279235530Sdelphij * and the important definition for UDPMSGSIZE is included too.
280146773Ssam */
281235530Sdelphij# ifndef PORTMAP
282235530Sdelphij#  define PORTMAP
283235530Sdelphij# endif /* not PORTMAP */
284190207Srpaulo# include <rpc/rpc.h>
285146773Ssam# ifndef XDRPROC_T_TYPE
286146773Ssamtypedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...));
287146773Ssam# endif /* not XDRPROC_T_TYPE */
288146773Ssam#endif /* HAVE_RPC_RPC_H */
289241235Sdelphij
290251158Sdelphij/*
291214478Srpaulo * Actions to take if <rpc/types.h> exists.
292214478Srpaulo */
293146773Ssam#ifdef HAVE_RPC_TYPES_H
294146773Ssam# include <rpc/types.h>
295146773Ssam#endif /* HAVE_RPC_TYPES_H */
296146773Ssam
297146773Ssam/*
298146773Ssam * Actions to take if <rpc/xdr.h> exists.
299146773Ssam */
300146773Ssam/* Prevent multiple inclusion on Ultrix 4 */
301190207Srpaulo#if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__)
302146773Ssam# include <rpc/xdr.h>
303235530Sdelphij#endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */
304235530Sdelphij
305235530Sdelphij/*
306235530Sdelphij * Actions to take if <malloc.h> exists.
307235530Sdelphij * Don't include malloc.h if stdlib.h exists, because modern
308251158Sdelphij * systems complain if you use malloc.h instead of stdlib.h.
309235530Sdelphij * XXX: let's hope there are no systems out there that need both.
310251158Sdelphij */
311235530Sdelphij#if defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H)
312251158Sdelphij# include <malloc.h>
313235530Sdelphij#endif /* defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H) */
314235530Sdelphij
315235530Sdelphij/*
316235530Sdelphij * Actions to take if <mntent.h> exists.
317235530Sdelphij */
318235530Sdelphij#ifdef HAVE_MNTENT_H
319146773Ssam/* some systems need <stdio.h> before <mntent.h> is included */
320146773Ssam# ifdef HAVE_STDIO_H
321162017Ssam#  include <stdio.h>
322162017Ssam# endif /* HAVE_STDIO_H */
323162017Ssam# include <mntent.h>
324162017Ssam#endif /* HAVE_MNTENT_H */
325146773Ssam
326162017Ssam/*
327162017Ssam * Actions to take if <sys/fsid.h> exists.
328162017Ssam */
329146773Ssam#ifdef HAVE_SYS_FSID_H
330146773Ssam# include <sys/fsid.h>
331146773Ssam#endif /* HAVE_SYS_FSID_H */
332146773Ssam
333146773Ssam/*
334146773Ssam * Actions to take if <sys/utsname.h> exists.
335146773Ssam */
336146773Ssam#ifdef HAVE_SYS_UTSNAME_H
337146773Ssam# include <sys/utsname.h>
338146773Ssam#endif /* HAVE_SYS_UTSNAME_H */
339146773Ssam
340146773Ssam/*
341146773Ssam * Actions to take if <sys/mntent.h> exists.
342146773Ssam */
343146773Ssam#ifdef HAVE_SYS_MNTENT_H
344146773Ssam# include <sys/mntent.h>
345146773Ssam#endif /* HAVE_SYS_MNTENT_H */
346146773Ssam
347146773Ssam/*
348146773Ssam * Actions to take if <ndbm.h> or <db1/ndbm.h> exist.
349146773Ssam * Should be included before <rpcsvc/yp_prot.h> because on some systems
350146773Ssam * like Linux, it also defines "struct datum".
351146773Ssam */
352146773Ssam#ifdef HAVE_MAP_NDBM
353146773Ssam# include NEW_DBM_H
354146773Ssam# ifndef DATUM
355146773Ssam/* ensure that struct datum is not included again from <rpcsvc/yp_prot.h> */
356146773Ssam#  define DATUM
357146773Ssam# endif /* not DATUM */
358146773Ssam#endif /* HAVE_MAP_NDBM */
359146773Ssam
360146773Ssam/*
361146773Ssam * Actions to take if <net/errno.h> exists.
362146773Ssam */
363146773Ssam#ifdef HAVE_NET_ERRNO_H
364146773Ssam# include <net/errno.h>
365146773Ssam#endif /* HAVE_NET_ERRNO_H */
366146773Ssam
367146773Ssam/*
368235530Sdelphij * Actions to take if <net/if.h> exists.
369146773Ssam */
370146773Ssam#ifdef HAVE_NET_IF_H
371146773Ssam# include <net/if.h>
372146773Ssam#endif /* HAVE_NET_IF_H */
373146773Ssam
374146773Ssam/*
375146773Ssam * Actions to take if <net/route.h> exists.
376146773Ssam */
377146773Ssam#ifdef HAVE_NET_ROUTE_H
378146773Ssam# include <net/route.h>
379146773Ssam#endif /* HAVE_NET_ROUTE_H */
380146773Ssam
381146773Ssam/*
382146773Ssam * Actions to take if <sys/mbuf.h> exists.
383146773Ssam */
384146773Ssam#ifdef HAVE_SYS_MBUF_H
385146773Ssam# include <sys/mbuf.h>
386146773Ssam/*
387146773Ssam * OSF4 (DU-4.0) defines m_next and m_data also in <sys/mount.h> so I must
388146773Ssam # undefine them here to avoid conflicts.
389146773Ssam */
390146773Ssam# ifdef m_next
391146773Ssam#  undef m_next
392146773Ssam# endif /* m_next */
393146773Ssam# ifdef m_data
394146773Ssam#  undef m_data
395214478Srpaulo# endif /* m_data */
396146773Ssam/*
397146773Ssam * AIX 3 defines MFREE and m_flags also in <sys/mount.h>.
398146773Ssam */
399146773Ssam# ifdef m_flags
400146773Ssam#  undef m_flags
401146773Ssam# endif /* m_flags */
402146773Ssam# ifdef MFREE
403146773Ssam#  undef MFREE
404146773Ssam# endif /* MFREE */
405146773Ssam#endif /* HAVE_SYS_MBUF_H */
406146773Ssam
407146773Ssam/*
408146773Ssam * Actions to take if <sys/mman.h> exists.
409146773Ssam */
410146773Ssam#ifdef HAVE_SYS_MMAN_H
411146773Ssam# include <sys/mman.h>
412146773Ssam#endif /* HAVE_SYS_MMAN_H */
413146773Ssam
414235530Sdelphij/*
415146773Ssam * Actions to take if <netdb.h> exists.
416146773Ssam */
417251158Sdelphij#ifdef HAVE_NETDB_H
418146773Ssam# include <netdb.h>
419146773Ssam#endif /* HAVE_NETDB_H */
420146773Ssam
421146773Ssam/*
422146773Ssam * Actions to take if <netdir.h> exists.
423146773Ssam */
424146773Ssam#ifdef HAVE_NETDIR_H
425146773Ssam# include <netdir.h>
426146773Ssam#endif /* HAVE_NETDIR_H */
427146773Ssam
428146773Ssam/*
429146773Ssam * Actions to take if <net/if_var.h> exists.
430146773Ssam */
431146773Ssam#ifdef HAVE_NET_IF_VAR_H
432146773Ssam# include <net/if_var.h>
433146773Ssam#endif /* HAVE_NET_IF_VAR_H */
434146773Ssam
435146773Ssam/*
436146773Ssam * Actions to take if <netinet/if_ether.h> exists.
437146773Ssam */
438146773Ssam#ifdef HAVE_NETINET_IF_ETHER_H
439146773Ssam# include <netinet/if_ether.h>
440146773Ssam#endif /* HAVE_NETINET_IF_ETHER_H */
441146773Ssam
442146773Ssam/*
443146773Ssam * Actions to take if <netinet/in.h> exists.
444146773Ssam */
445146773Ssam#ifdef HAVE_NETINET_IN_H
446146773Ssam# include <netinet/in.h>
447146773Ssam#endif /* HAVE_NETINET_IN_H */
448146773Ssam
449146773Ssam/*
450146773Ssam * Actions to take if <rpcsvc/yp_prot.h> exists.
451146773Ssam */
452146773Ssam#ifdef HAVE_RPCSVC_YP_PROT_H
453146773Ssam# ifdef HAVE_BAD_HEADERS
454146773Ssam/* avoid circular dependency in aix 4.3 with <rpcsvc/ypclnt.h> */
455146773Ssamstruct ypall_callback;
456146773Ssam# endif /* HAVE_BAD_HEADERS */
457146773Ssam# include <rpcsvc/yp_prot.h>
458146773Ssam#endif /* HAVE_RPCSVC_YP_PROT_H */
459146773Ssam
460146773Ssam/*
461235530Sdelphij * Actions to take if <rpcsvc/ypclnt.h> exists.
462235530Sdelphij */
463146773Ssam#ifdef HAVE_RPCSVC_YPCLNT_H
464146773Ssam# include <rpcsvc/ypclnt.h>
465146773Ssam#endif /* HAVE_RPCSVC_YPCLNT_H */
466146773Ssam
467146773Ssam/*
468146773Ssam * Actions to take if <sys/ucred.h> exists.
469214478Srpaulo */
470146773Ssam#ifdef HAVE_SYS_UCRED_H
471214478Srpaulo# include <sys/ucred.h>
472235530Sdelphij#endif /* HAVE_SYS_UCRED_H */
473214478Srpaulo
474235530Sdelphij
475235530Sdelphij/*
476146773Ssam * Actions to take if <sys/mount.h> exists.
477146773Ssam */
478235530Sdelphij#ifdef HAVE_SYS_MOUNT_H
479146773Ssam/*
480235530Sdelphij * Some operating systems must define these variables to get
481146773Ssam * NFS and other definitions included.
482146773Ssam */
483146773Ssam# ifndef NFSCLIENT
484146773Ssam#  define NFSCLIENT 1
485146773Ssam# endif /* not NFSCLIENT */
486146773Ssam# ifndef NFS
487146773Ssam#  define NFS 1
488146773Ssam# endif /* not NFS */
489146773Ssam# ifndef PCFS
490146773Ssam#  define PCFS 1
491146773Ssam# endif /* not PCFS */
492146773Ssam# ifndef LOFS
493146773Ssam#  define LOFS 1
494146773Ssam# endif /* not LOFS */
495235530Sdelphij# ifndef RFS
496146773Ssam#  define RFS 1
497146773Ssam# endif /* not RFS */
498146773Ssam# ifndef MSDOSFS
499235530Sdelphij#  define MSDOSFS 1
500235530Sdelphij# endif /* not MSDOSFS */
501235530Sdelphij# ifndef MFS
502235530Sdelphij#  define MFS 1
503235530Sdelphij# endif /* not MFS */
504235530Sdelphij# ifndef CD9660
505235530Sdelphij#  define CD9660 1
506146773Ssam# endif /* not CD9660 */
507146773Ssam# include <sys/mount.h>
508214478Srpaulo#endif /* HAVE_SYS_MOUNT_H */
509214478Srpaulo
510214478Srpaulo#ifdef HAVE_SYS_VMOUNT_H
511214478Srpaulo# include <sys/vmount.h>
512214478Srpaulo#endif /* HAVE_SYS_VMOUNT_H */
513214478Srpaulo
514214478Srpaulo/*
515146773Ssam * Actions to take if <linux/fs.h> exists.
516 * There is no point in including this on a glibc2 system,
517 * we're only asking for trouble
518 */
519#if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2)
520/*
521 * There are various conflicts in definitions between RedHat Linux, newer
522 * 2.2 kernels, and <netinet/in.h> and <linux/fs.h>.
523 */
524# ifdef HAVE_SOCKETBITS_H
525/* conflicts with <socketbits.h> */
526#  define _LINUX_SOCKET_H
527#  undef BLKFLSBUF
528#  undef BLKGETSIZE
529#  undef BLKRAGET
530#  undef BLKRASET
531#  undef BLKROGET
532#  undef BLKROSET
533#  undef BLKRRPART
534#  undef MS_MGC_VAL
535#  undef MS_RMT_MASK
536#  if defined(__GLIBC__) && __GLIBC__ >= 2
537/* conflicts with <waitflags.h> */
538#   undef WNOHANG
539#   undef WUNTRACED
540#  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
541/* conflicts with <statfsbuf.h> */
542#  define _SYS_STATFS_H
543# endif /* HAVE_SOCKETBITS_H */
544
545# ifdef _SYS_WAIT_H
546#  if defined(__GLIBC__) && __GLIBC__ >= 2
547/* conflicts with <bits/waitflags.h> (RedHat/Linux 6.0 and kernels 2.2 */
548#   undef WNOHANG
549#   undef WUNTRACED
550#  endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
551# endif /* _SYS_WAIT_H */
552
553# ifdef HAVE_LINUX_POSIX_TYPES_H
554#  include <linux/posix_types.h>
555# endif /* HAVE_LINUX_POSIX_TYPES_H */
556# ifndef _LINUX_BYTEORDER_GENERIC_H
557#  define _LINUX_BYTEORDER_GENERIC_H
558# endif /* _LINUX_BYTEORDER_GENERIC_H */
559/* conflicts with <sys/mount.h> in 2.[12] kernels */
560# ifdef _SYS_MOUNT_H
561#  undef BLKFLSBUF
562#  undef BLKGETSIZE
563#  undef BLKRAGET
564#  undef BLKRASET
565#  undef BLKROGET
566#  undef BLKROSET
567#  undef BLKRRPART
568#  undef BLOCK_SIZE
569#  undef MS_MANDLOCK
570#  undef MS_MGC_VAL
571#  undef MS_NOATIME
572#  undef MS_NODEV
573#  undef MS_NODIRATIME
574#  undef MS_NOEXEC
575#  undef MS_NOSUID
576#  undef MS_RDONLY
577#  undef MS_REMOUNT
578#  undef MS_RMT_MASK
579#  undef MS_SYNCHRONOUS
580#  undef S_APPEND
581#  undef S_IMMUTABLE
582/* conflicts with <statfsbuf.h> */
583#  define _SYS_STATFS_H
584# endif /* _SYS_MOUNT_H */
585# ifndef _LINUX_STRING_H_
586#  define _LINUX_STRING_H_
587# endif /* not _LINUX_STRING_H_ */
588# ifdef HAVE_LINUX_KDEV_T_H
589#  define __KERNEL__
590#  include <linux/kdev_t.h>
591#  undef __KERNEL__
592# endif /* HAVE_LINUX_KDEV_T_H */
593# ifdef HAVE_LINUX_LIST_H
594#  define __KERNEL__
595#  include <linux/list.h>
596#  undef __KERNEL__
597# endif /* HAVE_LINUX_LIST_H */
598# include <linux/fs.h>
599#endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */
600
601#ifdef HAVE_CDFS_CDFS_MOUNT_H
602# include <cdfs/cdfs_mount.h>
603#endif /* HAVE_CDFS_CDFS_MOUNT_H */
604
605#ifdef HAVE_CDFS_CDFSMOUNT_H
606# include <cdfs/cdfsmount.h>
607#endif /* HAVE_CDFS_CDFSMOUNT_H */
608
609/*
610 * Actions to take if <linux/loop.h> exists.
611 */
612#ifdef HAVE_LINUX_LOOP_H
613# ifdef HAVE_LINUX_POSIX_TYPES_H
614#  include <linux/posix_types.h>
615# endif /* HAVE_LINUX_POSIX_TYPES_H */
616/* next dev_t lines needed due to changes in kernel code */
617# undef dev_t
618# define dev_t unsigned short	/* compatible with Red Hat and SuSE */
619# include <linux/loop.h>
620#endif /* HAVE_LINUX_LOOP_H */
621
622/*
623 * AUTOFS PROTOCOL HEADER FILES:
624 */
625
626/*
627 * Actions to take if <linux/auto_fs[4].h> exists.
628 * We really don't want <linux/fs.h> pulled in here
629 */
630#ifndef _LINUX_FS_H
631#define _LINUX_FS_H
632#endif /* _LINUX_FS_H */
633#ifdef HAVE_LINUX_AUTO_FS4_H
634# include <linux/auto_fs4.h>
635#else  /* not HAVE_LINUX_AUTO_FS4_H */
636# ifdef HAVE_LINUX_AUTO_FS_H
637#  include <linux/auto_fs.h>
638# endif /* HAVE_LINUX_AUTO_FS_H */
639#endif /* not HAVE_LINUX_AUTO_FS4_H */
640
641/*
642 * Actions to take if <sys/fs/autofs.h> exists.
643 */
644#ifdef HAVE_SYS_FS_AUTOFS_H
645# include <sys/fs/autofs.h>
646#endif /* HAVE_SYS_FS_AUTOFS_H */
647
648/*
649 * Actions to take if <rpcsvc/autofs_prot.h> or <sys/fs/autofs_prot.h> exist.
650 */
651#ifdef HAVE_RPCSVC_AUTOFS_PROT_H
652# include <rpcsvc/autofs_prot.h>
653#else  /* not HAVE_RPCSVC_AUTOFS_PROT_H */
654# ifdef HAVE_SYS_FS_AUTOFS_PROT_H
655#  include <sys/fs/autofs_prot.h>
656# endif /* HAVE_SYS_FS_AUTOFS_PROT_H */
657#endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */
658
659/*
660 * Actions to take if <lber.h> exists.
661 * This header file is required before <ldap.h> can be included.
662 */
663#ifdef HAVE_LBER_H
664# include <lber.h>
665#endif /* HAVE_LBER_H */
666
667/*
668 * Actions to take if <ldap.h> exists.
669 */
670#ifdef HAVE_LDAP_H
671# include <ldap.h>
672#endif /* HAVE_LDAP_H */
673
674/****************************************************************************
675 ** IMPORTANT!!!							   **
676 ** We always include am-utils' amu_autofs_prot.h.			   **
677 ** That is actually defined in "conf/autofs/autofs_${autofs_style}.h"     **
678 ****************************************************************************/
679#include <amu_autofs_prot.h>
680
681
682/*
683 * NFS PROTOCOL HEADER FILES:
684 */
685
686/*
687 * Actions to take if <nfs/export.h> exists.
688 */
689#ifdef HAVE_NFS_EXPORT_H
690# include <nfs/export.h>
691#endif /* HAVE_NFS_EXPORT_H */
692
693/****************************************************************************
694 ** IMPORTANT!!!							   **
695 ** We always include am-utils' amu_nfs_prot.h.				   **
696 ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" **
697 ****************************************************************************/
698#include <amu_nfs_prot.h>
699
700/*
701 * DO NOT INCLUDE THESE FILES:
702 * They conflicts with other NFS headers and are generally not needed.
703 */
704#ifdef DO_NOT_INCLUDE
705# ifdef HAVE_NFS_NFS_CLNT_H
706#  include <nfs/nfs_clnt.h>
707# endif /* HAVE_NFS_NFS_CLNT_H */
708# ifdef HAVE_LINUX_NFS_H
709#  include <linux/nfs.h>
710# endif /* HAVE_LINUX_NFS_H */
711#endif /* DO NOT INCLUDE */
712
713/*
714 * Actions to take if one of the nfs headers exists.
715 */
716#ifdef HAVE_NFS_NFS_GFS_H
717# include <nfs/nfs_gfs.h>
718#endif /* HAVE_NFS_NFS_GFS_H */
719#ifdef HAVE_NFS_MOUNT_H
720# include <nfs/mount.h>
721#endif /* HAVE_NFS_MOUNT_H */
722#ifdef HAVE_NFS_NFS_MOUNT_H_off
723/* broken on nextstep3 (includes non-existing headers) */
724# include <nfs/nfs_mount.h>
725#endif /* HAVE_NFS_NFS_MOUNT_H */
726#ifdef HAVE_NFS_PATHCONF_H
727# include <nfs/pathconf.h>
728#endif /* HAVE_NFS_PATHCONF_H */
729#ifdef HAVE_SYS_FS_NFS_MOUNT_H
730# include <sys/fs/nfs/mount.h>
731#endif /* HAVE_SYS_FS_NFS_MOUNT_H */
732#ifdef HAVE_SYS_FS_NFS_NFS_CLNT_H
733# include <sys/fs/nfs/nfs_clnt.h>
734#endif /* HAVE_SYS_FS_NFS_NFS_CLNT_H */
735#ifdef HAVE_SYS_FS_NFS_CLNT_H
736# include <sys/fs/nfs_clnt.h>
737#endif /* HAVE_SYS_FS_NFS_CLNT_H */
738
739/* complex rules for linux/nfs_mount.h: broken on so many systems */
740#ifdef HAVE_LINUX_NFS_MOUNT_H
741# ifndef _LINUX_NFS_H
742#  define _LINUX_NFS_H
743# endif /* not _LINUX_NFS_H */
744# ifndef _LINUX_NFS2_H
745#  define _LINUX_NFS2_H
746# endif /* not _LINUX_NFS2_H */
747# ifndef _LINUX_NFS3_H
748#  define _LINUX_NFS3_H
749# endif /* not _LINUX_NFS3_H */
750# ifndef _LINUX_NFS_FS_H
751#  define _LINUX_NFS_FS_H
752# endif /* not _LINUX_NFS_FS_H */
753# ifndef _LINUX_IN_H
754#  define _LINUX_IN_H
755# endif /* not _LINUX_IN_H */
756# ifndef __KERNEL__
757#  define __KERNEL__
758# endif /* __KERNEL__ */
759# include <linux/nfs_mount.h>
760# undef __KERNEL__
761#endif /* HAVE_LINUX_NFS_MOUNT_H */
762
763/*
764 * Actions to take if <pwd.h> exists.
765 */
766#ifdef HAVE_PWD_H
767# include <pwd.h>
768#endif /* HAVE_PWD_H */
769
770/*
771 * Actions to take if <hesiod.h> exists.
772 */
773#ifdef HAVE_HESIOD_H
774# include <hesiod.h>
775#endif /* HAVE_HESIOD_H */
776
777/*
778 * Actions to take if <arpa/nameser.h> exists.
779 * Should be included before <resolv.h>.
780 */
781#ifdef HAVE_ARPA_NAMESER_H
782# ifdef NOERROR
783#  undef NOERROR
784# endif /* NOERROR */
785/*
786 * Conflicts with <sys/tpicommon.h> which is included from <sys/tiuser.h>
787 * on Solaris 2.6 systems.  So undefine it first.
788 */
789# ifdef T_UNSPEC
790#  undef T_UNSPEC
791# endif /* T_UNSPEC */
792# include <arpa/nameser.h>
793#endif /* HAVE_ARPA_NAMESER_H */
794
795/*
796 * Actions to take if <arpa/inet.h> exists.
797 */
798#ifdef HAVE_ARPA_INET_H
799# ifdef HAVE_BAD_HEADERS
800/* aix 4.3: avoid including <net/if_dl.h> */
801struct sockaddr_dl;
802# endif /* HAVE_BAD_HEADERS */
803# include <arpa/inet.h>
804#endif /* HAVE_ARPA_INET_H */
805
806/*
807 * Actions to take if <resolv.h> exists.
808 */
809#ifdef HAVE_RESOLV_H
810/*
811 * On AIX 5.2, both <resolv.h> and <arpa/nameser_compat.h> define MAXDNAME,
812 * if compiling with gcc -D_USE_IRS (so that we get extern definitions for
813 * hstrerror() and others).
814 */
815# if defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS)
816#  undef MAXDNAME
817# endif /* defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) */
818# include <resolv.h>
819#endif /* HAVE_RESOLV_H */
820
821/*
822 * Actions to take if <sys/uio.h> exists.
823 */
824#ifdef HAVE_SYS_UIO_H
825# include <sys/uio.h>
826#endif /* HAVE_SYS_UIO_H */
827
828/*
829 * Actions to take if <sys/fs/cachefs_fs.h> exists.
830 */
831#ifdef HAVE_SYS_FS_CACHEFS_FS_H
832# include <sys/fs/cachefs_fs.h>
833#endif /* HAVE_SYS_FS_CACHEFS_FS_H */
834
835/*
836 * Actions to take if <sys/fs/pc_fs.h> exists.
837 */
838#ifdef HAVE_SYS_FS_PC_FS_H
839# include <sys/fs/pc_fs.h>
840#endif /* HAVE_SYS_FS_PC_FS_H */
841
842/*
843 * Actions to take if <msdosfs/msdosfsmount.h> exists.
844 */
845#ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
846# include <msdosfs/msdosfsmount.h>
847#endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
848#ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
849# include <fs/msdosfs/msdosfsmount.h>
850#endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
851
852/*
853 * Actions to take if <fs/msdosfs/msdosfsmount.h> exists.
854 */
855#ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
856# include <fs/msdosfs/msdosfsmount.h>
857#endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
858
859/*
860 * Actions to take if <sys/fs/tmp.h> exists.
861 */
862#ifdef HAVE_SYS_FS_TMP_H
863# include <sys/fs/tmp.h>
864#endif /* HAVE_SYS_FS_TMP_H */
865#ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H
866# include <fs/tmpfs/tmpfs_args.h>
867#endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */
868
869
870/*
871 * Actions to take if <sys/fs/ufs_mount.h> exists.
872 */
873#ifdef HAVE_SYS_FS_UFS_MOUNT_H
874# include <sys/fs/ufs_mount.h>
875#endif /* HAVE_SYS_FS_UFS_MOUNT_H */
876/*
877 * HAVE_UFS_UFS_UFSMOUNT_H should NOT be defined on netbsd/openbsd because it
878 * causes errors with other header files.  Instead, add it to the specific
879 * conf/nfs_prot_*.h file.
880 */
881#ifdef	HAVE_UFS_UFS_UFSMOUNT_H
882# include <ufs/ufs/ufsmount.h>
883#endif	/* HAVE_UFS_UFS_UFSMOUNT_H */
884
885/*
886 * Actions to take if <sys/fs/efs_clnt.h> exists.
887 */
888#ifdef HAVE_SYS_FS_EFS_CLNT_H
889# include <sys/fs/efs_clnt.h>
890#endif /* HAVE_SYS_FS_EFS_CLNT_H */
891#ifdef HAVE_FS_EFS_EFS_MOUNT_H
892# include <fs/efs/efs_mount.h>
893#endif /* HAVE_FS_EFS_EFS_MOUNT_H */
894
895/*
896 * Actions to take if <sys/fs/xfs_clnt.h> exists.
897 */
898#ifdef HAVE_SYS_FS_XFS_CLNT_H
899# include <sys/fs/xfs_clnt.h>
900#endif /* HAVE_SYS_FS_XFS_CLNT_H */
901
902/*
903 * Actions to take if <assert.h> exists.
904 */
905#ifdef HAVE_ASSERT_H
906# include <assert.h>
907#endif /* HAVE_ASSERT_H */
908
909/*
910 * Actions to take if <cfs.h> exists.
911 */
912#ifdef HAVE_CFS_H
913# include <cfs.h>
914#endif /* HAVE_CFS_H */
915
916/*
917 * Actions to take if <cluster.h> exists.
918 */
919#ifdef HAVE_CLUSTER_H
920# include <cluster.h>
921#endif /* HAVE_CLUSTER_H */
922
923/*
924 * Actions to take if <ctype.h> exists.
925 */
926#ifdef HAVE_CTYPE_H
927# include <ctype.h>
928#endif /* HAVE_CTYPE_H */
929
930/*
931 * Actions to take if <errno.h> exists.
932 */
933#ifdef HAVE_ERRNO_H
934# include <errno.h>
935#else
936/*
937 * Actions to take if <sys/errno.h> exists.
938 */
939# ifdef HAVE_SYS_ERRNO_H
940#  include <sys/errno.h>
941extern int errno;
942# endif /* HAVE_SYS_ERRNO_H */
943#endif /* HAVE_ERRNO_H */
944
945/*
946 * Actions to take if <grp.h> exists.
947 */
948#ifdef HAVE_GRP_H
949# include <grp.h>
950#endif /* HAVE_GRP_H */
951
952/*
953 * Actions to take if <hsfs/hsfs.h> exists.
954 */
955#ifdef HAVE_HSFS_HSFS_H
956# include <hsfs/hsfs.h>
957#endif /* HAVE_HSFS_HSFS_H */
958
959/*
960 * Actions to take if <cdfs/cdfsmount.h> exists.
961 */
962#ifdef HAVE_CDFS_CDFSMOUNT_H
963# include <cdfs/cdfsmount.h>
964#endif /* HAVE_CDFS_CDFSMOUNT_H */
965
966/*
967 * Actions to take if <isofs/cd9660/cd9660_mount.h> exists.
968 */
969#ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H
970# include <isofs/cd9660/cd9660_mount.h>
971#endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */
972
973/*
974 * Actions to take if <fs/udf/udf_mount.h> exists.
975 */
976#ifdef HAVE_FS_UDF_UDF_MOUNT_H
977# include <fs/udf/udf_mount.h>
978#endif /* HAVE_FS_UDF_UDF_MOUNT_H */
979
980/*
981 * Actions to take if <mount.h> exists.
982 */
983#ifdef HAVE_MOUNT_H
984# include <mount.h>
985#endif /* HAVE_MOUNT_H */
986
987/*
988 * Actions to take if <nsswitch.h> exists.
989 */
990#ifdef HAVE_NSSWITCH_H
991# include <nsswitch.h>
992#endif /* HAVE_NSSWITCH_H */
993
994/*
995 * Actions to take if <rpc/auth_des.h> exists.
996 */
997#ifdef HAVE_RPC_AUTH_DES_H
998# include <rpc/auth_des.h>
999#endif /* HAVE_RPC_AUTH_DES_H */
1000
1001/*
1002 * Actions to take if <rpc/pmap_clnt.h> exists.
1003 */
1004#ifdef HAVE_RPC_PMAP_CLNT_H
1005# include <rpc/pmap_clnt.h>
1006#endif /* HAVE_RPC_PMAP_CLNT_H */
1007
1008/*
1009 * Actions to take if <rpc/pmap_prot.h> exists.
1010 */
1011#ifdef HAVE_RPC_PMAP_PROT_H
1012# include <rpc/pmap_prot.h>
1013#endif /* HAVE_RPC_PMAP_PROT_H */
1014
1015
1016/*
1017 * Actions to take if <rpcsvc/mount.h> exists.
1018 * AIX does not protect against this file doubly included,
1019 * so I have to do my own protection here.
1020 */
1021#ifdef HAVE_RPCSVC_MOUNT_H
1022# ifndef _RPCSVC_MOUNT_H
1023#  include <rpcsvc/mount.h>
1024# endif /* not _RPCSVC_MOUNT_H */
1025#endif /* HAVE_RPCSVC_MOUNT_H */
1026
1027/*
1028 * Actions to take if <rpcsvc/nis.h> exists.
1029 */
1030#ifdef HAVE_RPCSVC_NIS_H
1031/*
1032 * Solaris 10 (build 72) defines GROUP_OBJ in <sys/acl.h>, which is included
1033 * in many other header files.  <rpcsvc/nis.h> uses GROUP_OBJ inside enum
1034 * zotypes.  So if you're unlucky enough to include both headers, you get a
1035 * compile error because the two symbols conflict.
1036 * A similar conflict arises with Sun cc and the definition of "GROUP".
1037 *
1038 * Temp hack: undefine acl.h's GROUP_OBJ and GROUP because they're not needed
1039 * for am-utils.
1040 */
1041# ifdef GROUP_OBJ
1042#  undef GROUP_OBJ
1043# endif /* GROUP_OBJ */
1044# ifdef GROUP
1045#  undef GROUP
1046# endif /* GROUP */
1047# include <rpcsvc/nis.h>
1048#endif /* HAVE_RPCSVC_NIS_H */
1049
1050/*
1051 * Actions to take if <setjmp.h> exists.
1052 */
1053#ifdef HAVE_SETJMP_H
1054# include <setjmp.h>
1055#endif /* HAVE_SETJMP_H */
1056
1057/*
1058 * Actions to take if <signal.h> exists.
1059 */
1060#ifdef HAVE_SIGNAL_H
1061# include <signal.h>
1062#endif /* HAVE_SIGNAL_H */
1063
1064/*
1065 * Actions to take if <string.h> exists.
1066 */
1067#ifdef HAVE_STRING_H
1068# include <string.h>
1069#endif /* HAVE_STRING_H */
1070
1071/*
1072 * Actions to take if <strings.h> exists.
1073 */
1074#ifdef HAVE_STRINGS_H
1075# include <strings.h>
1076#endif /* HAVE_STRINGS_H */
1077
1078/*
1079 * Actions to take if <sys/config.h> exists.
1080 */
1081#ifdef HAVE_SYS_CONFIG_H
1082# include <sys/config.h>
1083#endif /* HAVE_SYS_CONFIG_H */
1084
1085/*
1086 * Actions to take if <sys/dg_mount.h> exists.
1087 */
1088#ifdef HAVE_SYS_DG_MOUNT_H
1089# include <sys/dg_mount.h>
1090#endif /* HAVE_SYS_DG_MOUNT_H */
1091
1092/*
1093 * Actions to take if <sys/fs_types.h> exists.
1094 */
1095#ifdef HAVE_SYS_FS_TYPES_H
1096/*
1097 * Define KERNEL here to avoid multiple definitions of gt_names[] on
1098 * Ultrix 4.3.
1099 */
1100# define KERNEL
1101# include <sys/fs_types.h>
1102# undef KERNEL
1103#endif /* HAVE_SYS_FS_TYPES_H */
1104
1105/*
1106 * Actions to take if <sys/fstyp.h> exists.
1107 */
1108#ifdef HAVE_SYS_FSTYP_H
1109# include <sys/fstyp.h>
1110#endif /* HAVE_SYS_FSTYP_H */
1111
1112/*
1113 * Actions to take if <sys/lock.h> exists.
1114 */
1115#ifdef HAVE_SYS_LOCK_H
1116# include <sys/lock.h>
1117#endif /* HAVE_SYS_LOCK_H */
1118
1119/*
1120 * Actions to take if <sys/machine.h> exists.
1121 */
1122#ifdef HAVE_SYS_MACHINE_H
1123# include <sys/machine.h>
1124#endif /* HAVE_SYS_MACHINE_H */
1125
1126/*
1127 * Actions to take if <sys/mntctl.h> exists.
1128 */
1129#ifdef HAVE_SYS_MNTCTL_H
1130# include <sys/mntctl.h>
1131#endif /* HAVE_SYS_MNTCTL_H */
1132
1133/*
1134 * Actions to take if <sys/mnttab.h> exists.
1135 */
1136#ifdef HAVE_SYS_MNTTAB_H
1137# include <sys/mnttab.h>
1138#endif /* HAVE_SYS_MNTTAB_H */
1139
1140/*
1141 * Actions to take if <mnttab.h> exists.
1142 * Do not include it if MNTTAB is already defined because it probably
1143 * came from <sys/mnttab.h> and we do not want conflicting definitions.
1144 */
1145#if defined(HAVE_MNTTAB_H) && !defined(MNTTAB)
1146# include <mnttab.h>
1147#endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */
1148
1149/*
1150 * Actions to take if <netconfig.h> exists.
1151 */
1152#ifdef HAVE_NETCONFIG_H
1153# include <netconfig.h>
1154/* Some systems (Solaris 2.5.1) don't declare this external */
1155extern char *nc_sperror(void);
1156#endif /* HAVE_NETCONFIG_H */
1157
1158/*
1159 * Actions to take if <sys/netconfig.h> exists.
1160 */
1161#ifdef HAVE_SYS_NETCONFIG_H
1162# include <sys/netconfig.h>
1163#endif /* HAVE_SYS_NETCONFIG_H */
1164
1165/*
1166 * Actions to take if <sys/pathconf.h> exists.
1167 */
1168#ifdef HAVE_SYS_PATHCONF_H
1169# include <sys/pathconf.h>
1170#endif /* HAVE_SYS_PATHCONF_H */
1171
1172/*
1173 * Actions to take if <sys/resource.h> exists.
1174 */
1175#ifdef HAVE_SYS_RESOURCE_H
1176# include <sys/resource.h>
1177#endif /* HAVE_SYS_RESOURCE_H */
1178
1179/*
1180 * Actions to take if <sys/sema.h> exists.
1181 */
1182#ifdef HAVE_SYS_SEMA_H
1183# include <sys/sema.h>
1184#endif /* HAVE_SYS_SEMA_H */
1185
1186/*
1187 * Actions to take if <sys/signal.h> exists.
1188 */
1189#ifdef HAVE_SYS_SIGNAL_H
1190# include <sys/signal.h>
1191#endif /* HAVE_SYS_SIGNAL_H */
1192
1193/*
1194 * Actions to take if <sys/sockio.h> exists.
1195 */
1196#ifdef HAVE_SYS_SOCKIO_H
1197# include <sys/sockio.h>
1198#endif /* HAVE_SYS_SOCKIO_H */
1199
1200/*
1201 * Actions to take if <sys/syscall.h> exists.
1202 */
1203#ifdef HAVE_SYS_SYSCALL_H
1204# include <sys/syscall.h>
1205#endif /* HAVE_SYS_SYSCALL_H */
1206
1207/*
1208 * Actions to take if <sys/syslimits.h> exists.
1209 */
1210#ifdef HAVE_SYS_SYSLIMITS_H
1211# include <sys/syslimits.h>
1212#endif /* HAVE_SYS_SYSLIMITS_H */
1213
1214/*
1215 * Actions to take if <tiuser.h> exists.
1216 */
1217#ifdef HAVE_TIUSER_H
1218/*
1219 * Some systems like AIX have multiple definitions for T_NULL and others
1220 * that are defined first in <arpa/nameser.h>.
1221 */
1222# ifdef HAVE_ARPA_NAMESER_H
1223#  ifdef T_NULL
1224#   undef T_NULL
1225#  endif /* T_NULL */
1226#  ifdef T_UNSPEC
1227#   undef T_UNSPEC
1228#  endif /* T_UNSPEC */
1229#  ifdef T_IDLE
1230#   undef T_IDLE
1231#  endif /* T_IDLE */
1232# endif /* HAVE_ARPA_NAMESER_H */
1233# include <tiuser.h>
1234#endif /* HAVE_TIUSER_H */
1235
1236/*
1237 * Actions to take if <sys/tiuser.h> exists.
1238 */
1239#ifdef HAVE_SYS_TIUSER_H
1240# include <sys/tiuser.h>
1241#endif /* HAVE_SYS_TIUSER_H */
1242
1243/*
1244 * Actions to take if <sys/statfs.h> exists.
1245 */
1246#ifdef HAVE_SYS_STATFS_H
1247# include <sys/statfs.h>
1248#endif /* HAVE_SYS_STATFS_H */
1249
1250/*
1251 * Actions to take if <sys/statvfs.h> exists.
1252 */
1253#ifdef HAVE_SYS_STATVFS_H
1254# include <sys/statvfs.h>
1255#endif /* HAVE_SYS_STATVFS_H */
1256
1257/*
1258 * Actions to take if <sys/vfs.h> exists.
1259 */
1260#ifdef HAVE_SYS_VFS_H
1261# include <sys/vfs.h>
1262#endif /* HAVE_SYS_VFS_H */
1263
1264/*
1265 * Actions to take if <sys/vmount.h> exists.
1266 */
1267#ifdef HAVE_SYS_VMOUNT_H
1268# include <sys/vmount.h>
1269#endif /* HAVE_SYS_VMOUNT_H */
1270
1271/*
1272 * Actions to take if <ufs/ufs_mount.h> exists.
1273 */
1274#ifdef HAVE_UFS_UFS_MOUNT_H
1275# include <ufs/ufs_mount.h>
1276#endif /* HAVE_UFS_UFS_MOUNT_H */
1277
1278/*
1279 * Are S_ISDIR, S_ISREG, et al broken?  If not, include <sys/stat.h>.
1280 * Turned off the not using sys/stat.h based on if the macros are
1281 * "broken", because they incorrectly get reported as broken on
1282 * ncr2.
1283 */
1284#ifndef STAT_MACROS_BROKEN_notused
1285/*
1286 * RedHat Linux 4.2 (alpha) has a problem in the headers that causes
1287 * duplicate definitions, and also some other nasty bugs.  Upgrade to Redhat
1288 * 5.0!
1289 */
1290# ifdef HAVE_SYS_STAT_H
1291/* avoid duplicates or conflicts with <linux/stat.h> (RedHat alpha linux) */
1292#  if defined(S_IFREG) && defined(HAVE_STATBUF_H)
1293#   include <statbuf.h>
1294#   undef S_IFBLK
1295#   undef S_IFCHR
1296#   undef S_IFDIR
1297#   undef S_IFIFO
1298#   undef S_IFLNK
1299#   undef S_IFMT
1300#   undef S_IFREG
1301#   undef S_IFSOCK
1302#   undef S_IRGRP
1303#   undef S_IROTH
1304#   undef S_IRUSR
1305#   undef S_IRWXG
1306#   undef S_IRWXO
1307#   undef S_IRWXU
1308#   undef S_ISBLK
1309#   undef S_ISCHR
1310#   undef S_ISDIR
1311#   undef S_ISFIFO
1312#   undef S_ISGID
1313#   undef S_ISLNK
1314#   undef S_ISREG
1315#   undef S_ISSOCK
1316#   undef S_ISUID
1317#   undef S_ISVTX
1318#   undef S_IWGRP
1319#   undef S_IWOTH
1320#   undef S_IWUSR
1321#   undef S_IXGRP
1322#   undef S_IXOTH
1323#   undef S_IXUSR
1324#  endif /* defined(S_IFREG) && defined(HAVE_STATBUF_H) */
1325#  include <sys/stat.h>
1326# endif /* HAVE_SYS_STAT_H */
1327#endif /* not STAT_MACROS_BROKEN_notused */
1328
1329/*
1330 * Actions to take if <stdio.h> exists.
1331 */
1332#ifdef HAVE_STDIO_H
1333# include <stdio.h>
1334#endif /* HAVE_STDIO_H */
1335
1336/*
1337 * Actions to take if <stdlib.h> exists.
1338 */
1339#ifdef HAVE_STDLIB_H
1340# include <stdlib.h>
1341#endif /* HAVE_STDLIB_H */
1342
1343/*
1344 * Actions to take if <regex.h> exists.
1345 */
1346#ifdef HAVE_REGEX_H
1347# include <regex.h>
1348#endif /* HAVE_REGEX_H */
1349
1350/*
1351 * Actions to take if <tcpd.h> exists.
1352 */
1353#if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP)
1354# include <tcpd.h>
1355#endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */
1356
1357
1358/****************************************************************************/
1359/*
1360 * Specific macros we're looking for.
1361 */
1362#ifndef HAVE_MEMSET
1363# ifdef HAVE_BZERO
1364#  define	memset(ptr, val, len)	bzero((ptr), (len))
1365# else /* not HAVE_BZERO */
1366#  error Cannot find either memset or bzero!
1367# endif /* not HAVE_BZERO */
1368#endif /* not HAVE_MEMSET */
1369
1370#ifndef HAVE_MEMMOVE
1371# ifdef HAVE_BCOPY
1372#  define	memmove(to, from, len)	bcopy((from), (to), (len))
1373# else /* not HAVE_BCOPY */
1374#  error Cannot find either memmove or bcopy!
1375# endif /* not HAVE_BCOPY */
1376#endif /* not HAVE_MEMMOVE */
1377
1378/*
1379 * memcmp() is more problematic:
1380 * Systems that don't have it, but have bcmp(), will use bcmp() instead.
1381 * Those that have it, but it is bad (SunOS 4 doesn't handle
1382 * 8 bit comparisons correctly), will get to use am_memcmp().
1383 * Otherwise if you have memcmp() and it is good, use it.
1384 */
1385#ifdef HAVE_MEMCMP
1386# ifdef HAVE_BAD_MEMCMP
1387#  define	memcmp		am_memcmp
1388extern int am_memcmp(const voidp s1, const voidp s2, size_t len);
1389# endif /* HAVE_BAD_MEMCMP */
1390#else /* not HAVE_MEMCMP */
1391# ifdef HAVE_BCMP
1392#  define	memcmp(a, b, len)	bcmp((a), (b), (len))
1393# endif /* HAVE_BCMP */
1394#endif /* not HAVE_MEMCMP */
1395
1396#ifndef HAVE_SETEUID
1397# ifdef HAVE_SETRESUID
1398#  define	seteuid(x)		setresuid(-1,(x),-1)
1399# else /* not HAVE_SETRESUID */
1400#  error Cannot find either seteuid or setresuid!
1401# endif /* not HAVE_SETRESUID */
1402#endif /* not HAVE_SETEUID */
1403
1404/*
1405 * Define type of mntent_t.
1406 * Defaults to struct mntent, else struct mnttab.  If neither is found, and
1407 * the operating system does keep not mount tables in the kernel, then flag
1408 * it as an error.  If neither is found and the OS keeps mount tables in the
1409 * kernel, then define our own version of mntent; it will be needed for amd
1410 * to keep its own internal version of the mount tables.
1411 */
1412#ifdef HAVE_STRUCT_MNTENT
1413typedef struct mntent mntent_t;
1414#else /* not HAVE_STRUCT_MNTENT */
1415# ifdef HAVE_STRUCT_MNTTAB
1416typedef struct mnttab mntent_t;
1417/* map struct mnttab field names to struct mntent field names */
1418#  define mnt_fsname	mnt_special
1419#  define mnt_dir	mnt_mountp
1420#  define mnt_opts	mnt_mntopts
1421#  define mnt_type	mnt_fstype
1422# else /* not HAVE_STRUCT_MNTTAB */
1423#  ifdef MOUNT_TABLE_ON_FILE
1424#   error Could not find definition for struct mntent or struct mnttab!
1425#  else /* not MOUNT_TABLE_ON_FILE */
1426typedef struct _am_mntent {
1427  char	*mnt_fsname;		/* name of mounted file system */
1428  char	*mnt_dir;		/* file system path prefix */
1429  char	*mnt_type;		/* MNTTAB_TYPE_* */
1430  char	*mnt_opts;		/* MNTTAB_OPT_* */
1431  int	mnt_freq;		/* dump frequency, in days */
1432  int	mnt_passno;		/* pass number on parallel fsck */
1433} mntent_t;
1434#  endif /* not MOUNT_TABLE_ON_FILE */
1435# endif /* not HAVE_STRUCT_MNTTAB */
1436#endif /* not HAVE_STRUCT_MNTENT */
1437
1438/*
1439 * Provide FD_* macros for systems that lack them.
1440 */
1441#ifndef FD_SET
1442# define FD_SET(fd, set) (*(set) |= (1 << (fd)))
1443# define FD_ISSET(fd, set) (*(set) & (1 << (fd)))
1444# define FD_CLR(fd, set) (*(set) &= ~(1 << (fd)))
1445# define FD_ZERO(set) (*(set) = 0)
1446#endif /* not FD_SET */
1447
1448
1449/*
1450 * Complete external definitions missing from some systems.
1451 */
1452
1453#ifndef HAVE_EXTERN_SYS_ERRLIST
1454extern const char *const sys_errlist[];
1455#endif /* not HAVE_EXTERN_SYS_ERRLIST */
1456
1457#ifndef HAVE_EXTERN_OPTARG
1458extern char *optarg;
1459extern int optind;
1460#endif /* not HAVE_EXTERN_OPTARG */
1461
1462#if defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR)
1463extern char *clnt_spcreateerror(const char *s);
1464#endif /* defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) */
1465
1466#if defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO)
1467extern char *clnt_sperrno(const enum clnt_stat num);
1468#endif /* defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) */
1469
1470#ifndef HAVE_EXTERN_FREE
1471extern void free(voidp);
1472#endif /* not HAVE_EXTERN_FREE */
1473
1474#if defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS)
1475extern void get_myaddress(struct sockaddr_in *addr);
1476#endif /* defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) */
1477
1478#if defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME)
1479# if defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS)
1480extern int getdomainname(char *name, int namelen);
1481# endif /* defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) */
1482#endif /* defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) */
1483
1484#if defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE)
1485extern int getdtablesize(void);
1486#endif /* defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) */
1487
1488#if defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME)
1489extern int gethostname(char *name, int namelen);
1490#endif /* defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) */
1491
1492#ifndef HAVE_EXTERN_GETLOGIN
1493extern char *getlogin(void);
1494#endif /* not HAVE_EXTERN_GETLOGIN */
1495
1496#if defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE)
1497extern int getpagesize(void);
1498#endif /* defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) */
1499
1500#ifndef HAVE_EXTERN_GETWD
1501extern char *getwd(char *s);
1502#endif /* not HAVE_EXTERN_GETWD */
1503
1504#if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL)
1505extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, char *client_user);
1506#endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) */
1507
1508#ifndef HAVE_EXTERN_INNETGR
1509extern int innetgr(char *, char *, char *, char *);
1510#endif /* not HAVE_EXTERN_INNETGR */
1511
1512#if defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP)
1513extern int mkstemp(char *);
1514#endif /* defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) */
1515
1516#ifndef HAVE_EXTERN_SBRK
1517extern caddr_t sbrk(int incr);
1518#endif /* not HAVE_EXTERN_SBRK */
1519
1520#if defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID)
1521extern int seteuid(uid_t euid);
1522#endif /* not defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) */
1523
1524#if defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER)
1525extern int setitimer(int, struct itimerval *, struct itimerval *);
1526#endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */
1527
1528#ifndef HAVE_EXTERN_SLEEP
1529extern unsigned int sleep(unsigned int seconds);
1530#endif /* not HAVE_EXTERN_SETITIMER */
1531
1532#ifndef HAVE_EXTERN_STRCASECMP
1533/*
1534 * define this extern even if function does not exist, for it will
1535 * be filled in by libamu/strcasecmp.c
1536 */
1537extern int strcasecmp(const char *s1, const char *s2);
1538#endif /* not HAVE_EXTERN_STRCASECMP */
1539
1540#ifndef HAVE_EXTERN_STRLCAT
1541/*
1542 * define this extern even if function does not exist, for it will
1543 * be filled in by libamu/strlcat.c
1544 */
1545extern size_t strlcat(char *dst, const char *src, size_t siz);
1546#endif /* not HAVE_EXTERN_STRLCAT */
1547
1548#ifndef HAVE_EXTERN_STRLCPY
1549/*
1550 * define this extern even if function does not exist, for it will
1551 * be filled in by libamu/strlcpy.c
1552 */
1553extern size_t strlcpy(char *dst, const char *src, size_t siz);
1554#endif /* not HAVE_EXTERN_STRLCPY */
1555
1556#if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR)
1557extern char *strstr(const char *s1, const char *s2);
1558#endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */
1559
1560#if defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP)
1561extern int usleep(u_int useconds);
1562#endif /* defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) */
1563
1564#ifndef HAVE_EXTERN_UALARM
1565extern u_int ualarm(u_int usecs, u_int interval);
1566#endif /* not HAVE_EXTERN_UALARM */
1567
1568#if defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3)
1569extern int wait3(int *statusp, int options, struct rusage *rusage);
1570#endif /* defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) */
1571
1572#if defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF)
1573extern int vsnprintf(char *, int, const char *, ...);
1574#endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */
1575
1576#ifndef HAVE_EXTERN_XDR_CALLMSG
1577extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg);
1578#endif /* not HAVE_EXTERN_XDR_CALLMSG */
1579
1580#ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH
1581extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth);
1582#endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */
1583
1584/****************************************************************************/
1585/*
1586 * amd-specific header files.
1587 */
1588#ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE
1589# include <amu_nfs_prot.h>
1590#endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */
1591#include <am_compat.h>
1592#include <am_xdr_func.h>
1593#include <am_utils.h>
1594#include <amq_defs.h>
1595#include <aux_conf.h>
1596
1597
1598/****************************************************************************/
1599/*
1600 * External definitions that depend on other macros available (or not)
1601 * and those are probably declared in any of the above headers.
1602 */
1603
1604#ifdef HAVE_HASMNTOPT
1605# ifdef HAVE_BAD_HASMNTOPT
1606extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
1607# else /* not HAVE_BAD_HASMNTOPT */
1608#  define amu_hasmntopt hasmntopt
1609# endif /* not HAVE_BAD_HASMNTOPT */
1610#else /* not HAVE_HASMNTOPT */
1611extern char *amu_hasmntopt(mntent_t *mnt, char *opt);
1612#endif /* not HAVE_HASMNTOPT */
1613
1614#endif /* not _AM_DEFS_H */
1615