Avoid using the obsolete inet_addr.

This commit is contained in:
Hans Leidekker 2005-08-27 09:20:24 +00:00 committed by Alexandre Julliard
parent 6d94aa471c
commit 4f36cae4dd
2 changed files with 19 additions and 9 deletions

View File

@ -3815,7 +3815,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
LPINT lpAddressLength)
{
INT res=0;
LONG inetaddr;
struct in_addr inetaddr;
LPSTR workBuffer=NULL,ptrPort;
TRACE( "(%s, %x, %p, %p, %p)\n", AddressString, AddressFamily, lpProtocolInfo,
@ -3853,10 +3853,9 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
}
else
((LPSOCKADDR_IN)lpAddress)->sin_port = 0;
inetaddr = inet_addr(workBuffer);
if (inetaddr != INADDR_NONE)
if (inet_aton(workBuffer, &inetaddr) > 0)
{
((LPSOCKADDR_IN)lpAddress)->sin_addr.WS_s_addr = inetaddr;
((LPSOCKADDR_IN)lpAddress)->sin_addr.WS_s_addr = inetaddr.s_addr;
res = 0;
}
else

View File

@ -1210,9 +1210,12 @@ static void test_WSAStringToAddressA(void)
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressA( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressA() succeeded unexpectedly: %d\n", WSAGetLastError() );
ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff,
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
@ -1223,9 +1226,12 @@ static void test_WSAStringToAddressA(void)
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressA( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressA() succeeded unexpectedly: %d\n", WSAGetLastError() );
ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff && sockaddr.sin_port == 0xffff,
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
}
static void test_WSAStringToAddressW(void)
@ -1257,7 +1263,6 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
@ -1266,9 +1271,12 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressW( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff,
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
@ -1279,9 +1287,12 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressW( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressW() succeeded unexpectedly: %d\n", WSAGetLastError() );
ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff && sockaddr.sin_port == 0xffff,
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
}
/**************** Main program ***************/