Author: tfaber Date: Thu Apr 9 16:14:46 2015 New Revision: 67121
URL: http://svn.reactos.org/svn/reactos?rev=67121&view=rev Log: [WS2_32] - Import GetAddrInfoW and GetNameInfoW from Wine - Put Wine code in wine/ subfolder CORE-9509 #resolve
Added: trunk/reactos/dll/win32/ws2_32/wine/ (with props) trunk/reactos/dll/win32/ws2_32/wine/async.c - copied unchanged from r67118, trunk/reactos/dll/win32/ws2_32/misc/async.c trunk/reactos/dll/win32/ws2_32/wine/socket.c (with props) Removed: trunk/reactos/dll/win32/ws2_32/misc/async.c Modified: trunk/reactos/dll/win32/ws2_32/CMakeLists.txt trunk/reactos/dll/win32/ws2_32/misc/stubs.c
Modified: trunk/reactos/dll/win32/ws2_32/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/CMakeLists... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/CMakeLists.txt [iso-8859-1] Thu Apr 9 16:14:46 2015 @@ -19,7 +19,8 @@
add_library(ws2_32 SHARED ${SOURCE} - misc/async.c + wine/async.c + wine/socket.c ws2_32.rc ${CMAKE_CURRENT_BINARY_DIR}/ws2_32.def)
Removed: trunk/reactos/dll/win32/ws2_32/misc/async.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/async... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/misc/async.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/misc/async.c (removed) @@ -1,440 +0,0 @@ -/* Async WINSOCK DNS services - * - * Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka. - * Copyright (C) 1999 Marcus Meissner - * Copyright (C) 2009 Alexandre Julliard - * - * 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 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * 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). - * - * 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). - */ - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#include <wine/config.h> - -#include <stdarg.h> -#include <windef.h> -#include <winbase.h> -#include <winuser.h> -#include <winsock2.h> - -#include <wine/debug.h> - -WINE_DEFAULT_DEBUG_CHANNEL(winsock); - - -struct async_query_header -{ - HWND hWnd; - UINT uMsg; - void *sbuf; - INT sbuflen; - HANDLE handle; -}; - -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 -{ - 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; -}; - - -/* ----------------------------------- helper functions - */ - -static int list_size(char** l, int item_size) -{ - int i,j = 0; - if(l) - { for(i=0;l[i];i++) - j += (item_size) ? item_size : strlen(l[i]) + 1; - j += (i + 1) * sizeof(char*); } - return j; -} - -static int list_dup(char** l_src, char* ref, int item_size) -{ - 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++) - { l_to[i] = p; - 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); -} - -static DWORD finish_query( struct async_query_header *query, LPARAM lparam ) -{ - PostMessageW( query->hWnd, query->uMsg, (WPARAM)query->handle, lparam ); - HeapFree( GetProcessHeap(), 0, query ); - return 0; -} - -/* ----- hostent */ - -static LPARAM copy_he(void *base, int size, const struct hostent *he) -{ - char *p; - int needed; - struct hostent *to = base; - - if (!he) return MAKELPARAM( 0, GetLastError() ); - - needed = sizeof(struct hostent) + strlen(he->h_name) + 1 + - 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 ); -} - -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 */ - -static LPARAM copy_pe(void *base, int size, const struct protoent* pe) -{ - char *p; - int needed; - struct protoent *to = base; - - if (!pe) return MAKELPARAM( 0, GetLastError() ); - - 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 ); -} - -static DWORD WINAPI async_getprotobyname(LPVOID arg) -{ - struct async_query_getprotobyname *aq = arg; - struct protoent *pe = getprotobyname( aq->proto_name ); - - return finish_query( &aq->query, copy_pe( aq->query.sbuf, aq->query.sbuflen, pe )); -} - -static DWORD WINAPI async_getprotobynumber(LPVOID arg) -{ - struct async_query_getprotobynumber *aq = arg; - struct protoent *pe = getprotobynumber( aq->proto_number ); - - return finish_query( &aq->query, copy_pe( aq->query.sbuf, aq->query.sbuflen, pe )); -} - -/* ----- servent */ - -static LPARAM copy_se(void *base, int size, const struct servent* se) -{ - char *p; - int needed; - struct servent *to = base; - - if (!se) return MAKELPARAM( 0, GetLastError() ); - - 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 ); -} - -static DWORD WINAPI async_getservbyname(LPVOID arg) -{ - struct async_query_getservbyname *aq = arg; - struct servent *se = getservbyname( aq->serv_name, aq->serv_proto ); - - return finish_query( &aq->query, copy_se( aq->query.sbuf, aq->query.sbuflen, se )); -} - -static DWORD WINAPI async_getservbyport(LPVOID arg) -{ - struct async_query_getservbyport *aq = arg; - struct servent *se = getservbyport( aq->serv_port, aq->serv_proto ); - - return finish_query( &aq->query, copy_se( aq->query.sbuf, aq->query.sbuflen, se )); -} - - -/**************************************************************************** - * The main async help function. - * - * 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. - */ -static HANDLE run_query( HWND hWnd, UINT uMsg, LPTHREAD_START_ROUTINE func, - struct async_query_header *query, void *sbuf, INT sbuflen ) -{ - static LONG next_handle = 0xdead; - HANDLE thread; - ULONG handle; - do - handle = LOWORD( InterlockedIncrement( &next_handle )); - while (!handle); /* avoid handle 0 */ - - query->hWnd = hWnd; - query->uMsg = uMsg; - query->handle = UlongToHandle( handle ); - query->sbuf = sbuf; - query->sbuflen = sbuflen; - - thread = CreateThread( NULL, 0, func, query, 0, NULL ); - if (!thread) - { - SetLastError( WSAEWOULDBLOCK ); - HeapFree( GetProcessHeap(), 0, query ); - return 0; - } - CloseHandle( thread ); - return UlongToHandle( handle ); -} - - -/*********************************************************************** - * WSAAsyncGetHostByAddr (WS2_32.102) - */ -HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr, - INT len, INT type, LPSTR sbuf, INT buflen) -{ - struct async_query_gethostbyaddr *aq; - - TRACE("hwnd %p, msg %04x, addr %p[%i]\n", hWnd, uMsg, addr, len ); - - if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len ))) - { - SetLastError( WSAEWOULDBLOCK ); - return 0; - } - aq->host_addr = (char *)(aq + 1); - aq->host_len = len; - aq->host_type = type; - memcpy( aq->host_addr, addr, len ); - return run_query( hWnd, uMsg, async_gethostbyaddr, &aq->query, sbuf, buflen ); -} - -/*********************************************************************** - * WSAAsyncGetHostByName (WS2_32.103) - */ -HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, LPCSTR name, - LPSTR sbuf, INT buflen) -{ - 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 ); - - if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len ))) - { - SetLastError( WSAEWOULDBLOCK ); - return 0; - } - aq->host_name = (char *)(aq + 1); - strcpy( aq->host_name, name ); - return run_query( hWnd, uMsg, async_gethostbyname, &aq->query, sbuf, buflen ); -} - -/*********************************************************************** - * WSAAsyncGetProtoByName (WS2_32.105) - */ -HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name, - LPSTR sbuf, INT buflen) -{ - 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 ); - - 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 (WS2_32.104) - */ -HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number, - LPSTR sbuf, INT buflen) -{ - struct async_query_getprotobynumber *aq; - - TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number ); - - if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) ))) - { - SetLastError( WSAEWOULDBLOCK ); - return 0; - } - aq->proto_number = number; - return run_query( hWnd, uMsg, async_getprotobynumber, &aq->query, sbuf, buflen ); -} - -/*********************************************************************** - * WSAAsyncGetServByName (WS2_32.107) - */ -HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, - LPCSTR proto, LPSTR sbuf, INT buflen) -{ - struct async_query_getservbyname *aq; - unsigned int len1 = strlen(name) + 1; - unsigned int len2 = proto ? strlen(proto) + 1 : 0; - - TRACE("hwnd %p, msg %04x, name %s, proto %s\n", hWnd, uMsg, debugstr_a(name), debugstr_a(proto)); - - if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len1 + len2 ))) - { - SetLastError( WSAEWOULDBLOCK ); - return 0; - } - - aq->serv_name = (char *)(aq + 1); - strcpy( aq->serv_name, name ); - - 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 ); -} - -/*********************************************************************** - * WSAAsyncGetServByPort (WS2_32.106) - */ -HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port, - LPCSTR proto, LPSTR sbuf, INT buflen) -{ - struct async_query_getservbyport *aq; - unsigned int len = proto ? strlen(proto) + 1 : 0; - - 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 ); -}
Modified: trunk/reactos/dll/win32/ws2_32/misc/stubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/stubs... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/misc/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/ws2_32/misc/stubs.c [iso-8859-1] Thu Apr 9 16:14:46 2015 @@ -930,39 +930,4 @@ return FALSE; }
-/* - * @unimplemented - */ -INT -EXPORT -GetAddrInfoW(IN PCWSTR pszNodeName, - IN PCWSTR pszServiceName, - IN const ADDRINFOW *ptHints, - OUT PADDRINFOW *pptResult) -{ - UNIMPLEMENTED - - WSASetLastError(EAI_FAIL); - return EAI_FAIL; -} - -/* - * @unimplemented - */ -INT -EXPORT -GetNameInfoW(IN CONST SOCKADDR *pSockaddr, - IN socklen_t SockaddrLength, - OUT PWCHAR pNodeBuffer, - IN DWORD NodeBufferSize, - OUT PWCHAR pServiceBuffer, - IN DWORD ServiceBufferSize, - IN INT Flags) -{ - UNIMPLEMENTED - - WSASetLastError(EAI_FAIL); - return EAI_FAIL; -} - /* EOF */
Propchange: trunk/reactos/dll/win32/ws2_32/wine/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details.
Propchange: trunk/reactos/dll/win32/ws2_32/wine/ ------------------------------------------------------------------------------ bugtraq:url = https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/dll/win32/ws2_32/wine/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: trunk/reactos/dll/win32/ws2_32/wine/socket.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/wine/socke... ============================================================================== --- trunk/reactos/dll/win32/ws2_32/wine/socket.c (added) +++ trunk/reactos/dll/win32/ws2_32/wine/socket.c [iso-8859-1] Thu Apr 9 16:14:46 2015 @@ -0,0 +1,198 @@ +/* + * based on Windows Sockets 1.1 specs + * + * Copyright (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka. + * Copyright (C) 2001 Stefan Leichter + * Copyright (C) 2004 Hans Leidekker + * Copyright (C) 2005 Marcus Meissner + * Copyright (C) 2006-2008 Kai Blin + * + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * 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). + */ + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#include <windef.h> +#include <winbase.h> +#include <winnls.h> +#include <ws2tcpip.h> + +static inline void FreeAddrInfoW_(struct addrinfoW *pAddrInfo) +{ + freeaddrinfo((struct addrinfo *)pAddrInfo); +} +#define FreeAddrInfoW FreeAddrInfoW_ + +static struct addrinfoW *addrinfo_AtoW(const struct addrinfo *ai) +{ + struct addrinfoW *ret; + + if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct addrinfoW)))) return NULL; + ret->ai_flags = ai->ai_flags; + ret->ai_family = ai->ai_family; + ret->ai_socktype = ai->ai_socktype; + ret->ai_protocol = ai->ai_protocol; + ret->ai_addrlen = ai->ai_addrlen; + ret->ai_canonname = NULL; + ret->ai_addr = NULL; + ret->ai_next = NULL; + if (ai->ai_canonname) + { + int len = MultiByteToWideChar(CP_ACP, 0, ai->ai_canonname, -1, NULL, 0); + if (!(ret->ai_canonname = HeapAlloc(GetProcessHeap(), 0, len))) + { + HeapFree(GetProcessHeap(), 0, ret); + return NULL; + } + MultiByteToWideChar(CP_ACP, 0, ai->ai_canonname, -1, ret->ai_canonname, len); + } + if (ai->ai_addr) + { + if (!(ret->ai_addr = HeapAlloc(GetProcessHeap(), 0, ai->ai_addrlen))) + { + HeapFree(GetProcessHeap(), 0, ret->ai_canonname); + HeapFree(GetProcessHeap(), 0, ret); + return NULL; + } + memcpy(ret->ai_addr, ai->ai_addr, ai->ai_addrlen); + } + return ret; +} + +static struct addrinfoW *addrinfo_list_AtoW(const struct addrinfo *info) +{ + struct addrinfoW *ret, *infoW; + + if (!(ret = infoW = addrinfo_AtoW(info))) return NULL; + while (info->ai_next) + { + if (!(infoW->ai_next = addrinfo_AtoW(info->ai_next))) + { + FreeAddrInfoW(ret); + return NULL; + } + infoW = infoW->ai_next; + info = info->ai_next; + } + return ret; +} + +static struct addrinfo *addrinfo_WtoA(const struct addrinfoW *ai) +{ + struct addrinfo *ret; + + if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct addrinfo)))) return NULL; + ret->ai_flags = ai->ai_flags; + ret->ai_family = ai->ai_family; + ret->ai_socktype = ai->ai_socktype; + ret->ai_protocol = ai->ai_protocol; + ret->ai_addrlen = ai->ai_addrlen; + ret->ai_canonname = NULL; + ret->ai_addr = NULL; + ret->ai_next = NULL; + if (ai->ai_canonname) + { + int len = WideCharToMultiByte(CP_ACP, 0, ai->ai_canonname, -1, NULL, 0, NULL, NULL); + if (!(ret->ai_canonname = HeapAlloc(GetProcessHeap(), 0, len))) + { + HeapFree(GetProcessHeap(), 0, ret); + return NULL; + } + WideCharToMultiByte(CP_ACP, 0, ai->ai_canonname, -1, ret->ai_canonname, len, NULL, NULL); + } + if (ai->ai_addr) + { + if (!(ret->ai_addr = HeapAlloc(GetProcessHeap(), 0, sizeof(struct sockaddr)))) + { + HeapFree(GetProcessHeap(), 0, ret->ai_canonname); + HeapFree(GetProcessHeap(), 0, ret); + return NULL; + } + memcpy(ret->ai_addr, ai->ai_addr, sizeof(struct sockaddr)); + } + return ret; +} + +/*********************************************************************** + * GetAddrInfoW (WS2_32.@) + */ +int WINAPI GetAddrInfoW(LPCWSTR nodename, LPCWSTR servname, const ADDRINFOW *hints, PADDRINFOW *res) +{ + int ret, len; + char *nodenameA = NULL, *servnameA = NULL; + struct addrinfo *resA, *hintsA = NULL; + + *res = NULL; + if (nodename) + { + len = WideCharToMultiByte(CP_ACP, 0, nodename, -1, NULL, 0, NULL, NULL); + if (!(nodenameA = HeapAlloc(GetProcessHeap(), 0, len))) return EAI_MEMORY; + WideCharToMultiByte(CP_ACP, 0, nodename, -1, nodenameA, len, NULL, NULL); + } + if (servname) + { + len = WideCharToMultiByte(CP_ACP, 0, servname, -1, NULL, 0, NULL, NULL); + if (!(servnameA = HeapAlloc(GetProcessHeap(), 0, len))) + { + HeapFree(GetProcessHeap(), 0, nodenameA); + return EAI_MEMORY; + } + WideCharToMultiByte(CP_ACP, 0, servname, -1, servnameA, len, NULL, NULL); + } + + if (hints) hintsA = addrinfo_WtoA(hints); + ret = getaddrinfo(nodenameA, servnameA, hintsA, &resA); + freeaddrinfo(hintsA); + + if (!ret) + { + *res = addrinfo_list_AtoW(resA); + freeaddrinfo(resA); + } + + HeapFree(GetProcessHeap(), 0, nodenameA); + HeapFree(GetProcessHeap(), 0, servnameA); + return ret; +} + +int WINAPI GetNameInfoW(const SOCKADDR *sa, socklen_t salen, PWCHAR host, + DWORD hostlen, PWCHAR serv, DWORD servlen, INT flags) +{ + int ret; + char *hostA = NULL, *servA = NULL; + + if (host && (!(hostA = HeapAlloc(GetProcessHeap(), 0, hostlen)))) return EAI_MEMORY; + if (serv && (!(servA = HeapAlloc(GetProcessHeap(), 0, servlen)))) + { + HeapFree(GetProcessHeap(), 0, hostA); + return EAI_MEMORY; + } + + ret = getnameinfo(sa, salen, hostA, hostlen, servA, servlen, flags); + if (!ret) + { + if (host) MultiByteToWideChar(CP_ACP, 0, hostA, -1, host, hostlen); + if (serv) MultiByteToWideChar(CP_ACP, 0, servA, -1, serv, servlen); + } + + HeapFree(GetProcessHeap(), 0, hostA); + HeapFree(GetProcessHeap(), 0, servA); + return ret; +}
Propchange: trunk/reactos/dll/win32/ws2_32/wine/socket.c ------------------------------------------------------------------------------ svn:eol-style = native