12 #include <sys/types.h>
17 #ifdef HAVE_SYS_PARAM_H
18 #include <sys/param.h>
21 /* <unistd.h> should be included before any preprocessor test
25 #if !defined(__GLIBC__)
27 #include <crt_externs.h>
28 #define environ (*_NSGetEnviron())
30 extern char ** environ;
31 #endif /* __APPLE__ */
35 #if TIME_WITH_SYS_TIME
36 # include <sys/time.h>
40 # include <sys/time.h>
47 extern time_t timezone;
50 /* Since major is a function on SVR4, we can't use `ifndef major'. */
52 #include <sys/mkdev.h>
55 #if MAJOR_IN_SYSMACROS
56 #include <sys/sysmacros.h>
59 #ifdef major /* Might be defined in sys/types.h. */
64 #define major(dev) (((dev) >> 8) & 0xff)
65 #define minor(dev) ((dev) & 0xff)
66 #define makedev(maj, min) (((maj) << 8) | (min))
75 # if !STDC_HEADERS && HAVE_MEMORY_H
84 #if !defined(HAVE_STPCPY)
85 char * stpcpy(/*@out@*/ char * dest, const char * src);
88 #if !defined(HAVE_STPNCPY)
89 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
99 #if HAVE_ERROR && HAVE_ERROR_H
103 #if HAVE___SECURE_GETENV
104 #define getenv(_s) __secure_getenv(_s)
108 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
109 #define getopt system_getopt
110 /*@=macrounrecog =incondefs =globuse =mustmod @*/
111 /*@-skipansiheaders@*/
113 /*@=skipansiheaders@*/
115 #else /* not STDC_HEADERS */
116 char *getenv (const char *name);
118 char *realpath(const char *path, char resolved_path []);
120 #endif /* STDC_HEADERS */
122 /* XXX solaris2.5.1 has not */
123 #if !defined(EXIT_FAILURE)
124 #define EXIT_FAILURE 1
130 #include <sys/file.h>
133 #if !defined(SEEK_SET)
147 # define NLENGTH(direct) (strlen((direct)->d_name))
148 #else /* not HAVE_DIRENT_H */
149 # define dirent direct
150 # define NLENGTH(direct) ((direct)->d_namlen)
151 # ifdef HAVE_SYS_NDIR_H
152 # include <sys/ndir.h>
153 # endif /* HAVE_SYS_NDIR_H */
154 # ifdef HAVE_SYS_DIR_H
155 # include <sys/dir.h>
156 # endif /* HAVE_SYS_DIR_H */
159 # endif /* HAVE_NDIR_H */
160 #endif /* HAVE_DIRENT_H */
164 # define alloca __builtin_alloca
166 # ifdef HAVE_ALLOCA_H
170 /* AIX alloca decl has to be the first thing in the file, bletch! */
179 #include <sys/mman.h>
182 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
183 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
184 #include <sys/resource.h>
187 #if HAVE_SYS_UTSNAME_H
188 #include <sys/utsname.h>
192 #include <sys/wait.h>
218 #include <selinux/selinux.h>
220 typedef char * security_context_t;
224 #define getfilecon(_fn, _c) (-1)
225 #define lgetfilecon(_fn, _c) (-1)
226 #define fgetfilecon(_fd, _c) (-1)
228 #define setfilecon(_fn, _c) (-1)
229 #define lsetfilecon(_fn, _c) (-1)
230 #define fsetfilecon(_fd, _c) (-1)
232 #define security_check_context(_c) (0)
234 #define is_selinux_enabled() (-1)
236 #define matchpathcon_init(_fn) (-1)
237 #define matchpathcon_fini() (0)
238 #define matchpathcon(_fn, _fm, _c) (-1)
240 #define rpm_execcon(_v, _fn, _av, _envp) (0)
243 /*@-declundef -incondefs @*/ /* FIX: these are macros */
246 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
248 /*@ensures maxSet(result) == (size - 1) @*/
249 /*@modifies errno @*/;
253 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
254 /*@ensures maxSet(result) == (nmemb - 1) @*/
258 * @todo Annotate ptr with returned/out.
260 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
262 /*@ensures maxSet(result) == (size - 1) @*/
263 /*@modifies *ptr @*/;
267 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
269 /*@=declundef =incondefs @*/
273 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
278 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
279 #if defined(__GNUC__)
280 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
281 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
282 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
283 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
284 #endif /* defined(__GNUC__) */
285 #endif /* HAVE_MCHECK_H */
287 /* Retrofit glibc __progname */
288 #if defined __GLIBC__ && __GLIBC__ >= 2
289 #if __GLIBC_MINOR__ >= 1
290 #define __progname __assert_program_name
292 #define setprogname(pn)
294 #define __progname program_name
295 #define setprogname(pn) \
296 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
297 else __progname = pn; \
301 extern const char *__progname;
311 /* Take care of NLS matters. */
317 # define setlocale(Category, Locale) /* empty */
321 # include <libintl.h>
322 # define _(Text) gettext (Text)
324 # undef bindtextdomain
325 # define bindtextdomain(Domain, Directory) /* empty */
327 # define textdomain(Domain) /* empty */
328 # define _(Text) Text
330 # define dgettext(DomainName, Text) Text
333 #define N_(Text) Text
335 /* ============== from misc/miscfn.h */
337 #if !defined(USE_GNU_GLOB)
351 #include "misc/glob.h"
352 #include "misc/fnmatch.h"
357 #define S_IFSOCK (0xc000)
361 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
365 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
373 #define realloc(ptr,size) myrealloc(ptr,size)
374 extern void *myrealloc(void *, size_t);
378 extern int setenv(const char *name, const char *value, int replace);
379 extern void unsetenv(const char *name);
382 #if HAVE_SYS_SOCKET_H
383 #include <sys/types.h>
384 #include <sys/socket.h>
390 #if HAVE_SYS_SELECT_H
391 #include <sys/select.h>
395 /* Solaris <= 2.6 limits getpass return to only 8 chars */
396 #if HAVE_GETPASSPHRASE
397 #define getpass getpassphrase
404 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
405 # define GETMNTENT_ONE 0
406 # define GETMNTENT_TWO 0
407 # if HAVE_SYS_MNTCTL_H
408 # include <sys/mntctl.h>
410 # if HAVE_SYS_VMOUNT_H
411 # include <sys/vmount.h>
413 # if HAVE_SYS_MOUNT_H
414 # include <sys/mount.h>
416 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
420 # define our_mntent struct mntent
421 # define our_mntdir mnt_dir
422 # elif HAVE_STRUCT_MNTTAB
428 struct our_mntent *getmntent(FILE *filep);
429 # define our_mntent struct our_mntent
435 struct our_mntent *getmntent(FILE *filep);
436 # define our_mntent struct our_mntent
438 # define GETMNTENT_ONE 1
439 # define GETMNTENT_TWO 0
440 #elif HAVE_SYS_MNTTAB_H
442 # include <sys/mnttab.h>
443 # define GETMNTENT_ONE 0
444 # define GETMNTENT_TWO 1
445 # define our_mntent struct mnttab
446 # define our_mntdir mnt_mountp
447 #else /* if !HAVE_MNTCTL */
448 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
452 #define MOUNTED "/etc/mnttab"
455 #endif /* H_SYSTEM */