From 9f0d190739f9f2d14f81825f992e47b061d80e27 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 18 Oct 2000 17:25:30 +0000 Subject: [PATCH] Add ldap_pvt_gai_strerror(). Calls to gai_strerror() should be replaced with calls AC_GAI_STRERROR(). --- include/ac/socket.h | 9 +++++++++ libraries/libldap/util-int.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/ac/socket.h b/include/ac/socket.h index e48dcb8f84..26af7a571a 100644 --- a/include/ac/socket.h +++ b/include/ac/socket.h @@ -193,4 +193,13 @@ LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * )); # define INET6_ADDRSTRLEN 46 #endif +#ifdef HAVE_GETADDRINFO +# ifdef HAVE_GAI_STRERROR +# define AC_GAI_STRERROR(x) (gai_strerror((x))) +# else +# define AC_GAI_STRERROR(x) (ldap_pvt_gai_strerror((x))) + char * ldap_pvt_gai_strerror( int ); +# endif +#endif + #endif /* _AC_SOCKET_H_ */ diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index 9e8a59fded..ffd2214081 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -413,3 +413,39 @@ char * ldap_pvt_get_fqdn( char *name ) LDAP_FREE( ha_buf ); return fqdn; } + +#if defined( HAVE_GETADDRINFO ) && !defined( HAVE_GAI_STRERROR ) +char *ldap_pvt_gai_strerror (int code) { + static struct { + int code; + const char *msg; + } values[] = { +#ifdef EAI_ADDRFAMILY + { EAI_ADDRFAMILY, "Address family for hostname not supported" }, +#endif + { EAI_AGAIN, "Temporary failure in name resolution" }, + { EAI_BADFLAGS, "Bad value for ai_flags" }, + { EAI_FAIL, "Non-recoverable failure in name resolution" }, + { EAI_FAMILY, "ai_family not supported" }, + { EAI_MEMORY, "Memory allocation failure" }, +#ifdef EAI_NODATA + { EAI_NODATA, "No address associated with hostname" }, +#endif + { EAI_NONAME, "Name or service not known" }, + { EAI_SERVICE, "Servname not supported for ai_socktype" }, + { EAI_SOCKTYPE, "ai_socktype not supported" }, + { EAI_SYSTEM, "System error" }, + { 0, NULL } + }; + + int i; + + for ( i = 0; values[i].msg != NULL; i++ ) { + if ( values[i].code == code ) { + return (char *) values[i].msg; + } + } + + return "Unknown error"; +} +#endif -- 2.39.5