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