at = attrs_find( at->a_next, b->a_dn_at ) )
{
if( value_find_ex( b->a_dn_at,
- SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, at->a_vals, &bv )
- == 0 )
+ SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
+ at->a_vals, &bv ) == 0 )
{
/* found it */
match = 1;
}
return NULL;
}
+
+MatchingRule *ad_mr(
+ AttributeDescription *ad,
+ unsigned usage )
+{
+ switch( usage & SLAP_MR_TYPE_MASK ) {
+ case SLAP_MR_NONE:
+ case SLAP_MR_EQUALITY:
+ return ad->ad_type->sat_equality;
+ break;
+ case SLAP_MR_ORDERING:
+ return ad->ad_type->sat_ordering;
+ break;
+ case SLAP_MR_SUBSTR:
+ return ad->ad_type->sat_substr;
+ break;
+ case SLAP_MR_EXT:
+ default:
+ assert( 0 /* ad_mr: bad usage */);
+ }
+ return NULL;
+}
}
if ( sat->sat_ordering_oid ) {
+ if( !sat->sat_equality ) {
+ *err = sat->sat_ordering_oid;
+ return SLAP_SCHERR_ATTR_BAD_MR;
+ }
+
mr = mr_find(sat->sat_ordering_oid);
if( mr == NULL ) {
}
if ( sat->sat_substr_oid ) {
+ if( !sat->sat_equality ) {
+ *err = sat->sat_substr_oid;
+ return SLAP_SCHERR_ATTR_BAD_MR;
+ }
+
mr = mr_find(sat->sat_substr_oid);
if( mr == NULL ) {
* syntax and compat syntaxes instead of those
* associated with the substrings rule.
*/
- if( sat->sat_equality &&
- sat->sat_syntax != sat->sat_equality->smr_syntax )
- {
+ if( sat->sat_syntax != sat->sat_equality->smr_syntax ) {
if( sat->sat_equality->smr_compat_syntaxes == NULL ) {
*err = sat->sat_substr_oid;
return SLAP_SCHERR_ATTR_BAD_MR;
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 );
{
rc = LDAP_COMPARE_FALSE;
- if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
+#ifdef SLAP_NVALUES
+ if ( value_find_ex( ava->aa_desc,
+ SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ a->a_vals, &ava->aa_value ) == 0 )
+#else
+ if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
+#endif
+ {
rc = LDAP_COMPARE_TRUE;
break;
}
group_oc_name, group_at_name, 0 );
#endif
- if( value_find_ex( group_at,
- SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- attr->a_vals, op_ndn ) != LDAP_SUCCESS )
- {
+ if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, DETAIL1,
"bdb_group: \"%s\" not in \"%s\": %s\n",
ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
} else {
res = value_match( &ret, desc,
- desc->ad_type->sat_ordering,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ desc->ad_type->sat_ordering, 0,
&entrycsn_bv, latest_entrycsn_bv, &text );
if ( res != LDAP_SUCCESS ) {
ret = 0;
ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
} else {
res = value_match( &ret, desc,
- desc->ad_type->sat_ordering,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ desc->ad_type->sat_ordering, 0,
&entrycsn_bv, latest_entrycsn_bv, &text );
if ( res != LDAP_SUCCESS ) {
ret = 0;
#endif
- if( value_find_ex( group_at, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- attr->a_vals, op_ndn ) != LDAP_SUCCESS )
- {
+ if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDBM, DETAIL1,
"ldbm_back_group: \"%s\" not in \"%s\": %s\n",
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 ) {
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 ) {
goto cleanup;
}
+#ifdef SLAP_NVALUES
+ rc = 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, &text );
+#else
rc = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
&value, &ava.aa_value, &text );
+#endif
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, NULL, text, NULL, NULL );
goto cleanup;
{
rc = LDAP_COMPARE_FALSE;
- if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
+#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 )
+#else
+ if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
+#endif
+ {
rc = LDAP_COMPARE_TRUE;
break;
}
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;
+ MatchingRule *mr = NULL;
struct berval bv = { 0, NULL };
int do_sort = 0;
if( ava->la_flags & LDAP_AVA_BINARY ) {
/* AVA is binary encoded, don't muck with it */
- validf = NULL;
- transf = NULL;
- mr = NULL;
} else if( flags & SLAP_LDAPDN_PRETTY ) {
- validf = NULL;
transf = ad->ad_type->sat_syntax->ssyn_pretty;
- mr = NULL;
- } else {
+ if( !transf ) {
+ validf = ad->ad_type->sat_syntax->ssyn_validate;
+ }
+ } else { /* normalization */
validf = ad->ad_type->sat_syntax->ssyn_validate;
- transf = ad->ad_type->sat_syntax->ssyn_normalize;
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
+ * if value is empty, use empty_bv
+ */
+ rc = ( *normf )(
+ 0,
+ ad->ad_type->sat_syntax,
+ mr,
+ ava->la_value.bv_len
+ ? &ava->la_value
+ : (struct berval *) &slap_empty_bv,
+ &bv );
+
+ if ( rc != LDAP_SUCCESS ) {
+ return LDAP_INVALID_SYNTAX;
+ }
+ }
+
+#else
if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
char *s = bv.bv_val;
}
free( s );
}
+#endif
if( bv.bv_val ) {
free( ava->la_value.bv_val );
nvals[0].bv_val = NULL;
if( ad->ad_type->sat_equality &&
- ad->ad_type->sat_equality->smr_match &&
- ad->ad_type->sat_syntax->ssyn_normalize )
+ ad->ad_type->sat_equality->smr_normalize )
{
- rc = ad->ad_type->sat_syntax->ssyn_normalize(
+ rc = ad->ad_type->sat_equality->smr_normalize(
+ SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad->ad_type->sat_syntax,
+ ad->ad_type->sat_equality,
&vals[0], &nvals[0] );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
- "str2entry: NULL (ssyn_normalize %d)\n" , rc, 0, 0 );
+ "str2entry: NULL (smr_normalize %d)\n" , rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
- "<= str2entry NULL (ssyn_normalize %d)\n", rc, 0, 0 );
+ "<= str2entry NULL (smr_normalize %d)\n", rc, 0, 0 );
#endif
entry_free( e );
#ifdef SLAP_NVALUES
if( count && ad->ad_type->sat_equality &&
- ad->ad_type->sat_equality->smr_match &&
- ad->ad_type->sat_syntax->ssyn_normalize )
+ ad->ad_type->sat_equality->smr_normalize )
{
a->a_nvals = ch_malloc((count+1)*sizeof(struct berval));
for(j=0; j<count; j++) {
- rc = ad->ad_type->sat_syntax->ssyn_normalize(
+ rc = ad->ad_type->sat_equality->smr_normalize(
+ SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad->ad_type->sat_syntax,
+ ad->ad_type->sat_equality,
&a->a_vals[j], &a->a_nvals[j] );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
- "entry_decode: NULL (ssyn_normalize %d)\n",
+ "entry_decode: NULL (smr_normalize %d)\n",
rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
- "<= entry_decode NULL (ssyn_normalize %d)\n",
+ "<= entry_decode NULL (smr_normalize %d)\n",
rc, 0, 0 );
#endif
goto return_error;
}
+#ifdef SLAP_NVALUES
+ /* validate using equality matching rule validator! */
+ rc = asserted_value_validate_normalize(
+ f->f_sub_desc, f->f_sub_desc->ad_type->sat_substr,
+ usage, &value, &bv, text );
+ if( rc != LDAP_SUCCESS ) {
+ goto return_error;
+ }
+#else
/* validate using equality matching rule validator! */
rc = value_validate( f->f_sub_desc->ad_type->sat_equality,
&value, text );
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
+#endif
value = bv;
goto return_error;
}
+#ifdef SLAP_NVALUES
+ /* validate using equality matching rule validator! */
+ rc = asserted_value_validate_normalize(
+ vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_substr,
+ usage, &value, &bv, text );
+ 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;
}
+#endif
value = bv;
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mra->ma_rule,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
bv, &mra->ma_value, &text );
if( rc != LDAP_SUCCESS ) {
}
/* 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;
}
int ret;
int rc;
- rc = value_match( &ret, a->a_desc, mra->ma_rule,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
}
/* 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;
}
}
/* check match */
- rc = value_match( &ret, ad, mra->ma_rule,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, ad, mra->ma_rule, 0,
bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, a->a_desc, mr, 0,
bv, &ava->aa_value, &text );
if( rc != LDAP_SUCCESS ) {
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, a->a_desc, mr, 0,
bv, f->f_sub, &text );
if( rc != LDAP_SUCCESS ) {
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_ASSERTION_SYNTAX_MATCH, bv, &ava->aa_value, &text );
+ rc = value_match( &ret, a->a_desc, mr, 0,
+ bv, &ava->aa_value, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
}
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
+ rc = value_match( &ret, a->a_desc, mr, 0,
bv, vrf->vrf_sub, &text );
if( rc != LDAP_SUCCESS ) {
value = mra->ma_value;
} else {
+ int rc;
const char *text = NULL;
/* check if matching is appropriate */
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 */
- if ( value_validate_normalize( a->a_desc,
+ rc = value_validate_normalize( a->a_desc,
SLAP_MR_EQUALITY,
&mra->ma_value, &value,
- &text ) != LDAP_SUCCESS ) {
- continue;
- }
+ &text );
+#endif
+ if( rc != LDAP_SUCCESS ) continue;
}
for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
int rc;
const char *text;
- rc = value_match( &ret, a->a_desc, mra->ma_rule,
- SLAP_MR_ASSERTION_SYNTAX_MATCH,
- bv, &value,
- &text );
-
+ rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
+ bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
}
#ifdef SLAP_NVALUES
if( nvals && ad->ad_type->sat_equality &&
- ad->ad_type->sat_equality->smr_match &&
- ad->ad_type->sat_syntax->ssyn_normalize )
+ ad->ad_type->sat_equality->smr_normalize )
{
ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) );
for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
- rc = ad->ad_type->sat_syntax->ssyn_normalize(
+ rc = ad->ad_type->sat_equality->smr_normalize(
+ 0,
ad->ad_type->sat_syntax,
+ ad->ad_type->sat_equality,
&ml->sml_values[nvals], &ml->sml_nvalues[nvals] );
if( rc ) {
#ifdef NEW_LOGGING
{
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS, matched;
+#ifdef SLAP_NVALUES
+ /* needs major reworking */
+#else
BerVarray nvals = NULL, nmods = NULL;
/*
goto return_results;
}
- for ( i = 0; mods[ i ].bv_val != NULL; i++ ) {
+ for ( i=0; mods[i].bv_val != NULL; i++ ) {
rc = value_normalize( ad, SLAP_MR_EQUALITY,
- &mods[ i ], &nmods[ i ], text );
+ &mods[i], &nmods[i], text );
if ( rc != LDAP_SUCCESS ) {
- nmods[ i ].bv_val = NULL;
+ nmods[i].bv_val = NULL;
goto return_results;
}
if ( numvals > 0 && numvals < nummods ) {
- for ( matched = 0, j = 0; nvals[ j ].bv_val; j++ ) {
+ 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;
ber_bvarray_free( nmods );
}
+#endif
return rc;
}
/* test asserted values against existing values */
if( a ) {
for( matched = 0, j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
- if ( bvmatch( &mod->sm_bvalues[i],
- &a->a_vals[j] ) ) {
+ if ( bvmatch( &mod->sm_bvalues[i], &a->a_vals[j] ) ) {
if ( permissive ) {
matched++;
continue;
int rc;
- if ( mod->sm_bvalues[ 1 ].bv_val == 0 ) {
+ if ( mod->sm_bvalues[1].bv_val == 0 ) {
if ( a != NULL ) {
struct berval asserted;
int i;
+#ifndef SLAP_NVALUES
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
+ | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
+ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ &a->a_nvals[i],
+ &mod->sm_nvalues[0],
+ text );
+
+ } else {
+ rc = value_match( &match, mod->sm_desc, mr,
+ SLAP_MR_EQUALITY
+ | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+ &a->a_vals[i],
+ &mod->sm_values[0],
+ text );
+ }
+
+#else
rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
- &a->a_vals[ i ], &asserted, text );
+ &a->a_vals[i],
+ &asserted,
+ text );
+#endif
if( rc == LDAP_SUCCESS && match == 0 ) {
if ( permissive ) {
return LDAP_NO_SUCH_ATTRIBUTE;
}
+#ifdef SLAP_NVALUES
+ nvals = a->a_nvals;
+#else
/* find each value to delete */
for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ )
/* count existing values */ ;
goto return_results;
}
}
+#endif
for ( i = 0; mod->sm_bvalues[ i ].bv_val != NULL; i++ ) {
- struct berval asserted;
int found = 0;
+#ifndef SLAP_NVALUES
+ struct berval asserted;
/* normalize the value to be deleted */
rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
if( rc != LDAP_SUCCESS ) {
goto return_results;
}
+#endif
/* search it */
for ( j = 0; nvals[ j ].bv_val != NULL; j++ ) {
continue;
}
+#ifdef SLAP_NVALUES
+ if( mod->sm_nvalues ) {
+ rc = (*mr->smr_match)( &match,
+ SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
+ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ a->a_desc->ad_type->sat_syntax,
+ mr, &nvals[ j ],
+ &mod->sm_nvalues[i] );
+ } else {
+ rc = (*mr->smr_match)( &match,
+ SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+ a->a_desc->ad_type->sat_syntax,
+ mr, &nvals[ 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 );
+ 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",
break;
}
+#ifndef SLAP_NVALUES
free( asserted.bv_val );
+#endif
if ( found == 0 ) {
*text = textbuf;
return LDAP_INAPPROPRIATE_MATCHING;
}
+#ifndef SLAP_NVALUES
/*
* OK, if no matching rule, normalize for equality, otherwise
* normalize for the matching rule.
if ( rc == LDAP_SUCCESS ) {
ber_dupbv( &ma->ma_value, &value );
}
+#endif
+ }
+#ifdef SLAP_NVALUES
+ /*
+ * Normalize per matching rule
+ */
+ rc = asserted_value_validate_normalize( ma->ma_desc,
+ ma->ma_rule,
+ SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+ &ma->ma_value, &value, text );
+ if ( rc == LDAP_SUCCESS ) {
+ ber_dupbv( &ma->ma_value, &value );
}
+#endif
if( rc != LDAP_SUCCESS ) {
mra_free( ma, 1 );
LDAP_SLAPD_F (int) ad_define_option LDAP_P(( const char *name,
const char *fname, int lineno ));
+LDAP_SLAPD_F (MatchingRule *) ad_mr(
+ AttributeDescription *ad,
+ unsigned usage );
+
/*
* add.c
*/
/*
* value.c
*/
+#ifdef SLAP_NVALUES
+LDAP_SLAPD_F (int) asserted_value_validate_normalize LDAP_P((
+ AttributeDescription *ad,
+ MatchingRule *mr,
+ unsigned usage,
+ struct berval *in,
+ struct berval *out,
+ const char ** text ));
+#else
LDAP_SLAPD_F (int) value_validate LDAP_P((
MatchingRule *mr,
struct berval *in,
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,
AttributeDescription *ad,
struct berval *v1,
void *v2,
const char ** text ));
-#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value)))
LDAP_SLAPD_F (int) value_find_ex LDAP_P((
AttributeDescription *ad,
unsigned flags,
BerVarray values,
struct berval *value ));
+
LDAP_SLAPD_F (int) value_add LDAP_P((
BerVarray *vals,
BerVarray addvals ));
/* naming check */
rc = entry_naming_check( e, text, textbuf, textlen );
- if ( rc != LDAP_SUCCESS ) {
+ if( rc != LDAP_SUCCESS ) {
return rc;
}
break;
}
- if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 ) {
+#ifdef SLAP_NVALUES
+ if ( value_find_ex( desc,
+ SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH.
+ attr->a_nvals ? attr->a_nvals : attr->a_vals,
+ &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",
ava->la_attr.bv_val );
#define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
#define HASH_Final(d,c) lutil_HASHFinal(d,c)
+#ifdef SLAP_NVALUES
+#define SLAP_MR_DN_FOLD (0) /* TO BE DELETED */
+#endif
+
/* recycled validatation routines */
#define berValidate blobValidate
if( rc != LDAP_SUCCESS ) {
break;
}
+#ifndef SLAP_NVALUES
} else if ( mr->smr_syntax->ssyn_normalize ) {
rc = (mr->smr_syntax->ssyn_normalize)( syntax, &values[i], &value );
if( rc != LDAP_SUCCESS ) {
break;
}
+#endif
} else {
ber_dupbv( &value, &values[i] );
}
return SLAPD_COMPARE_UNDEFINED;
}
+#ifdef SLAP_NVALUES
+ assert(0 /* FIX ME */);
+#else
if( SLAP_IS_MR_ATTRIBUTE_SYNTAX_MATCH( flags ) ) {
*matchp = ( asserted != oc );
} else {
*matchp = !is_object_subclass( asserted, oc );
}
+#endif
#if OCDEBUG
#ifdef NEW_LOGGING
#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_HIDE 0x8000U
-#define SLAP_MR_TYPE_MASK 0x0F00U
-#define SLAP_MR_SUBTYPE_MASK 0x00F0U
-#define SLAP_MR_USAGE 0x000FU
+#define SLAP_MR_TYPE_MASK 0xF000U
+#define SLAP_MR_SUBTYPE_MASK 0x0F00U
+#define SLAP_MR_USAGE 0x00FFU
#define SLAP_MR_NONE 0x0000U
-#define SLAP_MR_EQUALITY 0x0100U
-#define SLAP_MR_ORDERING 0x0200U
-#define SLAP_MR_SUBSTR 0x0400U
-#define SLAP_MR_EXT 0x0800U /* implicitly extensible */
+#define SLAP_MR_EQUALITY 0x1000U
+#define SLAP_MR_ORDERING 0x2000U
+#define SLAP_MR_SUBSTR 0x4000U
+#define SLAP_MR_EXT 0x8000U /* implicitly extensible */
+
+#define SLAP_MR_EQUALITY_APPROX ( SLAP_MR_EQUALITY | 0x0100U )
-#define SLAP_MR_EQUALITY_APPROX ( SLAP_MR_EQUALITY | 0x0010U )
-#define SLAP_MR_DN_FOLD 0x0008U
+#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0100U )
+#define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0200U )
+#define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0400U )
-#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0010U )
-#define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0020U )
-#define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0040U )
+#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
* 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
+#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
*/
#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
+ * or the attribute syntax. In some cases, the syntax of
+ * the value is known. If so, these flags indicate which
+ * syntax the value is expected to conform to. If not,
+ * neither of these flags is set (until the syntax of the
+ * provided value is determined). If the value is of the
+ * attribute syntax, the flag is changed once a value of
+ * the assertion syntax is derived from the provided value.
+ */
+#define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX 0x0001U
+#define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX 0x0002U
+
+#define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \
+ ((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
*/
-#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH 0x0004U
-#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH 0x0008U
+#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH 0x0010U
+#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH 0x0020U
#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
(!((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH))
slap_mr_indexer_func * mrd_indexer;
slap_mr_filter_func * mrd_filter;
+ /* For equality rule, this may refer to an appropriate approximate rule */
char * mrd_associated;
} slap_mrule_defs_rec;
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
return LDAP_SUCCESS;
}
+#ifdef SLAP_NVALUES
+int asserted_value_validate_normalize(
+ AttributeDescription *ad,
+ MatchingRule *mr,
+ unsigned usage,
+ struct berval *in,
+ struct berval *out,
+ const char ** text )
+{
+ int rc;
+
+ /* we expect the value to be in the assertion syntax */
+ assert( !SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) );
+
+ if( mr == NULL ) {
+ *text = "inappropriate matching request";
+ return LDAP_INAPPROPRIATE_MATCHING;
+ }
+
+ if( !mr->smr_match ) {
+ *text = "requested matching rule not supported";
+ return LDAP_INAPPROPRIATE_MATCHING;
+ }
+
+ assert( mr->smr_syntax );
+ assert( mr->smr_syntax->ssyn_validate );
+
+ rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
+
+ if( rc != LDAP_SUCCESS ) {
+ *text = "value does not conform to assertion syntax";
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ if( mr->smr_normalize ) {
+ rc = (mr->smr_normalize)( usage,
+ ad ? ad->ad_type->sat_syntax : NULL,
+ mr, in, out );
+
+ if( rc != LDAP_SUCCESS ) {
+ *text = "unable to normalize value for matching";
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ } else {
+ ber_dupbv( out, in );
+ }
+}
+
+#else
int
value_validate(
MatchingRule *mr,
const char **text )
{
int rc;
- MatchingRule *mr;
-
- switch( usage & SLAP_MR_TYPE_MASK ) {
- case SLAP_MR_NONE:
- case SLAP_MR_EQUALITY:
- mr = ad->ad_type->sat_equality;
- break;
- case SLAP_MR_ORDERING:
- mr = ad->ad_type->sat_ordering;
- break;
- case SLAP_MR_SUBSTR:
- mr = ad->ad_type->sat_substr;
- break;
- case SLAP_MR_EXT:
- default:
- assert( 0 );
- *text = "internal error";
- return LDAP_OTHER;
- }
+ MatchingRule *mr = ad_mr( ad, usage );
if( mr == NULL ) {
*text = "inappropriate matching request";
const char **text )
{
int rc;
- MatchingRule *mr;
-
- switch( usage & SLAP_MR_TYPE_MASK ) {
- case SLAP_MR_NONE:
- case SLAP_MR_EQUALITY:
- mr = ad->ad_type->sat_equality;
- break;
- case SLAP_MR_ORDERING:
- mr = ad->ad_type->sat_ordering;
- break;
- case SLAP_MR_SUBSTR:
- mr = ad->ad_type->sat_substr;
- break;
- case SLAP_MR_EXT:
- default:
- assert( 0 );
- *text = "internal error";
- return LDAP_OTHER;
- }
+ MatchingRule *mr = ad_mr( ad, usage );
if( mr == NULL ) {
*text = "inappropriate matching request";
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 );
/* 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 rc;
}
-
int value_find_ex(
AttributeDescription *ad,
unsigned flags,
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 ) &&
+ mr->smr_normalize )
+ {
+ rc = (mr->smr_normalize)(
+ flags & SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK,
+ ad ? ad->ad_type->sat_syntax : NULL,
+ mr, val, &nval );
+
+ if( rc != LDAP_SUCCESS ) {
+ 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 )
return LDAP_INAPPROPRIATE_MATCHING;
}
}
+#endif
for ( i = 0; vals[i].bv_val != NULL; i++ ) {
int match;