fix: last update transaction set segfault bug in installer.
[platform/upstream/rpm.git] / system.h
1 /* system-dependent definitions for fileutils programs.
2    Copyright (C) 89, 91, 92, 93, 94, 1996 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18 #ifndef H_SYSTEM
19 #define H_SYSTEM
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <stdio.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28
29 #ifdef HAVE_SYS_PARAM_H
30 #include <sys/param.h>
31 #endif
32
33 /* <unistd.h> should be included before any preprocessor test
34    of _POSIX_VERSION.  */
35 #ifdef HAVE_UNISTD_H
36 /*@-skipposixheaders@*/
37 #include <unistd.h>
38 /*@=skipposixheaders@*/
39 #endif
40
41 #if TIME_WITH_SYS_TIME
42 # include <sys/time.h>
43 # include <time.h>
44 #else
45 # if HAVE_SYS_TIME_H
46 #  include <sys/time.h>
47 # else
48 #  include <time.h>
49 # endif
50 #endif
51
52 #if NEED_TIMEZONE
53 extern time_t timezone;
54 #endif
55
56
57 /* Since major is a function on SVR4, we can't use `ifndef major'.  */
58 #if MAJOR_IN_MKDEV
59 #include <sys/mkdev.h>
60 #define HAVE_MAJOR
61 #endif
62 #if MAJOR_IN_SYSMACROS
63 #include <sys/sysmacros.h>
64 #define HAVE_MAJOR
65 #endif
66 #ifdef major                    /* Might be defined in sys/types.h.  */
67 #define HAVE_MAJOR
68 #endif
69
70 #ifndef HAVE_MAJOR
71 #define major(dev)  (((dev) >> 8) & 0xff)
72 #define minor(dev)  ((dev) & 0xff)
73 #define makedev(maj, min)  (((maj) << 8) | (min))
74 #endif
75 #undef HAVE_MAJOR
76
77 #ifdef HAVE_UTIME_H
78 #include <utime.h>
79 #endif
80
81 /* Don't use bcopy!  Use memmove if source and destination may overlap,
82    memcpy otherwise.  */
83
84 #ifdef HAVE_STRING_H
85 # if !STDC_HEADERS && HAVE_MEMORY_H
86 #  include <memory.h>
87 # endif
88 # include <string.h>
89 #else
90 # include <strings.h>
91 char *memchr ();
92 #endif
93
94 #include <errno.h>
95 #ifndef errno
96 extern int errno;
97 #endif
98
99 #ifdef STDC_HEADERS
100 #define getopt system_getopt
101 /*@-skipansiheaders@*/
102 #include <stdlib.h>
103 /*@=skipansiheaders@*/
104 #undef getopt
105 #else /* not STDC_HEADERS */
106 char *getenv (const char *name);
107 #endif /* STDC_HEADERS */
108
109 #ifdef HAVE_FCNTL_H
110 #include <fcntl.h>
111 #else
112 #include <sys/file.h>
113 #endif
114
115 #ifndef SEEK_SET
116 #define SEEK_SET 0
117 #define SEEK_CUR 1
118 #define SEEK_END 2
119 #endif
120 #ifndef F_OK
121 #define F_OK 0
122 #define X_OK 1
123 #define W_OK 2
124 #define R_OK 4
125 #endif
126
127 #ifdef HAVE_DIRENT_H
128 # include <dirent.h>
129 # define NLENGTH(direct) (strlen((direct)->d_name))
130 #else /* not HAVE_DIRENT_H */
131 # define dirent direct
132 # define NLENGTH(direct) ((direct)->d_namlen)
133 # ifdef HAVE_SYS_NDIR_H
134 #  include <sys/ndir.h>
135 # endif /* HAVE_SYS_NDIR_H */
136 # ifdef HAVE_SYS_DIR_H
137 #  include <sys/dir.h>
138 # endif /* HAVE_SYS_DIR_H */
139 # ifdef HAVE_NDIR_H
140 #  include <ndir.h>
141 # endif /* HAVE_NDIR_H */
142 #endif /* HAVE_DIRENT_H */
143
144 #ifdef __GNUC__
145 # undef alloca
146 # define alloca __builtin_alloca
147 #else
148 # ifdef HAVE_ALLOCA_H
149 #  include <alloca.h>
150 # else
151 #  ifndef _AIX
152 /* AIX alloca decl has to be the first thing in the file, bletch! */
153 char *alloca ();
154 #  endif
155 # endif
156 #endif
157
158 #include <ctype.h>
159
160 #if HAVE_SYS_MMAN_H
161 #include <sys/mman.h>
162 #endif
163
164 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
165 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
166 #include <sys/resource.h>
167 #endif
168
169 #if HAVE_SYS_UTSNAME_H
170 #include <sys/utsname.h>
171 #endif
172
173 #if HAVE_SYS_WAIT_H
174 #include <sys/wait.h>
175 #endif
176
177 #if HAVE_GETOPT_H
178 #include <getopt.h>
179 #endif
180
181 #if HAVE_GRP_H
182 #include <grp.h>
183 #endif
184
185 #if HAVE_LIMITS_H
186 #include <limits.h>
187 #endif
188
189 #if HAVE_MALLOC_H
190 #include <malloc.h>
191 #endif
192
193 #if HAVE_NETDB_H
194 #include <netdb.h>
195 #endif
196
197 #if HAVE_PWD_H
198 #include <pwd.h>
199 #endif
200
201 /* Take care of NLS matters.  */
202
203 #if HAVE_LOCALE_H
204 # include <locale.h>
205 #endif
206 #if !HAVE_SETLOCALE
207 # define setlocale(Category, Locale) /* empty */
208 #endif
209
210 #if ENABLE_NLS && !defined(__LCLINT__)
211 # include <libintl.h>
212 # define _(Text) gettext (Text)
213 #else
214 # undef bindtextdomain
215 # define bindtextdomain(Domain, Directory) /* empty */
216 # undef textdomain
217 # define textdomain(Domain) /* empty */
218 # define _(Text) Text
219 #endif
220
221 #define N_(Text) Text
222
223 /* ============== from misc/miscfn.h */
224
225 #if HAVE_FNMATCH_H
226 #include <fnmatch.h>
227 #else
228 #include "misc/fnmatch.h"
229 #endif
230
231 #if HAVE_GLOB_H
232 #include <glob.h>
233 #else
234 #include "misc/glob.h"
235 #endif
236
237 #if ! HAVE_S_IFSOCK
238 #define S_IFSOCK (0xC000)
239 #endif
240
241 #if ! HAVE_S_ISLNK
242 #define S_ISLNK(mode) ((mode & 0xF000) == S_IFLNK)
243 #endif
244
245 #if ! HAVE_S_ISSOCK
246 #define S_ISSOCK(mode) ((mode & 0xF000) == S_IFSOCK)
247 #endif
248
249 #if NEED_STRINGS_H
250 #include <strings.h>
251 #endif
252
253 #if ! HAVE_REALPATH
254 char *realpath(const char *path, char resolved_path []);
255 #endif
256
257 #if NEED_MYREALLOC
258 #define realloc(ptr,size) myrealloc(ptr,size)
259 extern void *myrealloc(void *, size_t);
260 #endif
261
262 #if HAVE_SYS_SOCKET_H
263 #include <sys/types.h>
264 #include <sys/socket.h>
265 #endif
266
267 #if HAVE_SYS_SELECT_H
268 #include <sys/select.h>
269 #endif
270
271 #if ! HAVE_LCHOWN
272 #define lchown chown
273 #endif
274
275 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
276 # define GETMNTENT_ONE 0
277 # define GETMNTENT_TWO 0
278 # if HAVE_SYS_MNTCTL_H
279 #  include <sys/mntctl.h>
280 # endif
281 # if HAVE_SYS_VMOUNT_H
282 #  include <sys/vmount.h>
283 # endif
284 # if HAVE_SYS_MOUNT_H
285 #  include <sys/mount.h>
286 # endif
287 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
288 # if HAVE_MNTENT_H
289 #  include <stdio.h>
290 #  include <mntent.h>
291 #  define our_mntent struct mntent
292 #  define our_mntdir mnt_dir
293 # elif HAVE_STRUCT_MNTTAB
294 #  include <stdio.h>
295 #  include <mnttab.h>
296    struct our_mntent {
297        char * our_mntdir;
298    };
299    struct our_mntent *getmntent(FILE *filep);
300 #  define our_mntent struct our_mntent
301 # else
302 #  include <stdio.h>
303    struct our_mntent {
304        char * our_mntdir;
305    };
306    struct our_mntent *getmntent(FILE *filep);
307 #  define our_mntent struct our_mntent
308 # endif
309 # define GETMNTENT_ONE 1
310 # define GETMNTENT_TWO 0
311 #elif HAVE_SYS_MNTTAB_H
312 # include <stdio.h>
313 # include <sys/mnttab.h>
314 # define GETMNTENT_ONE 0
315 # define GETMNTENT_TWO 1
316 # define our_mntent struct mnttab
317 # define our_mntdir mnt_mountp
318 #else /* if !HAVE_MNTCTL */
319 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
320 #endif
321
322 #ifndef MOUNTED
323 #define MOUNTED "/etc/mnttab"
324 #endif
325 #endif  /* H_SYSTEM */