mirror of
https://github.com/reactos/reactos.git
synced 2025-07-06 03:11:22 +00:00
[WS2_32]
- Sync async.c to Wine 1.5.4. Fixes crash in ws2_32:sock svn path=/trunk/; revision=56784
This commit is contained in:
parent
0397391d51
commit
99944e4408
2 changed files with 264 additions and 518 deletions
|
@ -2,6 +2,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
|
* Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
|
||||||
* Copyright (C) 1999 Marcus Meissner
|
* Copyright (C) 1999 Marcus Meissner
|
||||||
|
* Copyright (C) 2009 Alexandre Julliard
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -35,117 +36,71 @@
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define WS_FD_SETSIZE FD_SETSIZE
|
|
||||||
typedef struct hostent WS_hostent;
|
|
||||||
typedef struct servent WS_servent;
|
|
||||||
typedef struct protoent WS_protoent;
|
|
||||||
|
|
||||||
#include "wine/config.h"
|
#include "wine/config.h"
|
||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
|
|
||||||
#ifndef __REACTOS__
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#ifdef HAVE_SYS_IPC_H
|
|
||||||
# include <sys/ipc.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_FILIO_H
|
|
||||||
# include <sys/filio.h>
|
|
||||||
#endif
|
|
||||||
#if defined(__svr4__)
|
|
||||||
#include <sys/ioccom.h>
|
|
||||||
#ifdef HAVE_SYS_SOCKIO_H
|
|
||||||
# include <sys/sockio.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__EMX__)
|
|
||||||
# include <sys/so_ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_PARAM_H
|
|
||||||
# include <sys/param.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_MSG_H
|
|
||||||
# include <sys/msg.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_WAIT_H
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#ifdef HAVE_SYS_ERRNO_H
|
|
||||||
#include <sys/errno.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_RESOLV_H
|
|
||||||
# include <resolv.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wine/winbase16.h"
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "wingdi.h"
|
#include "wingdi.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
#include "winsock2.h"
|
#include "winsock2.h"
|
||||||
#include "ws2spi.h"
|
#include "ws2spi.h"
|
||||||
#include "wownt32.h"
|
|
||||||
#include "wine/winsock16.h"
|
|
||||||
#include "winnt.h"
|
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
|
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
|
||||||
|
|
||||||
|
|
||||||
/* protoptypes of some functions in socket.c
|
struct async_query_header
|
||||||
*/
|
{
|
||||||
|
HWND hWnd;
|
||||||
|
UINT uMsg;
|
||||||
|
void *sbuf;
|
||||||
|
INT sbuflen;
|
||||||
|
HANDLE handle;
|
||||||
|
};
|
||||||
|
|
||||||
#define AQ_WIN16 0x00
|
struct async_query_gethostbyname
|
||||||
#define AQ_WIN32 0x04
|
{
|
||||||
#define HB_WIN32(hb) (hb->flags & AQ_WIN32)
|
struct async_query_header query;
|
||||||
#define AQ_NUMBER 0x00
|
char *host_name;
|
||||||
#define AQ_NAME 0x08
|
};
|
||||||
#define AQ_COPYPTR1 0x10
|
|
||||||
#define AQ_DUPLOWPTR1 0x20
|
|
||||||
#define AQ_MASKPTR1 0x30
|
|
||||||
#define AQ_COPYPTR2 0x40
|
|
||||||
#define AQ_DUPLOWPTR2 0x80
|
|
||||||
#define AQ_MASKPTR2 0xC0
|
|
||||||
|
|
||||||
#define AQ_GETHOST 0
|
struct async_query_gethostbyaddr
|
||||||
#define AQ_GETPROTO 1
|
{
|
||||||
#define AQ_GETSERV 2
|
struct async_query_header query;
|
||||||
#define AQ_GETMASK 3
|
char *host_addr;
|
||||||
|
int host_len;
|
||||||
|
int host_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct async_query_getprotobyname
|
||||||
|
{
|
||||||
|
struct async_query_header query;
|
||||||
|
char *proto_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct async_query_getprotobynumber
|
||||||
|
{
|
||||||
|
struct async_query_header query;
|
||||||
|
int proto_number;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct async_query_getservbyname
|
||||||
|
{
|
||||||
|
struct async_query_header query;
|
||||||
|
char *serv_name;
|
||||||
|
char *serv_proto;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct async_query_getservbyport
|
||||||
|
{
|
||||||
|
struct async_query_header query;
|
||||||
|
char *serv_proto;
|
||||||
|
int serv_port;
|
||||||
|
};
|
||||||
|
|
||||||
/* The handles used are pseudo-handles that can be simply casted. */
|
|
||||||
/* 16-bit values are used internally (to be sure handle comparison works right in 16-bit apps). */
|
|
||||||
#define WSA_H32(h16) ((HANDLE)(ULONG_PTR)(h16))
|
|
||||||
|
|
||||||
/* ----------------------------------- helper functions - */
|
/* ----------------------------------- helper functions - */
|
||||||
|
|
||||||
|
@ -159,10 +114,8 @@ static int list_size(char** l, int item_size)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int list_dup(char** l_src, char* ref, char* base, int item_size)
|
static int list_dup(char** l_src, char* ref, int item_size)
|
||||||
{
|
{
|
||||||
/* base is either either equal to ref or 0 or SEGPTR */
|
|
||||||
|
|
||||||
char* p = ref;
|
char* p = ref;
|
||||||
char** l_to = (char**)ref;
|
char** l_to = (char**)ref;
|
||||||
int i,j,k;
|
int i,j,k;
|
||||||
|
@ -170,314 +123,142 @@ static int list_dup(char** l_src, char* ref, char* base, int item_size)
|
||||||
for(j=0;l_src[j];j++) ;
|
for(j=0;l_src[j];j++) ;
|
||||||
p += (j + 1) * sizeof(char*);
|
p += (j + 1) * sizeof(char*);
|
||||||
for(i=0;i<j;i++)
|
for(i=0;i<j;i++)
|
||||||
{ l_to[i] = base + (p - ref);
|
{ l_to[i] = p;
|
||||||
k = ( item_size ) ? item_size : strlen(l_src[i]) + 1;
|
k = ( item_size ) ? item_size : strlen(l_src[i]) + 1;
|
||||||
memcpy(p, l_src[i], k); p += k; }
|
memcpy(p, l_src[i], k); p += k; }
|
||||||
l_to[i] = NULL;
|
l_to[i] = NULL;
|
||||||
return (p - ref);
|
return (p - ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----- hostent */
|
static DWORD finish_query( struct async_query_header *query, LPARAM lparam )
|
||||||
|
|
||||||
static int hostent_size(struct hostent* p_he)
|
|
||||||
{
|
{
|
||||||
int size = 0;
|
PostMessageW( query->hWnd, query->uMsg, (WPARAM)query->handle, lparam );
|
||||||
if( p_he )
|
HeapFree( GetProcessHeap(), 0, query );
|
||||||
{ size = sizeof(struct hostent);
|
return 0;
|
||||||
size += strlen(p_he->h_name) + 1;
|
|
||||||
size += list_size(p_he->h_aliases, 0);
|
|
||||||
size += list_size(p_he->h_addr_list, p_he->h_length ); }
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy hostent to p_to, fix up inside pointers using p_base (different for
|
/* ----- hostent */
|
||||||
* Win16 (linear vs. segmented). Return -neededsize on overrun.
|
|
||||||
*/
|
static LPARAM copy_he(void *base, int size, const struct hostent *he)
|
||||||
static int WS_copy_he(char *p_to,char *p_base,int t_size,struct hostent* p_he, int flag)
|
|
||||||
{
|
{
|
||||||
char* p_name,*p_aliases,*p_addr,*p;
|
char *p;
|
||||||
struct ws_hostent16 *p_to16 = (struct ws_hostent16*)p_to;
|
int needed;
|
||||||
WS_hostent *p_to32 = (WS_hostent*)p_to;
|
struct hostent *to = base;
|
||||||
int size = hostent_size(p_he) +
|
|
||||||
(
|
|
||||||
(flag & AQ_WIN32) ? sizeof(WS_hostent) : sizeof(struct ws_hostent16)
|
|
||||||
- sizeof(struct hostent)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (t_size < size)
|
if (!he) return MAKELPARAM( 0, GetLastError() );
|
||||||
return -size;
|
|
||||||
p = p_to;
|
|
||||||
p += (flag & AQ_WIN32) ?
|
|
||||||
sizeof(WS_hostent) : sizeof(struct ws_hostent16);
|
|
||||||
p_name = p;
|
|
||||||
strcpy(p, p_he->h_name); p += strlen(p) + 1;
|
|
||||||
p_aliases = p;
|
|
||||||
p += list_dup(p_he->h_aliases, p, p_base + (p - p_to), 0);
|
|
||||||
p_addr = p;
|
|
||||||
list_dup(p_he->h_addr_list, p, p_base + (p - p_to), p_he->h_length);
|
|
||||||
|
|
||||||
if (flag & AQ_WIN32)
|
needed = sizeof(struct hostent) + strlen(he->h_name) + 1 +
|
||||||
{
|
list_size(he->h_aliases, 0) +
|
||||||
p_to32->h_addrtype = p_he->h_addrtype;
|
list_size(he->h_addr_list, he->h_length );
|
||||||
p_to32->h_length = p_he->h_length;
|
if (size < needed) return MAKELPARAM( needed, WSAENOBUFS );
|
||||||
p_to32->h_name = (p_base + (p_name - p_to));
|
|
||||||
p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to));
|
|
||||||
p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_to16->h_addrtype = (INT16)p_he->h_addrtype;
|
|
||||||
p_to16->h_length = (INT16)p_he->h_length;
|
|
||||||
p_to16->h_name = (SEGPTR)(p_base + (p_name - p_to));
|
|
||||||
p_to16->h_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
|
|
||||||
p_to16->h_addr_list = (SEGPTR)(p_base + (p_addr - p_to));
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
to->h_addrtype = he->h_addrtype;
|
||||||
|
to->h_length = he->h_length;
|
||||||
|
p = (char *)(to + 1);
|
||||||
|
to->h_name = p;
|
||||||
|
strcpy(p, he->h_name); p += strlen(p) + 1;
|
||||||
|
to->h_aliases = (char **)p;
|
||||||
|
p += list_dup(he->h_aliases, p, 0);
|
||||||
|
to->h_addr_list = (char **)p;
|
||||||
|
list_dup(he->h_addr_list, p, he->h_length);
|
||||||
|
return MAKELPARAM( needed, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI async_gethostbyname(LPVOID arg)
|
||||||
|
{
|
||||||
|
struct async_query_gethostbyname *aq = arg;
|
||||||
|
struct hostent *he = gethostbyname( aq->host_name );
|
||||||
|
|
||||||
|
return finish_query( &aq->query, copy_he( aq->query.sbuf, aq->query.sbuflen, he ));
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI async_gethostbyaddr(LPVOID arg)
|
||||||
|
{
|
||||||
|
struct async_query_gethostbyaddr *aq = arg;
|
||||||
|
struct hostent *he = gethostbyaddr( aq->host_addr, aq->host_len, aq->host_type );
|
||||||
|
|
||||||
|
return finish_query( &aq->query, copy_he( aq->query.sbuf, aq->query.sbuflen, he ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----- protoent */
|
/* ----- protoent */
|
||||||
|
|
||||||
static int protoent_size(struct protoent* p_pe)
|
static LPARAM copy_pe(void *base, int size, const struct protoent* pe)
|
||||||
{
|
{
|
||||||
int size = 0;
|
char *p;
|
||||||
if( p_pe )
|
int needed;
|
||||||
{ size = sizeof(struct protoent);
|
struct protoent *to = base;
|
||||||
size += strlen(p_pe->p_name) + 1;
|
|
||||||
size += list_size(p_pe->p_aliases, 0); }
|
if (!pe) return MAKELPARAM( 0, GetLastError() );
|
||||||
return size;
|
|
||||||
|
needed = sizeof(struct protoent) + strlen(pe->p_name) + 1 + list_size(pe->p_aliases, 0);
|
||||||
|
if (size < needed) return MAKELPARAM( needed, WSAENOBUFS );
|
||||||
|
|
||||||
|
to->p_proto = pe->p_proto;
|
||||||
|
p = (char *)(to + 1);
|
||||||
|
to->p_name = p;
|
||||||
|
strcpy(p, pe->p_name); p += strlen(p) + 1;
|
||||||
|
to->p_aliases = (char **)p;
|
||||||
|
list_dup(pe->p_aliases, p, 0);
|
||||||
|
return MAKELPARAM( needed, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy protoent to p_to, fix up inside pointers using p_base (different for
|
static DWORD WINAPI async_getprotobyname(LPVOID arg)
|
||||||
* Win16 (linear vs. segmented). Return -neededsize on overrun.
|
|
||||||
*/
|
|
||||||
static int WS_copy_pe(char *p_to,char *p_base,int t_size,struct protoent* p_pe, int flag)
|
|
||||||
{
|
{
|
||||||
char* p_name,*p_aliases,*p;
|
struct async_query_getprotobyname *aq = arg;
|
||||||
struct ws_protoent16 *p_to16 = (struct ws_protoent16*)p_to;
|
struct protoent *pe = getprotobyname( aq->proto_name );
|
||||||
WS_protoent *p_to32 = (WS_protoent*)p_to;
|
|
||||||
int size = protoent_size(p_pe) +
|
|
||||||
(
|
|
||||||
(flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16)
|
|
||||||
- sizeof(struct protoent)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (t_size < size)
|
return finish_query( &aq->query, copy_pe( aq->query.sbuf, aq->query.sbuflen, pe ));
|
||||||
return -size;
|
}
|
||||||
p = p_to;
|
|
||||||
p += (flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16);
|
|
||||||
p_name = p;
|
|
||||||
strcpy(p, p_pe->p_name); p += strlen(p) + 1;
|
|
||||||
p_aliases = p;
|
|
||||||
list_dup(p_pe->p_aliases, p, p_base + (p - p_to), 0);
|
|
||||||
|
|
||||||
if (flag & AQ_WIN32)
|
static DWORD WINAPI async_getprotobynumber(LPVOID arg)
|
||||||
{
|
{
|
||||||
p_to32->p_proto = p_pe->p_proto;
|
struct async_query_getprotobynumber *aq = arg;
|
||||||
p_to32->p_name = (p_base) + (p_name - p_to);
|
struct protoent *pe = getprotobynumber( aq->proto_number );
|
||||||
p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_to16->p_proto = (INT16)p_pe->p_proto;
|
|
||||||
p_to16->p_name = (SEGPTR)(p_base) + (p_name - p_to);
|
|
||||||
p_to16->p_aliases = (SEGPTR)((p_base) + (p_aliases - p_to));
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
return finish_query( &aq->query, copy_pe( aq->query.sbuf, aq->query.sbuflen, pe ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----- servent */
|
/* ----- servent */
|
||||||
|
|
||||||
static int servent_size(struct servent* p_se)
|
static LPARAM copy_se(void *base, int size, const struct servent* se)
|
||||||
{
|
{
|
||||||
int size = 0;
|
char *p;
|
||||||
if( p_se ) {
|
int needed;
|
||||||
size += sizeof(struct servent);
|
struct servent *to = base;
|
||||||
size += strlen(p_se->s_proto) + strlen(p_se->s_name) + 2;
|
|
||||||
size += list_size(p_se->s_aliases, 0);
|
if (!se) return MAKELPARAM( 0, GetLastError() );
|
||||||
}
|
|
||||||
return size;
|
needed = sizeof(struct servent) + strlen(se->s_proto) + strlen(se->s_name) + 2 + list_size(se->s_aliases, 0);
|
||||||
|
if (size < needed) return MAKELPARAM( needed, WSAENOBUFS );
|
||||||
|
|
||||||
|
to->s_port = se->s_port;
|
||||||
|
p = (char *)(to + 1);
|
||||||
|
to->s_name = p;
|
||||||
|
strcpy(p, se->s_name); p += strlen(p) + 1;
|
||||||
|
to->s_proto = p;
|
||||||
|
strcpy(p, se->s_proto); p += strlen(p) + 1;
|
||||||
|
to->s_aliases = (char **)p;
|
||||||
|
list_dup(se->s_aliases, p, 0);
|
||||||
|
return MAKELPARAM( needed, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy servent to p_to, fix up inside pointers using p_base (different for
|
static DWORD WINAPI async_getservbyname(LPVOID arg)
|
||||||
* Win16 (linear vs. segmented). Return -neededsize on overrun.
|
|
||||||
* Take care of different Win16/Win32 servent structs (packing !)
|
|
||||||
*/
|
|
||||||
static int WS_copy_se(char *p_to,char *p_base,int t_size,struct servent* p_se, int flag)
|
|
||||||
{
|
{
|
||||||
char* p_name,*p_aliases,*p_proto,*p;
|
struct async_query_getservbyname *aq = arg;
|
||||||
struct ws_servent16 *p_to16 = (struct ws_servent16*)p_to;
|
struct servent *se = getservbyname( aq->serv_name, aq->serv_proto );
|
||||||
WS_servent *p_to32 = (WS_servent*)p_to;
|
|
||||||
int size = servent_size(p_se) +
|
|
||||||
(
|
|
||||||
(flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16)
|
|
||||||
- sizeof(struct servent)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (t_size < size)
|
return finish_query( &aq->query, copy_se( aq->query.sbuf, aq->query.sbuflen, se ));
|
||||||
return -size;
|
|
||||||
p = p_to;
|
|
||||||
p += (flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16);
|
|
||||||
p_name = p;
|
|
||||||
strcpy(p, p_se->s_name); p += strlen(p) + 1;
|
|
||||||
p_proto = p;
|
|
||||||
strcpy(p, p_se->s_proto); p += strlen(p) + 1;
|
|
||||||
p_aliases = p;
|
|
||||||
list_dup(p_se->s_aliases, p, p_base + (p - p_to), 0);
|
|
||||||
|
|
||||||
if (flag & AQ_WIN32)
|
|
||||||
{
|
|
||||||
p_to32->s_port = p_se->s_port;
|
|
||||||
p_to32->s_name = (p_base + (p_name - p_to));
|
|
||||||
p_to32->s_proto = (p_base + (p_proto - p_to));
|
|
||||||
p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_to16->s_port = (INT16)p_se->s_port;
|
|
||||||
p_to16->s_name = (SEGPTR)(p_base + (p_name - p_to));
|
|
||||||
p_to16->s_proto = (SEGPTR)(p_base + (p_proto - p_to));
|
|
||||||
p_to16->s_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE16 __ws_async_handle = 0xdead;
|
static DWORD WINAPI async_getservbyport(LPVOID arg)
|
||||||
|
{
|
||||||
|
struct async_query_getservbyport *aq = arg;
|
||||||
|
struct servent *se = getservbyport( aq->serv_port, aq->serv_proto );
|
||||||
|
|
||||||
/* Generic async query struct. we use symbolic names for the different queries
|
return finish_query( &aq->query, copy_se( aq->query.sbuf, aq->query.sbuflen, se ));
|
||||||
* for readability.
|
|
||||||
*/
|
|
||||||
typedef struct _async_query {
|
|
||||||
HWND16 hWnd;
|
|
||||||
UINT16 uMsg;
|
|
||||||
LPCSTR ptr1;
|
|
||||||
#define host_name ptr1
|
|
||||||
#define host_addr ptr1
|
|
||||||
#define serv_name ptr1
|
|
||||||
#define proto_name ptr1
|
|
||||||
LPCSTR ptr2;
|
|
||||||
#define serv_proto ptr2
|
|
||||||
int int1;
|
|
||||||
#define host_len int1
|
|
||||||
#define proto_number int1
|
|
||||||
#define serv_port int1
|
|
||||||
int int2;
|
|
||||||
#define host_type int2
|
|
||||||
SEGPTR sbuf;
|
|
||||||
INT16 sbuflen;
|
|
||||||
|
|
||||||
HANDLE16 async_handle;
|
|
||||||
int flags;
|
|
||||||
int qt;
|
|
||||||
char xbuf[1];
|
|
||||||
} async_query;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* The async query function.
|
|
||||||
*
|
|
||||||
* It is either called as a thread startup routine or directly. It has
|
|
||||||
* to free the passed arg from the process heap and PostMessageA the async
|
|
||||||
* result or the error code.
|
|
||||||
*
|
|
||||||
* FIXME:
|
|
||||||
* - errorhandling not verified.
|
|
||||||
*/
|
|
||||||
static DWORD WINAPI _async_queryfun(LPVOID arg) {
|
|
||||||
async_query *aq = (async_query*)arg;
|
|
||||||
int size = 0;
|
|
||||||
WORD fail = 0;
|
|
||||||
char *targetptr = (HB_WIN32(aq)?(char*)aq->sbuf:0/*(char*)MapSL(aq->sbuf)*/);
|
|
||||||
|
|
||||||
switch (aq->flags & AQ_GETMASK) {
|
|
||||||
case AQ_GETHOST: {
|
|
||||||
struct hostent *he;
|
|
||||||
char *copy_hostent = targetptr;
|
|
||||||
char buf[100];
|
|
||||||
if( !(aq->host_name)) {
|
|
||||||
aq->host_name = buf;
|
|
||||||
if( gethostname( buf, 100) == -1) {
|
|
||||||
fail = WSAENOBUFS; /* appropriate ? */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
he = (aq->flags & AQ_NAME) ?
|
|
||||||
gethostbyname(aq->host_name):
|
|
||||||
gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type);
|
|
||||||
if (!he) fail = WSAGetLastError();
|
|
||||||
if (he) {
|
|
||||||
size = WS_copy_he(copy_hostent,(char*)aq->sbuf,aq->sbuflen,he,aq->flags);
|
|
||||||
if (size < 0) {
|
|
||||||
fail = WSAENOBUFS;
|
|
||||||
size = -size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case AQ_GETPROTO: {
|
|
||||||
#if defined(HAVE_GETPROTOBYNAME) && defined(HAVE_GETPROTOBYNUMBER)
|
|
||||||
struct protoent *pe;
|
|
||||||
char *copy_protoent = targetptr;
|
|
||||||
pe = (aq->flags & AQ_NAME)?
|
|
||||||
getprotobyname(aq->proto_name) :
|
|
||||||
getprotobynumber(aq->proto_number);
|
|
||||||
if (pe) {
|
|
||||||
size = WS_copy_pe(copy_protoent,(char*)aq->sbuf,aq->sbuflen,pe,aq->flags);
|
|
||||||
if (size < 0) {
|
|
||||||
fail = WSAENOBUFS;
|
|
||||||
size = -size;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (aq->flags & AQ_NAME)
|
|
||||||
MESSAGE("protocol %s not found; You might want to add "
|
|
||||||
"this to /etc/protocols\n", debugstr_a(aq->proto_name) );
|
|
||||||
else
|
|
||||||
MESSAGE("protocol number %d not found; You might want to add "
|
|
||||||
"this to /etc/protocols\n", aq->proto_number );
|
|
||||||
fail = WSANO_DATA;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
fail = WSANO_DATA;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case AQ_GETSERV: {
|
|
||||||
struct servent *se;
|
|
||||||
char *copy_servent = targetptr;
|
|
||||||
se = (aq->flags & AQ_NAME)?
|
|
||||||
getservbyname(aq->serv_name,aq->serv_proto) :
|
|
||||||
#ifdef HAVE_GETSERVBYPORT
|
|
||||||
getservbyport(aq->serv_port,aq->serv_proto);
|
|
||||||
#else
|
|
||||||
NULL;
|
|
||||||
#endif
|
|
||||||
if (se) {
|
|
||||||
size = WS_copy_se(copy_servent,(char*)aq->sbuf,aq->sbuflen,se,aq->flags);
|
|
||||||
if (size < 0) {
|
|
||||||
fail = WSAENOBUFS;
|
|
||||||
size = -size;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (aq->flags & AQ_NAME)
|
|
||||||
MESSAGE("service %s protocol %s not found; You might want to add "
|
|
||||||
"this to /etc/services\n", debugstr_a(aq->serv_name) ,
|
|
||||||
aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
|
|
||||||
else
|
|
||||||
MESSAGE("service on port %d protocol %s not found; You might want to add "
|
|
||||||
"this to /etc/services\n", aq->serv_port,
|
|
||||||
aq->serv_proto ? debugstr_a(aq->serv_proto ):"*");
|
|
||||||
fail = WSANO_DATA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
PostMessageA(HWND_32(aq->hWnd),aq->uMsg,(WPARAM) aq->async_handle,size|(fail<<16));
|
|
||||||
HeapFree(GetProcessHeap(),0,arg);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* The main async help function.
|
* The main async help function.
|
||||||
*
|
*
|
||||||
|
@ -485,105 +266,54 @@ static DWORD WINAPI _async_queryfun(LPVOID arg) {
|
||||||
* with no thread support. This relies on the fact that PostMessage() does
|
* with no thread support. This relies on the fact that PostMessage() does
|
||||||
* not actually call the windowproc before the function returns.
|
* not actually call the windowproc before the function returns.
|
||||||
*/
|
*/
|
||||||
static HANDLE16 __WSAsyncDBQuery(
|
static HANDLE run_query( HWND hWnd, UINT uMsg, LPTHREAD_START_ROUTINE func,
|
||||||
HWND hWnd, UINT uMsg,INT int1,LPCSTR ptr1, INT int2, LPCSTR ptr2,
|
struct async_query_header *query, void *sbuf, INT sbuflen )
|
||||||
void *sbuf, INT sbuflen, UINT flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
async_query* aq;
|
static LONG next_handle = 0xdead;
|
||||||
char* pto;
|
HANDLE thread;
|
||||||
LPCSTR pfm;
|
ULONG handle;
|
||||||
int xbuflen = 0;
|
do
|
||||||
|
handle = LOWORD( InterlockedIncrement( &next_handle ));
|
||||||
|
while (!handle); /* avoid handle 0 */
|
||||||
|
|
||||||
/* allocate buffer to copy protocol- and service name to */
|
query->hWnd = hWnd;
|
||||||
/* note: this is done in the calling thread so we can return */
|
query->uMsg = uMsg;
|
||||||
/* a decent error code if the Alloc fails */
|
query->handle = UlongToHandle( handle );
|
||||||
|
query->sbuf = sbuf;
|
||||||
|
query->sbuflen = sbuflen;
|
||||||
|
|
||||||
switch (flags & AQ_MASKPTR1) {
|
thread = CreateThread( NULL, 0, func, query, 0, NULL );
|
||||||
case 0: break;
|
if (!thread)
|
||||||
case AQ_COPYPTR1: xbuflen += int1; break;
|
{
|
||||||
case AQ_DUPLOWPTR1: xbuflen += strlen(ptr1) + 1; break;
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
}
|
HeapFree( GetProcessHeap(), 0, query );
|
||||||
|
return 0;
|
||||||
switch (flags & AQ_MASKPTR2) {
|
}
|
||||||
case 0: break;
|
CloseHandle( thread );
|
||||||
case AQ_COPYPTR2: xbuflen += int2; break;
|
return UlongToHandle( handle );
|
||||||
case AQ_DUPLOWPTR2: xbuflen += strlen(ptr2) + 1; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(aq = HeapAlloc(GetProcessHeap(),0,sizeof(async_query) + xbuflen))) {
|
|
||||||
SetLastError(WSAEWOULDBLOCK); /* insufficient resources */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pto = aq->xbuf;
|
|
||||||
if (ptr1) switch (flags & AQ_MASKPTR1) {
|
|
||||||
case 0: break;
|
|
||||||
case AQ_COPYPTR1: memcpy(pto, ptr1, int1); ptr1 = pto; pto += int1; break;
|
|
||||||
case AQ_DUPLOWPTR1: pfm = ptr1; ptr1 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
|
|
||||||
}
|
|
||||||
if (ptr2) switch (flags & AQ_MASKPTR2) {
|
|
||||||
case 0: break;
|
|
||||||
case AQ_COPYPTR2: memcpy(pto, ptr2, int2); ptr2 = pto; pto += int2; break;
|
|
||||||
case AQ_DUPLOWPTR2: pfm = ptr2; ptr2 = pto; do *pto++ = tolower(*pfm); while (*pfm++); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
aq->hWnd = HWND_16(hWnd);
|
|
||||||
aq->uMsg = uMsg;
|
|
||||||
aq->int1 = int1;
|
|
||||||
aq->ptr1 = ptr1;
|
|
||||||
aq->int2 = int2;
|
|
||||||
aq->ptr2 = ptr2;
|
|
||||||
/* avoid async_handle = 0 */
|
|
||||||
aq->async_handle = (++__ws_async_handle ? __ws_async_handle : ++__ws_async_handle);
|
|
||||||
aq->flags = flags;
|
|
||||||
aq->sbuf = (SEGPTR)sbuf;
|
|
||||||
aq->sbuflen = sbuflen;
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (CreateThread(NULL,0,_async_queryfun,aq,0,NULL) == INVALID_HANDLE_VALUE)
|
|
||||||
#endif
|
|
||||||
_async_queryfun(aq);
|
|
||||||
return __ws_async_handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* WSAAsyncGetHostByAddr (WINSOCK.102)
|
|
||||||
*/
|
|
||||||
HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 uMsg, LPCSTR addr,
|
|
||||||
INT16 len, INT16 type, SEGPTR sbuf, INT16 buflen)
|
|
||||||
{
|
|
||||||
TRACE("hwnd %04x, msg %04x, addr %08x[%i]\n",
|
|
||||||
hWnd, uMsg, (unsigned)addr , len );
|
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,len,addr,type,NULL,
|
|
||||||
(void*)sbuf,buflen,
|
|
||||||
AQ_NUMBER|AQ_COPYPTR1|AQ_WIN16|AQ_GETHOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* WSAAsyncGetHostByAddr (WS2_32.102)
|
* WSAAsyncGetHostByAddr (WS2_32.102)
|
||||||
*/
|
*/
|
||||||
HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
|
HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
|
||||||
INT len, INT type, LPSTR sbuf, INT buflen)
|
INT len, INT type, LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %04x, addr %08x[%i]\n",
|
struct async_query_gethostbyaddr *aq;
|
||||||
hWnd, uMsg, (unsigned)addr , len );
|
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,len,addr,type,NULL,sbuf,buflen,
|
|
||||||
AQ_NUMBER|AQ_COPYPTR1|AQ_WIN32|AQ_GETHOST));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
TRACE("hwnd %p, msg %04x, addr %p[%i]\n", hWnd, uMsg, addr, len );
|
||||||
* WSAAsyncGetHostByName (WINSOCK.103)
|
|
||||||
*/
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
|
||||||
HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
{
|
||||||
SEGPTR sbuf, INT16 buflen)
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
{
|
return 0;
|
||||||
TRACE("hwnd %04x, msg %04x, host %s, buffer %i\n",
|
}
|
||||||
hWnd, uMsg, (name)?name:"<null>", (int)buflen );
|
aq->host_addr = (char *)(aq + 1);
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,NULL,
|
aq->host_len = len;
|
||||||
(void*)sbuf,buflen,
|
aq->host_type = type;
|
||||||
AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETHOST);
|
memcpy( aq->host_addr, addr, len );
|
||||||
|
return run_query( hWnd, uMsg, async_gethostbyaddr, &aq->query, sbuf, buflen );
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -592,23 +322,19 @@ HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
||||||
HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
||||||
LPSTR sbuf, INT buflen)
|
LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %08x, host %s, buffer %i\n",
|
struct async_query_gethostbyname *aq;
|
||||||
hWnd, uMsg, (name)?name:"<null>", (int)buflen );
|
unsigned int len = strlen(name) + 1;
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
|
|
||||||
AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETHOST));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
TRACE("hwnd %p, msg %04x, host %s, buffer %i\n", hWnd, uMsg, debugstr_a(name), buflen );
|
||||||
* WSAAsyncGetProtoByName (WINSOCK.105)
|
|
||||||
*/
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
|
||||||
HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
{
|
||||||
SEGPTR sbuf, INT16 buflen)
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
{
|
return 0;
|
||||||
TRACE("hwnd %04x, msg %08x, protocol %s\n",
|
}
|
||||||
hWnd, uMsg, (name)?name:"<null>" );
|
aq->host_name = (char *)(aq + 1);
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,NULL,
|
strcpy( aq->host_name, name );
|
||||||
(void*)sbuf,buflen,
|
return run_query( hWnd, uMsg, async_gethostbyname, &aq->query, sbuf, buflen );
|
||||||
AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN16|AQ_GETPROTO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -617,47 +343,39 @@ HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
||||||
HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
||||||
LPSTR sbuf, INT buflen)
|
LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %08x, protocol %s\n",
|
struct async_query_getprotobyname *aq;
|
||||||
hWnd, uMsg, (name)?name:"<null>" );
|
unsigned int len = strlen(name) + 1;
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,NULL,sbuf,buflen,
|
|
||||||
AQ_NAME|AQ_DUPLOWPTR1|AQ_WIN32|AQ_GETPROTO));
|
TRACE("hwnd %p, msg %04x, proto %s, buffer %i\n", hWnd, uMsg, debugstr_a(name), buflen );
|
||||||
|
|
||||||
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
|
||||||
|
{
|
||||||
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
aq->proto_name = (char *)(aq + 1);
|
||||||
|
strcpy( aq->proto_name, name );
|
||||||
|
return run_query( hWnd, uMsg, async_getprotobyname, &aq->query, sbuf, buflen );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* WSAAsyncGetProtoByNumber (WINSOCK.104)
|
|
||||||
*/
|
|
||||||
HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd,UINT16 uMsg,INT16 number,
|
|
||||||
SEGPTR sbuf, INT16 buflen)
|
|
||||||
{
|
|
||||||
TRACE("hwnd %04x, msg %04x, num %i\n", hWnd, uMsg, number );
|
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,number,NULL,0,NULL,
|
|
||||||
(void*)sbuf,buflen,
|
|
||||||
AQ_GETPROTO|AQ_NUMBER|AQ_WIN16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* WSAAsyncGetProtoByNumber (WS2_32.104)
|
* WSAAsyncGetProtoByNumber (WS2_32.104)
|
||||||
*/
|
*/
|
||||||
HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
|
HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
|
||||||
LPSTR sbuf, INT buflen)
|
LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number );
|
struct async_query_getprotobynumber *aq;
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,number,NULL,0,NULL,sbuf,buflen,
|
|
||||||
AQ_GETPROTO|AQ_NUMBER|AQ_WIN32));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number );
|
||||||
* WSAAsyncGetServByName (WINSOCK.107)
|
|
||||||
*/
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) )))
|
||||||
HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
{
|
||||||
LPCSTR proto, SEGPTR sbuf, INT16 buflen)
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
{
|
return 0;
|
||||||
TRACE("hwnd %04x, msg %04x, name %s, proto %s\n",
|
}
|
||||||
hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
|
aq->proto_number = number;
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,0,name,0,proto,
|
return run_query( hWnd, uMsg, async_getprotobynumber, &aq->query, sbuf, buflen );
|
||||||
(void*)sbuf,buflen,
|
|
||||||
AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -666,23 +384,30 @@ HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 uMsg, LPCSTR name,
|
||||||
HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
||||||
LPCSTR proto, LPSTR sbuf, INT buflen)
|
LPCSTR proto, LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %04x, name %s, proto %s\n",
|
struct async_query_getservbyname *aq;
|
||||||
hWnd, uMsg, (name)?name:"<null>", (proto)?proto:"<null>");
|
unsigned int len1 = strlen(name) + 1;
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,0,name,0,proto,sbuf,buflen,
|
unsigned int len2 = proto ? strlen(proto) + 1 : 0;
|
||||||
AQ_GETSERV|AQ_NAME|AQ_DUPLOWPTR1|AQ_DUPLOWPTR2|AQ_WIN32));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
TRACE("hwnd %p, msg %04x, name %s, proto %s\n", hWnd, uMsg, debugstr_a(name), debugstr_a(proto));
|
||||||
* WSAAsyncGetServByPort (WINSOCK.106)
|
|
||||||
*/
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len1 + len2 )))
|
||||||
HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port,
|
{
|
||||||
LPCSTR proto, SEGPTR sbuf, INT16 buflen)
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
{
|
return 0;
|
||||||
TRACE("hwnd %04x, msg %04x, port %i, proto %s\n",
|
}
|
||||||
hWnd, uMsg, port, (proto)?proto:"<null>" );
|
|
||||||
return __WSAsyncDBQuery(HWND_32(hWnd),uMsg,port,NULL,0,proto,
|
aq->serv_name = (char *)(aq + 1);
|
||||||
(void*)sbuf,buflen,
|
strcpy( aq->serv_name, name );
|
||||||
AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN16);
|
|
||||||
|
if (proto)
|
||||||
|
{
|
||||||
|
aq->serv_proto = aq->serv_name + len1;
|
||||||
|
strcpy( aq->serv_proto, proto );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aq->serv_proto = NULL;
|
||||||
|
|
||||||
|
return run_query( hWnd, uMsg, async_getservbyname, &aq->query, sbuf, buflen );
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -691,8 +416,26 @@ HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 uMsg, INT16 port,
|
||||||
HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
|
HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
|
||||||
LPCSTR proto, LPSTR sbuf, INT buflen)
|
LPCSTR proto, LPSTR sbuf, INT buflen)
|
||||||
{
|
{
|
||||||
TRACE("hwnd %p, msg %04x, port %i, proto %s\n",
|
struct async_query_getservbyport *aq;
|
||||||
hWnd, uMsg, port, (proto)?proto:"<null>" );
|
unsigned int len = proto ? strlen(proto) + 1 : 0;
|
||||||
return WSA_H32( __WSAsyncDBQuery(hWnd,uMsg,port,NULL,0,proto,sbuf,buflen,
|
|
||||||
AQ_GETSERV|AQ_NUMBER|AQ_DUPLOWPTR2|AQ_WIN32));
|
TRACE("hwnd %p, msg %04x, port %i, proto %s\n", hWnd, uMsg, port, debugstr_a(proto));
|
||||||
|
|
||||||
|
if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
|
||||||
|
{
|
||||||
|
SetLastError( WSAEWOULDBLOCK );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proto)
|
||||||
|
{
|
||||||
|
aq->serv_proto = (char *)(aq + 1);
|
||||||
|
strcpy( aq->serv_proto, proto );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aq->serv_proto = NULL;
|
||||||
|
|
||||||
|
aq->serv_port = port;
|
||||||
|
|
||||||
|
return run_query( hWnd, uMsg, async_getservbyport, &aq->query, sbuf, buflen );
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,9 @@ User32 -
|
||||||
reactos/dll/win32/user32/windows/text.c # Forked (lstr.c)
|
reactos/dll/win32/user32/windows/text.c # Forked (lstr.c)
|
||||||
reactos/dll/win32/user32/windows/winpos.c # Forked
|
reactos/dll/win32/user32/windows/winpos.c # Forked
|
||||||
|
|
||||||
|
ws2_32 -
|
||||||
|
reactos/dll/win32/ws2_32/misc/async.c # Synced to Wine-1.5.4
|
||||||
|
|
||||||
Update process for autosync DLLs
|
Update process for autosync DLLs
|
||||||
|
|
||||||
*** This process can only be done on Microsoft Windows ***
|
*** This process can only be done on Microsoft Windows ***
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue