]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/matchedValues.c
cleanup
[openldap] / servers / slapd / matchedValues.c
index 56bd29667b491b59dc3e40bd258be1e43a5266a5..0d3986ae2b4f8da8397134954c7318c0aa11a067 100644 (file)
@@ -19,7 +19,8 @@
 
 #include "../../libraries/liblber/lber-int.h"
 
-static int test_mra_vrFilter(
+static int
+test_mra_vrFilter(
        Backend         *be,
        Connection      *conn,
        Operation       *op,
@@ -73,8 +74,7 @@ filter_matched_values(
        int             rc = LDAP_SUCCESS;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
-               "filter_matched_values: begin\n" ));
+       LDAP_LOG( FILTER, ENTRY, "filter_matched_values: begin\n", 0, 0, 0 );
 #else
        Debug( LDAP_DEBUG_FILTER, "=> filter_matched_values\n", 0, 0, 0 );
 #endif
@@ -83,13 +83,12 @@ filter_matched_values(
                switch ( f->f_choice ) {
                case SLAPD_FILTER_COMPUTED:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
+                       LDAP_LOG( FILTER, DETAIL1, 
                                "test_vrFilter: COMPUTED %s (%d)\n",
                                f->f_result == LDAP_COMPARE_FALSE ? "false" :
                                f->f_result == LDAP_COMPARE_TRUE         ? "true"  :
                                f->f_result == SLAPD_COMPARE_UNDEFINED ? "undefined" :
-                               "error",
-                               f->f_result ));
+                               "error", f->f_result, 0 );
 #else
                        Debug( LDAP_DEBUG_FILTER, "     COMPUTED %s (%d)\n",
                                f->f_result == LDAP_COMPARE_FALSE ? "false" :
@@ -103,8 +102,7 @@ filter_matched_values(
 
                case LDAP_FILTER_EQUALITY:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
-                               "test_vrFilter: EQUALITY\n" ));
+                       LDAP_LOG( FILTER, DETAIL1, "test_vrFilter: EQUALITY\n", 0, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_FILTER, "     EQUALITY\n", 0, 0, 0 );
 #endif
@@ -117,8 +115,7 @@ filter_matched_values(
 
                case LDAP_FILTER_SUBSTRINGS:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
-                               "test_vrFilter  SUBSTRINGS\n" ));
+                       LDAP_LOG( FILTER, DETAIL1, "test_vrFilter  SUBSTRINGS\n", 0, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_FILTER, "     SUBSTRINGS\n", 0, 0, 0 );
 #endif
@@ -132,8 +129,7 @@ filter_matched_values(
 
                case LDAP_FILTER_PRESENT:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
-                               "test_vrFilter: PRESENT\n" ));
+                       LDAP_LOG( FILTER, DETAIL1, "test_vrFilter:      PRESENT\n", 0, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_FILTER, "     PRESENT\n", 0, 0, 0 );
 #endif
@@ -162,8 +158,7 @@ filter_matched_values(
 
                case LDAP_FILTER_EXT:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
-                               "test_vrFilter: EXT\n" ));
+                       LDAP_LOG( FILTER, DETAIL1, "test_vrFilter:      EXT\n", 0, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_FILTER, "     EXT\n", 0, 0, 0 );
 #endif
@@ -176,9 +171,8 @@ filter_matched_values(
 
                default:
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "filter", LDAP_LEVEL_INFO,
-                               "test_vrFilter:  unknown filter type %lu\n", 
-                               f->f_choice ));
+                       LDAP_LOG( FILTER, INFO, 
+                               "test_vrFilter:  unknown filter type %lu\n", f->f_choice, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_ANY, "        unknown filter type %lu\n",
                                f->f_choice, 0, 0 );
@@ -188,8 +182,7 @@ filter_matched_values(
        }
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
-               "filter_matched_values:  return=%d\n", rc ));
+       LDAP_LOG( FILTER, ENTRY, "filter_matched_values:  return=%d\n", rc, 0, 0 );
 #else
        Debug( LDAP_DEBUG_FILTER, "<= filter_matched_values %d\n", rc, 0, 0 );
 #endif
@@ -350,7 +343,8 @@ test_substrings_vrFilter(
        return LDAP_SUCCESS;
 }
 
-static int test_mra_vrFilter(
+static int
+test_mra_vrFilter(
        Backend         *be,
        Connection      *conn,
        Operation       *op,
@@ -362,10 +356,31 @@ static int test_mra_vrFilter(
        int i, j;
 
        for ( i=0; a != NULL; a = a->a_next, i++ ) {
-               struct berval *bv;
-       
-               if ( !is_ad_subtype( a->a_desc, mra->ma_desc ) ) {
-                       return( LDAP_SUCCESS );
+               struct berval *bv, value;
+
+               if ( mra->ma_desc ) {
+                       if ( !is_ad_subtype( a->a_desc, mra->ma_desc ) ) {
+                               continue;
+                       }
+                       value = mra->ma_value;
+
+               } else {
+                       const char      *text = NULL;
+
+                       /* check if matching is appropriate */
+                       if ( strcmp( mra->ma_rule->smr_syntax->ssyn_oid,
+                               a->a_desc->ad_type->sat_syntax->ssyn_oid ) != 0 ) {
+                               continue;
+                       }
+
+                       /* normalize for equality */
+                       if ( value_validate_normalize( a->a_desc, 
+                               SLAP_MR_EQUALITY,
+                               &mra->ma_value, &value,
+                               &text ) != LDAP_SUCCESS ) {
+                               continue;
+                       }
+
                }
 
                for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
@@ -375,14 +390,14 @@ static int test_mra_vrFilter(
 
                        rc = value_match( &ret, a->a_desc, mra->ma_rule,
                                SLAP_MR_ASSERTION_SYNTAX_MATCH,
-                               bv, &mra->ma_value,
+                               bv, &value,
                                &text );
 
                        if( rc != LDAP_SUCCESS ) {
                                return rc;
                        }
 
-                       if ( ret ) {
+                       if ( ret == 0 ) {
                                (*e_flags)[i][j] = 1;
                        }
                }