1999-04-10 18:58:55 +02:00
|
|
|
/* Async WINSOCK DNS services
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
|
|
|
|
* Copyright (C) 1999 Marcus Meissner
|
2009-09-29 18:22:52 +02:00
|
|
|
* Copyright (C) 2009 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-04-10 18:58:55 +02:00
|
|
|
*
|
|
|
|
* NOTE: If you make any changes to fix a particular app, make sure
|
|
|
|
* they don't break something else like Netscape or telnet and ftp
|
|
|
|
* clients and servers (www.winsite.com got a lot of those).
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-04-10 18:58:55 +02:00
|
|
|
* FIXME:
|
|
|
|
* - Add WSACancel* and correct handle management. (works rather well for
|
|
|
|
* now without it.)
|
|
|
|
* - Verify & Check all calls for correctness
|
|
|
|
* (currently only WSAGetHostByName*, WSAGetServByPort* calls)
|
|
|
|
* - Check error returns.
|
|
|
|
* - mirc/mirc32 Finger @linux.kernel.org sometimes fails in threaded mode.
|
|
|
|
* (not sure why)
|
|
|
|
* - This implementation did ignore the "NOTE:" section above (since the
|
|
|
|
* whole stuff did not work anyway to other changes).
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
#include "ws2_32_private.h"
|
1999-04-10 18:58:55 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2000-09-24 21:41:57 +02:00
|
|
|
|
2009-09-29 18:25:05 +02:00
|
|
|
struct async_query_header
|
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
LPARAM (*func)( struct async_query_header *query );
|
2009-09-29 18:25:05 +02:00
|
|
|
HWND hWnd;
|
|
|
|
UINT uMsg;
|
|
|
|
void *sbuf;
|
|
|
|
INT sbuflen;
|
|
|
|
HANDLE handle;
|
|
|
|
};
|
|
|
|
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_gethostbyname
|
|
|
|
{
|
|
|
|
struct async_query_header query;
|
|
|
|
char *host_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct async_query_gethostbyaddr
|
|
|
|
{
|
|
|
|
struct async_query_header query;
|
|
|
|
char *host_addr;
|
|
|
|
int host_len;
|
|
|
|
int host_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct async_query_getprotobyname
|
|
|
|
{
|
2009-09-29 18:25:05 +02:00
|
|
|
struct async_query_header query;
|
2009-09-29 19:30:05 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2009-09-29 18:22:52 +02:00
|
|
|
|
1999-04-10 18:58:55 +02:00
|
|
|
/* ----------------------------------- helper functions - */
|
|
|
|
|
|
|
|
static int list_size(char** l, int item_size)
|
|
|
|
{
|
|
|
|
int i,j = 0;
|
|
|
|
if(l)
|
2002-06-01 01:06:46 +02:00
|
|
|
{ for(i=0;l[i];i++)
|
1999-04-10 18:58:55 +02:00
|
|
|
j += (item_size) ? item_size : strlen(l[i]) + 1;
|
|
|
|
j += (i + 1) * sizeof(char*); }
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
2009-09-29 20:03:36 +02:00
|
|
|
static int list_dup(char** l_src, char* ref, int item_size)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
1999-04-10 18:58:55 +02:00
|
|
|
char* p = ref;
|
|
|
|
char** l_to = (char**)ref;
|
|
|
|
int i,j,k;
|
|
|
|
|
|
|
|
for(j=0;l_src[j];j++) ;
|
|
|
|
p += (j + 1) * sizeof(char*);
|
|
|
|
for(i=0;i<j;i++)
|
2009-09-29 20:03:36 +02:00
|
|
|
{ l_to[i] = p;
|
1999-04-10 18:58:55 +02:00
|
|
|
k = ( item_size ) ? item_size : strlen(l_src[i]) + 1;
|
|
|
|
memcpy(p, l_src[i], k); p += k; }
|
|
|
|
l_to[i] = NULL;
|
|
|
|
return (p - ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- hostent */
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
static LPARAM copy_he(void *base, int size, const struct hostent *he)
|
2009-09-29 20:03:36 +02:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
int needed;
|
2021-08-05 04:20:48 +02:00
|
|
|
struct hostent *to = base;
|
2009-09-29 20:03:36 +02:00
|
|
|
|
|
|
|
if (!he) return MAKELPARAM( 0, GetLastError() );
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
needed = sizeof(struct hostent) + strlen(he->h_name) + 1 +
|
2009-09-29 20:03:36 +02:00
|
|
|
list_size(he->h_aliases, 0) +
|
|
|
|
list_size(he->h_addr_list, he->h_length );
|
|
|
|
if (size < needed) return MAKELPARAM( needed, WSAENOBUFS );
|
|
|
|
|
|
|
|
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 );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_gethostbyname( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_gethostbyname *aq = CONTAINING_RECORD( query, struct async_query_gethostbyname, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct hostent *he = gethostbyname( aq->host_name );
|
2009-09-29 18:22:52 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_he( query->sbuf, query->sbuflen, he );
|
2009-09-29 18:22:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_gethostbyaddr( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_gethostbyaddr *aq = CONTAINING_RECORD( query, struct async_query_gethostbyaddr, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct hostent *he = gethostbyaddr( aq->host_addr, aq->host_len, aq->host_type );
|
2009-09-29 20:03:36 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_he( query->sbuf, query->sbuflen, he );
|
2009-09-29 18:22:52 +02:00
|
|
|
}
|
|
|
|
|
1999-04-10 18:58:55 +02:00
|
|
|
/* ----- protoent */
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
static LPARAM copy_pe( void *base, int size, const struct protoent *pe )
|
1999-04-10 18:58:55 +02:00
|
|
|
{
|
2009-09-29 20:03:36 +02:00
|
|
|
char *p;
|
|
|
|
int needed;
|
2021-08-05 04:20:48 +02:00
|
|
|
struct protoent *to = base;
|
1999-04-10 18:58:55 +02:00
|
|
|
|
2009-09-29 20:03:36 +02:00
|
|
|
if (!pe) return MAKELPARAM( 0, GetLastError() );
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
needed = sizeof(struct protoent) + strlen( pe->p_name ) + 1 + list_size( pe->p_aliases, 0 );
|
2009-09-29 20:03:36 +02:00
|
|
|
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 );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_getprotobyname( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_getprotobyname *aq = CONTAINING_RECORD( query, struct async_query_getprotobyname, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct protoent *pe = getprotobyname( aq->proto_name );
|
2009-09-29 19:32:27 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_pe( query->sbuf, query->sbuflen, pe );
|
2009-09-29 18:22:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_getprotobynumber( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_getprotobynumber *aq = CONTAINING_RECORD( query, struct async_query_getprotobynumber, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct protoent *pe = getprotobynumber( aq->proto_number );
|
2009-09-29 19:32:27 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_pe( query->sbuf, query->sbuflen, pe );
|
2009-09-29 18:22:52 +02:00
|
|
|
}
|
|
|
|
|
1999-04-10 18:58:55 +02:00
|
|
|
/* ----- servent */
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
static LPARAM copy_se( void *base, int size, const struct servent *se )
|
1999-04-10 18:58:55 +02:00
|
|
|
{
|
2009-09-29 20:03:36 +02:00
|
|
|
char *p;
|
|
|
|
int needed;
|
2021-08-05 04:20:48 +02:00
|
|
|
struct servent *to = base;
|
1999-04-10 18:58:55 +02:00
|
|
|
|
2009-09-29 20:03:36 +02:00
|
|
|
if (!se) return MAKELPARAM( 0, GetLastError() );
|
|
|
|
|
2021-08-05 04:20:48 +02:00
|
|
|
needed = sizeof(struct servent) + strlen( se->s_proto ) + strlen( se->s_name ) + 2 + list_size( se->s_aliases, 0 );
|
2009-09-29 20:03:36 +02:00
|
|
|
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 );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_getservbyname( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_getservbyname *aq = CONTAINING_RECORD( query, struct async_query_getservbyname, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct servent *se = getservbyname( aq->serv_name, aq->serv_proto );
|
2009-09-29 19:32:27 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_se( query->sbuf, query->sbuflen, se );
|
2009-09-29 18:22:52 +02:00
|
|
|
}
|
1999-04-10 18:58:55 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
static LPARAM async_getservbyport( struct async_query_header *query )
|
2009-09-29 18:22:52 +02:00
|
|
|
{
|
2016-08-21 19:55:43 +02:00
|
|
|
struct async_query_getservbyport *aq = CONTAINING_RECORD( query, struct async_query_getservbyport, query );
|
2021-08-05 04:20:48 +02:00
|
|
|
struct servent *se = getservbyport( aq->serv_port, aq->serv_proto );
|
2009-09-29 19:32:27 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
return copy_se( query->sbuf, query->sbuflen, se );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void WINAPI async_worker( TP_CALLBACK_INSTANCE *instance, void *context )
|
|
|
|
{
|
|
|
|
struct async_query_header *query = context;
|
|
|
|
LPARAM lparam = query->func( query );
|
|
|
|
PostMessageW( query->hWnd, query->uMsg, (WPARAM)query->handle, lparam );
|
2021-08-19 06:25:48 +02:00
|
|
|
free( query );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
2009-09-29 18:22:52 +02:00
|
|
|
|
1999-04-10 18:58:55 +02:00
|
|
|
/****************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* The main async help function.
|
|
|
|
*
|
1999-04-10 18:58:55 +02:00
|
|
|
* It either starts a thread or just calls the function directly for platforms
|
|
|
|
* with no thread support. This relies on the fact that PostMessage() does
|
|
|
|
* not actually call the windowproc before the function returns.
|
|
|
|
*/
|
2016-08-21 19:55:43 +02:00
|
|
|
static HANDLE run_query( HWND hWnd, UINT uMsg, LPARAM (*func)(struct async_query_header *),
|
2009-09-29 20:03:36 +02:00
|
|
|
struct async_query_header *query, void *sbuf, INT sbuflen )
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
static LONG next_handle = 0xdead;
|
2011-11-26 23:43:03 +01:00
|
|
|
ULONG handle;
|
|
|
|
do
|
|
|
|
handle = LOWORD( InterlockedIncrement( &next_handle ));
|
|
|
|
while (!handle); /* avoid handle 0 */
|
2009-09-29 19:30:05 +02:00
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
query->func = func;
|
2009-09-29 19:30:05 +02:00
|
|
|
query->hWnd = hWnd;
|
|
|
|
query->uMsg = uMsg;
|
|
|
|
query->handle = UlongToHandle( handle );
|
|
|
|
query->sbuf = sbuf;
|
|
|
|
query->sbuflen = sbuflen;
|
|
|
|
|
2016-08-21 19:55:43 +02:00
|
|
|
if (!TrySubmitThreadpoolCallback( async_worker, query, NULL ))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
2021-08-19 06:25:48 +02:00
|
|
|
free( query );
|
2009-09-29 19:30:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return UlongToHandle( handle );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetHostByAddr (WS2_32.102)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
|
|
|
|
INT len, INT type, LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_gethostbyaddr *aq;
|
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, addr %p[%i]\n", hWnd, uMsg, addr, len );
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) + len )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
aq->host_addr = (char *)(aq + 1);
|
|
|
|
aq->host_len = len;
|
|
|
|
aq->host_type = type;
|
|
|
|
memcpy( aq->host_addr, addr, len );
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_gethostbyaddr, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetHostByName (WS2_32.103)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
1999-04-10 18:58:55 +02:00
|
|
|
LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_gethostbyname *aq;
|
|
|
|
unsigned int len = strlen(name) + 1;
|
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, host %s, buffer %i\n", hWnd, uMsg, debugstr_a(name), buflen );
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) + len )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
aq->host_name = (char *)(aq + 1);
|
|
|
|
strcpy( aq->host_name, name );
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_gethostbyname, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetProtoByName (WS2_32.105)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
|
|
|
LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_getprotobyname *aq;
|
|
|
|
unsigned int len = strlen(name) + 1;
|
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, proto %s, buffer %i\n", hWnd, uMsg, debugstr_a(name), buflen );
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) + len )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
aq->proto_name = (char *)(aq + 1);
|
|
|
|
strcpy( aq->proto_name, name );
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_getprotobyname, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetProtoByNumber (WS2_32.104)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
|
|
|
|
LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_getprotobynumber *aq;
|
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number );
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
aq->proto_number = number;
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_getprotobynumber, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetServByName (WS2_32.107)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
|
|
|
|
LPCSTR proto, LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_getservbyname *aq;
|
|
|
|
unsigned int len1 = strlen(name) + 1;
|
2012-03-23 04:23:48 +01:00
|
|
|
unsigned int len2 = proto ? strlen(proto) + 1 : 0;
|
2009-09-29 19:30:05 +02:00
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, name %s, proto %s\n", hWnd, uMsg, debugstr_a(name), debugstr_a(proto));
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) + len1 + len2 )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
2012-03-23 04:23:48 +01:00
|
|
|
|
2009-09-29 19:30:05 +02:00
|
|
|
aq->serv_name = (char *)(aq + 1);
|
|
|
|
strcpy( aq->serv_name, name );
|
2012-03-23 04:23:48 +01:00
|
|
|
|
|
|
|
if (proto)
|
|
|
|
{
|
|
|
|
aq->serv_proto = aq->serv_name + len1;
|
|
|
|
strcpy( aq->serv_proto, proto );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aq->serv_proto = NULL;
|
|
|
|
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_getservbyname, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSAAsyncGetServByPort (WS2_32.106)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
|
|
|
|
LPCSTR proto, LPSTR sbuf, INT buflen)
|
|
|
|
{
|
2009-09-29 19:30:05 +02:00
|
|
|
struct async_query_getservbyport *aq;
|
2011-06-01 14:14:18 +02:00
|
|
|
unsigned int len = proto ? strlen(proto) + 1 : 0;
|
2009-09-29 19:30:05 +02:00
|
|
|
|
|
|
|
TRACE("hwnd %p, msg %04x, port %i, proto %s\n", hWnd, uMsg, port, debugstr_a(proto));
|
|
|
|
|
2021-08-19 06:25:48 +02:00
|
|
|
if (!(aq = malloc( sizeof(*aq) + len )))
|
2009-09-29 19:30:05 +02:00
|
|
|
{
|
|
|
|
SetLastError( WSAEWOULDBLOCK );
|
|
|
|
return 0;
|
|
|
|
}
|
2011-06-01 14:14:18 +02:00
|
|
|
|
|
|
|
if (proto)
|
|
|
|
{
|
|
|
|
aq->serv_proto = (char *)(aq + 1);
|
|
|
|
strcpy( aq->serv_proto, proto );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aq->serv_proto = NULL;
|
|
|
|
|
|
|
|
aq->serv_port = port;
|
|
|
|
|
2009-09-29 20:03:36 +02:00
|
|
|
return run_query( hWnd, uMsg, async_getservbyport, &aq->query, sbuf, buflen );
|
1999-04-10 18:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* WSACancelAsyncRequest (WS2_32.108)
|
1999-04-10 18:58:55 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle)
|
|
|
|
{
|
2002-10-30 21:26:32 +01:00
|
|
|
FIXME("(%p),stub\n", hAsyncTaskHandle);
|
1999-04-10 18:58:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-01 22:52:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WSApSetPostRoutine (WS2_32.24)
|
|
|
|
*/
|
2001-10-09 23:48:22 +02:00
|
|
|
INT WINAPI WSApSetPostRoutine(LPWPUPOSTMESSAGE lpPostRoutine)
|
2001-10-01 22:52:23 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p), stub !\n", lpPostRoutine);
|
|
|
|
return 0;
|
|
|
|
}
|
Stub implementations for WPUCompleteOverlappedRequest,
WSADuplicateSocketW, WSAEnumNameSpaceProviders{A,W}, WSAGetQOSByName,
WSAGetServiceClassInfo{A,W}, WSAGetServiceClassNameByClassId{A,W},
WSALookupServiceEnd, WSALookupServiceNext{A,W},
WSAProviderConfigChange, WSASetService{A,W}, WSCEnableNSProvider,
WSCGetProviderPath, WSCInstallNameSpace, WSCWriteProviderOrder.
Implementations for WSANtohl, WSANtohs, WSASocketA->W crosscall.
Avoid NULL dereferences in WSAStringToAddress{A,W} and
WSAAddressToString{A,W}.
2005-01-10 15:34:15 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2009-09-29 20:00:53 +02:00
|
|
|
* WPUCompleteOverlappedRequest (WS2_32.25)
|
Stub implementations for WPUCompleteOverlappedRequest,
WSADuplicateSocketW, WSAEnumNameSpaceProviders{A,W}, WSAGetQOSByName,
WSAGetServiceClassInfo{A,W}, WSAGetServiceClassNameByClassId{A,W},
WSALookupServiceEnd, WSALookupServiceNext{A,W},
WSAProviderConfigChange, WSASetService{A,W}, WSCEnableNSProvider,
WSCGetProviderPath, WSCInstallNameSpace, WSCWriteProviderOrder.
Implementations for WSANtohl, WSANtohs, WSASocketA->W crosscall.
Avoid NULL dereferences in WSAStringToAddress{A,W} and
WSAAddressToString{A,W}.
2005-01-10 15:34:15 +01:00
|
|
|
*/
|
|
|
|
WSAEVENT WINAPI WPUCompleteOverlappedRequest(SOCKET s, LPWSAOVERLAPPED overlapped,
|
2005-06-25 20:34:32 +02:00
|
|
|
DWORD error, DWORD transferred, LPINT errcode)
|
Stub implementations for WPUCompleteOverlappedRequest,
WSADuplicateSocketW, WSAEnumNameSpaceProviders{A,W}, WSAGetQOSByName,
WSAGetServiceClassInfo{A,W}, WSAGetServiceClassNameByClassId{A,W},
WSALookupServiceEnd, WSALookupServiceNext{A,W},
WSAProviderConfigChange, WSASetService{A,W}, WSCEnableNSProvider,
WSCGetProviderPath, WSCInstallNameSpace, WSCWriteProviderOrder.
Implementations for WSANtohl, WSANtohs, WSASocketA->W crosscall.
Avoid NULL dereferences in WSAStringToAddress{A,W} and
WSAAddressToString{A,W}.
2005-01-10 15:34:15 +01:00
|
|
|
{
|
2007-05-24 16:41:17 +02:00
|
|
|
FIXME("(0x%08lx,%p,0x%08x,0x%08x,%p), stub !\n", s, overlapped, error, transferred, errcode);
|
Stub implementations for WPUCompleteOverlappedRequest,
WSADuplicateSocketW, WSAEnumNameSpaceProviders{A,W}, WSAGetQOSByName,
WSAGetServiceClassInfo{A,W}, WSAGetServiceClassNameByClassId{A,W},
WSALookupServiceEnd, WSALookupServiceNext{A,W},
WSAProviderConfigChange, WSASetService{A,W}, WSCEnableNSProvider,
WSCGetProviderPath, WSCInstallNameSpace, WSCWriteProviderOrder.
Implementations for WSANtohl, WSANtohs, WSASocketA->W crosscall.
Avoid NULL dereferences in WSAStringToAddress{A,W} and
WSAAddressToString{A,W}.
2005-01-10 15:34:15 +01:00
|
|
|
|
2005-06-25 20:34:32 +02:00
|
|
|
if (errcode)
|
|
|
|
*errcode = WSAEINVAL;
|
Stub implementations for WPUCompleteOverlappedRequest,
WSADuplicateSocketW, WSAEnumNameSpaceProviders{A,W}, WSAGetQOSByName,
WSAGetServiceClassInfo{A,W}, WSAGetServiceClassNameByClassId{A,W},
WSALookupServiceEnd, WSALookupServiceNext{A,W},
WSAProviderConfigChange, WSASetService{A,W}, WSCEnableNSProvider,
WSCGetProviderPath, WSCInstallNameSpace, WSCWriteProviderOrder.
Implementations for WSANtohl, WSANtohs, WSASocketA->W crosscall.
Avoid NULL dereferences in WSAStringToAddress{A,W} and
WSAAddressToString{A,W}.
2005-01-10 15:34:15 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|