]> sjero.net Git - wget/blob - src/mswindows.h
[svn] Include winsock headers from mswindows.h.
[wget] / src / mswindows.h
1 /* Declarations for windows
2    Copyright (C) 1995, 1997, 1997, 1998 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
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 Include mswindows.h inside or after "wget.h"
35 #endif
36
37 #ifndef WIN32_LEAN_AND_MEAN
38 #define WIN32_LEAN_AND_MEAN  /* Prevent inclusion of <winsock*.h> in <windows.h> */
39 #endif
40
41 #include <windows.h>
42
43 /* Use the correct winsock header; <ws2tcpip.h> includes <winsock2.h> only on
44  * Watcom/MingW. We cannot use <winsock.h> for IPv6. Using getaddrinfo() requires
45  * <ws2tcpip.h>
46  */
47 #if defined(ENABLE_IPV6) || defined(HAVE_GETADDRINFO)
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 /* Must include <sys/stat.h> because of 'stat' define below. */
59 #include <sys/stat.h>
60
61 /* Missing in several .c files. Include here. */
62 #include <io.h>
63
64 /* Apparently needed for alloca(). */
65 #include <malloc.h>
66
67 #ifndef S_ISDIR
68 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
69 #endif
70 #ifndef S_ISLNK
71 # define S_ISLNK(a) 0
72 #endif
73
74 /* We have strcasecmp and strncasecmp, just under a different name. */
75 #define strcasecmp stricmp
76 #define strncasecmp strnicmp
77
78 /* The same for snprintf() and vsnprintf().  */
79 #define snprintf _snprintf
80 #define vsnprintf _vsnprintf
81
82 /* No stat on Windows.  */
83 #define lstat stat
84
85 #define PATH_SEPARATOR '\\'
86
87 /* Microsoft says stat is _stat, Borland doesn't */
88 #ifdef _MSC_VER
89 # define stat _stat
90 #endif
91
92 #ifdef HAVE_ISATTY
93 /* Microsoft VC supports _isatty; Borland ? */
94 #ifdef _MSC_VER
95 # define isatty _isatty
96 #endif
97 #endif
98
99 #define REALCLOSE(x) closesocket (x)
100
101 /* read & write don't work with sockets on Windows 95.  */
102 #define READ(fd, buf, cnt) recv ((fd), (buf), (cnt), 0)
103 #define WRITE(fd, buf, cnt) send ((fd), (buf), (cnt), 0)
104
105 /* #### Do we need this?  */
106 #include <direct.h>
107
108 /* Windows compilers accept only one arg to mkdir. */
109 #ifndef __BORLANDC__
110 # define mkdir(a, b) _mkdir(a)
111 #else  /* __BORLANDC__ */
112 # define mkdir(a, b) mkdir(a)
113 #endif /* __BORLANDC__ */
114
115 /* Declarations of various socket errors: */
116
117 #define EWOULDBLOCK             WSAEWOULDBLOCK
118 #define EINPROGRESS             WSAEINPROGRESS
119 #define EALREADY                WSAEALREADY
120 #define ENOTSOCK                WSAENOTSOCK
121 #define EDESTADDRREQ            WSAEDESTADDRREQ
122 #define EMSGSIZE                WSAEMSGSIZE
123 #define EPROTOTYPE              WSAEPROTOTYPE
124 #define ENOPROTOOPT             WSAENOPROTOOPT
125 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
126 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
127 #define EOPNOTSUPP              WSAEOPNOTSUPP
128 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
129 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
130 #define EADDRINUSE              WSAEADDRINUSE
131 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
132 #define ENETDOWN                WSAENETDOWN
133 #define ENETUNREACH             WSAENETUNREACH
134 #define ENETRESET               WSAENETRESET
135 #define ECONNABORTED            WSAECONNABORTED
136 #define ECONNRESET              WSAECONNRESET
137 #define ENOBUFS                 WSAENOBUFS
138 #define EISCONN                 WSAEISCONN
139 #define ENOTCONN                WSAENOTCONN
140 #define ESHUTDOWN               WSAESHUTDOWN
141 #define ETOOMANYREFS            WSAETOOMANYREFS
142 #define ETIMEDOUT               WSAETIMEDOUT
143 #define ECONNREFUSED            WSAECONNREFUSED
144 #define ELOOP                   WSAELOOP
145 #define EHOSTDOWN               WSAEHOSTDOWN
146 #define EHOSTUNREACH            WSAEHOSTUNREACH
147 #define EPROCLIM                WSAEPROCLIM
148 #define EUSERS                  WSAEUSERS
149 #define EDQUOT                  WSAEDQUOT
150 #define ESTALE                  WSAESTALE
151 #define EREMOTE                 WSAEREMOTE
152
153 /* Public functions.  */
154
155 #ifndef HAVE_SLEEP
156 unsigned int sleep (unsigned);
157 #endif
158 #ifndef HAVE_USLEEP
159 int usleep (unsigned long);
160 #endif
161
162 void ws_startup (void);
163 void ws_changetitle (const char*, int);
164 void ws_percenttitle (double);
165 char *ws_mypath (void);
166 void ws_help (const char *);
167 void windows_main_junk (int *, char **, char **);
168
169 /* Things needed for IPv6; missing in <ws2tcpip.h>. */
170 #ifdef ENABLE_IPV6
171 # ifndef HAVE_NTOP
172   extern const char *inet_ntop (int af, const void *src, char *dst, size_t size);
173 # endif
174 # ifndef HAVE_PTON
175   extern int inet_pton (int af, const char *src, void *dst);
176 # endif
177 #endif /* ENABLE_IPV6 */
178
179 #endif /* MSWINDOWS_H */