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__)
290 #include <selinux/selinux.h>
292 typedef char * security_context_t;
296 #define getfilecon(_fn, _c) (-1)
297 #define lgetfilecon(_fn, _c) (-1)
298 #define fgetfilecon(_fd, _c) (-1)
300 #define setfilecon(_fn, _c) (-1)
301 #define lsetfilecon(_fn, _c) (-1)
302 #define fsetfilecon(_fd, _c) (-1)
304 #define security_check_context(_c) (0)
306 #define is_selinux_enabled() (-1)
309 #if defined(__LCLINT__)
311 extern void freecon(/*@only@*/ security_context_t con)
314 extern int getfilecon(const char *path, /*@out@*/ security_context_t *con)
315 /*@modifies *con @*/;
316 extern int lgetfilecon(const char *path, /*@out@*/ security_context_t *con)
317 /*@modifies *con @*/;
318 extern int fgetfilecon(int fd, /*@out@*/ security_context_t *con)
319 /*@modifies *con @*/;
321 extern int setfilecon(const char *path, security_context_t con)
322 /*@globals fileSystem @*/
323 /*@modifies fileSystem @*/;
324 extern int lsetfilecon(const char *path, security_context_t con)
325 /*@globals fileSystem @*/
326 /*@modifies fileSystem @*/;
327 extern int fsetfilecon(int fd, security_context_t con)
328 /*@globals fileSystem @*/
329 /*@modifies fileSystem @*/;
331 extern int security_check_context(security_context_t con)
332 /*@globals fileSystem @*/
333 /*@modifies fileSystem @*/;
335 extern int is_selinux_enabled(void)
336 /*@globals fileSystem @*/
337 /*@modifies fileSystem @*/;
341 /*@-declundef -incondefs @*/ /* FIX: these are macros */
344 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
346 /*@ensures maxSet(result) == (size - 1) @*/
347 /*@modifies errno @*/;
351 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
352 /*@ensures maxSet(result) == (nmemb - 1) @*/
356 * @todo Annotate ptr with returned/out.
358 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
360 /*@ensures maxSet(result) == (size - 1) @*/
361 /*@modifies *ptr @*/;
365 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
367 /*@=declundef =incondefs @*/
371 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
376 #if defined(__LCLINT__)
377 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
381 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
382 MCHECK_OK, /* Block is fine. */
383 MCHECK_FREE, /* Block freed twice. */
384 MCHECK_HEAD, /* Memory before the block was clobbered. */
385 MCHECK_TAIL /* Memory after the block was clobbered. */
389 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
390 /*@globals internalState@*/
391 /*@modifies internalState @*/;
392 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
393 /*@globals internalState@*/
394 /*@modifies internalState @*/;
395 extern void mcheck_check_all (void)
396 /*@globals internalState@*/
397 /*@modifies internalState @*/;
398 extern enum mcheck_status mprobe (void *__ptr)
399 /*@globals internalState@*/
400 /*@modifies internalState @*/;
401 extern void mtrace (void)
402 /*@globals internalState@*/
403 /*@modifies internalState @*/;
404 extern void muntrace (void)
405 /*@globals internalState@*/
406 /*@modifies internalState @*/;
407 /*@=declundef =incondefs @*/
408 #endif /* defined(__LCLINT__) */
410 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
411 #if defined(__GNUC__)
412 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
413 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
414 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
415 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
416 #endif /* defined(__GNUC__) */
417 #endif /* HAVE_MCHECK_H */
419 /* Retrofit glibc __progname */
420 #if defined __GLIBC__ && __GLIBC__ >= 2
421 #if __GLIBC_MINOR__ >= 1
422 #define __progname __assert_program_name
424 #define setprogname(pn)
426 #define __progname program_name
427 #define setprogname(pn) \
428 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
429 else __progname = pn; \
433 const char *__progname;
443 /* Take care of NLS matters. */
449 # define setlocale(Category, Locale) /* empty */
452 #if ENABLE_NLS && !defined(__LCLINT__)
453 # include <libintl.h>
454 # define _(Text) gettext (Text)
456 # undef bindtextdomain
457 # define bindtextdomain(Domain, Directory) /* empty */
459 # define textdomain(Domain) /* empty */
460 # define _(Text) Text
462 # define dgettext(DomainName, Text) Text
465 #define N_(Text) Text
467 /* ============== from misc/miscfn.h */
469 #if !defined(USE_GNU_GLOB)
483 #include "misc/glob.h"
484 #include "misc/fnmatch.h"
488 #if defined(__LCLINT__)
489 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
491 typedef /*@concrete@*/ struct
498 void (*gl_closedir) (void *);
500 struct dirent *(*gl_readdir) (void *);
502 void *(*gl_readdir) (void *);
504 ptr_t (*gl_opendir) (const char *);
506 int (*gl_lstat) (const char *restrict, struct stat *restrict);
507 int (*gl_stat) (const char *restrict, struct stat *restrict);
509 int (*gl_lstat) (const char *restrict, void *restrict);
510 int (*gl_stat) (const char *restrict, void *restrict);
517 /*@constant int GLOB_ERR@*/
518 /*@constant int GLOB_MARK@*/
519 /*@constant int GLOB_NOSORT@*/
520 /*@constant int GLOB_DOOFFS@*/
521 /*@constant int GLOB_NOCHECK@*/
522 /*@constant int GLOB_APPEND@*/
523 /*@constant int GLOB_NOESCAPE@*/
524 /*@constant int GLOB_PERIOD@*/
527 /*@constant int GLOB_MAGCHAR@*/
528 /*@constant int GLOB_ALTDIRFUNC@*/
529 /*@constant int GLOB_BRACE@*/
530 /*@constant int GLOB_NOMAGIC@*/
531 /*@constant int GLOB_TILDE@*/
532 /*@constant int GLOB_ONLYDIR@*/
533 /*@constant int GLOB_TILDE_CHECK@*/
536 /*@constant int GLOB_FLAGS@*/
538 /*@constant int GLOB_NOSPACE@*/
539 /*@constant int GLOB_ABORTED@*/
540 /*@constant int GLOB_NOMATCH@*/
541 /*@constant int GLOB_NOSYS@*/
543 /*@constant int GLOB_ABEND@*/
548 extern int glob (const char *pattern, int flags,
549 int (*errfunc) (const char *, int),
550 /*@out@*/ glob_t *pglob)
551 /*@globals errno, fileSystem @*/
552 /*@modifies *pglob, errno, fileSystem @*/;
553 /* XXX only annotation is a white lie */
554 extern void globfree (/*@only@*/ glob_t *pglob)
555 /*@modifies *pglob @*/;
557 extern int glob_pattern_p (const char *pattern, int quote)
563 /*@constant int FNM_PATHNAME@*/
564 /*@constant int FNM_NOESCAPE@*/
565 /*@constant int FNM_PERIOD@*/
568 /*@constant int FNM_FILE_NAME@*/ /* GNU extension */
569 /*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
570 /*@constant int FNM_CASEFOLD@*/ /* GNU extension */
571 /*@constant int FNM_EXTMATCH@*/ /* GNU extension */
574 /*@constant int FNM_NOMATCH@*/
577 /*@constant int FNM_NOSYS@*/ /* X/Open */
582 extern int fnmatch (const char *pattern, const char *string, int flags)
584 /*@=declundef =incondefs @*/
588 #define S_IFSOCK (0xc000)
592 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
596 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
604 #define realloc(ptr,size) myrealloc(ptr,size)
605 extern void *myrealloc(void *, size_t);
609 extern int setenv(const char *name, const char *value, int replace);
610 extern void unsetenv(const char *name);
613 #if HAVE_SYS_SOCKET_H
614 #include <sys/types.h>
615 #include <sys/socket.h>
618 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
619 #include <sys/select.h>
622 /* Solaris <= 2.6 limits getpass return to only 8 chars */
623 #if HAVE_GETPASSPHRASE
624 #define getpass getpassphrase
631 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
632 # define GETMNTENT_ONE 0
633 # define GETMNTENT_TWO 0
634 # if HAVE_SYS_MNTCTL_H
635 # include <sys/mntctl.h>
637 # if HAVE_SYS_VMOUNT_H
638 # include <sys/vmount.h>
640 # if HAVE_SYS_MOUNT_H
641 # include <sys/mount.h>
643 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
647 # define our_mntent struct mntent
648 # define our_mntdir mnt_dir
649 # elif HAVE_STRUCT_MNTTAB
655 struct our_mntent *getmntent(FILE *filep);
656 # define our_mntent struct our_mntent
662 struct our_mntent *getmntent(FILE *filep);
663 # define our_mntent struct our_mntent
665 # define GETMNTENT_ONE 1
666 # define GETMNTENT_TWO 0
667 #elif HAVE_SYS_MNTTAB_H
669 # include <sys/mnttab.h>
670 # define GETMNTENT_ONE 0
671 # define GETMNTENT_TWO 1
672 # define our_mntent struct mnttab
673 # define our_mntdir mnt_mountp
674 #else /* if !HAVE_MNTCTL */
675 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
679 #define MOUNTED "/etc/mnttab"
682 #if defined(__LCLINT__)
683 #define FILE_RCSID(id)
685 #define FILE_RCSID(id) \
686 static inline const char *rcsid(const char *p) { \
687 return rcsid(p = id); \
691 #endif /* H_SYSTEM */