]> git.sur5r.net Git - openldap/commitdiff
Changed be_nsuffix from char ** to struct berval ** to eliminate strlen's
authorHoward Chu <hyc@openldap.org>
Sat, 8 Dec 2001 05:15:58 +0000 (05:15 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 8 Dec 2001 05:15:58 +0000 (05:15 +0000)
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-monitor/init.c
servers/slapd/back-passwd/search.c
servers/slapd/backend.c
servers/slapd/config.c
servers/slapd/slap.h

index a40663cbaef200791df9cc712a0f8df6e3e95535..8bef765bce2dc39bbd92b1a2082cfceb18b99ed8 100644 (file)
@@ -579,9 +579,8 @@ int bdb_build_tree(
         * multiple suffixes for a single backend won't work!
         */
        bdb->bi_sufflen = strlen(be->be_suffix[0]);
-       bdb->bi_nsufflen = strlen(be->be_nsuffix[0]);
 
-       rdns = ldap_explode_dn(be->be_nsuffix[0], 0);
+       rdns = ldap_explode_dn(be->be_nsuffix[0]->bv_val, 0);
        for (i=0; rdns[i]; i++);
        bdb->bi_nrdns = i;
        charray_free(rdns);
@@ -621,7 +620,7 @@ int bdb_fix_dn(
        ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
        o = bdb_find_id_node(id, bdb->bi_tree);
        rlen = bdb->bi_sufflen + 1;
-       nrlen = bdb->bi_nsufflen + 1;
+       nrlen = be->be_nsuffix[0]->bv_len + 1;
        for (n = o; n; n=n->i_parent) {
                rlen += n->i_rdn->rdn.bv_len + 1;
                nrlen += n->i_rdn->nrdn.bv_len + 1;
@@ -641,7 +640,7 @@ int bdb_fix_dn(
        ptr--;
        nptr--;
        strcpy(ptr, be->be_suffix[0]);
-       strcpy(nptr, be->be_nsuffix[0]);
+       strcpy(nptr, be->be_nsuffix[0]->bv_val);
 
        return 0;
 }
index e787577556156f3c590d4738959a12b266c4166e..b7b0c51ea6292c556bc76f92834713faabf5ba8f 100644 (file)
@@ -206,7 +206,7 @@ monitor_back_db_init(
        monitor_defined++;
 
        charray_add( &be->be_suffix, SLAPD_MONITOR_DN );
-       charray_add( &be->be_nsuffix, SLAPD_MONITOR_NDN );
+       ber_bvecadd( &be->be_nsuffix, ber_bvstr( SLAPD_MONITOR_NDN ));
 
        mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
        ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
index 1a9bf057ebf35ba977b6c8f152b4245bc746ba45..1fd69910907563da41dadacd85fc4a7b8b7b633b 100644 (file)
@@ -190,7 +190,7 @@ passwd_back_search(
                if( !be_issuffix( be, parent ) ) {
                        int i;
                        for( i=0; be->be_nsuffix[i] != NULL; i++ ) {
-                               if( dn_issuffix( nbase, be->be_nsuffix[i] ) ) {
+                               if( dn_issuffix( nbase, be->be_nsuffix[i]->bv_val ) ) {
                                        matched = ch_strdup( be->be_suffix[i] );
                                        break;
                                }
index 688a4ee3e8bd81b035b2ac7211b0aca2ab53bfdc..08e1062fdb70e52da33318fddc9f22f78a47ddf2 100644 (file)
@@ -525,7 +525,7 @@ select_backend(
                for ( j = 0; backends[i].be_nsuffix != NULL &&
                    backends[i].be_nsuffix[j] != NULL; j++ )
                {
-                       len = strlen( backends[i].be_nsuffix[j] );
+                       len = backends[i].be_nsuffix[j]->bv_len;
 
                        if ( len > dnlen ) {
                                /* suffix is longer than DN */
@@ -539,7 +539,7 @@ select_backend(
                        }
                        
 
-                       if ( strcmp( backends[i].be_nsuffix[j], &dn[dnlen-len] ) == 0 ) {
+                       if ( strcmp( backends[i].be_nsuffix[j]->bv_val, &dn[dnlen-len] ) == 0 ) {
                                if( be == NULL ) {
                                        be = &backends[i];
 
@@ -564,9 +564,13 @@ be_issuffix(
 )
 {
        int     i;
+       int     len = strlen(suffix);
 
        for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) {
-               if ( strcmp( be->be_nsuffix[i], suffix ) == 0 ) {
+               if ( len != be->be_nsuffix[i]->bv_len ) {
+                       continue;
+               }
+               if ( strcmp( be->be_nsuffix[i]->bv_val, suffix ) == 0 ) {
                        return( 1 );
                }
        }
index 756a6bb3769f988aea84c91053f486bcea855565..1dfef56688a6087e523f0b1f9298fe8e3a4ee854 100644 (file)
@@ -899,6 +899,7 @@ read_config( const char *fname )
 
                        } else {
                                char *dn = ch_strdup( cargv[1] );
+
                                if ( load_ucdata( NULL ) < 0 ) {
                                        return( 1 );
                                }
@@ -947,8 +948,7 @@ read_config( const char *fname )
                                        return 1;
                                }
 #endif /* USE_LDAP_DN_PARSING */
-                               charray_add( &be->be_nsuffix, dn );
-                               free( dn );
+                               ber_bvecadd( &be->be_nsuffix, ber_bvstr( dn ));
                        }
 
                /* set database suffixAlias */
index 6c35e4735e6f7827267c6097f6a2aef52e87c6e0..c0a6237ce3da428444af0b1d1d79218b808653cf 100644 (file)
@@ -979,7 +979,7 @@ struct slap_backend_db {
 
        /* these should be renamed from be_ to bd_ */
        char    **be_suffix;    /* the DN suffixes of data in this backend */
-       char    **be_nsuffix;   /* the normalized DN suffixes in this backend */
+       struct berval   **be_nsuffix;   /* the normalized DN suffixes in this backend */
        char    **be_suffixAlias; /* pairs of DN suffix aliases and deref values */
        char    *be_root_dn;    /* the magic "root" dn for this db      */
        char    *be_root_ndn;   /* the magic "root" normalized dn for this db   */