source: trunk/gsdl/packages/mg/sysfuncs.h@ 4907

Last change on this file since 4907 was 4907, checked in by jrm21, 21 years ago

don't include getopt.h if UNISTD is defined, since it will conflict.

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