mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-29 10:07:32 -05:00
Added the easy part of NLS support, behind an #ifdef.
This commit is contained in:
parent
e9415f4a38
commit
75c7331743
3 changed files with 45 additions and 6 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue