ws2_32: Fix flags conversion in getnameinfo() function.

This commit is contained in:
Kirill K. Smirnov 2007-12-17 17:40:02 +03:00 committed by Alexandre Julliard
parent d701ee22f3
commit 01380b0554
1 changed files with 24 additions and 2 deletions

View File

@ -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");