source: trunk/gsdl/src/mgpp/lib/sysfuncs.h@ 2442

Last change on this file since 2442 was 2442, checked in by jrm21, 23 years ago

portability changes, use getopt from unistd.h (all POSIX systems)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 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#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#define alloca __builtin_alloca
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
136#ifdef __cplusplus /* compiling for C++ */
137#include <stdlib.h>
138#ifndef __bcopy
139inline void *bcopy(void *s, void *d, int n)
140{ return memcpy(d, s, n);
141}
142#define __bcopy 1
143#endif
144#ifndef __bcmp
145inline int bcmp(void *s1, void *s2, int n)
146{ return memcmp(s1, s2, n);
147}
148#define __bcmp 1
149#endif
150#ifndef __bzero
151inline void bzero(void *m, int n)
152{ memset(m, 0, n);
153}
154#define __bzero 1
155#endif
156#else /* compiling for C */
157#ifndef bcopy
158#define bcopy(s, d, n) memcpy((d), (s), (n))
159#endif
160#ifndef bcmp
161#define bcmp(s1, s2, n) memcmp((s1), (s2), (n))
162#endif
163#ifndef bzero
164#define bzero(s, n) memset((s), 0, (n))
165#endif
166#endif
167
168#else /* not STDC_HEADERS and not HAVE_STRING_H */
169#include <strings.h>
170 /* memory.h and strings.h conflict on some systems */
171#endif
172/* ------------------------------------------------- */
173
174
175/* Declare errno. */
176
177#include <errno.h>
178#ifndef errno
179extern int errno;
180#endif
181
182/* Declare open parameters. */
183
184#ifdef HAVE_FCNTL_H
185#include <fcntl.h>
186#else
187#include <sys/file.h>
188#endif
189
190#ifndef O_BINARY
191#define O_BINARY 0
192#endif
193#ifndef O_CREAT
194#define O_CREAT 0
195#endif
196#ifndef O_NDELAY
197#define O_NDELAY 0
198#endif
199#ifndef O_RDONLY
200#define O_RDONLY 0
201#endif
202#ifndef O_RDWR
203#define O_RDWR 2
204#endif
205
206/* Declare file status routines and bits. */
207
208#ifdef STAT_MACROS_BROKEN
209#undef S_ISBLK
210#undef S_ISCHR
211#undef S_ISDIR
212#undef S_ISFIFO
213#undef S_ISLNK
214#undef S_ISMPB
215#undef S_ISMPC
216#undef S_ISNWK
217#undef S_ISREG
218#undef S_ISSOCK
219#endif
220
221/* On MSDOS, there are missing things from <sys/stat.h>. */
222#ifdef __MSDOS__
223#define S_ISUID 0
224#define S_ISGID 0
225#define S_ISVTX 0
226#endif
227
228#ifndef S_ISREG /* POSIX.1 stat stuff missing */
229#define mode_t unsigned short
230#endif
231#if !defined(S_ISBLK) && defined(S_IFBLK)
232#define S_ISBLK(Mode) (((Mode) & S_IFMT) == S_IFBLK)
233#endif
234#if !defined(S_ISCHR) && defined(S_IFCHR)
235#define S_ISCHR(Mode) (((Mode) & S_IFMT) == S_IFCHR)
236#endif
237#if !defined(S_ISDIR) && defined(S_IFDIR)
238#define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
239#endif
240#if !defined(S_ISREG) && defined(S_IFREG)
241#define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
242#endif
243#if !defined(S_ISFIFO) && defined(S_IFIFO)
244#define S_ISFIFO(Mode) (((Mode) & S_IFMT) == S_IFIFO)
245#endif
246#if !defined(S_ISLNK) && defined(S_IFLNK)
247#define S_ISLNK(Mode) (((Mode) & S_IFMT) == S_IFLNK)
248#endif
249#if !defined(S_ISSOCK) && defined(S_IFSOCK)
250#define S_ISSOCK(Mode) (((Mode) & S_IFMT) == S_IFSOCK)
251#endif
252#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
253#define S_ISMPB(Mode) (((Mode) & S_IFMT) == S_IFMPB)
254#define S_ISMPC(Mode) (((Mode) & S_IFMT) == S_IFMPC)
255#endif
256#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
257#define S_ISNWK(Mode) (((Mode) & S_IFMT) == S_IFNWK)
258#endif
259
260#if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
261#define S_ISCTG(Mode) (((Mode) & S_IFMT) == S_IFCTG)
262#endif
263#if !defined(S_ISVTX)
264#define S_ISVTX 0001000
265#endif
266
267/* [RPAP - Feb 97: WIN32 Port] */
268#if !defined(_POSIX_SOURCE) && !defined(__WIN32__)
269#include <sys/param.h>
270#endif
271
272/* Include <unistd.h> before any preprocessor test of _POSIX_VERSION. */
273#ifdef HAVE_UNISTD_H
274#include <unistd.h>
275#endif
276
277
278/* Declare standard functions. */
279
280#ifdef STDC_HEADERS
281#include <stdlib.h>
282#else
283voidstar malloc ();
284voidstar realloc ();
285char *getenv ();
286#endif
287
288#include <stdio.h>
289
290#ifndef _POSIX_VERSION
291#ifdef __MSDOS__
292#include <io.h>
293#else
294off_t lseek ();
295#endif
296#endif
297
298#include <pathmax.h>
299
300/* Until getoptold function is declared in getopt.h, we need this here for
301 struct option. */
302/*#include <getopt.h>*/
303
304#ifdef WITH_DMALLOC
305#undef HAVE_VALLOC
306#define DMALLOC_FUNC_CHECK
307#include <dmalloc.h>
308#endif
309
310/* Prototypes for external functions. */
311
312#ifndef __P
313#if PROTOTYPES
314#define __P(Args) Args
315#else
316#define __P(Args) ()
317#endif
318#endif
319
320#if HAVE_LOCALE_H
321#include <locale.h>
322#endif
323#if !HAVE_SETLOCALE
324#define setlocale(Category, Locale)
325#endif
326
327#if ENABLE_NLS
328#include <libintl.h>
329#define _(Text) gettext (Text)
330#else
331#define textdomain(Domain)
332#define _(Text) Text
333#endif
334
335/* Library modules. */
336
337#ifdef HAVE_VPRINTF
338void error __P ((int, int, const char *,...));
339#else
340void error ();
341#endif
342
343#ifndef HAVE_STRSTR
344char *strstr __P ((const char *, const char *));
345#endif
346
347/* [RB/TS:Oct/95] commented out. Used by lib/gmalloc.c - but it defines it anyway ???
348 *#ifndef HAVE_VALLOC
349 *#define valloc(Size) malloc (Size)
350 *#endif
351 */
352
353voidstar xmalloc __P ((size_t));
354voidstar xrealloc __P ((voidstar, size_t));
355char *xstrdup __P ((const char *));
356
357/* [TS:Aug/95]
358 * These were required by files which referred
359 * to these as function pointers.
360 * e.g. huffman.c - fread, mgfelics.c - fgetc
361 */
362#ifndef HAVE_FREAD_DECL
363extern size_t fread __P ((void *, size_t, size_t, FILE *));
364#endif
365#ifndef HAVE_FGETC_DECL
366extern int fgetc __P ((FILE *));
367#endif
368
369/* [RPAP - Feb 97: WIN32 Port] */
370#ifndef u_long
371# define u_long unsigned long
372#endif
373#ifndef u_char
374# define u_char unsigned char
375#endif
376
377
378#endif /* SYSFUNCS_H */
Note: See TracBrowser for help on using the repository browser.