Kirill K. Smirnov : ws2_32: Fix flags conversion in getnameinfo() function.

Alexandre Julliard julliard at winehq.org
Tue Dec 18 07:34:56 CST 2007


Module: wine
Branch: master
Commit: 01380b0554f685d85bf0dca6363cd55003ba482d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=01380b0554f685d85bf0dca6363cd55003ba482d

Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date:   Mon Dec 17 17:40:02 2007 +0300

ws2_32: Fix flags conversion in getnameinfo() function.

---

 dlls/ws2_32/socket.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 3abb5a0..12024f5 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -327,6 +327,15 @@ static const int ws_aiflag_map[][2] =
      */
 };
 
+static const int ws_niflag_map[][2] =
+{
+    MAP_OPTION( NI_NOFQDN ),
+    MAP_OPTION( NI_NUMERICHOST ),
+    MAP_OPTION( NI_NAMEREQD ),
+    MAP_OPTION( NI_NUMERICSERV ),
+    MAP_OPTION( NI_DGRAM ),
+};
+
 static const int ws_eai_map[][2] =
 {
     MAP_OPTION( EAI_AGAIN ),
@@ -3327,7 +3336,7 @@ void WINAPI WS_freeaddrinfo(struct WS_addrinfo *res)
     }
 }
 
-/* helper functions for getaddrinfo() */
+/* helper functions for getaddrinfo()/getnameinfo() */
 static int convert_aiflag_w2u(int winflags) {
     int i, unixflags = 0;
 
@@ -3341,6 +3350,19 @@ static int convert_aiflag_w2u(int winflags) {
     return unixflags;
 }
 
+static int convert_niflag_w2u(int winflags) {
+    int i, unixflags = 0;
+
+    for (i=0;i<sizeof(ws_niflag_map)/sizeof(ws_niflag_map[0]);i++)
+        if (ws_niflag_map[i][0] & winflags) {
+            unixflags |= ws_niflag_map[i][1];
+            winflags &= ~ws_niflag_map[i][0];
+        }
+    if (winflags)
+        FIXME("Unhandled windows NI_xxx flags %x\n", winflags);
+    return unixflags;
+}
+
 static int convert_aiflag_u2w(int unixflags) {
     int i, winflags = 0;
 
@@ -3498,7 +3520,7 @@ int WINAPI WS_getnameinfo(const SOCKADDR *sa, WS_socklen_t salen, PCHAR host,
         WSASetLastError(WSAEFAULT);
         return WSA_NOT_ENOUGH_MEMORY;
     }
-    ret = getnameinfo(&sa_u.addr, size, host, hostlen, serv, servlen, convert_aiflag_w2u(flags));
+    ret = getnameinfo(&sa_u.addr, size, host, hostlen, serv, servlen, convert_niflag_w2u(flags));
     return convert_eai_u2w(ret);
 #else
     FIXME("getnameinfo() failed, not found during buildtime.\n");




More information about the wine-cvs mailing list