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 */
160 #include <sys/mman.h>
163 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
164 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
165 #include <sys/resource.h>
168 #if HAVE_SYS_UTSNAME_H
169 #include <sys/utsname.h>
173 #include <sys/wait.h>
197 #include <selinux/selinux.h>
199 typedef char * security_context_t;
203 #define getfilecon(_fn, _c) (-1)
204 #define lgetfilecon(_fn, _c) (-1)
205 #define fgetfilecon(_fd, _c) (-1)
207 #define setfilecon(_fn, _c) (-1)
208 #define lsetfilecon(_fn, _c) (-1)
209 #define fsetfilecon(_fd, _c) (-1)
211 #define security_check_context(_c) (0)
213 #define is_selinux_enabled() (-1)
215 #define matchpathcon_init(_fn) (-1)
216 #define matchpathcon_fini() (0)
217 #define matchpathcon(_fn, _fm, _c) (-1)
219 #define rpm_execcon(_v, _fn, _av, _envp) (0)
223 * Wrapper to free(3), permit NULL, return NULL.
224 * @param p memory to free
225 * @return NULL always
228 void * _free(void * p)
230 if (p != NULL) free(p);
235 * Wrapper to free(3), permit NULL, return NULL.
236 * For documenting cases where const is used to protect long-lived
237 * non-const data that's supposed to be freed.
238 * @param p memory to free
239 * @return NULL always
242 void * _constfree(const void * p)
244 if (p != NULL) free((void *)p);
248 /* FIX: these are macros */
251 void * xmalloc (size_t size);
255 void * xcalloc (size_t nmemb, size_t size);
258 * @todo Annotate ptr with returned/out.
260 void * xrealloc (void * ptr,
265 char * xstrdup (const char *str);
269 void * vmefail(size_t size);
273 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
274 #if defined(__GNUC__)
275 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
276 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
277 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
278 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
279 #endif /* defined(__GNUC__) */
280 #endif /* HAVE_MCHECK_H */
282 /* Retrofit glibc __progname */
283 #if defined __GLIBC__ && __GLIBC__ >= 2
284 #if __GLIBC_MINOR__ >= 1
285 #define __progname __assert_program_name
287 #define setprogname(pn)
289 #define __progname program_name
290 #define setprogname(pn) \
291 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
292 else __progname = pn; \
295 extern const char *__progname;
305 /* Take care of NLS matters. */
311 # define setlocale(Category, Locale) /* empty */
315 # include <libintl.h>
316 # define _(Text) dgettext (PACKAGE, Text)
318 # undef bindtextdomain
319 # define bindtextdomain(Domain, Directory) /* empty */
321 # define textdomain(Domain) /* empty */
322 # define _(Text) Text
324 # define dgettext(DomainName, Text) Text
327 #define N_(Text) Text
329 /* ============== from misc/miscfn.h */
331 #if !defined(USE_GNU_GLOB)
340 #include "misc/glob.h"
341 #include "misc/fnmatch.h"
345 #define S_IFSOCK (0xc000)
349 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
353 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
361 #define realloc(ptr,size) myrealloc(ptr,size)
362 extern void *myrealloc(void *, size_t);
366 extern int setenv(const char *name, const char *value, int replace);
367 extern void unsetenv(const char *name);
370 #if HAVE_SYS_SOCKET_H
371 #include <sys/types.h>
372 #include <sys/socket.h>
378 #if HAVE_SYS_SELECT_H
379 #include <sys/select.h>
383 /* Solaris <= 2.6 limits getpass return to only 8 chars */
384 #if HAVE_GETPASSPHRASE
385 #define getpass getpassphrase
392 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
393 # define GETMNTENT_ONE 0
394 # define GETMNTENT_TWO 0
395 # if HAVE_SYS_MNTCTL_H
396 # include <sys/mntctl.h>
398 # if HAVE_SYS_VMOUNT_H
399 # include <sys/vmount.h>
401 # if HAVE_SYS_MOUNT_H
402 # include <sys/mount.h>
404 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
408 # define our_mntent struct mntent
409 # define our_mntdir mnt_dir
410 # elif HAVE_STRUCT_MNTTAB
416 struct our_mntent *getmntent(FILE *filep);
417 # define our_mntent struct our_mntent
423 struct our_mntent *getmntent(FILE *filep);
424 # define our_mntent struct our_mntent
426 # define GETMNTENT_ONE 1
427 # define GETMNTENT_TWO 0
428 #elif HAVE_SYS_MNTTAB_H
430 # include <sys/mnttab.h>
431 # define GETMNTENT_ONE 0
432 # define GETMNTENT_TWO 1
433 # define our_mntent struct mnttab
434 # define our_mntdir mnt_mountp
435 #else /* if !HAVE_MNTCTL */
436 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
440 #define MOUNTED "/etc/mnttab"
443 #endif /* H_SYSTEM */