]> git.sur5r.net Git - openldap/commitdiff
Added the easy part of NLS support, behind an #ifdef.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 4 Oct 2001 18:06:08 +0000 (18:06 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 4 Oct 2001 18:06:08 +0000 (18:06 +0000)
libraries/libldap/error.c
libraries/libldap/init.c
libraries/libldap/ldap-int.h

index 77b54f9e0dc0043e3a1d77951ec9cebe48f8d80c..0e7721a21aac290afe71cc8ccc042c833c11ad1f 100644 (file)
 
 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];
                }
index 8c453154ae5acd7e21bb4b4e3c7a209dccb90ce5..227617704cb96ff7a2fea78d6138a628bbb20e99 100644 (file)
@@ -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 );
index 971412b26051bb901b53435b95469a0a94eb1aee..8cfc81e3ac10772f93acca9afbadb1687cff649b 100644 (file)
@@ -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
  */