From: Howard Chu Date: Wed, 2 Jan 2002 13:28:10 +0000 (+0000) Subject: Changed struct berval ** to BVarray X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~365 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4aa2a2869219880c9a76d9c0ae163a7ff7a51d4e;p=openldap Changed struct berval ** to BVarray --- diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index 63b1f4818a..eb7c0e0856 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -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 ); diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 53d77849b7..b9555b2f66 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -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 ); diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 11de1b5757..71049a9305 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -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 ); diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 1789ff0c9b..880d2128a8 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -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; diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 7108669e8f..d30a2f716c 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -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 ); diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index 91ccc0bb0f..01a2094a41 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -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 ); } diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index 6c187c47ab..c8dc7f5eb4 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -149,7 +149,7 @@ monitor_back_search( int slimit, int tlimit, Filter *filter, - const char *filterstr, + struct berval *filterstr, AttributeName *attrs, int attrsonly ) diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index 4e6fb54d72..f14337b826 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -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 ); diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 3fff3238f4..cf9cebcdad 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -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 ); }