at = attrs_find( at->a_next, b->a_dn_at ) )
{
if( value_find_ex( b->a_dn_at,
-#ifdef SLAP_NVALUES
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_nvals,
-#else
- SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- at->a_vals,
-#endif
&bv ) == 0 )
{
/* found it */
for ( i = 0; at->a_vals[i].bv_val != NULL; i++ ) {
if (aci_mask( op,
e, desc, val,
-#ifdef SLAP_NVALUES
&at->a_nvals[i],
-#else
- &at->a_vals[i],
-#endif
matches, &grant, &deny ) != 0)
{
tgrant |= grant;
case LDAP_MOD_ADD:
assert( mlist->sml_bvalues != NULL );
-#ifdef SLAP_NVALUES
for ( bv = mlist->sml_nvalues
? mlist->sml_nvalues : mlist->sml_values;
bv->bv_val != NULL; bv++ )
-#else
- for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ )
-#endif
{
if ( ! access_allowed( op, e,
mlist->sml_desc, bv, ACL_WRITE, &state ) )
}
break;
}
-#ifdef SLAP_NVALUES
for ( bv = mlist->sml_nvalues
? mlist->sml_nvalues : mlist->sml_values;
bv->bv_val != NULL; bv++ )
-#else
- for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ )
-#endif
{
if ( ! access_allowed( op, e,
mlist->sml_desc, bv, ACL_WRITE, &state ) )
at = attrs_find( at->a_next, ad ) )
{
if (value_find_ex( ad,
-#ifdef SLAP_NVALUES
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_nvals,
-#else
- SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- at->a_vals,
-#endif
&bv) == 0 )
{
rc = 1;
Modifications *mod;
ber_tag_t rtag;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_values );
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_values = tmp.sml_values;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
ch_free( mods->sml_values );
mods->sml_values = NULL;
-#ifdef SLAP_NVALUES
if( mods->sml_nvalues ) {
attr->a_nvals = ch_realloc( attr->a_nvals,
sizeof( struct berval ) * (i+j) );
} else {
attr->a_nvals = attr->a_vals;
}
-#endif
continue;
#else
} else {
int rc;
-#ifdef SLAP_NVALUES
int match;
for ( i = 0; mods->sml_nvalues[i].bv_val != NULL; i++ ) {
}
}
}
-#else
- rc = modify_check_duplicates( mods->sml_desc, mr,
- NULL, mods->sml_bvalues, 0,
- text, textbuf, textlen );
-#endif
if ( rc != LDAP_SUCCESS ) {
return rc;
}
attr->a_vals = mods->sml_values;
mods->sml_values = NULL;
-#ifdef SLAP_NVALUES
if ( mods->sml_nvalues ) {
attr->a_nvals = mods->sml_nvalues;
mods->sml_nvalues = NULL;
} else {
attr->a_nvals = attr->a_vals;
}
-#endif
*tail = attr;
tail = &attr->a_next;
AttributeDescription *ad_attributeTypes = slap_schema.si_ad_attributeTypes;
AttributeType *at;
struct berval val;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH(at,&attr_list,sat_next) {
if( at->sat_flags & SLAP_AT_HIDE ) continue;
return -1;
}
-#ifdef SLAP_NVALUES
nval.bv_val = at->sat_oid;
nval.bv_len = strlen(at->sat_oid);
if( attr_merge_one( e, ad_attributeTypes, &val, &nval ) )
-#else
- if( attr_merge_one( e, ad_attributeTypes, &val ) )
-#endif
{
return -1;
}
attr_free( Attribute *a )
{
ber_bvarray_free( a->a_vals );
-#ifdef SLAP_NVALUES
if (a->a_nvals != a->a_vals) ber_bvarray_free( a->a_nvals );
-#endif
free( a );
}
}
tmp->a_vals[i].bv_val = NULL;
-#ifdef SLAP_NVALUES
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++ ) {
} else {
tmp->a_nvals = tmp->a_vals;
}
-#endif
} else {
tmp->a_vals = NULL;
-#ifdef SLAP_NVALUES
tmp->a_nvals = NULL;
-#endif
}
tmp->a_desc = a->a_desc;
Entry *e,
AttributeDescription *desc,
BerVarray vals
-#ifdef SLAP_NVALUES
, BerVarray nvals
-#endif
) {
int rc;
*a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc;
(*a)->a_vals = NULL;
-#ifdef SLAP_NVALUES
(*a)->a_nvals = NULL;
-#endif
(*a)->a_next = NULL;
(*a)->a_flags = 0;
}
rc = value_add( &(*a)->a_vals, vals );
-#ifdef SLAP_NVALUES
if( !rc && nvals ) rc = value_add( &(*a)->a_nvals, nvals );
else (*a)->a_nvals = (*a)->a_vals;
-#endif
return rc;
}
Entry *e,
AttributeDescription *desc,
struct berval *val
-#ifdef SLAP_NVALUES
, struct berval *nval
-#endif
) {
int rc;
Attribute **a;
*a = (Attribute *) ch_malloc( sizeof(Attribute) );
(*a)->a_desc = desc;
(*a)->a_vals = NULL;
-#ifdef SLAP_NVALUES
(*a)->a_nvals = NULL;
-#endif
(*a)->a_next = NULL;
(*a)->a_flags = 0;
}
rc = value_add_one( &(*a)->a_vals, val );
-#ifdef SLAP_NVALUES
if( !rc && nval ) rc = value_add_one( &(*a)->a_nvals, nval );
else (*a)->a_nvals = (*a)->a_vals;
-#endif
return rc;
}
return rc;
}
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize(
aa->aa_desc, ad_mr(aa->aa_desc, usage),
usage, &value, &aa->aa_value, text );
-#else
- rc = value_validate_normalize( aa->aa_desc, usage,
- &value, &aa->aa_value, text );
-#endif
if( rc != LDAP_SUCCESS ) {
ch_free( aa );
{
rs->sr_err = LDAP_COMPARE_FALSE;
-#ifdef SLAP_NVALUES
if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#else
- if ( value_find( op->oq_compare.rs_ava->aa_desc, a->a_vals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#endif
{
rs->sr_err = LDAP_COMPARE_TRUE;
break;
/* add each attribute to the indexes */
for ( ; ap != NULL; ap = ap->a_next ) {
-#ifdef SLAP_NVALUES
rc = bdb_index_values( be, txn, ap->a_desc,
ap->a_nvals, e->e_id, op );
-#else
- rc = bdb_index_values( be, txn, ap->a_desc,
- ap->a_vals, e->e_id, op );
-#endif
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
rc = bdb_index_values( op->o_bd, tid, ap->a_desc,
-#ifdef SLAP_NVALUES
ap->a_nvals,
-#else
- ap->a_vals,
-#endif
e->e_id, SLAP_INDEX_DELETE_OP );
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
if (ap->a_flags & SLAP_ATTR_IXADD) {
rc = bdb_index_values( op->o_bd, tid, ap->a_desc,
-#ifdef SLAP_NVALUES
ap->a_nvals,
-#else
- ap->a_vals,
-#endif
e->e_id, SLAP_INDEX_ADD_OP );
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
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 );
}
}
ml.sml_desc = slap_schema.si_ad_userPassword;
ml.sml_values = vals;
-#ifdef SLAP_NVALUES
ml.sml_nvalues = NULL;
-#endif
ml.sml_op = LDAP_MOD_REPLACE;
ml.sml_next = NULL;
v = a->a_vals;
if (a->a_vals != &dummy)
ber_bvarray_free(a->a_vals);
-#ifdef SLAP_NVALUES
if (a->a_nvals != v)
ber_bvarray_free(a->a_nvals);
-#endif
ch_free(a);
}
const char *text;
int last;
int private = flags & LDAP_BUILD_ENTRY_PRIVATE;
-#ifdef SLAP_NVALUES
int normalize = flags & LDAP_BUILD_ENTRY_NORMALIZE;
-#endif /* SLAP_NVALUES */
/* safe assumptions ... */
assert( ent );
next_attr:;
-#ifdef SLAP_NVALUES
if ( normalize ) {
if ( last && attr->a_desc->ad_type->sat_equality &&
attr->a_desc->ad_type->sat_equality->smr_normalize ) {
} else {
attr->a_nvals = NULL;
}
-#endif
*attrp = attr;
attrp = &attr->a_next;
}
{
rs->sr_err = LDAP_COMPARE_FALSE;
-#ifdef SLAP_NVALUES
if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#else
- if ( value_find( op->oq_compare.rs_ava->aa_desc, a->a_vals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#endif
{
rs->sr_err = LDAP_COMPARE_TRUE;
break;
/* add each attribute to the indexes */
for ( ; ap != NULL; ap = ap->a_next ) {
index_values( be, ap->a_desc,
-#ifdef SLAP_NVALUES
ap->a_nvals,
-#else
- ap->a_vals,
-#endif
e->e_id, op );
}
for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
rc = index_values( op->o_bd, ap->a_desc,
-#ifdef SLAP_NVALUES
ap->a_nvals,
-#else
- ap->a_vals,
-#endif
e->e_id, SLAP_INDEX_DELETE_OP );
if ( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
if ( ap->a_flags & SLAP_ATTR_IXADD ) {
rc = index_values( op->o_bd, ap->a_desc,
-#ifdef SLAP_NVALUES
ap->a_nvals,
-#else
- ap->a_vals,
-#endif
e->e_id, SLAP_INDEX_ADD_OP );
if ( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
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 );
}
ml.sml_desc = slap_schema.si_ad_userPassword;
ml.sml_values = vals;
-#ifdef SLAP_NVALUES
ml.sml_nvalues = vals;
-#endif
ml.sml_op = LDAP_MOD_REPLACE;
ml.sml_next = NULL;
a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc )) {
rs->sr_err = LDAP_COMPARE_FALSE;
-#ifdef SLAP_NVALUES
if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#else
- if ( value_find( ava->aa_desc, a->a_vals,
- &op->oq_compare.rs_ava->aa_value ) == 0 )
-#endif
{
rs->sr_err = LDAP_COMPARE_TRUE;
break;
const char *text = NULL;
struct berval asserted;
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize(
mod->sm_desc, mr,
SLAP_MR_EQUALITY,
&mod->sm_bvalues[i],
&asserted,
&text );
-#else
- rc = value_normalize( mod->sm_desc,
- SLAP_MR_EQUALITY,
- &mod->sm_bvalues[i],
- &asserted,
- &text );
-#endif
if ( rc != LDAP_SUCCESS ) {
return rc;
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
-#ifdef SLAP_NVALUES
0,
-#else
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
-#endif
&a->a_vals[j], &asserted, &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
struct berval asserted;
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize(
mod->sm_desc, mr,
SLAP_MR_EQUALITY,
&mod->sm_bvalues[i],
&asserted,
&text );
-#else
- rc = value_normalize( mod->sm_desc,
- SLAP_MR_EQUALITY,
- &mod->sm_bvalues[i],
- &asserted,
- &text );
-#endif
if( rc != LDAP_SUCCESS ) return rc;
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
-#ifdef SLAP_NVALUES
0,
-#else
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
-#endif
&a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ))
{
rs->sr_err = LDAP_COMPARE_FALSE;
-#ifdef SLAP_NVALUES
if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#else
- if ( value_find( op->oq_compare.rs_ava->aa_desc, a->a_vals, &op->oq_compare.rs_ava->aa_value ) == 0 )
-#endif
{
rs->sr_err = LDAP_COMPARE_TRUE;
break;
if ( e ) {
a = attr_find( e->e_attrs, group_at );
if ( a ) {
-#ifdef SLAP_NVALUES
rc = value_find_ex( group_at,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals, op_ndn );
-#else
- rc = value_find_ex( group_at, 0, a->a_vals, op_ndn );
-#endif
} else {
rc = LDAP_NO_SUCH_ATTRIBUTE;
}
for ( i=0,j=0; a->a_vals[i].bv_val; i++ ) {
if ( op->o_conn && access_allowed( op,
e, entry_at,
-#ifdef SLAP_NVALUES
&a->a_nvals[i],
-#else
- &a->a_vals[i],
-#endif
ACL_AUTH, &acl_state ) == 0 ) {
continue;
}
ber_dupbv( &v[j],
-#ifdef SLAP_NVALUES
&a->a_nvals[i]
-#else
- &a->a_vals[i]
-#endif
);
if (v[j].bv_val ) j++;
}
goto cleanup;
}
-#ifdef SLAP_NVALUES
rs->sr_err = asserted_value_validate_normalize( ava.aa_desc,
ava.aa_desc->ad_type->sat_equality,
SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&value, &ava.aa_value, &rs->sr_text );
-#else
- rs->sr_err = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
- &value, &ava.aa_value, &rs->sr_text );
-#endif
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
goto cleanup;
{
rc = LDAP_COMPARE_FALSE;
-#ifdef SLAP_NVALUES
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
a->a_nvals,
&ava->aa_value ) == 0 )
-#else
- if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
-#endif
{
rc = LDAP_COMPARE_TRUE;
break;
LDAP_SLIST_FOREACH( sc, &controls_list, sc_next ) {
vals[0].bv_val = sc->sc_oid;
vals[0].bv_len = strlen( sc->sc_oid );
-#ifdef SLAP_NVALUES
if ( attr_merge( e, ad_supportedControl, vals, NULL ) )
-#else
- if ( attr_merge( e, ad_supportedControl, vals ) )
-#endif /* SLAP_NVALUES */
return -1;
}
ContentRule *cr;
struct berval val;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH(cr, &cr_list, scr_next) {
if ( ldap_contentrule2bv( &cr->scr_crule, &val ) == NULL ) {
(long) val.bv_len, val.bv_val, 0 );
#endif
-#ifdef SLAP_NVALUES
nval.bv_val = cr->scr_oid;
nval.bv_len = strlen(cr->scr_oid);
if( attr_merge_one( e, ad_ditContentRules, &val, &nval ) )
-#else
- if( attr_merge_one( e, ad_ditContentRules, &val ) )
-#endif
{
return -1;
}
LDAPAVA *ava = rdn[ 0 ][ iAVA ];
AttributeDescription *ad;
slap_syntax_validate_func *validf = NULL;
-#ifdef SLAP_NVALUES
slap_mr_normalize_func *normf = NULL;
-#endif
slap_syntax_transform_func *transf = NULL;
MatchingRule *mr = NULL;
struct berval bv = { 0, NULL };
} else { /* normalization */
validf = ad->ad_type->sat_syntax->ssyn_validate;
mr = ad->ad_type->sat_equality;
-#ifdef SLAP_NVALUES
if( mr ) normf = mr->smr_normalize;
-#else
- transf = ad->ad_type->sat_syntax->ssyn_normalize;
-#endif
}
if ( validf ) {
if ( transf ) {
/*
-#ifdef SLAP_NVALUES
* transform value by pretty function
-#else
- * transform value by normalize/pretty function
-#endif
* if value is empty, use empty_bv
*/
rc = ( *transf )( ad->ad_type->sat_syntax,
}
}
-#ifdef SLAP_NVALUES
if ( normf ) {
/*
* normalize value
}
}
-#else
- if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
- char *s = bv.bv_val;
-
- if ( UTF8bvnormalize( &bv, &bv,
- LDAP_UTF8_CASEFOLD ) == NULL ) {
- return LDAP_INVALID_SYNTAX;
- }
- free( s );
- }
-#endif
if( bv.bv_val ) {
free( ava->la_value.bv_val );
}
int
-#ifdef SLAP_NVALUES
dnNormalize(
slap_mask_t use,
Syntax *syntax,
MatchingRule *mr,
struct berval *val,
struct berval *out )
-#else
-dnNormalize(
- Syntax *syntax,
- struct berval *val,
- struct berval *out )
-#endif
{
assert( val );
assert( out );
Entry *e;
char *type;
struct berval vals[2];
-#ifdef SLAP_NVALUES
struct berval nvals[2], *nvalsp;
-#endif
AttributeDescription *ad;
const char *text;
char *next;
}
}
-#ifdef SLAP_NVALUES
nvalsp = NULL;
nvals[0].bv_val = NULL;
nvalsp = &nvals[0];
}
-#endif
-#ifdef SLAP_NVALUES
rc = attr_merge( e, ad, vals, nvalsp );
-#else
- rc = attr_merge( e, ad, vals );
-#endif
if( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
free( type );
free( vals[0].bv_val );
-#ifdef SLAP_NVALUES
free( nvals[0].bv_val );
-#endif
}
/* check to make sure there was a dn: line */
}
len += entry_lenlen(i);
siz += sizeof(struct berval); /* empty berval at end */
-#ifdef SLAP_NVALUES
if (a->a_nvals != a->a_vals) {
for (i=0; a->a_nvals[i].bv_val; i++) {
siz += sizeof(struct berval);
} else {
len += entry_lenlen(0); /* 0 nvals */
}
-#endif
}
len += 1; /* NUL byte at end */
len += entry_lenlen(siz);
ptr += a->a_vals[i].bv_len;
*ptr++ = '\0';
}
-#ifdef SLAP_NVALUES
if (a->a_nvals != a->a_vals) {
entry_putlen(&ptr, i);
for (i=0; a->a_nvals[i].bv_val; i++) {
} else {
entry_putlen(&ptr, 0);
}
-#endif
}
}
*ptr = '\0';
bptr->bv_len = 0;
bptr++;
-#ifdef SLAP_NVALUES
j = entry_getlen(&ptr);
if (j) {
a->a_nvals = bptr;
} else {
a->a_nvals = a->a_vals;
}
-#endif
}
if (a) a->a_next = NULL;
ValuesReturnFilter **f,
const char **text );
-#ifdef SLAP_NVALUES
#define XXX 1
-#endif
int
get_filter(
goto return_error;
}
-#ifdef SLAP_NVALUES
/* validate/normalize using equality matching rule validator! */
rc = asserted_value_validate_normalize(
ssa.sa_desc, ssa.sa_desc->ad_type->sat_equality,
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
-#else
- /* validate using equality matching rule validator! */
- rc = value_validate( ssa.sa_desc->ad_type->sat_equality,
- &value, text );
- if( rc != LDAP_SUCCESS ) {
- goto return_error;
- }
-
- rc = value_normalize( ssa.sa_desc, usage,
- &value, &nvalue, text );
-
- if( rc != LDAP_SUCCESS ) {
- goto return_error;
- }
-#endif
rc = LDAP_PROTOCOL_ERROR;
goto return_error;
}
-#ifdef SLAP_NVALUES
/* validate/normalize using equality matching rule validator! */
rc = asserted_value_validate_normalize(
vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_equality,
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
-#else
- /* valiate using equality matching rule validator! */
- rc = value_validate( vrf->vrf_sub_desc->ad_type->sat_equality,
- &value, text );
- if( rc != LDAP_SUCCESS ) {
- goto return_error;
- }
-
- rc = value_normalize( vrf->vrf_sub_desc, usage,
- &value, &bv, text );
- if( rc != LDAP_SUCCESS ) {
- goto return_error;
- }
-#endif
value = bv;
a = attrs_find( a->a_next, mra->ma_desc ) )
{
struct berval *bv;
-#ifdef SLAP_NVALUES
/* If ma_rule is not the same as the attribute's
* normal rule, then we can't use the a_nvals.
*/
if (mra->ma_rule == a->a_desc->ad_type->sat_equality)
bv = a->a_nvals;
else
-#endif
bv = a->a_vals;
for ( ; bv->bv_val != NULL; bv++ )
{
}
/* normalize for equality */
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
-#else
- rc = value_validate_normalize( a->a_desc,
- SLAP_MR_EQUALITY,
- &mra->ma_value, &value, &text );
-#endif
if ( rc != LDAP_SUCCESS ) {
continue;
}
}
/* check match */
-#ifdef SLAP_NVALUES
if (mra->ma_rule == a->a_desc->ad_type->sat_equality)
bv = a->a_nvals;
else
-#endif
bv = a->a_vals;
for ( ; bv->bv_val != NULL; bv++ )
{
}
/* normalize for equality */
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( ad,
mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
-#else
- rc = value_validate_normalize( ad, SLAP_MR_EQUALITY,
- &mra->ma_value, &value, &text );
-#endif
if ( rc != LDAP_SUCCESS ) {
continue;
}
continue;
}
-#ifdef SLAP_NVALUES
for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
-#else
- for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
-#endif
{
int ret;
int rc;
continue;
}
-#ifdef SLAP_NVALUES
for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ )
-#else
- for ( bv = a->a_vals; bv->bv_val != NULL; bv++ )
-#endif
{
int ret;
int rc;
}
-#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;
continue;
}
-#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;
continue;
}
-#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
-#else
- /* normalize for equality */
- rc = value_validate_normalize( a->a_desc,
- SLAP_MR_EQUALITY,
- &mra->ma_value, &value,
- &text );
-#endif
if( rc != LDAP_SUCCESS ) continue;
}
-#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;
ber_int_t mop;
Modifications tmp, *mod;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
&tmp.sml_type, &tmp.sml_values )
mod->sml_op = mop;
mod->sml_type = tmp.sml_type;
mod->sml_values = tmp.sml_values;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
mod->sml_desc = NULL;
mod->sml_next = NULL;
*modtail = mod;
return LDAP_CONSTRAINT_VIOLATION;
}
-#ifdef SLAP_NVALUES
if( nvals && ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_normalize )
{
ml->sml_nvalues[nvals].bv_val = NULL;
ml->sml_nvalues[nvals].bv_len = 0;
}
-#endif
}
}
char *textbuf, size_t textlen )
{
struct berval name, timestamp, csn;
-#ifdef SLAP_NVALUES
struct berval nname;
-#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
Modifications *mod;
if( op->o_dn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
-#ifdef SLAP_NVALUES
nname = name;
-#endif
} else {
name = op->o_dn;
-#ifdef SLAP_NVALUES
nname = op->o_ndn;
-#endif
}
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &tmpval );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
}
/* Apply modification */
-#ifdef SLAP_NVALUES
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 4 * sizeof( struct berval ) );
-#else
- mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval ) );
-#endif
mod_tmp->sml_desc = desc;
mod_tmp->sml_values = ( BerVarray )( mod_tmp + 1 );
mod_tmp->sml_values[0] = new_rdn[0][a_cnt]->la_value;
mod_tmp->sml_values[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)(
} else {
mod_tmp->sml_nvalues = NULL;
}
-#endif
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
}
/* Apply modification */
-#ifdef SLAP_NVALUES
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 4 * sizeof ( struct berval ) );
-#else
- mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof ( struct berval ) );
-#endif
mod_tmp->sml_desc = desc;
mod_tmp->sml_values = ( BerVarray )(mod_tmp+1);
mod_tmp->sml_values[0] = old_rdn[0][d_cnt]->la_value;
mod_tmp->sml_values[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)(
} else {
mod_tmp->sml_nvalues = NULL;
}
-#endif
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;
{
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS, matched;
-#ifdef SLAP_NVALUES
/* this function is no longer used */
-#else
- BerVarray nvals = NULL, nmods = NULL;
-
- /*
- * FIXME: better do the following
- *
- * - count the existing values
- * - count the new values
- *
- * - if the existing values are less than the new ones {
- * - normalize all the existing values
- * - for each new value {
- * - normalize
- * - check with existing
- * - cross-check with already normalized new vals
- * }
- * } else {
- * - for each new value {
- * - normalize
- * - cross-check with already normalized new vals
- * }
- * - for each existing value {
- * - normalize
- * - check with already normalized new values
- * }
- * }
- *
- * The first case is good when adding a lot of new values,
- * and significantly at first import of values (e.g. adding
- * a new group); the latter case seems to be quite important
- * as well, because it is likely to be the most frequently
- * used when administering the entry. The current
- * implementation will always normalize all the existing
- * values before checking. If there's no duplicate, the
- * performances should not change; they will in case of error.
- */
-
- for ( nummods = 0; mods[ nummods ].bv_val != NULL; nummods++ )
- /* count new values */ ;
-
- if ( vals ) {
- for ( numvals = 0; vals[ numvals ].bv_val != NULL; numvals++ )
- /* count existing values */ ;
-
- if ( numvals < nummods ) {
- nvals = SLAP_CALLOC( numvals + 1, sizeof( struct berval ) );
- if( nvals == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
-#endif
- goto return_results;
- }
-
- /* normalize the existing values first */
- for ( j = 0; vals[ j ].bv_val != NULL; j++ ) {
- rc = value_normalize( ad, SLAP_MR_EQUALITY,
- &vals[ j ], &nvals[ j ], text );
-
- /* existing attribute values must normalize */
- assert( rc == LDAP_SUCCESS );
-
- if ( rc != LDAP_SUCCESS ) {
- nvals[ j ].bv_val = NULL;
- goto return_results;
- }
- }
- nvals[ j ].bv_val = NULL;
- }
- }
-
- /*
- * If the existing values are less than the new values,
- * it is more convenient to normalize all the existing
- * values and test each new value against them first,
- * then to other already normalized values
- */
- nmods = SLAP_CALLOC( nummods + 1, sizeof( struct berval ) );
- if ( nmods == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "modify_check_duplicates: SLAP_CALLOC failed", 0, 0, 0 );
-#endif
- goto return_results;
- }
-
- for ( i=0; mods[i].bv_val != NULL; i++ ) {
- rc = value_normalize( ad, SLAP_MR_EQUALITY,
- &mods[i], &nmods[i], text );
-
- if ( rc != LDAP_SUCCESS ) {
- nmods[i].bv_val = NULL;
- goto return_results;
- }
-
- if ( numvals > 0 && numvals < nummods ) {
- for ( matched=0, j=0; nvals[j].bv_val; j++ ) {
- int match;
-
- rc = (*mr->smr_match)( &match,
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- ad->ad_type->sat_syntax,
- mr, &nmods[ i ], &nvals[ j ] );
-
- if ( rc != LDAP_SUCCESS ) {
- nmods[ i + 1 ].bv_val = NULL;
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: matching rule failed",
- ad->ad_cname.bv_val );
- goto return_results;
- }
-
- if ( match == 0 ) {
- if ( permissive ) {
- matched++;
- continue;
- }
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: value #%d provided more than once",
- ad->ad_cname.bv_val, i );
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- nmods[ i + 1 ].bv_val = NULL;
- goto return_results;
- }
- }
-
- if ( permissive && matched == j ) {
- nmods[ i + 1 ].bv_val = NULL;
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- goto return_results;
- }
- }
-
- for ( matched = 0, j = 0; j < i; j++ ) {
- int match;
-
- rc = (*mr->smr_match)( &match,
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- ad->ad_type->sat_syntax,
- mr, &nmods[ i ], &nmods[ j ] );
- if ( rc != LDAP_SUCCESS ) {
- nmods[ i + 1 ].bv_val = NULL;
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: matching rule failed",
- ad->ad_cname.bv_val );
- goto return_results;
- }
-
- if ( match == 0 ) {
- if ( permissive ) {
- matched++;
- continue;
- }
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: value #%d provided more than once",
- ad->ad_cname.bv_val, j );
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- nmods[ i + 1 ].bv_val = NULL;
- goto return_results;
- }
- }
-
- if ( permissive && matched == j ) {
- nmods[ i + 1 ].bv_val = NULL;
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- goto return_results;
- }
- }
- nmods[ i ].bv_val = NULL;
-
- /*
- * if new values are more than existing values, it is more
- * convenient to normalize and check all new values first,
- * then check each new value against existing values, which
- * can be normalized in place
- */
-
- if ( numvals >= nummods ) {
- for ( j = 0; vals[ j ].bv_val; j++ ) {
- struct berval asserted;
-
- rc = value_normalize( ad, SLAP_MR_EQUALITY,
- &vals[ j ], &asserted, text );
-
- if ( rc != LDAP_SUCCESS ) {
- goto return_results;
- }
-
- for ( matched = 0, i = 0; nmods[ i ].bv_val; i++ ) {
- int match;
-
- rc = (*mr->smr_match)( &match,
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- ad->ad_type->sat_syntax,
- mr, &nmods[ i ], &asserted );
- if ( rc != LDAP_SUCCESS ) {
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: matching rule failed",
- ad->ad_cname.bv_val );
- goto return_results;
- }
-
- if ( match == 0 ) {
- if ( permissive ) {
- matched++;
- continue;
- }
- *text = textbuf;
- snprintf( textbuf, textlen,
- "%s: value #%d provided more than once",
- ad->ad_cname.bv_val, j );
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- goto return_results;
- }
- }
-
- if ( permissive && matched == i ) {
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- goto return_results;
- }
- }
- }
-
-return_results:;
- if ( nvals ) {
- ber_bvarray_free( nvals );
- }
- if ( nmods ) {
- ber_bvarray_free( nmods );
- }
-
-#endif
return rc;
}
}
} else {
-#ifdef SLAP_NVALUES
/* no normalization is done in this routine nor
* in the matching routines called by this routine.
* values are now normalized once on input to the
* This should outperform the old code. No numbers
* are available yet.
*/
-#else
- /*
- * The original code performs ( n ) normalizations
- * and ( n * ( n - 1 ) / 2 ) matches, which hide
- * the same number of normalizations. The new code
- * performs the same number of normalizations ( n )
- * and ( n * ( n - 1 ) / 2 ) mem compares, far less
- * expensive than an entire match, if a match is
- * equivalent to a normalization and a mem compare ...
- *
- * This is far more memory expensive than the previous,
- * but it can heavily improve performances when big
- * chunks of data are added (typical example is a group
- * with thousands of DN-syntax members; on my system:
- * for members of 5-RDN DNs,
-
- members orig bvmatch (dirty) new
- 1000 0m38.456s 0m0.553s 0m0.608s
- 2000 2m33.341s 0m0.851s 0m1.003s
-
- * Moreover, 100 groups with 10000 members each were
- * added in 37m27.933s (an analogous LDIF file was
- * loaded into Active Directory in 38m28.682s, BTW).
- *
- * Maybe we could switch to the new algorithm when
- * the number of values overcomes a given threshold?
- */
-#endif
int rc;
if ( mod->sm_bvalues[1].bv_val == 0 ) {
if ( a != NULL ) {
int i;
-#ifndef SLAP_NVALUES
- struct berval asserted;
- rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
- &mod->sm_bvalues[ 0 ], &asserted, text );
- if ( rc != LDAP_SUCCESS ) {
- return rc;
- }
-#endif
for ( matched = 0, i = 0; a->a_vals[ i ].bv_val; i++ ) {
int match;
-#ifdef SLAP_NVALUES
if( mod->sm_nvalues ) {
rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_EQUALITY
text );
}
-#else
- rc = value_match( &match, mod->sm_desc, mr,
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- &a->a_vals[i],
- &asserted,
- text );
-#endif
if( rc == LDAP_SUCCESS && match == 0 ) {
if ( permissive ) {
matched++;
continue;
}
-#ifndef SLAP_NVALUES
- free( asserted.bv_val );
-#endif
*text = textbuf;
snprintf( textbuf, textlen,
"modify/%s: %s: value #0 already exists",
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
-#ifndef SLAP_NVALUES
- free( asserted.bv_val );
-#endif
if ( permissive && matched == i ) {
/* values already exist; do nothing */
return LDAP_SUCCESS;
}
/* no - add them */
-#ifdef SLAP_NVALUES
if( attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues ) != 0 )
-#else
- if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 )
-#endif
{
/* this should return result of attr_merge */
*text = textbuf;
int i, j, k, rc = LDAP_SUCCESS;
Attribute *a;
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
-#ifndef SLAP_NVALUES
- BerVarray nvals = NULL;
-#endif
char dummy = '\0';
/*
return LDAP_NO_SUCH_ATTRIBUTE;
}
-#ifndef SLAP_NVALUES
- /* find each value to delete */
- for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ )
- /* count existing values */ ;
-
- nvals = (BerVarray)SLAP_CALLOC( j + 1, sizeof ( struct berval ) );
- if( nvals == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, ERR,
- "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "modify_delete_values: SLAP_CALLOC failed", 0, 0, 0 );
-#endif
- goto return_results;
- }
-
- /* normalize existing values */
- for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ ) {
- rc = value_normalize( a->a_desc, SLAP_MR_EQUALITY,
- &a->a_vals[ j ], &nvals[ j ], text );
-
- if ( rc != LDAP_SUCCESS ) {
- nvals[ j ].bv_val = NULL;
- goto return_results;
- }
- }
-#endif
for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
int found = 0;
-#ifndef SLAP_NVALUES
- struct berval asserted;
-
- /* normalize the value to be deleted */
- rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
- &mod->sm_bvalues[ i ], &asserted, text );
-
- if( rc != LDAP_SUCCESS ) {
- goto return_results;
- }
-
- /* search it */
- for ( j = 0; nvals[ j ].bv_val != NULL; j++ )
-#else
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ )
-#endif
{
int match;
-#ifndef SLAP_NVALUES
- if ( nvals[j].bv_val == &dummy ) {
- continue;
- }
-
-#endif
-#ifdef SLAP_NVALUES
if( mod->sm_nvalues ) {
assert( a->a_nvals );
rc = (*mr->smr_match)( &match,
mr, &a->a_vals[j],
&mod->sm_values[i] );
}
-#else
- rc = (*mr->smr_match)( &match,
- SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- a->a_desc->ad_type->sat_syntax,
- mr, &nvals[ j ],
- &asserted );
-#endif
if ( rc != LDAP_SUCCESS ) {
-#ifndef SLAP_NVALUES
- free( asserted.bv_val );
-#endif
*text = textbuf;
snprintf( textbuf, textlen,
"%s: matching rule failed",
found = 1;
/* delete value and mark it as dummy */
-#ifdef SLAP_NVALUES
free( a->a_vals[j].bv_val );
a->a_vals[j].bv_val = &dummy;
if( a->a_nvals != a->a_vals ) {
free( a->a_nvals[j].bv_val );
a->a_nvals[j].bv_val = &dummy;
}
-#else
- free( nvals[ j ].bv_val );
- nvals[ j ].bv_val = &dummy;
-#endif
break;
}
-#ifndef SLAP_NVALUES
- free( asserted.bv_val );
-#endif
if ( found == 0 ) {
*text = textbuf;
}
/* compact array skipping dummies */
-#ifdef SLAP_NVALUES
for ( k = 0, j = 0; a->a_vals[k].bv_val != NULL; k++ )
-#else
- for ( k = 0, j = 0; nvals[k].bv_val != NULL; j++, k++ )
-#endif
{
-#ifdef SLAP_NVALUES
/* skip dummies */
if( a->a_vals[k].bv_val == &dummy ) {
assert( a->a_nvals == NULL || a->a_nvals[k].bv_val == &dummy );
continue;
}
-#else
- /* delete and skip dummies */ ;
- for ( ; nvals[ k ].bv_val == &dummy; k++ ) {
- free( a->a_vals[ k ].bv_val );
- }
-#endif
if ( j != k ) {
a->a_vals[ j ] = a->a_vals[ k ];
-#ifdef SLAP_NVALUES
if (a->a_nvals != a->a_vals) {
a->a_nvals[ j ] = a->a_nvals[ k ];
}
-#endif
}
-#ifndef SLAP_NVALUES
- if ( a->a_vals[ k ].bv_val == NULL ) {
- break;
- }
-#else
j++;
-#endif
}
a->a_vals[j].bv_val = NULL;
-#ifdef SLAP_NVALUES
if (a->a_nvals != a->a_vals) a->a_nvals[j].bv_val = NULL;
-#else
-
- assert( i == k - j );
-#endif
/* if no values remain, delete the entire attribute */
if ( a->a_vals[0].bv_val == NULL ) {
}
return_results:;
-#ifndef SLAP_NVALUES
- if ( nvals ) {
- /* delete the remaining normalized values */
- for ( j = 0; nvals[ j ].bv_val != NULL; j++ ) {
- if ( nvals[ j ].bv_val != &dummy ) {
- ber_memfree( nvals[ j ].bv_val );
- }
- }
- ber_memfree( nvals );
- }
-#endif
return rc;
}
if ( mod->sm_values != NULL ) ber_bvarray_free( mod->sm_values );
mod->sm_values = NULL;
-#ifdef SLAP_NVALUES
if ( mod->sm_nvalues != NULL ) ber_bvarray_free( mod->sm_nvalues );
mod->sm_nvalues = NULL;
-#endif
if( freeit ) free( mod );
}
smr->smr_compat_syntaxes = compat_syn;
smr->smr_normalize = def->mrd_normalize;
smr->smr_match = def->mrd_match;
-#ifndef SLAP_NVALUES
- smr->smr_convert = def->mrd_convert;
-#endif
smr->smr_indexer = def->mrd_indexer;
smr->smr_filter = def->mrd_filter;
smr->smr_associated = amr;
{
AttributeDescription *ad_matchingRules = slap_schema.si_ad_matchingRules;
MatchingRule *mr;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH(mr, &mr_list, smr_next ) {
if ( mr->smr_usage & SLAP_MR_HIDE ) {
Debug( LDAP_DEBUG_TRACE, "Merging mr [%lu] %s\n",
mr->smr_str.bv_len, mr->smr_str.bv_val, 0 );
#endif
-#ifdef SLAP_NVALUES
nval.bv_val = mr->smr_oid;
nval.bv_len = strlen(mr->smr_oid);
if( attr_merge_one( e, ad_matchingRules, &mr->smr_str, &nval ) )
-#else
- if( attr_merge_one( e, ad_matchingRules, &mr->smr_str ) )
-#endif
{
return -1;
}
AttributeDescription *ad_matchingRuleUse
= slap_schema.si_ad_matchingRuleUse;
MatchingRuleUse *mru;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH( mru, &mru_list, smru_next ) {
Debug( LDAP_DEBUG_TRACE, "Merging mru [%lu] %s\n",
mru->smru_str.bv_len, mru->smru_str.bv_val, 0 );
#endif
-#ifdef SLAP_NVALUES
nval.bv_val = mru->smru_oid;
nval.bv_len = strlen(mru->smru_oid);
if( attr_merge_one( e, ad_matchingRuleUse, &mru->smru_str, &nval ) )
-#else
- if( attr_merge_one( e, ad_matchingRuleUse, &mru->smru_str ) )
-#endif
{
return -1;
}
return LDAP_INAPPROPRIATE_MATCHING;
}
-#ifndef SLAP_NVALUES
- /*
- * OK, if no matching rule, normalize for equality, otherwise
- * normalize for the matching rule.
- */
- rc = value_validate_normalize( ma.ma_desc, SLAP_MR_EQUALITY,
- &value, &ma.ma_value, text );
- } else {
- /*
- * Need to normalize, but how?
- */
- rc = value_validate( ma.ma_rule, &value, text );
- if ( rc == LDAP_SUCCESS ) {
- ber_dupbv( &ma.ma_value, &value );
- }
-#endif
}
-#ifdef SLAP_NVALUES
/*
* Normalize per matching rule
*/
ma.ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&value, &ma.ma_value, text );
-#endif
if( rc != LDAP_SUCCESS ) {
return rc;
AttributeDescription *ad_objectClasses = slap_schema.si_ad_objectClasses;
ObjectClass *oc;
struct berval val;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH( oc, &oc_list, soc_next ) {
if( oc->soc_flags & SLAP_OC_HIDE ) continue;
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
(long) val.bv_len, val.bv_val, 0 );
#endif
-#ifdef SLAP_NVALUES
nval.bv_val = oc->soc_oid;
nval.bv_len = strlen(oc->soc_oid);
if( attr_merge_one( e, ad_objectClasses, &val, &nval ) )
-#else
- if( attr_merge_one( e, ad_objectClasses, &val ) )
-#endif
{
return -1;
}
a->a_vals[1].bv_len = 0;
a->a_vals[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
a->a_nvals = ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( a->a_nvals, &global_schemandn );
a->a_nvals[1].bv_len = 0;
a->a_nvals[1].bv_val = NULL;
-#endif
a->a_next = NULL;
a->a_flags = 0;
ber_str2bv( val, len, 1, a->a_vals );
a->a_vals[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
a->a_nvals = a->a_vals;
-#endif
a->a_next = NULL;
a->a_flags = 0;
LDAP_SLAPD_F (void) attr_free LDAP_P(( Attribute *a ));
LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a ));
-#ifdef SLAP_NVALUES
#define attr_mergeit( e, d, v ) attr_merge( e, d, v, NULL /* FIXME */ )
#define attr_mergeit_one( e, d, v ) attr_merge_one( e, d, v, NULL /* FIXME */ )
AttributeDescription *desc,
struct berval *val,
struct berval *nval ));
-#else
-#define attr_mergeit( e, d, v ) attr_merge( e, d, v )
-#define attr_mergeit_one( e, d, v ) attr_merge_one( e, d, v )
-LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
- AttributeDescription *desc,
- BerVarray vals ));
-LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
- AttributeDescription *desc,
- struct berval *val ));
-#endif
LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
Attribute *a, AttributeDescription *desc ));
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((
Syntax *syntax,
struct berval *val ));
-#ifdef SLAP_NVALUES
LDAP_SLAPD_F (int) dnNormalize LDAP_P((
slap_mask_t use,
Syntax *syntax,
struct berval *val,
struct berval *normalized ));
#define dnNormalize2(s,v,n) dnNormalize(0,(s),NULL,(v),(n))
-#else
-LDAP_SLAPD_F (int) dnNormalize LDAP_P((
- Syntax *syntax,
- struct berval *val,
- struct berval *normalized ));
-#define dnNormalize2(s,v,n) dnNormalize((s),(v),(n))
-#endif
LDAP_SLAPD_F (int) dnPretty LDAP_P((
Syntax *syntax,
/*
* value.c
*/
-#ifdef SLAP_NVALUES
LDAP_SLAPD_F (int) asserted_value_validate_normalize LDAP_P((
AttributeDescription *ad,
MatchingRule *mr,
struct berval *in,
struct berval *out,
const char ** text ));
-#else
-LDAP_SLAPD_F (int) value_validate LDAP_P((
- MatchingRule *mr,
- struct berval *in,
- const char ** text ));
-LDAP_SLAPD_F (int) value_normalize LDAP_P((
- AttributeDescription *ad,
- unsigned usage,
- struct berval *in,
- struct berval *out,
- const char ** text ));
-LDAP_SLAPD_F (int) value_validate_normalize LDAP_P((
- AttributeDescription *ad,
- unsigned usage,
- struct berval *in,
- struct berval *out,
- const char ** text ));
-#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value)))
-#endif
LDAP_SLAPD_F (int) value_match LDAP_P((
int *match,
{
Entry *e;
struct berval vals[2], *bv;
-#ifdef SLAP_NVALUES
struct berval nvals[2];
-#endif
int i, j;
char ** supportedSASLMechanisms;
= slap_schema.si_ad_ref;
vals[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
nvals[1].bv_val = NULL;
-#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
vals[0].bv_val = "top";
vals[0].bv_len = sizeof("top")-1;
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, NULL ) )
-#else
- if( attr_merge( e, ad_objectClass, vals ) )
-#endif
{
return LDAP_OTHER;
}
vals[0].bv_val = "OpenLDAProotDSE";
vals[0].bv_len = sizeof("OpenLDAProotDSE")-1;
-#ifdef SLAP_NVALUES
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, NULL ) )
-#else
- if( attr_merge( e, ad_structuralObjectClass, vals ) )
-#endif
return LDAP_OTHER;
for ( i = 0; i < nbackends; i++ ) {
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 ) )
-#endif
{
return LDAP_OTHER;
}
}
for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) {
vals[0] = backends[i].be_suffix[j];
-#ifdef SLAP_NVALUES
nvals[0] = backends[i].be_nsuffix[0];
if( attr_merge( e, ad_namingContexts, vals, nvals ) )
-#else
- if( attr_merge( e, ad_namingContexts, vals ) )
-#endif
{
return LDAP_OTHER;
}
/* supportedExtension */
for ( i=0; (bv = get_supported_extop(i)) != NULL; i++ ) {
vals[0] = *bv;
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedExtension, vals, NULL ) )
-#else
- if( attr_merge( e, ad_supportedExtension, vals ) )
-#endif
{
return LDAP_OTHER;
}
/* netscape supportedExtension */
for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) {
vals[0] = *bv;
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedExtension, vals, NULL ))
-#else
- if( attr_merge( e, ad_supportedExtension, vals ))
-#endif
{
return LDAP_OTHER;
}
#endif /* LDAP_SLAPI */
/* supportedFeatures */
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedFeatures,
supportedFeatures, NULL ) )
-#else
- if( attr_merge( e, ad_supportedFeatures, supportedFeatures ) )
-#endif
{
return LDAP_OTHER;
}
snprintf(buf, sizeof buf, "%d", i);
vals[0].bv_val = buf;
vals[0].bv_len = strlen( vals[0].bv_val );
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedLDAPVersion, vals, NULL ) )
-#else
- if( attr_merge( e, ad_supportedLDAPVersion, vals ) )
-#endif
{
return LDAP_OTHER;
}
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
vals[0].bv_val = supportedSASLMechanisms[i];
vals[0].bv_len = strlen( vals[0].bv_val );
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_supportedSASLMechanisms, vals, NULL ) )
-#else
- if( attr_merge( e, ad_supportedSASLMechanisms, vals ) )
-#endif
{
return LDAP_OTHER;
}
}
if ( default_referral != NULL ) {
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_ref, default_referral, NULL /* FIXME */ ) )
-#else
- if( attr_merge( e, ad_ref, default_referral ) )
-#endif
{
return LDAP_OTHER;
}
if( usr_attr != NULL) {
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 == a->a_vals) ? NULL : a->a_nvals ) )
-#else
- if( attr_merge( e, a->a_desc, a->a_vals ) )
-#endif
{
return LDAP_OTHER;
}
*/
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 == a->a_vals) ? NULL : a->a_nvals ) )
-#else
- if( attr_merge( usr_attr, a->a_desc, a->a_vals ) )
-#endif
{
rc = LDAP_OTHER;
break;
Entry *e;
struct berval vals[5];
-#ifdef SLAP_NVALUES
struct berval nvals[5];
-#endif
e = (Entry *) SLAP_CALLOC( 1, sizeof(Entry) );
if( e == NULL ) {
vals[0].bv_val = "subentry";
vals[0].bv_len = sizeof("subentry")-1;
-#ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_structuralObjectClass, vals, vals ) )
-#else
- if( attr_merge_one( e, ad_structuralObjectClass, vals ) )
-#endif
{
/* Out of memory, do something about it */
entry_free( e );
vals[3].bv_val = "extensibleObject";
vals[3].bv_len = sizeof("extensibleObject")-1;
vals[4].bv_val = NULL;
-#ifdef SLAP_NVALUES
if( attr_merge( e, ad_objectClass, vals, vals ) )
-#else
- if( attr_merge( e, ad_objectClass, vals ) )
-#endif
{
/* Out of memory, do something about it */
entry_free( e );
return LDAP_OTHER;
}
-#ifdef SLAP_NVALUES
nvals[0].bv_val = strchr( global_schemandn.bv_val, '=' );
assert( nvals[0].bv_val );
nvals[0].bv_val++;
(nvals[0].bv_val - global_schemandn.bv_val);
if( attr_merge_one( e, desc, vals, nvals ) )
-#else
- if( attr_merge_one( e, desc, vals ) )
-#endif
{
/* Out of memory, do something about it */
entry_free( e );
vals[0].bv_val = timebuf;
vals[0].bv_len = strlen( timebuf );
-#ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_createTimestamp, vals, vals ) )
-#else
- if( attr_merge_one( e, ad_createTimestamp, vals ) )
-#endif
{
/* Out of memory, do something about it */
entry_free( e );
*text = "out of memory";
return LDAP_OTHER;
}
-#ifdef SLAP_NVALUES
if( attr_merge_one( e, ad_modifyTimestamp, vals, vals ) )
-#else
- if( attr_merge_one( e, ad_modifyTimestamp, vals ) )
-#endif
{
/* Out of memory, do something about it */
entry_free( e );
rc = LDAP_NAMING_VIOLATION;
}
-#ifdef SLAP_NVALUES
if ( value_find_ex( desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
attr->a_nvals,
&ava->la_value ) != 0 )
-#else
- if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 )
-#endif
{
snprintf( textbuf, textlen,
"value of naming attribute '%s' is not present in entry",
#define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
#define HASH_Final(d,c) lutil_HASHFinal(d,c)
+#define SLAP_NVALUES 1
+
#ifdef SLAP_NVALUES
/* TO BE DELETED */
#define SLAP_MR_DN_FOLD (0)
return SLAPD_COMPARE_UNDEFINED;
}
-#ifdef SLAP_NVALUES
if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) )
-#else
- if( SLAP_IS_MR_ATTRIBUTE_SYNTAX_MATCH( flags ) )
-#endif
{
*matchp = ( asserted != oc );
} else {
#include "ldap_queue.h"
#ifdef LDAP_DEVEL
-#define SLAP_NVALUES 1
#define SLAP_EXTENDED_SCHEMA 1
#define LDAP_CACHING
#endif
#define SLAP_SYNTAX_HIDE 0x8000U /* hide (do not publish) */
slap_syntax_validate_func *ssyn_validate;
-#ifndef SLAP_NVALUES
- slap_syntax_transform_func *ssyn_normalize;
-#endif
slap_syntax_transform_func *ssyn_pretty;
#ifdef SLAPD_BINARY_CONVERSION
char *sd_desc;
int sd_flags;
slap_syntax_validate_func *sd_validate;
-#ifdef SLAP_NVALUES
slap_syntax_transform_func *sd_normalizeXXX; /* to be deleted */
-#else
- slap_syntax_transform_func *sd_normalize;
-#endif
slap_syntax_transform_func *sd_pretty;
#ifdef SLAPD_BINARY_CONVERSION
slap_syntax_transform_func *sd_ber2str;
#define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0200U )
#define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0400U )
-#ifndef SLAP_NVALUES
-#define SLAP_MR_DN_FOLD 0x0080U
-#endif
-#ifndef SLAP_NVALUES
-/*
- * normally the asserted value is expected to conform to
- * assertion syntax specified in the matching rule, however
- * at times (such as during individual value modification),
- * the asserted value is expected to conform to the
- * attribute's value syntax.
- */
-#define SLAP_MR_ASSERTION_SYNTAX_MATCH 0x0000U
-#define SLAP_MR_ATTRIBUTE_SYNTAX_MATCH 0x0001U
-
-/* For SLAP_MR_ATTRIBUTE_SYNTAX_MATCHes, this flag indicates
- * that the asserted value of the attribute syntax has been
- * converted to the assertion syntax. (Not sure why we just
- * don't clear the SLAP_MR_ATTRIBUTE_SYNTAX_MATCH flag instead.)
- */
-#define SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH 0x0002U
-
-#else
/*
* The asserted value, depending on the particular usage,
* is expected to conform to either the assertion syntax
((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX )
#define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \
((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX )
-#endif
/* either or both the asserted value or attribute value
* may be provided in normalized form
typedef struct slap_attr {
AttributeDescription *a_desc;
BerVarray a_vals; /* preserved values */
-#ifdef SLAP_NVALUES
BerVarray a_nvals; /* normalized values */
-#endif
struct slap_attr *a_next;
unsigned a_flags;
#define SLAP_ATTR_IXADD 0x1U
struct berval sm_type;
BerVarray sm_values;
#define sm_bvalues sm_values
-#ifdef SLAP_NVALUES
BerVarray sm_nvalues;
-#endif
} Modification;
typedef struct slap_mod_list {
next = ml->sml_next;
slapi_ch_free( (void **)&ml->sml_bvalues );
-#ifdef SLAP_NVALUES
slapi_ch_free( (void **)&ml->sml_nvalues );
-#endif
slapi_ch_free( (void **)&ml );
}
}
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = tmp.sml_nvalues;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = tmp.sml_nvalues;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
mod = (Modifications *)ch_malloc( sizeof(Modifications) );
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = tmp.sml_nvalues;
-#endif
} else {
rs.sr_err = values2obj( pMod->mod_values, &bv );
if ( rs.sr_err != LDAP_SUCCESS )
tmp.sml_type.bv_val = pMod->mod_type;
tmp.sml_type.bv_len = strlen( pMod->mod_type );
tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
mod = (Modifications *) ch_malloc( sizeof(Modifications) );
mod->sml_desc = NULL;
mod->sml_type = tmp.sml_type;
mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = tmp.sml_nvalues;
-#endif
}
*modtail = mod;
modtail = &mod->sml_next;
return LDAP_CONSTRAINT_VIOLATION;
}
}
-#ifdef SLAP_NVALUES
mod.sm_nvalues = NULL;
-#endif
rc = modify_add_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) );
if ( rc != LDAP_SUCCESS ) {
return LDAP_CONSTRAINT_VIOLATION;
}
-#if SLAP_NVALUES
mod.sm_nvalues = NULL;
-#endif
rc = modify_delete_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) );
a->a_desc = ad;
a->a_vals = NULL;
-#ifdef SLAP_NVALUES
a->a_nvals = NULL;
-#endif
a->a_next = NULL;
a->a_flags = 0;
int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v )
{
#ifdef LDAP_SLAPI
-#ifdef SLAP_NVALUES
/*
* FIXME: here we may lose alignment between a_vals/a_nvals
*/
-#endif
return value_add_one( &a->a_vals, (Slapi_Value *)v );
#else
return -1;
const char *text;
mr = a->a_desc->ad_type->sat_equality;
-#ifdef SLAP_NVALUES
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
(struct berval *)v1, (void *)v2, &text );
-#else
- rc = value_match( &ret, a->a_desc, mr, SLAP_MR_ASSERTION_SYNTAX_MATCH,
- (struct berval *)v1, (void *)v2, &text );
-#endif
if ( rc != LDAP_SUCCESS )
return -1;
mr = a->a_desc->ad_type->sat_equality;
for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
-#ifdef SLAP_NVALUES
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, bv, v, &text );
-#else
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_ASSERTION_SYNTAX_MATCH, bv, v, &text );
-#endif
if ( rc != LDAP_SUCCESS ) {
return -1;
}
}
mod->sml_bvalues[i].bv_val = NULL;
}
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
return LDAP_CONSTRAINT_VIOLATION;
}
-#ifdef SLAP_NVALUES
if( nvals && ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_normalize )
{
ml->sml_nvalues[nvals].bv_val = NULL;
ml->sml_nvalues[nvals].bv_len = 0;
}
-#endif
}
prevml = ml;
ml = ml->sml_next;
char *textbuf, size_t textlen )
{
struct berval name, timestamp, csn;
-#ifdef SLAP_NVALUES
struct berval nname;
-#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
Modifications *mod;
if( op->o_dn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
-#ifdef SLAP_NVALUES
nname = name;
-#endif
} else {
name = op->o_dn;
-#ifdef SLAP_NVALUES
nname = op->o_ndn;
-#endif
}
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &tmpval );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
sizeof( struct berval ) * j );
-#ifdef SLAP_NVALUES
if( attr->a_nvals ) {
attr->a_nvals = ch_realloc( attr->a_nvals,
sizeof( struct berval ) * (i+j) );
ch_free( mods->sml_nvalues );
mods->sml_nvalues = NULL;
}
-#endif
continue;
#else
/* should check for duplicates */
attr->a_vals = mods->sml_values;
-#ifdef SLAP_NVALUES
attr->a_nvals = mods->sml_nvalues;
-#endif
*tail = attr;
tail = &attr->a_next;
ssyn->ssyn_oidlen = strlen(syn->syn_oid);
ssyn->ssyn_flags = def->sd_flags;
ssyn->ssyn_validate = def->sd_validate;
-#ifndef SLAP_NVALUES
- ssyn->ssyn_normalize = def->sd_normalize;
-#endif
ssyn->ssyn_pretty = def->sd_pretty;
#ifdef SLAPD_BINARY_CONVERSION
AttributeDescription *ad_ldapSyntaxes = slap_schema.si_ad_ldapSyntaxes;
Syntax *syn;
struct berval val;
-#ifdef SLAP_NVALUES
struct berval nval;
-#endif
LDAP_SLIST_FOREACH(syn, &syn_list, ssyn_next ) {
if ( ! syn->ssyn_validate ) {
#endif
#endif
-#ifdef SLAP_NVALUES
nval.bv_val = syn->ssyn_oid;
nval.bv_len = strlen(syn->ssyn_oid);
if( attr_merge_one( e, ad_ldapSyntaxes, &val, &nval ) )
-#else
- if( attr_merge_one( e, ad_ldapSyntaxes, &val ) )
-#endif
{
return -1;
}
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
attr_merge( e, slap_schema.si_ad_structuralObjectClass,
vals, NULL /* FIXME */ );
-#else
- attr_merge( e, slap_schema.si_ad_structuralObjectClass, vals );
-#endif
}
/* check schema */
struct berval name, timestamp, csn;
-#ifdef SLAP_NVALUES
struct berval nvals[ 2 ];
struct berval nname;
-#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
vals[1].bv_len = 0;
vals[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
nvals[1].bv_len = 0;
nvals[1].bv_val = NULL;
-#endif
ltm = gmtime(&now);
lutil_gentime( timebuf, sizeof(timebuf), ltm );
if ( be->be_rootndn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
-#ifdef SLAP_NVALUES
nname.bv_val = SLAPD_ANONYMOUS;
nname.bv_len = sizeof(SLAPD_ANONYMOUS) - 1;
-#endif
} else {
name = be->be_rootdn;
-#ifdef SLAP_NVALUES
nname = be->be_rootndn;
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )
{
vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
vals[0].bv_val = uuidbuf;
-#ifdef SLAP_NVALUES
attr_merge( e, slap_schema.si_ad_entryUUID, vals, NULL );
-#else
- attr_merge( e, slap_schema.si_ad_entryUUID, vals );
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName )
== NULL )
{
vals[0] = name;
-#ifdef SLAP_NVALUES
nvals[0] = nname;
attr_merge( e, slap_schema.si_ad_creatorsName, vals, nvals );
-#else
- attr_merge( e, slap_schema.si_ad_creatorsName, vals );
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_modifiersName )
== NULL )
{
vals[0] = name;
-#ifdef SLAP_NVALUES
nvals[0] = nname;
attr_merge( e, slap_schema.si_ad_modifiersName, vals, nvals );
-#else
- attr_merge( e, slap_schema.si_ad_modifiersName, vals );
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp )
== NULL )
{
vals[0] = timestamp;
-#ifdef SLAP_NVALUES
attr_merge( e, slap_schema.si_ad_createTimestamp, vals, NULL );
-#else
- attr_merge( e, slap_schema.si_ad_createTimestamp, vals );
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp )
== NULL )
{
vals[0] = timestamp;
-#ifdef SLAP_NVALUES
attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals, NULL );
-#else
- attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals );
-#endif
}
if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN )
== NULL )
{
vals[0] = csn;
-#ifdef SLAP_NVALUES
attr_merge( e, slap_schema.si_ad_entryCSN, vals, NULL );
-#else
- attr_merge( e, slap_schema.si_ad_entryCSN, vals );
-#endif
}
}
return LDAP_SUCCESS;
}
-#ifdef SLAP_NVALUES
int asserted_value_validate_normalize(
AttributeDescription *ad,
MatchingRule *mr,
return LDAP_SUCCESS;
}
-#else
-int
-value_validate(
- MatchingRule *mr,
- struct berval *in,
- const char **text )
-{
- int rc;
-
- if( mr == NULL ) {
- *text = "inappropriate matching request";
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- if( mr->smr_syntax == NULL ) {
- *text = "no assertion syntax";
- return LDAP_INVALID_SYNTAX;
- }
-
- if( ! mr->smr_syntax->ssyn_validate ) {
- *text = "no syntax validator";
- return LDAP_INVALID_SYNTAX;
- }
-
- rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "value is invalid";
- return LDAP_INVALID_SYNTAX;
- }
-
- return LDAP_SUCCESS;
-}
-
-int
-value_normalize(
- AttributeDescription *ad,
- unsigned usage,
- struct berval *in,
- struct berval *out,
- const char **text )
-{
- int rc;
- MatchingRule *mr = ad_mr( ad, usage );
-
- if( mr == NULL ) {
- *text = "inappropriate matching request";
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- /* we only support equality matching of binary attributes */
- /* This is suspect, flexible certificate matching will hit this */
- if( slap_ad_is_binary( ad ) && usage != SLAP_MR_EQUALITY ) {
- *text = "inappropriate binary matching";
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- if( mr->smr_normalize ) {
- rc = (mr->smr_normalize)( usage,
- ad->ad_type->sat_syntax,
- mr, in, out );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "unable to normalize value";
- return LDAP_INVALID_SYNTAX;
- }
-
- } else if ( mr->smr_syntax->ssyn_normalize ) {
- rc = (mr->smr_syntax->ssyn_normalize)(
- ad->ad_type->sat_syntax,
- in, out );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "unable to normalize value";
- return LDAP_INVALID_SYNTAX;
- }
-
- } else {
- ber_dupbv( out, in );
- }
-
- return LDAP_SUCCESS;
-}
-
-int
-value_validate_normalize(
- AttributeDescription *ad,
- unsigned usage,
- struct berval *in,
- struct berval *out,
- const char **text )
-{
- int rc;
- MatchingRule *mr = ad_mr( ad, usage );
-
- if( mr == NULL ) {
- *text = "inappropriate matching request";
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- if( mr->smr_syntax == NULL ) {
- *text = "no assertion syntax";
- return LDAP_INVALID_SYNTAX;
- }
-
- if( ! mr->smr_syntax->ssyn_validate ) {
- *text = "no syntax validator";
- return LDAP_INVALID_SYNTAX;
- }
-
- rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "value is invalid";
- return LDAP_INVALID_SYNTAX;
- }
-
- /* we only support equality matching of binary attributes */
- /* This is suspect, flexible certificate matching will hit this */
- if( slap_ad_is_binary( ad ) && usage != SLAP_MR_EQUALITY ) {
- *text = "inappropriate binary matching";
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- if( mr->smr_normalize ) {
- rc = (mr->smr_normalize)( usage,
- ad->ad_type->sat_syntax,
- mr, in, out );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "unable to normalize value";
- return LDAP_INVALID_SYNTAX;
- }
-
- } else if ( mr->smr_syntax->ssyn_normalize ) {
- rc = (mr->smr_syntax->ssyn_normalize)(
- ad->ad_type->sat_syntax,
- in, out );
-
- if( rc != LDAP_SUCCESS ) {
- *text = "unable to normalize value";
- return LDAP_INVALID_SYNTAX;
- }
-
- } else {
- ber_dupbv( out, in );
- }
-
- return LDAP_SUCCESS;
-}
-#endif
int
value_match(
return LDAP_INAPPROPRIATE_MATCHING;
}
-#ifndef SLAP_NVALUES
- if( ad->ad_type->sat_syntax->ssyn_normalize ) {
- rc = ad->ad_type->sat_syntax->ssyn_normalize(
- ad->ad_type->sat_syntax, v1, &nv1 );
-
- if( rc != LDAP_SUCCESS ) {
- return LDAP_INAPPROPRIATE_MATCHING;
- }
- }
-
- if ( SLAP_IS_MR_ATTRIBUTE_SYNTAX_NONCONVERTED_MATCH( flags ) &&
- mr->smr_convert )
- {
- rc = (mr->smr_convert)( v2, &nv2 );
- if ( rc != LDAP_SUCCESS ) {
- return LDAP_INVALID_SYNTAX;
- }
-
- /* let smr_match know we've converted the value */
- flags |= SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH;
- }
-#endif
rc = (mr->smr_match)( match, flags,
ad->ad_type->sat_syntax,
return LDAP_INAPPROPRIATE_MATCHING;
}
-#ifdef SLAP_NVALUES
assert(SLAP_IS_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH( flags ));
if( !SLAP_IS_MR_ASSERTED_VALUE_NORMALIZED_MATCH( flags ) &&
return LDAP_INVALID_SYNTAX;
}
}
-#else
-
- /* Take care of this here or ssyn_normalize later will hurt */
- if ( SLAP_IS_MR_ATTRIBUTE_SYNTAX_NONCONVERTED_MATCH( flags )
- && mr->smr_convert )
- {
- rc = (mr->smr_convert)( val, &nval );
- if ( rc != LDAP_SUCCESS ) {
- return LDAP_INVALID_SYNTAX;
- }
-
- /* let value_match know we've done the version */
- flags |= SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH;
- }
-
- if( !(flags & SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH) &&
- mr->smr_syntax->ssyn_normalize )
- {
- struct berval nval_tmp = { 0, NULL };
-
- rc = mr->smr_syntax->ssyn_normalize(
- mr->smr_syntax,
- nval.bv_val == NULL ? val : &nval, &nval_tmp );
-
- free(nval.bv_val);
- nval = nval_tmp;
- if( rc != LDAP_SUCCESS ) {
- free(nval.bv_val);
- return LDAP_INAPPROPRIATE_MATCHING;
- }
- }
-#endif
for ( i = 0; vals[i].bv_val != NULL; i++ ) {
int match;