]> sjero.net Git - wget/blob - src/mswindows.h
Fix build under mingw.
[wget] / src / mswindows.h
1 /* Declarations for windows
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3    2005, 2006, 2007, 2008, 2009 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 #include <winsock2.h>
46 #include <ws2tcpip.h>
47
48 #ifndef EAI_SYSTEM
49 # define EAI_SYSTEM -1   /* value doesn't matter */
50 #endif
51
52 /* Declares file access functions, such as open, creat, access, and
53    chmod.  Unix declares these in unistd.h and fcntl.h.  */
54 #include <io.h>
55
56 /* Declares getpid(). */
57 #include <process.h>
58
59 #ifndef S_ISDIR
60 # define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
61 #endif
62 #ifndef S_ISLNK
63 # define S_ISLNK(a) 0
64 #endif
65
66 /* We have strcasecmp and strncasecmp, just under different names.  */
67 #ifndef HAVE_STRCASECMP
68 # define strcasecmp stricmp
69 #endif
70 #ifndef HAVE_STRNCASECMP
71 # define strncasecmp strnicmp
72 #endif
73
74 #include <stdio.h>
75
76 /* The same for snprintf() and vsnprintf().  */
77 #define snprintf _snprintf
78 #define vsnprintf _vsnprintf
79
80 /* Define a wgint type under Windows. */
81 typedef __int64 wgint;
82 #define SIZEOF_WGINT 8
83
84 /* str_to_wgint is a function with the semantics of strtol[l], but
85    which works on wgint.  */
86 #if defined HAVE_STRTOLL
87 # define str_to_wgint strtoll
88 #elif defined HAVE__STRTOI64
89 # define str_to_wgint _strtoi64
90 #else
91 # define str_to_wgint strtoll
92 # define NEED_STRTOLL
93 # define strtoll_type __int64
94 #endif
95
96 /* Windows has no symlink, therefore no lstat.  Without symlinks lstat
97    is equivalent to stat anyway.  */
98 #define lstat stat
99
100 /* Define LFS aliases for stat and fstat. */
101 #ifdef stat_alias
102 # define stat(f, b) stat_alias (f, b)
103 #endif
104 #ifdef fstat_alias
105 # define fstat(f, b) fstat_alias (f, b)
106 #endif
107
108 #define PATH_SEPARATOR '\\'
109
110 /* Win32 doesn't support the MODE argument to mkdir.  */
111 #include <direct.h>
112 #define mkdir(a, b) (mkdir) (a)
113
114 /* Additional declarations needed for IPv6: */
115 #ifdef ENABLE_IPV6
116 const char *inet_ntop (int, const void *, char *, socklen_t);
117 #endif
118
119 #ifdef NEED_GAI_STRERROR
120 # undef gai_strerror
121 # define gai_strerror strerror
122 #endif
123
124 #ifndef INHIBIT_WRAP
125
126 /* Winsock functions don't set errno, so we provide wrappers that do. */
127
128 #define socket wrapped_socket
129 #define bind wrapped_bind
130 #define connect wrapped_connect
131 #define listen wrapped_listen
132 #define accept wrapped_accept
133 #define recv wrapped_recv
134 #define send wrapped_send
135 #define select wrapped_select
136 #define getsockname wrapped_getsockname
137 #define getpeername wrapped_getpeername
138 #define setsockopt wrapped_setsockopt
139 #define closesocket wrapped_closesocket
140
141 #endif /* not INHIBIT_WRAP */
142
143 int wrapped_socket (int, int, int);
144 int wrapped_bind (int, struct sockaddr *, int);
145 int wrapped_connect (int, const struct sockaddr *, int);
146 int wrapped_listen (int s, int backlog);
147 int wrapped_accept (int s, struct sockaddr *a, int *alen);
148 int wrapped_recv (int, void *, int, int);
149 int wrapped_send (int, const void *, int, int);
150 int wrapped_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *);
151 int wrapped_getsockname (int, struct sockaddr *, int *);
152 int wrapped_getpeername (int, struct sockaddr *, int *);
153 int wrapped_setsockopt (int, int, int, const void *, int);
154 int wrapped_closesocket (int);
155
156 /* Public functions.  */
157
158 void ws_startup (void);
159 void ws_changetitle (const char *);
160 void ws_percenttitle (double);
161 char *ws_mypath (void);
162 void windows_main (char **);
163
164 #endif /* MSWINDOWS_H */