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