]> git.sur5r.net Git - openldap/commitdiff
Changed struct berval ** to BVarray
authorHoward Chu <hyc@openldap.org>
Wed, 2 Jan 2002 13:28:10 +0000 (13:28 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 2 Jan 2002 13:28:10 +0000 (13:28 +0000)
servers/slapd/back-monitor/backend.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/operation.c
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/search.c
servers/slapd/back-monitor/sent.c
servers/slapd/back-monitor/thread.c

index 63b1f4818aa7630f4a9e427fd6397dca97d42168..eb7c0e0856f1561591984280a7399811615ceba5 100644 (file)
@@ -54,7 +54,7 @@ monitor_subsys_backend_init(
        Entry                   *e, *e_backend, *e_tmp;
        int                     i;
        struct monitorentrypriv *mp;
-       struct berval           *bv[2], val;
+       struct berval           bv[2];
 
        mi = ( struct monitorinfo * )be->be_private;
 
@@ -76,8 +76,7 @@ monitor_subsys_backend_init(
                return( -1 );
        }
 
-       bv[0] = &val;
-       bv[1] = NULL;
+       bv[1].bv_val = NULL;
        e_tmp = NULL;
        for ( i = nBackendInfo; i--; ) {
                char buf[1024];
@@ -118,8 +117,8 @@ monitor_subsys_backend_init(
                        return( -1 );
                }
                
-               val.bv_val = bi->bi_type;
-               val.bv_len = strlen( val.bv_val );
+               bv[0].bv_val = bi->bi_type;
+               bv[0].bv_len = strlen( bv[0].bv_val );
 
                attr_merge( e, monitor_ad_desc, bv );
                attr_merge( e_backend, monitor_ad_desc, bv );
index 53d77849b7823eb2a3b477674f0a22c85d7ed3bb..b9555b2f666815ad42e66e0ab93ea0d3b54ad826 100644 (file)
@@ -51,7 +51,7 @@ monitor_subsys_conn_init(
        Entry                   *e, *e_tmp, *e_conn;
        struct monitorentrypriv *mp;
        char                    buf[1024];
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        assert( be != NULL );
 
@@ -108,8 +108,9 @@ monitor_subsys_conn_init(
                return( -1 );
        }
        
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -244,8 +245,8 @@ monitor_subsys_conn_update(
                }
 
                snprintf( buf, sizeof( buf ), "%ld", n );
-               ber_bvfree( a->a_vals[ 0 ] );
-               a->a_vals[ 0 ] = ber_bvstrdup( buf );
+               free( a->a_vals[ 0 ].bv_val );
+               ber_str2bv( buf, 0, 1, a->a_vals );
        }
 
        return( 0 );
@@ -263,7 +264,7 @@ conn_create(
        char                    buf2[22];
        char                    buf3[22];
 
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        Entry                   *e;
 
@@ -346,8 +347,9 @@ conn_create(
                buf3
                );
 
-       val.bv_val = buf;
-       val.bv_len = strlen( buf );
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = buf;
+       bv[0].bv_len = strlen( buf );
        attr_merge( e, monitor_ad_desc, bv );
 
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
index 11de1b5757426be486881e4562b05a5dd5ec6dac..71049a9305c8aba1d4081d62fbf5a2bdb78dd571 100644 (file)
@@ -51,7 +51,7 @@ monitor_subsys_database_init(
        int                     i;
        struct monitorentrypriv *mp;
        AttributeDescription    *ad_nc = slap_schema.si_ad_namingContexts;
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        assert( be != NULL );
        assert( monitor_ad_desc != NULL );
@@ -116,12 +116,13 @@ monitor_subsys_database_init(
                        return( -1 );
                }
                
-               val.bv_val = be->bd_info->bi_type;
-               val.bv_len = strlen( val.bv_val );
+               bv[1].bv_val = NULL;
+               bv[0].bv_val = be->bd_info->bi_type;
+               bv[0].bv_len = strlen( bv[0].bv_val );
                attr_merge( e, monitor_ad_desc, bv );
                
                for ( j = 0; be->be_suffix[j]; j++ ) {
-                       val = *be->be_suffix[j];
+                       bv[0] = *be->be_suffix[j];
 
                        attr_merge( e, ad_nc, bv );
                        attr_merge( e_database, ad_nc, bv );
index 1789ff0c9bf1fd4a86167a310d5d4aca1e50b26b..880d2128a820cfc4fdd8ea6572fb09829d2d406b 100644 (file)
@@ -89,7 +89,7 @@ monitor_subsys_log_init(
        struct monitorinfo      *mi;
        Entry                   *e;
        int                     i;
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        ldap_pvt_thread_mutex_init( &monitor_log_mutex );
 
@@ -112,11 +112,13 @@ monitor_subsys_log_init(
                return( -1 );
        }
 
+       bv[1].bv_val = NULL;
+
        /* initialize the debug level */
        for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
                if ( int_2_level[ i ].i & ldap_syslog ) {
-                       val.bv_val = ( char * )int_2_level[ i ].s;
-                       val.bv_len = strlen( val.bv_val );
+                       bv[0].bv_val = ( char * )int_2_level[ i ].s;
+                       bv[0].bv_len = strlen( bv[0].bv_val );
 
                        attr_merge( e, monitor_ad_desc, bv );
                }
@@ -271,21 +273,21 @@ check_constraints( Modification *mod, int *newlevel )
 {
        int             i;
 
-       for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i] != NULL; i++ ) {
+       for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                int l;
                const char *s;
                ber_len_t len;
                
-               l = loglevel2int( mod->sm_bvalues[i]->bv_val );
+               l = loglevel2int( mod->sm_bvalues[i].bv_val );
                if ( !l ) {
                        return LDAP_CONSTRAINT_VIOLATION;
                }
 
                s = int2loglevel( l );
                len = strlen( s );
-               assert( len == mod->sm_bvalues[i]->bv_len );
+               assert( len == mod->sm_bvalues[i].bv_len );
                
-               AC_MEMCPY( mod->sm_bvalues[i]->bv_val, s, len );
+               AC_MEMCPY( mod->sm_bvalues[i].bv_val, s, len );
 
                *newlevel |= l;
        }
@@ -314,7 +316,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
 
-               for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+               for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                        int rc;
                        int j;
                        const char *text = NULL;
@@ -322,7 +324,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
 
                        rc = value_normalize( mod->sm_desc,
                                        SLAP_MR_EQUALITY,
-                                       mod->sm_bvalues[i],
+                                       &mod->sm_bvalues[i],
                                        &asserted,
                                        &text );
 
@@ -330,11 +332,11 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                                return rc;
                        }
 
-                       for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+                       for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
                                                SLAP_MR_VALUE_SYNTAX_MATCH,
-                                               a->a_vals[j], &asserted, &text );
+                                               &a->a_vals[j], &asserted, &text );
 
                                if ( rc == LDAP_SUCCESS && match == 0 ) {
                                        free( asserted.bv_val );
@@ -348,7 +350,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
 
        /* no - add them */
        if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
-               /* this should return result return of attr_merge */
+               /* this should return result of attr_merge */
                return LDAP_OTHER;
        }
 
@@ -394,7 +396,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* find each value to delete */
-       for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+       for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                int rc;
                const char *text = NULL;
 
@@ -402,18 +404,18 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
 
                rc = value_normalize( mod->sm_desc,
                                SLAP_MR_EQUALITY,
-                               mod->sm_bvalues[i],
+                               &mod->sm_bvalues[i],
                                &asserted,
                                &text );
 
                if( rc != LDAP_SUCCESS ) return rc;
 
                found = 0;
-               for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+               for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
                                        SLAP_MR_VALUE_SYNTAX_MATCH,
-                                       a->a_vals[j], &asserted, &text );
+                                       &a->a_vals[j], &asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
                                continue;
@@ -423,11 +425,11 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
                        found = 1;
 
                        /* delete it */
-                       ber_bvfree( a->a_vals[j] );
-                       for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+                       free( a->a_vals[j].bv_val );
+                       for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
                                a->a_vals[k - 1] = a->a_vals[k];
                        }
-                       a->a_vals[k - 1] = NULL;
+                       a->a_vals[k - 1].bv_val = NULL;
 
                        break;
                }
