From c1da50a4261747a5ea1f8f3843fcf33dc4f9496d Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 24 May 2000 18:49:30 +0000 Subject: [PATCH] SLAPD_SCHEMA_NOT_COMPAT: equality filters (2.5.4.0=2.5.6.0) works! ie: (objectclass=top) --- servers/slapd/attr.c | 2 +- servers/slapd/filterentry.c | 17 +++++++++++------ servers/slapd/proto-slap.h | 1 + servers/slapd/schema_init.c | 12 +++++++++--- servers/slapd/slap.h | 1 + servers/slapd/value.c | 22 +++++++++++++++++++--- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index dd1d3b612e..481d1c7adf 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -223,7 +223,7 @@ attrs_find( ) { for ( ; a != NULL; a = a->a_next ) { - if ( is_ad_subtype( a->a_desc, desc ) == 0 ) { + if ( is_ad_subtype( a->a_desc, desc ) ) { return( a ); } } diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index b60ed66873..fe4e1c1b54 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -253,34 +253,39 @@ test_ava_filter( #endif for ( i = 0; a->a_vals[i] != NULL; i++ ) { - int rc; + int ret; #ifdef SLAPD_SCHEMA_NOT_COMPAT + int rc; const char *text; - rc = value_match( a->a_desc, mr, + rc = value_match( &ret, a->a_desc, mr, a->a_vals[i], ava->aa_value, &text ); + + if( rc != LDAP_SUCCESS ) { + return rc; + } #else - rc = value_cmp( a->a_vals[i], &ava->ava_value, a->a_syntax, + ret = value_cmp( a->a_vals[i], &ava->ava_value, a->a_syntax, 3 ); #endif switch ( type ) { case LDAP_FILTER_EQUALITY: case LDAP_FILTER_APPROX: - if ( rc == 0 ) { + if ( ret == 0 ) { return LDAP_COMPARE_TRUE; } break; case LDAP_FILTER_GE: - if ( rc >= 0 ) { + if ( ret >= 0 ) { return LDAP_COMPARE_TRUE; } break; case LDAP_FILTER_LE: - if ( rc <= 0 ) { + if ( ret <= 0 ) { return LDAP_COMPARE_TRUE; } break; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 9b9241745c..31a4d13573 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -686,6 +686,7 @@ LIBSLAPD_F (int) value_normalize LDAP_P(( struct berval **out, const char ** text )); LIBSLAPD_F (int) value_match LDAP_P(( + int *match, AttributeDescription *ad, MatchingRule *mr, struct berval *v1, diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 02beabc58c..ad9bf48a5e 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -307,30 +307,35 @@ IA5StringNormalize( static int caseExactIA5Match( + int *match, unsigned use, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue ) { - return strcmp( value->bv_val, + *match = strcmp( value->bv_val, ((struct berval *) assertedValue)->bv_val ); + return LDAP_SUCCESS; } static int caseIgnoreIA5Match( + int *match, unsigned use, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue ) { - return strcasecmp( value->bv_val, + *match = strcasecmp( value->bv_val, ((struct berval *) assertedValue)->bv_val ); + return LDAP_SUCCESS; } static int objectClassMatch( + int *match, unsigned use, Syntax *syntax, MatchingRule *mr, @@ -340,7 +345,8 @@ objectClassMatch( ObjectClass *oc = oc_find( value->bv_val ); ObjectClass *asserted = oc_find( ((struct berval *) assertedValue)->bv_val ); - return oc == NULL || oc != asserted; + *match = ( oc == NULL || oc != asserted ); + return LDAP_SUCCESS; } struct syntax_defs_rec { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 92978f9861..fc9644b8d6 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -191,6 +191,7 @@ typedef int slap_mr_normalize_func LDAP_P(( /* Match (compare) function */ typedef int slap_mr_match_func LDAP_P(( + int *match, unsigned use, struct slap_syntax *syntax, /* syntax of stored value */ struct slap_matching_rule *mr, diff --git a/servers/slapd/value.c b/servers/slapd/value.c index ec7bc11f84..753c724005 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -177,15 +177,27 @@ value_normalize( #ifdef SLAPD_SCHEMA_NOT_COMPAT int value_match( + int *match, AttributeDescription *ad, MatchingRule *mr, struct berval *v1, /* (unnormalized) stored value */ struct berval *v2, /* (normalized) asserted value */ const char ** text ) { - /* not yet implemented */ - return 0; + int rc; + int usage = 0; + + if( !mr->smr_match ) { + return LDAP_INAPPROPRIATE_MATCHING; + } + + rc = (mr->smr_match)( match, usage, + ad->ad_type->sat_syntax, + mr, v1, v2 ); + + return rc; } + #else int value_cmp( @@ -256,7 +268,11 @@ value_find( for ( i = 0; vals[i] != NULL; i++ ) { #ifdef SLAPD_SCHEMA_NOT_COMPAT - if ( value_match( ad, mr, vals[i], val, text ) == 0 ) + int rc; + int match; + rc = value_match( &match, ad, mr, vals[i], val, text ); + + if( rc == LDAP_SUCCESS && match == 0 ) #else if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) #endif -- 2.39.5