SLAP_NVALUES tweaks - after input, a_nvals is always populated. If there is

no normalizer, a_nvals = a_vals.
This commit is contained in:
Howard Chu 2003-03-24 01:56:56 +00:00
parent 491ad352ea
commit 5ad51b6150
24 changed files with 97 additions and 68 deletions

View file

@ -907,7 +907,7 @@ dn_match_cleanup:;
#ifdef SLAP_NVALUES
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_nvals ? at->a_nvals : at->a_vals,
at->a_nvals,
#else
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_vals,
@ -1125,7 +1125,7 @@ dn_match_cleanup:;
if (aci_mask( be, conn, op,
e, desc, val,
#ifdef SLAP_NVALUES
at->a_nvals ? &at->a_nvals[i] : &at->a_vals[i],
&at->a_nvals[i],
#else
&at->a_vals[i],
#endif
@ -1858,7 +1858,7 @@ aci_mask(
#ifdef SLAP_NVALUES
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_nvals ? at->a_nvals : at->a_vals,
at->a_nvals,
#else
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_vals,

View file

@ -431,7 +431,7 @@ slap_mods2entry(
mods->sml_values = NULL;
#ifdef SLAP_NVALUES
if( attr->a_nvals ) {
if( mods->sml_nvalues ) {
attr->a_nvals = ch_realloc( attr->a_nvals,
sizeof( struct berval ) * (i+j) );
@ -441,6 +441,8 @@ slap_mods2entry(
/* trim the mods array */
ch_free( mods->sml_nvalues );
mods->sml_nvalues = NULL;
} else {
attr->a_nvals = attr->a_vals;
}
#endif
@ -479,10 +481,31 @@ slap_mods2entry(
const char *text = NULL;
char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
#ifdef SLAP_NVALUES
int match;
for ( i = 0; mods->sml_nvalues[i].bv_val != NULL; i++ ) {
/* test asserted values against themselves */
for( j = 0; j < i; j++ ) {
rc = value_match( &match, mods->sml_desc, mr,
SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
| SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
| SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
&mods->sml_nvalues[i], &mods->sml_nvalues[j], &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
/* value exists already */
snprintf( textbuf, textlen,
"%s: value #%d provided more than once",
mods->sml_desc->ad_cname.bv_val, j );
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
}
#else
rc = modify_check_duplicates( mods->sml_desc, mr,
NULL, mods->sml_bvalues, 0,
&text, textbuf, sizeof( textbuf ) );
#endif
if ( rc != LDAP_SUCCESS ) {
return rc;
}
@ -501,8 +524,12 @@ slap_mods2entry(
mods->sml_values = NULL;
#ifdef SLAP_NVALUES
attr->a_nvals = mods->sml_nvalues;
mods->sml_nvalues = NULL;
if ( mods->sml_nvalues ) {
attr->a_nvals = mods->sml_nvalues;
mods->sml_nvalues = NULL;
} else {
attr->a_nvals = attr->a_vals;
}
#endif
*tail = attr;

View file

@ -27,7 +27,7 @@ attr_free( Attribute *a )
{
ber_bvarray_free( a->a_vals );
#ifdef SLAP_NVALUES
ber_bvarray_free( a->a_nvals );
if (a->a_nvals != a->a_vals) ber_bvarray_free( a->a_nvals );
#endif
free( a );
}
@ -66,7 +66,7 @@ Attribute *attr_dup( Attribute *a )
tmp->a_vals[i].bv_val = NULL;
#ifdef SLAP_NVALUES
if( a->a_nvals != NULL ) {
if( a->a_nvals != a->a_vals ) {
tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval));
for( i=0; a->a_nvals[i].bv_val != NULL; i++ ) {
ber_dupbv( &tmp->a_nvals[i], &a->a_nvals[i] );
@ -75,7 +75,7 @@ Attribute *attr_dup( Attribute *a )
tmp->a_nvals[i].bv_val = NULL;
} else {
tmp->a_nvals = NULL;
tmp->a_nvals = tmp->a_vals;
}
#endif
@ -154,6 +154,7 @@ attr_merge(
#ifdef SLAP_NVALUES
if( !rc && nvals ) rc = value_add( &(*a)->a_nvals, nvals );
else (*a)->a_nvals = (*a)->a_vals;
#endif
return rc;
@ -192,6 +193,7 @@ attr_merge_one(
#ifdef SLAP_NVALUES
if( !rc && nval ) rc = value_add_one( &(*a)->a_nvals, nval );
else (*a)->a_nvals = (*a)->a_vals;
#endif
return rc;
}

View file

@ -203,7 +203,7 @@ dn2entry_retry:
&& op != NULL
&& access_allowed(be, conn, op, e, entry_at,
#ifdef SLAP_NVALUES
attr->a_nvals ? &attr->a_nvals[i] : &attr->a_vals[i],
&attr->a_nvals[i],
#else
&attr->a_vals[i],
#endif
@ -213,8 +213,7 @@ dn2entry_retry:
}
#ifdef SLAP_NVALUES
ber_dupbv( &v[j],
attr->a_nvals ? &attr->a_nvals[i] : &attr->a_vals[i] );
ber_dupbv( &v[j], &attr->a_nvals[i] );
#else
ber_dupbv( &v[j], &attr->a_vals[i] );
#endif

View file

@ -129,7 +129,7 @@ dn2entry_retry:
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals ? a->a_nvals : a->a_vals, &ava->aa_value ) == 0 )
a->a_nvals, &ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
#endif

View file

@ -219,8 +219,7 @@ dn2entry_retry:
#ifdef SLAP_NVALUES
if( value_find_ex( group_at, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH
| SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
attr->a_nvals ? attr->a_nvals : attr->a_vals,
op_ndn ) != LDAP_SUCCESS )
attr->a_nvals, op_ndn ) != LDAP_SUCCESS )
#else
if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS )
#endif

View file

@ -358,8 +358,7 @@ bdb_index_entry(
for ( ; ap != NULL; ap = ap->a_next ) {
#ifdef SLAP_NVALUES
rc = bdb_index_values( be, txn, ap->a_desc,
ap->a_nvals ? ap->a_nvals : ap->a_vals,
e->e_id, op );
ap->a_nvals, e->e_id, op );
#else
rc = bdb_index_values( be, txn, ap->a_desc,
ap->a_vals, e->e_id, op );

View file

@ -211,7 +211,7 @@ int bdb_modify_internal(
if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
rc = bdb_index_values( be, tid, ap->a_desc,
#ifdef SLAP_NVALUES
ap->a_nvals ? ap->a_nvals : ap->a_vals,
ap->a_nvals,
#else
ap->a_vals,
#endif
@ -239,7 +239,7 @@ int bdb_modify_internal(
if (ap->a_flags & SLAP_ATTR_IXADD) {
rc = bdb_index_values( be, tid, ap->a_desc,
#ifdef SLAP_NVALUES
ap->a_nvals ? ap->a_nvals : ap->a_vals,
ap->a_nvals,
#else
ap->a_vals,
#endif

View file

@ -940,6 +940,9 @@ done:
Modifications *tmp;
for (; mod; mod=tmp ) {
tmp = mod->sml_next;
#ifdef SLAP_NVALUES
if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
#endif
free( mod );
}
}

View file

@ -107,8 +107,7 @@ ldbm_back_compare(
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals ? a->a_nvals : a->a_vals,
&ava->aa_value ) == 0 )
a->a_nvals, &ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
#endif

View file

@ -182,8 +182,7 @@ ldbm_back_group(
if( value_find_ex( group_at,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH
| SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
attr->a_nvals ? attr->a_nvals : attr->a_vals,
op_ndn ) != LDAP_SUCCESS )
attr->a_nvals, op_ndn ) != LDAP_SUCCESS )
#else
if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS )
#endif

View file

@ -311,7 +311,7 @@ index_entry(
for ( ; ap != NULL; ap = ap->a_next ) {
index_values( be, ap->a_desc,
#ifdef SLAP_NVALUES
ap->a_nvals ? ap->a_nvals : ap->a_vals,
ap->a_nvals,
#else
ap->a_vals,
#endif

View file

@ -227,7 +227,7 @@ int ldbm_modify_internal(
if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
rc = index_values( be, ap->a_desc,
#ifdef SLAP_NVALUES
ap->a_nvals ? ap->a_nvals : ap->a_vals,
ap->a_nvals,
#else
ap->a_vals,
#endif
@ -253,7 +253,7 @@ int ldbm_modify_internal(
if ( ap->a_flags & SLAP_ATTR_IXADD ) {
rc = index_values( be, ap->a_desc,
#ifdef SLAP_NVALUES
ap->a_nvals ? ap->a_nvals : ap->a_vals,
ap->a_nvals,
#else
ap->a_vals,
#endif

View file

@ -661,6 +661,9 @@ return_results:
if ( mod != NULL ) {
Modifications *tmp;
for (; mod; mod = tmp ) {
#ifdef SLAP_NVALUES
if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
#endif
tmp = mod->sml_next;
free( mod );
}

View file

@ -84,8 +84,7 @@ monitor_back_compare(
#ifdef SLAP_NVALUES
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
a->a_nvals ? a->a_nvals : a->a_vals,
&ava->aa_value ) == 0 )
a->a_nvals, &ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
#endif

View file

@ -358,7 +358,7 @@ static int compare_entry(
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals ? a->a_nvals : a->a_vals,
a->a_nvals,
&ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )

View file

@ -545,7 +545,7 @@ int entry_encode(Entry *e, struct berval *bv)
len += entry_lenlen(i);
siz += sizeof(struct berval); /* empty berval at end */
#ifdef SLAP_NVALUES_ON_DISK
if (a->a_nvals) {
if (a->a_nvals != a->a_vals) {
for (i=0; a->a_nvals[i].bv_val; i++) {
siz += sizeof(struct berval);
len += a->a_nvals[i].bv_len + 1;
@ -590,7 +590,7 @@ int entry_encode(Entry *e, struct berval *bv)
*ptr++ = '\0';
}
#ifdef SLAP_NVALUES_ON_DISK
if (a->a_nvals) {
if (a->a_nvals != a->a_vals) {
entry_putlen(&ptr, i);
for (i=0; a->a_nvals[i].bv_val; i++) {
entry_putlen(&ptr, a->a_nvals[i].bv_len);
@ -725,7 +725,7 @@ int entry_decode(struct berval *bv, Entry **e)
bptr->bv_len = 0;
bptr++;
} else {
a->a_nvals = NULL;
a->a_nvals = a->a_vals;
}
#elif defined(SLAP_NVALUES)
if( count && ad->ad_type->sat_equality &&
@ -756,6 +756,8 @@ int entry_decode(struct berval *bv, Entry **e)
}
a->a_nvals[j].bv_val = NULL;
a->a_nvals[j].bv_len = 0;
} else {
a->a_nvals = a->a_vals;
}
#endif

View file

@ -233,11 +233,11 @@ static int test_mra_filter(
{
struct berval *bv;
#ifdef SLAP_NVALUES
for ( bv = a->a_nvals ? a->a_nvals : a->a_vals;
bv->bv_val != NULL; bv++ )
bv = a->a_nvals;
#else
for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
bv = a->a_vals;
#endif
for ( ; bv->bv_val != NULL; bv++ )
{
int ret;
int rc;
@ -292,8 +292,7 @@ static int test_mra_filter(
/* check match */
#ifdef SLAP_NVALUES
for ( bv = a->a_nvals ? a->a_nvals : a->a_vals;
bv->bv_val != NULL; bv++ )
for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
#else
for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
#endif
@ -447,8 +446,7 @@ test_ava_filter(
}
#ifdef SLAP_NVALUES
for ( bv = a->a_nvals ? a->a_nvals : a->a_vals;
bv->bv_val != NULL; bv++ )
for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
#else
for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
#endif
@ -684,8 +682,7 @@ test_substrings_filter(
}
#ifdef SLAP_NVALUES
for ( bv = a->a_nvals ? a->a_nvals : a->a_vals;
bv->bv_val != NULL; bv++ )
for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
#else
for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
#endif

View file

@ -388,7 +388,12 @@ test_mra_vrFilter(
if( rc != LDAP_SUCCESS ) continue;
}
for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
#ifdef SLAP_NVALUES
bv = a->a_nvals;
#else
bv = a->a_vals;
#endif
for ( j = 0; bv->bv_val != NULL; bv++, j++ ) {
int ret;
int rc;
const char *text;

View file

@ -564,7 +564,7 @@ slap_modrdn2mods(
/* Apply modification */
#ifdef SLAP_NVALUES
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof ( struct berval ) );
+ 4 * sizeof ( struct berval ) );
#else
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 2 * sizeof ( struct berval ) );

View file

@ -31,7 +31,7 @@ modify_check_duplicates(
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS, matched;
#ifdef SLAP_NVALUES
/* needs major reworking */
/* this function is no longer used */
#else
BerVarray nvals = NULL, nmods = NULL;
@ -315,11 +315,6 @@ modify_add_values(
/* check if the values we're adding already exist */
if( mr == NULL || !mr->smr_match ) {
#ifdef SLAP_NVALUES
/* we should have no normalized values as there is no equality rule */
/* assert( mod->sm_nvalues[0].bv_val == NULL); */
#endif
if ( a != NULL ) {
/* do not allow add of additional attribute
if no equality rule exists */
@ -333,11 +328,6 @@ modify_add_values(
for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
/* test asserted values against existing values */
if( a ) {
#ifdef SLAP_NVALUES
/* we should have no normalized values as there
is no equality rule */
assert( a->a_nvals == NULL);
#endif
for( matched = 0, j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
if ( bvmatch( &mod->sm_bvalues[i], &a->a_vals[j] ) ) {
if ( permissive ) {
@ -639,11 +629,13 @@ modify_delete_values(
mr, &a->a_nvals[j],
&mod->sm_nvalues[i] );
} else {
#if 0
assert( a->a_nvals == NULL );
#endif
rc = (*mr->smr_match)( &match,
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
a->a_desc->ad_type->sat_syntax,
mr, &a->a_nvals[j],
mr, &a->a_vals[j],
&mod->sm_values[i] );
}
#else
@ -675,7 +667,7 @@ modify_delete_values(
#ifdef SLAP_NVALUES
free( a->a_vals[j].bv_val );
a->a_vals[j].bv_val = &dummy;
if( a->a_nvals ) {
if( a->a_nvals != a->a_vals ) {
free( a->a_nvals[j].bv_val );
a->a_nvals[j].bv_val = &dummy;
}
@ -723,7 +715,7 @@ modify_delete_values(
if ( j != k ) {
a->a_vals[ j ] = a->a_vals[ k ];
#ifdef SLAP_NVALUES
if (a->a_nvals) {
if (a->a_nvals != a->a_vals) {
a->a_nvals[ j ] = a->a_nvals[ k ];
}
#endif
@ -740,7 +732,7 @@ modify_delete_values(
a->a_vals[j].bv_val = NULL;
#ifdef SLAP_NVALUES
if (a->a_nvals) a->a_nvals[j].bv_val = NULL;
if (a->a_nvals != a->a_vals) a->a_nvals[j].bv_val = NULL;
#else
assert( i == k - j );

View file

@ -66,7 +66,7 @@ slap_operational_hasSubordinate( int hs )
a->a_vals[1].bv_val = NULL;
#ifdef SLAP_NVALUES
a->a_nvals = NULL;
a->a_nvals = a->a_vals;
#endif
a->a_next = NULL;

View file

@ -101,7 +101,7 @@ root_dse_info(
vals[0].bv_val = "top";
vals[0].bv_len = sizeof("top")-1;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
if( attr_merge( e, ad_objectClass, vals, NULL ) )
#else
if( attr_merge( e, ad_objectClass, vals ) )
#endif
@ -112,13 +112,13 @@ root_dse_info(
vals[0].bv_val = "OpenLDAProotDSE";
vals[0].bv_len = sizeof("OpenLDAProotDSE")-1;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
if( attr_merge( e, ad_objectClass, vals, NULL ) )
#else
if( attr_merge( e, ad_objectClass, vals ) )
#endif
return LDAP_OTHER;
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_structuralObjectClass, vals, vals ) )
if( attr_merge( e, ad_structuralObjectClass, vals, NULL ) )
#else
if( attr_merge( e, ad_structuralObjectClass, vals ) )
#endif
@ -128,6 +128,7 @@ root_dse_info(
if ( backends[i].be_flags & SLAP_BFLAG_MONITOR ) {
vals[0] = backends[i].be_suffix[0];
#ifdef SLAP_NVALUES
nvals[0] = backends[i].be_nsuffix[0];
if( attr_merge( e, ad_monitorContext, vals, nvals ) )
#else
if( attr_merge( e, ad_monitorContext, vals ) )
@ -143,7 +144,8 @@ root_dse_info(
for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) {
vals[0] = backends[i].be_suffix[j];
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_namingContexts, vals, NULL ) )
nvals[0] = backends[i].be_nsuffix[0];
if( attr_merge( e, ad_namingContexts, vals, nvals ) )
#else
if( attr_merge( e, ad_namingContexts, vals ) )
#endif
@ -191,7 +193,7 @@ root_dse_info(
/* supportedFeatures */
#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedFeatures,
supportedFeatures, supportedFeatures ) )
supportedFeatures, NULL ) )
#else
if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) )
#endif
@ -255,7 +257,8 @@ root_dse_info(
Attribute *a;
for( a = usr_attr->e_attrs; a != NULL; a = a->a_next ) {
#ifdef SLAP_NVALUES
if( attr_merge( e, a->a_desc, a->a_vals, a->a_nvals ) )
if( attr_merge( e, a->a_desc, a->a_vals,
(a->a_nvals == a->a_vals) ? NULL : a->a_nvals ) )
#else
if( attr_merge( e, a->a_desc, a->a_vals ) )
#endif
@ -332,7 +335,8 @@ int read_root_dse_file( const char *fname )
for(a = e->e_attrs; a != NULL; a = a->a_next) {
#ifdef SLAP_NVALUES
if( attr_merge( usr_attr, a->a_desc, a->a_vals, a->a_nvals ) )
if( attr_merge( usr_attr, a->a_desc, a->a_vals,
(a->a_nvals == a->a_vals) ? NULL : a->a_nvals ) )
#else
if( attr_merge( usr_attr, a->a_desc, a->a_vals ) )
#endif

View file

@ -859,7 +859,7 @@ entry_naming_check(
#ifdef SLAP_NVALUES
if ( value_find_ex( desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
attr->a_nvals ? attr->a_nvals : attr->a_vals,
attr->a_nvals,
&ava->la_value ) != 0 )
#else
if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 )