From fe03d112cbbb25a1ce27162f89baaab4226228b5 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 29 Jul 2009 02:25:02 +0000 Subject: [PATCH] 2009-07-29 04:24 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/hbsocket.c ! finished hb_socketResolveAddr() in systems where getaddrinfo() is not available --- harbour/ChangeLog | 5 +++++ harbour/source/rtl/hbsocket.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1d9c861d1b..be1b32fc9d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-29 04:24 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/hbsocket.c + ! finished hb_socketResolveAddr() in systems where getaddrinfo() + is not available + 2009-07-29 00:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/hbsocket.c ! disabled inet_pton() and inet_ntop() in OS2 GCC builds. diff --git a/harbour/source/rtl/hbsocket.c b/harbour/source/rtl/hbsocket.c index 7f1728f88b..f86c0368aa 100644 --- a/harbour/source/rtl/hbsocket.c +++ b/harbour/source/rtl/hbsocket.c @@ -2579,8 +2579,19 @@ char * hb_socketResolveAddr( const char * szAddr, int af ) he = gethostbyname( szAddr ); if( he && he->h_addr_list[ 0 ] ) - szResult = hb_strdup( he->h_addr_list[ 0 ] ); - + { + struct in_addr * sin = ( struct in_addr * ) he->h_addr_list[ 0 ]; +# if defined( HB_HAS_INET_NTOP ) + char buf[ INET_ADDRSTRLEN ]; + szAddr = inet_ntop( AF_INET, sin, buf, sizeof( buf ) ); +# elif defined( HB_IS_INET_NTOA_MT_SAFE ) + szAddr = inet_ntoa( *sin ); +# else + char buf[ INET_ADDRSTRLEN ]; + szAddr = hb_inet_ntoa( sin, buf ); +# endif + szResult = hb_strdup( szAddr ); + } hb_vmLock(); } #if defined( HB_HAS_INET6 ) @@ -2736,7 +2747,7 @@ PHB_ITEM hb_socketGetHosts( const char * szAddr, int af ) pItem = hb_itemArrayNew( iCount ); do { - struct in_addr * sin = ( struct in_addr * ) he->h_addr_list[ iCount - 1 ]; + struct in_addr * sin = ( struct in_addr * ) he->h_addr_list[ iCount - 1 ]; # if defined( HB_HAS_INET_NTOP ) char buf[ INET_ADDRSTRLEN ]; szAddr = inet_ntop( AF_INET, sin, buf, sizeof( buf ) );