]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ankh/examples/wget/contrib/src/sysdep.h
Inital import
[l4.git] / l4 / pkg / ankh / examples / wget / contrib / src / sysdep.h
1 /* Dirty system-dependent hacks.
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3    2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
5 This file is part of GNU Wget.
6
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at
10 your option) any later version.
11
12 GNU Wget is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
19
20 Additional permission under GNU GPL version 3 section 7
21
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work.  */
30
31 /* This file is included by wget.h.  Random .c files need not include
32    it.  */
33
34 #ifndef SYSDEP_H
35 #define SYSDEP_H
36
37 /* Must include these, so we can test for the missing stat macros and
38    define them as necessary.  */
39 #include <sys/types.h>
40 #include <sys/stat.h>
41
42 #ifdef HAVE_INTTYPES_H
43 # include <inttypes.h>
44 #endif
45
46 #ifdef WINDOWS
47 /* Windows doesn't have some functions normally found on Unix-like
48    systems, such as strcasecmp, strptime, etc.  Include mswindows.h so
49    we get the declarations for their replacements in mswindows.c, as
50    well as to pick up Windows-specific includes and constants.  To be
51    able to test for such features, the file must be included as early
52    as possible.  */
53 # include "mswindows.h"
54 #endif
55
56 /* Provide support for C99-type boolean type "bool".  This blurb comes
57    straight from the Autoconf 2.59 manual. */
58 #if HAVE_STDBOOL_H
59 # include <stdbool.h>
60 #else
61 # if ! HAVE__BOOL
62 #  ifdef __cplusplus
63 typedef bool _Bool;
64 #  else
65 //typedef unsigned char _Bool;
66 #define _Bool unsigned char
67 #  endif
68 # endif
69 # define bool _Bool
70 # define false 0
71 # define true 1
72 # define __bool_true_false_are_defined 1
73 #endif
74
75 /* Needed for compilation under OS/2 and MSDOS */
76 #if defined(__EMX__) || defined(MSDOS)
77 # ifndef S_ISLNK
78 #  define S_ISLNK(m) 0
79 # endif
80 # ifndef lstat
81 #  define lstat stat
82 # endif
83 #endif /* __EMX__ || MSDOS */
84
85 /* Reportedly, stat() macros are broken on some old systems.  Those
86    systems will have to fend for themselves, as I will not introduce
87    new code to handle it.
88
89    However, I will add code for *missing* macros, and the following
90    are reportedly missing from many systems.  */
91 #ifndef S_ISLNK
92 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
93 #endif
94 #ifndef S_ISDIR
95 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
96 #endif
97 #ifndef S_ISREG
98 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
99 #endif
100
101 /* These are needed so we can #define struct_stat to struct _stati64
102    under Windows. */
103 #ifndef struct_stat
104 # define struct_stat struct stat
105 #endif
106 #ifndef struct_fstat
107 # define struct_fstat struct stat
108 #endif
109
110 /* For CHAR_BIT, LONG_MAX, etc. */
111 #include <limits.h>
112
113 #ifndef CHAR_BIT
114 # define CHAR_BIT 8
115 #endif
116
117 /* From gnulib, simplified to assume a signed type. */
118 #define TYPE_MAXIMUM(t) ((t) (~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
119
120 /* These are defined in cmpt.c if missing, so we must declare
121    them.  */
122 #ifndef HAVE_STRCASECMP
123 int strcasecmp ();
124 #endif
125 #ifndef HAVE_STRNCASECMP
126 int strncasecmp ();
127 #endif
128 #ifndef HAVE_STRPTIME
129 char *strptime ();
130 #endif
131 #ifndef HAVE_TIMEGM
132 # include <time.h>
133 time_t timegm (struct tm *);
134 #endif
135 #ifndef HAVE_MEMRCHR
136 void *memrchr (const void *, int, size_t);
137 #endif
138
139 /* These are defined in snprintf.c.  It would be nice to have an
140    snprintf.h, though.  */
141 #ifndef HAVE_SNPRINTF
142 int snprintf ();
143 #endif
144 #ifndef HAVE_VSNPRINTF
145 int vsnprintf ();
146 #endif
147
148 /* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't
149    provide MAP_FAILED, a symbolic constant for the value returned by
150    mmap() when it doesn't work.  Usually, this constant should be -1.
151    This only makes sense for files that use mmap() and include
152    sys/mman.h *before* sysdep.h, but doesn't hurt others.  */
153
154 #ifndef MAP_FAILED
155 # define MAP_FAILED ((void *) -1)
156 #endif
157
158 /* Enable system fnmatch only on systems where fnmatch.h is usable.
159    If the fnmatch on your system is buggy, undef this symbol and a
160    replacement implementation will be used instead.  */
161 #ifdef HAVE_WORKING_FNMATCH_H
162 # define SYSTEM_FNMATCH
163 #endif
164
165 #ifdef SYSTEM_FNMATCH
166 # include <fnmatch.h>
167 #else  /* not SYSTEM_FNMATCH */
168 /* Define fnmatch flags.  Undef them first to avoid warnings in case
169    an evil library include chose to include system fnmatch.h.  */
170 # undef FNM_PATHNAME
171 # undef FNM_NOESCAPE
172 # undef FNM_PERIOD
173 # undef FNM_NOMATCH
174
175 # define FNM_PATHNAME   (1 << 0) /* No wildcard can ever match `/'.  */
176 # define FNM_NOESCAPE   (1 << 1) /* Backslashes don't quote special chars.  */
177 # define FNM_PERIOD     (1 << 2) /* Leading `.' is matched only explicitly.  */
178 # define FNM_NOMATCH    1
179
180 int fnmatch (const char *, const char *, int);
181 #endif
182
183 /* Provide sig_atomic_t if the system doesn't.  */
184 #ifndef HAVE_SIG_ATOMIC_T
185 typedef int sig_atomic_t;
186 #endif
187
188 /* Provide uint32_t on the platforms that don't define it.  Although
189    most code should be agnostic about integer sizes, some code really
190    does need a 32-bit integral type.  Such code should use uint32_t.
191    (The exception is gnu-md5.[ch], which uses its own detection for
192    portability across platforms.)  */
193
194 #ifndef HAVE_UINT32_T
195 # if SIZEOF_INT == 4
196 typedef unsigned int uint32_t;
197 # else
198 #  if SIZEOF_LONG == 4
199 typedef unsigned long uint32_t;
200 #  else
201 #   if SIZEOF_SHORT == 4
202 typedef unsigned short uint32_t;
203 #   else
204  #error "Cannot determine a 32-bit unsigned integer type"
205 #   endif
206 #  endif
207 # endif
208 #endif
209
210 /* If uintptr_t isn't defined, simply typedef it to unsigned long. */
211 #ifndef HAVE_UINTPTR_T
212 typedef unsigned long uintptr_t;
213 #endif
214
215 /* If intptr_t isn't defined, simply typedef it to long. */
216 #ifndef HAVE_INTPTR_T
217 typedef long intptr_t;
218 #endif
219
220 #endif /* SYSDEP_H */