Don't use a hex number for the event in the default string.
[wine/multimedia.git] / include / winsock.h
blob47d1aa40062171ff92b3e2554e480d9081ca8cb3
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
6 * Copyright (C) the Wine project
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifdef __WINESRC__
24 # ifndef __WINE_WINSOCK2__
25 # error Please use Winsock2 in Wine
26 # endif
27 #endif
29 #ifndef __WINE_WINSOCKAPI_STDLIB_H
30 #define __WINE_WINSOCKAPI_STDLIB_H
33 * This section defines the items that conflict with the Unix headers.
35 #ifndef USE_WS_PREFIX
36 /* We are not using the WS_ prefix we risk getting conflicts for
37 * everything related to select.
39 # ifdef FD_CLR
40 /* Too late, the Unix version of stdlib.h was included before winsock.h.
41 * This means select and all the related stuff is already defined and we
42 * cannot override types and function prototypes.
43 * All we can do is disable all these symbols so that they are not used
44 * inadvertantly.
46 # undef FD_SETSIZE
47 # undef FD_CLR
48 # undef FD_SET
49 # undef FD_ZERO
50 # undef FD_ISSET
52 # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
53 # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54 # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55 # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56 # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57 # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58 # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
59 # define htonl Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
60 # define htons Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
61 # define ntohl Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
62 # define ntohs Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
63 # else /* FD_CLR */
64 /* stdlib.h has not been included yet so it's not too late. Include it now
65 * making sure that none of the select symbols is affected. Then we can
66 * define them with our own values.
68 # define fd_set unix_fd_set
69 # define timeval unix_timeval
70 # define select unix_select
71 # define htonl unix_htonl
72 # define htons unix_htons
73 # define ntohl unix_ntohl
74 # define ntohs unix_ntohs
75 # include <sys/types.h>
76 # include <stdlib.h>
77 # undef fd_set
78 # undef timeval
79 # undef select
80 # undef htonl
81 # undef htons
82 # undef ntohl
83 # undef ntohs
84 # undef FD_SETSIZE
85 # undef FD_CLR
86 # undef FD_SET
87 # undef FD_ZERO
88 # undef FD_ISSET
90 # define WS_DEFINE_SELECT
91 # endif /* FD_CLR */
93 #else
94 # define WS_DEFINE_SELECT
95 # include <sys/types.h>
96 # include <stdlib.h>
97 #endif /* !USE_WS_PREFIX */
99 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
101 #ifndef __WINESRC__
102 # include "windows.h"
103 #else
104 # include "windef.h"
105 #endif
107 #ifndef _WINSOCKAPI_
108 #define _WINSOCKAPI_
110 #if defined(__MINGW_H) && !defined(MSVCRT_BSD_TYPES_DEFINED)
111 /* MinGW doesn't define the u_xxx types */
112 typedef unsigned char u_char;
113 typedef unsigned short u_short;
114 typedef unsigned int u_int;
115 typedef unsigned long u_long;
116 #endif
118 #ifdef USE_WS_PREFIX
119 # define WS(x) WS_##x
120 #else
121 # define WS(x) x
122 #endif
124 #ifdef __cplusplus
125 extern "C" {
126 #endif /* defined(__cplusplus) */
128 /* proper 4-byte packing */
129 #include "pshpack4.h"
132 * Address families
134 #ifndef USE_WS_PREFIX
135 #define AF_UNSPEC 0
136 #define AF_UNIX 1
137 #define AF_INET 2
138 #define AF_IMPLINK 3
139 #define AF_PUP 4
140 #define AF_CHAOS 5
141 #define AF_NS 6
142 #define AF_IPX AF_NS
143 #define AF_ISO 7
144 #define AF_OSI AF_ISO
145 #define AF_ECMA 8
146 #define AF_DATAKIT 9
147 #define AF_CCITT 10
148 #define AF_SNA 11
149 #define AF_DECnet 12
150 #define AF_DLI 13
151 #define AF_LAT 14
152 #define AF_HYLINK 15
153 #define AF_APPLETALK 16
154 #define AF_NETBIOS 17
155 #define AF_VOICEVIEW 18
156 #define AF_FIREFOX 19
157 #define AF_UNKNOWN1 20
158 #define AF_BAN 21
159 #define AF_ATM 22
160 #define AF_INET6 23
161 #define AF_CLUSTER 24
162 #define AF_12844 25
163 #define AF_IRDA 26
164 #define AF_MAX 27
165 #define PF_UNSPEC AF_UNSPEC
166 #define PF_UNIX AF_UNIX
167 #define PF_INET AF_INET
168 #define PF_IMPLINK AF_IMPLINK
169 #define PF_PUP AF_PUP
170 #define PF_CHAOS AF_CHAOS
171 #define PF_NS AF_NS
172 #define PF_IPX AF_IPX
173 #define PF_ISO AF_ISO
174 #define PF_OSI AF_OSI
175 #define PF_ECMA AF_ECMA
176 #define PF_DATAKIT AF_DATAKIT
177 #define PF_CCITT AF_CCITT
178 #define PF_SNA AF_SNA
179 #define PF_DECnet AF_DECnet
180 #define PF_DLI AF_DLI
181 #define PF_LAT AF_LAT
182 #define PF_HYLINK AF_HYLINK
183 #define PF_APPLETALK AF_APPLETALK
184 #define PF_VOICEVIEW AF_VOICEVIEW
185 #define PF_FIREFOX AF_FIREFOX
186 #define PF_UNKNOWN1 AF_UNKNOWN1
187 #define PF_BAN AF_BAN
188 #define PF_MAX AF_MAX
189 #else /* USE_WS_PREFIX */
190 #define WS_AF_UNSPEC 0
191 #define WS_AF_UNIX 1
192 #define WS_AF_INET 2
193 #define WS_AF_IMPLINK 3
194 #define WS_AF_PUP 4
195 #define WS_AF_CHAOS 5
196 #define WS_AF_NS 6
197 #define WS_AF_IPX WS_AF_NS
198 #define WS_AF_ISO 7
199 #define WS_AF_OSI AF_ISO
200 #define WS_AF_ECMA 8
201 #define WS_AF_DATAKIT 9
202 #define WS_AF_CCITT 10
203 #define WS_AF_SNA 11
204 #define WS_AF_DECnet 12
205 #define WS_AF_DLI 13
206 #define WS_AF_LAT 14
207 #define WS_AF_HYLINK 15
208 #define WS_AF_APPLETALK 16
209 #define WS_AF_NETBIOS 17
210 #define WS_AF_VOICEVIEW 18
211 #define WS_AF_FIREFOX 19
212 #define WS_AF_UNKNOWN1 20
213 #define WS_AF_BAN 21
214 #define WS_AF_ATM 22
215 #define WS_AF_INET6 23
216 #define WS_AF_CLUSTER 24
217 #define WS_AF_12844 25
218 #define WS_AF_IRDA 26
219 #define WS_AF_MAX 27
220 #endif /* USE_WS_PREFIX */
223 * Types
225 #ifndef USE_WS_PREFIX
226 #define SOCK_STREAM 1
227 #define SOCK_DGRAM 2
228 #define SOCK_RAW 3
229 #define SOCK_RDM 4
230 #define SOCK_SEQPACKET 5
231 #else /* USE_WS_PREFIX */
232 #define WS_SOCK_STREAM 1
233 #define WS_SOCK_DGRAM 2
234 #define WS_SOCK_RAW 3
235 #define WS_SOCK_RDM 4
236 #define WS_SOCK_SEQPACKET 5
237 #endif /* USE_WS_PREFIX */
241 * Protocols
243 #ifndef USE_WS_PREFIX
244 #define IPPROTO_IP 0
245 #define IPPROTO_ICMP 1
246 #define IPPROTO_IGMP 2
247 #define IPPROTO_GGP 3
248 #define IPPROTO_TCP 6
249 #define IPPROTO_UDP 17
250 #define IPPROTO_IDP 22
251 #define IPPROTO_ND 77
252 #define IPPROTO_RAW 255
253 #define IPPROTO_MAX 256
254 #else /* USE_WS_PREFIX */
255 #define WS_IPPROTO_IP 0
256 #define WS_IPPROTO_ICMP 1
257 #define WS_IPPROTO_IGMP 2
258 #define WS_IPPROTO_GGP 3
259 #define WS_IPPROTO_TCP 6
260 #define WS_IPPROTO_UDP 17
261 #define WS_IPPROTO_IDP 22
262 #define WS_IPPROTO_ND 77
263 #define WS_IPPROTO_RAW 255
264 #define WS_IPPROTO_MAX 256
265 #endif /* USE_WS_PREFIX */
267 typedef struct WS(protoent)
269 char* p_name;
270 char** p_aliases;
271 short p_proto;
272 } PROTOENT, *PPROTOENT, *LPPROTOENT;
277 * Networks
279 struct WS(netent)
281 char* n_name; /* official name of net */
282 char** n_aliases; /* alias list */
283 short n_addrtype; /* net address type */
284 u_long n_net; /* network # */
289 * Services
291 #ifndef USE_WS_PREFIX
292 #define IPPORT_ECHO 7
293 #define IPPORT_DISCARD 9
294 #define IPPORT_SYSTAT 11
295 #define IPPORT_DAYTIME 13
296 #define IPPORT_NETSTAT 15
297 #define IPPORT_FTP 21
298 #define IPPORT_TELNET 23
299 #define IPPORT_SMTP 25
300 #define IPPORT_TIMESERVER 37
301 #define IPPORT_NAMESERVER 42
302 #define IPPORT_WHOIS 43
303 #define IPPORT_MTP 57
304 #define IPPORT_TFTP 69
305 #define IPPORT_RJE 77
306 #define IPPORT_FINGER 79
307 #define IPPORT_TTYLINK 87
308 #define IPPORT_SUPDUP 95
309 #define IPPORT_EXECSERVER 512
310 #define IPPORT_LOGINSERVER 513
311 #define IPPORT_CMDSERVER 514
312 #define IPPORT_EFSSERVER 520
313 #define IPPORT_BIFFUDP 512
314 #define IPPORT_WHOSERVER 513
315 #define IPPORT_ROUTESERVER 520
316 #define IPPORT_RESERVED 1024
317 #else /* USE_WS_PREFIX */
318 #define WS_IPPORT_ECHO 7
319 #define WS_IPPORT_DISCARD 9
320 #define WS_IPPORT_SYSTAT 11
321 #define WS_IPPORT_DAYTIME 13
322 #define WS_IPPORT_NETSTAT 15
323 #define WS_IPPORT_FTP 21
324 #define WS_IPPORT_TELNET 23
325 #define WS_IPPORT_SMTP 25
326 #define WS_IPPORT_TIMESERVER 37
327 #define WS_IPPORT_NAMESERVER 42
328 #define WS_IPPORT_WHOIS 43
329 #define WS_IPPORT_MTP 57
330 #define WS_IPPORT_TFTP 69
331 #define WS_IPPORT_RJE 77
332 #define WS_IPPORT_FINGER 79
333 #define WS_IPPORT_TTYLINK 87
334 #define WS_IPPORT_SUPDUP 95
335 #define WS_IPPORT_EXECSERVER 512
336 #define WS_IPPORT_LOGINSERVER 513
337 #define WS_IPPORT_CMDSERVER 514
338 #define WS_IPPORT_EFSSERVER 520
339 #define WS_IPPORT_BIFFUDP 512
340 #define WS_IPPORT_WHOSERVER 513
341 #define WS_IPPORT_ROUTESERVER 520
342 #define WS_IPPORT_RESERVED 1024
343 #endif /* USE_WS_PREFIX */
345 typedef struct WS(servent)
347 char* s_name; /* official service name */
348 char** s_aliases; /* alias list */
349 short s_port; /* port # */
350 char* s_proto; /* protocol to use */
351 } SERVENT, *PSERVENT, *LPSERVENT;
356 * Hosts
359 typedef struct WS(hostent)
361 char* h_name; /* official name of host */
362 char** h_aliases; /* alias list */
363 short h_addrtype; /* host address type */
364 short h_length; /* length of address */
365 char** h_addr_list; /* list of addresses from name server */
366 #define h_addr h_addr_list[0] /* address, for backward compat */
367 } HOSTENT, *PHOSTENT, *LPHOSTENT;
371 * Sockets
374 typedef UINT_PTR SOCKET;
377 * This is used instead of -1, since the
378 * SOCKET type is unsigned.
380 #define INVALID_SOCKET (~0)
381 #define SOCKET_ERROR (-1)
383 typedef struct WS(sockaddr)
385 u_short sa_family;
386 char sa_data[14];
387 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
389 typedef struct WS(linger)
391 u_short l_onoff; /* option on/off */
392 u_short l_linger; /* linger time */
393 } LINGER, *PLINGER, *LPLINGER;
396 * Select
399 #ifdef WS_DEFINE_SELECT
400 /* Define our own version of select and the associated types and macros */
402 # ifndef USE_WS_PREFIX
403 # ifndef FD_SETSIZE
404 # define FD_SETSIZE 64
405 # endif
406 # else
407 # ifndef WS_FD_SETSIZE
408 # define WS_FD_SETSIZE 64
409 # endif
410 # endif
412 typedef struct WS(fd_set)
414 u_int fd_count; /* how many are SET? */
415 # ifndef USE_WS_PREFIX
416 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
417 # else
418 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
419 # endif
420 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
422 typedef struct WS(timeval)
424 long tv_sec; /* seconds */
425 long tv_usec; /* and microseconds */
426 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
428 #define WINE_FD_CLR(fd, set, cast) do { \
429 u_int __i; \
430 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
432 if (((cast*)(set))->fd_array[__i] == fd) \
434 while (__i < ((cast*)(set))->fd_count-1) \
436 ((cast*)(set))->fd_array[__i] = \
437 ((cast*)(set))->fd_array[__i+1]; \
438 __i++; \
440 ((cast*)(set))->fd_count--; \
441 break; \
444 } while(0)
445 #define __WS_FD_SET1(fd, set, cast) do { \
446 if (((cast*)(set))->fd_count < FD_SETSIZE) \
447 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
448 } while(0)
449 /* This version checks if the filedesc is already in the list, and appends it
450 * only if it's not the case
452 #define __WS_FD_SET2(fd, set, cast) do { \
453 u_int __i; \
454 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
456 if (((cast*)(set))->fd_array[__i]==(fd)) \
457 break; \
459 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
461 ((cast*)(set))->fd_count++; \
462 ((cast*)(set))->fd_array[__i]=(fd);\
464 } while(0)
466 #ifndef __WINE_WINSOCK2__
467 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
468 #else
469 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
470 #endif
472 #ifndef USE_WS_PREFIX
473 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
474 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
475 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
476 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
477 #else
478 #define WS_FD_CLR(fd, set) WINE_FD_CLR((fd),(set), WS_fd_set)
479 #define WS_FD_SET(fd, set) WINE_FD_SET((fd),(set), WS_fd_set)
480 #define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
481 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
482 #endif
484 u_long WINAPI WS(htonl)(u_long);
485 u_short WINAPI WS(htons)(u_short);
486 u_long WINAPI WS(ntohl)(u_long);
487 u_short WINAPI WS(ntohs)(u_short);
489 #endif /* WS_DEFINE_SELECT */
493 * Internet address (old style... should be updated)
496 #ifndef USE_WS_PREFIX
497 #define IN_CLASSA_NSHIFT 24
498 #define IN_CLASSA_MAX 128
499 #define IN_CLASSA_NET 0xff000000
500 #define IN_CLASSA_HOST 0x00ffffff
501 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
502 #define IN_CLASSB_NSHIFT 16
503 #define IN_CLASSB_MAX 65536
504 #define IN_CLASSB_NET 0xffff0000
505 #define IN_CLASSB_HOST 0x0000ffff
506 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
507 #define IN_CLASSC_NSHIFT 8
508 #define IN_CLASSC_NET 0xffffff00
509 #define IN_CLASSC_HOST 0x000000ff
510 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
511 #else
512 #define WS_IN_CLASSA_NSHIFT 24
513 #define WS_IN_CLASSA_MAX 128
514 #define WS_IN_CLASSA_NET 0xff000000
515 #define WS_IN_CLASSA_HOST 0x00ffffff
516 #define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
517 #define WS_IN_CLASSB_NSHIFT 16
518 #define WS_IN_CLASSB_MAX 65536
519 #define WS_IN_CLASSB_NET 0xffff0000
520 #define WS_IN_CLASSB_HOST 0x0000ffff
521 #define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
522 #define WS_IN_CLASSC_NSHIFT 8
523 #define WS_IN_CLASSC_NET 0xffffff00
524 #define WS_IN_CLASSC_HOST 0x000000ff
525 #define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
526 #endif /* USE_WS_PREFIX */
528 #ifndef USE_WS_PREFIX
529 #define INADDR_ANY (u_long)0x00000000
530 #define INADDR_LOOPBACK 0x7f000001
531 #define INADDR_BROADCAST (u_long)0xffffffff
532 #define INADDR_NONE 0xffffffff
533 #else
534 #define WS_INADDR_ANY (u_long)0x00000000
535 #define WS_INADDR_LOOPBACK 0x7f000001
536 #define WS_INADDR_BROADCAST (u_long)0xffffffff
537 #define WS_INADDR_NONE 0xffffffff
538 #endif /* USE_WS_PREFIX */
540 typedef struct WS(in_addr)
542 union {
543 struct {
544 u_char s_b1,s_b2,s_b3,s_b4;
545 } S_un_b;
546 struct {
547 u_short s_w1,s_w2;
548 } S_un_w;
549 u_long S_addr;
550 } S_un;
551 #ifndef USE_WS_PREFIX
552 #define s_addr S_un.S_addr
553 #define s_host S_un.S_un_b.s_b2
554 #define s_net S_un.S_un_b.s_b1
555 #define s_imp S_un.S_un_w.s_w2
556 #define s_impno S_un.S_un_b.s_b4
557 #define s_lh S_un.S_un_b.s_b3
558 #else
559 #define WS_s_addr S_un.S_addr
560 #define WS_s_host S_un.S_un_b.s_b2
561 #define WS_s_net S_un.S_un_b.s_b1
562 #define WS_s_imp S_un.S_un_w.s_w2
563 #define WS_s_impno S_un.S_un_b.s_b4
564 #define WS_s_lh S_un.S_un_b.s_b3
565 #endif /* USE_WS_PREFIX */
566 } IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
568 typedef struct WS(sockaddr_in)
570 short sin_family;
571 u_short sin_port;
572 struct WS(in_addr) sin_addr;
573 char sin_zero[8];
574 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
578 * WSAStartup
580 #define WSADESCRIPTION_LEN 256
581 #define WSASYS_STATUS_LEN 128
583 typedef struct WS(WSAData)
585 WORD wVersion;
586 WORD wHighVersion;
587 char szDescription[WSADESCRIPTION_LEN+1];
588 char szSystemStatus[WSASYS_STATUS_LEN+1];
589 WORD iMaxSockets;
590 WORD iMaxUdpDg;
591 char *lpVendorInfo;
592 } WSADATA, *LPWSADATA;
597 * {get,set}sockopt
599 #ifndef USE_WS_PREFIX
600 #define SOL_SOCKET 0xffff
601 #define SO_DEBUG 0x0001
602 #define SO_ACCEPTCONN 0x0002
603 #define SO_REUSEADDR 0x0004
604 #define SO_KEEPALIVE 0x0008
605 #define SO_DONTROUTE 0x0010
606 #define SO_BROADCAST 0x0020
607 #define SO_USELOOPBACK 0x0040
608 #define SO_LINGER 0x0080
609 #define SO_OOBINLINE 0x0100
610 #define SO_DONTLINGER (u_int)(~SO_LINGER)
611 #define SO_SNDBUF 0x1001
612 #define SO_RCVBUF 0x1002
613 #define SO_SNDLOWAT 0x1003
614 #define SO_RCVLOWAT 0x1004
615 #define SO_SNDTIMEO 0x1005
616 #define SO_RCVTIMEO 0x1006
617 #define SO_ERROR 0x1007
618 #define SO_TYPE 0x1008
621 #define IOCPARM_MASK 0x7f
622 #define IOC_VOID 0x20000000
623 #define IOC_OUT 0x40000000
624 #define IOC_IN 0x80000000
625 #define IOC_INOUT (IOC_IN|IOC_OUT)
627 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
628 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
629 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
631 #else
633 #define WS_SOL_SOCKET 0xffff
634 #define WS_SO_DEBUG 0x0001
635 #define WS_SO_ACCEPTCONN 0x0002
636 #define WS_SO_REUSEADDR 0x0004
637 #define WS_SO_KEEPALIVE 0x0008
638 #define WS_SO_DONTROUTE 0x0010
639 #define WS_SO_BROADCAST 0x0020
640 #define WS_SO_USELOOPBACK 0x0040
641 #define WS_SO_LINGER 0x0080
642 #define WS_SO_OOBINLINE 0x0100
643 #define WS_SO_DONTLINGER (u_int)(~WS_SO_LINGER)
644 #define WS_SO_SNDBUF 0x1001
645 #define WS_SO_RCVBUF 0x1002
646 #define WS_SO_SNDLOWAT 0x1003
647 #define WS_SO_RCVLOWAT 0x1004
648 #define WS_SO_SNDTIMEO 0x1005
649 #define WS_SO_RCVTIMEO 0x1006
650 #define WS_SO_ERROR 0x1007
651 #define WS_SO_TYPE 0x1008
653 #define WS_IOCPARM_MASK 0x7f
654 #define WS_IOC_VOID 0x20000000
655 #define WS_IOC_OUT 0x40000000
656 #define WS_IOC_IN 0x80000000
657 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
659 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
660 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
661 #define WS__IOW(x,y,t) (WS_IOC_IN|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
663 #endif
665 /* IPPROTO_TCP options */
666 #ifndef USE_WS_PREFIX
667 #define TCP_NODELAY 1
668 #else
669 #define WS_TCP_NODELAY 1
670 #endif
672 /* IPPROTO_IP options */
673 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
674 # ifndef USE_WS_PREFIX
675 # define IP_OPTIONS 1
676 # define IP_MULTICAST_IF 2
677 # define IP_MULTICAST_TTL 3
678 # define IP_MULTICAST_LOOP 4
679 # define IP_ADD_MEMBERSHIP 5
680 # define IP_DROP_MEMBERSHIP 6
681 # define IP_TTL 7
682 # define IP_TOS 8
683 # define IP_DONTFRAGMENT 9
684 # else
685 # define WS_IP_OPTIONS 1
686 # define WS_IP_MULTICAST_IF 2
687 # define WS_IP_MULTICAST_TTL 3
688 # define WS_IP_MULTICAST_LOOP 4
689 # define WS_IP_ADD_MEMBERSHIP 5
690 # define WS_IP_DROP_MEMBERSHIP 6
691 # define WS_IP_TTL 7
692 # define WS_IP_TOS 8
693 # define WS_IP_DONTFRAGMENT 9
694 # endif
695 #endif
699 * Socket I/O flags (supported by spec 1.1)
701 #ifndef USE_WS_PREFIX
702 #define FIONREAD _IOR('f', 127, u_long)
703 #define FIONBIO _IOW('f', 126, u_long)
704 #define SIOCATMARK _IOR('s', 7, u_long)
705 #else
706 #define WS_FIONREAD WS__IOR('f', 127, u_long)
707 #define WS_FIONBIO WS__IOW('f', 126, u_long)
708 #define WS_SIOCATMARK WS__IOR('s', 7, u_long)
709 #endif
712 * Maximum queue length specifiable by listen.
714 #ifndef USE_WS_PREFIX
715 #define SOMAXCONN 5
717 #define MSG_OOB 0x0001
718 #define MSG_PEEK 0x0002
719 #define MSG_DONTROUTE 0x0004
720 #define MSG_MAXIOVLEN 0x000a
721 #define MSG_PARTIAL 0x8000
722 #else /* USE_WS_PREFIX */
723 #define WS_SOMAXCONN 5
725 #define WS_MSG_OOB 0x0001
726 #define WS_MSG_PEEK 0x0002
727 #define WS_MSG_DONTROUTE 0x0004
728 #define WS_MSG_MAXIOVLEN 0x000a
729 #define WS_MSG_PARTIAL 0x8000
730 #endif /* USE_WS_PREFIX */
733 * Define constant based on rfc883, used by gethostbyxxxx() calls.
735 #ifndef USE_WS_PREFIX
736 #define MAXGETHOSTSTRUCT 1024
737 #else
738 #define MAXGETHOSTSTRUCT 1024
739 #endif
743 * Define flags to be used with the WSAAsyncSelect() call.
745 #define FD_READ 0x00000001
746 #define FD_WRITE 0x00000002
747 #define FD_OOB 0x00000004
748 #define FD_ACCEPT 0x00000008
749 #define FD_CONNECT 0x00000010
750 #define FD_CLOSE 0x00000020
752 /* internal per-socket flags */
753 #ifdef __WINESRC__
754 #define FD_WINE_LISTENING 0x10000000
755 #define FD_WINE_NONBLOCKING 0x20000000
756 #define FD_WINE_CONNECTED 0x40000000
757 #define FD_WINE_RAW 0x80000000
758 #define FD_WINE_INTERNAL 0xFFFF0000
759 #endif
762 * All Windows Sockets error constants are biased by WSABASEERR from
763 * the "normal"
765 #define WSABASEERR 10000
767 * Windows Sockets definitions of regular Microsoft C error constants
769 #define WSAEINTR (WSABASEERR+4)
770 #define WSAEBADF (WSABASEERR+9)
771 #define WSAEACCES (WSABASEERR+13)
772 #define WSAEFAULT (WSABASEERR+14)
773 #define WSAEINVAL (WSABASEERR+22)
774 #define WSAEMFILE (WSABASEERR+24)
777 * Windows Sockets definitions of regular Berkeley error constants
779 #define WSAEWOULDBLOCK (WSABASEERR+35)
780 #define WSAEINPROGRESS (WSABASEERR+36)
781 #define WSAEALREADY (WSABASEERR+37)
782 #define WSAENOTSOCK (WSABASEERR+38)
783 #define WSAEDESTADDRREQ (WSABASEERR+39)
784 #define WSAEMSGSIZE (WSABASEERR+40)
785 #define WSAEPROTOTYPE (WSABASEERR+41)
786 #define WSAENOPROTOOPT (WSABASEERR+42)
787 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
788 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
789 #define WSAEOPNOTSUPP (WSABASEERR+45)
790 #define WSAEPFNOSUPPORT (WSABASEERR+46)
791 #define WSAEAFNOSUPPORT (WSABASEERR+47)
792 #define WSAEADDRINUSE (WSABASEERR+48)
793 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
794 #define WSAENETDOWN (WSABASEERR+50)
795 #define WSAENETUNREACH (WSABASEERR+51)
796 #define WSAENETRESET (WSABASEERR+52)
797 #define WSAECONNABORTED (WSABASEERR+53)
798 #define WSAECONNRESET (WSABASEERR+54)
799 #define WSAENOBUFS (WSABASEERR+55)
800 #define WSAEISCONN (WSABASEERR+56)
801 #define WSAENOTCONN (WSABASEERR+57)
802 #define WSAESHUTDOWN (WSABASEERR+58)
803 #define WSAETOOMANYREFS (WSABASEERR+59)
804 #define WSAETIMEDOUT (WSABASEERR+60)
805 #define WSAECONNREFUSED (WSABASEERR+61)
806 #define WSAELOOP (WSABASEERR+62)
807 #define WSAENAMETOOLONG (WSABASEERR+63)
808 #define WSAEHOSTDOWN (WSABASEERR+64)
809 #define WSAEHOSTUNREACH (WSABASEERR+65)
810 #define WSAENOTEMPTY (WSABASEERR+66)
811 #define WSAEPROCLIM (WSABASEERR+67)
812 #define WSAEUSERS (WSABASEERR+68)
813 #define WSAEDQUOT (WSABASEERR+69)
814 #define WSAESTALE (WSABASEERR+70)
815 #define WSAEREMOTE (WSABASEERR+71)
816 #define WSAEDISCON (WSABASEERR+101)
819 * Extended Windows Sockets error constant definitions
821 #define WSASYSNOTREADY (WSABASEERR+91)
822 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
823 #define WSANOTINITIALISED (WSABASEERR+93)
824 #define WSAEDISCON (WSABASEERR+101)
825 #define WSAENOMORE (WSABASEERR+102)
826 #define WSAECANCELLED (WSABASEERR+103)
827 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
828 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
829 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
830 #define WSASYSCALLFAILURE (WSABASEERR+107)
831 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
832 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
833 #define WSA_E_NO_MORE (WSABASEERR+110)
834 #define WSA_E_CANCELLED (WSABASEERR+111)
835 #define WSAEREFUSED (WSABASEERR+112)
838 * Error return codes from gethostbyname() and gethostbyaddr()
839 * (when using the resolver). Note that these errors are
840 * retrieved via WSAGetLastError() and must therefore follow
841 * the rules for avoiding clashes with error numbers from
842 * specific implementations or language run-time systems.
843 * For this reason the codes are based at WSABASEERR+1001.
844 * Note also that [WSA]NO_ADDRESS is defined only for
845 * compatibility purposes.
848 #ifndef USE_WS_PREFIX
849 #define h_errno WSAGetLastError()
850 #else
851 #define WS_h_errno WSAGetLastError()
852 #endif
854 /* Authoritative Answer: Host not found */
855 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
857 /* Non-Authoritative: Host not found, or SERVERFAIL */
858 #define WSATRY_AGAIN (WSABASEERR+1002)
860 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
861 #define WSANO_RECOVERY (WSABASEERR+1003)
863 /* Valid name, no data record of requested type */
864 #define WSANO_DATA (WSABASEERR+1004)
866 /* no address, look for MX record */
867 #define WSANO_ADDRESS WSANO_DATA
869 #ifndef USE_WS_PREFIX
870 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
871 #define TRY_AGAIN WSATRY_AGAIN
872 #define NO_RECOVERY WSANO_RECOVERY
873 #define NO_DATA WSANO_DATA
874 #define NO_ADDRESS WSANO_ADDRESS
875 #endif /* USE_WS_PREFIX */
880 * Windows message parameter composition and decomposition
881 * macros.
885 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
886 * when constructing the response to a WSAAsyncGetXByY() routine.
888 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
890 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
891 * when constructing the response to WSAAsyncSelect().
893 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
895 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
896 * to extract the buffer length from the lParam in the response
897 * to a WSAGetXByY().
899 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
901 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
902 * to extract the error code from the lParam in the response
903 * to a WSAGetXByY().
905 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
907 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
908 * to extract the event code from the lParam in the response
909 * to a WSAAsyncSelect().
911 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
913 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
914 * to extract the error code from the lParam in the response
915 * to a WSAAsyncSelect().
917 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
922 * Prototypes
924 * Remember to keep this section in sync with the
925 * "Winsock Function Typedefs" section in winsock2.h.
927 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
928 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
929 HANDLE WINAPI WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
930 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
931 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
932 HANDLE WINAPI WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
933 HANDLE WINAPI WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
934 int WINAPI WSAAsyncSelect(SOCKET,HWND,u_int,long);
935 int WINAPI WSACancelAsyncRequest(HANDLE);
936 int WINAPI WSACancelBlockingCall(void);
937 int WINAPI WSACleanup(void);
938 int WINAPI WSAGetLastError(void);
939 BOOL WINAPI WSAIsBlocking(void);
940 FARPROC WINAPI WSASetBlockingHook(FARPROC);
941 void WINAPI WSASetLastError(int);
942 int WINAPI WSAStartup(WORD,LPWSADATA);
943 int WINAPI WSAUnhookBlockingHook(void);
945 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
946 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
947 int WINAPI WS(closesocket)(SOCKET);
948 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
949 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
950 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
951 /* gethostname not defined because of conflicts with unistd.h */
952 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
953 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
954 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
955 #ifdef WS_DEFINE_SELECT
956 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
957 #endif
958 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
959 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
960 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
961 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
962 unsigned long WINAPI WS(inet_addr)(const char*);
963 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
964 int WINAPI WS(ioctlsocket)(SOCKET,long,u_long*);
965 int WINAPI WS(listen)(SOCKET,int);
966 int WINAPI WS(recv)(SOCKET,char*,int,int);
967 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
968 int WINAPI WS(send)(SOCKET,const char*,int,int);
969 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
970 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
971 int WINAPI WS(shutdown)(SOCKET,int);
972 SOCKET WINAPI WS(socket)(int,int,int);
974 #if defined(__WINESRC__) || !defined(__WINE_WINSOCK2__)
975 /* Stuff specific to winsock.h */
977 #include "mswsock.h"
979 #endif /* __WINE_WINSOCK2__ */
980 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
983 #include "poppack.h"
985 #ifdef __cplusplus
987 #endif
989 #ifndef __WINE_WINSOCK2__
990 #undef WS
991 #undef WS_API_PROTOTYPES
992 #undef WS_API_TYPEDEFS
993 #endif
995 #endif /* _WINSOCKAPI_ */