Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenasync.c
Go to the documentation of this file.
00001 /* Async WINSOCK DNS services 00002 * 00003 * Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka. 00004 * Copyright (C) 1999 Marcus Meissner 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 * 00020 * NOTE: If you make any changes to fix a particular app, make sure 00021 * they don't break something else like Netscape or telnet and ftp 00022 * clients and servers (www.winsite.com got a lot of those). 00023 * 00024 * FIXME: 00025 * - Add WSACancel* and correct handle management. (works rather well for 00026 * now without it.) 00027 * - Verify & Check all calls for correctness 00028 * (currently only WSAGetHostByName*, WSAGetServByPort* calls) 00029 * - Check error returns. 00030 * - mirc/mirc32 Finger @linux.kernel.org sometimes fails in threaded mode. 00031 * (not sure why) 00032 * - This implementation did ignore the "NOTE:" section above (since the 00033 * whole stuff did not work anyway to other changes). 00034 */ 00035 00036 #include <windows.h> 00037 00038 #define WS_FD_SETSIZE FD_SETSIZE 00039 typedef struct hostent WS_hostent; 00040 typedef struct servent WS_servent; 00041 typedef struct protoent WS_protoent; 00042 00043 #include "wine/config.h" 00044 #include "wine/port.h" 00045 00046 #ifndef __REACTOS__ 00047 #include <stdarg.h> 00048 #include <string.h> 00049 #include <sys/types.h> 00050 #ifdef HAVE_SYS_IPC_H 00051 # include <sys/ipc.h> 00052 #endif 00053 #ifdef HAVE_SYS_IOCTL_H 00054 # include <sys/ioctl.h> 00055 #endif 00056 #ifdef HAVE_SYS_FILIO_H 00057 # include <sys/filio.h> 00058 #endif 00059 #if defined(__svr4__) 00060 #include <sys/ioccom.h> 00061 #ifdef HAVE_SYS_SOCKIO_H 00062 # include <sys/sockio.h> 00063 #endif 00064 #endif 00065 00066 #if defined(__EMX__) 00067 # include <sys/so_ioctl.h> 00068 #endif 00069 00070 #ifdef HAVE_SYS_PARAM_H 00071 # include <sys/param.h> 00072 #endif 00073 00074 #ifdef HAVE_SYS_MSG_H 00075 # include <sys/msg.h> 00076 #endif 00077 #ifdef HAVE_SYS_WAIT_H 00078 #include <sys/wait.h> 00079 #endif 00080 #ifdef HAVE_SYS_SOCKET_H 00081 #include <sys/socket.h> 00082 #endif 00083 #ifdef HAVE_NETINET_IN_H 00084 # include <netinet/in.h> 00085 #endif 00086 #ifdef HAVE_ARPA_INET_H 00087 # include <arpa/inet.h> 00088 #endif 00089 #include <ctype.h> 00090 #include <fcntl.h> 00091 #include <errno.h> 00092 #ifdef HAVE_SYS_ERRNO_H 00093 #include <sys/errno.h> 00094 #endif 00095 #ifdef HAVE_NETDB_H 00096 #include <netdb.h> 00097 #endif 00098 #ifdef HAVE_UNISTD_H 00099 # include <unistd.h> 00100 #endif 00101 #include <stdlib.h> 00102 #ifdef HAVE_ARPA_NAMESER_H 00103 # include <arpa/nameser.h> 00104 #endif 00105 #ifdef HAVE_RESOLV_H 00106 # include <resolv.h> 00107 #endif 00108 #endif 00109 00110 #include "wine/winbase16.h" 00111 #include "windef.h" 00112 #include "winbase.h" 00113 #include "wingdi.h" 00114 #include "winuser.h" 00115 #include "winsock2.h" 00116 #include "ws2spi.h" 00117 #include "wownt32.h" 00118 #include "wine/winsock16.h" 00119 #include "winnt.h" 00120 00121 #include "wine/debug.h" 00122 00123 WINE_DEFAULT_DEBUG_CHANNEL(winsock); 00124 00125 00126 /* protoptypes of some functions in socket.c 00127 */ 00128 00129 #define AQ_WIN16 0x00 00130 #define AQ_WIN32 0x04 00131 #define HB_WIN32(hb) (hb->flags & AQ_WIN32) 00132 #define AQ_NUMBER 0x00 00133 #define AQ_NAME 0x08 00134 #define AQ_COPYPTR1 0x10 00135 #define AQ_DUPLOWPTR1 0x20 00136 #define AQ_MASKPTR1 0x30 00137 #define AQ_COPYPTR2 0x40 00138 #define AQ_DUPLOWPTR2 0x80 00139 #define AQ_MASKPTR2 0xC0 00140 00141 #define AQ_GETHOST 0 00142 #define AQ_GETPROTO 1 00143 #define AQ_GETSERV 2 00144 #define AQ_GETMASK 3 00145 00146 /* The handles used are pseudo-handles that can be simply casted. */ 00147 /* 16-bit values are used internally (to be sure handle comparison works right in 16-bit apps). */ 00148 #define WSA_H32(h16) ((HANDLE)(ULONG_PTR)(h16)) 00149 00150 /* ----------------------------------- helper functions - */ 00151 00152 static int list_size(char** l, int item_size) 00153 { 00154 int i,j = 0; 00155 if(l) 00156 { for(i=0;l[i];i++) 00157 j += (item_size) ? item_size : strlen(l[i]) + 1; 00158 j += (i + 1) * sizeof(char*); } 00159 return j; 00160 } 00161 00162 static int list_dup(char** l_src, char* ref, char* base, int item_size) 00163 { 00164 /* base is either either equal to ref or 0 or SEGPTR */ 00165 00166 char* p = ref; 00167 char** l_to = (char**)ref; 00168 int i,j,k; 00169 00170 for(j=0;l_src[j];j++) ; 00171 p += (j + 1) * sizeof(char*); 00172 for(i=0;i<j;i++) 00173 { l_to[i] = base + (p - ref); 00174 k = ( item_size ) ? item_size : strlen(l_src[i]) + 1; 00175 memcpy(p, l_src[i], k); p += k; } 00176 l_to[i] = NULL; 00177 return (p - ref); 00178 } 00179 00180 /* ----- hostent */ 00181 00182 static int hostent_size(struct hostent* p_he) 00183 { 00184 int size = 0; 00185 if( p_he ) 00186 { size = sizeof(struct hostent); 00187 size += strlen(p_he->h_name) + 1; 00188 size += list_size(p_he->h_aliases, 0); 00189 size += list_size(p_he->h_addr_list, p_he->h_length ); } 00190 return size; 00191 } 00192 00193 /* Copy hostent to p_to, fix up inside pointers using p_base (different for 00194 * Win16 (linear vs. segmented). Return -neededsize on overrun. 00195 */ 00196 static int WS_copy_he(char *p_to,char *p_base,int t_size,struct hostent* p_he, int flag) 00197 { 00198 char* p_name,*p_aliases,*p_addr,*p; 00199 struct ws_hostent16 *p_to16 = (struct ws_hostent16*)p_to; 00200 WS_hostent *p_to32 = (WS_hostent*)p_to; 00201 int size = hostent_size(p_he) + 00202 ( 00203 (flag & AQ_WIN32) ? sizeof(WS_hostent) : sizeof(struct ws_hostent16) 00204 - sizeof(struct hostent) 00205 ); 00206 00207 if (t_size < size) 00208 return -size; 00209 p = p_to; 00210 p += (flag & AQ_WIN32) ? 00211 sizeof(WS_hostent) : sizeof(struct ws_hostent16); 00212 p_name = p; 00213 strcpy(p, p_he->h_name); p += strlen(p) + 1; 00214 p_aliases = p; 00215 p += list_dup(p_he->h_aliases, p, p_base + (p - p_to), 0); 00216 p_addr = p; 00217 list_dup(p_he->h_addr_list, p, p_base + (p - p_to), p_he->h_length); 00218 00219 if (flag & AQ_WIN32) 00220 { 00221 p_to32->h_addrtype = p_he->h_addrtype; 00222 p_to32->h_length = p_he->h_length; 00223 p_to32->h_name = (p_base + (p_name - p_to)); 00224 p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to)); 00225 p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to)); 00226 } 00227 else 00228 { 00229 p_to16->h_addrtype = (INT16)p_he->h_addrtype; 00230 p_to16->h_length = (INT16)p_he->h_length; 00231 p_to16->h_name = (SEGPTR)(p_base + (p_name - p_to)); 00232 p_to16->h_aliases = (SEGPTR)(p_base + (p_aliases - p_to)); 00233 p_to16->h_addr_list = (SEGPTR)(p_base + (p_addr - p_to)); 00234 } 00235 00236 return size; 00237 } 00238 00239 /* ----- protoent */ 00240 00241 static int protoent_size(struct protoent* p_pe) 00242 { 00243 int size = 0; 00244 if( p_pe ) 00245 { size = sizeof(struct protoent); 00246 size += strlen(p_pe->p_name) + 1; 00247 size += list_size(p_pe->p_aliases, 0); } 00248 return size; 00249 } 00250 00251 /* Copy protoent to p_to, fix up inside pointers using p_base (different for 00252 * Win16 (linear vs. segmented). Return -neededsize on overrun. 00253 */ 00254 static int WS_copy_pe(char *p_to,char *p_base,int t_size,struct protoent* p_pe, int flag) 00255 { 00256 char* p_name,*p_aliases,*p; 00257 struct ws_protoent16 *p_to16 = (struct ws_protoent16*)p_to; 00258 WS_protoent *p_to32 = (WS_protoent*)p_to; 00259 int size = protoent_size(p_pe) + 00260 ( 00261 (flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16) 00262 - sizeof(struct protoent) 00263 ); 00264 00265 if (t_size < size) 00266 return -size; 00267 p = p_to; 00268 p += (flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16); 00269 p_name = p; 00270 strcpy(p, p_pe->p_name); p += strlen(p) + 1; 00271 p_aliases = p; 00272 list_dup(p_pe->p_aliases, p, p_base + (p - p_to), 0); 00273 00274 if (flag & AQ_WIN32) 00275 { 00276 p_to32->p_proto = p_pe->p_proto; 00277 p_to32->p_name = (p_base) + (p_name - p_to); 00278 p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to)); 00279 } 00280 else 00281 { 00282 p_to16->p_proto = (INT16)p_pe->p_proto; 00283 p_to16->p_name = (SEGPTR)(p_base) + (p_name - p_to); 00284 p_to16->p_aliases = (SEGPTR)((p_base) + (p_aliases - p_to)); 00285 } 00286 00287 return size; 00288 } 00289 00290 /* ----- servent */ 00291 00292 static int servent_size(struct servent* p_se) 00293 { 00294 int size = 0; 00295 if( p_se ) { 00296 size += sizeof(struct servent); 00297 size += strlen(p_se->s_proto) + strlen(p_se->s_name) + 2; 00298 size += list_size(p_se->s_aliases, 0); 00299 } 00300 return size; 00301 } 00302 00303 /* Copy servent to p_to, fix up inside pointers using p_base (different for 00304 * Win16 (linear vs. segmented). Return -neededsize on overrun. 00305 * Take care of different Win16/Win32 servent structs (packing !) 00306 */ 00307 static int WS_copy_se(char *p_to,char *p_base,int t_size,struct servent* p_se, int flag) 00308 { 00309 char* p_name,*p_aliases,*p_proto,*p; 00310 struct ws_servent16 *p_to16 = (struct ws_servent16*)p_to; 00311 WS_servent *p_to32 = (WS_servent*)p_to; 00312 int size = servent_size(p_se) + 00313 ( 00314 (flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16) 00315 - sizeof(struct servent) 00316 ); 00317 00318 if (t_size < size) 00319 return -size; 00320 p = p_to; 00321 p += (flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16); 00322 p_name = p; 00323 strcpy(p, p_se->s_name); p += strlen(p) + 1; 00324 p_proto = p; 00325 strcpy(p, p_se->s_proto); p += strlen(p) + 1; 00326 p_aliases = p; 00327 list_dup(p_se->s_aliases, p, p_base + (p - p_to), 0); 00328 00329 if (flag & AQ_WIN32) 00330 { 00331 p_to32->s_port = p_se->s_port; 00332 p_to32->s_name = (p_base + (p_name - p_to)); 00333 p_to32->s_proto = (p_base + (p_proto - p_to)); 00334 p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to)); 00335 } 00336 else 00337 { 00338 p_to16->s_port = (INT16)p_se->s_port; 00339 p_to16->s_name = (SEGPTR)(p_base + (p_name - p_to)); 00340 p_to16->s_proto = (SEGPTR)(p_base + (p_proto - p_to)); 00341 p_to16->s_aliases = (SEGPTR)(p_base + (p_aliases - p_to)); 00342 } 00343 00344 return size; 00345 } 00346 00347 static HANDLE16 __ws_async_handle = 0xdead; 00348 00349 /* Generic async query struct. we use symbolic names for the different queries 00350 * for readability. 00351 */ 00352 typedef struct _async_query { 00353 HWND16 hWnd; 00354 UINT16 uMsg; 00355 LPCSTR ptr1; 00356 #define host_name ptr1 00357 #define host_addr ptr1 00358 #define serv_name ptr1 00359 #define proto_name ptr1 00360 LPCSTR ptr2; 00361 #define serv_proto ptr2 00362 int int1; 00363 #define host_len int1 00364 #define proto_number int1 00365 #define serv_port int1 00366 int int2; 00367 #define host_type int2 00368 SEGPTR sbuf; 00369 INT16 sbuflen; 00370 00371 HANDLE16 async_handle; 00372 int flags; 00373 int qt; 00374 char xbuf[1]; 00375 } async_query; 00376 00377 00378 /**************************************************************************** 00379 * The async query function. 00380 * 00381 * It is either called as a thread startup routine or directly. It has 00382 * to free the passed arg from the process heap and PostMessageA the async 00383 * result or the error code. 00384 * 00385 * FIXME: 00386 * - errorhandling not verified. 00387 */ 00388 static DWORD WINAPI _async_queryfun(LPVOID arg) { 00389 async_query *aq = (async_query*)arg; 00390 int size = 0; 00391 WORD fail = 0; 00392 char *targetptr = (HB_WIN32(aq)?(char*)aq->sbuf:0/*(char*)MapSL(aq->sbuf)*/); 00393 00394 switch (aq->flags & AQ_GETMASK) { 00395 case AQ_GETHOST: { 00396 struct hostent *he; 00397 char *copy_hostent = targetptr; 00398 char buf[100]; 00399 if( !(aq->host_name)) { 00400 aq->host_name = buf; 00401 if( gethostname( buf, 100) == -1) { 00402 fail = WSAENOBUFS; /* appropriate ? */ 00403 break; 00404 } 00405 } 00406 he = (aq->flags & AQ_NAME) ? 00407 gethostbyname(aq->host_name): 00408 gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type); 00409 if (!he) fail = WSAGetLastError(); 00410 if (he) { 00411 size = WS_copy_he(copy_hostent,(char*)aq->sbuf,aq->sbuflen,he,aq->flags); 00412 if (size < 0) { 00413 fail = WSAENOBUFS; 00414 size = -size; 00415 } 00416 } 00417 } 00418 break; 00419 case AQ_GETPROTO: { 00420 #if defined(HAVE_GETPROTOBYNAME) && defined(HAVE_GETPROTOBYNUMBER) 00421 struct protoent *pe; 00422 char *copy_protoent = targetptr; 00423 pe = (aq->flags & AQ_NAME)? 00424 getprotobyname(aq->proto_name) : 00425 getprotobynumber(aq->proto_number); 00426 if (pe) { 00427 size = WS_copy_pe(copy_protoent,(char*)aq->sbuf,aq->sbuflen,pe,aq->flags); 00428 if (size < 0) { 00429 fail = WSAENOBUFS; 00430 size = -size; 00431 } 00432 } else { 00433 if (aq->flags & AQ_NAME) 00434 MESSAGE("protocol %s not found; You might want to add " 00435 "this to /etc/protocols\n", debugstr_a(aq->proto_name) ); 00436 else 00437 MESSAGE("protocol number %d not found; You might want to add " 00438 "this to /etc/protocols\n", aq->proto_number ); 00439 fail = WSANO_DATA; 00440 } 00441 #else 00442 fail = WSANO_DATA; 00443 #endif 00444 } 00445 break; 00446 case AQ_GETSERV: { 00447 struct servent *se; 00448 char *copy_servent = targetptr; 00449 se = (aq->flags & AQ_NAME)? 00450 getservbyname(aq->serv_name,aq->serv_proto) : 00451 #ifdef HAVE_GETSERVBYPORT 00452 getservbyport(aq->serv_port,aq->serv_proto); 00453 #else 00454 NULL; 00455 #endif 00456 if (se) { 00457 size = WS_copy_se(copy_servent,(char*)aq->sbuf,aq->sbuflen,se,aq->flags); 00458 if (size < 0) { 00459 fail = WSAENOBUFS; 00460 size = -size; 00461 } 00462 } else { 00463 if (aq->flags & AQ_NAME) 00464 MESSAGE("service %s protocol %s not found; You might want to add " 00465 "this to /etc/services\n", debugstr_a(aq->serv_name) , 00466 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*"); 00467 else 00468 MESSAGE("service on port %d protocol %s not found; You might want to add " 00469 "this to /etc/services\n", aq->serv_port, 00470 aq->serv_proto ? debugstr_a(aq->serv_proto ):"*"); 00471 fail = WSANO_DATA; 00472 } 00473 } 00474 break; 00475 } 00476 PostMessageA(HWND_32(aq->hWnd),aq->uMsg,(WPARAM) aq->async_handle,size|(fail<<16)); 00477 HeapFree(GetProcessHeap(),0,arg); 00478 return 0; 00479 } 00480 00481 /**************************************************************************** 00482 * The main async help function. 00483 * 00484 * It either starts a thread or just calls the function directly for platforms 00485 * with no thread support. This relies on the fact that PostMessage() does 00486 * not actually call the windowproc before the function returns. 00487 */ 00488 static HANDLE16 __WSAsyncDBQuery( 00489 HWND hWnd, UINT uMsg,INT int1,LPCSTR ptr1, INT int2, LPCSTR ptr2, 00490 void *sbuf, INT sbuflen, UINT flags 00491 ) 00492 { 00493 async_query* aq; 00494 char* pto; 00495 LPCSTR pfm; 00496 int xbuflen = 0; 00497 00498 /* allocate buffer to copy protocol- and service name to */ 00499 /* note: this is done in the calling thread so we can return */ 00500 /* a decent error code if the Alloc fails */ 00501 00502 switch (flags & AQ_MASKPTR1) { 00503 case 0: break; 00504 case AQ_COPYPTR1: xbuflen += int1; break; 00505 case AQ_DUPLOWPTR1: xbuflen += strlen(ptr1) + 1; break; 00506 } 00507 00508 switch (flags & AQ_MASKPTR2) { 00509 case 0: break; 00510 case AQ_COPYPTR2: xbuflen += int2; break; 00511 case AQ_DUPLOWPTR2: xbuflen += strlen(ptr2) + 1; break; 00512 } 00513 00514 if(!(aq = HeapAlloc(GetProcessHeap(),0,sizeof(async_query) + xbuflen))) { 00515 SetLastError(WSAEWOULDBLOCK); /* insufficient resources */ 00516 return 0; 00517 } 00518 00519 pto = aq->xbuf; 00520 if (ptr1) switch (flags & AQ_MASKPTR1) { 00521 case 0: break; 00522 case AQ_COPYPTR1: memcpy(pto, ptr1, int1); ptr1 = pto; pto += int1; break; 00523 case AQ_DUPLOWPTR1: pfm = ptr1; ptr1 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break; 00524 } 00525 if (ptr2) switch (flags & AQ_MASKPTR2) { 00526 case 0: break; 00527 case AQ_COPYPTR2: memcpy(pto, ptr2, int2); ptr2 = pto; pto += int2; break; 00528 case AQ_DUPLOWPTR2: pfm = ptr2; ptr2 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break; 00529 } 00530 00531 aq->hWnd = HWND_16(hWnd); 00532 aq->uMsg = uMsg; 00533 aq->int1 = int1; 00534 aq->ptr1 = ptr1; 00535 aq->int2 = int2; 00536 aq->ptr2 = ptr2; 00537 /* avoid async_handle = 0 */ 00538 aq->async_handle = (++__ws_async_handle ? __ws_async_handle : ++__ws_async_handle); 00539 aq->flags = flags; 00540 aq->sbuf = (SEGPTR)sbuf; 00541 aq->sbuflen = sbuflen; 00542 00543 #if 1 00544 if (CreateThread(NULL,0,_async_queryfun,aq,0,NULL) == INVALID_HANDLE_VALUE) 00545 #endif 00546 _async_queryfun(aq); 00547 return __ws_async_handle; 00548 } 00549 00550 00551 /*********************************************************************** 00552 * WSAAsyncGetHostByAddr (WINSOCK.102) 00553 */ 00554 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 uMsg, LPCSTR addr, 00555 INT16 len, INT16 type, SEGPTR sbuf, INT16 buflen) 00556 { 00557 TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n", 00558 hWnd, uMsg, (unsigned)addr , len ); 00559 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,len,addr,type,NULL, 00560 (void*)sbuf,buflen, 00561 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN16|AQ_GETHOST); 00562 } 00563 00564 /*********************************************************************** 00565 * WSAAsyncGetHostByAddr (WS2_32.102) 00566 */ 00567 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr, 00568 INT len, INT type, LPSTR sbuf, INT buflen) 00569 { 00570 TRACE("hwnd %p, msg %04x, addr %08x[%i]\n", 00571 hWnd, uMsg, (unsigned)addr , len ); 00572 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,sbuf,buflen, 00573 AQ_NUMBER|AQ_COPYPTR1|AQ_WIN32|AQ_GETHOST)); 00574 } 00575 00576 /*********************************************************************** 00577 * WSAAsyncGetHostByName (WINSOCK.103) 00578 */ 00579 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, 00580 SEGPTR sbuf, INT16 buflen) 00581 { 00582 TRACE("hwnd %04x, msg %04x, host %s, buffer %i\n", 00583 hWnd, uMsg, (name)?name:"<null>", (int)buflen ); 00584 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,NULL, 00585 (void*)sbuf,buflen, 00586 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETHOST); 00587 } 00588 00589 /*********************************************************************** 00590 * WSAAsyncGetHostByName (WS2_32.103) 00591 */ 00592 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name, 00593 LPSTR sbuf, INT buflen) 00594 { 00595 TRACE("hwnd %p, msg %08x, host %s, buffer %i\n", 00596 hWnd, uMsg, (name)?name:"<null>", (int)buflen ); 00597 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen, 00598 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETHOST)); 00599 } 00600 00601 /*********************************************************************** 00602 * WSAAsyncGetProtoByName (WINSOCK.105) 00603 */ 00604 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, 00605 SEGPTR sbuf, INT16 buflen) 00606 { 00607 TRACE("hwnd %04x, msg %08x, protocol %s\n", 00608 hWnd, uMsg, (name)?name:"<null>" ); 00609 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,NULL, 00610 (void*)sbuf,buflen, 00611 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETPROTO); 00612 } 00613 00614 /*********************************************************************** 00615 * WSAAsyncGetProtoByName (WS2_32.105) 00616 */ 00617 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name, 00618 LPSTR sbuf, INT buflen) 00619 { 00620 TRACE("hwnd %p, msg %08x, protocol %s\n", 00621 hWnd, uMsg, (name)?name:"<null>" ); 00622 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen, 00623 AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETPROTO)); 00624 } 00625 00626 00627 /*********************************************************************** 00628 * WSAAsyncGetProtoByNumber (WINSOCK.104) 00629 */ 00630 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd,UINT16 uMsg,INT16 number, 00631 SEGPTR sbuf, INT16 buflen) 00632 { 00633 TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number ); 00634 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,number,NULL,0,NULL, 00635 (void*)sbuf,buflen, 00636 AQ_GETPROTO|AQ_NUMBER|AQ_WIN16); 00637 } 00638 00639 /*********************************************************************** 00640 * WSAAsyncGetProtoByNumber (WS2_32.104) 00641 */ 00642 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number, 00643 LPSTR sbuf, INT buflen) 00644 { 00645 TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number ); 00646 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,sbuf,buflen, 00647 AQ_GETPROTO|AQ_NUMBER|AQ_WIN32)); 00648 } 00649 00650 /*********************************************************************** 00651 * WSAAsyncGetServByName (WINSOCK.107) 00652 */ 00653 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, 00654 LPCSTR proto, SEGPTR sbuf, INT16 buflen) 00655 { 00656 TRACE("hwnd %04x, msg %04x, name %s, proto %s\n", 00657 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>"); 00658 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,proto, 00659 (void*)sbuf,buflen, 00660 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN16); 00661 } 00662 00663 /*********************************************************************** 00664 * WSAAsyncGetServByName (WS2_32.107) 00665 */ 00666 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, 00667 LPCSTR proto, LPSTR sbuf, INT buflen) 00668 { 00669 TRACE("hwnd %p, msg %04x, name %s, proto %s\n", 00670 hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>"); 00671 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,sbuf,buflen, 00672 AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN32)); 00673 } 00674 00675 /*********************************************************************** 00676 * WSAAsyncGetServByPort (WINSOCK.106) 00677 */ 00678 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port, 00679 LPCSTR proto, SEGPTR sbuf, INT16 buflen) 00680 { 00681 TRACE("hwnd %04x, msg %04x, port %i, proto %s\n", 00682 hWnd, uMsg, port, (proto)?proto:"<null>" ); 00683 return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,port,NULL,0,proto, 00684 (void*)sbuf,buflen, 00685 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN16); 00686 } 00687 00688 /*********************************************************************** 00689 * WSAAsyncGetServByPort (WS2_32.106) 00690 */ 00691 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port, 00692 LPCSTR proto, LPSTR sbuf, INT buflen) 00693 { 00694 TRACE("hwnd %p, msg %04x, port %i, proto %s\n", 00695 hWnd, uMsg, port, (proto)?proto:"<null>" ); 00696 return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,sbuf,buflen, 00697 AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN32)); 00698 } Generated on Sun May 27 2012 04:27:05 for ReactOS by
1.7.6.1
|