1 | /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
|
---|
2 | *
|
---|
3 | * This header file corresponds to version 1.1 of the Windows Sockets
|
---|
4 | * specification.
|
---|
5 | *
|
---|
6 | * Copyright (C) the Wine project
|
---|
7 | *
|
---|
8 | * This library is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU Lesser General Public
|
---|
10 | * License as published by the Free Software Foundation; either
|
---|
11 | * version 2.1 of the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This library is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * Lesser General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Lesser General Public
|
---|
19 | * License along with this library; if not, write to the Free Software
|
---|
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
25 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
26 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
27 | * a choice of LGPL license versions is made available with the language indicating
|
---|
28 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
29 | * of the LGPL is applied is otherwise unspecified.
|
---|
30 | */
|
---|
31 |
|
---|
32 | #ifdef __WINESRC__
|
---|
33 | # ifndef __WINE_WINSOCK2__
|
---|
34 | # error Please use Winsock2 in Wine
|
---|
35 | # endif
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifndef __WINE_WINSOCKAPI_STDLIB_H
|
---|
39 | #define __WINE_WINSOCKAPI_STDLIB_H
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * This section defines the items that conflict with the Unix headers.
|
---|
43 | */
|
---|
44 | #ifndef USE_WS_PREFIX
|
---|
45 | /* We are not using the WS_ prefix we risk getting conflicts for
|
---|
46 | * everything related to select.
|
---|
47 | */
|
---|
48 | # ifdef FD_CLR
|
---|
49 | /* Too late, the Unix version of stdlib.h was included before winsock.h.
|
---|
50 | * This means select and all the related stuff is already defined and we
|
---|
51 | * cannot override types and function prototypes.
|
---|
52 | * All we can do is disable all these symbols so that they are not used
|
---|
53 | * inadvertently.
|
---|
54 | */
|
---|
55 | # include <sys/types.h>
|
---|
56 | # undef FD_SETSIZE
|
---|
57 | # undef FD_CLR
|
---|
58 | # undef FD_SET
|
---|
59 | # undef FD_ZERO
|
---|
60 | # undef FD_ISSET
|
---|
61 |
|
---|
62 | # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
63 | # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
64 | # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
65 | # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
66 | # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
67 | # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
68 | # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
|
---|
69 | # elif defined(RLIM_INFINITY)
|
---|
70 | /* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
|
---|
71 | # define fd_set unix_fd_set
|
---|
72 | # include <sys/types.h>
|
---|
73 | # include <time.h>
|
---|
74 | # include <stdlib.h>
|
---|
75 | # undef fd_set
|
---|
76 | # undef FD_SETSIZE
|
---|
77 | # undef FD_CLR
|
---|
78 | # undef FD_SET
|
---|
79 | # undef FD_ZERO
|
---|
80 | # undef FD_ISSET
|
---|
81 | # define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
|
---|
82 | # define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
|
---|
83 | # else /* FD_CLR */
|
---|
84 | /* stdlib.h has not been included yet so it's not too late. Include it now
|
---|
85 | * making sure that none of the select symbols is affected. Then we can
|
---|
86 | * define them with our own values.
|
---|
87 | */
|
---|
88 | # define fd_set unix_fd_set
|
---|
89 | # define timeval unix_timeval
|
---|
90 | # define select unix_select
|
---|
91 | # define socklen_t unix_socklen_t
|
---|
92 | # define u_long unix_u_long
|
---|
93 | # include <sys/types.h>
|
---|
94 | # include <time.h>
|
---|
95 | # include <stdlib.h>
|
---|
96 | # undef fd_set
|
---|
97 | # undef timeval
|
---|
98 | # undef select
|
---|
99 | # undef socklen_t
|
---|
100 | # undef u_long
|
---|
101 | # undef FD_SETSIZE
|
---|
102 | # undef FD_CLR
|
---|
103 | # undef FD_SET
|
---|
104 | # undef FD_ZERO
|
---|
105 | # undef FD_ISSET
|
---|
106 | # undef _TIMEVAL_DEFINED
|
---|
107 |
|
---|
108 | # define WS_DEFINE_SELECT
|
---|
109 | # endif /* FD_CLR */
|
---|
110 |
|
---|
111 | #else
|
---|
112 | # define WS_DEFINE_SELECT
|
---|
113 | # include <sys/types.h>
|
---|
114 | # include <stdlib.h>
|
---|
115 | #endif /* !USE_WS_PREFIX */
|
---|
116 |
|
---|
117 | #endif /* __WINE_WINSOCKAPI_STDLIB_H */
|
---|
118 |
|
---|
119 | #ifndef __WINESRC__
|
---|
120 | # include <windows.h>
|
---|
121 | #else
|
---|
122 | # include <windef.h>
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | #ifndef _WINSOCKAPI_
|
---|
126 | #define _WINSOCKAPI_
|
---|
127 |
|
---|
128 | #ifdef USE_WS_PREFIX
|
---|
129 | typedef unsigned char WS_u_char;
|
---|
130 | typedef unsigned short WS_u_short;
|
---|
131 | typedef unsigned int WS_u_int;
|
---|
132 | typedef ULONG WS_u_long;
|
---|
133 | #elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
|
---|
134 | /* MinGW doesn't define the u_xxx types */
|
---|
135 | typedef unsigned char u_char;
|
---|
136 | typedef unsigned short u_short;
|
---|
137 | typedef unsigned int u_int;
|
---|
138 | typedef ULONG u_long;
|
---|
139 | #define _BSDTYPES_DEFINED
|
---|
140 | #else
|
---|
141 | #define u_long ULONG /* make sure we don't use the system u_long */
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | #ifdef USE_WS_PREFIX
|
---|
145 | # define WS(x) WS_##x
|
---|
146 | #else
|
---|
147 | # define WS(x) x
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | #ifdef __cplusplus
|
---|
151 | extern "C" {
|
---|
152 | #endif /* defined(__cplusplus) */
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * Address families
|
---|
156 | */
|
---|
157 | #ifndef USE_WS_PREFIX
|
---|
158 | #define AF_UNSPEC 0
|
---|
159 | #define AF_UNIX 1
|
---|
160 | #define AF_INET 2
|
---|
161 | #define AF_IMPLINK 3
|
---|
162 | #define AF_PUP 4
|
---|
163 | #define AF_CHAOS 5
|
---|
164 | #define AF_NS 6
|
---|
165 | #define AF_IPX AF_NS
|
---|
166 | #define AF_ISO 7
|
---|
167 | #define AF_OSI AF_ISO
|
---|
168 | #define AF_ECMA 8
|
---|
169 | #define AF_DATAKIT 9
|
---|
170 | #define AF_CCITT 10
|
---|
171 | #define AF_SNA 11
|
---|
172 | #define AF_DECnet 12
|
---|
173 | #define AF_DLI 13
|
---|
174 | #define AF_LAT 14
|
---|
175 | #define AF_HYLINK 15
|
---|
176 | #define AF_APPLETALK 16
|
---|
177 | #define AF_NETBIOS 17
|
---|
178 | #define AF_VOICEVIEW 18
|
---|
179 | #define AF_FIREFOX 19
|
---|
180 | #define AF_UNKNOWN1 20
|
---|
181 | #define AF_BAN 21
|
---|
182 | #define AF_ATM 22
|
---|
183 | #define AF_INET6 23
|
---|
184 | #define AF_CLUSTER 24
|
---|
185 | #define AF_12844 25
|
---|
186 | #define AF_IRDA 26
|
---|
187 | #define AF_MAX 27
|
---|
188 | #define PF_UNSPEC AF_UNSPEC
|
---|
189 | #define PF_UNIX AF_UNIX
|
---|
190 | #define PF_INET AF_INET
|
---|
191 | #define PF_IMPLINK AF_IMPLINK
|
---|
192 | #define PF_PUP AF_PUP
|
---|
193 | #define PF_CHAOS AF_CHAOS
|
---|
194 | #define PF_NS AF_NS
|
---|
195 | #define PF_IPX AF_IPX
|
---|
196 | #define PF_ISO AF_ISO
|
---|
197 | #define PF_OSI AF_OSI
|
---|
198 | #define PF_ECMA AF_ECMA
|
---|
199 | #define PF_DATAKIT AF_DATAKIT
|
---|
200 | #define PF_CCITT AF_CCITT
|
---|
201 | #define PF_SNA AF_SNA
|
---|
202 | #define PF_DECnet AF_DECnet
|
---|
203 | #define PF_DLI AF_DLI
|
---|
204 | #define PF_LAT AF_LAT
|
---|
205 | #define PF_HYLINK AF_HYLINK
|
---|
206 | #define PF_APPLETALK AF_APPLETALK
|
---|
207 | #define PF_VOICEVIEW AF_VOICEVIEW
|
---|
208 | #define PF_FIREFOX AF_FIREFOX
|
---|
209 | #define PF_UNKNOWN1 AF_UNKNOWN1
|
---|
210 | #define PF_BAN AF_BAN
|
---|
211 | #define PF_MAX AF_MAX
|
---|
212 | #else /* USE_WS_PREFIX */
|
---|
213 | #define WS_AF_UNSPEC 0
|
---|
214 | #define WS_AF_UNIX 1
|
---|
215 | #define WS_AF_INET 2
|
---|
216 | #define WS_AF_IMPLINK 3
|
---|
217 | #define WS_AF_PUP 4
|
---|
218 | #define WS_AF_CHAOS 5
|
---|
219 | #define WS_AF_NS 6
|
---|
220 | #define WS_AF_IPX WS_AF_NS
|
---|
221 | #define WS_AF_ISO 7
|
---|
222 | #define WS_AF_OSI AF_ISO
|
---|
223 | #define WS_AF_ECMA 8
|
---|
224 | #define WS_AF_DATAKIT 9
|
---|
225 | #define WS_AF_CCITT 10
|
---|
226 | #define WS_AF_SNA 11
|
---|
227 | #define WS_AF_DECnet 12
|
---|
228 | #define WS_AF_DLI 13
|
---|
229 | #define WS_AF_LAT 14
|
---|
230 | #define WS_AF_HYLINK 15
|
---|
231 | #define WS_AF_APPLETALK 16
|
---|
232 | #define WS_AF_NETBIOS 17
|
---|
233 | #define WS_AF_VOICEVIEW 18
|
---|
234 | #define WS_AF_FIREFOX 19
|
---|
235 | #define WS_AF_UNKNOWN1 20
|
---|
236 | #define WS_AF_BAN 21
|
---|
237 | #define WS_AF_ATM 22
|
---|
238 | #define WS_AF_INET6 23
|
---|
239 | #define WS_AF_CLUSTER 24
|
---|
240 | #define WS_AF_12844 25
|
---|
241 | #define WS_AF_IRDA 26
|
---|
242 | #define WS_AF_MAX 27
|
---|
243 | #endif /* USE_WS_PREFIX */
|
---|
244 |
|
---|
245 | /*
|
---|
246 | * Types
|
---|
247 | */
|
---|
248 | #ifndef USE_WS_PREFIX
|
---|
249 | #define SOCK_STREAM 1
|
---|
250 | #define SOCK_DGRAM 2
|
---|
251 | #define SOCK_RAW 3
|
---|
252 | #define SOCK_RDM 4
|
---|
253 | #define SOCK_SEQPACKET 5
|
---|
254 | #else /* USE_WS_PREFIX */
|
---|
255 | #define WS_SOCK_STREAM 1
|
---|
256 | #define WS_SOCK_DGRAM 2
|
---|
257 | #define WS_SOCK_RAW 3
|
---|
258 | #define WS_SOCK_RDM 4
|
---|
259 | #define WS_SOCK_SEQPACKET 5
|
---|
260 | #endif /* USE_WS_PREFIX */
|
---|
261 |
|
---|
262 |
|
---|
263 | /*
|
---|
264 | * Protocols
|
---|
265 | */
|
---|
266 | #ifndef USE_WS_PREFIX
|
---|
267 | #define IPPROTO_IP 0
|
---|
268 | #define IPPROTO_ICMP 1
|
---|
269 | #define IPPROTO_IGMP 2
|
---|
270 | #define IPPROTO_GGP 3
|
---|
271 | #define IPPROTO_TCP 6
|
---|
272 | #define IPPROTO_UDP 17
|
---|
273 | #define IPPROTO_IDP 22
|
---|
274 | #define IPPROTO_IPV6 41
|
---|
275 | #define IPPROTO_ND 77
|
---|
276 | #define IPPROTO_RAW 255
|
---|
277 | #define IPPROTO_MAX 256
|
---|
278 | #else /* USE_WS_PREFIX */
|
---|
279 | #define WS_IPPROTO_IP 0
|
---|
280 | #define WS_IPPROTO_ICMP 1
|
---|
281 | #define WS_IPPROTO_IGMP 2
|
---|
282 | #define WS_IPPROTO_GGP 3
|
---|
283 | #define WS_IPPROTO_TCP 6
|
---|
284 | #define WS_IPPROTO_UDP 17
|
---|
285 | #define WS_IPPROTO_IDP 22
|
---|
286 | #define WS_IPPROTO_IPV6 41
|
---|
287 | #define WS_IPPROTO_ND 77
|
---|
288 | #define WS_IPPROTO_RAW 255
|
---|
289 | #define WS_IPPROTO_MAX 256
|
---|
290 | #endif /* USE_WS_PREFIX */
|
---|
291 |
|
---|
292 | typedef struct WS(protoent)
|
---|
293 | {
|
---|
294 | char* p_name;
|
---|
295 | char** p_aliases;
|
---|
296 | short p_proto;
|
---|
297 | } PROTOENT, *PPROTOENT, *LPPROTOENT;
|
---|
298 |
|
---|
299 |
|
---|
300 |
|
---|
301 | /*
|
---|
302 | * Networks
|
---|
303 | */
|
---|
304 | struct WS(netent)
|
---|
305 | {
|
---|
306 | char* n_name; /* official name of net */
|
---|
307 | char** n_aliases; /* alias list */
|
---|
308 | short n_addrtype; /* net address type */
|
---|
309 | ULONG n_net; /* network # */
|
---|
310 | };
|
---|
311 |
|
---|
312 |
|
---|
313 | /*
|
---|
314 | * Services
|
---|
315 | */
|
---|
316 | #ifndef USE_WS_PREFIX
|
---|
317 | #define IPPORT_ECHO 7
|
---|
318 | #define IPPORT_DISCARD 9
|
---|
319 | #define IPPORT_SYSTAT 11
|
---|
320 | #define IPPORT_DAYTIME 13
|
---|
321 | #define IPPORT_NETSTAT 15
|
---|
322 | #define IPPORT_FTP 21
|
---|
323 | #define IPPORT_TELNET 23
|
---|
324 | #define IPPORT_SMTP 25
|
---|
325 | #define IPPORT_TIMESERVER 37
|
---|
326 | #define IPPORT_NAMESERVER 42
|
---|
327 | #define IPPORT_WHOIS 43
|
---|
328 | #define IPPORT_MTP 57
|
---|
329 | #define IPPORT_TFTP 69
|
---|
330 | #define IPPORT_RJE 77
|
---|
331 | #define IPPORT_FINGER 79
|
---|
332 | #define IPPORT_TTYLINK 87
|
---|
333 | #define IPPORT_SUPDUP 95
|
---|
334 | #define IPPORT_EXECSERVER 512
|
---|
335 | #define IPPORT_LOGINSERVER 513
|
---|
336 | #define IPPORT_CMDSERVER 514
|
---|
337 | #define IPPORT_EFSSERVER 520
|
---|
338 | #define IPPORT_BIFFUDP 512
|
---|
339 | #define IPPORT_WHOSERVER 513
|
---|
340 | #define IPPORT_ROUTESERVER 520
|
---|
341 | #define IPPORT_RESERVED 1024
|
---|
342 | #else /* USE_WS_PREFIX */
|
---|
343 | #define WS_IPPORT_ECHO 7
|
---|
344 | #define WS_IPPORT_DISCARD 9
|
---|
345 | #define WS_IPPORT_SYSTAT 11
|
---|
346 | #define WS_IPPORT_DAYTIME 13
|
---|
347 | #define WS_IPPORT_NETSTAT 15
|
---|
348 | #define WS_IPPORT_FTP 21
|
---|
349 | #define WS_IPPORT_TELNET 23
|
---|
350 | #define WS_IPPORT_SMTP 25
|
---|
351 | #define WS_IPPORT_TIMESERVER 37
|
---|
352 | #define WS_IPPORT_NAMESERVER 42
|
---|
353 | #define WS_IPPORT_WHOIS 43
|
---|
354 | #define WS_IPPORT_MTP 57
|
---|
355 | #define WS_IPPORT_TFTP 69
|
---|
356 | #define WS_IPPORT_RJE 77
|
---|
357 | #define WS_IPPORT_FINGER 79
|
---|
358 | #define WS_IPPORT_TTYLINK 87
|
---|
359 | #define WS_IPPORT_SUPDUP 95
|
---|
360 | #define WS_IPPORT_EXECSERVER 512
|
---|
361 | #define WS_IPPORT_LOGINSERVER 513
|
---|
362 | #define WS_IPPORT_CMDSERVER 514
|
---|
363 | #define WS_IPPORT_EFSSERVER 520
|
---|
364 | #define WS_IPPORT_BIFFUDP 512
|
---|
365 | #define WS_IPPORT_WHOSERVER 513
|
---|
366 | #define WS_IPPORT_ROUTESERVER 520
|
---|
367 | #define WS_IPPORT_RESERVED 1024
|
---|
368 | #endif /* USE_WS_PREFIX */
|
---|
369 |
|
---|
370 | typedef struct WS(servent)
|
---|
371 | {
|
---|
372 | char* s_name; /* official service name */
|
---|
373 | char** s_aliases; /* alias list */
|
---|
374 | #ifdef _WIN64
|
---|
375 | char* s_proto; /* protocol to use */
|
---|
376 | short s_port; /* port # */
|
---|
377 | #else
|
---|
378 | short s_port; /* port # */
|
---|
379 | char* s_proto; /* protocol to use */
|
---|
380 | #endif
|
---|
381 | } SERVENT, *PSERVENT, *LPSERVENT;
|
---|
382 |
|
---|
383 |
|
---|
384 |
|
---|
385 | /*
|
---|
386 | * Hosts
|
---|
387 | */
|
---|
388 |
|
---|
389 | typedef struct WS(hostent)
|
---|
390 | {
|
---|
391 | char* h_name; /* official name of host */
|
---|
392 | char** h_aliases; /* alias list */
|
---|
393 | short h_addrtype; /* host address type */
|
---|
394 | short h_length; /* length of address */
|
---|
395 | char** h_addr_list; /* list of addresses from name server */
|
---|
396 | #define h_addr h_addr_list[0] /* address, for backward compat */
|
---|
397 | } HOSTENT, *PHOSTENT, *LPHOSTENT;
|
---|
398 |
|
---|
399 |
|
---|
400 | /*
|
---|
401 | * Sockets
|
---|
402 | */
|
---|
403 |
|
---|
404 | typedef UINT_PTR SOCKET;
|
---|
405 |
|
---|
406 | /*
|
---|
407 | * This is used instead of -1, since the
|
---|
408 | * SOCKET type is unsigned.
|
---|
409 | */
|
---|
410 | #define INVALID_SOCKET (SOCKET)(~0)
|
---|
411 | #define SOCKET_ERROR (-1)
|
---|
412 |
|
---|
413 | typedef struct WS(sockaddr)
|
---|
414 | {
|
---|
415 | WS(u_short) sa_family;
|
---|
416 | char sa_data[14];
|
---|
417 | } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
|
---|
418 |
|
---|
419 | typedef struct WS(linger)
|
---|
420 | {
|
---|
421 | WS(u_short) l_onoff; /* option on/off */
|
---|
422 | WS(u_short) l_linger; /* linger time */
|
---|
423 | } LINGER, *PLINGER, *LPLINGER;
|
---|
424 |
|
---|
425 | /*
|
---|
426 | * Select
|
---|
427 | */
|
---|
428 |
|
---|
429 | #ifdef WS_DEFINE_SELECT
|
---|
430 | /* Define our own version of select and the associated types and macros */
|
---|
431 |
|
---|
432 | # ifndef USE_WS_PREFIX
|
---|
433 | # ifndef FD_SETSIZE
|
---|
434 | # define FD_SETSIZE 64
|
---|
435 | # endif
|
---|
436 | # else
|
---|
437 | # ifndef WS_FD_SETSIZE
|
---|
438 | # define WS_FD_SETSIZE 64
|
---|
439 | # endif
|
---|
440 | # endif
|
---|
441 |
|
---|
442 | typedef struct WS(fd_set)
|
---|
443 | {
|
---|
444 | WS(u_int) fd_count; /* how many are SET? */
|
---|
445 | # ifndef USE_WS_PREFIX
|
---|
446 | SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
|
---|
447 | # else
|
---|
448 | SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
|
---|
449 | # endif
|
---|
450 | } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
|
---|
451 |
|
---|
452 | #ifndef _TIMEVAL_DEFINED
|
---|
453 | #define _TIMEVAL_DEFINED
|
---|
454 | typedef struct WS(timeval)
|
---|
455 | {
|
---|
456 | LONG tv_sec; /* seconds */
|
---|
457 | LONG tv_usec; /* and microseconds */
|
---|
458 | } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
|
---|
459 | #endif
|
---|
460 |
|
---|
461 | #define __WS_FD_CLR(fd, set, cast) do { \
|
---|
462 | unsigned int __i; \
|
---|
463 | for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
|
---|
464 | { \
|
---|
465 | if (((cast*)(set))->fd_array[__i] == fd) \
|
---|
466 | { \
|
---|
467 | while (__i < ((cast*)(set))->fd_count-1) \
|
---|
468 | { \
|
---|
469 | ((cast*)(set))->fd_array[__i] = \
|
---|
470 | ((cast*)(set))->fd_array[__i+1]; \
|
---|
471 | __i++; \
|
---|
472 | } \
|
---|
473 | ((cast*)(set))->fd_count--; \
|
---|
474 | break; \
|
---|
475 | } \
|
---|
476 | } \
|
---|
477 | } while(0)
|
---|
478 | #define __WS_FD_SET1(fd, set, cast) do { \
|
---|
479 | if (((cast*)(set))->fd_count < FD_SETSIZE) \
|
---|
480 | ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
|
---|
481 | } while(0)
|
---|
482 | /* This version checks if the filedesc is already in the list, and appends it
|
---|
483 | * only if it's not the case
|
---|
484 | */
|
---|
485 | #define __WS_FD_SET2(fd, set, cast) do { \
|
---|
486 | unsigned int __i; \
|
---|
487 | for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
|
---|
488 | { \
|
---|
489 | if (((cast*)(set))->fd_array[__i]==(fd)) \
|
---|
490 | break; \
|
---|
491 | } \
|
---|
492 | if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
|
---|
493 | { \
|
---|
494 | ((cast*)(set))->fd_count++; \
|
---|
495 | ((cast*)(set))->fd_array[__i]=(fd);\
|
---|
496 | } \
|
---|
497 | } while(0)
|
---|
498 |
|
---|
499 | #ifndef __WINE_WINSOCK2__
|
---|
500 | #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
|
---|
501 | #else
|
---|
502 | #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
|
---|
503 | #endif
|
---|
504 |
|
---|
505 | #ifndef USE_WS_PREFIX
|
---|
506 | #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
|
---|
507 | #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
|
---|
508 | #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
|
---|
509 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
|
---|
510 | #else
|
---|
511 | #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
|
---|
512 | #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
|
---|
513 | #define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
|
---|
514 | #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
|
---|
515 | #endif
|
---|
516 |
|
---|
517 | int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
|
---|
518 |
|
---|
519 | #endif /* WS_DEFINE_SELECT */
|
---|
520 |
|
---|
521 | /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
|
---|
522 | #ifndef USE_WS_PREFIX
|
---|
523 |
|
---|
524 | #undef htonl
|
---|
525 | #undef htons
|
---|
526 | #undef ntohl
|
---|
527 | #undef ntohs
|
---|
528 |
|
---|
529 | #ifdef WORDS_BIGENDIAN
|
---|
530 |
|
---|
531 | #define htonl(l) ((ULONG)(l))
|
---|
532 | #define htons(s) ((u_short)(s))
|
---|
533 | #define ntohl(l) ((ULONG)(l))
|
---|
534 | #define ntohs(s) ((u_short)(s))
|
---|
535 |
|
---|
536 | #else /* WORDS_BIGENDIAN */
|
---|
537 |
|
---|
538 | static inline u_short __wine_ushort_swap(u_short s)
|
---|
539 | {
|
---|
540 | return (s >> 8) | (s << 8);
|
---|
541 | }
|
---|
542 | static inline ULONG __wine_ulong_swap(ULONG l)
|
---|
543 | {
|
---|
544 | return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
|
---|
545 | }
|
---|
546 | #define htonl(l) __wine_ulong_swap(l)
|
---|
547 | #define htons(s) __wine_ushort_swap(s)
|
---|
548 | #define ntohl(l) __wine_ulong_swap(l)
|
---|
549 | #define ntohs(s) __wine_ushort_swap(s)
|
---|
550 |
|
---|
551 | #endif /* WORDS_BIGENDIAN */
|
---|
552 |
|
---|
553 | #endif /* USE_WS_PREFIX */
|
---|
554 |
|
---|
555 | /*
|
---|
556 | * Internet address (old style... should be updated)
|
---|
557 | */
|
---|
558 |
|
---|
559 | #ifndef USE_WS_PREFIX
|
---|
560 | #define IN_CLASSA_NSHIFT 24
|
---|
561 | #define IN_CLASSA_MAX 128
|
---|
562 | #define IN_CLASSA_NET 0xff000000
|
---|
563 | #define IN_CLASSA_HOST 0x00ffffff
|
---|
564 | #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
|
---|
565 | #define IN_CLASSB_NSHIFT 16
|
---|
566 | #define IN_CLASSB_MAX 65536
|
---|
567 | #define IN_CLASSB_NET 0xffff0000
|
---|
568 | #define IN_CLASSB_HOST 0x0000ffff
|
---|
569 | #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
|
---|
570 | #define IN_CLASSC_NSHIFT 8
|
---|
571 | #define IN_CLASSC_NET 0xffffff00
|
---|
572 | #define IN_CLASSC_HOST 0x000000ff
|
---|
573 | #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
|
---|
574 | #else
|
---|
575 | #define WS_IN_CLASSA_NSHIFT 24
|
---|
576 | #define WS_IN_CLASSA_MAX 128
|
---|
577 | #define WS_IN_CLASSA_NET 0xff000000
|
---|
578 | #define WS_IN_CLASSA_HOST 0x00ffffff
|
---|
579 | #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
|
---|
580 | #define WS_IN_CLASSB_NSHIFT 16
|
---|
581 | #define WS_IN_CLASSB_MAX 65536
|
---|
582 | #define WS_IN_CLASSB_NET 0xffff0000
|
---|
583 | #define WS_IN_CLASSB_HOST 0x0000ffff
|
---|
584 | #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
|
---|
585 | #define WS_IN_CLASSC_NSHIFT 8
|
---|
586 | #define WS_IN_CLASSC_NET 0xffffff00
|
---|
587 | #define WS_IN_CLASSC_HOST 0x000000ff
|
---|
588 | #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
|
---|
589 | #endif /* USE_WS_PREFIX */
|
---|
590 |
|
---|
591 | #ifndef USE_WS_PREFIX
|
---|
592 | #define INADDR_ANY ((ULONG)0x00000000)
|
---|
593 | #define INADDR_LOOPBACK 0x7f000001
|
---|
594 | #define INADDR_BROADCAST ((ULONG)0xffffffff)
|
---|
595 | #define INADDR_NONE 0xffffffff
|
---|
596 | #else
|
---|
597 | #define WS_INADDR_ANY ((ULONG)0x00000000)
|
---|
598 | #define WS_INADDR_LOOPBACK 0x7f000001
|
---|
599 | #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
|
---|
600 | #define WS_INADDR_NONE 0xffffffff
|
---|
601 | #endif /* USE_WS_PREFIX */
|
---|
602 |
|
---|
603 | typedef struct WS(in_addr)
|
---|
604 | {
|
---|
605 | union {
|
---|
606 | struct {
|
---|
607 | WS(u_char) s_b1,s_b2,s_b3,s_b4;
|
---|
608 | } S_un_b;
|
---|
609 | struct {
|
---|
610 | WS(u_short) s_w1,s_w2;
|
---|
611 | } S_un_w;
|
---|
612 | ULONG S_addr;
|
---|
613 | } S_un;
|
---|
614 | #ifndef USE_WS_PREFIX
|
---|
615 | #define s_addr S_un.S_addr
|
---|
616 | #define s_host S_un.S_un_b.s_b2
|
---|
617 | #define s_net S_un.S_un_b.s_b1
|
---|
618 | #define s_imp S_un.S_un_w.s_w2
|
---|
619 | #define s_impno S_un.S_un_b.s_b4
|
---|
620 | #define s_lh S_un.S_un_b.s_b3
|
---|
621 | #else
|
---|
622 | #define WS_s_addr S_un.S_addr
|
---|
623 | #define WS_s_host S_un.S_un_b.s_b2
|
---|
624 | #define WS_s_net S_un.S_un_b.s_b1
|
---|
625 | #define WS_s_imp S_un.S_un_w.s_w2
|
---|
626 | #define WS_s_impno S_un.S_un_b.s_b4
|
---|
627 | #define WS_s_lh S_un.S_un_b.s_b3
|
---|
628 | #endif /* USE_WS_PREFIX */
|
---|
629 | } IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
|
---|
630 |
|
---|
631 | typedef struct WS(sockaddr_in)
|
---|
632 | {
|
---|
633 | short sin_family;
|
---|
634 | WS(u_short) sin_port;
|
---|
635 | struct WS(in_addr) sin_addr;
|
---|
636 | char sin_zero[8];
|
---|
637 | } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
|
---|
638 |
|
---|
639 | /*
|
---|
640 | * Multicast group information
|
---|
641 | */
|
---|
642 |
|
---|
643 | #if !defined(__WINE_WINSOCK2__)
|
---|
644 | struct WS(ip_mreq)
|
---|
645 | {
|
---|
646 | struct WS(in_addr) imr_multiaddr;
|
---|
647 | struct WS(in_addr) imr_interface;
|
---|
648 | };
|
---|
649 | #endif
|
---|
650 |
|
---|
651 | /*
|
---|
652 | * WSAStartup
|
---|
653 | */
|
---|
654 | #define WSADESCRIPTION_LEN 256
|
---|
655 | #define WSASYS_STATUS_LEN 128
|
---|
656 |
|
---|
657 | typedef struct WS(WSAData)
|
---|
658 | {
|
---|
659 | WORD wVersion;
|
---|
660 | WORD wHighVersion;
|
---|
661 | #ifdef _WIN64
|
---|
662 | WORD iMaxSockets;
|
---|
663 | WORD iMaxUdpDg;
|
---|
664 | char *lpVendorInfo;
|
---|
665 | char szDescription[WSADESCRIPTION_LEN+1];
|
---|
666 | char szSystemStatus[WSASYS_STATUS_LEN+1];
|
---|
667 | #else
|
---|
668 | char szDescription[WSADESCRIPTION_LEN+1];
|
---|
669 | char szSystemStatus[WSASYS_STATUS_LEN+1];
|
---|
670 | WORD iMaxSockets;
|
---|
671 | WORD iMaxUdpDg;
|
---|
672 | char *lpVendorInfo;
|
---|
673 | #endif
|
---|
674 | } WSADATA, *LPWSADATA;
|
---|
675 |
|
---|
676 |
|
---|
677 |
|
---|
678 | /*
|
---|
679 | * {get,set}sockopt
|
---|
680 | */
|
---|
681 | #ifndef USE_WS_PREFIX
|
---|
682 | #define SOL_SOCKET 0xffff
|
---|
683 | #define SO_DEBUG 0x0001
|
---|
684 | #define SO_ACCEPTCONN 0x0002
|
---|
685 | #define SO_REUSEADDR 0x0004
|
---|
686 | #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
|
---|
687 | #define SO_KEEPALIVE 0x0008
|
---|
688 | #define SO_DONTROUTE 0x0010
|
---|
689 | #define SO_BROADCAST 0x0020
|
---|
690 | #define SO_USELOOPBACK 0x0040
|
---|
691 | #define SO_LINGER 0x0080
|
---|
692 | #define SO_OOBINLINE 0x0100
|
---|
693 | #define SO_DONTLINGER ((u_int)(~SO_LINGER))
|
---|
694 | #define SO_SNDBUF 0x1001
|
---|
695 | #define SO_RCVBUF 0x1002
|
---|
696 | #define SO_SNDLOWAT 0x1003
|
---|
697 | #define SO_RCVLOWAT 0x1004
|
---|
698 | #define SO_SNDTIMEO 0x1005
|
---|
699 | #define SO_RCVTIMEO 0x1006
|
---|
700 | #define SO_ERROR 0x1007
|
---|
701 | #define SO_TYPE 0x1008
|
---|
702 |
|
---|
703 |
|
---|
704 | #define IOCPARM_MASK 0x7f
|
---|
705 | #define IOC_VOID 0x20000000
|
---|
706 | #define IOC_OUT 0x40000000
|
---|
707 | #define IOC_IN 0x80000000
|
---|
708 | #define IOC_INOUT (IOC_IN|IOC_OUT)
|
---|
709 |
|
---|
710 | #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
---|
711 | #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
712 | #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
713 |
|
---|
714 | #else
|
---|
715 |
|
---|
716 | #define WS_SOL_SOCKET 0xffff
|
---|
717 | #define WS_SO_DEBUG 0x0001
|
---|
718 | #define WS_SO_ACCEPTCONN 0x0002
|
---|
719 | #define WS_SO_REUSEADDR 0x0004
|
---|
720 | #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
|
---|
721 | #define WS_SO_KEEPALIVE 0x0008
|
---|
722 | #define WS_SO_DONTROUTE 0x0010
|
---|
723 | #define WS_SO_BROADCAST 0x0020
|
---|
724 | #define WS_SO_USELOOPBACK 0x0040
|
---|
725 | #define WS_SO_LINGER 0x0080
|
---|
726 | #define WS_SO_OOBINLINE 0x0100
|
---|
727 | #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
|
---|
728 | #define WS_SO_SNDBUF 0x1001
|
---|
729 | #define WS_SO_RCVBUF 0x1002
|
---|
730 | #define WS_SO_SNDLOWAT 0x1003
|
---|
731 | #define WS_SO_RCVLOWAT 0x1004
|
---|
732 | #define WS_SO_SNDTIMEO 0x1005
|
---|
733 | #define WS_SO_RCVTIMEO 0x1006
|
---|
734 | #define WS_SO_ERROR 0x1007
|
---|
735 | #define WS_SO_TYPE 0x1008
|
---|
736 |
|
---|
737 | #define WS_IOCPARM_MASK 0x7f
|
---|
738 | #define WS_IOC_VOID 0x20000000
|
---|
739 | #define WS_IOC_OUT 0x40000000
|
---|
740 | #define WS_IOC_IN 0x80000000
|
---|
741 | #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
|
---|
742 |
|
---|
743 | #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
|
---|
744 | #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
745 | #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
746 |
|
---|
747 | #endif
|
---|
748 |
|
---|
749 | /* IPPROTO_TCP options */
|
---|
750 | #ifndef USE_WS_PREFIX
|
---|
751 | #define TCP_NODELAY 1
|
---|
752 | #else
|
---|
753 | #define WS_TCP_NODELAY 1
|
---|
754 | #endif
|
---|
755 |
|
---|
756 | /* IPPROTO_IP options */
|
---|
757 | #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
|
---|
758 | # ifndef USE_WS_PREFIX
|
---|
759 | # define IP_OPTIONS 1
|
---|
760 | # define IP_MULTICAST_IF 2
|
---|
761 | # define IP_MULTICAST_TTL 3
|
---|
762 | # define IP_MULTICAST_LOOP 4
|
---|
763 | # define IP_ADD_MEMBERSHIP 5
|
---|
764 | # define IP_DROP_MEMBERSHIP 6
|
---|
765 | # define IP_TTL 7
|
---|
766 | # define IP_TOS 8
|
---|
767 | # define IP_DONTFRAGMENT 9
|
---|
768 | # else
|
---|
769 | # define WS_IP_OPTIONS 1
|
---|
770 | # define WS_IP_MULTICAST_IF 2
|
---|
771 | # define WS_IP_MULTICAST_TTL 3
|
---|
772 | # define WS_IP_MULTICAST_LOOP 4
|
---|
773 | # define WS_IP_ADD_MEMBERSHIP 5
|
---|
774 | # define WS_IP_DROP_MEMBERSHIP 6
|
---|
775 | # define WS_IP_TTL 7
|
---|
776 | # define WS_IP_TOS 8
|
---|
777 | # define WS_IP_DONTFRAGMENT 9
|
---|
778 | # endif
|
---|
779 | #endif
|
---|
780 |
|
---|
781 |
|
---|
782 | /*
|
---|
783 | * Socket I/O flags (supported by spec 1.1)
|
---|
784 | */
|
---|
785 | #ifndef USE_WS_PREFIX
|
---|
786 | #define FIONREAD _IOR('f', 127, ULONG)
|
---|
787 | #define FIONBIO _IOW('f', 126, ULONG)
|
---|
788 | #define FIOASYNC _IOW('f', 125, ULONG)
|
---|
789 | #define SIOCSHIWAT _IOW('s', 0, ULONG)
|
---|
790 | #define SIOCGHIWAT _IOR('s', 1, ULONG)
|
---|
791 | #define SIOCSLOWAT _IOW('s', 2, ULONG)
|
---|
792 | #define SIOCGLOWAT _IOR('s', 3, ULONG)
|
---|
793 | #define SIOCATMARK _IOR('s', 7, ULONG)
|
---|
794 | #else
|
---|
795 | #define WS_FIONREAD WS__IOR('f', 127, ULONG)
|
---|
796 | #define WS_FIONBIO WS__IOW('f', 126, ULONG)
|
---|
797 | #define WS_FIOASYNC WS__IOW('f', 125, ULONG)
|
---|
798 | #define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
|
---|
799 | #define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
|
---|
800 | #define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
|
---|
801 | #define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
|
---|
802 | #define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
|
---|
803 | #endif
|
---|
804 |
|
---|
805 | /*
|
---|
806 | * Maximum queue length specifiable by listen.
|
---|
807 | */
|
---|
808 | #ifndef USE_WS_PREFIX
|
---|
809 | #define SOMAXCONN 5
|
---|
810 |
|
---|
811 | #define MSG_OOB 0x0001
|
---|
812 | #define MSG_PEEK 0x0002
|
---|
813 | #define MSG_DONTROUTE 0x0004
|
---|
814 | #define MSG_WAITALL 0x0008
|
---|
815 | #define MSG_INTERRUPT 0x0010
|
---|
816 | #define MSG_PARTIAL 0x8000
|
---|
817 | #define MSG_MAXIOVLEN 16
|
---|
818 | #else /* USE_WS_PREFIX */
|
---|
819 | #define WS_SOMAXCONN 5
|
---|
820 |
|
---|
821 | #define WS_MSG_OOB 0x0001
|
---|
822 | #define WS_MSG_PEEK 0x0002
|
---|
823 | #define WS_MSG_DONTROUTE 0x0004
|
---|
824 | #define WS_MSG_WAITALL 0x0008
|
---|
825 | #define WS_MSG_INTERRUPT 0x0010
|
---|
826 | #define WS_MSG_PARTIAL 0x8000
|
---|
827 | #define WS_MSG_MAXIOVLEN 16
|
---|
828 | #endif /* USE_WS_PREFIX */
|
---|
829 |
|
---|
830 | /*
|
---|
831 | * Define constant based on rfc883, used by gethostbyxxxx() calls.
|
---|
832 | */
|
---|
833 | #ifndef USE_WS_PREFIX
|
---|
834 | #define MAXGETHOSTSTRUCT 1024
|
---|
835 | #else
|
---|
836 | #define MAXGETHOSTSTRUCT 1024
|
---|
837 | #endif
|
---|
838 |
|
---|
839 |
|
---|
840 | /*
|
---|
841 | * Define flags to be used with the WSAAsyncSelect() call.
|
---|
842 | */
|
---|
843 | #define FD_READ 0x00000001
|
---|
844 | #define FD_WRITE 0x00000002
|
---|
845 | #define FD_OOB 0x00000004
|
---|
846 | #define FD_ACCEPT 0x00000008
|
---|
847 | #define FD_CONNECT 0x00000010
|
---|
848 | #define FD_CLOSE 0x00000020
|
---|
849 |
|
---|
850 | /* internal per-socket flags */
|
---|
851 | #ifdef __WINESRC__
|
---|
852 | #define FD_WINE_LISTENING 0x10000000
|
---|
853 | #define FD_WINE_NONBLOCKING 0x20000000
|
---|
854 | #define FD_WINE_CONNECTED 0x40000000
|
---|
855 | #define FD_WINE_RAW 0x80000000
|
---|
856 | #define FD_WINE_INTERNAL 0xFFFF0000
|
---|
857 | #endif
|
---|
858 |
|
---|
859 | /*
|
---|
860 | * All Windows Sockets error constants are biased by WSABASEERR from
|
---|
861 | * the "normal". They are also defined in winerror.h.
|
---|
862 | */
|
---|
863 | #define WSABASEERR 10000
|
---|
864 | /*
|
---|
865 | * Windows Sockets definitions of regular Microsoft C error constants
|
---|
866 | */
|
---|
867 | #define WSAEINTR (WSABASEERR+4)
|
---|
868 | #define WSAEBADF (WSABASEERR+9)
|
---|
869 | #define WSAEACCES (WSABASEERR+13)
|
---|
870 | #define WSAEFAULT (WSABASEERR+14)
|
---|
871 | #define WSAEINVAL (WSABASEERR+22)
|
---|
872 | #define WSAEMFILE (WSABASEERR+24)
|
---|
873 |
|
---|
874 | /*
|
---|
875 | * Windows Sockets definitions of regular Berkeley error constants
|
---|
876 | */
|
---|
877 | #define WSAEWOULDBLOCK (WSABASEERR+35)
|
---|
878 | #define WSAEINPROGRESS (WSABASEERR+36)
|
---|
879 | #define WSAEALREADY (WSABASEERR+37)
|
---|
880 | #define WSAENOTSOCK (WSABASEERR+38)
|
---|
881 | #define WSAEDESTADDRREQ (WSABASEERR+39)
|
---|
882 | #define WSAEMSGSIZE (WSABASEERR+40)
|
---|
883 | #define WSAEPROTOTYPE (WSABASEERR+41)
|
---|
884 | #define WSAENOPROTOOPT (WSABASEERR+42)
|
---|
885 | #define WSAEPROTONOSUPPORT (WSABASEERR+43)
|
---|
886 | #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
|
---|
887 | #define WSAEOPNOTSUPP (WSABASEERR+45)
|
---|
888 | #define WSAEPFNOSUPPORT (WSABASEERR+46)
|
---|
889 | #define WSAEAFNOSUPPORT (WSABASEERR+47)
|
---|
890 | #define WSAEADDRINUSE (WSABASEERR+48)
|
---|
891 | #define WSAEADDRNOTAVAIL (WSABASEERR+49)
|
---|
892 | #define WSAENETDOWN (WSABASEERR+50)
|
---|
893 | #define WSAENETUNREACH (WSABASEERR+51)
|
---|
894 | #define WSAENETRESET (WSABASEERR+52)
|
---|
895 | #define WSAECONNABORTED (WSABASEERR+53)
|
---|
896 | #define WSAECONNRESET (WSABASEERR+54)
|
---|
897 | #define WSAENOBUFS (WSABASEERR+55)
|
---|
898 | #define WSAEISCONN (WSABASEERR+56)
|
---|
899 | #define WSAENOTCONN (WSABASEERR+57)
|
---|
900 | #define WSAESHUTDOWN (WSABASEERR+58)
|
---|
901 | #define WSAETOOMANYREFS (WSABASEERR+59)
|
---|
902 | #define WSAETIMEDOUT (WSABASEERR+60)
|
---|
903 | #define WSAECONNREFUSED (WSABASEERR+61)
|
---|
904 | #define WSAELOOP (WSABASEERR+62)
|
---|
905 | #define WSAENAMETOOLONG (WSABASEERR+63)
|
---|
906 | #define WSAEHOSTDOWN (WSABASEERR+64)
|
---|
907 | #define WSAEHOSTUNREACH (WSABASEERR+65)
|
---|
908 | #define WSAENOTEMPTY (WSABASEERR+66)
|
---|
909 | #define WSAEPROCLIM (WSABASEERR+67)
|
---|
910 | #define WSAEUSERS (WSABASEERR+68)
|
---|
911 | #define WSAEDQUOT (WSABASEERR+69)
|
---|
912 | #define WSAESTALE (WSABASEERR+70)
|
---|
913 | #define WSAEREMOTE (WSABASEERR+71)
|
---|
914 |
|
---|
915 | /*
|
---|
916 | * Extended Windows Sockets error constant definitions
|
---|
917 | */
|
---|
918 | #define WSASYSNOTREADY (WSABASEERR+91)
|
---|
919 | #define WSAVERNOTSUPPORTED (WSABASEERR+92)
|
---|
920 | #define WSANOTINITIALISED (WSABASEERR+93)
|
---|
921 | #define WSAEDISCON (WSABASEERR+101)
|
---|
922 | #define WSAENOMORE (WSABASEERR+102)
|
---|
923 | #define WSAECANCELLED (WSABASEERR+103)
|
---|
924 | #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
|
---|
925 | #define WSAEINVALIDPROVIDER (WSABASEERR+105)
|
---|
926 | #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
|
---|
927 | #define WSASYSCALLFAILURE (WSABASEERR+107)
|
---|
928 | #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
|
---|
929 | #define WSATYPE_NOT_FOUND (WSABASEERR+109)
|
---|
930 | #define WSA_E_NO_MORE (WSABASEERR+110)
|
---|
931 | #define WSA_E_CANCELLED (WSABASEERR+111)
|
---|
932 | #define WSAEREFUSED (WSABASEERR+112)
|
---|
933 |
|
---|
934 | /*
|
---|
935 | * Error return codes from gethostbyname() and gethostbyaddr()
|
---|
936 | * (when using the resolver). Note that these errors are
|
---|
937 | * retrieved via WSAGetLastError() and must therefore follow
|
---|
938 | * the rules for avoiding clashes with error numbers from
|
---|
939 | * specific implementations or language run-time systems.
|
---|
940 | * For this reason the codes are based at WSABASEERR+1001.
|
---|
941 | * Note also that [WSA]NO_ADDRESS is defined only for
|
---|
942 | * compatibility purposes.
|
---|
943 | */
|
---|
944 |
|
---|
945 | #ifndef USE_WS_PREFIX
|
---|
946 | #define h_errno WSAGetLastError()
|
---|
947 | #else
|
---|
948 | #define WS_h_errno WSAGetLastError()
|
---|
949 | #endif
|
---|
950 |
|
---|
951 | /* Authoritative Answer: Host not found */
|
---|
952 | #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
|
---|
953 |
|
---|
954 | /* Non-Authoritative: Host not found, or SERVERFAIL */
|
---|
955 | #define WSATRY_AGAIN (WSABASEERR+1002)
|
---|
956 |
|
---|
957 | /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
|
---|
958 | #define WSANO_RECOVERY (WSABASEERR+1003)
|
---|
959 |
|
---|
960 | /* Valid name, no data record of requested type */
|
---|
961 | #define WSANO_DATA (WSABASEERR+1004)
|
---|
962 |
|
---|
963 | /* no address, look for MX record */
|
---|
964 | #define WSANO_ADDRESS WSANO_DATA
|
---|
965 |
|
---|
966 | #ifndef USE_WS_PREFIX
|
---|
967 | #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
|
---|
968 | #define TRY_AGAIN WSATRY_AGAIN
|
---|
969 | #define NO_RECOVERY WSANO_RECOVERY
|
---|
970 | #define NO_DATA WSANO_DATA
|
---|
971 | #define NO_ADDRESS WSANO_ADDRESS
|
---|
972 | #endif /* USE_WS_PREFIX */
|
---|
973 |
|
---|
974 |
|
---|
975 |
|
---|
976 | /*
|
---|
977 | * Windows message parameter composition and decomposition
|
---|
978 | * macros.
|
---|
979 | */
|
---|
980 |
|
---|
981 | /*
|
---|
982 | * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
|
---|
983 | * when constructing the response to a WSAAsyncGetXByY() routine.
|
---|
984 | */
|
---|
985 | #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
|
---|
986 | /*
|
---|
987 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
|
---|
988 | * when constructing the response to WSAAsyncSelect().
|
---|
989 | */
|
---|
990 | #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
---|
991 | /*
|
---|
992 | * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
|
---|
993 | * to extract the buffer length from the lParam in the response
|
---|
994 | * to a WSAGetXByY().
|
---|
995 | */
|
---|
996 | #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
|
---|
997 | /*
|
---|
998 | * WSAGETASYNCERROR is intended for use by the Windows Sockets application
|
---|
999 | * to extract the error code from the lParam in the response
|
---|
1000 | * to a WSAGetXByY().
|
---|
1001 | */
|
---|
1002 | #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
|
---|
1003 | /*
|
---|
1004 | * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
|
---|
1005 | * to extract the event code from the lParam in the response
|
---|
1006 | * to a WSAAsyncSelect().
|
---|
1007 | */
|
---|
1008 | #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
|
---|
1009 | /*
|
---|
1010 | * WSAGETSELECTERROR is intended for use by the Windows Sockets application
|
---|
1011 | * to extract the error code from the lParam in the response
|
---|
1012 | * to a WSAAsyncSelect().
|
---|
1013 | */
|
---|
1014 | #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
|
---|
1015 |
|
---|
1016 |
|
---|
1017 |
|
---|
1018 | /*
|
---|
1019 | * Prototypes
|
---|
1020 | *
|
---|
1021 | * Remember to keep this section in sync with the
|
---|
1022 | * "Winsock Function Typedefs" section in winsock2.h.
|
---|
1023 | */
|
---|
1024 | #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
|
---|
1025 | HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
|
---|
1026 | HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
|
---|
1027 | HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
|
---|
1028 | HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
|
---|
1029 | HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
|
---|
1030 | HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
|
---|
1031 | int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
|
---|
1032 | int WINAPI WSACancelAsyncRequest(HANDLE);
|
---|
1033 | int WINAPI WSACancelBlockingCall(void);
|
---|
1034 | int WINAPI WSACleanup(void);
|
---|
1035 | int WINAPI WSAGetLastError(void);
|
---|
1036 | BOOL WINAPI WSAIsBlocking(void);
|
---|
1037 | FARPROC WINAPI WSASetBlockingHook(FARPROC);
|
---|
1038 | void WINAPI WSASetLastError(int);
|
---|
1039 | int WINAPI WSAStartup(WORD,LPWSADATA);
|
---|
1040 | int WINAPI WSAUnhookBlockingHook(void);
|
---|
1041 |
|
---|
1042 | SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
|
---|
1043 | int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
|
---|
1044 | int WINAPI WS(closesocket)(SOCKET);
|
---|
1045 | int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
|
---|
1046 | struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
|
---|
1047 | struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
|
---|
1048 | /* gethostname not defined because of conflicts with unistd.h */
|
---|
1049 | int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
|
---|
1050 | struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
|
---|
1051 | struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
|
---|
1052 | #ifdef WS_DEFINE_SELECT
|
---|
1053 | int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
|
---|
1054 | #endif
|
---|
1055 | struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
|
---|
1056 | struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
|
---|
1057 | int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
|
---|
1058 | int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
|
---|
1059 | ULONG WINAPI WS(inet_addr)(const char*);
|
---|
1060 | char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
|
---|
1061 | int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
|
---|
1062 | int WINAPI WS(listen)(SOCKET,int);
|
---|
1063 | int WINAPI WS(recv)(SOCKET,char*,int,int);
|
---|
1064 | int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
|
---|
1065 | int WINAPI WS(send)(SOCKET,const char*,int,int);
|
---|
1066 | int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
|
---|
1067 | int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
|
---|
1068 | int WINAPI WS(shutdown)(SOCKET,int);
|
---|
1069 | SOCKET WINAPI WS(socket)(int,int,int);
|
---|
1070 |
|
---|
1071 | #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
|
---|
1072 |
|
---|
1073 | #ifdef __cplusplus
|
---|
1074 | }
|
---|
1075 | #endif
|
---|
1076 |
|
---|
1077 | #ifndef __WINE_WINSOCK2__
|
---|
1078 | #undef WS
|
---|
1079 | #undef WS_API_PROTOTYPES
|
---|
1080 | #undef WS_API_TYPEDEFS
|
---|
1081 | #endif
|
---|
1082 |
|
---|
1083 | #endif /* _WINSOCKAPI_ */
|
---|