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. */
63 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
69 /* We have strcasecmp and strncasecmp, just under different names. */
70 #ifndef HAVE_STRCASECMP
71 # define strcasecmp stricmp
73 #ifndef HAVE_STRNCASECMP
74 # define strncasecmp strnicmp
77 /* The same for snprintf() and vsnprintf(). */
78 #define snprintf _snprintf
79 #define vsnprintf _vsnprintf
81 /* Define a wgint type under Windows. */
82 typedef __int64 wgint;
83 #define SIZEOF_WGINT 8
84 #define WGINT_MAX LL (9223372036854775807)
86 /* str_to_wgint is a function with the semantics of strtol, but which
88 #if defined HAVE_STRTOLL
89 # define str_to_wgint strtoll
90 #elif defined HAVE__STRTOI64
91 # define str_to_wgint _strtoi64
93 __int64 str_to_int64 (const char *, char **, int);
94 # define str_to_wgint str_to_int64
97 /* Windows has no symlink, therefore no lstat. Without symlinks lstat
98 is equivalent to stat anyway. */
101 #define PATH_SEPARATOR '\\'
103 /* Win32 doesn't support the MODE argument to mkdir. */
105 #define mkdir(a, b) (mkdir) (a)
107 /* Additional declarations needed for IPv6: */
109 const char *inet_ntop (int, const void *, char *, socklen_t);
114 /* Winsock functions don't set errno, so we provide wrappers that do. */
116 #define socket wrapped_socket
117 #define bind wrapped_bind
118 #define connect wrapped_connect
119 #define listen wrapped_listen
120 #define accept wrapped_accept
121 #define recv wrapped_recv
122 #define send wrapped_send
123 #define select wrapped_select
124 #define getsockname wrapped_getsockname
125 #define getpeername wrapped_getpeername
126 #define setsockopt wrapped_setsockopt
127 #define closesocket wrapped_closesocket
129 #endif /* not INHIBIT_WRAP */
131 int wrapped_socket (int, int, int);
132 int wrapped_bind (int, struct sockaddr *, int);
133 int wrapped_connect (int, const struct sockaddr *, int);
134 int wrapped_listen (int s, int backlog);
135 int wrapped_accept (int s, struct sockaddr *a, int *alen);
136 int wrapped_recv (int, void *, int, int);
137 int wrapped_send (int, const void *, int, int);
138 int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
139 int wrapped_getsockname (int, struct sockaddr *, int *);
140 int wrapped_getpeername (int, struct sockaddr *, int *);
141 int wrapped_setsockopt (int, int, int, const void *, int);
142 int wrapped_closesocket (int);
144 /* Finally, provide a private version of strerror that does the
145 right thing with Winsock errors. */
147 # define strerror windows_strerror
149 const char *windows_strerror (int);
151 /* Declarations of various socket errors: */
153 #define EWOULDBLOCK WSAEWOULDBLOCK
154 #define EINPROGRESS WSAEINPROGRESS
155 #define EALREADY WSAEALREADY
156 #define ENOTSOCK WSAENOTSOCK
157 #define EDESTADDRREQ WSAEDESTADDRREQ
158 #define EMSGSIZE WSAEMSGSIZE
159 #define EPROTOTYPE WSAEPROTOTYPE
160 #define ENOPROTOOPT WSAENOPROTOOPT
161 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
162 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
163 #define EOPNOTSUPP WSAEOPNOTSUPP
164 #define EPFNOSUPPORT WSAEPFNOSUPPORT
165 #define EAFNOSUPPORT WSAEAFNOSUPPORT
166 #define EADDRINUSE WSAEADDRINUSE
167 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
168 #define ENETDOWN WSAENETDOWN
169 #define ENETUNREACH WSAENETUNREACH
170 #define ENETRESET WSAENETRESET
171 #define ECONNABORTED WSAECONNABORTED
172 #define ECONNRESET WSAECONNRESET
173 #define ENOBUFS WSAENOBUFS
174 #define EISCONN WSAEISCONN
175 #define ENOTCONN WSAENOTCONN
176 #define ESHUTDOWN WSAESHUTDOWN
177 #define ETOOMANYREFS WSAETOOMANYREFS
178 #define ETIMEDOUT WSAETIMEDOUT
179 #define ECONNREFUSED WSAECONNREFUSED
180 #define ELOOP WSAELOOP
181 #define EHOSTDOWN WSAEHOSTDOWN
182 #define EHOSTUNREACH WSAEHOSTUNREACH
183 #define EPROCLIM WSAEPROCLIM
184 #define EUSERS WSAEUSERS
185 #define EDQUOT WSAEDQUOT
186 #define ESTALE WSAESTALE
187 #define EREMOTE WSAEREMOTE
189 /* Public functions. */
191 void ws_startup (void);
192 void ws_changetitle (const char *);
193 void ws_percenttitle (double);
194 char *ws_mypath (void);
195 void windows_main (int *, char **, char **);
197 #endif /* MSWINDOWS_H */