1 /* Declarations for windows
2 Copyright (C) 1996-2006 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 3 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, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the Free Software Foundation
20 gives permission to link the code of its release of Wget with the
21 OpenSSL project's "OpenSSL" library (or with modified versions of it
22 that use the same license as the "OpenSSL" library), and distribute
23 the linked executables. You must obey the GNU General Public License
24 in all respects for all of the code used other than "OpenSSL". If you
25 modify this file, you may extend this exception to your version of the
26 file, but you are not obligated to do so. If you do not wish to do
27 so, delete this exception statement from your version. */
33 # error This file should not be included directly.
36 /* Prevent inclusion of <winsock*.h> in <windows.h>. */
37 #ifndef WIN32_LEAN_AND_MEAN
38 # define WIN32_LEAN_AND_MEAN
43 /* We need winsock2.h for IPv6 and ws2tcpip.h for getaddrinfo, so
44 include both in ENABLE_IPV6 case. (ws2tcpip.h includes winsock2.h
47 # include <winsock2.h>
48 # include <ws2tcpip.h>
54 # define EAI_SYSTEM -1 /* value doesn't matter */
57 /* Declares file access functions, such as open, creat, access, and
58 chmod. Unix declares these in unistd.h and fcntl.h. */
61 /* Declares getpid(). */
65 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
71 /* We have strcasecmp and strncasecmp, just under different names. */
72 #ifndef HAVE_STRCASECMP
73 # define strcasecmp stricmp
75 #ifndef HAVE_STRNCASECMP
76 # 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
87 /* str_to_wgint is a function with the semantics of strtol[l], but
88 which works on wgint. */
89 #if defined HAVE_STRTOLL
90 # define str_to_wgint strtoll
91 #elif defined HAVE__STRTOI64
92 # define str_to_wgint _strtoi64
94 # define str_to_wgint strtoll
96 # define strtoll_type __int64
99 /* Windows has no symlink, therefore no lstat. Without symlinks lstat
100 is equivalent to stat anyway. */
103 /* Define LFS aliases for stat and fstat. */
105 # define stat(f, b) stat_alias (f, b)
108 # define fstat(f, b) fstat_alias (f, b)
111 #define PATH_SEPARATOR '\\'
113 /* Win32 doesn't support the MODE argument to mkdir. */
115 #define mkdir(a, b) (mkdir) (a)
117 /* Additional declarations needed for IPv6: */
119 const char *inet_ntop (int, const void *, char *, socklen_t);
122 #ifdef NEED_GAI_STRERROR
124 # define gai_strerror windows_strerror
129 /* Winsock functions don't set errno, so we provide wrappers that do. */
131 #define socket wrapped_socket
132 #define bind wrapped_bind
133 #define connect wrapped_connect
134 #define listen wrapped_listen
135 #define accept wrapped_accept
136 #define recv wrapped_recv
137 #define send wrapped_send
138 #define select wrapped_select
139 #define getsockname wrapped_getsockname
140 #define getpeername wrapped_getpeername
141 #define setsockopt wrapped_setsockopt
142 #define closesocket wrapped_closesocket
144 #endif /* not INHIBIT_WRAP */
146 int wrapped_socket (int, int, int);
147 int wrapped_bind (int, struct sockaddr *, int);
148 int wrapped_connect (int, const struct sockaddr *, int);
149 int wrapped_listen (int s, int backlog);
150 int wrapped_accept (int s, struct sockaddr *a, int *alen);
151 int wrapped_recv (int, void *, int, int);
152 int wrapped_send (int, const void *, int, int);
153 int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
154 int wrapped_getsockname (int, struct sockaddr *, int *);
155 int wrapped_getpeername (int, struct sockaddr *, int *);
156 int wrapped_setsockopt (int, int, int, const void *, int);
157 int wrapped_closesocket (int);
159 /* Finally, provide a private version of strerror that does the
160 right thing with Winsock errors. */
162 # define strerror windows_strerror
164 const char *windows_strerror (int);
166 /* Declarations of various socket errors: */
168 #define EWOULDBLOCK WSAEWOULDBLOCK
169 #define EINPROGRESS WSAEINPROGRESS
170 #define EALREADY WSAEALREADY
171 #define ENOTSOCK WSAENOTSOCK
172 #define EDESTADDRREQ WSAEDESTADDRREQ
173 #define EMSGSIZE WSAEMSGSIZE
174 #define EPROTOTYPE WSAEPROTOTYPE
175 #define ENOPROTOOPT WSAENOPROTOOPT
176 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
177 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
178 #define EOPNOTSUPP WSAEOPNOTSUPP
179 #define EPFNOSUPPORT WSAEPFNOSUPPORT
180 #define EAFNOSUPPORT WSAEAFNOSUPPORT
181 #define EADDRINUSE WSAEADDRINUSE
182 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
183 #define ENETDOWN WSAENETDOWN
184 #define ENETUNREACH WSAENETUNREACH
185 #define ENETRESET WSAENETRESET
186 #define ECONNABORTED WSAECONNABORTED
187 #define ECONNRESET WSAECONNRESET
188 #define ENOBUFS WSAENOBUFS
189 #define EISCONN WSAEISCONN
190 #define ENOTCONN WSAENOTCONN
191 #define ESHUTDOWN WSAESHUTDOWN
192 #define ETOOMANYREFS WSAETOOMANYREFS
193 #define ETIMEDOUT WSAETIMEDOUT
194 #define ECONNREFUSED WSAECONNREFUSED
195 #define ELOOP WSAELOOP
196 #define EHOSTDOWN WSAEHOSTDOWN
197 #define EHOSTUNREACH WSAEHOSTUNREACH
198 #define EPROCLIM WSAEPROCLIM
199 #define EUSERS WSAEUSERS
200 #define EDQUOT WSAEDQUOT
201 #define ESTALE WSAESTALE
202 #define EREMOTE WSAEREMOTE
204 /* Public functions. */
206 void ws_startup (void);
207 void ws_changetitle (const char *);
208 void ws_percenttitle (double);
209 char *ws_mypath (void);
210 void windows_main (int *, char **, char **);
212 #endif /* MSWINDOWS_H */