X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Futil-int.c;h=ffd221408188583f5ed92d32ba69f32e78ef8ad8;hb=c1a257a83f3d8b9565238b5f9b8cad39a6194f63;hp=ff002eb9f65d688ec7af555936ab30364cc95eb4;hpb=621babf51da2cc936e2e6659fab02e8a3ba8c873;p=openldap diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index ff002eb9f6..ffd2214081 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -98,7 +98,6 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf ) static char *safe_realloc( char **buf, int len ); #if !defined(HAVE_GETHOSTBYNAME_R) && defined(LDAP_R_COMPILE) -# define NEED_COPY_HOSTENT static int copy_hostent( struct hostent *res, char **buf, struct hostent * src ); #endif @@ -414,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