4 * Some misc low-level API
14 #ifdef HAVE_SYS_PARAM_H
15 #include <sys/param.h>
18 /* <unistd.h> should be included before any preprocessor test
22 #if !defined(__GLIBC__)
24 #include <crt_externs.h>
25 #define environ (*_NSGetEnviron())
27 extern char ** environ;
28 #endif /* __APPLE__ */
32 #if !defined(HAVE_STPCPY)
33 char * stpcpy(char * dest, const char * src);
36 #if !defined(HAVE_STPNCPY)
37 char * stpncpy(char * dest, const char * src, size_t n);
40 #if HAVE_SECURE_GETENV
41 #define getenv(_s) secure_getenv(_s)
42 #elif HAVE___SECURE_GETENV
43 #define getenv(_s) __secure_getenv(_s)
54 # define NLENGTH(direct) (strlen((direct)->d_name))
55 #else /* not HAVE_DIRENT_H */
56 # define dirent direct
57 # define NLENGTH(direct) ((direct)->d_namlen)
58 # ifdef HAVE_SYS_NDIR_H
59 # include <sys/ndir.h>
60 # endif /* HAVE_SYS_NDIR_H */
61 # ifdef HAVE_SYS_DIR_H
63 # endif /* HAVE_SYS_DIR_H */
66 # endif /* HAVE_NDIR_H */
67 #endif /* HAVE_DIRENT_H */
74 #ifdef _POSIX_PATH_MAX
75 #define PATH_MAX _POSIX_PATH_MAX
76 #elif defined MAXPATHLEN
77 #define PATH_MAX MAXPATHLEN
83 #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
84 extern int fdatasync(int fildes);
87 #include "rpmio/rpmutil.h"
88 /* compatibility macros to avoid a mass-renaming all over the codebase */
89 #define xmalloc(_size) rmalloc((_size))
90 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
91 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
92 #define xstrdup(_str) rstrdup((_str))
93 #define _free(_ptr) rfree((_ptr))
95 /* To extract program's name: use calls (reimplemented or shipped with system):
96 - void setprogname(const char *pn)
97 - const char *getprogname(void)
99 setprogname(*pn) must be the first call in main() in order to set the name
100 as soon as possible. */
101 #if defined(HAVE_SETPROGNAME) /* BSD'ish systems */
102 # include <stdlib.h> /* Make sure this header is included */
103 # define xsetprogname(pn) setprogname(pn)
104 # define xgetprogname(pn) getprogname(pn)
105 #elif defined(HAVE___PROGNAME) /* glibc and others */
106 # define xsetprogname(pn)
107 extern const char *__progname;
108 # define xgetprogname(pn) __progname
110 # error "Did not find any sutable implementation of xsetprogname/xgetprogname"
113 /* Take care of NLS matters. */
116 # include <libintl.h>
117 # define _(Text) dgettext (PACKAGE, Text)
119 # define _(Text) Text
122 #define N_(Text) Text
124 /* ============== from misc/miscfn.h */
126 #include "misc/fnmatch.h"
130 #endif /* H_SYSTEM */