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 /*@modifies errno, systemState @*/;
28 /*@=superuser =declundef =incondefs @*/
32 #if TIME_WITH_SYS_TIME
33 # include <sys/time.h>
37 # include <sys/time.h>
44 extern time_t timezone;
47 #if defined(__LCLINT__)
48 typedef unsigned int u_int32_t;
49 typedef unsigned short u_int16_t;
50 typedef unsigned char u_int8_t;
51 /*@-incondefs@*/ /* LCLint 3.0.0.15 */
56 /* Since major is a function on SVR4, we can't use `ifndef major'. */
58 #include <sys/mkdev.h>
61 #if MAJOR_IN_SYSMACROS
62 #include <sys/sysmacros.h>
65 #ifdef major /* Might be defined in sys/types.h. */
70 #define major(dev) (((dev) >> 8) & 0xff)
71 #define minor(dev) ((dev) & 0xff)
72 #define makedev(maj, min) (((maj) << 8) | (min))
81 # if !STDC_HEADERS && HAVE_MEMORY_H
90 #if !defined(HAVE_STPCPY)
91 char * stpcpy(/*@out@*/ char * dest, const char * src);
94 #if !defined(HAVE_STPNCPY)
95 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
106 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
107 #define getopt system_getopt
108 /*@=macrounrecog =incondefs =globuse =mustmod @*/
109 /*@-skipansiheaders@*/
111 /*@=skipansiheaders@*/
113 #if defined(__LCLINT__)
114 /*@-declundef -incondefs @*/ /* LCL: modifies clause missing */
115 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
116 /*@requires maxSet(resolved_name) >= (PATH_MAX - 1); @*/
117 /*@modifies *resolved_name, errno, fileSystem @*/;
118 /*@=declundef =incondefs @*/
120 #else /* not STDC_HEADERS */
121 char *getenv (const char *name);
123 char *realpath(const char *path, char resolved_path []);
125 #endif /* STDC_HEADERS */
127 /* XXX solaris2.5.1 has not */
128 #if !defined(EXIT_FAILURE)
129 #define EXIT_FAILURE 1
135 #include <sys/file.h>
138 #if !defined(SEEK_SET) && !defined(__LCLINT__)
143 #if !defined(F_OK) && !defined(__LCLINT__)
152 # define NLENGTH(direct) (strlen((direct)->d_name))
153 #else /* not HAVE_DIRENT_H */
154 # define dirent direct
155 # define NLENGTH(direct) ((direct)->d_namlen)
156 # ifdef HAVE_SYS_NDIR_H
157 # include <sys/ndir.h>
158 # endif /* HAVE_SYS_NDIR_H */
159 # ifdef HAVE_SYS_DIR_H
160 # include <sys/dir.h>
161 # endif /* HAVE_SYS_DIR_H */
164 # endif /* HAVE_NDIR_H */
165 #endif /* HAVE_DIRENT_H */
167 #if defined(__LCLINT__)
168 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
169 /*@only@*/ void * alloca (size_t size)
170 /*@ensures MaxSet(result) == (size - 1) @*/
172 /*@=declundef =incondefs @*/
177 # define alloca __builtin_alloca
179 # ifdef HAVE_ALLOCA_H
183 /* AIX alloca decl has to be the first thing in the file, bletch! */
191 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
192 #include <sys/mman.h>
195 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
196 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
197 #include <sys/resource.h>
200 #if HAVE_SYS_UTSNAME_H
201 #include <sys/utsname.h>
205 #include <sys/wait.h>
226 #if HAVE_MALLOC_H && !defined(__LCLINT__)
230 /*@-declundef -incondefs @*/ /* FIX: these are macros */
233 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
234 /*@ensures MaxSet(result) == (size - 1) @*/
235 /*@modifies errno @*/;
239 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
240 /*@ensures MaxSet(result) == (nmemb - 1) @*/
244 * @todo Annotate ptr with returned/out.
246 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
248 /*@ensures MaxSet(result) == (size - 1) @*/
249 /*@modifies *ptr @*/;
253 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
255 /*@=declundef =incondefs @*/
259 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
264 #if defined(__LCLINT__)
265 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
269 MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
270 MCHECK_OK, /* Block is fine. */
271 MCHECK_FREE, /* Block freed twice. */
272 MCHECK_HEAD, /* Memory before the block was clobbered. */
273 MCHECK_TAIL /* Memory after the block was clobbered. */
277 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
278 /*@globals internalState@*/
279 /*@modifies internalState @*/;
280 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
281 /*@globals internalState@*/
282 /*@modifies internalState @*/;
283 extern void mcheck_check_all (void)
284 /*@globals internalState@*/
285 /*@modifies internalState @*/;
286 extern enum mcheck_status mprobe (void *__ptr)
287 /*@globals internalState@*/
288 /*@modifies internalState @*/;
289 extern void mtrace (void)
290 /*@globals internalState@*/
291 /*@modifies internalState @*/;
292 extern void muntrace (void)
293 /*@globals internalState@*/
294 /*@modifies internalState @*/;
295 /*@=declundef =incondefs @*/
296 #endif /* defined(__LCLINT__) */
298 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
299 #if defined(__GNUC__)
300 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
301 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
302 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
303 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
304 #endif /* defined(__GNUC__) */
305 #endif /* HAVE_MCHECK_H */
307 /* Retrofit glibc __progname */
308 #if defined __GLIBC__ && __GLIBC__ >= 2
309 #if __GLIBC_MINOR__ >= 1
310 #define __progname __assert_program_name
312 #define setprogname(pn)
314 #define __progname program_name
315 #define setprogname(pn) \
316 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
317 else __progname = pn; \
320 const char *__progname;
330 /* Take care of NLS matters. */
336 # define setlocale(Category, Locale) /* empty */
339 #if ENABLE_NLS && !defined(__LCLINT__)
340 # include <libintl.h>
341 # define _(Text) gettext (Text)
343 # undef bindtextdomain
344 # define bindtextdomain(Domain, Directory) /* empty */
346 # define textdomain(Domain) /* empty */
347 # define _(Text) Text
349 # define dgettext(DomainName, Text) Text
352 #define N_(Text) Text
354 /* ============== from misc/miscfn.h */
356 #if !defined(USE_GNU_GLOB)
370 #include "misc/glob.h"
371 #include "misc/fnmatch.h"
375 #if defined(__LCLINT__)
376 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
378 typedef /*@concrete@*/ struct
385 void (*gl_closedir) (void *);
387 struct dirent *(*gl_readdir) (void *);
389 void *(*gl_readdir) (void *);
391 ptr_t (*gl_opendir) (const char *);
393 int (*gl_lstat) (const char *restrict, struct stat *restrict);
394 int (*gl_stat) (const char *restrict, struct stat *restrict);
396 int (*gl_lstat) (const char *restrict, void *restrict);
397 int (*gl_stat) (const char *restrict, void *restrict);
404 /*@constant int GLOB_ERR@*/
405 /*@constant int GLOB_MARK@*/
406 /*@constant int GLOB_NOSORT@*/
407 /*@constant int GLOB_DOOFFS@*/
408 /*@constant int GLOB_NOCHECK@*/
409 /*@constant int GLOB_APPEND@*/
410 /*@constant int GLOB_NOESCAPE@*/
411 /*@constant int GLOB_PERIOD@*/
414 /*@constant int GLOB_MAGCHAR@*/
415 /*@constant int GLOB_ALTDIRFUNC@*/
416 /*@constant int GLOB_BRACE@*/
417 /*@constant int GLOB_NOMAGIC@*/
418 /*@constant int GLOB_TILDE@*/
419 /*@constant int GLOB_ONLYDIR@*/
420 /*@constant int GLOB_TILDE_CHECK@*/
423 /*@constant int GLOB_FLAGS@*/
425 /*@constant int GLOB_NOSPACE@*/
426 /*@constant int GLOB_ABORTED@*/
427 /*@constant int GLOB_NOMATCH@*/
428 /*@constant int GLOB_NOSYS@*/
430 /*@constant int GLOB_ABEND@*/
435 extern int glob (const char *pattern, int flags,
436 int (*errfunc) (const char *, int),
437 /*@out@*/ glob_t *pglob)
438 /*@modifies *pglob, errno, fileSystem @*/;
439 /* XXX only annotation is a white lie */
440 extern void globfree (/*@only@*/ glob_t *pglob)
441 /*@modifies *pglob @*/;
443 extern int glob_pattern_p (const char *pattern, int quote)
449 /*@constant int FNM_PATHNAME@*/
450 /*@constant int FNM_NOESCAPE@*/
451 /*@constant int FNM_PERIOD@*/
454 /*@constant int FNM_FILE_NAME@*/ /* GNU extension */
455 /*@constant int FNM_LEADING_DIR@*/ /* GNU extension */
456 /*@constant int FNM_CASEFOLD@*/ /* GNU extension */
457 /*@constant int FNM_EXTMATCH@*/ /* GNU extension */
460 /*@constant int FNM_NOMATCH@*/
463 /*@constant int FNM_NOSYS@*/ /* X/Open */
468 extern int fnmatch (const char *pattern, const char *string, int flags)
470 /*@=declundef =incondefs @*/
474 #define S_IFSOCK (0xc000)
478 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
482 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
490 #define realloc(ptr,size) myrealloc(ptr,size)
491 extern void *myrealloc(void *, size_t);
495 extern int setenv(const char *name, const char *value, int replace);
496 extern void unsetenv(const char *name);
499 #if HAVE_SYS_SOCKET_H
500 #include <sys/types.h>
501 #include <sys/socket.h>
504 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
505 #include <sys/select.h>
508 /* Solaris <= 2.6 limits getpass return to only 8 chars */
509 #if HAVE_GETPASSPHRASE
510 #define getpass getpassphrase
517 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
518 # define GETMNTENT_ONE 0
519 # define GETMNTENT_TWO 0
520 # if HAVE_SYS_MNTCTL_H
521 # include <sys/mntctl.h>
523 # if HAVE_SYS_VMOUNT_H
524 # include <sys/vmount.h>
526 # if HAVE_SYS_MOUNT_H
527 # include <sys/mount.h>
529 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
533 # define our_mntent struct mntent
534 # define our_mntdir mnt_dir
535 # elif HAVE_STRUCT_MNTTAB
541 struct our_mntent *getmntent(FILE *filep);
542 # define our_mntent struct our_mntent
548 struct our_mntent *getmntent(FILE *filep);
549 # define our_mntent struct our_mntent
551 # define GETMNTENT_ONE 1
552 # define GETMNTENT_TWO 0
553 #elif HAVE_SYS_MNTTAB_H
555 # include <sys/mnttab.h>
556 # define GETMNTENT_ONE 0
557 # define GETMNTENT_TWO 1
558 # define our_mntent struct mnttab
559 # define our_mntdir mnt_mountp
560 #else /* if !HAVE_MNTCTL */
561 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
565 #define MOUNTED "/etc/mnttab"
567 #endif /* H_SYSTEM */