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

Last change on this file since 821 was 821, checked in by sjboddie, 24 years ago

fixed an inconsistency in the definition of error()

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