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