1 | /* System dependent definitions for GNU tar.
|
---|
2 | Copyright (C) 1994 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
|
---|
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
17 | */
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * [TS:Aug/95]
|
---|
21 | * Based on code from system.h file in GNU's tar package
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef SYSFUNCS_H
|
---|
26 | #define SYSFUNCS_H
|
---|
27 |
|
---|
28 | #include <sys/stat.h>
|
---|
29 |
|
---|
30 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
31 | #ifdef HAVE_CONFIG_H
|
---|
32 | # ifdef __WIN32__
|
---|
33 | # include <WIN32cfg.h>
|
---|
34 | # else
|
---|
35 | # include <config.h>
|
---|
36 | # endif
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | /* Declare alloca. AIX requires this to be the first thing in the file. */
|
---|
40 |
|
---|
41 | #ifdef __GNUC__
|
---|
42 | #ifndef alloca
|
---|
43 | #define alloca __builtin_alloca
|
---|
44 | #endif
|
---|
45 | #else
|
---|
46 | #if HAVE_ALLOCA_H
|
---|
47 | #include <alloca.h>
|
---|
48 | #else
|
---|
49 | #ifdef _AIX
|
---|
50 | #pragma alloca
|
---|
51 | #else
|
---|
52 | #ifndef alloca
|
---|
53 | char *alloca ();
|
---|
54 | #endif
|
---|
55 | #endif
|
---|
56 | #endif
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #include <sys/types.h>
|
---|
60 |
|
---|
61 | /* ------------------------------------------------- */
|
---|
62 | /* [TS:Aug/95]
|
---|
63 | * Some extra include files that mg needs
|
---|
64 | */
|
---|
65 | #include <stdlib.h>
|
---|
66 | #include <math.h>
|
---|
67 |
|
---|
68 | #ifndef log2
|
---|
69 | # ifndef M_LN2
|
---|
70 | # define M_LN2 0.69314718055994530942
|
---|
71 | # endif
|
---|
72 | # define log2(x) (log(x)/M_LN2)
|
---|
73 | #endif
|
---|
74 |
|
---|
75 |
|
---|
76 | #ifndef HAVE_SETBUFFER
|
---|
77 | #ifdef __CYGWIN__
|
---|
78 | /* Cygwin has setbuffer in stdio.h, but can't link against it!! */
|
---|
79 | #include <stdio.h>
|
---|
80 | #endif
|
---|
81 | # define setbuffer(f, b, s) setvbuf(f, b, _IOFBF, s)
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
85 | #if defined(__MSDOS__) && !defined(__WIN32__)
|
---|
86 | # define SHORT_SUFFIX 1
|
---|
87 | #endif
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | #include <assert.h>
|
---|
92 |
|
---|
93 | /* ------------------------------------------------- */
|
---|
94 |
|
---|
95 | /* Declare a generic pointer type. */
|
---|
96 | #if __STDC__ || defined(__TURBOC__)
|
---|
97 | #define voidstar void *
|
---|
98 | #else
|
---|
99 | #define voidstar char *
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | /* Declare ISASCII. */
|
---|
103 |
|
---|
104 | #include <ctype.h>
|
---|
105 |
|
---|
106 | #if STDC_HEADERS
|
---|
107 | #define ISASCII(Char) 1
|
---|
108 | #else
|
---|
109 | #ifdef isascii
|
---|
110 | #define ISASCII(Char) isascii (Char)
|
---|
111 | #else
|
---|
112 | #if HAVE_ISASCII
|
---|
113 | #define ISASCII(Char) isascii (Char)
|
---|
114 | #else
|
---|
115 | #define ISASCII(Char) 1
|
---|
116 | #endif
|
---|
117 | #endif
|
---|
118 | #endif
|
---|
119 |
|
---|
120 |
|
---|
121 | /* ------------------------------------------------- */
|
---|
122 | /* [TS:Aug/95]
|
---|
123 | * The following is copied from GNU Autoconf.Info (1.1)
|
---|
124 | * It sets up the approriate string and memory functions.
|
---|
125 | */
|
---|
126 |
|
---|
127 | #if STDC_HEADERS || HAVE_STRING_H
|
---|
128 | #include <string.h>
|
---|
129 | /* An ANSI string.h and pre-ANSI memory.h might conflict */
|
---|
130 | #if !STDC_HEADERS && HAVE_MEMORY_H
|
---|
131 | #include <memory.h>
|
---|
132 | #endif /* not STDC_HEADERS and HAVE_MEMORY_H */
|
---|
133 | #ifndef index
|
---|
134 | /*#define index strchr
|
---|
135 | *
|
---|
136 | * this is stuffing up our code so its commented out */
|
---|
137 | #endif
|
---|
138 | #ifndef rindex
|
---|
139 | #define rindex strrchr
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | #ifdef __cplusplus /* compiling for C++ */
|
---|
143 | #include <stdlib.h>
|
---|
144 | #ifndef __bcopy
|
---|
145 | inline void *bcopy(void *s, void *d, int n)
|
---|
146 | { return memcpy(d, s, n);
|
---|
147 | }
|
---|
148 | #define __bcopy 1
|
---|
149 | #endif
|
---|
150 | #ifndef __bcmp
|
---|
151 | inline int bcmp(void *s1, void *s2, int n)
|
---|
152 | { return memcmp(s1, s2, n);
|
---|
153 | }
|
---|
154 | #define __bcmp 1
|
---|
155 | #endif
|
---|
156 | #ifndef __bzero
|
---|
157 | inline void bzero(void *m, int n)
|
---|
158 | { memset(m, 0, n);
|
---|
159 | }
|
---|
160 | #define __bzero 1
|
---|
161 | #endif
|
---|
162 | #else /* compiling for C */
|
---|
163 | #ifndef bcopy
|
---|
164 | #define bcopy(s, d, n) memcpy((d), (s), (n))
|
---|
165 | #endif
|
---|
166 | #ifndef bcmp
|
---|
167 | #define bcmp(s1, s2, n) memcmp((s1), (s2), (n))
|
---|
168 | #endif
|
---|
169 | #ifndef bzero
|
---|
170 | #define bzero(s, n) memset((s), 0, (n))
|
---|
171 | #endif
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | #else /* not STDC_HEADERS and not HAVE_STRING_H */
|
---|
175 | #include <strings.h>
|
---|
176 | /* memory.h and strings.h conflict on some systems */
|
---|
177 | #endif
|
---|
178 | /* ------------------------------------------------- */
|
---|
179 |
|
---|
180 |
|
---|
181 | /* Declare errno. */
|
---|
182 |
|
---|
183 | #include <errno.h>
|
---|
184 | #ifndef errno
|
---|
185 | extern int errno;
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | /* Declare open parameters. */
|
---|
189 |
|
---|
190 | #ifdef HAVE_FCNTL_H
|
---|
191 | #include <fcntl.h>
|
---|
192 | #else
|
---|
193 | #include <sys/file.h>
|
---|
194 | #endif
|
---|
195 |
|
---|
196 | #ifndef O_BINARY
|
---|
197 | #define O_BINARY 0
|
---|
198 | #endif
|
---|
199 | #ifndef O_CREAT
|
---|
200 | #define O_CREAT 0
|
---|
201 | #endif
|
---|
202 | #ifndef O_NDELAY
|
---|
203 | #define O_NDELAY 0
|
---|
204 | #endif
|
---|
205 | #ifndef O_RDONLY
|
---|
206 | #define O_RDONLY 0
|
---|
207 | #endif
|
---|
208 | #ifndef O_RDWR
|
---|
209 | #define O_RDWR 2
|
---|
210 | #endif
|
---|
211 |
|
---|
212 | /* Declare file status routines and bits. */
|
---|
213 |
|
---|
214 | #ifdef STAT_MACROS_BROKEN
|
---|
215 | #undef S_ISBLK
|
---|
216 | #undef S_ISCHR
|
---|
217 | #undef S_ISDIR
|
---|
218 | #undef S_ISFIFO
|
---|
219 | #undef S_ISLNK
|
---|
220 | #undef S_ISMPB
|
---|
221 | #undef S_ISMPC
|
---|
222 | #undef S_ISNWK
|
---|
223 | #undef S_ISREG
|
---|
224 | #undef S_ISSOCK
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | /* On MSDOS, there are missing things from <sys/stat.h>. */
|
---|
228 | #ifdef __MSDOS__
|
---|
229 | #define S_ISUID 0
|
---|
230 | #define S_ISGID 0
|
---|
231 | #define S_ISVTX 0
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | #ifndef S_ISREG /* POSIX.1 stat stuff missing */
|
---|
235 | #define mode_t unsigned short
|
---|
236 | #endif
|
---|
237 | #if !defined(S_ISBLK) && defined(S_IFBLK)
|
---|
238 | #define S_ISBLK(Mode) (((Mode) & S_IFMT) == S_IFBLK)
|
---|
239 | #endif
|
---|
240 | #if !defined(S_ISCHR) && defined(S_IFCHR)
|
---|
241 | #define S_ISCHR(Mode) (((Mode) & S_IFMT) == S_IFCHR)
|
---|
242 | #endif
|
---|
243 | #if !defined(S_ISDIR) && defined(S_IFDIR)
|
---|
244 | #define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
|
---|
245 | #endif
|
---|
246 | #if !defined(S_ISREG) && defined(S_IFREG)
|
---|
247 | #define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
|
---|
248 | #endif
|
---|
249 | #if !defined(S_ISFIFO) && defined(S_IFIFO)
|
---|
250 | #define S_ISFIFO(Mode) (((Mode) & S_IFMT) == S_IFIFO)
|
---|
251 | #endif
|
---|
252 | #if !defined(S_ISLNK) && defined(S_IFLNK)
|
---|
253 | #define S_ISLNK(Mode) (((Mode) & S_IFMT) == S_IFLNK)
|
---|
254 | #endif
|
---|
255 | #if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
---|
256 | #define S_ISSOCK(Mode) (((Mode) & S_IFMT) == S_IFSOCK)
|
---|
257 | #endif
|
---|
258 | #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
---|
259 | #define S_ISMPB(Mode) (((Mode) & S_IFMT) == S_IFMPB)
|
---|
260 | #define S_ISMPC(Mode) (((Mode) & S_IFMT) == S_IFMPC)
|
---|
261 | #endif
|
---|
262 | #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
---|
263 | #define S_ISNWK(Mode) (((Mode) & S_IFMT) == S_IFNWK)
|
---|
264 | #endif
|
---|
265 |
|
---|
266 | #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
|
---|
267 | #define S_ISCTG(Mode) (((Mode) & S_IFMT) == S_IFCTG)
|
---|
268 | #endif
|
---|
269 | #if !defined(S_ISVTX)
|
---|
270 | #define S_ISVTX 0001000
|
---|
271 | #endif
|
---|
272 |
|
---|
273 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
274 | #if !defined(_POSIX_SOURCE) && !defined(__WIN32__)
|
---|
275 | #include <sys/param.h>
|
---|
276 | #endif
|
---|
277 |
|
---|
278 | /* Include <unistd.h> before any preprocessor test of _POSIX_VERSION. */
|
---|
279 | #ifdef HAVE_UNISTD_H
|
---|
280 | #include <unistd.h>
|
---|
281 | #endif
|
---|
282 |
|
---|
283 |
|
---|
284 | /* Declare standard functions. */
|
---|
285 |
|
---|
286 | #ifdef STDC_HEADERS
|
---|
287 | #include <stdlib.h>
|
---|
288 | #else
|
---|
289 | voidstar malloc ();
|
---|
290 | voidstar realloc ();
|
---|
291 | char *getenv ();
|
---|
292 | #endif
|
---|
293 |
|
---|
294 | #include <stdio.h>
|
---|
295 |
|
---|
296 | #ifndef _POSIX_VERSION
|
---|
297 | #ifdef __MSDOS__
|
---|
298 | #include <io.h>
|
---|
299 | #else
|
---|
300 | off_t lseek ();
|
---|
301 | #endif
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | #ifndef __WIN32__
|
---|
305 | #include <pathmax.h>
|
---|
306 | #endif
|
---|
307 |
|
---|
308 | /* Until getoptold function is declared in getopt.h, we need this here for
|
---|
309 | struct option. */
|
---|
310 | /*#include <getopt.h>*/
|
---|
311 |
|
---|
312 | #ifdef WITH_DMALLOC
|
---|
313 | #undef HAVE_VALLOC
|
---|
314 | #define DMALLOC_FUNC_CHECK
|
---|
315 | #include <dmalloc.h>
|
---|
316 | #endif
|
---|
317 |
|
---|
318 | /* Prototypes for external functions. */
|
---|
319 |
|
---|
320 | #ifndef __P
|
---|
321 | #if PROTOTYPES
|
---|
322 | #define __P(Args) Args
|
---|
323 | #else
|
---|
324 | #define __P(Args) ()
|
---|
325 | #endif
|
---|
326 | #endif
|
---|
327 |
|
---|
328 | #if HAVE_LOCALE_H
|
---|
329 | #include <locale.h>
|
---|
330 | #endif
|
---|
331 | /*** setlocale is ansi and posix...(jrm21)
|
---|
332 | #if !HAVE_SETLOCALE
|
---|
333 | #define setlocale(Category, Locale)
|
---|
334 | #endif
|
---|
335 | ***/
|
---|
336 |
|
---|
337 | #if ENABLE_NLS
|
---|
338 | #include <libintl.h>
|
---|
339 | #define _(Text) gettext (Text)
|
---|
340 | #else
|
---|
341 | #define textdomain(Domain)
|
---|
342 | #define _(Text) Text
|
---|
343 | #endif
|
---|
344 |
|
---|
345 | /* Library modules. */
|
---|
346 |
|
---|
347 | #ifdef HAVE_VPRINTF
|
---|
348 | void error __P ((int, int, const char *,...));
|
---|
349 | #else
|
---|
350 | void error ();
|
---|
351 | #endif
|
---|
352 |
|
---|
353 | #ifndef HAVE_STRSTR
|
---|
354 | char *strstr __P ((const char *, const char *));
|
---|
355 | #endif
|
---|
356 |
|
---|
357 | /* [RB/TS:Oct/95] commented out. Used by lib/gmalloc.c - but it defines it anyway ???
|
---|
358 | *#ifndef HAVE_VALLOC
|
---|
359 | *#define valloc(Size) malloc (Size)
|
---|
360 | *#endif
|
---|
361 | */
|
---|
362 |
|
---|
363 | voidstar xmalloc __P ((size_t));
|
---|
364 | voidstar xrealloc __P ((voidstar, size_t));
|
---|
365 | char *xstrdup __P ((const char *));
|
---|
366 |
|
---|
367 | /* [TS:Aug/95]
|
---|
368 | * These were required by files which referred
|
---|
369 | * to these as function pointers.
|
---|
370 | * e.g. huffman.c - fread, mgfelics.c - fgetc
|
---|
371 | */
|
---|
372 | #ifndef HAVE_FREAD_DECL
|
---|
373 | extern size_t fread __P ((void *, size_t, size_t, FILE *));
|
---|
374 | #endif
|
---|
375 | #ifndef HAVE_FGETC_DECL
|
---|
376 | extern int fgetc __P ((FILE *));
|
---|
377 | #endif
|
---|
378 |
|
---|
379 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
380 | #ifndef u_long
|
---|
381 | # define u_long unsigned long
|
---|
382 | #endif
|
---|
383 | #ifndef u_char
|
---|
384 | # define u_char unsigned char
|
---|
385 | #endif
|
---|
386 |
|
---|
387 |
|
---|
388 | #endif /* SYSFUNCS_H */
|
---|