12 #include <sys/types.h>
14 #if defined(__LCLINT__)
16 typedef unsigned int u_int32_t;
17 typedef unsigned short u_int16_t;
18 typedef unsigned char u_int8_t;
19 /*@-incondefs@*/ /* LCLint 3.0.0.15 */
22 /* XXX from /usr/include/bits/sigset.h */
24 # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
27 unsigned long int __val[_SIGSET_NWORDS];
36 #ifdef HAVE_SYS_PARAM_H
37 #include <sys/param.h>
40 /* <unistd.h> should be included before any preprocessor test
44 #if defined(__LCLINT__)
45 /*@-superuser -declundef -incondefs @*/ /* LCL: modifies clause missing */
46 extern int chroot (const char *__path)
47 /*@globals errno, systemState @*/
48 /*@modifies errno, systemState @*/;
49 /*@=superuser =declundef =incondefs @*/
51 #if !defined(__GLIBC__) && !defined(__LCLINT__)
52 extern char ** environ;
56 #if TIME_WITH_SYS_TIME
57 # include <sys/time.h>
61 # include <sys/time.h>
68 extern time_t timezone;
71 /* Since major is a function on SVR4, we can't use `ifndef major'. */
73 #include <sys/mkdev.h>
76 #if MAJOR_IN_SYSMACROS
77 #include <sys/sysmacros.h>
80 #ifdef major /* Might be defined in sys/types.h. */
85 #define major(dev) (((dev) >> 8) & 0xff)
86 #define minor(dev) ((dev) & 0xff)
87 #define makedev(maj, min) (((maj) << 8) | (min))
96 # if !STDC_HEADERS && HAVE_MEMORY_H
101 # include <strings.h>
105 #if !defined(HAVE_STPCPY)
106 char * stpcpy(/*@out@*/ char * dest, const char * src);
109 #if !defined(HAVE_STPNCPY)
110 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
120 #if defined(__LCLINT__)
123 extern void error(int status, int errnum, const char *format, ...)
124 __attribute__ ((__format__ (__printf__, 3, 4)))
125 /*@globals fileSystem @*/
126 /*@modifies fileSystem @*/;
129 #if HAVE_ERROR && HAVE_ERROR_H
134 #if HAVE___SECURE_GETENV && !defined(__LCLINT__)
135 #define getenv(_s) __secure_getenv(_s)
139 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
140 #define getopt system_getopt
141 /*@=macrounrecog =incondefs =globuse =mustmod @*/
142 /*@-skipansiheaders@*/
144 /*@=skipansiheaders@*/
146 #if defined(__LCLINT__)
147 /*@-declundef -incondefs @*/ /* LCL: modifies clause missing */
148 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
149 /*@globals errno, fileSystem @*/
150 /*@requires maxSet(resolved_name) >= (PATH_MAX - 1); @*/
151 /*@modifies *resolved_name, errno, fileSystem @*/;
152 /*@=declundef =incondefs @*/
154 #else /* not STDC_HEADERS */
155 char *getenv (const char *name);
157 char *realpath(const char *path, char resolved_path []);
159 #endif /* STDC_HEADERS */
161 /* XXX solaris2.5.1 has not */
162 #if !defined(EXIT_FAILURE)
163 #define EXIT_FAILURE 1
169 #include <sys/file.h>
172 #if !defined(SEEK_SET) && !defined(__LCLINT__)
177 #if !defined(F_OK) && !defined(__LCLINT__)
186 # define NLENGTH(direct) (strlen((direct)->d_name))
187 #else /* not HAVE_DIRENT_H */
188 # define dirent direct
189 # define NLENGTH(direct) ((direct)->d_namlen)
190 # ifdef HAVE_SYS_NDIR_H
191 # include <sys/ndir.h>
192 # endif /* HAVE_SYS_NDIR_H */
193 # ifdef HAVE_SYS_DIR_H
194 # include <sys/dir.h>
195 # endif /* HAVE_SYS_DIR_H */
198 # endif /* HAVE_NDIR_H */
199 #endif /* HAVE_DIRENT_H */
201 #if defined(__LCLINT__)
202 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
203 /*@only@*/ /*@out@*/ void * alloca (size_t __size)
204 /*@ensures maxSet(result) == (__size - 1) @*/
206 /*@=declundef =incondefs @*/
211 # define alloca __builtin_alloca
213 # ifdef HAVE_ALLOCA_H
217 /* AIX alloca decl has to be the first thing in the file, bletch! */
223 #if defined (__GLIBC__) && defined(__LCLINT__)
226 extern __const __int32_t *__ctype_tolower;
228 extern __const __int32_t *__ctype_toupper;
234 #if defined (__GLIBC__) && defined(__LCLINT__)
236 extern int isalnum(int) __THROW /*@*/;
237 extern int iscntrl(int) __THROW /*@*/;
238 extern int isgraph(int) __THROW /*@*/;
239 extern int islower(int) __THROW /*@*/;
240 extern int ispunct(int) __THROW /*@*/;
241 extern int isxdigit(int) __THROW /*@*/;
242 extern int isascii(int) __THROW /*@*/;
243 extern int toascii(int) __THROW /*@*/;
244 extern int _toupper(int) __THROW /*@*/;
245 extern int _tolower(int) __THROW /*@*/;
250 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
251 #include <sys/mman.h>
254 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
255 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
256 #include <sys/resource.h>
259 #if HAVE_SYS_UTSNAME_H
260 #include <sys/utsname.h>
264 #include <sys/wait.h>
285 #if HAVE_MALLOC_H && !defined(__LCLINT__)
289 /*@-declundef -incondefs @*/ /* FIX: these are macros */
292 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
294 /*@ensures maxSet(result) == (size - 1) @*/
295 /*@modifies errno @*/;
299 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
300 /*@ensures maxSet(result) == (nmemb - 1) @*/
304 * @todo Annotate ptr with returned/out.
306 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
308 /*@ensures maxSet(result) == (size - 1) @*/
309 /*@modifies *ptr @*/;
313 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
315 /*@=declundef =incondefs @*/
319 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
324 #if defined(__LCLINT__)
325 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
329 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
330 MCHECK_OK, /* Block is fine. */
331 MCHECK_FREE, /* Block freed twice. */
332 MCHECK_HEAD, /* Memory before the block was clobbered. */
333 MCHECK_TAIL /* Memory after the block was clobbered. */
337 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
338 /*@globals internalState@*/
339 /*@modifies internalState @*/;
340 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
341 /*@globals internalState@*/
342 /*@modifies internalState @*/;
343 extern void mcheck_check_all (void)
344 /*@globals internalState@*/
345 /*@modifies internalState @*/;
346 extern enum mcheck_status mprobe (void *__ptr)
347 /*@globals internalState@*/
348 /*@modifies internalState @*/;
349 extern void mtrace (void)
350 /*@globals internalState@*/
351 /*@modifies internalState @*/;
352 extern void muntrace (void)
353 /*@globals internalState@*/
354 /*@modifies internalState @*/;
355 /*@=declundef =incondefs @*/
356 #endif /* defined(__LCLINT__) */
358 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
359 #if defined(__GNUC__)
360 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
361 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
362 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
363 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
364 #endif /* defined(__GNUC__) */
365 #endif /* HAVE_MCHECK_H */
367 /* Retrofit glibc __progname */
368 #if defined __GLIBC__ && __GLIBC__ >= 2
369 #if __GLIBC_MINOR__ >= 1
370 #define __progname __assert_program_name
372 #define setprogname(pn)
374 #define __progname program_name
375 #define setprogname(pn) \
376 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
377 else __progname = pn; \
381 const char *__progname;
391 /* Take care of NLS matters. */
397 # define setlocale(Category, Locale) /* empty */
400 #if ENABLE_NLS && !defined(__LCLINT__)
401 # include <libintl.h>
402 # define _(Text) gettext (Text)
404 # undef bindtextdomain
405 # define bindtextdomain(Domain, Directory) /* empty */
407 # define textdomain(Domain) /* empty */
408 # define _(Text) Text
410 # define dgettext(DomainName, Text) Text
413 #define N_(Text) Text
415 /* ============== from misc/miscfn.h */
417 #if !defined(USE_GNU_GLOB)
431 #include "misc/glob.h"
432 #include "misc/fnmatch.h"
436 #if defined(__LCLINT__)
437 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
439 typedef /*@concrete@*/ struct
446 void (*gl_closedir) (void *);
448 struct dirent *(*gl_readdir) (void *);
450 void *(*gl_readdir) (void *);
452 ptr_t (*gl_opendir) (const char *);
454 int (*gl_lstat) (const char *restrict, struct stat *restrict);
455 int (*gl_stat) (const char *restrict, struct stat *restrict);
457 int (*gl_lstat) (const char *restrict, void *restrict);
458 int (*gl_stat) (const char *restrict, void *restrict);
465 /*@constant int GLOB_ERR@*/
466 /*@constant int GLOB_MARK@*/
467 /*@constant int GLOB_NOSORT@*/
468 /*@constant int GLOB_DOOFFS@*/
469 /*@constant int GLOB_NOCHECK@*/
470 /*@constant int GLOB_APPEND@*/
471 /*@constant int GLOB_NOESCAPE@*/
472 /*@constant int GLOB_PERIOD@*/
475 /*@constant int GLOB_MAGCHAR@*/
476 /*@constant int GLOB_ALTDIRFUNC@*/
477 /*@constant int GLOB_BRACE@*/
478 /*@constant int GLOB_NOMAGIC@*/
479 /*@constant int GLOB_TILDE@*/
480 /*@constant int GLOB_ONLYDIR@*/
481 /*@constant int GLOB_TILDE_CHECK@*/
484 /*@constant int GLOB_FLAGS@*/
486 /*@constant int GLOB_NOSPACE@*/
487 /*@constant int GLOB_ABORTED@*/
488 /*@constant int GLOB_NOMATCH@*/
489 /*@constant int GLOB_NOSYS@*/
491 /*@constant int GLOB_ABEND@*/
496 extern int glob (const char *pattern, int flags,
497 int (*errfunc) (const char *, int),
498 /*@out@*/ glob_t *pglob)
499 /*@globals errno, fileSystem @*/
500 /*@modifies *pglob, errno, fileSystem @*/;
501 /* XXX only annotation is a white lie */
502 extern void globfree (/*@only@*/ glob_t *pglob)
503 /*@modifies *pglob @*/;
505 extern int glob_pattern_p (const char *pattern, int quote)
511 /*@constant int FNM_PATHNAME@*/
512 /*@constant int FNM_NOESCAPE@*/
513 /*@constant int FNM_PERIOD@*/
516 /*@constant int FNM_FILE_NAME@*/ /* GNU extension */
517 /*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
518 /*@constant int FNM_CASEFOLD@*/ /* GNU extension */
519 /*@constant int FNM_EXTMATCH@*/ /* GNU extension */
522 /*@constant int FNM_NOMATCH@*/
525 /*@constant int FNM_NOSYS@*/ /* X/Open */
530 extern int fnmatch (const char *pattern, const char *string, int flags)
532 /*@=declundef =incondefs @*/
536 #define S_IFSOCK (0xc000)
540 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
544 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
552 #define realloc(ptr,size) myrealloc(ptr,size)
553 extern void *myrealloc(void *, size_t);
557 extern int setenv(const char *name, const char *value, int replace);
558 extern void unsetenv(const char *name);
561 #if HAVE_SYS_SOCKET_H
562 #include <sys/types.h>
563 #include <sys/socket.h>
566 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
567 #include <sys/select.h>
570 /* Solaris <= 2.6 limits getpass return to only 8 chars */
571 #if HAVE_GETPASSPHRASE
572 #define getpass getpassphrase
579 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
580 # define GETMNTENT_ONE 0
581 # define GETMNTENT_TWO 0
582 # if HAVE_SYS_MNTCTL_H
583 # include <sys/mntctl.h>
585 # if HAVE_SYS_VMOUNT_H
586 # include <sys/vmount.h>
588 # if HAVE_SYS_MOUNT_H
589 # include <sys/mount.h>
591 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
595 # define our_mntent struct mntent
596 # define our_mntdir mnt_dir
597 # elif HAVE_STRUCT_MNTTAB
603 struct our_mntent *getmntent(FILE *filep);
604 # define our_mntent struct our_mntent
610 struct our_mntent *getmntent(FILE *filep);
611 # define our_mntent struct our_mntent
613 # define GETMNTENT_ONE 1
614 # define GETMNTENT_TWO 0
615 #elif HAVE_SYS_MNTTAB_H
617 # include <sys/mnttab.h>
618 # define GETMNTENT_ONE 0
619 # define GETMNTENT_TWO 1
620 # define our_mntent struct mnttab
621 # define our_mntdir mnt_mountp
622 #else /* if !HAVE_MNTCTL */
623 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
627 #define MOUNTED "/etc/mnttab"
630 #if defined(__LCLINT__)
631 #define FILE_RCSID(id)
633 #define FILE_RCSID(id) \
634 static inline const char *rcsid(const char *p) { \
635 return rcsid(p = id); \
639 #endif /* H_SYSTEM */