rpm  4.11.1-rc1
system.h
Go to the documentation of this file.
1 
5 #ifndef H_SYSTEM
6 #define H_SYSTEM
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #ifdef HAVE_SYS_PARAM_H
13 #include <sys/param.h>
14 #endif
15 
16 /* <unistd.h> should be included before any preprocessor test
17  of _POSIX_VERSION. */
18 #ifdef HAVE_UNISTD_H
19 #include <unistd.h>
20 #if !defined(__GLIBC__)
21 #ifdef __APPLE__
22 #include <crt_externs.h>
23 #define environ (*_NSGetEnviron())
24 #else
25 extern char ** environ;
26 #endif /* __APPLE__ */
27 #endif
28 #endif
29 
30 #if !defined(HAVE_STPCPY)
31 char * stpcpy(char * dest, const char * src);
32 #endif
33 
34 #if !defined(HAVE_STPNCPY)
35 char * stpncpy(char * dest, const char * src, size_t n);
36 #endif
37 
38 #if HAVE_SECURE_GETENV
39 #define getenv(_s) secure_getenv(_s)
40 #elif HAVE___SECURE_GETENV
41 #define getenv(_s) __secure_getenv(_s)
42 #endif
43 
44 #ifdef HAVE_FCNTL_H
45 #include <fcntl.h>
46 #else
47 #include <sys/file.h>
48 #endif
49 
50 #ifdef HAVE_DIRENT_H
51 # include <dirent.h>
52 # define NLENGTH(direct) (strlen((direct)->d_name))
53 #else /* not HAVE_DIRENT_H */
54 # define dirent direct
55 # define NLENGTH(direct) ((direct)->d_namlen)
56 # ifdef HAVE_SYS_NDIR_H
57 # include <sys/ndir.h>
58 # endif /* HAVE_SYS_NDIR_H */
59 # ifdef HAVE_SYS_DIR_H
60 # include <sys/dir.h>
61 # endif /* HAVE_SYS_DIR_H */
62 # ifdef HAVE_NDIR_H
63 # include <ndir.h>
64 # endif /* HAVE_NDIR_H */
65 #endif /* HAVE_DIRENT_H */
66 
67 #if HAVE_LIMITS_H
68 #include <limits.h>
69 #endif
70 
71 #ifndef PATH_MAX
72 #ifdef _POSIX_PATH_MAX
73 #define PATH_MAX _POSIX_PATH_MAX
74 #elif defined MAXPATHLEN
75 #define PATH_MAX MAXPATHLEN
76 #else
77 #define PATH_MAX 256
78 #endif
79 #endif
80 
81 #if WITH_SELINUX
82 #include <selinux/selinux.h>
83 #include <selinux/label.h>
84 #include <selinux/avc.h>
85 #else
86 typedef char * security_context_t;
87 
88 #define freecon(_c)
89 
90 #define setfilecon(_fn, _c) (-1)
91 #define lsetfilecon(_fn, _c) (-1)
92 
93 #define is_selinux_enabled() (0)
94 
95 #define matchpathcon_init(_fn) (-1)
96 #define matchpathcon_fini() (0)
97 #define matchpathcon(_fn, _fm, _c) (-1)
98 
99 #define selabel_lookup_raw(_hnd, _scon, _key,_type) (-1)
100 
101 #define selinux_file_context_path() (0)
102 
103 #define rpm_execcon(_v, _fn, _av, _envp) (0)
104 #endif
105 
106 #include "rpmio/rpmutil.h"
107 /* compatibility macros to avoid a mass-renaming all over the codebase */
108 #define xmalloc(_size) rmalloc((_size))
109 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
110 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
111 #define xstrdup(_str) rstrdup((_str))
112 #define _free(_ptr) rfree((_ptr))
113 
114 /* Retrofit glibc __progname */
115 #if defined __GLIBC__ && __GLIBC__ >= 2
116 #if __GLIBC_MINOR__ >= 1
117 #define __progname __assert_program_name
118 #endif
119 #define setprogname(pn)
120 #else
121 #define __progname program_name
122 #define setprogname(pn) \
123  { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
124  else __progname = pn; \
125  }
126 #endif
127 extern const char *__progname;
128 
129 /* Take care of NLS matters. */
130 #if ENABLE_NLS
131 # include <locale.h>
132 # include <libintl.h>
133 # define _(Text) dgettext (PACKAGE, Text)
134 #else
135 # define _(Text) Text
136 #endif
137 
138 #define N_(Text) Text
139 
140 /* ============== from misc/miscfn.h */
141 
142 #include "misc/fnmatch.h"
143 
144 #include <dlfcn.h>
145 
146 #endif /* H_SYSTEM */