From ba749eb798d653c1f3e8006b7138ee54f0d83429 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 25 Apr 2004 01:09:40 +0000 Subject: [PATCH] Updated string error handling --- libraries/libldap/os-local.c | 3 ++- libraries/libldap/util-int.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index ecc7a2459a..6cbc8a10c2 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -103,11 +103,12 @@ ldap_pvt_close_socket(LDAP *ld, int s) #undef TRACE #define TRACE do { \ + char ebuf[128]; \ oslocal_debug(ld, \ "ldap_is_socket_ready: errror on socket %d: errno: %d (%s)\n", \ s, \ errno, \ - STRERROR(errno) ); \ + AC_STRERROR_R(errno, ebuf, sizeof ebuf)); \ } while( 0 ) /* diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index dbdc8b298c..2d3e3ba97b 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -43,6 +43,12 @@ extern int h_errno; #endif +#ifdef HAVE_HSTRERROR +# define HSTRERROR(e) hstrerror(e) +#else +# define HSTRERROR(e) hp_strerror(e) +#endif + #ifndef LDAP_R_COMPILE # undef HAVE_REENTRANT_FUNCTIONS # undef HAVE_CTIME_R @@ -189,7 +195,7 @@ int ldap_pvt_gethostbyname_a( #endif } -#ifndef GETNAMEINFO +#if !defined( GETNAMEINFO ) && !defined( HAVE_HERROR ) static const char * hp_strerror( int err ) { @@ -249,7 +255,7 @@ int ldap_pvt_get_hname( alen = sizeof(sin->sin_addr); } else { rc = NO_RECOVERY; - *err = (char *)hp_strerror( rc ); + *err = (char *)HSTRERROR( rc ); return rc; } #if defined( HAVE_GETHOSTBYADDR_R ) @@ -281,7 +287,7 @@ int ldap_pvt_get_hname( if (hp) { strncpy( name, hp->h_name, namelen ); } else { - *err = (char *)hp_strerror( h_errno ); + *err = (char *)HSTRERROR( h_errno ); } LDAP_FREE(buf); #else /* HAVE_GETHOSTBYADDR_R */ -- 2.39.5