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 getcon(_c) (-1)
305 #define getexeccon(_c) (-1)
306 #define setexeccon(_c) (-1)
308 #define security_check_context(_c) (0)
309 #define security_getenforce() (0)
311 #define is_selinux_enabled() (-1)
314 #if defined(__LCLINT__)
316 extern void freecon(/*@only@*/ security_context_t con)
319 extern int getfilecon(const char *path, /*@out@*/ security_context_t *con)
320 /*@modifies *con @*/;
321 extern int lgetfilecon(const char *path, /*@out@*/ security_context_t *con)
322 /*@modifies *con @*/;
323 extern int fgetfilecon(int fd, /*@out@*/ security_context_t *con)
324 /*@modifies *con @*/;
326 extern int setfilecon(const char *path, security_context_t con)
327 /*@globals fileSystem @*/
328 /*@modifies fileSystem @*/;
329 extern int lsetfilecon(const char *path, security_context_t con)
330 /*@globals fileSystem @*/
331 /*@modifies fileSystem @*/;
332 extern int fsetfilecon(int fd, security_context_t con)
333 /*@globals fileSystem @*/
334 /*@modifies fileSystem @*/;
336 extern int getcon(/*@out@*/ security_context_t *con)
337 /*@modifies *con @*/;
338 extern int getexeccon(/*@out@*/ security_context_t *con)
339 /*@modifies *con @*/;
340 extern int setexeccon(security_context_t con)
341 /*@globals fileSystem @*/
342 /*@modifies fileSystem @*/;
344 extern int security_check_context(security_context_t con)
345 /*@globals fileSystem @*/
346 /*@modifies fileSystem @*/;
347 extern int security_getenforce(void)
348 /*@globals fileSystem @*/
349 /*@modifies fileSystem @*/;
351 extern int is_selinux_enabled(void)
352 /*@globals fileSystem @*/
353 /*@modifies fileSystem @*/;
357 /*@-declundef -incondefs @*/ /* FIX: these are macros */
360 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
362 /*@ensures maxSet(result) == (size - 1) @*/
363 /*@modifies errno @*/;
367 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
368 /*@ensures maxSet(result) == (nmemb - 1) @*/
372 * @todo Annotate ptr with returned/out.
374 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
376 /*@ensures maxSet(result) == (size - 1) @*/
377 /*@modifies *ptr @*/;
381 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
383 /*@=declundef =incondefs @*/
387 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
392 #if defined(__LCLINT__)
393 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
397 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
398 MCHECK_OK, /* Block is fine. */
399 MCHECK_FREE, /* Block freed twice. */
400 MCHECK_HEAD, /* Memory before the block was clobbered. */
401 MCHECK_TAIL /* Memory after the block was clobbered. */
405 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
406 /*@globals internalState@*/
407 /*@modifies internalState @*/;
408 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
409 /*@globals internalState@*/
410 /*@modifies internalState @*/;
411 extern void mcheck_check_all (void)
412 /*@globals internalState@*/
413 /*@modifies internalState @*/;
414 extern enum mcheck_status mprobe (void *__ptr)
415 /*@globals internalState@*/
416 /*@modifies internalState @*/;
417 extern void mtrace (void)
418 /*@globals internalState@*/
419 /*@modifies internalState @*/;
420 extern void muntrace (void)
421 /*@globals internalState@*/
422 /*@modifies internalState @*/;
423 /*@=declundef =incondefs @*/
424 #endif /* defined(__LCLINT__) */
426 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
427 #if defined(__GNUC__)
428 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
429 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
430 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
431 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
432 #endif /* defined(__GNUC__) */
433 #endif /* HAVE_MCHECK_H */
435 /* Retrofit glibc __progname */
436 #if defined __GLIBC__ && __GLIBC__ >= 2
437 #if __GLIBC_MINOR__ >= 1
438 #define __progname __assert_program_name
440 #define setprogname(pn)
442 #define __progname program_name
443 #define setprogname(pn) \
444 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
445 else __progname = pn; \
449 const char *__progname;
459 /* Take care of NLS matters. */
465 # define setlocale(Category, Locale) /* empty */
468 #if ENABLE_NLS && !defined(__LCLINT__)
469 # include <libintl.h>
470 # define _(Text) gettext (Text)
472 # undef bindtextdomain
473 # define bindtextdomain(Domain, Directory) /* empty */
475 # define textdomain(Domain) /* empty */
476 # define _(Text) Text
478 # define dgettext(DomainName, Text) Text
481 #define N_(Text) Text
483 /* ============== from misc/miscfn.h */
485 #if !defined(USE_GNU_GLOB)
499 #include "misc/glob.h"
500 #include "misc/fnmatch.h"
504 #if defined(__LCLINT__)
505 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
507 typedef /*@concrete@*/ struct
514 void (*gl_closedir) (void *);
516 struct dirent *(*gl_readdir) (void *);
518 void *(*gl_readdir) (void *);
520 ptr_t (*gl_opendir) (const char *);
522 int (*gl_lstat) (const char *restrict, struct stat *restrict);
523 int (*gl_stat) (const char *restrict, struct stat *restrict);
525 int (*gl_lstat) (const char *restrict, void *restrict);
526 int (*gl_stat) (const char *restrict, void *restrict);
533 /*@constant int GLOB_ERR@*/
534 /*@constant int GLOB_MARK@*/
535 /*@constant int GLOB_NOSORT@*/
536 /*@constant int GLOB_DOOFFS@*/
537 /*@constant int GLOB_NOCHECK@*/
538 /*@constant int GLOB_APPEND@*/
539 /*@constant int GLOB_NOESCAPE@*/
540 /*@constant int GLOB_PERIOD@*/
543 /*@constant int GLOB_MAGCHAR@*/
544 /*@constant int GLOB_ALTDIRFUNC@*/
545 /*@constant int GLOB_BRACE@*/
546 /*@constant int GLOB_NOMAGIC@*/
547 /*@constant int GLOB_TILDE@*/
548 /*@constant int GLOB_ONLYDIR@*/
549 /*@constant int GLOB_TILDE_CHECK@*/
552 /*@constant int GLOB_FLAGS@*/
554 /*@constant int GLOB_NOSPACE@*/
555 /*@constant int GLOB_ABORTED@*/
556 /*@constant int GLOB_NOMATCH@*/
557 /*@constant int GLOB_NOSYS@*/
559 /*@constant int GLOB_ABEND@*/
564 /*@-type@*/ /* XXX glob64_t */
565 extern int glob (const char *__pattern, int __flags,
566 int (*__errfunc) (const char *, int),
567 /*@out@*/ glob_t *__pglob)
568 /*@globals errno, fileSystem @*/
569 /*@modifies *__pglob, errno, fileSystem @*/;
570 /* XXX only annotation is a white lie */
571 extern void globfree (/*@only@*/ glob_t *__pglob)
572 /*@modifies *__pglob @*/;
575 extern int glob_pattern_p (const char *__pattern, int __quote)
581 /*@constant int FNM_PATHNAME@*/
582 /*@constant int FNM_NOESCAPE@*/
583 /*@constant int FNM_PERIOD@*/
586 /*@constant int FNM_FILE_NAME@*/ /* GNU extension */
587 /*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
588 /*@constant int FNM_CASEFOLD@*/ /* GNU extension */
589 /*@constant int FNM_EXTMATCH@*/ /* GNU extension */
592 /*@constant int FNM_NOMATCH@*/
595 /*@constant int FNM_NOSYS@*/ /* X/Open */
600 extern int fnmatch (const char *pattern, const char *string, int flags)
602 /*@=declundef =incondefs @*/
606 #define S_IFSOCK (0xc000)
610 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
614 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
622 #define realloc(ptr,size) myrealloc(ptr,size)
623 extern void *myrealloc(void *, size_t);
627 extern int setenv(const char *name, const char *value, int replace);
628 extern void unsetenv(const char *name);
631 #if HAVE_SYS_SOCKET_H
632 #include <sys/types.h>
633 #include <sys/socket.h>
639 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
640 #include <sys/select.h>
644 /* Solaris <= 2.6 limits getpass return to only 8 chars */
645 #if HAVE_GETPASSPHRASE
646 #define getpass getpassphrase
653 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
654 # define GETMNTENT_ONE 0
655 # define GETMNTENT_TWO 0
656 # if HAVE_SYS_MNTCTL_H
657 # include <sys/mntctl.h>
659 # if HAVE_SYS_VMOUNT_H
660 # include <sys/vmount.h>
662 # if HAVE_SYS_MOUNT_H
663 # include <sys/mount.h>
665 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
669 # define our_mntent struct mntent
670 # define our_mntdir mnt_dir
671 # elif HAVE_STRUCT_MNTTAB
677 struct our_mntent *getmntent(FILE *filep);
678 # define our_mntent struct our_mntent
684 struct our_mntent *getmntent(FILE *filep);
685 # define our_mntent struct our_mntent
687 # define GETMNTENT_ONE 1
688 # define GETMNTENT_TWO 0
689 #elif HAVE_SYS_MNTTAB_H
691 # include <sys/mnttab.h>
692 # define GETMNTENT_ONE 0
693 # define GETMNTENT_TWO 1
694 # define our_mntent struct mnttab
695 # define our_mntdir mnt_mountp
696 #else /* if !HAVE_MNTCTL */
697 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
701 #define MOUNTED "/etc/mnttab"
704 #if defined(__LCLINT__)
705 #define FILE_RCSID(id)
707 #define FILE_RCSID(id) \
708 static inline const char *rcsid(const char *p) { \
709 return rcsid(p = id); \
713 #endif /* H_SYSTEM */