source: main/trunk/greenstone2/common-src/indexers/mgpp/lib/sysfuncs.h@ 29051

Last change on this file since 29051 was 29051, checked in by ak19, 10 years ago

Dr Bainbridge made some fixes to header file inclusions so that when compiling with Visual Studio 12 (2013) on Windows (64 bit), GS2 still compiles successfully

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