1 /* Declarations for windows
2 Copyright (C) 1996-2005 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
9 (at 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 Foundation, Inc.,
18 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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. */
34 # error This file should not be included directly.
37 /* Prevent inclusion of <winsock*.h> in <windows.h>. */
38 #ifndef WIN32_LEAN_AND_MEAN
39 # define WIN32_LEAN_AND_MEAN
44 /* We need winsock2.h for IPv6 and ws2tcpip.h for getaddrinfo, so
45 include both in ENABLE_IPV6 case. (ws2tcpip.h includes winsock2.h
48 # include <winsock2.h>
49 # include <ws2tcpip.h>
55 # define EAI_SYSTEM -1 /* value doesn't matter */
58 /* Declares file access functions, such as open, creat, access, and
59 chmod. Unix declares these in unistd.h and fcntl.h. */
62 /* Declares getpid(). */
66 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
72 /* We have strcasecmp and strncasecmp, just under different names. */
73 #ifndef HAVE_STRCASECMP
74 # define strcasecmp stricmp
76 #ifndef HAVE_STRNCASECMP
77 # define strncasecmp strnicmp
80 /* The same for snprintf() and vsnprintf(). */
81 #define snprintf _snprintf
82 #define vsnprintf _vsnprintf
84 /* Define a wgint type under Windows. */
85 typedef __int64 wgint;
86 #define SIZEOF_WGINT 8
87 #define WGINT_MAX LL (9223372036854775807)
89 /* str_to_wgint is a function with the semantics of strtol[l], but
90 which works on wgint. */
91 #if defined HAVE_STRTOLL
92 # define str_to_wgint strtoll
93 #elif defined HAVE__STRTOI64
94 # define str_to_wgint _strtoi64
96 # define str_to_wgint strtoll
98 # define strtoll_type __int64
101 /* Windows has no symlink, therefore no lstat. Without symlinks lstat
102 is equivalent to stat anyway. */
105 /* Define LFS aliases for stat and fstat. */
107 # define stat(f, b) stat_alias (f, b)
110 # define fstat(f, b) fstat_alias (f, b)
113 #define PATH_SEPARATOR '\\'
115 /* Win32 doesn't support the MODE argument to mkdir. */
117 #define mkdir(a, b) (mkdir) (a)
119 /* Additional declarations needed for IPv6: */
121 const char *inet_ntop (int, const void *, char *, socklen_t);
124 #ifdef NEED_GAI_STRERROR
126 # define gai_strerror windows_strerror
131 /* Winsock functions don't set errno, so we provide wrappers that do. */
133 #define socket wrapped_socket
134 #define bind wrapped_bind
135 #define connect wrapped_connect
136 #define listen wrapped_listen
137 #define accept wrapped_accept
138 #define recv wrapped_recv
139 #define send wrapped_send
140 #define select wrapped_select
141 #define getsockname wrapped_getsockname
142 #define getpeername wrapped_getpeername
143 #define setsockopt wrapped_setsockopt
144 #define closesocket wrapped_closesocket
146 #endif /* not INHIBIT_WRAP */
148 int wrapped_socket (int, int, int);
149 int wrapped_bind (int, struct sockaddr *, int);
150 int wrapped_connect (int, const struct sockaddr *, int);
151 int wrapped_listen (int s, int backlog);
152 int wrapped_accept (int s, struct sockaddr *a, int *alen);
153 int wrapped_recv (int, void *, int, int);
154 int wrapped_send (int, const void *, int, int);
155 int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
156 int wrapped_getsockname (int, struct sockaddr *, int *);
157 int wrapped_getpeername (int, struct sockaddr *, int *);
158 int wrapped_setsockopt (int, int, int, const void *, int);
159 int wrapped_closesocket (int);
161 /* Finally, provide a private version of strerror that does the
162 right thing with Winsock errors. */
164 # define strerror windows_strerror
166 const char *windows_strerror (int);
168 /* Declarations of various socket errors: */
170 #define EWOULDBLOCK WSAEWOULDBLOCK
171 #define EINPROGRESS WSAEINPROGRESS
172 #define EALREADY WSAEALREADY
173 #define ENOTSOCK WSAENOTSOCK
174 #define EDESTADDRREQ WSAEDESTADDRREQ
175 #define EMSGSIZE WSAEMSGSIZE
176 #define EPROTOTYPE WSAEPROTOTYPE
177 #define ENOPROTOOPT WSAENOPROTOOPT
178 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
179 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
180 #define EOPNOTSUPP WSAEOPNOTSUPP
181 #define EPFNOSUPPORT WSAEPFNOSUPPORT
182 #define EAFNOSUPPORT WSAEAFNOSUPPORT
183 #define EADDRINUSE WSAEADDRINUSE
184 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
185 #define ENETDOWN WSAENETDOWN
186 #define ENETUNREACH WSAENETUNREACH
187 #define ENETRESET WSAENETRESET
188 #define ECONNABORTED WSAECONNABORTED
189 #define ECONNRESET WSAECONNRESET
190 #define ENOBUFS WSAENOBUFS
191 #define EISCONN WSAEISCONN
192 #define ENOTCONN WSAENOTCONN
193 #define ESHUTDOWN WSAESHUTDOWN
194 #define ETOOMANYREFS WSAETOOMANYREFS
195 #define ETIMEDOUT WSAETIMEDOUT
196 #define ECONNREFUSED WSAECONNREFUSED
197 #define ELOOP WSAELOOP
198 #define EHOSTDOWN WSAEHOSTDOWN
199 #define EHOSTUNREACH WSAEHOSTUNREACH
200 #define EPROCLIM WSAEPROCLIM
201 #define EUSERS WSAEUSERS
202 #define EDQUOT WSAEDQUOT
203 #define ESTALE WSAESTALE
204 #define EREMOTE WSAEREMOTE
206 /* Public functions. */
208 void ws_startup (void);
209 void ws_changetitle (const char *);
210 void ws_percenttitle (double);
211 char *ws_mypath (void);
212 void windows_main (int *, char **, char **);
214 #endif /* MSWINDOWS_H */