~ubuntu-branches/ubuntu/maverick/wget/maverick

« back to all changes in this revision

Viewing changes to src/mswindows.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-05-27 11:49:54 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527114954-ame070pjhqtofeaf
Tags: 1.11.2-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Declarations for windows
2
 
   Copyright (C) 1995, 1997, 1997, 1998, 2004
3
 
   Free Software Foundation, Inc.
 
2
   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 
3
   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
4
 
5
5
This file is part of GNU Wget.
6
6
 
7
7
GNU Wget is free software; you can redistribute it and/or modify
8
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
 
9
the Free Software Foundation; either version 3 of the License, or
10
10
(at your option) any later version.
11
11
 
12
12
GNU Wget is distributed in the hope that it will be useful,
15
15
GNU General Public License for more details.
16
16
 
17
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.  */
 
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
30
 
31
31
#ifndef MSWINDOWS_H
32
32
#define MSWINDOWS_H
33
33
 
34
34
#ifndef WGET_H
35
 
#error Include mswindows.h inside or after "wget.h"
 
35
# error This file should not be included directly.
36
36
#endif
37
37
 
38
38
/* Prevent inclusion of <winsock*.h> in <windows.h>.  */
39
39
#ifndef WIN32_LEAN_AND_MEAN
40
 
#define WIN32_LEAN_AND_MEAN
 
40
# define WIN32_LEAN_AND_MEAN
41
41
#endif
42
42
 
43
43
#include <windows.h>
44
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)
 
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
49
# include <winsock2.h>
50
50
# include <ws2tcpip.h>
51
51
#else
56
56
# define EAI_SYSTEM -1   /* value doesn't matter */
57
57
#endif
58
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.  */
 
59
/* Declares file access functions, such as open, creat, access, and
 
60
   chmod.  Unix declares these in unistd.h and fcntl.h.  */
63
61
#include <io.h>
64
62
 
65
 
/* Apparently needed for alloca().  */
66
 
#include <malloc.h>
 
63
/* Declares getpid(). */
 
64
#include <process.h>
67
65
 
68
66
#ifndef S_ISDIR
69
67
# define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
72
70
# define S_ISLNK(a) 0
73
71
#endif
74
72
 
75
 
/* We have strcasecmp and strncasecmp, just under a different name.  */
76
 
#define strcasecmp stricmp
77
 
#define strncasecmp strnicmp
 
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
78
80
 
79
81
/* The same for snprintf() and vsnprintf().  */
80
82
#define snprintf _snprintf
84
86
typedef __int64 wgint;
85
87
#define SIZEOF_WGINT 8
86
88
 
87
 
#ifdef __GNUC__
88
 
#define WGINT_MAX 9223372036854775807LL
89
 
#else
90
 
#define WGINT_MAX 9223372036854775807I64
91
 
#endif
92
 
 
93
 
#if defined __MINGW32__
 
89
/* str_to_wgint is a function with the semantics of strtol[l], but
 
90
   which works on wgint.  */
 
91
#if defined HAVE_STRTOLL
94
92
# define str_to_wgint strtoll
95
 
#elif defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__BORLANDC__)
 
93
#elif defined HAVE__STRTOI64
96
94
# define str_to_wgint _strtoi64
97
95
#else
98
96
# define str_to_wgint strtoll
99
97
# define NEED_STRTOLL
100
 
# define strtoll_return __int64
 
98
# define strtoll_type __int64
101
99
#endif
102
100
 
103
101
/* Windows has no symlink, therefore no lstat.  Without symlinks lstat
104
102
   is equivalent to stat anyway.  */
105
103
#define lstat stat
106
104
 
107
 
/* Transparently support statting large files, like POSIX's LFS API
108
 
   does.  All Windows compilers we support use _stati64 (but have
109
 
   different names for 2nd argument type, see below), so we use
110
 
   that.  */
111
 
