]> sjero.net Git - wget/blob - src/mswindows.h
[svn] Revamped MS console logic. Submitted by David Fritz.
[wget] / src / mswindows.h
1 /* Declarations for windows
2    Copyright (C) 1995, 1997, 1997, 1998, 2004
3    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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 In addition, as a special exception, the Free Software Foundation
22 gives permission to link the code of its release of Wget with the
23 OpenSSL project's "OpenSSL" library (or with modified versions of it
24 that use the same license as the "OpenSSL" library), and distribute
25 the linked executables.  You must obey the GNU General Public License
26 in all respects for all of the code used other than "OpenSSL".  If you
27 modify this file, you may extend this exception to your version of the
28 file, but you are not obligated to do so.  If you do not wish to do
29 so, delete this exception statement from your version.  */
30
31 #ifndef MSWINDOWS_H
32 #define MSWINDOWS_H
33
34 #ifndef WGET_H
35 #error Include mswindows.h inside or after "wget.h"
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 /* Use the correct winsock header; <ws2tcpip.h> includes <winsock2.h> only
46    on Watcom/MingW.  We cannot use <winsock.h> for IPv6.  Using
47    getaddrinfo() requires <ws2tcpip.h>.  */
48 #if defined(ENABLE_IPV6) || defined(HAVE_GETADDRINFO)
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 /* Must include <sys/stat.h> because of 'stat' define below.  */
60 #include <sys/stat.h>
61
62 /* Missing in several .c files.  Include here.  */
63 #include <io.h>
64
65 /* Apparently needed for alloca().  */
66 #include <malloc.h>
67
68 #ifndef S_ISDIR
69 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
70 #endif
71 #ifndef S_ISLNK
72 # define S_ISLNK(a) 0
73 #endif
74
75 /* We have strcasecmp and strncasecmp, just under a different name.  */
76 #define strcasecmp stricmp
77 #define strncasecmp strnicmp
78
79 /* The same for snprintf() and vsnprintf().  */
80 #define snprintf _snprintf
81 #define vsnprintf _vsnprintf
82
83 /* No stat on Windows.  */
84 #define lstat stat
85
86 #define PATH_SEPARATOR '\\'
87
88 /* Microsoft says stat is _stat, Borland doesn't.  */
89 #ifdef _MSC_VER
90 # define stat _stat
91 #endif
92
93 #ifdef HAVE_ISATTY
94 /* Microsoft VC supports _isatty; Borland?  */
95 #ifdef _MSC_VER
96 # define isatty _isatty
97 #endif
98 #endif
99
100 #define REALCLOSE(x) closesocket (x)
101
102 /* #### Do we need this?  */
103 #include <direct.h>
104
105 /* Windows compilers accept only one arg to mkdir.  */
106 #ifndef __BORLANDC__
107 # define mkdir(a, b) _mkdir(a)
108 #else  /* __BORLANDC__ */
109 # define mkdir(a, b) mkdir(a)
110 #endif /* __BORLANDC__ */
111
112 /* Declarations of various socket errors:  */
113
114 #define EWOULDBLOCK             WSAEWOULDBLOCK
115 #define EINPROGRESS             WSAEINPROGRESS
116 #define EALREADY                WSAEALREADY
117 #define ENOTSOCK                WSAENOTSOCK
118 #define EDESTADDRREQ            WSAEDESTADDRREQ
119 #define EMSGSIZE                WSAEMSGSIZE
120 #define EPROTOTYPE              WSAEPROTOTYPE
121 #define ENOPROTOOPT             WSAENOPROTOOPT
122 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
123 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
124 #define EOPNOTSUPP              WSAEOPNOTSUPP
125 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
126 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
127 #define EADDRINUSE              WSAEADDRINUSE
128 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
129 #define ENETDOWN                WSAENETDOWN
130 #define ENETUNREACH             WSAENETUNREACH
131 #define ENETRESET               WSAENETRESET
132 #define ECONNABORTED            WSAECONNABORTED
133 #define ECONNRESET              WSAECONNRESET
134 #define ENOBUFS                 WSAENOBUFS
135 #define EISCONN                 WSAEISCONN
136 #define ENOTCONN                WSAENOTCONN
137 #define ESHUTDOWN               WSAESHUTDOWN
138 #define ETOOMANYREFS            WSAETOOMANYREFS
139 #define ETIMEDOUT               WSAETIMEDOUT
140 #define ECONNREFUSED            WSAECONNREFUSED
141 #define ELOOP                   WSAELOOP
142 #define EHOSTDOWN               WSAEHOSTDOWN
143 #define EHOSTUNREACH            WSAEHOSTUNREACH
144 #define EPROCLIM                WSAEPROCLIM
145 #define EUSERS                  WSAEUSERS
146 #define EDQUOT                  WSAEDQUOT
147 #define ESTALE                  WSAESTALE
148 #define EREMOTE                 WSAEREMOTE
149
150 /* Public functions.  */
151
152 #ifndef HAVE_SLEEP
153 unsigned int sleep (unsigned);
154 #endif
155 #ifndef HAVE_USLEEP
156 int usleep (unsigned long);
157 #endif
158
159 void ws_startup (void);
160 void ws_changetitle (const char *);
161 void ws_percenttitle (double);
162 char *ws_mypath (void);
163 void windows_main_junk (int *, char **, char **);
164
165 /* Things needed for IPv6; missing in <ws2tcpip.h>.  */
166 #ifdef ENABLE_IPV6
167 # ifndef HAVE_NTOP
168   extern const char *inet_ntop (int af, const void *src, char *dst, size_t size);
169 # endif
170 # ifndef HAVE_PTON
171   extern int inet_pton (int af, const char *src, void *dst);
172 # endif
173 #endif /* ENABLE_IPV6 */
174
175 #endif /* MSWINDOWS_H */