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 /* This file is included by wget.h. Random .c files need not include
26 /* We need these to be playing with various stuff. */
27 #ifdef TIME_WITH_SYS_TIME
28 # include <sys/time.h>
30 #else /* not TIME_WITH_SYS_TIME_H */
31 #ifdef HAVE_SYS_TIME_H
32 # include <sys/time.h>
33 #else /* not HAVE_SYS_TIME_H */
35 #endif /* HAVE_SYS_TIME_H */
36 #endif /* TIME_WITH_SYS_TIME_H */
38 #include <sys/types.h>
42 /* Windows doesn't have some functions. Include mswindows.h so we get
43 their declarations, as well as some additional declarations and
44 macros. This must come first, so it can set things up. */
45 #include <mswindows.h>
48 /* Watcom-specific stuff. In practice this is probably specific to
49 Windows, although Watcom exists under other OS's too. For that
50 reason, we keep this here. */
53 /* Watcom has its own alloca() defined in malloc.h malloc.h needs to
54 be included in the sources to prevent 'undefined external' errors
57 /* io.h defines unlink() and chmod(). We put this here because it's
58 way too obscure to require all the .c files to observe. */
60 #endif /* __WATCOMC__ */
62 /* Needed for compilation under OS/2: */
72 /* Reportedly, stat() macros are broken on some old systems. Those
73 systems will have to fend for themselves, as I will not introduce
74 new code to handle it.
76 However, I will add code for *missing* macros, and the following
77 are missing from many systems. */
79 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
82 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
85 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
88 /* Bletch! SPARC compiler doesn't define sparc (needed by
89 arpa/nameser.h) when in -Xc mode. Luckily, it always defines
100 # define READ(fd, buf, cnt) recv((fd), (buf), (cnt), 0)
101 # define WRITE(fd, buf, cnt) send((fd), (buf), (cnt), 0)
104 /* mswindows.h defines these. */
106 # define READ(fd, buf, cnt) read ((fd), (buf), (cnt))
109 # define WRITE(fd, buf, cnt) write ((fd), (buf), (cnt))
112 # define REALCLOSE(x) close (x)
118 DEBUGP (("Closing fd %d\n", x)); \
121 /* Define a large ("very long") type useful for storing large
122 non-negative quantities that exceed sizes of normal download, such
123 as the *total* number of bytes downloaded. To fit today's needs,
124 this needs to be an integral type at least 64 bits wide. On the
125 machines where `long' is 64-bit, we use long. Otherwise, we check
126 whether `long long' is available and if yes, use that. If long
127 long is unavailable, we give up and just use `long'.
129 This check could be smarter and moved to configure, which could
130 check for a bunch of non-standard types such as uint64_t. But I
131 don't see the need for it -- the current test will work on all
132 modern architectures, and if it fails, nothing bad happens, we just
135 Note: you cannot use VERY_LONG_TYPE along with printf(). When you
136 need to print it, use very_long_to_string(). */
138 #if (SIZEOF_LONG >= 8) || !defined(HAVE_LONG_LONG)
139 /* either long is "big enough", or long long is unavailable which
140 leaves long as the only choice. */
141 # define VERY_LONG_TYPE unsigned long
142 #else /* use long long */
143 /* long is smaller than 8 bytes, but long long is available. */
144 # define VERY_LONG_TYPE unsigned long long
145 #endif /* use long long */
147 /* Defined in cmpt.c: */
148 #ifndef HAVE_STRERROR
151 #ifndef HAVE_STRCASECMP
154 #ifndef HAVE_STRNCASECMP
160 #ifndef HAVE_STRPTIME
163 #ifndef HAVE_VSNPRINTF
170 /* SunOS brain damage -- for some reason, SunOS header files fail to
171 declare the functions below, which causes all kinds of problems
172 (compiling errors) with pointer arithmetic and similar.
174 This used to be only within `#ifdef STDC_HEADERS', but it got
175 tripped on other systems (AIX), thus causing havoc. Fortunately,
176 SunOS appears to be the only system braindamaged that badly, so I
177 added an extra `#ifdef sun' guard. */
187 #endif /* not __cplusplus */
189 #endif /* STDC_HEADERS */
191 /* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't
192 provide MAP_FAILED, a symbolic constant for the value returned by
193 mmap() when it doesn't work. Usually, this constant should be -1.
194 This only makes sense for files that use mmap() and include
195 sys/mman.h *before* sysdep.h, but doesn't hurt others. */
198 # define MAP_FAILED ((void *) -1)
201 /* Define wrapper macros for different MD5 routines. */
204 #ifdef HAVE_BUILTIN_MD5
205 # include <gnu-md5.h>
206 # define MD5_CONTEXT_TYPE struct md5_ctx
207 # define MD5_INIT(ctx) md5_init_ctx (ctx)
208 # define MD5_UPDATE(buffer, len, ctx) md5_process_bytes (buffer, len, ctx)
209 # define MD5_FINISH(ctx, result) md5_finish_ctx (ctx, result)
212 #ifdef HAVE_SOLARIS_MD5
214 # define MD5_CONTEXT_TYPE MD5_CTX
215 # define MD5_INIT(ctx) MD5Init (ctx)
216 # define MD5_UPDATE(buffer, len, ctx) MD5Update (ctx, (unsigned char *)(buffer), len)
217 # define MD5_FINISH(ctx, result) MD5Final ((unsigned char *)(result), ctx)
220 #endif /* HAVE_MD5 */
222 #endif /* SYSDEP_H */