Remove libcap stuff out of system.h
[platform/upstream/rpm.git] / system.h
1 /**
2  * \file system.h
3  */
4
5 #ifndef H_SYSTEM
6 #define H_SYSTEM
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include <sys/types.h>
13
14 #include <sys/stat.h>
15 #include <stdio.h>
16
17 #ifdef HAVE_SYS_PARAM_H
18 #include <sys/param.h>
19 #endif
20
21 /* <unistd.h> should be included before any preprocessor test
22    of _POSIX_VERSION.  */
23 #ifdef HAVE_UNISTD_H
24 #include <unistd.h>
25 #if !defined(__GLIBC__)
26 #ifdef __APPLE__
27 #include <crt_externs.h>
28 #define environ (*_NSGetEnviron())
29 #else
30 extern char ** environ;
31 #endif /* __APPLE__ */
32 #endif
33 #endif
34
35 #ifdef HAVE_STRING_H
36 # if !STDC_HEADERS && HAVE_MEMORY_H
37 #  include <memory.h>
38 # endif
39 # include <string.h>
40 #else
41 # include <strings.h>
42 #endif
43
44 #if !defined(HAVE_STPCPY)
45 char * stpcpy(char * dest, const char * src);
46 #endif
47
48 #if !defined(HAVE_STPNCPY)
49 char * stpncpy(char * dest, const char * src, size_t n);
50 #endif
51
52 #include <errno.h>
53 #ifndef errno
54 extern int errno;
55 #endif
56
57 #if HAVE___SECURE_GETENV
58 #define getenv(_s)      __secure_getenv(_s)
59 #endif
60
61 #ifdef STDC_HEADERS
62 /* FIX: shrug */
63 #define getopt system_getopt
64 #include <stdlib.h>
65 #undef getopt
66 #else /* not STDC_HEADERS */
67 char *getenv (const char *name);
68 #endif /* STDC_HEADERS */
69
70 /* XXX solaris2.5.1 has not */
71 #if !defined(EXIT_FAILURE)
72 #define EXIT_FAILURE    1
73 #endif
74
75 #ifdef HAVE_FCNTL_H
76 #include <fcntl.h>
77 #else
78 #include <sys/file.h>
79 #endif
80
81 #ifdef HAVE_DIRENT_H
82 # include <dirent.h>
83 # define NLENGTH(direct) (strlen((direct)->d_name))
84 #else /* not HAVE_DIRENT_H */
85 # define dirent direct
86 # define NLENGTH(direct) ((direct)->d_namlen)
87 # ifdef HAVE_SYS_NDIR_H
88 #  include <sys/ndir.h>
89 # endif /* HAVE_SYS_NDIR_H */
90 # ifdef HAVE_SYS_DIR_H
91 #  include <sys/dir.h>
92 # endif /* HAVE_SYS_DIR_H */
93 # ifdef HAVE_NDIR_H
94 #  include <ndir.h>
95 # endif /* HAVE_NDIR_H */
96 #endif /* HAVE_DIRENT_H */
97
98 #include <ctype.h>
99
100 #if HAVE_LIMITS_H
101 #include <limits.h>
102 #endif
103
104 #ifndef PATH_MAX
105 #ifdef _POSIX_PATH_MAX
106 #define PATH_MAX _POSIX_PATH_MAX
107 #elif defined MAXPATHLEN
108 #define PATH_MAX MAXPATHLEN
109 #else
110 #define PATH_MAX 256
111 #endif
112 #endif
113
114 #if WITH_SELINUX
115 #include <selinux/selinux.h>
116 #else
117 typedef char * security_context_t;
118
119 #define freecon(_c)
120
121 #define setfilecon(_fn, _c)     (-1)
122 #define lsetfilecon(_fn, _c)    (-1)
123
124 #define is_selinux_enabled()    (0)
125
126 #define matchpathcon_init(_fn)                  (-1)
127 #define matchpathcon_fini()                     (0)
128 #define matchpathcon(_fn, _fm, _c)              (-1)
129
130 #define rpm_execcon(_v, _fn, _av, _envp)        (0)
131 #endif
132
133 #include "rpmio/rpmutil.h"
134 /* compatibility macros to avoid a mass-renaming all over the codebase */
135 #define xmalloc(_size) rmalloc((_size))
136 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
137 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
138 #define xstrdup(_str) rstrdup((_str))
139 #define _free(_ptr) rfree((_ptr))
140
141 /* Retrofit glibc __progname */
142 #if defined __GLIBC__ && __GLIBC__ >= 2
143 #if __GLIBC_MINOR__ >= 1
144 #define __progname      __assert_program_name
145 #endif
146 #define setprogname(pn)
147 #else
148 #define __progname      program_name
149 #define setprogname(pn) \
150   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
151     else __progname = pn;               \
152   }
153 #endif
154 extern const char *__progname;
155
156 /* Take care of NLS matters.  */
157
158 #if HAVE_LOCALE_H
159 # include <locale.h>
160 #endif
161 #if !HAVE_SETLOCALE
162 # define setlocale(Category, Locale) /* empty */
163 #endif
164
165 #if ENABLE_NLS
166 # include <libintl.h>
167 # define _(Text) dgettext (PACKAGE, Text)
168 #else
169 # undef bindtextdomain
170 # define bindtextdomain(Domain, Directory) /* empty */
171 # undef textdomain
172 # define textdomain(Domain) /* empty */
173 # define _(Text) Text
174 # undef dgettext
175 # define dgettext(DomainName, Text) Text
176 #endif
177
178 #define N_(Text) Text
179
180 /* ============== from misc/miscfn.h */
181
182 #if !defined(USE_GNU_GLOB) 
183 #if HAVE_FNMATCH_H
184 #include <fnmatch.h>
185 #endif
186
187 #if HAVE_GLOB_H 
188 #include <glob.h>
189 #endif
190 #else
191 #include "misc/glob.h"
192 #include "misc/fnmatch.h"
193 #endif
194
195 #if NEED_STRINGS_H
196 #include <strings.h>
197 #endif
198
199 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
200 # define GETMNTENT_ONE 0
201 # define GETMNTENT_TWO 0
202 # if HAVE_SYS_MNTCTL_H
203 #  include <sys/mntctl.h>
204 # endif
205 # if HAVE_SYS_VMOUNT_H
206 #  include <sys/vmount.h>
207 # endif
208 # if HAVE_SYS_MOUNT_H
209 #  include <sys/mount.h>
210 # endif
211 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
212 # if HAVE_MNTENT_H
213 #  include <stdio.h>
214 #  include <mntent.h>
215 #  define our_mntent struct mntent
216 #  define our_mntdir mnt_dir
217 # elif HAVE_STRUCT_MNTTAB
218 #  include <stdio.h>
219 #  include <mnttab.h>
220    struct our_mntent {
221        char * our_mntdir;
222    };
223    struct our_mntent *getmntent(FILE *filep);
224 #  define our_mntent struct our_mntent
225 # else
226 #  include <stdio.h>
227    struct our_mntent {
228        char * our_mntdir;
229    };
230    struct our_mntent *getmntent(FILE *filep);
231 #  define our_mntent struct our_mntent
232 # endif
233 # define GETMNTENT_ONE 1
234 # define GETMNTENT_TWO 0
235 #elif HAVE_SYS_MNTTAB_H
236 # include <stdio.h>
237 # include <sys/mnttab.h>
238 # define GETMNTENT_ONE 0
239 # define GETMNTENT_TWO 1
240 # define our_mntent struct mnttab
241 # define our_mntdir mnt_mountp
242 #else /* if !HAVE_MNTCTL */
243 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
244 #endif
245
246 #ifndef MOUNTED
247 #define MOUNTED "/etc/mnttab"
248 #endif
249
250 #endif  /* H_SYSTEM */