1 /* Dirty system-dependent hacks.
2 Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
4 This file is part of GNU Wget.
6 GNU Wget is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at
9 your option) any later version.
11 GNU Wget is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Wget; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 In addition, as a special exception, the Free Software Foundation
21 gives permission to link the code of its release of Wget with the
22 OpenSSL project's "OpenSSL" library (or with modified versions of it
23 that use the same license as the "OpenSSL" library), and distribute
24 the linked executables. You must obey the GNU General Public License
25 in all respects for all of the code used other than "OpenSSL". If you
26 modify this file, you may extend this exception to your version of the
27 file, but you are not obligated to do so. If you do not wish to do
28 so, delete this exception statement from your version. */
30 /* This file is included by wget.h. Random .c files need not include
36 /* Must include these, so we can test for the missing stat macros and
37 define them as necessary. */
38 #include <sys/types.h>
41 #ifdef HAVE_INTTYPES_H
42 # include <inttypes.h>
46 /* Windows doesn't have some functions normally found on Unix-like
47 systems, such as strcasecmp, strptime, strpbrk, etc. Include
48 mswindows.h so we get the declarations for their replacements in
49 mswindows.c, as well as to pick up Windows-specific includes and
50 constants. To be able to test for such features, the file must be
51 included as early as possible. */
52 # include <mswindows.h>
55 /* Provide support for C99-type boolean type "bool". This blurb comes
56 straight from the Autoconf 2.59 manual. */
64 typedef unsigned char _Bool;
70 # define __bool_true_false_are_defined 1
73 /* Needed for compilation under OS/2: */
83 /* Reportedly, stat() macros are broken on some old systems. Those
84 systems will have to fend for themselves, as I will not introduce
85 new code to handle it.
87 However, I will add code for *missing* macros, and the following
88 are reportedly missing from many systems. */
90 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
93 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
96 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
99 /* Define a large integral type useful for storing large sizes that
100 exceed sizes of one download, such as when printing the sum of all
101 downloads. Note that this has nothing to do with large file
102 support, which determines the wgint type. This should be as large
103 as possible even on systems where when wgint is 32-bit; also,
104 unlike wgint, this can be a floating point type.
106 We use a 64-bit integral type where available, `double' otherwise.
107 It's hard to print LARGE_INT's portably, but fortunately it's
111 /* Long is large enough: use it. */
112 typedef long LARGE_INT;
113 # define LARGE_INT_FMT "%ld"
114 #elif SIZEOF_LONG_LONG >= 8
115 /* Long long is large enough: use it. */
116 typedef long long LARGE_INT;
117 # define LARGE_INT_FMT "%lld"
119 /* Use __int64 under Windows. */
120 typedef __int64 LARGE_INT;
121 # define LARGE_INT_FMT "%I64"
123 /* Large integer type unavailable; fake it with `double'. */
124 typedef double LARGE_INT;
125 # define LARGE_INT_FMT "%.0f"
128 /* Under Windows we #define struct_stat to struct _stati64. */
130 # define struct_stat struct stat
133 /* For CHAR_BIT, LONG_MAX, etc. */
140 /* Used by wget.h to define SIZEOF_WGINT. */
142 # define LONG_MAX ((long) ~((unsigned long)1 << (CHAR_BIT * sizeof (long) - 1)))
145 # define LLONG_MAX ((long long) ~((unsigned long long)1 << (CHAR_BIT * sizeof (long long) - 1)))
148 /* These are defined in cmpt.c if missing, so we must declare
150 #ifndef HAVE_STRCASECMP
153 #ifndef HAVE_STRNCASECMP
156 #ifndef HAVE_STRPTIME
160 /* These are defined in snprintf.c. It would be nice to have an
161 snprintf.h, though. */
162 #ifndef HAVE_SNPRINTF
165 #ifndef HAVE_VSNPRINTF
169 /* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't
170 provide MAP_FAILED, a symbolic constant for the value returned by
171 mmap() when it doesn't work. Usually, this constant should be -1.
172 This only makes sense for files that use mmap() and include
173 sys/mman.h *before* sysdep.h, but doesn't hurt others. */
176 # define MAP_FAILED ((void *) -1)
179 /* Enable system fnmatch only on systems where fnmatch.h is usable and
180 which are known to have a non-broken fnmatch implementation.
181 Currently those include glibc-based systems and Solaris. One could
182 add more, but fnmatch is not that large, so it might be better to
184 #ifdef HAVE_WORKING_FNMATCH_H
185 # if defined __GLIBC__ && __GLIBC__ >= 2
186 # define SYSTEM_FNMATCH
189 # define SYSTEM_FNMATCH
191 #endif /* HAVE_WORKING_FNMATCH_H */
193 #ifdef SYSTEM_FNMATCH
194 # include <fnmatch.h>
195 #else /* not SYSTEM_FNMATCH */
196 /* Define fnmatch flags. Undef them first to avoid warnings in case
197 an evil library include chose to include system fnmatch.h. */
203 # define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
204 # define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
205 # define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
206 # define FNM_NOMATCH 1
208 /* Declare the function minimally. */
212 /* Provide sig_atomic_t if the system doesn't. */
213 #ifndef HAVE_SIG_ATOMIC_T
214 typedef int sig_atomic_t;
217 /* Provide uint32_t on the platforms that don't define it. Although
218 most code should be agnostic about integer sizes, some code really
219 does need a 32-bit integral type. Such code should use uint32_t.
220 (The exception is gnu-md5.[ch], which uses its own detection for
221 portability across platforms.) */
223 #ifndef HAVE_UINT32_T
225 typedef unsigned int uint32_t;
227 # if SIZEOF_LONG == 4
228 typedef unsigned long uint32_t;
230 # if SIZEOF_SHORT == 4
231 typedef unsigned short uint32_t;
233 #error "Cannot determine a 32-bit unsigned integer type"
239 #endif /* SYSDEP_H */