Various combobox fixes.
[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 #ifdef __svr4__
15 #ifndef HAVE_SYS_SOCKET_H
16 #define HAVE_SYS_SOCKET_H
17 #endif /* HAVE_SYS_SOCKET_H */
18 #endif /* __svr4__ */
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            WS_FD_READ
268 #define FD_WRITE           WS_FD_WRITE
269 #define FD_OOB             WS_FD_OOB
270 #define FD_ACCEPT          WS_FD_ACCEPT
271 #define FD_CONNECT         WS_FD_CONNECT
272 #define FD_CLOSE           WS_FD_CLOSE
273 #define WS_FD_READ         0x0001
274 #define WS_FD_WRITE        0x0002
275 #define WS_FD_OOB          0x0004
276 #define WS_FD_ACCEPT       0x0008
277 #define WS_FD_CONNECT      0x0010
278 #define WS_FD_CLOSE        0x0020
279
280 #define WS_FD_LISTENING    0x10000000   /* internal per-socket flags */
281 #define WS_FD_NONBLOCKING  0x20000000
282 #define WS_FD_CONNECTED    0x40000000
283 #define WS_FD_RAW          0x80000000
284 #define WS_FD_SERVEVENT    0x01000000
285 #define WS_FD_INTERNAL     0xFFFF0000
286
287 /*
288  * All Windows Sockets error constants are biased by WSABASEERR from
289  * the "normal"
290  */
291 #define WSABASEERR              10000
292 /*
293  * Windows Sockets definitions of regular Microsoft C error constants
294  */
295 #define WSAEINTR                (WSABASEERR+4)
296 #define WSAEBADF                (WSABASEERR+9)
297 #define WSAEACCES               (WSABASEERR+13)
298 #define WSAEFAULT               (WSABASEERR+14)
299 #define WSAEINVAL               (WSABASEERR+22)
300 #define WSAEMFILE               (WSABASEERR+24)
301
302 /*
303  * Windows Sockets definitions of regular Berkeley error constants
304  */
305 #define WSAEWOULDBLOCK          (WSABASEERR+35)
306 #define WSAEINPROGRESS          (WSABASEERR+36)
307 #define WSAEALREADY             (WSABASEERR+37)
308 #define WSAENOTSOCK             (WSABASEERR+38)
309 #define WSAEDESTADDRREQ         (WSABASEERR+39)
310 #define WSAEMSGSIZE             (WSABASEERR+40)
311 #define WSAEPROTOTYPE           (WSABASEERR+41)
312 #define WSAENOPROTOOPT          (WSABASEERR+42)
313 #define WSAEPROTONOSUPPORT      (WSABASEERR+43)
314 #define WSAESOCKTNOSUPPORT      (WSABASEERR+44)
315 #define WSAEOPNOTSUPP           (WSABASEERR+45)
316 #define WSAEPFNOSUPPORT         (WSABASEERR+46)
317 #define WSAEAFNOSUPPORT         (WSABASEERR+47)
318 #define WSAEADDRINUSE           (WSABASEERR+48)
319 #define WSAEADDRNOTAVAIL        (WSABASEERR+49)
320 #define WSAENETDOWN             (WSABASEERR+50)
321 #define WSAENETUNREACH          (WSABASEERR+51)
322 #define WSAENETRESET            (WSABASEERR+52)
323 #define WSAECONNABORTED         (WSABASEERR+53)
324 #define WSAECONNRESET           (WSABASEERR+54)
325 #define WSAENOBUFS              (WSABASEERR+55)
326 #define WSAEISCONN              (WSABASEERR+56)
327 #define WSAENOTCONN             (WSABASEERR+57)
328 #define WSAESHUTDOWN            (WSABASEERR+58)
329 #define WSAETOOMANYREFS         (WSABASEERR+59)
330 #define WSAETIMEDOUT            (WSABASEERR+60)
331 #define WSAECONNREFUSED         (WSABASEERR+61)
332 #define WSAELOOP                (WSABASEERR+62)
333 #define WSAENAMETOOLONG         (WSABASEERR+63)
334 #define WSAEHOSTDOWN            (WSABASEERR+64)
335 #define WSAEHOSTUNREACH         (WSABASEERR+65)
336 #define WSAENOTEMPTY            (WSABASEERR+66)
337 #define WSAEPROCLIM             (WSABASEERR+67)
338 #define WSAEUSERS               (WSABASEERR+68)
339 #define WSAEDQUOT               (WSABASEERR+69)
340 #define WSAESTALE               (WSABASEERR+70)
341 #define WSAEREMOTE              (WSABASEERR+71)
342
343 /*
344  * Extended Windows Sockets error constant definitions
345  */
346 #define WSASYSNOTREADY          (WSABASEERR+91)
347 #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
348 #define WSANOTINITIALISED       (WSABASEERR+93)
349
350 /*
351  * Error return codes from gethostbyname() and gethostbyaddr()
352  * (when using the resolver). Note that these errors are
353  * retrieved via WSAGetLastError() and must therefore follow
354  * the rules for avoiding clashes with error numbers from
355  * specific implementations or language run-time systems.
356  * For this reason the codes are based at WSABASEERR+1001.
357  * Note also that [WSA]NO_ADDRESS is defined only for
358  * compatibility purposes.
359  */
360
361 /* #define h_errno         WSAGetLastError() */
362
363 /* Authoritative Answer: Host not found */
364 #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
365
366 /* Non-Authoritative: Host not found, or SERVERFAIL */
367 #define WSATRY_AGAIN            (WSABASEERR+1002)
368
369 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
370 #define WSANO_RECOVERY          (WSABASEERR+1003)
371
372 /* Valid name, no data record of requested type */
373 #define WSANO_DATA              (WSABASEERR+1004)
374
375 /* no address, look for MX record */
376 #define WSANO_ADDRESS           WSANO_DATA
377
378 /* Socket function prototypes */
379
380 #ifdef __cplusplus
381 extern "C" {
382 #endif
383
384 /* Microsoft Windows Extension function prototypes */
385
386 int     WINAPI closesocket(SOCKET s);
387
388 INT     WINAPI WSAStartup(UINT wVersionRequired, LPWSADATA lpWSAData);
389 void      WINAPI WSASetLastError(INT iError);
390 INT     WINAPI WSACleanup(void);
391 INT     WINAPI WSAGetLastError(void);
392 BOOL    WINAPI WSAIsBlocking(void);
393 INT     WINAPI WSACancelBlockingCall(void);
394 INT     WINAPI WSAUnhookBlockingHook(void);
395 FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc);
396 HANDLE  WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto,
397                                          LPSTR sbuf, INT buflen);
398 HANDLE  WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
399                                          LPCSTR proto, LPSTR sbuf, INT buflen);
400 HANDLE  WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg,
401                                           LPCSTR name, LPSTR sbuf, INT buflen);
402 HANDLE  WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg,
403                                             INT number, LPSTR sbuf, INT buflen);
404 HANDLE  WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg,
405                                          LPCSTR name, LPSTR sbuf, INT buflen);
406 HANDLE  WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
407                               INT len, INT type, LPSTR sbuf, INT buflen);
408 INT     WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
409 INT     WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent);
410 INT     WINAPI   WSARecvEx(SOCKET s, char *buf, INT len, INT *flags);
411
412 /*
413  * Address families
414  */
415 #define WS_AF_UNSPEC       0               /* unspecified */
416 #define WS_AF_UNIX         1               /* local to host (pipes, portals) */
417 #define WS_AF_INET         2               /* internetwork: UDP, TCP, etc. */
418 #define WS_AF_IMPLINK      3               /* arpanet imp addresses */
419 #define WS_AF_PUP          4               /* pup protocols: e.g. BSP */
420 #define WS_AF_CHAOS        5               /* mit CHAOS protocols */
421 #define WS_AF_NS           6               /* XEROX NS protocols */
422 #define WS_AF_IPX          WS_AF_NS        /* IPX protocols: IPX, SPX, etc. */
423 #define WS_AF_ISO          7               /* ISO protocols */
424 #define WS_AF_OSI          AF_ISO          /* OSI is ISO */
425 #define WS_AF_ECMA         8               /* european computer manufacturers */
426 #define WS_AF_DATAKIT      9               /* datakit protocols */
427 #define WS_AF_CCITT        10              /* CCITT protocols, X.25 etc */
428 #define WS_AF_SNA          11              /* IBM SNA */
429 #define WS_AF_DECnet       12              /* DECnet */
430 #define WS_AF_DLI          13              /* Direct data link interface */
431 #define WS_AF_LAT          14              /* LAT */
432 #define WS_AF_HYLINK       15              /* NSC Hyperchannel */
433 #define WS_AF_APPLETALK    16              /* AppleTalk */
434 #define WS_AF_NETBIOS      17              /* NetBios-style addresses */
435 #define WS_AF_VOICEVIEW    18              /* VoiceView */
436 #define WS_AF_FIREFOX      19              /* Protocols from Firefox */
437 #define WS_AF_UNKNOWN1     20              /* Somebody is using this! */
438 #define WS_AF_BAN          21              /* Banyan */
439 #define WS_AF_ATM          22              /* Native ATM Services */
440 #define WS_AF_INET6        23              /* Internetwork Version 6 */
441 #define WS_AF_CLUSTER      24              /* Microsoft Wolfpack */
442 #define WS_AF_12844        25              /* IEEE 1284.4 WG AF */
443 #define WS_AF_IRDA         26              /* IrDA */
444
445 #define WS_AF_MAX          27
446
447 #include "pshpack1.h"
448
449 struct ws_sockaddr_ipx
450 {
451         SHORT           sipx_family;
452         UINT            sipx_network;
453         CHAR            sipx_node[6];
454         WORD            sipx_port;
455 };
456
457 #include "poppack.h"
458
459 #ifdef __cplusplus
460 }
461 #endif
462
463 /* Microsoft Windows Extended data types */
464 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
465 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
466 typedef struct linger LINGER, *PLINGER, *LPLINGER;
467 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
468 typedef struct ws_fd_set32_struct FD_SET, *PFD_SET, *LPFD_SET;
469 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
470 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
471 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
472 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
473
474 /*
475  * Windows message parameter composition and decomposition
476  * macros.
477  *
478  * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
479  * when constructing the response to a WSAAsyncGetXByY() routine.
480  */
481 #define WSAMAKEASYNCREPLY(buflen,error)     MAKELONG(buflen,error)
482 /*
483  * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
484  * when constructing the response to WSAAsyncSelect().
485  */
486 #define WSAMAKESELECTREPLY(event,error)     MAKELONG(event,error)
487 /*
488  * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
489  * to extract the buffer length from the lParam in the response
490  * to a WSAGetXByY().
491  */
492 #define WSAGETASYNCBUFLEN(lParam)           LOWORD(lParam)
493 /*
494  * WSAGETASYNCERROR is intended for use by the Windows Sockets application
495  * to extract the error code from the lParam in the response
496  * to a WSAGetXByY().
497  */
498 #define WSAGETASYNCERROR(lParam)            HIWORD(lParam)
499 /*
500  * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
501  * to extract the event code from the lParam in the response
502  * to a WSAAsyncSelect().
503  */
504 #define WSAGETSELECTEVENT(lParam)           LOWORD(lParam)
505 /*
506  * WSAGETSELECTERROR is intended for use by the Windows Sockets application
507  * to extract the error code from the lParam in the response
508  * to a WSAAsyncSelect().
509  */
510 #define WSAGETSELECTERROR(lParam)           HIWORD(lParam)
511
512 #ifdef __cplusplus
513 } /* extern "C" */
514 #endif /* defined(__cplusplus) */
515
516 #endif  /* _WINSOCKAPI_ */
517