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>
46 /* Since major is a function on SVR4, we can't use `ifndef major'. */
48 #include <sys/mkdev.h>
51 #if MAJOR_IN_SYSMACROS
52 #include <sys/sysmacros.h>
55 #ifdef major /* Might be defined in sys/types.h. */
60 #define major(dev) (((dev) >> 8) & 0xff)
61 #define minor(dev) ((dev) & 0xff)
62 #define makedev(maj, min) (((maj) << 8) | (min))
71 # if !STDC_HEADERS && HAVE_MEMORY_H
80 #if !defined(HAVE_STPCPY)
81 char * stpcpy(char * dest, const char * src);
84 #if !defined(HAVE_STPNCPY)
85 char * stpncpy(char * dest, const char * src, size_t n);
93 #if HAVE_ERROR && HAVE_ERROR_H
97 #if HAVE___SECURE_GETENV
98 #define getenv(_s) __secure_getenv(_s)
103 #define getopt system_getopt
106 #else /* not STDC_HEADERS */
107 char *getenv (const char *name);
109 char *realpath(const char *path, char resolved_path []);
111 #endif /* STDC_HEADERS */
113 /* XXX solaris2.5.1 has not */
114 #if !defined(EXIT_FAILURE)
115 #define EXIT_FAILURE 1
121 #include <sys/file.h>
124 #if !defined(SEEK_SET)
138 # define NLENGTH(direct) (strlen((direct)->d_name))
139 #else /* not HAVE_DIRENT_H */
140 # define dirent direct
141 # define NLENGTH(direct) ((direct)->d_namlen)
142 # ifdef HAVE_SYS_NDIR_H
143 # include <sys/ndir.h>
144 # endif /* HAVE_SYS_NDIR_H */
145 # ifdef HAVE_SYS_DIR_H
146 # include <sys/dir.h>
147 # endif /* HAVE_SYS_DIR_H */
150 # endif /* HAVE_NDIR_H */
151 #endif /* HAVE_DIRENT_H */
156 #include <sys/mman.h>
159 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
160 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
161 #include <sys/resource.h>
164 #if HAVE_SYS_UTSNAME_H
165 #include <sys/utsname.h>
169 #include <sys/wait.h>
185 #ifdef _POSIX_PATH_MAX
186 #define PATH_MAX _POSIX_PATH_MAX
187 #elif defined MAXPATHLEN
188 #define PATH_MAX MAXPATHLEN
203 #include <selinux/selinux.h>
205 typedef char * security_context_t;
209 #define getfilecon(_fn, _c) (-1)
210 #define lgetfilecon(_fn, _c) (-1)
211 #define fgetfilecon(_fd, _c) (-1)
213 #define setfilecon(_fn, _c) (-1)
214 #define lsetfilecon(_fn, _c) (-1)
215 #define fsetfilecon(_fd, _c) (-1)
217 #define security_check_context(_c) (0)
219 #define is_selinux_enabled() (0)
221 #define matchpathcon_init(_fn) (-1)
222 #define matchpathcon_fini() (0)
223 #define matchpathcon(_fn, _fm, _c) (-1)
225 #define rpm_execcon(_v, _fn, _av, _envp) (0)
229 * Wrapper to free(3), permit NULL, return NULL.
230 * @param p memory to free
231 * @return NULL always
234 void * _free(void * p)
236 if (p != NULL) free(p);
241 #include <sys/capability.h>
243 typedef void * cap_t;
247 #include <acl/libacl.h>
251 * Wrapper to free(3), permit NULL, return NULL.
252 * For documenting cases where const is used to protect long-lived
253 * non-const data that's supposed to be freed.
254 * @param p memory to free
255 * @return NULL always
258 void * _constfree(const void * p)
260 if (p != NULL) free((void *)p);
264 /* FIX: these are macros */
267 void * xmalloc (size_t size);
271 void * xcalloc (size_t nmemb, size_t size);
274 * @todo Annotate ptr with returned/out.
276 void * xrealloc (void * ptr,
281 char * xstrdup (const char *str);
285 void * vmefail(size_t size);
289 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
290 #if defined(__GNUC__)
291 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
292 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
293 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
294 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
295 #endif /* defined(__GNUC__) */
296 #endif /* HAVE_MCHECK_H */
298 /* Retrofit glibc __progname */
299 #if defined __GLIBC__ && __GLIBC__ >= 2
300 #if __GLIBC_MINOR__ >= 1
301 #define __progname __assert_program_name
303 #define setprogname(pn)
305 #define __progname program_name
306 #define setprogname(pn) \
307 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
308 else __progname = pn; \
311 extern const char *__progname;
321 /* Take care of NLS matters. */
327 # define setlocale(Category, Locale) /* empty */
331 # include <libintl.h>
332 # define _(Text) dgettext (PACKAGE, Text)
334 # undef bindtextdomain
335 # define bindtextdomain(Domain, Directory) /* empty */
337 # define textdomain(Domain) /* empty */
338 # define _(Text) Text
340 # define dgettext(DomainName, Text) Text
343 #define N_(Text) Text
345 /* ============== from misc/miscfn.h */
347 #if !defined(USE_GNU_GLOB)
356 #include "misc/glob.h"
357 #include "misc/fnmatch.h"
361 #define S_IFSOCK (0xc000)
365 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
369 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
377 #define realloc(ptr,size) myrealloc(ptr,size)
378 extern void *myrealloc(void *, size_t);
382 extern int setenv(const char *name, const char *value, int replace);
383 extern void unsetenv(const char *name);
386 #if HAVE_SYS_SOCKET_H
387 #include <sys/types.h>
388 #include <sys/socket.h>
394 #if HAVE_SYS_SELECT_H
395 #include <sys/select.h>
399 /* Solaris <= 2.6 limits getpass return to only 8 chars */
400 #if HAVE_GETPASSPHRASE
401 #define getpass getpassphrase
408 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
409 # define GETMNTENT_ONE 0
410 # define GETMNTENT_TWO 0
411 # if HAVE_SYS_MNTCTL_H
412 # include <sys/mntctl.h>
414 # if HAVE_SYS_VMOUNT_H
415 # include <sys/vmount.h>
417 # if HAVE_SYS_MOUNT_H
418 # include <sys/mount.h>
420 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
424 # define our_mntent struct mntent
425 # define our_mntdir mnt_dir
426 # elif HAVE_STRUCT_MNTTAB
432 struct our_mntent *getmntent(FILE *filep);
433 # define our_mntent struct our_mntent
439 struct our_mntent *getmntent(FILE *filep);
440 # define our_mntent struct our_mntent
442 # define GETMNTENT_ONE 1
443 # define GETMNTENT_TWO 0
444 #elif HAVE_SYS_MNTTAB_H
446 # include <sys/mnttab.h>
447 # define GETMNTENT_ONE 0
448 # define GETMNTENT_TWO 1
449 # define our_mntent struct mnttab
450 # define our_mntdir mnt_mountp
451 #else /* if !HAVE_MNTCTL */
452 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
456 #define MOUNTED "/etc/mnttab"
459 #endif /* H_SYSTEM */