1 /* Declarations for windows
2 Copyright (C) 1995, 1997, 1997, 1998, 2004
3 Free Software Foundation, Inc.
5 This file is part of GNU Wget.
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with Wget; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 In addition, as a special exception, the Free Software Foundation
22 gives permission to link the code of its release of Wget with the
23 OpenSSL project's "OpenSSL" library (or with modified versions of it
24 that use the same license as the "OpenSSL" library), and distribute
25 the linked executables. You must obey the GNU General Public License
26 in all respects for all of the code used other than "OpenSSL". If you
27 modify this file, you may extend this exception to your version of the
28 file, but you are not obligated to do so. If you do not wish to do
29 so, delete this exception statement from your version. */
35 #error Include mswindows.h inside or after "wget.h"
38 /* Prevent inclusion of <winsock*.h> in <windows.h>. */
39 #ifndef WIN32_LEAN_AND_MEAN
40 #define WIN32_LEAN_AND_MEAN
45 /* Use the correct winsock header; <ws2tcpip.h> includes <winsock2.h> only
46 on Watcom/MingW. We cannot use <winsock.h> for IPv6. Using
47 getaddrinfo() requires <ws2tcpip.h>. */
48 #if defined(ENABLE_IPV6) || defined(HAVE_GETADDRINFO)
49 # include <winsock2.h>
50 # include <ws2tcpip.h>
56 # define EAI_SYSTEM -1 /* value doesn't matter */
59 /* Must include <sys/stat.h> because of 'stat' define below. */
62 /* Missing in several .c files. Include here. */
65 /* Apparently needed for alloca(). */
69 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
75 /* We have strcasecmp and strncasecmp, just under a different name. */
76 #define strcasecmp stricmp
77 #define strncasecmp strnicmp
79 /* The same for snprintf() and vsnprintf(). */
80 #define snprintf _snprintf
81 #define vsnprintf _vsnprintf
83 /* Define a wgint type under Windows. */
84 typedef __int64 wgint;
85 #define SIZEOF_WGINT 8
88 #define WGINT_MAX 9223372036854775807LL
90 #define WGINT_MAX 9223372036854775807I64
93 #define str_to_wgint str_to_int64
94 __int64 str_to_int64 (const char *, char **, int);
96 /* No lstat on Windows. */
99 /* Transparently support large files, in spirit similar to the POSIX
101 #define stat(fname, buf) _stati64 (fname, buf)
104 # define fstat(fd, buf) _fstati64 (fd, buf)
107 #if defined(_MSC_VER) || defined(__MINGW32__)
108 # define struct_stat struct _stati64
109 #elif defined(__BORLANDC__)
110 # define struct_stat struct stati64
112 # define struct_stat struct stat
115 #define PATH_SEPARATOR '\\'
119 # define isatty _isatty
123 /* #### Do we need this? */
126 /* Windows compilers accept only one arg to mkdir. */
128 # define mkdir(a, b) _mkdir(a)
129 #else /* __BORLANDC__ */
130 # define mkdir(a, b) mkdir(a)
131 #endif /* __BORLANDC__ */
135 /* Winsock functions don't set errno, so we provide wrappers
138 #define socket wrap_socket
139 #define bind wrap_bind
140 #define connect wrap_connect
141 #define recv wrap_recv
142 #define send wrap_send
143 #define select wrap_select
144 #define getsockname wrap_getsockname
145 #define getpeername wrap_getpeername
146 #define setsockopt wrap_setsockopt
148 #endif /* not INHIBIT_WRAP */
150 int wrap_socket (int, int, int);
151 int wrap_bind (int, struct sockaddr *, int);
152 int wrap_connect (int, const struct sockaddr *, int);
153 int wrap_recv (int, void *, int, int);
154 int wrap_send (int, const void *, int, int);
155 int wrap_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
156 int wrap_getsockname (int, struct sockaddr *, int *);
157 int wrap_getpeername (int, struct sockaddr *, int *);
158 int wrap_setsockopt (int, int, int, const void *, int);
160 /* Finally, provide a private version of strerror that does the
161 right thing with Winsock errors. */
163 # define strerror windows_strerror
165 const char *windows_strerror (int);
167 /* Declarations of various socket errors: */
169 #define EWOULDBLOCK WSAEWOULDBLOCK
170 #define EINPROGRESS WSAEINPROGRESS
171 #define EALREADY WSAEALREADY
172 #define ENOTSOCK WSAENOTSOCK
173 #define EDESTADDRREQ WSAEDESTADDRREQ
174 #define EMSGSIZE WSAEMSGSIZE
175 #define EPROTOTYPE WSAEPROTOTYPE
176 #define ENOPROTOOPT WSAENOPROTOOPT
177 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
178 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
179 #define EOPNOTSUPP WSAEOPNOTSUPP
180 #define EPFNOSUPPORT WSAEPFNOSUPPORT
181 #define EAFNOSUPPORT WSAEAFNOSUPPORT
182 #define EADDRINUSE WSAEADDRINUSE
183 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
184 #define ENETDOWN WSAENETDOWN
185 #define ENETUNREACH WSAENETUNREACH
186 #define ENETRESET WSAENETRESET
187 #define ECONNABORTED WSAECONNABORTED
188 #define ECONNRESET WSAECONNRESET
189 #define ENOBUFS WSAENOBUFS
190 #define EISCONN WSAEISCONN
191 #define ENOTCONN WSAENOTCONN
192 #define ESHUTDOWN WSAESHUTDOWN
193 #define ETOOMANYREFS WSAETOOMANYREFS
194 #define ETIMEDOUT WSAETIMEDOUT
195 #define ECONNREFUSED WSAECONNREFUSED
196 #define ELOOP WSAELOOP
197 #define EHOSTDOWN WSAEHOSTDOWN
198 #define EHOSTUNREACH WSAEHOSTUNREACH
199 #define EPROCLIM WSAEPROCLIM
200 #define EUSERS WSAEUSERS
201 #define EDQUOT WSAEDQUOT
202 #define ESTALE WSAESTALE
203 #define EREMOTE WSAEREMOTE
205 /* Public functions. */
208 unsigned int sleep (unsigned);
211 int usleep (unsigned long);
214 void ws_startup (void);
215 void ws_changetitle (const char *);
216 void ws_percenttitle (double);
217 char *ws_mypath (void);
218 void windows_main (int *, char **, char **);
220 /* Things needed for IPv6; missing in <ws2tcpip.h>. */
223 extern const char *inet_ntop (int af, const void *src, char *dst, size_t size);
226 extern int inet_pton (int af, const char *src, void *dst);
228 #endif /* ENABLE_IPV6 */
230 #endif /* MSWINDOWS_H */