]> git.sur5r.net Git - openldap/commitdiff
improve (and cleanup) value normalization
authorPierangelo Masarati <ando@openldap.org>
Tue, 8 Apr 2003 23:30:58 +0000 (23:30 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 8 Apr 2003 23:30:58 +0000 (23:30 +0000)
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/backend.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/listener.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/thread.c

index 3037e8655e14d9c9576167c89134c37f54c92625..a16f8fb7d9e369a442fffab8247e9e9a9a70cace 100644 (file)
@@ -203,7 +203,6 @@ struct monitorsubsys {
 extern struct monitorsubsys monitor_subsys[];
 
 extern AttributeDescription *monitor_ad_desc;
-extern slap_mr_normalize_func *monitor_ad_normalize;
 extern BackendDB *be_monitor;
 
 /*
index aab3ff7b26a4aa88815187a1d36f2908125e085c..573eaad4f03c2585298e5db0a5ba70c67b057bf1 100644 (file)
@@ -76,8 +76,7 @@ monitor_subsys_backend_init(
        for ( i = nBackendInfo; i--; ) {
                char            buf[1024];
                BackendInfo     *bi;
-               struct berval   bv, nbv;
-               int             rc;
+               struct berval   bv;
 
                bi = &backendInfo[i];
 
@@ -110,23 +109,8 @@ monitor_subsys_backend_init(
                bv.bv_val = bi->bi_type;
                bv.bv_len = strlen( bv.bv_val );
 
-               nbv.bv_val = NULL;
-               if ( monitor_ad_normalize ) {
-                       rc = monitor_ad_normalize(
-                                       0,
-                                       monitor_ad_desc->ad_type->sat_syntax,
-                                       monitor_ad_desc->ad_type->sat_equality,
-                                       &bv, &nbv );
-                       if ( rc ) {
-                               return( -1 );
-                       }
-               }
-
-               attr_merge_one( e, monitor_ad_desc, &bv,
-                               nbv.bv_val ? &nbv : NULL );
-               attr_merge_one( e_backend, monitor_ad_desc, &bv,
-                               nbv.bv_val ? &nbv : NULL );
-               ch_free( nbv.bv_val );
+               attr_merge_normalize_one( e, monitor_ad_desc, &bv );
+               attr_merge_normalize_one( e_backend, monitor_ad_desc, &bv );
 
                if ( bi->bi_controls ) {
                        int j;
index 9fde6ca7110c594c46f7ca832aa5b8b8079ae80a..b4ce5de9aecb3d14a50288d37cd4656f7ff3c81d 100644 (file)
@@ -152,7 +152,7 @@ monitor_subsys_database_init(
                                        j, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val );
                                bv.bv_val = buf;
                                bv.bv_len = strlen( buf );
-                               attr_mergeit_one( e, ad_seeAlso, &bv );
+                               attr_merge_normalize_one( e, ad_seeAlso, &bv );
                                break;
                        }
                }
@@ -239,7 +239,7 @@ monitor_back_add_plugin( Backend *be, Entry *e_database )
 
                bv.bv_val = buf;
                bv.bv_len = strlen( buf );
-               attr_mergeit_one( e_database, monitor_ad_desc, &bv );
+               attr_merge_normalize_one( e_database, monitor_ad_desc, &bv );
 
                i++;
 
index a929562301db3b1a7a3033bfaa6388ba0aa4aa18..fdcb40cfd4c672e1102e2a459ed453b0b67d6f9f 100644 (file)
@@ -44,7 +44,6 @@
  * used by many functions to add description to entries
  */
 AttributeDescription *monitor_ad_desc = NULL;
-slap_mr_normalize_func *monitor_ad_normalize = NULL;
 BackendDB *be_monitor = NULL;
 
 /*
@@ -301,10 +300,6 @@ monitor_back_db_init(
                return( -1 );
        }
 
-       if ( monitor_ad_desc->ad_type->sat_equality ) {
-               monitor_ad_normalize = monitor_ad_desc->ad_type->sat_equality->smr_normalize;
-       }
-
        /*      
         * Create all the subsystem specific entries
         */
@@ -429,7 +424,7 @@ monitor_back_db_init(
        } else {
                bv.bv_len = strlen( Versionstr );
        }
-       if ( attr_merge_one( e, monitor_ad_desc, &bv, NULL ) ) {
+       if ( attr_merge_normalize_one( e, monitor_ad_desc, &bv ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, CRIT,
                        "unable to add description to '%s' entry\n",
index b862fcd0f8e3168df93482576c870582ce0d3790..2224ec1de75d7d2baa7189d6b84d5a03a3c5882d 100644 (file)
@@ -122,54 +122,22 @@ monitor_subsys_listener_init(
 
 #ifdef HAVE_TLS
                if ( l[i]->sl_is_tls ) {
-                       struct berval bv, nbv;
+                       struct berval bv;
 
                        bv.bv_val = "TLS";
                        bv.bv_len = sizeof("TLS")-1;
 
-                       nbv.bv_val = NULL;
-                       if ( monitor_ad_normalize ) {
-                               int     rc;
-
-                               rc = monitor_ad_normalize(
-                                               0,
-                                               monitor_ad_desc->ad_type->sat_syntax,
-                                               monitor_ad_desc->ad_type->sat_equality,
-                                               &bv, &nbv );
-                               if ( rc ) {
-                                       return( -1 );
-                               }
-                       }
-
-                       attr_merge_one( e, monitor_ad_desc, &bv,
-                                       nbv.bv_val ? &nbv : NULL );
-                       ch_free( nbv.bv_val );
+                       attr_merge_normalize_one( e, monitor_ad_desc, &bv );
                }
 #endif /* HAVE_TLS */
 #ifdef LDAP_CONNECTIONLESS
                if ( l[i]->sl_is_udp ) {
-                       struct berval bv, nbv;
+                       struct berval bv;
 
                        bv.bv_val = "UDP";
                        bv.bv_len = sizeof("UDP")-1;
 
-                       nbv.bv_val = NULL;
-                       if ( monitor_ad_normalize ) {
-                               int     rc;
-
-                               rc = monitor_ad_normalize(
-                                               0,
-                                               monitor_ad_desc->ad_type->sat_syntax,
-                                               monitor_ad_desc->ad_type->sat_equality,
-                                               &bv, &nbv );
-                               if ( rc ) {
-                                       return( -1 );
-                               }
-                       }
-
-                       attr_merge_one( e, monitor_ad_desc, &bv,
-                                       nbv.bv_val ? &nbv : NULL );
-                       ch_free( nbv.bv_val );
+                       attr_merge_normalize_one( e, monitor_ad_desc, &bv );
                }
 #endif /* HAVE_TLS */
 
index 8bc0dd0d1835bc7ea50939b41816e6df78d2871c..5ebcba76fb6b62259a6f67bd2a73c3c0292de3de 100644 (file)
@@ -116,10 +116,10 @@ monitor_subsys_log_init(
        /* initialize the debug level(s) */
        for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
 
-               if ( monitor_ad_normalize ) {
+               if ( monitor_ad_desc->ad_type->sat_equality->smr_normalize ) {
                        int     rc;
 
-                       rc = monitor_ad_normalize(
+                       rc = (*monitor_ad_desc->ad_type->sat_equality->smr_normalize)(
                                        0,
                                        monitor_ad_desc->ad_type->sat_syntax,
                                        monitor_ad_desc->ad_type->sat_equality,
@@ -167,7 +167,8 @@ monitor_subsys_log_modify(
                 */
                if ( is_at_operational( mod->sm_desc->ad_type ) ) {
                        ( void ) attr_delete( &e->e_attrs, mod->sm_desc );
-                       rc = attr_mergeit( e, mod->sm_desc, mod->sm_bvalues );
+                       rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
+                                       mod->sm_nvalues );
                        if ( rc != 0 ) {
                                rc = LDAP_OTHER;
                                break;
@@ -374,10 +375,10 @@ add_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* no - add them */
-       if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues,
-                               mod->sm_nvalues ) != 0 ) {
+       rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues );
+       if ( rc != LDAP_SUCCESS ) {
                /* this should return result of attr_mergeit */
-               return LDAP_OTHER;
+               return rc;
        }
 
        return LDAP_SUCCESS;
@@ -499,10 +500,12 @@ replace_values( Entry *e, Modification *mod, int *newlevel )
                return rc;
        }
 
-       if ( mod->sm_bvalues != NULL &&
-               attr_merge( e, mod->sm_desc, mod->sm_bvalues,
-                      mod->sm_nvalues  ) != 0 ) {
-               return LDAP_OTHER;
+       if ( mod->sm_bvalues != NULL ) {
+               rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
+                      mod->sm_nvalues );
+               if ( rc != LDAP_SUCCESS ) {
+                       return rc;
+               }
        }
 
        return LDAP_SUCCESS;
index 5c2e88f5301352e32707b47effb5294470a1cec1..cc1a383d1b6e484c80b92565175a2f0b816af9bf 100644 (file)
@@ -115,28 +115,12 @@ monitor_subsys_readw_update_internal(
        }
 
        if ( b == NULL || b[0].bv_val == NULL ) {
-               struct berval bv, nbv;
+               struct berval bv;
 
                bv.bv_val = buf;
                bv.bv_len = strlen( buf );
 
-               nbv.bv_val = NULL;
-               if ( monitor_ad_normalize ) {
-                       int     rc;
-
-                       rc = monitor_ad_normalize(
-                                       0,
-                                       monitor_ad_desc->ad_type->sat_syntax,
-                                       monitor_ad_desc->ad_type->sat_equality,
-                                       &bv, &nbv );
-                       if ( rc ) {
-                               return( -1 );
-                       }
-               }
-
-               attr_merge_one( e, monitor_ad_desc, &bv,
-                               nbv.bv_val ? &nbv : NULL );
-               ch_free( nbv.bv_val );
+               attr_merge_normalize_one( e, monitor_ad_desc, &bv );
        }
 
        return( 0 );
index 7853a9faf1398f32f0ce2cbd87ac02a8b35b073f..16dd56b129982dca5c03364ff1e89abde927f7b3 100644 (file)
@@ -75,7 +75,7 @@ monitor_subsys_thread_init(
        bv.bv_val = buf;
        bv.bv_len = strlen( bv.bv_val );
 
-       attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+       attr_merge_normalize_one( e, monitor_ad_desc, &bv );
 
        monitor_cache_release( mi, e );
 
@@ -112,7 +112,7 @@ monitor_subsys_thread_update(
 
                bv.bv_val = buf;
                bv.bv_len = strlen( buf );
-               attr_merge_one( e, monitor_ad_desc, &bv, NULL );
+               attr_merge_normalize_one( e, monitor_ad_desc, &bv );
        }
 
        return( 0 );