]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/value.c
Extend value_match to extract an asserted value from a full value
[openldap] / servers / slapd / value.c
index 0ddd2518e52c9e7d928e702c2df87cc18f6df166..4a34fc09833a92eb953dad2e82adddfd3b8070b9 100644 (file)
@@ -125,13 +125,15 @@ value_match(
        int *match,
        AttributeDescription *ad,
        MatchingRule *mr,
+       unsigned flags,
        struct berval *v1, /* stored value */
        void *v2, /* assertion */
        const char ** text )
 {
        int rc;
-       int usage = 0;
        struct berval *nv1 = NULL;
+       struct berval *nv2 = NULL;
+       Syntax *syntax;
 
        if( !mr->smr_match ) {
                return LDAP_INAPPROPRIATE_MATCHING;
@@ -146,13 +148,22 @@ value_match(
                }
        }
 
-       rc = (mr->smr_match)( match, usage,
+       if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) &&
+            mr->smr_convert ) {
+               rc = (mr->smr_convert)(v2,&nv2);
+               if ( rc != LDAP_SUCCESS ) {
+                 return LDAP_INVALID_SYNTAX;
+               }
+       }
+
+       rc = (mr->smr_match)( match, flags,
                ad->ad_type->sat_syntax,
                mr,
                nv1 != NULL ? nv1 : v1,
-               v2 );
+               nv2 != NULL ? nv2 : v2 );
        
        ber_bvfree( nv1 );
+       ber_bvfree( nv2 );
        return rc;
 }
 
@@ -184,13 +195,15 @@ int value_find(
                int match;
                const char *text;
 
-               rc = value_match( &match, ad, mr, vals[i],
-                       nval == NULL ? val : nval, &text );
+               rc = value_match( &match, ad, mr, 0,
+                       vals[i], nval == NULL ? val : nval, &text );
 
                if( rc == LDAP_SUCCESS && match == 0 ) {
+                       ber_bvfree( nval );
                        return LDAP_SUCCESS;
                }
        }
 
+       ber_bvfree( nval );
        return LDAP_NO_SUCH_ATTRIBUTE;
 }