Added include protection for unistd.h and sys/time.h.
[wine/multimedia.git] / dlls / winsock / async.c
blob15239cabc0687c230f0c620cb725e4b338b79a9f
1 /* Async WINSOCK DNS services
3 * Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
4 * Copyright (C) 1999 Marcus Meissner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * NOTE: If you make any changes to fix a particular app, make sure
21 * they don't break something else like Netscape or telnet and ftp
22 * clients and servers (www.winsite.com got a lot of those).
24 * FIXME:
25 * - Add WSACancel* and correct handle management. (works rather well for
26 * now without it.)
27 * - Verify & Check all calls for correctness
28 * (currently only WSAGetHostByName*, WSAGetServByPort* calls)
29 * - Check error returns.
30 * - mirc/mirc32 Finger @linux.kernel.org sometimes fails in threaded mode.
31 * (not sure why)
32 * - This implementation did ignore the "NOTE:" section above (since the
33 * whole stuff did not work anyway to other changes).
36 #include "config.h"
37 #include "wine/port.h"
39 #include <string.h>
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_IPC_H
42 # include <sys/ipc.h>
43 #endif
44 #ifdef HAVE_SYS_IOCTL_H
45 # include <sys/ioctl.h>
46 #endif
47 #ifdef HAVE_SYS_FILIO_H
48 # include <sys/filio.h>
49 #endif
50 #if defined(__svr4__)
51 #include <sys/ioccom.h>
52 #ifdef HAVE_SYS_SOCKIO_H
53 # include <sys/sockio.h>
54 #endif
55 #endif
57 #if defined(__EMX__)
58 # include <sys/so_ioctl.h>
59 #endif
61 #ifdef HAVE_SYS_PARAM_H
62 # include <sys/param.h>
63 #endif
65 #ifdef HAVE_SYS_MSG_H
66 # include <sys/msg.h>
67 #endif
68 #ifdef HAVE_SYS_WAIT_H
69 #include <sys/wait.h>
70 #endif
71 #ifdef HAVE_SYS_SOCKET_H
72 #include <sys/socket.h>
73 #endif
74 #ifdef HAVE_NETINET_IN_H
75 # include <netinet/in.h>
76 #endif
77 #ifdef HAVE_ARPA_INET_H
78 # include <arpa/inet.h>
79 #endif
80 #include <ctype.h>
81 #include <fcntl.h>
82 #include <errno.h>
83 #ifdef HAVE_SYS_ERRNO_H
84 #include <sys/errno.h>
85 #endif
86 #ifdef HAVE_NETDB_H
87 #include <netdb.h>
88 #endif
89 #ifdef HAVE_UNISTD_H
90 # include <unistd.h>
91 #endif
92 #include <stdlib.h>
93 #ifdef HAVE_ARPA_NAMESER_H
94 # include <arpa/nameser.h>
95 #endif
96 #ifdef HAVE_RESOLV_H
97 # include <resolv.h>
98 #endif
100 #include "wine/winbase16.h"
101 #include "wingdi.h"
102 #include "winuser.h"
103 #include "winsock2.h"
104 #include "ws2spi.h"
105 #include "wine/winsock16.h"
106 #include "winnt.h"
108 #include "wine/debug.h"
110 WINE_DEFAULT_DEBUG_CHANNEL(winsock);
113 /* critical section to protect some non-rentrant net function */
114 CRITICAL_SECTION csWSgetXXXbyYYY = CRITICAL_SECTION_INIT("csWSgetXXXbyYYY");
116 /* protoptypes of some functions in socket.c
118 UINT16 wsaErrno(void);
119 UINT16 wsaHerrno(int errnr);
121 #define AQ_WIN16 0x00
122 #define AQ_WIN32 0x04
123 #define HB_WIN32(hb) (hb->flags & AQ_WIN32)
124 #define AQ_NUMBER 0x00
125 #define AQ_NAME 0x08
126 #define AQ_COPYPTR1 0x10
127 #define AQ_DUPLOWPTR1 0x20
128 #define AQ_MASKPTR1 0x30
129 #define AQ_COPYPTR2 0x40
130 #define AQ_DUPLOWPTR2 0x80
131 #define AQ_MASKPTR2 0xC0
133 #define AQ_GETHOST 0
134 #define AQ_GETPROTO 1
135 #define AQ_GETSERV 2
136 #define AQ_GETMASK 3
138 /* ----------------------------------- helper functions - */
140 static int list_size(char** l, int item_size)
142 int i,j = 0;
143 if(l)
144 { for(i=0;l[i];i++)
145 j += (item_size) ? item_size : strlen(l[i]) + 1;
146 j += (i + 1) * sizeof(char*); }
147 return j;
150 static int list_dup(char** l_src, char* ref, char* base, int item_size)
152 /* base is either either equal to ref or 0 or SEGPTR */
154 char* p = ref;
155 char** l_to = (char**)ref;
156 int i,j,k;
158 for(j=0;l_src[j];j++) ;
159 p += (j + 1) * sizeof(char*);
160 for(i=0;i<j;i++)
161 { l_to[i] = base + (p - ref);
162 k = ( item_size ) ? item_size : strlen(l_src[i]) + 1;
163 memcpy(p, l_src[i], k); p += k; }
164 l_to[i] = NULL;
165 return (p - ref);
168 /* ----- hostent */
170 static int hostent_size(struct hostent* p_he)
172 int size = 0;
173 if( p_he )
174 { size = sizeof(struct hostent);
175 size += strlen(p_he->h_name) + 1;
176 size += list_size(p_he->h_aliases, 0);
177 size += list_size(p_he->h_addr_list, p_he->h_length ); }
178 return size;
181 /* Copy hostent to p_to, fix up inside pointers using p_base (different for
182 * Win16 (linear vs. segmented). Return -neededsize on overrun.
184 static int WS_copy_he(char *p_to,char *p_base,int t_size,struct hostent* p_he, int flag)
186 char* p_name,*p_aliases,*p_addr,*p;
187 struct ws_hostent16 *p_to16 = (struct ws_hostent16*)p_to;
188 struct WS_hostent *p_to32 = (struct WS_hostent*)p_to;
189 int size = hostent_size(p_he) +
191 (flag & AQ_WIN16) ? sizeof(struct ws_hostent16) : sizeof(struct WS_hostent)
192 - sizeof(struct hostent)
195 if (t_size < size)
196 return -size;
197 p = p_to;
198 p += (flag & AQ_WIN16) ?
199 sizeof(struct ws_hostent16) : sizeof(struct WS_hostent);
200 p_name = p;
201 strcpy(p, p_he->h_name); p += strlen(p) + 1;
202 p_aliases = p;
203 p += list_dup(p_he->h_aliases, p, p_base + (p - (char*)p_to), 0);
204 p_addr = p;
205 list_dup(p_he->h_addr_list, p, p_base + (p - (char*)p_to), p_he->h_length);
207 if (flag & AQ_WIN16)
209 p_to16->h_addrtype = (INT16)p_he->h_addrtype;
210 p_to16->h_length = (INT16)p_he->h_length;
211 p_to16->h_name = (SEGPTR)(p_base + (p_name - p_to));
212 p_to16->h_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
213 p_to16->h_addr_list = (SEGPTR)(p_base + (p_addr - p_to));
215 else
217 p_to32->h_addrtype = p_he->h_addrtype;
218 p_to32->h_length = p_he->h_length;
219 p_to32->h_name = (p_base + (p_name - p_to));
220 p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to));
221 p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to));
224 return size;
227 /* ----- protoent */
229 static int protoent_size(struct protoent* p_pe)
231 int size = 0;
232 if( p_pe )
233 { size = sizeof(struct protoent);
234 size += strlen(p_pe->p_name) + 1;
235 size += list_size(p_pe->p_aliases, 0); }
236 return size;
239 /* Copy protoent to p_to, fix up inside pointers using p_base (different for
240 * Win16 (linear vs. segmented). Return -neededsize on overrun.
242 static int WS_copy_pe(char *p_to,char *p_base,int t_size,struct protoent* p_pe, int flag)
244 char* p_name,*p_aliases,*p;
245 struct ws_protoent16 *p_to16 = (struct ws_protoent16*)p_to;
246 struct WS_protoent *p_to32 = (struct WS_protoent*)p_to;
247 int size = protoent_size(p_pe) +
249 (flag & AQ_WIN16) ? sizeof(struct ws_protoent16) : sizeof(struct WS_protoent)
250 - sizeof(struct protoent)
253 if (t_size < size)
254 return -size;
255 p = p_to;
256 p += (flag & AQ_WIN16) ?
257 sizeof(struct ws_protoent16) : sizeof(struct WS_protoent);
258 p_name = p;
259 strcpy(p, p_pe->p_name); p += strlen(p) + 1;
260 p_aliases = p;
261 list_dup(p_pe->p_aliases, p, p_base + (p - (char*)p_to), 0);
263 if (flag & AQ_WIN16)
265 p_to16->p_proto = (INT16)p_pe->p_proto;
266 p_to16->p_name = (SEGPTR)(p_base) + (p_name - p_to);
267 p_to16->p_aliases = (SEGPTR)((p_base) + (p_aliases - p_to));
269 else
271 p_to32->p_proto = p_pe->p_proto;
272 p_to32->p_name = (p_base) + (p_name - p_to);
273 p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to));
276 return size;
279 /* ----- servent */
281 static int servent_size(struct servent* p_se)
283 int size = 0;
284 if( p_se ) {
285 size += sizeof(struct servent);
286 size += strlen(p_se->s_proto) + strlen(p_se->s_name) + 2;
287 size += list_size(p_se->s_aliases, 0);
289 return size;
292 /* Copy servent to p_to, fix up inside pointers using p_base (different for
293 * Win16 (linear vs. segmented). Return -neededsize on overrun.
294 * Take care of different Win16/Win32 servent structs (packing !)
296 static int WS_copy_se(char *p_to,char *p_base,int t_size,struct servent* p_se, int flag)
298 char* p_name,*p_aliases,*p_proto,*p;
299 struct ws_servent16 *p_to16 = (struct ws_servent16*)p_to;
300 struct WS_servent *p_to32 = (struct WS_servent*)p_to;
301 int size = servent_size(p_se) +
303 (flag & AQ_WIN16) ? sizeof(struct ws_servent16) : sizeof(struct WS_servent)
304 - sizeof(struct servent)
307 if (t_size < size)
308 return -size;
309 p = p_to;
310 p += (flag & AQ_WIN16) ?
311 sizeof(struct ws_servent16) : sizeof(struct WS_servent);
312 p_name = p;
313 strcpy(p, p_se->s_name); p += strlen(p) + 1;
314 p_proto = p;
315 strcpy(p, p_se->s_proto); p += strlen(p) + 1;
316 p_aliases = p;
317 list_dup(p_se->s_aliases, p, p_base + (p - p_to), 0);
319 if (flag & AQ_WIN16)
321 p_to16->s_port = (INT16)p_se->s_port;
322 p_to16->s_name = (SEGPTR)(p_base + (p_name - p_to));
323 p_to16->s_proto = (SEGPTR)(p_base + (p_proto - p_to));
324 p_to16->s_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
326 else
328 p_to32->s_port = p_se->s_port;
329 p_to32->s_name = (p_base + (p_name - p_to));
330 p_to32->s_proto = (p_base + (p_proto - p_to));
331 p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to));
334 return size;
337 static HANDLE __ws_async_handle = 0xdead;
339 /* Generic async query struct. we use symbolic names for the different queries
340 * for readability.
342 typedef struct _async_query {
343 HWND16 hWnd;
344 UINT16 uMsg;
345 LPCSTR ptr1;
346 #define host_name ptr1
347 #define host_addr ptr1
348 #define serv_name ptr1
349 #define proto_name ptr1
350 LPCSTR ptr2;
351 #define serv_proto ptr2
352 int int1;
353 #define host_len int1
354 #define proto_number int1
355 #define serv_port int1
356 int int2;
357 #define host_type int2
358 SEGPTR sbuf;
359 INT16 sbuflen;
361 HANDLE16 async_handle;
362 int flags;
363 int qt;
364 char xbuf[1];
365 } async_query;
368 /****************************************************************************
369 * The async query function.
371 * It is either called as a thread startup routine or directly. It has
372 * to free the passed arg from the process heap and PostMessageA the async
373 * result or the error code.
375 * FIXME:
376 * - errorhandling not verified.
378 static DWORD WINAPI _async_queryfun(LPVOID arg) {
379 async_query *aq = (async_query*)arg;
380 int size = 0;
381 WORD fail = 0;
382 char *targetptr = (HB_WIN32(aq)?(char*)aq->sbuf:(char*)MapSL(aq->sbuf));
384 switch (aq->flags & AQ_GETMASK) {
385 case AQ_GETHOST: {
386 struct hostent *he;
387 char *copy_hostent = targetptr;
388 #if HAVE_LINUX_GETHOSTBYNAME_R_6
389 char *extrabuf;
390 int ebufsize=1024;
391 struct hostent hostentry;
392 int locerr = ENOBUFS;
393 he = NULL;
394 extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
395 while(extrabuf) {
396 int res = (aq->flags & AQ_NAME) ?
397 gethostbyname_r(aq->host_name,
398 &hostentry, extrabuf, ebufsize, &he, &locerr):
399 gethostbyaddr_r(aq->host_addr,aq->host_len,aq->host_type,
400 &hostentry, extrabuf, ebufsize, &he, &locerr);
401 if( res != ERANGE) break;
402 ebufsize *=2;
403 extrabuf=HeapReAlloc(GetProcessHeap(),0,extrabuf,ebufsize) ;
405 if (!he) fail = ((locerr < 0) ? wsaErrno() : wsaHerrno(locerr));
406 #else
407 EnterCriticalSection( &csWSgetXXXbyYYY );
408 he = (aq->flags & AQ_NAME) ?
409 gethostbyname(aq->host_name):
410 gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type);
411 if (!he) fail = ((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
412 #endif
413 if (he) {
414 size = WS_copy_he(copy_hostent,(char*)aq->sbuf,aq->sbuflen,he,aq->flags);
415 if (size < 0) {
416 fail = WSAENOBUFS;
417 size = -size;
420 #if HAVE_LINUX_GETHOSTBYNAME_R_6
421 HeapFree(GetProcessHeap(),0,extrabuf);
422 #else
423 LeaveCriticalSection( &csWSgetXXXbyYYY );
424 #endif
426 break;
427 case AQ_GETPROTO: {
428 #if defined(HAVE_GETPROTOBYNAME) && defined(HAVE_GETPROTOBYNUMBER)
429 struct protoent *pe;
430 char *copy_protoent = targetptr;
431 EnterCriticalSection( &csWSgetXXXbyYYY );
432 pe = (aq->flags & AQ_NAME)?
433 getprotobyname(aq->proto_name) :
434 getprotobynumber(aq->proto_number);
435 if (pe) {
436 size = WS_copy_pe(copy_protoent,(char*)aq->sbuf,aq->sbuflen,pe,aq->flags);
437 if (size < 0) {
438 fail = WSAENOBUFS;
439 size = -size;
441 } else {
442 if (aq->flags & AQ_NAME)
443 MESSAGE("protocol %s not found; You might want to add "
444 "this to /etc/protocols\n", debugstr_a(aq->proto_name) );
445 else
446 MESSAGE("protocol number %d not found; You might want to add "
447 "this to /etc/protocols\n", aq->proto_number );
448 fail = WSANO_DATA;
450 LeaveCriticalSection( &csWSgetXXXbyYYY );
451 #else
452 fail = WSANO_DATA;
453 #endif
455 break;
456 case AQ_GETSERV: {
457 struct servent *se;
458 char *copy_servent = targetptr;
459 EnterCriticalSection( &csWSgetXXXbyYYY );
460 se = (aq->flags & AQ_NAME)?
461 getservbyname(aq->serv_name,aq->serv_proto) :
462 #ifdef HAVE_GETSERVBYPORT
463 getservbyport(aq->serv_port,aq->serv_proto);
464 #else
465 NULL;
466 #endif
467 if (se) {
468 size = WS_copy_se(copy_servent,(char*)aq->sbuf,aq->sbuflen,se,aq->flags);
469 if (size < 0) {
470 fail = WSAENOBUFS;
471 size = -size;
473 } else {
474 if (aq->flags & AQ_NAME)
475 MESSAGE("service %s protocol %s not found; You might want to add "
476 "this to /etc/services\n", debugstr_a(aq->serv_name) ,
477 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
478 else
479 MESSAGE("service on port %d protocol %s not found; You might want to add "
480 "this to /etc/services\n", aq->serv_port,
481 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
482 fail = WSANO_DATA;
484 LeaveCriticalSection( &csWSgetXXXbyYYY );
486 break;
488 PostMessageA(aq->hWnd,aq->uMsg,aq->async_handle,size|(fail<<16));
489 HeapFree(GetProcessHeap(),0,arg);
490 return 0;
493 /****************************************************************************
494 * The main async help function.
496 * It either starts a thread or just calls the function directly for platforms
497 * with no thread support. This relies on the fact that PostMessage() does
498 * not actually call the windowproc before the function returns.
500 static HANDLE16 __WSAsyncDBQuery(
501 HWND hWnd, UINT uMsg,INT int1,LPCSTR ptr1, INT int2, LPCSTR ptr2,
502 void *sbuf, INT sbuflen, UINT flags
505 async_query* aq;
506 char* pto;
507 LPCSTR pfm;
508 int xbuflen = 0;
510 /* allocate buffer to copy protocol- and service name to */
511 /* note: this is done in the calling thread so we can return */
512 /* a decent error code if the Alloc fails */
514 switch (flags & AQ_MASKPTR1) {
515 case 0: break;
516 case AQ_COPYPTR1: xbuflen += int1; break;
517 case AQ_DUPLOWPTR1: xbuflen += strlen(ptr1) + 1; break;
520 switch (flags & AQ_MASKPTR2) {
521 case 0: break;
522 case AQ_COPYPTR2: xbuflen += int2; break;
523 case AQ_DUPLOWPTR2: xbuflen += strlen(ptr2) + 1; break;
526 if(!(aq = HeapAlloc(GetProcessHeap(),0,sizeof(async_query) + xbuflen))) {
527 SetLastError(WSAEWOULDBLOCK); /* insufficient resources */
528 return 0;
531 pto = aq->xbuf;
532 if (ptr1) switch (flags & AQ_MASKPTR1) {
533 case 0: break;
534 case AQ_COPYPTR1: memcpy(pto, ptr1, int1); ptr1 = pto; pto += int1; break;
535 case AQ_DUPLOWPTR1: pfm = ptr1; ptr1 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
537 if (ptr2) switch (flags & AQ_MASKPTR2) {
538 case 0: break;
539 case AQ_COPYPTR2: memcpy(pto, ptr2, int2); ptr2 = pto; pto += int2; break;
540 case AQ_DUPLOWPTR2: pfm = ptr2; ptr2 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
543 aq->hWnd = hWnd;
544 aq->uMsg = uMsg;
545 aq->int1 = int1;
546 aq->ptr1 = ptr1;
547 aq->int2 = int2;
548 aq->ptr2 = ptr2;
549 aq->async_handle = ++__ws_async_handle;
550 aq->flags = flags;
551 aq->sbuf = (SEGPTR)sbuf;
552 aq->sbuflen = sbuflen;
554 #if 1
555 if (CreateThread(NULL,0,_async_queryfun,aq,0,NULL) == INVALID_HANDLE_VALUE)
556 #endif
557 _async_queryfun(aq);
558 return __ws_async_handle;
562 /***********************************************************************
563 * WSAAsyncGetHostByAddr (WINSOCK.102)
565 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 uMsg, LPCSTR addr,
566 INT16 len, INT16 type, SEGPTR sbuf, INT16 buflen)
568 TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n",
569 hWnd, uMsg, (unsigned)addr , len );
570 return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,(void*)sbuf,buflen,
571 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN16|AQ_GETHOST);
574 /***********************************************************************
575 * WSAAsyncGetHostByAddr (WS2_32.102)
577 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
578 INT len, INT type, LPSTR sbuf, INT buflen)
580 TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n",
581 hWnd, uMsg, (unsigned)addr , len );
582 return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,sbuf,buflen,
583 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN32|AQ_GETHOST);
586 /***********************************************************************
587 * WSAAsyncGetHostByName (WINSOCK.103)
589 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
590 SEGPTR sbuf, INT16 buflen)
592 TRACE("hwnd %04x, msg %04x, host %s, buffer %i\n",
593 hWnd, uMsg, (name)?name:"<null>", (int)buflen );
594 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,
595 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETHOST);
598 /***********************************************************************
599 * WSAAsyncGetHostByName (WS2_32.103)
601 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name,
602 LPSTR sbuf, INT buflen)
604 TRACE("hwnd %04x, msg %08x, host %s, buffer %i\n",
605 (HWND16)hWnd, uMsg, (name)?name:"<null>", (int)buflen );
606 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
607 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETHOST);
610 /***********************************************************************
611 * WSAAsyncGetProtoByName (WINSOCK.105)
613 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
614 SEGPTR sbuf, INT16 buflen)
616 TRACE("hwnd %04x, msg %08x, protocol %s\n",
617 (HWND16)hWnd, uMsg, (name)?name:"<null>" );
618 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,
619 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETPROTO);
622 /***********************************************************************
623 * WSAAsyncGetProtoByName (WS2_32.105)
625 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
626 LPSTR sbuf, INT buflen)
628 TRACE("hwnd %04x, msg %08x, protocol %s\n",
629 (HWND16)hWnd, uMsg, (name)?name:"<null>" );
630 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
631 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETPROTO);
635 /***********************************************************************
636 * WSAAsyncGetProtoByNumber (WINSOCK.104)
638 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd,UINT16 uMsg,INT16 number,
639 SEGPTR sbuf, INT16 buflen)
641 TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number );
642 return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,(void*)sbuf,buflen,
643 AQ_GETPROTO|AQ_NUMBER|AQ_WIN16);
646 /***********************************************************************
647 * WSAAsyncGetProtoByNumber (WS2_32.104)
649 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
650 LPSTR sbuf, INT buflen)
652 TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number );
653 return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,sbuf,buflen,
654 AQ_GETPROTO|AQ_NUMBER|AQ_WIN32);
657 /***********************************************************************
658 * WSAAsyncGetServByName (WINSOCK.107)
660 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
661 LPCSTR proto, SEGPTR sbuf, INT16 buflen)
663 TRACE("hwnd %04x, msg %04x, name %s, proto %s\n",
664 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
665 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,(void*)sbuf,buflen,
666 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN16);
669 /***********************************************************************
670 * WSAAsyncGetServByName (WS2_32.107)
672 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
673 LPCSTR proto, LPSTR sbuf, INT buflen)
675 TRACE("hwnd %04x, msg %04x, name %s, proto %s\n",
676 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
677 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,sbuf,buflen,
678 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN32);
681 /***********************************************************************
682 * WSAAsyncGetServByPort (WINSOCK.106)
684 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port,
685 LPCSTR proto, SEGPTR sbuf, INT16 buflen)
687 TRACE("hwnd %04x, msg %04x, port %i, proto %s\n",
688 hWnd, uMsg, port, (proto)?proto:"<null>" );
689 return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,(void*)sbuf,buflen,
690 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN16);
693 /***********************************************************************
694 * WSAAsyncGetServByPort (WS2_32.106)
696 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
697 LPCSTR proto, LPSTR sbuf, INT buflen)
699 TRACE("hwnd %04x, msg %04x, port %i, proto %s\n",
700 hWnd, uMsg, port, (proto)?proto:"<null>" );
701 return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,sbuf,buflen,
702 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN32);
705 /***********************************************************************
706 * WSACancelAsyncRequest (WS2_32.108)
708 INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle)
710 FIXME("(%08x),stub\n", hAsyncTaskHandle);
711 return 0;
714 /***********************************************************************
715 * WSACancelAsyncRequest (WINSOCK.108)
717 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle)
719 return (HANDLE16)WSACancelAsyncRequest((HANDLE)hAsyncTaskHandle);
722 /***********************************************************************
723 * WSApSetPostRoutine (WS2_32.24)
725 INT WINAPI WSApSetPostRoutine(LPWPUPOSTMESSAGE lpPostRoutine)
727 FIXME("(%p), stub !\n", lpPostRoutine);
728 return 0;