source: indexers/trunk/mg/sysfuncs.h@ 14911

Last change on this file since 14911 was 14911, checked in by davidb, 16 years ago

Standardisation of Windows config file to lowercase (included from this source file). Was causing a problem when trying to compile on Unix filesystem mounted under Windows.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 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#if defined(__WIN32__)
274#include <io.h>
275#define lseek _lseek
276#elif defined(__MSDOS__)
277#include <io.h>
278#else
279off_t lseek ();
280#endif
281#endif
282
283#include <pathmax.h>
284
285/* jrm21 2003 - this is in unistd.h now */
286#ifndef HAVE_UNISTD_H
287#include <getopt.h>
288#endif
289
290#ifdef WITH_DMALLOC
291#undef HAVE_VALLOC
292#define DMALLOC_FUNC_CHECK
293#include <dmalloc.h>
294#endif
295
296/* Prototypes for external functions. */
297
298#ifndef __P
299#if PROTOTYPES
300#define __P(Args) Args
301#else
302#define __P(Args) ()
303#endif
304#endif
305
306#if HAVE_LOCALE_H
307#include <locale.h>
308#endif
309
310#if ENABLE_NLS
311#include <libintl.h>
312#define _(Text) gettext (Text)
313#else
314#define textdomain(Domain)
315#define _(Text) Text
316#endif
317
318/* Library modules. */
319
320#if (HAVE_VPRINTF || HAVE_DOPRNT) && __STDC__
321/*void error __P ((int, int, const char *,...));*/
322void error (int, int, const char *,...);
323#else
324void error (int, int, char *, char *, char *, char *, char *, char *, char *, char *, char *);
325#endif
326
327#ifndef HAVE_STRSTR
328char *strstr __P ((const char *, const char *));
329#endif
330
331/* [RB/TS:Oct/95] commented out. Used by lib/gmalloc.c - but it defines it anyway ???
332 *#ifndef HAVE_VALLOC
333 *#define valloc(Size) malloc (Size)
334 *#endif
335 */
336
337voidstar xmalloc __P ((size_t));
338voidstar xrealloc __P ((voidstar, size_t));
339char *xstrdup __P ((const char *));
340
341/* [TS:Aug/95]
342 * These were required by files which referred
343 * to these as function pointers.
344 * e.g. huffman.c - fread, mgfelics.c - fgetc
345 */
346#ifndef HAVE_FREAD_DECL
347extern size_t fread __P ((void *, size_t, size_t, FILE *));
348#endif
349#ifndef HAVE_FGETC_DECL
350extern int fgetc __P ((FILE *));
351#endif
352
353/* [RPAP - Feb 97: WIN32 Port] */
354#ifndef u_long
355# define u_long unsigned long
356#endif
357#ifndef u_char
358# define u_char unsigned char
359#endif
360
361
362#endif /* SYSFUNCS_H */
Note: See TracBrowser for help on using the repository browser.