@@ -441,7 +443,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* if no values remain, delete the entire attribute */
-       if ( a->a_vals[0] == NULL ) {
+       if ( a->a_vals[0].bv_val == NULL ) {
                /* should already be zero */
                *newlevel = 0;
                
index 7108669e8f1fa450ecc93a5c661055d20dfdca72..d30a2f716c1350c9d34918d17546ec9217ffdf0f 100644 (file)
@@ -51,7 +51,7 @@ monitor_subsys_ops_init(
        Entry                   *e, *e_tmp, *e_op;
        struct monitorentrypriv *mp;
        char                    buf[1024];
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        assert( be != NULL );
 
@@ -108,8 +108,9 @@ monitor_subsys_ops_init(
                return( -1 );
        }
        
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -170,8 +171,8 @@ monitor_subsys_ops_init(
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -242,8 +243,8 @@ monitor_subsys_ops_update(
                }
 
                snprintf( buf, sizeof( buf ), "%ld", n );
-               ber_bvfree( a->a_vals[ 0 ] );
-               a->a_vals[ 0 ] = ber_bvstrdup( buf );
+               free( a->a_vals[ 0 ].bv_val );
+               ber_str2bv( buf, 0, 1, a->a_vals );
        }
 
        return( 0 );
index 91ccc0bb0f6e647b3709bb0d6f22e77235fc6797..01a2094a412b3dad7f1272fc1c4a7b27d7a43ca1 100644 (file)
@@ -73,20 +73,16 @@ monitor_subsys_readw_update_internal(
        int                     nconns, nwritewaiters, nreadwaiters;
        
        Attribute               *a;
-       struct berval           *bv[2], val, **b = NULL;
+       struct berval           bv[2], *b = NULL;
        char                    buf[1024];
        
        char                    *str = NULL;
        int                     num = 0;
 
-       bv[0] = &val;
-       bv[1] = NULL;
-
        assert( mi != NULL );
        assert( e != NULL );
        
-       bv[0] = &val;
-       bv[1] = NULL;
+       bv[1].bv_val = NULL;
        
        nconns = nwritewaiters = nreadwaiters = 0;
        for ( c = connection_first( &connindex );
@@ -114,18 +110,18 @@ monitor_subsys_readw_update_internal(
        snprintf( buf, sizeof( buf ), "%s=%d", str, num );
 
        if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
-               for ( b = a->a_vals; b[0] != NULL; b++ ) {
-                       if ( strncmp( b[0]->bv_val, str, strlen( str ) ) == 0 ) {
-                               ber_bvfree( b[0] );
-                               b[0] = ber_bvstrdup( buf );
+               for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
+                       if ( strncmp( b[0].bv_val, str, strlen( str ) ) == 0 ) {
+                               free( b[0].bv_val );
+                               ber_str2bv( buf, 0, 1, b );
                                break;
                        }
                }
        }
 
-       if ( b == NULL || b[0] == NULL ) {
-               val.bv_val = buf;
-               val.bv_len = strlen( buf );
+       if ( b == NULL || b[0].bv_val == NULL ) {
+               bv[0].bv_val = buf;
+               bv[0].bv_len = strlen( buf );
                attr_merge( e, monitor_ad_desc, bv );
        }
 
index 6c187c47abc3e71e6ac02caca8e0567339ae0eae..c8dc7f5eb479ddcbe5538a04289f051132d2825d 100644 (file)
@@ -149,7 +149,7 @@ monitor_back_search(
        int             slimit,
        int             tlimit,
        Filter          *filter,
-       const char      *filterstr,
+       struct berval   *filterstr,
        AttributeName   *attrs,
        int             attrsonly 
 )
index 4e6fb54d722b0a93262bce89dfaf6ce2cf3cc8b0..f14337b8267aa087bd563d81cfa959117a680243 100644 (file)
@@ -51,7 +51,7 @@ monitor_subsys_sent_init(
        Entry                   *e, *e_tmp, *e_sent;
        struct monitorentrypriv *mp;
        char                    buf[1024];
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        assert( be != NULL );
 
@@ -108,8 +108,9 @@ monitor_subsys_sent_init(
                return( -1 );
        }
        
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -170,8 +171,8 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -232,8 +233,8 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -294,8 +295,8 @@ monitor_subsys_sent_init(
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -378,8 +379,8 @@ monitor_subsys_sent_update(
                }
 
                snprintf( buf, sizeof( buf ), "%ld", n );
-               ber_bvfree( a->a_vals[ 0 ] );
-               a->a_vals[ 0 ] = ber_bvstrdup( buf );
+               free( a->a_vals[ 0 ].bv_val );
+               ber_str2bv( buf, 0, 1, a->a_vals );
        }
 
        return( 0 );
index 3fff3238f46e499f23758eb473f584448a277e9e..cf9cebcdadd3dbb94ae2f3a45f5eab7ba84a1891 100644 (file)
@@ -51,7 +51,7 @@ monitor_subsys_thread_init(
 {
        struct monitorinfo      *mi;
        Entry                   *e;
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
        static char             buf[1024];
 
        mi = ( struct monitorinfo * )be->be_private;
@@ -75,8 +75,9 @@ monitor_subsys_thread_init(
        /* initialize the thread number */
        snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max );
 
-       val.bv_val = buf;
-       val.bv_len = strlen( val.bv_val );
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = buf;
+       bv[0].bv_len = strlen( bv[0].bv_val );
 
        attr_merge( e, monitor_ad_desc, bv );
 
@@ -92,30 +93,29 @@ monitor_subsys_thread_update(
 )
 {
        Attribute               *a;
-       struct berval           *bv[2], val, **b = NULL;
+       struct berval           bv[2], *b = NULL;
        char                    buf[1024];
 
-       bv[0] = &val;
-       bv[1] = NULL;
+       bv[1].bv_val = NULL;
 
        snprintf( buf, sizeof( buf ), "backload=%d", 
                        ldap_pvt_thread_pool_backload( &connection_pool ) );
 
        if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
 
-               for ( b = a->a_vals; b[0] != NULL; b++ ) {
-                       if ( strncmp( b[0]->bv_val, "backload=", 
+               for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
+                       if ( strncmp( b[0].bv_val, "backload=", 
                                        sizeof( "backload=" ) - 1 ) == 0 ) {
-                               ber_bvfree( b[0] );
-                               b[0] = ber_bvstrdup( buf );
+                               free( b[0].bv_val );
+                               ber_str2bv( buf, 0, 1, &b[0] );
                                break;
                        }
                }
        }
 
-       if ( b == NULL || b[0] == NULL ) {
-               val.bv_val = buf;
-               val.bv_len = strlen( buf );
+       if ( b == NULL || b[0].bv_val == NULL ) {
+               bv[0].bv_val = buf;
+               bv[0].bv_len = strlen( buf );
                attr_merge( e, monitor_ad_desc, bv );
        }