From: Kurt Zeilenga Date: Thu, 4 Oct 2001 18:06:08 +0000 (+0000) Subject: Added the easy part of NLS support, behind an #ifdef. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~996 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=75c73317434eede956b13551a674149776e49d04;p=openldap Added the easy part of NLS support, behind an #ifdef. --- diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index 77b54f9e0d..0e7721a21a 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -18,17 +18,17 @@ struct ldaperror { int e_code; - char *e_reason; + char *e_reason; }; -static const struct ldaperror ldap_errlist[] = { +static struct ldaperror ldap_builtin_errlist[] = { {LDAP_SUCCESS, "Success" }, {LDAP_OPERATIONS_ERROR, "Operations error" }, {LDAP_PROTOCOL_ERROR, "Protocol error" }, {LDAP_TIMELIMIT_EXCEEDED, "Time limit exceeded" }, {LDAP_SIZELIMIT_EXCEEDED, "Size limit exceeded" }, - {LDAP_COMPARE_FALSE, "Compare false" }, - {LDAP_COMPARE_TRUE, "Compare true" }, + {LDAP_COMPARE_FALSE, "Compare False" }, + {LDAP_COMPARE_TRUE, "Compare True" }, {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Authentication method not supported" }, {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" }, {LDAP_PARTIAL_RESULTS, "Partial results and referral received" }, @@ -92,15 +92,47 @@ static const struct ldaperror ldap_errlist[] = { {LDAP_CLIENT_LOOP, "Client Loop" }, {LDAP_REFERRAL_LIMIT_EXCEEDED, "Referral Limit Exceeded" }, - {-1, NULL } + {-1, NULL} }; +static struct ldaperror *ldap_errlist = ldap_builtin_errlist; + +void ldap_int_error_init( void ) { +#ifdef LDAP_NLS +#define LDAP_NLS_SDK_CAT "openldap_sdk" +#define LDAP_NLS_LIBLDAP_SET (0) + + int i; + nl_catd catd = catopen( LDAP_NLS_SDK_CAT, NL_CAT_LOCALE ); + + if( catd == -1 ) { + return; + } + + for ( i=0; ldap_errlist[i].e_reason != NULL; i++ ) { + char *msg = catgets( catd, + LDAP_NLS_LIBLDAP_SET, + ldap_errlist[i].e_code, NULL ); + + if( msg != NULL ) { + msg = LDAP_STRDUP( msg ); + + if( msg != NULL ) { + ldap_errlist[i].e_reason = msg; + } + } + } + + catclose( catd ); +#endif +} + static const struct ldaperror * ldap_int_error( int err ) { int i; - for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) { + for ( i=0; ldap_errlist[i].e_reason != NULL; i++ ) { if ( err == ldap_errlist[i].e_code ) { return &ldap_errlist[i]; } diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index 8c453154ae..227617704c 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -432,6 +432,8 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl ) return; } + ldap_int_error_init(); + #if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) \ || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL) ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname ); diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 971412b260..8cfc81e3ac 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -341,6 +341,11 @@ LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P(( #define LDAP_VFREE(v) (LBER_VFREE((void **)(v))) #define LDAP_STRDUP(s) (LBER_STRDUP((s))) +/* + * in error.c + */ +void ldap_int_error_init( void ); + /* * in unit-int.c */