]> sjero.net Git - wget/blob - src/mswindows.h
Updated config.guess, config.sub, install.sh.
[wget] / src / mswindows.h
1 /* Declarations for windows
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3    2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
5 This file is part of GNU Wget.
6
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 3 of the License, or
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
19
20 Additional permission under GNU GPL version 3 section 7
21
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work.  */
30
31 #ifndef MSWINDOWS_H
32 #define MSWINDOWS_H
33
34 #ifndef WGET_H
35 # error This file should not be included directly.
36 #endif
37
38 /* Prevent inclusion of <winsock*.h> in <windows.h>.  */
39 #ifndef WIN32_LEAN_AND_MEAN
40 # define WIN32_LEAN_AND_MEAN
41 #endif
42
43 #include <windows.h>
44
45 /* We need winsock2.h for IPv6 and ws2tcpip.h for getaddrinfo, so
46   include both in ENABLE_IPV6 case.  (ws2tcpip.h includes winsock2.h
47   only on MinGW.) */
48 #ifdef ENABLE_IPV6
49 # include <winsock2.h>
50 # include <ws2tcpip.h>
51 #else
52 # include <winsock.h>
53 #endif
54
55 #ifndef EAI_SYSTEM
56 # define EAI_SYSTEM -1   /* value doesn't matter */
57 #endif
58
59 /* Declares file access functions, such as open, creat, access, and
60    chmod.  Unix declares these in unistd.h and fcntl.h.  */
61 #include <io.h>
62
63 /* Declares getpid(). */
64 #include <process.h>
65
66 #ifndef S_ISDIR
67 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
68 #endif
69 #ifndef S_ISLNK
70 # define S_ISLNK(a) 0
71 #endif
72
73 /* We have strcasecmp and strncasecmp, just under different names.  */
74 #ifndef HAVE_STRCASECMP
75 # define strcasecmp stricmp
76 #endif
77 #ifndef HAVE_STRNCASECMP
78 # define strncasecmp strnicmp
79 #endif
80
81 #include <stdio.h>
82
83 /* The same for snprintf() and vsnprintf().  */
84 #define snprintf _snprintf
85 #define vsnprintf _vsnprintf
86
87 /* Define a wgint type under Windows. */
88 typedef __int64 wgint;
89 #define SIZEOF_WGINT 8
90
91 /* str_to_wgint is a function with the semantics of strtol[l], but
92    which works on wgint.  */
93 #if defined HAVE_STRTOLL
94 # define str_to_wgint strtoll
95 #elif defined HAVE__STRTOI64
96 # define str_to_wgint _strtoi64
97 #else
98 # define str_to_wgint strtoll
99 # define NEED_STRTOLL
100 # define strtoll_type __int64
101 #endif
102
103 /* Windows has no symlink, therefore no lstat.  Without symlinks lstat
104    is equivalent to stat anyway.  */
105 #define lstat stat
106
107 /* Define LFS aliases for stat and fstat. */
108 #ifdef stat_alias
109 # define stat(f, b) stat_alias (f, b)
110 #endif
111 #ifdef fstat_alias
112 # define fstat(f, b) fstat_alias (f, b)
113 #endif
114
115 #define PATH_SEPARATOR '\\'
116
117 /* Win32 doesn't support the MODE argument to mkdir.  */
118 #include <direct.h>
119 #define mkdir(a, b) (mkdir) (a)
120
121 /* Additional declarations needed for IPv6: */
122 #ifdef ENABLE_IPV6
123 const char *inet_ntop (int, const void *, char *, socklen_t);
124 #endif
125
126 #ifdef NEED_GAI_STRERROR
127 # undef gai_strerror
128 # define gai_strerror windows_strerror
129 #endif
130
131 #ifndef INHIBIT_WRAP
132
133 /* Winsock functions don't set errno, so we provide wrappers that do. */
134
135 #define socket wrapped_socket
136 #define bind wrapped_bind
137 #define connect wrapped_connect
138 #define listen wrapped_listen
139 #define accept wrapped_accept
140 #define recv wrapped_recv
141 #define send wrapped_send
142 #define select wrapped_select
143 #define getsockname wrapped_getsockname
144 #define getpeername wrapped_getpeername
145 #define setsockopt wrapped_setsockopt
146 #define closesocket wrapped_closesocket
147
148 #endif /* not INHIBIT_WRAP */
149
150 int wrapped_socket (int, int, int);
151 int wrapped_bind (int, struct sockaddr *, int);
152 int wrapped_connect (int, const struct sockaddr *, int);
153 int wrapped_listen (int s, int backlog);
154 int wrapped_accept (int s, struct sockaddr *a, int *alen);
155 int wrapped_recv (int, void *, int, int);
156 int wrapped_send (int, const void *, int, int);
157 int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
158 int wrapped_getsockname (int, struct sockaddr *, int *);
159 int wrapped_getpeername (int, struct sockaddr *, int *);
160 int wrapped_setsockopt (int, int, int, const void *, int);
161 int wrapped_closesocket (int);
162
163 /* Finally, provide a private version of strerror that does the
164    right thing with Winsock errors. */
165 #ifndef INHIBIT_WRAP
166 # define strerror windows_strerror
167 #endif
168 const char *windows_strerror (int);
169
170 /* Declarations of various socket errors:  */
171
172 #define EWOULDBLOCK             WSAEWOULDBLOCK
173 #define EINPROGRESS             WSAEINPROGRESS
174 #define EALREADY                WSAEALREADY
175 #define ENOTSOCK                WSAENOTSOCK
176 #define EDESTADDRREQ            WSAEDESTADDRREQ
177 #define EMSGSIZE                WSAEMSGSIZE
178 #define EPROTOTYPE              WSAEPROTOTYPE
179 #define ENOPROTOOPT             WSAENOPROTOOPT
180 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
181 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
182 #define EOPNOTSUPP              WSAEOPNOTSUPP
183 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
184 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
185 #define EADDRINUSE              WSAEADDRINUSE
186 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
187 #define ENETDOWN                WSAENETDOWN
188 #define ENETUNREACH             WSAENETUNREACH
189 #define ENETRESET               WSAENETRESET
190 #define ECONNABORTED            WSAECONNABORTED
191 #define ECONNRESET              WSAECONNRESET
192 #define ENOBUFS                 WSAENOBUFS
193 #define EISCONN                 WSAEISCONN
194 #define ENOTCONN                WSAENOTCONN
195 #define ESHUTDOWN               WSAESHUTDOWN
196 #define ETOOMANYREFS            WSAETOOMANYREFS
197 #define ETIMEDOUT               WSAETIMEDOUT
198 #define ECONNREFUSED            WSAECONNREFUSED
199 #define ELOOP                   WSAELOOP
200 #define EHOSTDOWN               WSAEHOSTDOWN
201 #define EHOSTUNREACH            WSAEHOSTUNREACH
202 #define EPROCLIM                WSAEPROCLIM
203 #define EUSERS                  WSAEUSERS
204 #define EDQUOT                  WSAEDQUOT
205 #define ESTALE                  WSAESTALE
206 #define EREMOTE                 WSAEREMOTE
207
208 /* Public functions.  */
209
210 void ws_startup (void);
211 void ws_changetitle (const char *);
212 void ws_percenttitle (double);
213 char *ws_mypath (void);
214 void windows_main (char **);
215
216 #endif /* MSWINDOWS_H */