Rename "SystemTime" to "t" (this is *not* SYSTEMTIME - avoid
[wine/dcerpc.git] / dlls / winsock / async.c
blobb46b3b03b196dbe9eb90363c03b649d0f27ca478
1 /* Async WINSOCK DNS services
2 *
3 * (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
4 * (C) 1999 Marcus Meissner
6 * NOTE: If you make any changes to fix a particular app, make sure
7 * they don't break something else like Netscape or telnet and ftp
8 * clients and servers (www.winsite.com got a lot of those).
9 *
10 * FIXME:
11 * - Add WSACancel* and correct handle management. (works rather well for
12 * now without it.)
13 * - Verify & Check all calls for correctness
14 * (currently only WSAGetHostByName*, WSAGetServByPort* calls)
15 * - Check error returns.
16 * - mirc/mirc32 Finger @linux.kernel.org sometimes fails in threaded mode.
17 * (not sure why)
18 * - This implementation did ignore the "NOTE:" section above (since the
19 * whole stuff did not work anyway to other changes).
22 #include "config.h"
24 #include <string.h>
25 #include <sys/types.h>
26 #ifdef HAVE_SYS_IPC_H
27 # include <sys/ipc.h>
28 #endif
29 #include <sys/ioctl.h>
30 #ifdef HAVE_SYS_FILIO_H
31 # include <sys/filio.h>
32 #endif
33 #if defined(__svr4__)
34 #include <sys/ioccom.h>
35 #ifdef HAVE_SYS_SOCKIO_H
36 # include <sys/sockio.h>
37 #endif
38 #endif
40 #if defined(__EMX__)
41 # include <sys/so_ioctl.h>
42 #endif
44 #ifdef HAVE_SYS_PARAM_H
45 # include <sys/param.h>
46 #endif
48 #ifdef HAVE_SYS_MSG_H
49 # include <sys/msg.h>
50 #endif
51 #ifdef HAVE_SYS_WAIT_H
52 #include <sys/wait.h>
53 #endif
54 #ifdef HAVE_SYS_SOCKET_H
55 #include <sys/socket.h>
56 #endif
57 #ifdef HAVE_NETINET_IN_H
58 # include <netinet/in.h>
59 #endif
60 #ifdef HAVE_ARPA_INET_H
61 # include <arpa/inet.h>
62 #endif
63 #include <ctype.h>
64 #include <fcntl.h>
65 #include <errno.h>
66 #ifdef HAVE_SYS_ERRNO_H
67 #include <sys/errno.h>
68 #endif
69 #ifdef HAVE_NETDB_H
70 #include <netdb.h>
71 #endif
72 #include <unistd.h>
73 #include <stdlib.h>
74 #ifdef HAVE_ARPA_NAMESER_H
75 # include <arpa/nameser.h>
76 #endif
77 #ifdef HAVE_RESOLV_H
78 # include <resolv.h>
79 #endif
81 #include "wine/winbase16.h"
82 #include "wingdi.h"
83 #include "winuser.h"
84 #include "winsock2.h"
85 #include "wine/winsock16.h"
86 #include "winnt.h"
87 #include "wine/port.h"
88 #include "debugtools.h"
90 DEFAULT_DEBUG_CHANNEL(winsock);
93 /* critical section to protect some non-rentrant net function */
94 CRITICAL_SECTION csWSgetXXXbyYYY = CRITICAL_SECTION_INIT("csWSgetXXXbyYYY");
96 /* protoptypes of some functions in socket.c
98 UINT16 wsaErrno(void);
99 UINT16 wsaHerrno(int errnr);
101 #define AQ_WIN16 0x00
102 #define AQ_WIN32 0x04
103 #define HB_WIN32(hb) (hb->flags & AQ_WIN32)
104 #define AQ_NUMBER 0x00
105 #define AQ_NAME 0x08
106 #define AQ_COPYPTR1 0x10
107 #define AQ_DUPLOWPTR1 0x20
108 #define AQ_MASKPTR1 0x30
109 #define AQ_COPYPTR2 0x40
110 #define AQ_DUPLOWPTR2 0x80
111 #define AQ_MASKPTR2 0xC0
113 #define AQ_GETHOST 0
114 #define AQ_GETPROTO 1
115 #define AQ_GETSERV 2
116 #define AQ_GETMASK 3
118 /* ----------------------------------- helper functions - */
120 static int list_size(char** l, int item_size)
122 int i,j = 0;
123 if(l)
124 { for(i=0;l[i];i++)
125 j += (item_size) ? item_size : strlen(l[i]) + 1;
126 j += (i + 1) * sizeof(char*); }
127 return j;
130 static int list_dup(char** l_src, char* ref, char* base, int item_size)
132 /* base is either either equal to ref or 0 or SEGPTR */
134 char* p = ref;
135 char** l_to = (char**)ref;
136 int i,j,k;
138 for(j=0;l_src[j];j++) ;
139 p += (j + 1) * sizeof(char*);
140 for(i=0;i<j;i++)
141 { l_to[i] = base + (p - ref);
142 k = ( item_size ) ? item_size : strlen(l_src[i]) + 1;
143 memcpy(p, l_src[i], k); p += k; }
144 l_to[i] = NULL;
145 return (p - ref);
148 /* ----- hostent */
150 static int hostent_size(struct hostent* p_he)
152 int size = 0;
153 if( p_he )
154 { size = sizeof(struct hostent);
155 size += strlen(p_he->h_name) + 1;
156 size += list_size(p_he->h_aliases, 0);
157 size += list_size(p_he->h_addr_list, p_he->h_length ); }
158 return size;
161 /* Copy hostent to p_to, fix up inside pointers using p_base (different for
162 * Win16 (linear vs. segmented). Return -neededsize on overrun.
164 static int WS_copy_he(char *p_to,char *p_base,int t_size,struct hostent* p_he, int flag)
166 char* p_name,*p_aliases,*p_addr,*p;
167 struct ws_hostent16 *p_to16 = (struct ws_hostent16*)p_to;
168 struct ws_hostent32 *p_to32 = (struct ws_hostent32*)p_to;
169 int size = hostent_size(p_he) +
171 (flag & AQ_WIN16) ? sizeof(struct ws_hostent16) : sizeof(struct ws_hostent32)
172 - sizeof(struct hostent)
175 if (t_size < size)
176 return -size;
177 p = p_to;
178 p += (flag & AQ_WIN16) ?
179 sizeof(struct ws_hostent16) : sizeof(struct ws_hostent32);
180 p_name = p;
181 strcpy(p, p_he->h_name); p += strlen(p) + 1;
182 p_aliases = p;
183 p += list_dup(p_he->h_aliases, p, p_base + (p - (char*)p_to), 0);
184 p_addr = p;
185 list_dup(p_he->h_addr_list, p, p_base + (p - (char*)p_to), p_he->h_length);
187 if (flag & AQ_WIN16)
189 p_to16->h_addrtype = (INT16)p_he->h_addrtype;
190 p_to16->h_length = (INT16)p_he->h_length;
191 p_to16->h_name = (SEGPTR)(p_base + (p_name - p_to));
192 p_to16->h_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
193 p_to16->h_addr_list = (SEGPTR)(p_base + (p_addr - p_to));
195 else
197 p_to32->h_addrtype = p_he->h_addrtype;
198 p_to32->h_length = p_he->h_length;
199 p_to32->h_name = (p_base + (p_name - p_to));
200 p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to));
201 p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to));
204 return size;
207 /* ----- protoent */
209 static int protoent_size(struct protoent* p_pe)
211 int size = 0;
212 if( p_pe )
213 { size = sizeof(struct protoent);
214 size += strlen(p_pe->p_name) + 1;
215 size += list_size(p_pe->p_aliases, 0); }
216 return size;
219 /* Copy protoent to p_to, fix up inside pointers using p_base (different for
220 * Win16 (linear vs. segmented). Return -neededsize on overrun.
222 static int WS_copy_pe(char *p_to,char *p_base,int t_size,struct protoent* p_pe, int flag)
224 char* p_name,*p_aliases,*p;
225 struct ws_protoent16 *p_to16 = (struct ws_protoent16*)p_to;
226 struct ws_protoent32 *p_to32 = (struct ws_protoent32*)p_to;
227 int size = protoent_size(p_pe) +
229 (flag & AQ_WIN16) ? sizeof(struct ws_protoent16) : sizeof(struct ws_protoent32)
230 - sizeof(struct protoent)
233 if (t_size < size)
234 return -size;
235 p = p_to;
236 p += (flag & AQ_WIN16) ?
237 sizeof(struct ws_protoent16) : sizeof(struct ws_protoent32);
238 p_name = p;
239 strcpy(p, p_pe->p_name); p += strlen(p) + 1;
240 p_aliases = p;
241 list_dup(p_pe->p_aliases, p, p_base + (p - (char*)p_to), 0);
243 if (flag & AQ_WIN16)
245 p_to16->p_proto = (INT16)p_pe->p_proto;
246 p_to16->p_name = (SEGPTR)(p_base) + (p_name - p_to);
247 p_to16->p_aliases = (SEGPTR)((p_base) + (p_aliases - p_to));
249 else
251 p_to32->p_proto = p_pe->p_proto;
252 p_to32->p_name = (p_base) + (p_name - p_to);
253 p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to));
256 return size;
259 /* ----- servent */
261 static int servent_size(struct servent* p_se)
263 int size = 0;
264 if( p_se ) {
265 size += sizeof(struct servent);
266 size += strlen(p_se->s_proto) + strlen(p_se->s_name) + 2;
267 size += list_size(p_se->s_aliases, 0);
269 return size;
272 /* Copy servent to p_to, fix up inside pointers using p_base (different for
273 * Win16 (linear vs. segmented). Return -neededsize on overrun.
274 * Take care of different Win16/Win32 servent structs (packing !)
276 static int WS_copy_se(char *p_to,char *p_base,int t_size,struct servent* p_se, int flag)
278 char* p_name,*p_aliases,*p_proto,*p;
279 struct ws_servent16 *p_to16 = (struct ws_servent16*)p_to;
280 struct ws_servent32 *p_to32 = (struct ws_servent32*)p_to;
281 int size = servent_size(p_se) +
283 (flag & AQ_WIN16) ? sizeof(struct ws_servent16) : sizeof(struct ws_servent32)
284 - sizeof(struct servent)
287 if (t_size < size)
288 return -size;
289 p = p_to;
290 p += (flag & AQ_WIN16) ?
291 sizeof(struct ws_servent16) : sizeof(struct ws_servent32);
292 p_name = p;
293 strcpy(p, p_se->s_name); p += strlen(p) + 1;
294 p_proto = p;
295 strcpy(p, p_se->s_proto); p += strlen(p) + 1;
296 p_aliases = p;
297 list_dup(p_se->s_aliases, p, p_base + (p - p_to), 0);
299 if (flag & AQ_WIN16)
301 p_to16->s_port = (INT16)p_se->s_port;
302 p_to16->s_name = (SEGPTR)(p_base + (p_name - p_to));
303 p_to16->s_proto = (SEGPTR)(p_base + (p_proto - p_to));
304 p_to16->s_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
306 else
308 p_to32->s_port = p_se->s_port;
309 p_to32->s_name = (p_base + (p_name - p_to));
310 p_to32->s_proto = (p_base + (p_proto - p_to));
311 p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to));
314 return size;
317 static HANDLE __ws_async_handle = 0xdead;
319 /* Generic async query struct. we use symbolic names for the different queries
320 * for readability.
322 typedef struct _async_query {
323 HWND16 hWnd;
324 UINT16 uMsg;
325 LPCSTR ptr1;
326 #define host_name ptr1
327 #define host_addr ptr1
328 #define serv_name ptr1
329 #define proto_name ptr1
330 LPCSTR ptr2;
331 #define serv_proto ptr2
332 int int1;
333 #define host_len int1
334 #define proto_number int1
335 #define serv_port int1
336 int int2;
337 #define host_type int2
338 SEGPTR sbuf;
339 INT16 sbuflen;
341 HANDLE16 async_handle;
342 int flags;
343 int qt;
344 char xbuf[1];
345 } async_query;
348 /****************************************************************************
349 * The async query function.
351 * It is either called as a thread startup routine or directly. It has
352 * to free the passed arg from the process heap and PostMessageA the async
353 * result or the error code.
355 * FIXME:
356 * - errorhandling not verified.
358 static DWORD WINAPI _async_queryfun(LPVOID arg) {
359 async_query *aq = (async_query*)arg;
360 int size = 0;
361 WORD fail = 0;
362 char *targetptr = (HB_WIN32(aq)?(char*)aq->sbuf:(char*)MapSL(aq->sbuf));
364 switch (aq->flags & AQ_GETMASK) {
365 case AQ_GETHOST: {
366 struct hostent *he;
367 char *copy_hostent = targetptr;
368 #if HAVE_LINUX_GETHOSTBYNAME_R_6
369 char *extrabuf;
370 int ebufsize=1024;
371 struct hostent hostentry;
372 int locerr = ENOBUFS;
373 he = NULL;
374 extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
375 while(extrabuf) {
376 int res = (aq->flags & AQ_NAME) ?
377 gethostbyname_r(aq->host_name,
378 &hostentry, extrabuf, ebufsize, &he, &locerr):
379 gethostbyaddr_r(aq->host_addr,aq->host_len,aq->host_type,
380 &hostentry, extrabuf, ebufsize, &he, &locerr);
381 if( res != ERANGE) break;
382 ebufsize *=2;
383 extrabuf=HeapReAlloc(GetProcessHeap(),0,extrabuf,ebufsize) ;
385 if (!he) fail = ((locerr < 0) ? wsaErrno() : wsaHerrno(locerr));
386 #else
387 EnterCriticalSection( &csWSgetXXXbyYYY );
388 he = (aq->flags & AQ_NAME) ?
389 gethostbyname(aq->host_name):
390 gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type);
391 if (!he) fail = ((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
392 #endif
393 if (he) {
394 size = WS_copy_he(copy_hostent,(char*)aq->sbuf,aq->sbuflen,he,aq->flags);
395 if (size < 0) {
396 fail = WSAENOBUFS;
397 size = -size;
400 #if HAVE_LINUX_GETHOSTBYNAME_R_6
401 HeapFree(GetProcessHeap(),0,extrabuf);
402 #else
403 LeaveCriticalSection( &csWSgetXXXbyYYY );
404 #endif
406 break;
407 case AQ_GETPROTO: {
408 struct protoent *pe;
409 char *copy_protoent = targetptr;
410 EnterCriticalSection( &csWSgetXXXbyYYY );
411 pe = (aq->flags & AQ_NAME)?
412 getprotobyname(aq->proto_name) :
413 getprotobynumber(aq->proto_number);
414 if (pe) {
415 size = WS_copy_pe(copy_protoent,(char*)aq->sbuf,aq->sbuflen,pe,aq->flags);
416 if (size < 0) {
417 fail = WSAENOBUFS;
418 size = -size;
420 } else {
421 if (aq->flags & AQ_NAME)
422 MESSAGE("protocol %s not found; You might want to add "
423 "this to /etc/protocols\n", debugstr_a(aq->proto_name) );
424 else
425 MESSAGE("protocol number %d not found; You might want to add "
426 "this to /etc/protocols\n", aq->proto_number );
427 fail = WSANO_DATA;
429 LeaveCriticalSection( &csWSgetXXXbyYYY );
431 break;
432 case AQ_GETSERV: {
433 struct servent *se;
434 char *copy_servent = targetptr;
435 EnterCriticalSection( &csWSgetXXXbyYYY );
436 se = (aq->flags & AQ_NAME)?
437 getservbyname(aq->serv_name,aq->serv_proto) :
438 getservbyport(aq->serv_port,aq->serv_proto);
439 if (se) {
440 size = WS_copy_se(copy_servent,(char*)aq->sbuf,aq->sbuflen,se,aq->flags);
441 if (size < 0) {
442 fail = WSAENOBUFS;
443 size = -size;
445 } else {
446 if (aq->flags & AQ_NAME)
447 MESSAGE("service %s protocol %s not found; You might want to add "
448 "this to /etc/services\n", debugstr_a(aq->serv_name) ,
449 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
450 else
451 MESSAGE("service on port %d protocol %s not found; You might want to add "
452 "this to /etc/services\n", aq->serv_port,
453 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
454 fail = WSANO_DATA;
456 LeaveCriticalSection( &csWSgetXXXbyYYY );
458 break;
460 PostMessageA(aq->hWnd,aq->uMsg,aq->async_handle,size|(fail<<16));
461 HeapFree(GetProcessHeap(),0,arg);
462 return 0;
465 /****************************************************************************
466 * The main async help function.
468 * It either starts a thread or just calls the function directly for platforms
469 * with no thread support. This relies on the fact that PostMessage() does
470 * not actually call the windowproc before the function returns.
472 static HANDLE16 __WSAsyncDBQuery(
473 HWND hWnd, UINT uMsg,INT int1,LPCSTR ptr1, INT int2, LPCSTR ptr2,
474 void *sbuf, INT sbuflen, UINT flags
477 async_query* aq;
478 char* pto;
479 LPCSTR pfm;
480 int xbuflen = 0;
482 /* allocate buffer to copy protocol- and service name to */
483 /* note: this is done in the calling thread so we can return */
484 /* a decent error code if the Alloc fails */
486 switch (flags & AQ_MASKPTR1) {
487 case 0: break;
488 case AQ_COPYPTR1: xbuflen += int1; break;
489 case AQ_DUPLOWPTR1: xbuflen += strlen(ptr1) + 1; break;
492 switch (flags & AQ_MASKPTR2) {
493 case 0: break;
494 case AQ_COPYPTR2: xbuflen += int2; break;
495 case AQ_DUPLOWPTR2: xbuflen += strlen(ptr2) + 1; break;
498 if(!(aq = HeapAlloc(GetProcessHeap(),0,sizeof(async_query) + xbuflen))) {
499 SetLastError(WSAEWOULDBLOCK); /* insufficient resources */
500 return 0;
503 pto = aq->xbuf;
504 if (ptr1) switch (flags & AQ_MASKPTR1) {
505 case 0: break;
506 case AQ_COPYPTR1: memcpy(pto, ptr1, int1); ptr1 = pto; pto += int1; break;
507 case AQ_DUPLOWPTR1: pfm = ptr1; ptr1 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
509 if (ptr2) switch (flags & AQ_MASKPTR2) {
510 case 0: break;
511 case AQ_COPYPTR2: memcpy(pto, ptr2, int2); ptr2 = pto; pto += int2; break;
512 case AQ_DUPLOWPTR2: pfm = ptr2; ptr2 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
515 aq->hWnd = hWnd;
516 aq->uMsg = uMsg;
517 aq->int1 = int1;
518 aq->ptr1 = ptr1;
519 aq->int2 = int2;
520 aq->ptr2 = ptr2;
521 aq->async_handle = ++__ws_async_handle;
522 aq->flags = flags;
523 aq->sbuf = (SEGPTR)sbuf;
524 aq->sbuflen = sbuflen;
526 #if 1
527 if (CreateThread(NULL,0,_async_queryfun,aq,0,NULL) == INVALID_HANDLE_VALUE)
528 #endif
529 _async_queryfun(aq);
530 return __ws_async_handle;
534 /***********************************************************************
535 * WSAAsyncGetHostByAddr (WINSOCK.102)
537 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 uMsg, LPCSTR addr,
538 INT16 len, INT16 type, SEGPTR sbuf, INT16 buflen)
540 TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n",
541 hWnd, uMsg, (unsigned)addr , len );
542 return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,(void*)sbuf,buflen,
543 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN16|AQ_GETHOST);
546 /***********************************************************************
547 * WSAAsyncGetHostByAddr (WS2_32.102)
549 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
550 INT len, INT type, LPSTR sbuf, INT buflen)
552 TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n",
553 hWnd, uMsg, (unsigned)addr , len );
554 return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,sbuf,buflen,
555 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN32|AQ_GETHOST);
558 /***********************************************************************
559 * WSAAsyncGetHostByName (WINSOCK.103)
561 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
562 SEGPTR sbuf, INT16 buflen)
564 TRACE("hwnd %04x, msg %04x, host %s, buffer %i\n",
565 hWnd, uMsg, (name)?name:"<null>", (int)buflen );
566 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,
567 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETHOST);
570 /***********************************************************************
571 * WSAAsyncGetHostByName (WS2_32.103)
573 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name,
574 LPSTR sbuf, INT buflen)
576 TRACE("hwnd %04x, msg %08x, host %s, buffer %i\n",
577 (HWND16)hWnd, uMsg, (name)?name:"<null>", (int)buflen );
578 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
579 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETHOST);
582 /***********************************************************************
583 * WSAAsyncGetProtoByName (WINSOCK.105)
585 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
586 SEGPTR sbuf, INT16 buflen)
588 TRACE("hwnd %04x, msg %08x, protocol %s\n",
589 (HWND16)hWnd, uMsg, (name)?name:"<null>" );
590 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,
591 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETPROTO);
594 /***********************************************************************
595 * WSAAsyncGetProtoByName (WS2_32.105)
597 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
598 LPSTR sbuf, INT buflen)
600 TRACE("hwnd %04x, msg %08x, protocol %s\n",
601 (HWND16)hWnd, uMsg, (name)?name:"<null>" );
602 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
603 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETPROTO);
607 /***********************************************************************
608 * WSAAsyncGetProtoByNumber (WINSOCK.104)
610 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd,UINT16 uMsg,INT16 number,
611 SEGPTR sbuf, INT16 buflen)
613 TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number );
614 return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,(void*)sbuf,buflen,
615 AQ_GETPROTO|AQ_NUMBER|AQ_WIN16);
618 /***********************************************************************
619 * WSAAsyncGetProtoByNumber (WS2_32.104)
621 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
622 LPSTR sbuf, INT buflen)
624 TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number );
625 return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,sbuf,buflen,
626 AQ_GETPROTO|AQ_NUMBER|AQ_WIN32);
629 /***********************************************************************
630 * WSAAsyncGetServByName (WINSOCK.107)
632 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
633 LPCSTR proto, SEGPTR sbuf, INT16 buflen)
635 TRACE("hwnd %04x, msg %04x, name %s, proto %s\n",
636 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
637 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,(void*)sbuf,buflen,
638 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN16);
641 /***********************************************************************
642 * WSAAsyncGetServByName (WS2_32.107)
644 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
645 LPCSTR proto, LPSTR sbuf, INT buflen)
647 TRACE("hwnd %04x, msg %04x, name %s, proto %s\n",
648 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
649 return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,sbuf,buflen,
650 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN32);
653 /***********************************************************************
654 * WSAAsyncGetServByPort (WINSOCK.106)
656 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port,
657 LPCSTR proto, SEGPTR sbuf, INT16 buflen)
659 TRACE("hwnd %04x, msg %04x, port %i, proto %s\n",
660 hWnd, uMsg, port, (proto)?proto:"<null>" );
661 return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,(void*)sbuf,buflen,
662 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN16);
665 /***********************************************************************
666 * WSAAsyncGetServByPort (WS2_32.106)
668 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
669 LPCSTR proto, LPSTR sbuf, INT buflen)
671 TRACE("hwnd %04x, msg %04x, port %i, proto %s\n",
672 hWnd, uMsg, port, (proto)?proto:"<null>" );
673 return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,sbuf,buflen,
674 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN32);
677 /***********************************************************************
678 * WSACancelAsyncRequest (WS2_32.108)
680 INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle)
682 FIXME("(%08x),stub\n", hAsyncTaskHandle);
683 return 0;
686 /***********************************************************************
687 * WSACancelAsyncRequest (WINSOCK.108)
689 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle)
691 return (HANDLE16)WSACancelAsyncRequest((HANDLE)hAsyncTaskHandle);