Make dinput a properly separated dll.
[wine] / include / winsock.h
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
7 #ifndef _WINSOCKAPI_
8 #define _WINSOCKAPI_
9
10 #ifndef RC_INVOKED
11 #include <sys/types.h>
12
13 #ifndef __WINE__
14 #if defined(__svr4__) || defined(__NetBSD__) || defined(__FreeBSD__)
15 #ifndef HAVE_SYS_SOCKET_H
16 #define HAVE_SYS_SOCKET_H
17 #endif /* HAVE_SYS_SOCKET_H */
18 #endif /* __svr4__ || __NetBSD__ || __FreeBSD__ */
19 #endif /* __WINE__ */
20
21 /* Solaris uses these macro names */
22 #undef FSHIFT
23 #undef TRANSPARENT
24 #include <netinet/in.h>
25 /* Restore the Windows values */
26 #ifdef _WINUSER_
27 #undef FSHIFT
28 #define FSHIFT            0x04
29 #endif
30 #ifdef _WINGDI_
31 #undef TRANSPARENT
32 #define TRANSPARENT       1
33 #endif
34
35 #ifdef  HAVE_ARPA_INET_H
36 #include <arpa/inet.h>
37 #endif  /* HAVE_ARPA_INET_H */
38 #include <sys/time.h>
39 #include <fcntl.h>
40 #ifdef  HAVE_NETDB_H
41 #include <netdb.h>
42 #endif  /* HAVE_NETDB_H */
43 #ifdef  HAVE_SYS_SOCKET_H
44 #include <sys/socket.h>
45 #endif  /* HAVE_SYS_SOCKET_H */
46 #include <sys/ioctl.h>
47 #endif /* RC_INVOKED */
48
49 #include "windef.h"
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif /* defined(__cplusplus) */
54
55 /* no "forced" alignment of ws_XXXXent here ! */
56         
57 typedef struct ws_hostent
58 {
59         char    *h_name;        /* official name of host */
60         char    **h_aliases;    /* alias list */
61         short   h_addrtype;     /* host address type */
62         short   h_length;       /* length of address */
63         char    **h_addr_list;  /* list of addresses from name server */
64 } _ws_hostent;
65
66 typedef struct ws_protoent
67 {
68         char    *p_name;        /* official protocol name */
69         char    **p_aliases;    /* alias list */
70         short   p_proto;        /* protocol # */
71 } _ws_protoent;
72
73 typedef struct ws_servent 
74 {
75         char    *s_name;        /* official service name */
76         char    **s_aliases;    /* alias list */
77         short   s_port;         /* port # */
78         char    *s_proto;       /* protocol to use */
79 } _ws_servent;
80
81 typedef struct ws_netent
82 {
83         char    *n_name;        /* official name of net */
84         char    **n_aliases;    /* alias list */
85         short   n_addrtype;     /* net address type */
86         u_long  n_net;          /* network # */
87 } _ws_netent;
88
89 #include "pshpack1.h"
90
91 typedef UINT            SOCKET;
92
93 typedef struct sockaddr         ws_sockaddr;
94
95 typedef struct ws_fd_set32_struct
96 {
97         UINT    fd_count;               /* how many are SET? */
98         SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
99 } ws_fd_set32;
100
101
102 /* ws_fd_set operations */
103
104 INT WINAPI __WSAFDIsSet( SOCKET, ws_fd_set32 * );
105
106 #define __WS_FD_CLR(fd, set, cast) do { \
107     UINT __i; \
108     for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
109     { \
110         if (((cast*)(set))->fd_array[__i] == fd) \
111         { \
112             while (__i < ((cast*)(set))->fd_count-1) \
113             { \
114                 ((cast*)(set))->fd_array[__i] = \
115                     ((cast*)(set))->fd_array[__i+1]; \
116                 __i++; \
117             } \
118             ((cast*)(set))->fd_count--; \
119             break; \
120         } \
121     } \
122 } while(0)
123 #define WS_FD_CLR(fd, set)      __WS_FD_CLR((fd),(set), ws_fd_set32)
124
125 #define __WS_FD_SET(fd, set, cast) do { \
126     if (((cast*)(set))->fd_count < FD_SETSIZE) \
127         ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
128 } while(0)
129 #define WS_FD_SET(fd, set)    __WS_FD_SET((fd),(set), ws_fd_set32)
130 #define WS_FD_ZERO(set) (((ws_fd_set32*)(set))->fd_count=0)
131 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (ws_fd_set32*)(set))
132
133 /* 
134  * Internet address (old style... should be updated) 
135  */
136
137 struct ws_in_addr
138 {
139         union {
140                 struct { BYTE   s_b1,s_b2,s_b3,s_b4; } S_un_b;
141                 struct { WORD   s_w1,s_w2; } S_un_w;
142                 UINT S_addr;
143         } S_un;
144 #define ws_addr  S_un.S_addr            /* can be used for most tcp & ip code */
145 #define ws_host  S_un.S_un_b.s_b2       /* host on imp */
146 #define ws_net   S_un.S_un_b.s_b1       /* network */
147 #define ws_imp   S_un.S_un_w.s_w2       /* imp */
148 #define ws_impno S_un.S_un_b.s_b4       /* imp # */
149 #define ws_lh    S_un.S_un_b.s_b3       /* logical host */
150 };
151
152 struct ws_sockaddr_in
153 {
154         SHORT           sin_family;
155         WORD            sin_port;
156         struct ws_in_addr sin_addr;
157         BYTE            sin_zero[8];
158 };
159
160 #define WSADESCRIPTION_LEN      256
161 #define WSASYS_STATUS_LEN       128
162
163 typedef struct WSAData {
164         WORD                    wVersion;
165         WORD                    wHighVersion;
166         char                    szDescription[WSADESCRIPTION_LEN+1];
167         char                    szSystemStatus[WSASYS_STATUS_LEN+1];
168         WORD                    iMaxSockets;
169         WORD                    iMaxUdpDg;
170         char                   *lpVendorInfo;
171 } WSADATA, *LPWSADATA;
172
173 #include "poppack.h"
174
175 /*
176  * This is used instead of -1, since the
177  * SOCKET type is unsigned.
178  */
179 #define INVALID_SOCKET     (~0)
180 #define SOCKET_ERROR               (-1)
181
182
183 /*
184  * Types
185  */
186 #define WS_SOCK_STREAM     1               /* stream socket */
187 #define WS_SOCK_DGRAM      2               /* datagram socket */
188 #define WS_SOCK_RAW        3               /* raw-protocol interface */
189 #define WS_SOCK_RDM        4               /* reliably-delivered message */
190 #define WS_SOCK_SEQPACKET  5               /* sequenced packet stream */
191
192 #define WS_SOL_SOCKET           0xffff
193 #define WS_IPPROTO_TCP          6
194
195 /*
196  * Option flags per-socket.
197  */
198 #define WS_SO_DEBUG        0x0001          /* turn on debugging info recording */
199 #define WS_SO_ACCEPTCONN   0x0002          /* socket has had listen() */
200 #define WS_SO_REUSEADDR    0x0004          /* allow local address reuse */
201 #define WS_SO_KEEPALIVE    0x0008          /* keep connections alive */
202 #define WS_SO_DONTROUTE    0x0010          /* just use interface addresses */
203 #define WS_SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
204 #define WS_SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
205 #define WS_SO_LINGER       0x0080          /* linger on close if data present */
206 #define WS_SO_OOBINLINE    0x0100          /* leave received OOB data in line */
207
208 #define WS_SO_DONTLINGER   (UINT)(~WS_SO_LINGER)
209
210 /*
211  * Additional options.
212  */
213 #define WS_SO_SNDBUF       0x1001          /* send buffer size */
214 #define WS_SO_RCVBUF       0x1002          /* receive buffer size */
215 #define WS_SO_SNDLOWAT     0x1003          /* send low-water mark */
216 #define WS_SO_RCVLOWAT     0x1004          /* receive low-water mark */
217 #define WS_SO_SNDTIMEO     0x1005          /* send timeout */
218 #define WS_SO_RCVTIMEO     0x1006          /* receive timeout */
219 #define WS_SO_ERROR        0x1007          /* get error status and clear */
220 #define WS_SO_TYPE         0x1008          /* get socket type */
221
222 #define WS_IOCPARM_MASK    0x7f            /* parameters must be < 128 bytes */
223 #define WS_IOC_VOID        0x20000000      /* no parameters */
224 #define WS_IOC_OUT         0x40000000      /* copy out parameters */
225 #define WS_IOC_IN          0x80000000      /* copy in parameters */
226 #define WS_IOC_INOUT       (WS_IOC_IN|WS_IOC_OUT)
227 #define WS_IOR(x,y,t)      (WS_IOC_OUT|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
228 #define WS_IOW(x,y,t)      (WS_IOC_IN|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
229
230 /* IPPROTO_TCP options */
231 #define WS_TCP_NODELAY  1               /* do not apply nagle algorithm */
232
233 /*
234  * Socket I/O flags (supported by spec 1.1)
235  */
236
237 #define WS_FIONREAD    WS_IOR('f', 127, u_long)
238 #define WS_FIONBIO     WS_IOW('f', 126, u_long)
239
240 #define WS_SIOCATMARK  WS_IOR('s',  7, u_long)
241
242 /*
243  * Maximum queue length specifiable by listen.
244  */
245 #ifdef SOMAXCONN
246 #undef SOMAXCONN
247 #endif
248 #define SOMAXCONN       5
249
250 #ifndef MSG_DONTROUTE
251 #define MSG_DONTROUTE   0x4             /* send without using routing tables */
252 #endif
253 #define MSG_MAXIOVLEN   16
254
255 #ifndef MSG_PARTIAL
256 #define MSG_PARTIAL     0x8000 /* partial send or recv (WSARecvEx) */
257 #endif
258
259 /*
260  * Define constant based on rfc883, used by gethostbyxxxx() calls.
261  */
262 #define MAXGETHOSTSTRUCT        1024
263
264 /*
265  * Define flags to be used with the WSAAsyncSelect() call.
266  */
267 #define FD_READ                    0x00000001
268 #define FD_WRITE                   0x00000002
269 #define FD_OOB                     0x00000004
270 #define FD_ACCEPT                  0x00000008
271 #define FD_CONNECT                 0x00000010
272 #define FD_CLOSE                   0x00000020
273
274 /* internal per-socket flags */
275 #ifdef __WINE__
276 #define FD_WINE_LISTENING          0x10000000
277 #define FD_WINE_NONBLOCKING        0x20000000
278 #define FD_WINE_CONNECTED          0x40000000
279 #define FD_WINE_RAW                0x80000000
280 #define FD_WINE_SERVEVENT          0x01000000
281 #define FD_WINE_INTERNAL           0xFFFF0000
282 #endif
283
284 /*
285  * All Windows Sockets error constants are biased by WSABASEERR from
286  * the "normal"
287  */
288 #define WSABASEERR              10000
289 /*
290  * Windows Sockets definitions of regular Microsoft C error constants
291  */
292 #define WSAEINTR                (WSABASEERR+4)
293 #define WSAEBADF                (WSABASEERR+9)
294 #define WSAEACCES               (WSABASEERR+13)
295 #define WSAEFAULT               (WSABASEERR+14)
296 #define WSAEINVAL               (WSABASEERR+22)
297 #define WSAEMFILE               (WSABASEERR+24)
298
299 /*
300  * Windows Sockets definitions of regular Berkeley error constants
301  */
302 #define WSAEWOULDBLOCK          (WSABASEERR+35)
303 #define WSAEINPROGRESS          (WSABASEERR+36)
304 #define WSAEALREADY             (WSABASEERR+37)
305 #define WSAENOTSOCK             (WSABASEERR+38)
306 #define WSAEDESTADDRREQ         (WSABASEERR+39)
307 #define WSAEMSGSIZE             (WSABASEERR+40)
308 #define WSAEPROTOTYPE           (WSABASEERR+41)
309 #define WSAENOPROTOOPT          (WSABASEERR+42)
310 #define WSAEPROTONOSUPPORT      (WSABASEERR+43)
311 #define WSAESOCKTNOSUPPORT      (WSABASEERR+44)
312 #define WSAEOPNOTSUPP           (WSABASEERR+45)
313 #define WSAEPFNOSUPPORT         (WSABASEERR+46)
314 #define WSAEAFNOSUPPORT         (WSABASEERR+47)
315 #define WSAEADDRINUSE           (WSABASEERR+48)
316 #define WSAEADDRNOTAVAIL        (WSABASEERR+49)
317 #define WSAENETDOWN             (WSABASEERR+50)
318 #define WSAENETUNREACH          (WSABASEERR+51)
319 #define WSAENETRESET            (WSABASEERR+52)
320 #define WSAECONNABORTED         (WSABASEERR+53)
321 #define WSAECONNRESET           (WSABASEERR+54)
322 #define WSAENOBUFS              (WSABASEERR+55)
323 #define WSAEISCONN              (WSABASEERR+56)
324 #define WSAENOTCONN             (WSABASEERR+57)
325 #define WSAESHUTDOWN            (WSABASEERR+58)
326 #define WSAETOOMANYREFS         (WSABASEERR+59)
327 #define WSAETIMEDOUT            (WSABASEERR+60)
328 #define WSAECONNREFUSED         (WSABASEERR+61)
329 #define WSAELOOP                (WSABASEERR+62)
330 #define WSAENAMETOOLONG         (WSABASEERR+63)
331 #define WSAEHOSTDOWN            (WSABASEERR+64)
332 #define WSAEHOSTUNREACH         (WSABASEERR+65)
333 #define WSAENOTEMPTY            (WSABASEERR+66)
334 #define WSAEPROCLIM             (WSABASEERR+67)
335 #define WSAEUSERS               (WSABASEERR+68)
336 #define WSAEDQUOT               (WSABASEERR+69)
337 #define WSAESTALE               (WSABASEERR+70)
338 #define WSAEREMOTE              (WSABASEERR+71)
339
340 /*
341  * Extended Windows Sockets error constant definitions
342  */
343 #define WSASYSNOTREADY          (WSABASEERR+91)
344 #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
345 #define WSANOTINITIALISED       (WSABASEERR+93)
346
347 /*
348  * Error return codes from gethostbyname() and gethostbyaddr()
349  * (when using the resolver). Note that these errors are
350  * retrieved via WSAGetLastError() and must therefore follow
351  * the rules for avoiding clashes with error numbers from
352  * specific implementations or language run-time systems.
353  * For this reason the codes are based at WSABASEERR+1001.
354  * Note also that [WSA]NO_ADDRESS is defined only for
355  * compatibility purposes.
356  */
357
358 /* #define h_errno         WSAGetLastError() */
359
360 /* Authoritative Answer: Host not found */
361 #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
362
363 /* Non-Authoritative: Host not found, or SERVERFAIL */
364 #define WSATRY_AGAIN            (WSABASEERR+1002)
365
366 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
367 #define WSANO_RECOVERY          (WSABASEERR+1003)
368
369 /* Valid name, no data record of requested type */
370 #define WSANO_DATA              (WSABASEERR+1004)
371
372 /* no address, look for MX record */
373 #define WSANO_ADDRESS           WSANO_DATA
374
375 /* Socket function prototypes */
376
377 #ifdef __cplusplus
378 extern "C" {
379 #endif
380
381 /* Microsoft Windows Extension function prototypes */
382
383 int     WINAPI closesocket(SOCKET s);
384
385 int     WINAPI WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
386 void    WINAPI WSASetLastError(INT iError);
387 INT     WINAPI WSACleanup(void);
388 INT     WINAPI WSAGetLastError(void);
389 BOOL    WINAPI WSAIsBlocking(void);
390 INT     WINAPI WSACancelBlockingCall(void);
391 INT     WINAPI WSAUnhookBlockingHook(void);
392 FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc);
393 HANDLE  WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto,
394                                          LPSTR sbuf, INT buflen);
395 HANDLE  WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
396                                          LPCSTR proto, LPSTR sbuf, INT buflen);
397 HANDLE  WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg,
398                                           LPCSTR name, LPSTR sbuf, INT buflen);
399 HANDLE  WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg,
400                                             INT number, LPSTR sbuf, INT buflen);
401 HANDLE  WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg,
402                                          LPCSTR name, LPSTR sbuf, INT buflen);
403 HANDLE  WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
404                               INT len, INT type, LPSTR sbuf, INT buflen);
405 INT     WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
406 INT     WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent);
407 INT     WINAPI   WSARecvEx(SOCKET s, char *buf, INT len, INT *flags);
408
409 /*
410  * Address families
411  */
412 #define WS_AF_UNSPEC       0               /* unspecified */
413 #define WS_AF_UNIX         1               /* local to host (pipes, portals) */
414 #define WS_AF_INET         2               /* internetwork: UDP, TCP, etc. */
415 #define WS_AF_IMPLINK      3               /* arpanet imp addresses */
416 #define WS_AF_PUP          4               /* pup protocols: e.g. BSP */
417 #define WS_AF_CHAOS        5               /* mit CHAOS protocols */
418 #define WS_AF_NS           6               /* XEROX NS protocols */
419 #define WS_AF_IPX          WS_AF_NS        /* IPX protocols: IPX, SPX, etc. */
420 #define WS_AF_ISO          7               /* ISO protocols */
421 #define WS_AF_OSI          AF_ISO          /* OSI is ISO */
422 #define WS_AF_ECMA         8               /* european computer manufacturers */
423 #define WS_AF_DATAKIT      9               /* datakit protocols */
424 #define WS_AF_CCITT        10              /* CCITT protocols, X.25 etc */
425 #define WS_AF_SNA          11              /* IBM SNA */
426 #define WS_AF_DECnet       12              /* DECnet */
427 #define WS_AF_DLI          13              /* Direct data link interface */
428 #define WS_AF_LAT          14              /* LAT */
429 #define WS_AF_HYLINK       15              /* NSC Hyperchannel */
430 #define WS_AF_APPLETALK    16              /* AppleTalk */
431 #define WS_AF_NETBIOS      17              /* NetBios-style addresses */
432 #define WS_AF_VOICEVIEW    18              /* VoiceView */
433 #define WS_AF_FIREFOX      19              /* Protocols from Firefox */
434 #define WS_AF_UNKNOWN1     20              /* Somebody is using this! */
435 #define WS_AF_BAN          21              /* Banyan */
436 #define WS_AF_ATM          22              /* Native ATM Services */
437 #define WS_AF_INET6        23              /* Internetwork Version 6 */
438 #define WS_AF_CLUSTER      24              /* Microsoft Wolfpack */
439 #define WS_AF_12844        25              /* IEEE 1284.4 WG AF */
440 #define WS_AF_IRDA         26              /* IrDA */
441
442 #define WS_AF_MAX          27
443
444
445 #ifdef __cplusplus
446 }
447 #endif
448
449 /* Microsoft Windows Extended data types */
450 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
451 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
452 typedef struct linger LINGER, *PLINGER, *LPLINGER;
453 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
454 typedef struct ws_fd_set32_struct FD_SET, *PFD_SET, *LPFD_SET;
455 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
456 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
457 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
458 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
459
460 /*
461  * Windows message parameter composition and decomposition
462  * macros.
463  *
464  * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
465  * when constructing the response to a WSAAsyncGetXByY() routine.
466  */
467 #define WSAMAKEASYNCREPLY(buflen,error)     MAKELONG(buflen,error)
468 /*
469  * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
470  * when constructing the response to WSAAsyncSelect().
471  */
472 #define WSAMAKESELECTREPLY(event,error)     MAKELONG(event,error)
473 /*
474  * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
475  * to extract the buffer length from the lParam in the response
476  * to a WSAGetXByY().
477  */
478 #define WSAGETASYNCBUFLEN(lParam)           LOWORD(lParam)
479 /*
480  * WSAGETASYNCERROR is intended for use by the Windows Sockets application
481  * to extract the error code from the lParam in the response
482  * to a WSAGetXByY().
483  */
484 #define WSAGETASYNCERROR(lParam)            HIWORD(lParam)
485 /*
486  * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
487  * to extract the event code from the lParam in the response
488  * to a WSAAsyncSelect().
489  */
490 #define WSAGETSELECTEVENT(lParam)           LOWORD(lParam)
491 /*
492  * WSAGETSELECTERROR is intended for use by the Windows Sockets application
493  * to extract the error code from the lParam in the response
494  * to a WSAAsyncSelect().
495  */
496 #define WSAGETSELECTERROR(lParam)           HIWORD(lParam)
497
498 #ifdef __cplusplus
499 } /* extern "C" */
500 #endif /* defined(__cplusplus) */
501
502 #endif  /* _WINSOCKAPI_ */
503