12 #include <sys/types.h>
16 #ifdef HAVE_SYS_PARAM_H
17 #include <sys/param.h>
20 /* <unistd.h> should be included before any preprocessor test
24 #if defined(__LCLINT__)
25 /*@-superuser -declundef -incondefs @*/ /* LCL: modifies clause missing */
26 extern int chroot (const char *__path)
27 /*@globals errno, systemState @*/
28 /*@modifies errno, systemState @*/;
29 /*@=superuser =declundef =incondefs @*/
33 #if TIME_WITH_SYS_TIME
34 # include <sys/time.h>
38 # include <sys/time.h>
45 extern time_t timezone;
48 /* Since major is a function on SVR4, we can't use `ifndef major'. */
50 #include <sys/mkdev.h>
53 #if MAJOR_IN_SYSMACROS
54 #include <sys/sysmacros.h>
57 #ifdef major /* Might be defined in sys/types.h. */
62 #define major(dev) (((dev) >> 8) & 0xff)
63 #define minor(dev) ((dev) & 0xff)
64 #define makedev(maj, min) (((maj) << 8) | (min))
73 # if !STDC_HEADERS && HAVE_MEMORY_H
82 #if !defined(HAVE_STPCPY)
83 char * stpcpy(/*@out@*/ char * dest, const char * src);
86 #if !defined(HAVE_STPNCPY)
87 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
98 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
99 #define getopt system_getopt
100 /*@=macrounrecog =incondefs =globuse =mustmod @*/
101 /*@-skipansiheaders@*/
103 /*@=skipansiheaders@*/
105 #if defined(__LCLINT__)
106 /*@-declundef -incondefs @*/ /* LCL: modifies clause missing */
107 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
108 /*@globals errno, fileSystem @*/
109 /*@requires maxSet(resolved_name) >= (PATH_MAX - 1); @*/
110 /*@modifies *resolved_name, errno, fileSystem @*/;
111 /*@=declundef =incondefs @*/
113 #else /* not STDC_HEADERS */
114 char *getenv (const char *name);
116 char *realpath(const char *path, char resolved_path []);
118 #endif /* STDC_HEADERS */
120 /* XXX solaris2.5.1 has not */
121 #if !defined(EXIT_FAILURE)
122 #define EXIT_FAILURE 1
128 #include <sys/file.h>
131 #if !defined(SEEK_SET) && !defined(__LCLINT__)
136 #if !defined(F_OK) && !defined(__LCLINT__)
145 # define NLENGTH(direct) (strlen((direct)->d_name))
146 #else /* not HAVE_DIRENT_H */
147 # define dirent direct
148 # define NLENGTH(direct) ((direct)->d_namlen)
149 # ifdef HAVE_SYS_NDIR_H
150 # include <sys/ndir.h>
151 # endif /* HAVE_SYS_NDIR_H */
152 # ifdef HAVE_SYS_DIR_H
153 # include <sys/dir.h>
154 # endif /* HAVE_SYS_DIR_H */
157 # endif /* HAVE_NDIR_H */
158 #endif /* HAVE_DIRENT_H */
160 #if defined(__LCLINT__)
161 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
162 /*@only@*/ void * alloca (size_t __size)
163 /*@ensures MaxSet(result) == (__size - 1) @*/
165 /*@=declundef =incondefs @*/
170 # define alloca __builtin_alloca
172 # ifdef HAVE_ALLOCA_H
176 /* AIX alloca decl has to be the first thing in the file, bletch! */
184 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
185 #include <sys/mman.h>
188 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
189 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
190 #include <sys/resource.h>
193 #if HAVE_SYS_UTSNAME_H
194 #include <sys/utsname.h>
198 #include <sys/wait.h>
219 #if HAVE_MALLOC_H && !defined(__LCLINT__)
223 /*@-declundef -incondefs @*/ /* FIX: these are macros */
226 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
228 /*@ensures MaxSet(result) == (size - 1) @*/
229 /*@modifies errno @*/;
233 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
234 /*@ensures MaxSet(result) == (nmemb - 1) @*/
238 * @todo Annotate ptr with returned/out.
240 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
242 /*@ensures MaxSet(result) == (size - 1) @*/
243 /*@modifies *ptr @*/;
247 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
249 /*@=declundef =incondefs @*/
253 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
258 #if defined(__LCLINT__)
259 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
263 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
264 MCHECK_OK, /* Block is fine. */
265 MCHECK_FREE, /* Block freed twice. */
266 MCHECK_HEAD, /* Memory before the block was clobbered. */
267 MCHECK_TAIL /* Memory after the block was clobbered. */
271 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
272 /*@globals internalState@*/
273 /*@modifies internalState @*/;
274 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
275 /*@globals internalState@*/
276 /*@modifies internalState @*/;
277 extern void mcheck_check_all (void)
278 /*@globals internalState@*/
279 /*@modifies internalState @*/;
280 extern enum mcheck_status mprobe (void *__ptr)
281 /*@globals internalState@*/
282 /*@modifies internalState @*/;
283 extern void mtrace (void)
284 /*@globals internalState@*/
285 /*@modifies internalState @*/;
286 extern void muntrace (void)
287 /*@globals internalState@*/
288 /*@modifies internalState @*/;
289 /*@=declundef =incondefs @*/
290 #endif /* defined(__LCLINT__) */
292 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
293 #if defined(__GNUC__)
294 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
295 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
296 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
297 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
298 #endif /* defined(__GNUC__) */
299 #endif /* HAVE_MCHECK_H */
301 /* Retrofit glibc __progname */
302 #if defined __GLIBC__ && __GLIBC__ >= 2
303 #if __GLIBC_MINOR__ >= 1
304 #define __progname __assert_program_name
306 #define setprogname(pn)
308 #define __progname program_name
309 #define setprogname(pn) \
310 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
311 else __progname = pn; \
314 const char *__progname;
324 /* Take care of NLS matters. */
330 # define setlocale(Category, Locale) /* empty */
333 #if ENABLE_NLS && !defined(__LCLINT__)
334 # include <libintl.h>
335 # define _(Text) gettext (Text)
337 # undef bindtextdomain
338 # define bindtextdomain(Domain, Directory) /* empty */
340 # define textdomain(Domain) /* empty */
341 # define _(Text) Text
343 # define dgettext(DomainName, Text) Text
346 #define N_(Text) Text
348 /* ============== from misc/miscfn.h */
350 #if !defined(USE_GNU_GLOB)
364 #include "misc/glob.h"
365 #include "misc/fnmatch.h"
369 #if defined(__LCLINT__)
370 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
372 typedef /*@concrete@*/ struct
379 void (*gl_closedir) (void *);
381 struct dirent *(*gl_readdir) (void *);
383 void *(*gl_readdir) (void *);
385 ptr_t (*gl_opendir) (const char *);
387 int (*gl_lstat) (const char *restrict, struct stat *restrict);
388 int (*gl_stat) (const char *restrict, struct stat *restrict);
390 int (*gl_lstat) (const char *restrict, void *restrict);
391 int (*gl_stat) (const char *restrict, void *restrict);
398 /*@constant int GLOB_ERR@*/
399 /*@constant int GLOB_MARK@*/
400 /*@constant int GLOB_NOSORT@*/
401 /*@constant int GLOB_DOOFFS@*/
402 /*@constant int GLOB_NOCHECK@*/
403 /*@constant int GLOB_APPEND@*/
404 /*@constant int GLOB_NOESCAPE@*/
405 /*@constant int GLOB_PERIOD@*/
408 /*@constant int GLOB_MAGCHAR@*/
409 /*@constant int GLOB_ALTDIRFUNC@*/
410 /*@constant int GLOB_BRACE@*/
411 /*@constant int GLOB_NOMAGIC@*/
412 /*@constant int GLOB_TILDE@*/
413 /*@constant int GLOB_ONLYDIR@*/
414 /*@constant int GLOB_TILDE_CHECK@*/
417 /*@constant int GLOB_FLAGS@*/
419 /*@constant int GLOB_NOSPACE@*/
420 /*@constant int GLOB_ABORTED@*/
421 /*@constant int GLOB_NOMATCH@*/
422 /*@constant int GLOB_NOSYS@*/
424 /*@constant int GLOB_ABEND@*/
429 extern int glob (const char *pattern, int flags,
430 int (*errfunc) (const char *, int),
431 /*@out@*/ glob_t *pglob)
432 /*@globals errno, fileSystem @*/
433 /*@modifies *pglob, errno, fileSystem @*/;
434 /* XXX only annotation is a white lie */
435 extern void globfree (/*@only@*/ glob_t *pglob)
436 /*@modifies *pglob @*/;
438 extern int glob_pattern_p (const char *pattern, int quote)
444 /*@constant int FNM_PATHNAME@*/
445 /*@constant int FNM_NOESCAPE@*/
446 /*@constant int FNM_PERIOD@*/
449 /*@constant int FNM_FILE_NAME@*/ /* GNU extension */
450 /*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
451 /*@constant int FNM_CASEFOLD@*/ /* GNU extension */
452 /*@constant int FNM_EXTMATCH@*/ /* GNU extension */
455 /*@constant int FNM_NOMATCH@*/
458 /*@constant int FNM_NOSYS@*/ /* X/Open */
463 extern int fnmatch (const char *pattern, const char *string, int flags)
465 /*@=declundef =incondefs @*/
469 #define S_IFSOCK (0xc000)
473 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
477 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
485 #define realloc(ptr,size) myrealloc(ptr,size)
486 extern void *myrealloc(void *, size_t);
490 extern int setenv(const char *name, const char *value, int replace);
491 extern void unsetenv(const char *name);
494 #if HAVE_SYS_SOCKET_H
495 #include <sys/types.h>
496 #include <sys/socket.h>
499 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
500 #include <sys/select.h>
503 /* Solaris <= 2.6 limits getpass return to only 8 chars */
504 #if HAVE_GETPASSPHRASE
505 #define getpass getpassphrase
512 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
513 # define GETMNTENT_ONE 0
514 # define GETMNTENT_TWO 0
515 # if HAVE_SYS_MNTCTL_H
516 # include <sys/mntctl.h>
518 # if HAVE_SYS_VMOUNT_H
519 # include <sys/vmount.h>
521 # if HAVE_SYS_MOUNT_H
522 # include <sys/mount.h>
524 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
528 # define our_mntent struct mntent
529 # define our_mntdir mnt_dir
530 # elif HAVE_STRUCT_MNTTAB
536 struct our_mntent *getmntent(FILE *filep);
537 # define our_mntent struct our_mntent
543 struct our_mntent *getmntent(FILE *filep);
544 # define our_mntent struct our_mntent
546 # define GETMNTENT_ONE 1
547 # define GETMNTENT_TWO 0
548 #elif HAVE_SYS_MNTTAB_H
550 # include <sys/mnttab.h>
551 # define GETMNTENT_ONE 0
552 # define GETMNTENT_TWO 1
553 # define our_mntent struct mnttab
554 # define our_mntdir mnt_mountp
555 #else /* if !HAVE_MNTCTL */
556 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
560 #define MOUNTED "/etc/mnttab"
562 #endif /* H_SYSTEM */