#define stat(fname, buf) _stati64 (fname, buf)
112
 
 
113
 
/* On Windows the 64-bit stat requires an explicitly different type
114
 
   for the 2nd argument, so we define a struct_stat macro that expands
115
 
   to the appropriate type on Windows, and to the regular struct stat
116
 
   on Unix.
117
 
 
118
 
   Note that Borland C 5.5 has 64-bit stat (_stati64), but not a
119
 
   64-bit fstat!  Because of that we also need a struct_fstat that
120
 
   points to struct_stat on Unix and on Windows, except under Borland,
121
 
   where it points to the 32-bit struct stat.  */
122
 
 
123
 
#ifndef __BORLANDC__
124
 
# define fstat(fd, buf) _fstati64 (fd, buf)
125
 
# define struct_stat  struct _stati64
126
 
# define struct_fstat struct _stati64
127
 
#else  /* __BORLANDC__ */
128
 
# define struct_stat  struct stati64
129
 
# define struct_fstat struct stat
130
 
#endif /* __BORLANDC__ */
 
105
/* Define LFS aliases for stat and fstat. */
 
106
#ifdef stat_alias
 
107
# define stat(f, b) stat_alias (f, b)
 
108
#endif
 
109
#ifdef fstat_alias
 
110
# define fstat(f, b) fstat_alias (f, b)
 
111
#endif
131
112
 
132
113
#define PATH_SEPARATOR '\\'
133
114
 
134
 
#ifdef HAVE_ISATTY
135
 
#ifdef _MSC_VER
136
 
# define isatty _isatty
137
 
#endif
138
 
#endif
139
 
 
140
 
/* #### Do we need this?  */
 
115
/* Win32 doesn't support the MODE argument to mkdir.  */
141
116
#include <direct.h>
142
 
 
143
 
/* Windows compilers accept only one arg to mkdir.  */
144
 
#define mkdir(a, b) _mkdir(a)
 
117
#define mkdir(a, b) (mkdir) (a)
 
118
 
 
119
/* Additional declarations needed for IPv6: */
 
120
#ifdef ENABLE_IPV6
 
121
const char *inet_ntop (int, const void *, char *, socklen_t);
 
122
#endif
 
123
 
 
124
#ifdef NEED_GAI_STRERROR
 
125
# undef gai_strerror
 
126
# define gai_strerror windows_strerror
 
127
#endif
145
128
 
146
129
#ifndef INHIBIT_WRAP
147
130
 
148
 
/* Winsock functions don't set errno, so we provide wrappers
149
 
   that do. */
 
131
/* Winsock functions don't set errno, so we provide wrappers that do. */
150
132
 
151
133
#define socket wrapped_socket
152
134
#define bind wrapped_bind
183
165
#endif
184
166
const char *windows_strerror (int);
185
167
 
186
 
/* MingW 3.7 (or older) prototypes gai_strerror(), but is missing
187
 
   from all import libraries. */
188
 
#if defined(__MINGW32__) && defined(ENABLE_IPV6)
189
 
# undef gai_strerror
190
 
# define gai_strerror windows_strerror
191
 
#endif
192
 
 
193
168
/* Declarations of various socket errors:  */
194
169
 
195
170
#define EWOULDBLOCK             WSAEWOULDBLOCK
234
209
void ws_changetitle (const char *);
235
210
void ws_percenttitle (double);
236
211
char *ws_mypath (void);
237
 
void windows_main (int *, char **, char **);
238
 
 
239
 
/* Things needed for IPv6; missing in <ws2tcpip.h>.  */
240
 
#ifdef ENABLE_IPV6
241
 
# ifndef HAVE_INET_NTOP
242
 
extern const char *inet_ntop (int af, const void *src, char *dst, size_t size);
243
 
# endif
244
 
#endif /* ENABLE_IPV6 */
 
212
void windows_main (char **);
245
213
 
246
214
#endif /* MSWINDOWS_H */