Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 1 | /* Async WINSOCK DNS services |
| 2 | * |
| 3 | * (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka. |
| 4 | * (C) 1999 Marcus Meissner |
| 5 | * |
| 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). |
Rein Klazes | e9b2f3c | 2000-04-18 11:54:59 +0000 | [diff] [blame] | 20 | * - (Rein Klazes) Some structures returned (eg servent) are NOT correct in |
| 21 | * win32. The packing should be at 4 byte bounds. Same problem in socket.c |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #include "config.h" |
| 25 | |
| 26 | #include <string.h> |
| 27 | #include <sys/types.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 28 | #ifdef HAVE_SYS_IPC_H |
| 29 | # include <sys/ipc.h> |
| 30 | #endif |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 31 | #include <sys/ioctl.h> |
| 32 | #ifdef HAVE_SYS_FILIO_H |
| 33 | # include <sys/filio.h> |
| 34 | #endif |
| 35 | #if defined(__svr4__) |
| 36 | #include <sys/ioccom.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 37 | #ifdef HAVE_SYS_SOCKIO_H |
| 38 | # include <sys/sockio.h> |
| 39 | #endif |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 40 | #endif |
| 41 | |
| 42 | #if defined(__EMX__) |
| 43 | # include <sys/so_ioctl.h> |
| 44 | #endif |
| 45 | |
| 46 | #ifdef HAVE_SYS_PARAM_H |
| 47 | # include <sys/param.h> |
| 48 | #endif |
| 49 | |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 50 | #ifdef HAVE_SYS_MSG_H |
| 51 | # include <sys/msg.h> |
| 52 | #endif |
| 53 | #ifdef HAVE_SYS_WAIT_H |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 54 | #include <sys/wait.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 55 | #endif |
| 56 | #ifdef HAVE_SYS_SOCKET_H |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 57 | #include <sys/socket.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 58 | #endif |
| 59 | #ifdef HAVE_NETINET_IN_H |
| 60 | # include <netinet/in.h> |
| 61 | #endif |
| 62 | #ifdef HAVE_ARPA_INET_H |
| 63 | # include <arpa/inet.h> |
| 64 | #endif |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 65 | #include <ctype.h> |
| 66 | #include <fcntl.h> |
| 67 | #include <errno.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 68 | #ifdef HAVE_SYS_ERRNO_H |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 69 | #include <sys/errno.h> |
Patrik Stridvall | 2c92835 | 1999-10-31 02:07:54 +0000 | [diff] [blame] | 70 | #endif |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 71 | #include <netdb.h> |
| 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 |
| 80 | |
| 81 | #include "wine/winbase16.h" |
Patrik Stridvall | 6cc47d4 | 2000-03-08 18:26:56 +0000 | [diff] [blame] | 82 | #include "wingdi.h" |
| 83 | #include "winuser.h" |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 84 | #include "winsock.h" |
| 85 | #include "winnt.h" |
| 86 | #include "heap.h" |
| 87 | #include "task.h" |
| 88 | #include "message.h" |
| 89 | #include "miscemu.h" |
Patrik Stridvall | b901021 | 1999-11-13 22:23:35 +0000 | [diff] [blame] | 90 | #include "wine/port.h" |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 91 | #include "debugtools.h" |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 92 | |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 93 | DEFAULT_DEBUG_CHANNEL(winsock) |
| 94 | |
Rein Klazes | ce77ea9 | 2000-04-06 19:31:38 +0000 | [diff] [blame] | 95 | /* protoptypes of some functions in socket.c |
| 96 | */ |
| 97 | UINT16 wsaErrno(void); |
| 98 | UINT16 wsaHerrno(void); |
| 99 | |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 100 | /* ----------------------------------- helper functions - */ |
| 101 | |
| 102 | static int list_size(char** l, int item_size) |
| 103 | { |
| 104 | int i,j = 0; |
| 105 | if(l) |
| 106 | { for(i=0;l[i];i++) |
| 107 | j += (item_size) ? item_size : strlen(l[i]) + 1; |
| 108 | j += (i + 1) * sizeof(char*); } |
| 109 | return j; |
| 110 | } |
| 111 | |
| 112 | static int list_dup(char** l_src, char* ref, char* base, int item_size) |
| 113 | { |
| 114 | /* base is either either equal to ref or 0 or SEGPTR */ |
| 115 | |
| 116 | char* p = ref; |
| 117 | char** l_to = (char**)ref; |
| 118 | int i,j,k; |
| 119 | |
| 120 | for(j=0;l_src[j];j++) ; |
| 121 | p += (j + 1) * sizeof(char*); |
| 122 | for(i=0;i<j;i++) |
| 123 | { l_to[i] = base + (p - ref); |
| 124 | k = ( item_size ) ? item_size : strlen(l_src[i]) + 1; |
| 125 | memcpy(p, l_src[i], k); p += k; } |
| 126 | l_to[i] = NULL; |
| 127 | return (p - ref); |
| 128 | } |
| 129 | |
| 130 | /* ----- hostent */ |
| 131 | |
| 132 | static int hostent_size(struct hostent* p_he) |
| 133 | { |
| 134 | int size = 0; |
| 135 | if( p_he ) |
| 136 | { size = sizeof(struct hostent); |
| 137 | size += strlen(p_he->h_name) + 1; |
| 138 | size += list_size(p_he->h_aliases, 0); |
| 139 | size += list_size(p_he->h_addr_list, p_he->h_length ); } |
| 140 | return size; |
| 141 | } |
| 142 | |
| 143 | /* Copy hostent to p_to, fix up inside pointers using p_base (different for |
| 144 | * Win16 (linear vs. segmented). Return -neededsize on overrun. |
| 145 | */ |
| 146 | static int WS_copy_he(struct ws_hostent *p_to,char *p_base,int t_size,struct hostent* p_he) |
| 147 | { |
| 148 | char* p_name,*p_aliases,*p_addr,*p; |
| 149 | int size=hostent_size(p_he)+(sizeof(struct ws_hostent)-sizeof(struct hostent)); |
| 150 | |
| 151 | if (t_size < size) |
| 152 | return -size; |
| 153 | p = (char*)p_to; |
| 154 | p += sizeof(struct ws_hostent); |
| 155 | p_name = p; |
| 156 | strcpy(p, p_he->h_name); p += strlen(p) + 1; |
| 157 | p_aliases = p; |
| 158 | p += list_dup(p_he->h_aliases, p, p_base + (p - (char*)p_to), 0); |
| 159 | p_addr = p; |
| 160 | list_dup(p_he->h_addr_list, p, p_base + (p - (char*)p_to), p_he->h_length); |
| 161 | |
| 162 | p_to->h_addrtype = (INT16)p_he->h_addrtype; |
| 163 | p_to->h_length = (INT16)p_he->h_length; |
| 164 | p_to->h_name = (SEGPTR)(p_base + (p_name - (char*)p_to)); |
| 165 | p_to->h_aliases = (SEGPTR)(p_base + (p_aliases - (char*)p_to)); |
| 166 | p_to->h_addr_list = (SEGPTR)(p_base + (p_addr - (char*)p_to)); |
| 167 | |
| 168 | return size; |
| 169 | } |
| 170 | |
| 171 | /* ----- protoent */ |
| 172 | |
| 173 | static int protoent_size(struct protoent* p_pe) |
| 174 | { |
| 175 | int size = 0; |
| 176 | if( p_pe ) |
| 177 | { size = sizeof(struct protoent); |
| 178 | size += strlen(p_pe->p_name) + 1; |
| 179 | size += list_size(p_pe->p_aliases, 0); } |
| 180 | return size; |
| 181 | } |
| 182 | |
| 183 | /* Copy protoent to p_to, fix up inside pointers using p_base (different for |
| 184 | * Win16 (linear vs. segmented). Return -neededsize on overrun. |
| 185 | */ |
| 186 | static int WS_copy_pe(struct ws_protoent *p_to,char *p_base,int t_size,struct protoent* p_pe) |
| 187 | { |
| 188 | char* p_name,*p_aliases,*p; |
| 189 | int size=protoent_size(p_pe)+(sizeof(struct ws_protoent)-sizeof(struct protoent)); |
| 190 | |
| 191 | if (t_size < size) |
| 192 | return -size; |
| 193 | p = (char*)p_to; |
| 194 | p += sizeof(struct ws_protoent); |
| 195 | p_name = p; |
| 196 | strcpy(p, p_pe->p_name); p += strlen(p) + 1; |
| 197 | p_aliases = p; |
| 198 | list_dup(p_pe->p_aliases, p, p_base + (p - (char*)p_to), 0); |
| 199 | |
| 200 | p_to->p_proto = (INT16)p_pe->p_proto; |
| 201 | p_to->p_name = (SEGPTR)(p_base) + (p_name - (char*)p_to); |
| 202 | p_to->p_aliases = (SEGPTR)((p_base) + (p_aliases - (char*)p_to)); |
| 203 | |
| 204 | |
| 205 | return size; |
| 206 | } |
| 207 | |
| 208 | /* ----- servent */ |
| 209 | |
| 210 | static int servent_size(struct servent* p_se) |
| 211 | { |
| 212 | int size = 0; |
| 213 | if( p_se ) { |
| 214 | size += sizeof(struct servent); |
| 215 | size += strlen(p_se->s_proto) + strlen(p_se->s_name) + 2; |
| 216 | size += list_size(p_se->s_aliases, 0); |
| 217 | } |
| 218 | return size; |
| 219 | } |
| 220 | |
| 221 | /* Copy servent to p_to, fix up inside pointers using p_base (different for |
| 222 | * Win16 (linear vs. segmented). Return -neededsize on overrun. |
| 223 | */ |
| 224 | static int WS_copy_se(struct ws_servent *p_to,char *p_base,int t_size,struct servent* p_se) |
| 225 | { |
| 226 | char* p_name,*p_aliases,*p_proto,*p; |
| 227 | int size = servent_size(p_se)+(sizeof(struct ws_servent)-sizeof(struct servent)); |
| 228 | |
| 229 | if (t_size < size ) |
| 230 | return -size; |
| 231 | p = (char*)p_to; |
| 232 | p += sizeof(struct ws_servent); |
| 233 | p_name = p; |
| 234 | strcpy(p, p_se->s_name); p += strlen(p) + 1; |
| 235 | p_proto = p; |
| 236 | strcpy(p, p_se->s_proto); p += strlen(p) + 1; |
| 237 | p_aliases = p; |
| 238 | list_dup(p_se->s_aliases, p, p_base + (p - (char*)p_to), 0); |
| 239 | |
| 240 | p_to->s_port = (INT16)p_se->s_port; |
| 241 | p_to->s_name = (SEGPTR)(p_base + (p_name - (char*)p_to)); |
| 242 | p_to->s_proto = (SEGPTR)(p_base + (p_proto - (char*)p_to)); |
| 243 | p_to->s_aliases = (SEGPTR)(p_base + (p_aliases - (char*)p_to)); |
| 244 | |
| 245 | return size; |
| 246 | } |
| 247 | |
| 248 | static HANDLE __ws_async_handle = 0xdead; |
| 249 | |
| 250 | /* Generic async query struct. we use symbolic names for the different queries |
| 251 | * for readability. |
| 252 | */ |
| 253 | typedef struct _async_query { |
| 254 | HWND16 hWnd; |
| 255 | UINT16 uMsg; |
| 256 | LPCSTR ptr1; |
| 257 | #define host_name ptr1 |
| 258 | #define host_addr ptr1 |
| 259 | #define serv_name ptr1 |
| 260 | #define proto_name ptr1 |
| 261 | LPCSTR ptr2; |
| 262 | #define serv_proto ptr2 |
| 263 | int int1; |
| 264 | #define host_len int1 |
| 265 | #define proto_number int1 |
| 266 | #define serv_port int1 |
| 267 | int int2; |
| 268 | #define host_type int2 |
| 269 | SEGPTR sbuf; |
| 270 | INT16 sbuflen; |
| 271 | |
| 272 | HANDLE16 async_handle; |
| 273 | int flags; |
| 274 | #define AQ_WIN16 0 |
| 275 | #define AQ_WIN32 4 |
| 276 | #define HB_WIN32(hb) (hb->flags & AQ_WIN32) |
| 277 | #define AQ_NUMBER 0 |
| 278 | #define AQ_NAME 8 |
| 279 | |
| 280 | #define AQ_GETHOST 0 |
| 281 | #define AQ_GETPROTO 1 |
| 282 | #define AQ_GETSERV 2 |
| 283 | #define AQ_GETMASK 3 |
| 284 | int qt; |
Rein Klazes | e9b2f3c | 2000-04-18 11:54:59 +0000 | [diff] [blame] | 285 | char xbuf[1]; |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 286 | } async_query; |
| 287 | |
Rein Klazes | e9b2f3c | 2000-04-18 11:54:59 +0000 | [diff] [blame] | 288 | |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 289 | /**************************************************************************** |
| 290 | * The async query function. |
| 291 | * |
| 292 | * It is either called as a thread startup routine or directly. It has |
| 293 | * to free the passed arg from the process heap and PostMessageA the async |
| 294 | * result or the error code. |
| 295 | * |
| 296 | * FIXME: |
| 297 | * - errorhandling not verified. |
| 298 | */ |
| 299 | static DWORD WINAPI _async_queryfun(LPVOID arg) { |
| 300 | async_query *aq = (async_query*)arg; |
| 301 | int size = 0; |
| 302 | WORD fail = 0; |
| 303 | char *targetptr = (HB_WIN32(aq)?(char*)aq->sbuf:(char*)PTR_SEG_TO_LIN(aq->sbuf)); |
| 304 | |
| 305 | switch (aq->flags & AQ_GETMASK) { |
| 306 | case AQ_GETHOST: { |
| 307 | struct hostent *he; |
| 308 | struct ws_hostent *wshe = (struct ws_hostent*)targetptr; |
| 309 | |
| 310 | he = (aq->flags & AQ_NAME) ? |
| 311 | gethostbyname(aq->host_name): |
| 312 | gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type); |
| 313 | if (he) { |
| 314 | size = WS_copy_he(wshe,(char*)aq->sbuf,aq->sbuflen,he); |
| 315 | if (size < 0) { |
| 316 | fail = WSAENOBUFS; |
| 317 | size = -size; |
| 318 | } |
| 319 | } else { |
Rein Klazes | ce77ea9 | 2000-04-06 19:31:38 +0000 | [diff] [blame] | 320 | fail = ((h_errno < 0) ? wsaErrno() : wsaHerrno()); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | break; |
| 324 | case AQ_GETPROTO: { |
| 325 | struct protoent *pe; |
| 326 | struct ws_protoent *wspe = (struct ws_protoent*)targetptr; |
| 327 | pe = (aq->flags & AQ_NAME)? |
| 328 | getprotobyname(aq->proto_name) : |
| 329 | getprotobynumber(aq->proto_number); |
| 330 | if (pe) { |
| 331 | size = WS_copy_pe(wspe,(char*)aq->sbuf,aq->sbuflen,pe); |
| 332 | if (size < 0) { |
| 333 | fail = WSAENOBUFS; |
| 334 | size = -size; |
| 335 | } |
| 336 | } else { |
Rein Klazes | ce77ea9 | 2000-04-06 19:31:38 +0000 | [diff] [blame] | 337 | if (aq->flags & AQ_NAME) |
| 338 | MESSAGE("protocol %s not found; You might want to add " |
| 339 | "this to /etc/protocols\n", debugstr_a(aq->proto_name) ); |
| 340 | else |
| 341 | MESSAGE("protocol number %d not found; You might want to add " |
| 342 | "this to /etc/protocols\n", aq->proto_number ); |
| 343 | fail = WSANO_DATA; |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | break; |
| 347 | case AQ_GETSERV: { |
| 348 | struct servent *se; |
| 349 | struct ws_servent *wsse = (struct ws_servent*)targetptr; |
| 350 | se = (aq->flags & AQ_NAME)? |
| 351 | getservbyname(aq->serv_name,aq->serv_proto) : |
| 352 | getservbyport(aq->serv_port,aq->serv_proto); |
| 353 | if (se) { |
| 354 | size = WS_copy_se(wsse,(char*)aq->sbuf,aq->sbuflen,se); |
| 355 | if (size < 0) { |
| 356 | fail = WSAENOBUFS; |
| 357 | size = -size; |
| 358 | } |
| 359 | } else { |
Rein Klazes | ce77ea9 | 2000-04-06 19:31:38 +0000 | [diff] [blame] | 360 | if (aq->flags & AQ_NAME) |
| 361 | MESSAGE("service %s protocol %s not found; You might want to add " |
| 362 | "this to /etc/services\n", debugstr_a(aq->serv_name) , |
| 363 | aq->serv_proto ? debugstr_a(aq->serv_proto ):"*"); |
| 364 | else |
| 365 | MESSAGE("service on port %d protocol %s not found; You might want to add " |
| 366 | "this to /etc/services\n", aq->serv_port, |
| 367 | aq->serv_proto ? debugstr_a(aq->serv_proto ):"*"); |
| 368 | fail = WSANO_DATA; |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | break; |
| 372 | } |
| 373 | PostMessageA(aq->hWnd,aq->uMsg,aq->async_handle,size|(fail<<16)); |
| 374 | HeapFree(GetProcessHeap(),0,arg); |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | /**************************************************************************** |
| 379 | * The main async help function. |
| 380 | * |
| 381 | * It either starts a thread or just calls the function directly for platforms |
| 382 | * with no thread support. This relies on the fact that PostMessage() does |
| 383 | * not actually call the windowproc before the function returns. |
| 384 | */ |
| 385 | static HANDLE16 __WSAsyncDBQuery( |
| 386 | HWND hWnd, UINT uMsg,INT int1,LPCSTR ptr1, INT int2, LPCSTR ptr2, |
| 387 | void *sbuf, INT sbuflen, UINT flags |
Rein Klazes | e9b2f3c | 2000-04-18 11:54:59 +0000 | [diff] [blame] | 388 | ) |
| 389 | { |
| 390 | async_query *aq; |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 391 | HANDLE hthread; |
| 392 | |
Rein Klazes | e9b2f3c | 2000-04-18 11:54:59 +0000 | [diff] [blame] | 393 | int xbuflen=0; |
| 394 | /* allocate buffer to copy protocol- and service name to */ |
| 395 | /* note: this is done in the calling thread so we can return */ |
| 396 | /* a decent error code if the Alloc fails */ |
| 397 | |
| 398 | if( flags & (AQ_GETPROTO | AQ_GETSERV)) { |
| 399 | if(ptr1) xbuflen += strlen(ptr1)+1; |
| 400 | if(ptr2) xbuflen += strlen(ptr2)+1; |
| 401 | } |
| 402 | |
| 403 | aq = HeapAlloc(GetProcessHeap(),0,sizeof(async_query) + xbuflen); |
| 404 | if(!aq) { |
| 405 | SetLastError(WSAEWOULDBLOCK); /* insufficient resources */ |
| 406 | return 0; |
| 407 | } |
| 408 | /* convert protocol- and service names to lower case */ |
| 409 | if( flags & (AQ_GETPROTO | AQ_GETSERV)) { |
| 410 | const char *pfrom; |
| 411 | char *pto=aq->xbuf; |
| 412 | if(ptr1) { |
| 413 | pfrom=ptr1; |
| 414 | ptr1=pto; |
| 415 | do *pto++ = tolower(*pfrom); |
| 416 | while (*pfrom++); |
| 417 | } |
| 418 | if(ptr2) { |
| 419 | pfrom=ptr2; |
| 420 | ptr2=pto; |
| 421 | do *pto++ = tolower(*pfrom); |
| 422 | while (*pfrom++); |
| 423 | } |
| 424 | } |
| 425 | |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 426 | aq->hWnd = hWnd; |
| 427 | aq->uMsg = uMsg; |
| 428 | aq->int1 = int1; |
| 429 | aq->ptr1 = ptr1; |
| 430 | aq->int2 = int2; |
| 431 | aq->ptr2 = ptr2; |
| 432 | aq->async_handle = ++__ws_async_handle; |
| 433 | aq->flags = flags; |
| 434 | aq->sbuf = (SEGPTR)sbuf; |
| 435 | aq->sbuflen = sbuflen; |
| 436 | #if 1 |
Michael Veksler | 58abac3 | 1999-04-16 09:41:22 +0000 | [diff] [blame] | 437 | hthread = CreateThread(NULL,0,_async_queryfun,aq,0,NULL); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 438 | if (hthread==INVALID_HANDLE_VALUE) |
| 439 | #endif |
| 440 | _async_queryfun(aq); |
| 441 | return __ws_async_handle; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | /*********************************************************************** |
| 446 | * WSAAsyncGetHostByAddr() (WINSOCK.102) |
| 447 | */ |
| 448 | HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 uMsg, LPCSTR addr, |
| 449 | INT16 len, INT16 type, SEGPTR sbuf, INT16 buflen) |
| 450 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 451 | TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 452 | hWnd, uMsg, (unsigned)addr , len ); |
| 453 | return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,(void*)sbuf,buflen,AQ_NUMBER|AQ_WIN16|AQ_GETHOST); |
| 454 | } |
| 455 | |
| 456 | /*********************************************************************** |
| 457 | * WSAAsyncGetHostByAddr() (WSOCK32.102) |
| 458 | */ |
| 459 | HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr, |
| 460 | INT len, INT type, LPSTR sbuf, INT buflen) |
| 461 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 462 | TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 463 | hWnd, uMsg, (unsigned)addr , len ); |
| 464 | return __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,sbuf,buflen,AQ_NUMBER|AQ_WIN32|AQ_GETHOST); |
| 465 | } |
| 466 | |
| 467 | /*********************************************************************** |
| 468 | * WSAAsyncGetHostByName() (WINSOCK.103) |
| 469 | */ |
| 470 | HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, |
| 471 | SEGPTR sbuf, INT16 buflen) |
| 472 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 473 | TRACE("hwnd %04x, msg %04x, host %s, buffer %i\n", hWnd, uMsg, (name)?name:"<null>", (int)buflen ); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 474 | |
| 475 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,AQ_NAME|AQ_WIN16|AQ_GETHOST); |
| 476 | } |
| 477 | |
| 478 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 479 | * WSAAsyncGetHostByName() (WSOCK32.103) |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 480 | */ |
| 481 | HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name, |
| 482 | LPSTR sbuf, INT buflen) |
| 483 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 484 | TRACE("hwnd %04x, msg %08x, host %s, buffer %i\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 485 | (HWND16)hWnd, uMsg, (name)?name:"<null>", (int)buflen ); |
| 486 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,AQ_NAME|AQ_WIN32|AQ_GETHOST); |
| 487 | } |
| 488 | |
| 489 | /*********************************************************************** |
| 490 | * WSAAsyncGetProtoByName() (WINSOCK.105) |
| 491 | */ |
| 492 | HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, |
| 493 | SEGPTR sbuf, INT16 buflen) |
| 494 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 495 | TRACE("hwnd %04x, msg %08x, protocol %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 496 | (HWND16)hWnd, uMsg, (name)?name:"<null>" ); |
| 497 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,(void*)sbuf,buflen,AQ_GETPROTO|AQ_NAME|AQ_WIN16); |
| 498 | } |
| 499 | |
| 500 | /*********************************************************************** |
| 501 | * WSAAsyncGetProtoByName() (WSOCK32.105) |
| 502 | */ |
| 503 | HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name, |
| 504 | LPSTR sbuf, INT buflen) |
| 505 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 506 | TRACE("hwnd %04x, msg %08x, protocol %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 507 | (HWND16)hWnd, uMsg, (name)?name:"<null>" ); |
| 508 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,AQ_GETPROTO|AQ_NAME|AQ_WIN32); |
| 509 | } |
| 510 | |
| 511 | |
| 512 | /*********************************************************************** |
| 513 | * WSAAsyncGetProtoByNumber() (WINSOCK.104) |
| 514 | */ |
| 515 | HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd,UINT16 uMsg,INT16 number, |
| 516 | SEGPTR sbuf, INT16 buflen) |
| 517 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 518 | TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number ); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 519 | return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,(void*)sbuf,buflen,AQ_GETPROTO|AQ_NUMBER|AQ_WIN16); |
| 520 | } |
| 521 | |
| 522 | /*********************************************************************** |
| 523 | * WSAAsyncGetProtoByNumber() (WSOCK32.104) |
| 524 | */ |
| 525 | HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number, |
| 526 | LPSTR sbuf, INT buflen) |
| 527 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 528 | TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number ); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 529 | |
| 530 | return __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,sbuf,buflen,AQ_GETPROTO|AQ_NUMBER|AQ_WIN32); |
| 531 | } |
| 532 | |
| 533 | /*********************************************************************** |
| 534 | * WSAAsyncGetServByName() (WINSOCK.107) |
| 535 | */ |
| 536 | HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name, |
| 537 | LPCSTR proto, SEGPTR sbuf, INT16 buflen) |
| 538 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 539 | TRACE("hwnd %04x, msg %04x, name %s, proto %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 540 | hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>" ); |
| 541 | |
| 542 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,(void*)sbuf,buflen,AQ_GETSERV|AQ_NAME|AQ_WIN16); |
| 543 | } |
| 544 | |
| 545 | /*********************************************************************** |
| 546 | * WSAAsyncGetServByName() (WSOCK32.107) |
| 547 | */ |
| 548 | HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, |
| 549 | LPCSTR proto, LPSTR sbuf, INT buflen) |
| 550 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 551 | TRACE("hwnd %04x, msg %04x, name %s, proto %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 552 | hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>" ); |
| 553 | return __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,sbuf,buflen,AQ_GETSERV|AQ_NAME|AQ_WIN32); |
| 554 | } |
| 555 | |
| 556 | /*********************************************************************** |
| 557 | * WSAAsyncGetServByPort() (WINSOCK.106) |
| 558 | */ |
| 559 | HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port, |
| 560 | LPCSTR proto, SEGPTR sbuf, INT16 buflen) |
| 561 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 562 | TRACE("hwnd %04x, msg %04x, port %i, proto %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 563 | hWnd, uMsg, port, (proto)?proto:"<null>" ); |
| 564 | return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,(void*)sbuf,buflen,AQ_GETSERV|AQ_NUMBER|AQ_WIN16); |
| 565 | } |
| 566 | |
| 567 | /*********************************************************************** |
| 568 | * WSAAsyncGetServByPort() (WSOCK32.106) |
| 569 | */ |
| 570 | HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port, |
| 571 | LPCSTR proto, LPSTR sbuf, INT buflen) |
| 572 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 573 | TRACE("hwnd %04x, msg %04x, port %i, proto %s\n", |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 574 | hWnd, uMsg, port, (proto)?proto:"<null>" ); |
| 575 | return __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,sbuf,buflen,AQ_GETSERV|AQ_NUMBER|AQ_WIN32); |
| 576 | } |
| 577 | |
| 578 | /*********************************************************************** |
| 579 | * WSACancelAsyncRequest() (WINSOCK.108)(WSOCK32.109) |
| 580 | */ |
| 581 | INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle) |
| 582 | { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 583 | FIXME("(%08x),stub\n", hAsyncTaskHandle); |
Marcus Meissner | bdb6bec | 1999-04-10 16:58:55 +0000 | [diff] [blame] | 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle) |
| 588 | { |
| 589 | return (HANDLE16)WSACancelAsyncRequest((HANDLE)hAsyncTaskHandle); |
| 590 | } |