[1/2] ws2_32: Implement InetNtopW (try 3)

Bruno Jesus 00cpxxx at gmail.com
Fri Jul 22 23:21:23 CDT 2016


From: Philipp Hoppermann <plata at mailbox.org>

try 3 simplifies the function based on ideas by Sebastian Lackner.

Superseeds 124703, 124704, 124714, 124715

Fixes https://bugs.winehq.org/show_bug.cgi?id=40999

Signed-off-by: Philipp Hoppermann <plata at mailbox.org>
Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
-------------- next part --------------
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index b0af3d7..79ccfc2 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -7934,6 +7934,26 @@ INT WINAPI InetPtonW(INT family, PCWSTR addr, PVOID buffer)
 }
 
 /***********************************************************************
+ *              InetNtopW                      (WS2_32.@)
+ */
+PCWSTR WINAPI InetNtopW(INT family, PVOID addr, PWSTR buffer, SIZE_T len)
+{
+    char bufferA[WS_INET6_ADDRSTRLEN];
+    PWSTR ret = NULL;
+
+    TRACE("family %d, addr (%p), buffer (%p), len %ld\n", family, addr, buffer, len);
+
+    if (WS_inet_ntop(family, addr, bufferA, sizeof(bufferA)))
+    {
+        if (MultiByteToWideChar(CP_ACP, 0, bufferA, -1, buffer, len))
+            ret = buffer;
+        else
+            SetLastError(ERROR_INVALID_PARAMETER);
+    }
+    return ret;
+}
+
+/***********************************************************************
  *              WSAStringToAddressA                      (WS2_32.80)
  */
 INT WINAPI WSAStringToAddressA(LPSTR AddressString,
diff --git a/dlls/ws2_32/ws2_32.spec b/dlls/ws2_32/ws2_32.spec
index 7625f38..0482b7d 100644
--- a/dlls/ws2_32/ws2_32.spec
+++ b/dlls/ws2_32/ws2_32.spec
@@ -54,6 +54,7 @@
 @ stdcall GetAddrInfoExW(wstr wstr long ptr ptr ptr ptr ptr ptr ptr)
 @ stdcall GetAddrInfoW(wstr wstr ptr ptr)
 @ stdcall GetNameInfoW(ptr long ptr long ptr long long)
+@ stdcall InetNtopW(long ptr ptr long)
 @ stdcall InetPtonW(long wstr ptr)
 @ stdcall WSApSetPostRoutine(ptr)
 @ stdcall WPUCompleteOverlappedRequest(long ptr long long ptr)


More information about the wine-patches mailing list