Remove unnecessary and broken time.h related configure + system.h checks
[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 #if !defined(SEEK_SET)
82 #define SEEK_SET 0
83 #define SEEK_CUR 1
84 #define SEEK_END 2
85 #endif
86 #if !defined(F_OK) 
87 #define F_OK 0
88 #define X_OK 1
89 #define W_OK 2
90 #define R_OK 4
91 #endif
92
93 #ifdef HAVE_DIRENT_H
94 # include <dirent.h>
95 # define NLENGTH(direct) (strlen((direct)->d_name))
96 #else /* not HAVE_DIRENT_H */
97 # define dirent direct
98 # define NLENGTH(direct) ((direct)->d_namlen)
99 # ifdef HAVE_SYS_NDIR_H
100 #  include <sys/ndir.h>
101 # endif /* HAVE_SYS_NDIR_H */
102 # ifdef HAVE_SYS_DIR_H
103 #  include <sys/dir.h>
104 # endif /* HAVE_SYS_DIR_H */
105 # ifdef HAVE_NDIR_H
106 #  include <ndir.h>
107 # endif /* HAVE_NDIR_H */
108 #endif /* HAVE_DIRENT_H */
109
110 #include <ctype.h>
111
112 #if HAVE_SYS_MMAN_H
113 #include <sys/mman.h>
114 #endif
115
116 #if HAVE_SYS_WAIT_H
117 #include <sys/wait.h>
118 #endif
119
120 #if HAVE_LIMITS_H
121 #include <limits.h>
122 #endif
123
124 #ifndef PATH_MAX
125 #ifdef _POSIX_PATH_MAX
126 #define PATH_MAX _POSIX_PATH_MAX
127 #elif defined MAXPATHLEN
128 #define PATH_MAX MAXPATHLEN
129 #else
130 #define PATH_MAX 256
131 #endif
132 #endif
133
134 #if WITH_SELINUX
135 #include <selinux/selinux.h>
136 #else
137 typedef char * security_context_t;
138
139 #define freecon(_c)
140
141 #define getfilecon(_fn, _c)     (-1)
142 #define lgetfilecon(_fn, _c)    (-1)
143 #define fgetfilecon(_fd, _c)    (-1)
144
145 #define setfilecon(_fn, _c)     (-1)
146 #define lsetfilecon(_fn, _c)    (-1)
147 #define fsetfilecon(_fd, _c)    (-1)
148
149 #define security_check_context(_c)      (0)
150
151 #define is_selinux_enabled()    (0)
152
153 #define matchpathcon_init(_fn)                  (-1)
154 #define matchpathcon_fini()                     (0)
155 #define matchpathcon(_fn, _fm, _c)              (-1)
156
157 #define rpm_execcon(_v, _fn, _av, _envp)        (0)
158 #endif
159
160 #if WITH_CAP
161 #include <sys/capability.h>
162 #else
163 typedef void * cap_t;
164 #endif
165
166 #if WITH_ACL
167 #include <acl/libacl.h>
168 #endif
169
170 #if HAVE_MCHECK_H
171 #include <mcheck.h>
172 #endif  /* HAVE_MCHECK_H */
173
174 #include "rpmio/rpmutil.h"
175 /* compatibility macros to avoid a mass-renaming all over the codebase */
176 #define xmalloc(_size) rmalloc((_size))
177 #define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
178 #define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
179 #define xstrdup(_str) rstrdup((_str))
180 #define _free(_ptr) rfree((_ptr))
181
182 /* Retrofit glibc __progname */
183 #if defined __GLIBC__ && __GLIBC__ >= 2
184 #if __GLIBC_MINOR__ >= 1
185 #define __progname      __assert_program_name
186 #endif
187 #define setprogname(pn)
188 #else
189 #define __progname      program_name
190 #define setprogname(pn) \
191   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
192     else __progname = pn;               \
193   }
194 #endif
195 extern const char *__progname;
196
197 /* Take care of NLS matters.  */
198
199 #if HAVE_LOCALE_H
200 # include <locale.h>
201 #endif
202 #if !HAVE_SETLOCALE
203 # define setlocale(Category, Locale) /* empty */
204 #endif
205
206 #if ENABLE_NLS
207 # include <libintl.h>
208 # define _(Text) dgettext (PACKAGE, Text)
209 #else
210 # undef bindtextdomain
211 # define bindtextdomain(Domain, Directory) /* empty */
212 # undef textdomain
213 # define textdomain(Domain) /* empty */
214 # define _(Text) Text
215 # undef dgettext
216 # define dgettext(DomainName, Text) Text
217 #endif
218
219 #define N_(Text) Text
220
221 /* ============== from misc/miscfn.h */
222
223 #if !defined(USE_GNU_GLOB) 
224 #if HAVE_FNMATCH_H
225 #include <fnmatch.h>
226 #endif
227
228 #if HAVE_GLOB_H 
229 #include <glob.h>
230 #endif
231 #else
232 #include "misc/glob.h"
233 #include "misc/fnmatch.h"
234 #endif
235
236 #if NEED_STRINGS_H
237 #include <strings.h>
238 #endif
239
240 #if HAVE_GETMNTINFO || HAVE_GETMNTINFO_R || HAVE_MNTCTL
241 # define GETMNTENT_ONE 0
242 # define GETMNTENT_TWO 0
243 # if HAVE_SYS_MNTCTL_H
244 #  include <sys/mntctl.h>
245 # endif
246 # if HAVE_SYS_VMOUNT_H
247 #  include <sys/vmount.h>
248 # endif
249 # if HAVE_SYS_MOUNT_H
250 #  include <sys/mount.h>
251 # endif
252 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
253 # if HAVE_MNTENT_H
254 #  include <stdio.h>
255 #  include <mntent.h>
256 #  define our_mntent struct mntent
257 #  define our_mntdir mnt_dir
258 # elif HAVE_STRUCT_MNTTAB
259 #  include <stdio.h>
260 #  include <mnttab.h>
261    struct our_mntent {
262        char * our_mntdir;
263    };
264    struct our_mntent *getmntent(FILE *filep);
265 #  define our_mntent struct our_mntent
266 # else
267 #  include <stdio.h>
268    struct our_mntent {
269        char * our_mntdir;
270    };
271    struct our_mntent *getmntent(FILE *filep);
272 #  define our_mntent struct our_mntent
273 # endif
274 # define GETMNTENT_ONE 1
275 # define GETMNTENT_TWO 0
276 #elif HAVE_SYS_MNTTAB_H
277 # include <stdio.h>
278 # include <sys/mnttab.h>
279 # define GETMNTENT_ONE 0
280 # define GETMNTENT_TWO 1
281 # define our_mntent struct mnttab
282 # define our_mntdir mnt_mountp
283 #else /* if !HAVE_MNTCTL */
284 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
285 #endif
286
287 #ifndef MOUNTED
288 #define MOUNTED "/etc/mnttab"
289 #endif
290
291 #endif  /* H_SYSTEM */