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

Last change on this file since 2468 was 2468, checked in by sjboddie, 23 years ago

Fiddled about with mgpp to get it compiling on Windows under VC++ 6.0. I
still can't get it to compile under VC++ 4.2 because of some weird
behaviour in STLport.

Also tidied up a little and removed some of the old log information
that was scattered about in some of the files.

  • 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#ifndef __WIN32__
299#include <pathmax.h>
300#endif
301
302/* Until getoptold function is declared in getopt.h, we need this here for
303 struct option. */
304/*#include <getopt.h>*/
305
306#ifdef WITH_DMALLOC
307#undef HAVE_VALLOC
308#define DMALLOC_FUNC_CHECK
309#include <dmalloc.h>
310#endif
311
312/* Prototypes for external functions. */
313
314#ifndef __P
315#if PROTOTYPES
316#define __P(Args) Args
317#else
318#define __P(Args) ()
319#endif
320#endif
321
322#if HAVE_LOCALE_H
323#include <locale.h>
324#endif
325#if !HAVE_SETLOCALE
326#define setlocale(Category, Locale)
327#endif
328
329#if ENABLE_NLS
330#include <libintl.h>
331#define _(Text) gettext (Text)
332#else
333#define textdomain(Domain)
334#define _(Text) Text
335#endif
336
337/* Library modules. */
338
339#ifdef HAVE_VPRINTF
340void error __P ((int, int, const char *,...));
341#else
342void error ();
343#endif
344
345#ifndef HAVE_STRSTR
346char *strstr __P ((const char *, const char *));
347#endif
348
349/* [RB/TS:Oct/95] commented out. Used by lib/gmalloc.c - but it defines it anyway ???
350 *#ifndef HAVE_VALLOC
351 *#define valloc(Size) malloc (Size)
352 *#endif
353 */
354
355voidstar xmalloc __P ((size_t));
356voidstar xrealloc __P ((voidstar, size_t));
357char *xstrdup __P ((const char *));
358
359/* [TS:Aug/95]
360 * These were required by files which referred
361 * to these as function pointers.
362 * e.g. huffman.c - fread, mgfelics.c - fgetc
363 */
364#ifndef HAVE_FREAD_DECL
365extern size_t fread __P ((void *, size_t, size_t, FILE *));
366#endif
367#ifndef HAVE_FGETC_DECL
368extern int fgetc __P ((FILE *));
369#endif
370
371/* [RPAP - Feb 97: WIN32 Port] */
372#ifndef u_long
373# define u_long unsigned long
374#endif
375#ifndef u_char
376# define u_char unsigned char
377#endif
378
379
380#endif /* SYSFUNCS_H */
Note: See TracBrowser for help on using the repository browser.