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(char * dest, const char * src);
88 #if !defined(HAVE_STPNCPY)
89 char * stpncpy(char * dest, const char * src, size_t n);
97 #if HAVE_ERROR && HAVE_ERROR_H
101 #if HAVE___SECURE_GETENV
102 #define getenv(_s) __secure_getenv(_s)
107 #define getopt system_getopt
110 #else /* not STDC_HEADERS */
111 char *getenv (const char *name);
113 char *realpath(const char *path, char resolved_path []);
115 #endif /* STDC_HEADERS */
117 /* XXX solaris2.5.1 has not */
118 #if !defined(EXIT_FAILURE)
119 #define EXIT_FAILURE 1
125 #include <sys/file.h>
128 #if !defined(SEEK_SET)
142 # define NLENGTH(direct) (strlen((direct)->d_name))
143 #else /* not HAVE_DIRENT_H */
144 # define dirent direct
145 # define NLENGTH(direct) ((direct)->d_namlen)
146 # ifdef HAVE_SYS_NDIR_H
147 # include <sys/ndir.h>
148 # endif /* HAVE_SYS_NDIR_H */
149 # ifdef HAVE_SYS_DIR_H
150 # include <sys/dir.h>
151 # endif /* HAVE_SYS_DIR_H */
154 # endif /* HAVE_NDIR_H */
155 #endif /* HAVE_DIRENT_H */
159 # define alloca __builtin_alloca
161 # ifdef HAVE_ALLOCA_H
165 /* AIX alloca decl has to be the first thing in the file, bletch! */
174 #include <sys/mman.h>
177 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
178 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
179 #include <sys/resource.h>
182 #if HAVE_SYS_UTSNAME_H
183 #include <sys/utsname.h>
187 #include <sys/wait.h>
211 #include <selinux/selinux.h>
213 typedef char * security_context_t;
217 #define getfilecon(_fn, _c) (-1)
218 #define lgetfilecon(_fn, _c) (-1)
219 #define fgetfilecon(_fd, _c) (-1)
221 #define setfilecon(_fn, _c) (-1)
222 #define lsetfilecon(_fn, _c) (-1)
223 #define fsetfilecon(_fd, _c) (-1)
225 #define security_check_context(_c) (0)
227 #define is_selinux_enabled() (-1)
229 #define matchpathcon_init(_fn) (-1)
230 #define matchpathcon_fini() (0)
231 #define matchpathcon(_fn, _fm, _c) (-1)
233 #define rpm_execcon(_v, _fn, _av, _envp) (0)
237 * Wrapper to free(3), permit NULL, return NULL.
238 * @param p memory to free
239 * @return NULL always
242 void * _free(void * p)
244 if (p != NULL) free(p);
249 * Wrapper to free(3), permit NULL, return NULL.
250 * For documenting cases where const is used to protect long-lived
251 * non-const data that's supposed to be freed.
252 * @param p memory to free
253 * @return NULL always
256 void * _constfree(const void * p)
258 if (p != NULL) free((void *)p);
262 /* FIX: these are macros */
265 void * xmalloc (size_t size);
269 void * xcalloc (size_t nmemb, size_t size);
272 * @todo Annotate ptr with returned/out.
274 void * xrealloc (void * ptr,
279 char * xstrdup (const char *str);
283 void * vmefail(size_t size);
287 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
288 #if defined(__GNUC__)
289 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
290 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
291 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
292 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
293 #endif /* defined(__GNUC__) */
294 #endif /* HAVE_MCHECK_H */
296 /* Retrofit glibc __progname */
297 #if defined __GLIBC__ && __GLIBC__ >= 2
298 #if __GLIBC_MINOR__ >= 1
299 #define __progname __assert_program_name
301 #define setprogname(pn)
303 #define __progname program_name
304 #define setprogname(pn) \
305 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
306 else __progname = pn; \
309 extern const char *__progname;
319 /* Take care of NLS matters. */
325 # define setlocale(Category, Locale) /* empty */
329 # include <libintl.h>
330 # define _(Text) dgettext (PACKAGE, Text)
332 # undef bindtextdomain
333 # define bindtextdomain(Domain, Directory) /* empty */
335 # define textdomain(Domain) /* empty */
336 # define _(Text) Text
338 # define dgettext(DomainName, Text) Text
341 #define N_(Text) Text
343 /* ============== from misc/miscfn.h */
345 #if !defined(USE_GNU_GLOB)
354 #include "misc/glob.h"
355 #include "misc/fnmatch.h"
359 #define S_IFSOCK (0xc000)
363 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
367 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
375 #define realloc(ptr,size) myrealloc(ptr,size)
376 extern void *myrealloc(void *, size_t);
380 extern int setenv(const char *name, const char *value, int replace);
381 extern void unsetenv(const char *name);
384 #if HAVE_SYS_SOCKET_H
385 #include <sys/types.h>
386 #include <sys/socket.h>
392 #if HAVE_SYS_SELECT_H
393 #include <sys/select.h>
397 /* Solaris <= 2.6 limits getpass return to only 8 chars */
398 #if HAVE_GETPASSPHRASE
399 #define getpass getpassphrase
406 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
407 # define GETMNTENT_ONE 0
408 # define GETMNTENT_TWO 0
409 # if HAVE_SYS_MNTCTL_H
410 # include <sys/mntctl.h>
412 # if HAVE_SYS_VMOUNT_H
413 # include <sys/vmount.h>
415 # if HAVE_SYS_MOUNT_H
416 # include <sys/mount.h>
418 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
422 # define our_mntent struct mntent
423 # define our_mntdir mnt_dir
424 # elif HAVE_STRUCT_MNTTAB
430 struct our_mntent *getmntent(FILE *filep);
431 # define our_mntent struct our_mntent
437 struct our_mntent *getmntent(FILE *filep);
438 # define our_mntent struct our_mntent
440 # define GETMNTENT_ONE 1
441 # define GETMNTENT_TWO 0
442 #elif HAVE_SYS_MNTTAB_H
444 # include <sys/mnttab.h>
445 # define GETMNTENT_ONE 0
446 # define GETMNTENT_TWO 1
447 # define our_mntent struct mnttab
448 # define our_mntdir mnt_mountp
449 #else /* if !HAVE_MNTCTL */
450 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
454 #define MOUNTED "/etc/mnttab"
457 #endif /* H_SYSTEM */