]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/filter.c
added slapi_operation_set_pb
[openldap] / servers / slapd / filter.c
index 608b732c847c4c1cf26d4a5404b7dce1dccbd9b6..f0576cb02098022c48bd215d079c910a1fb37246 100644 (file)
@@ -1,7 +1,7 @@
 /* filter.c - routines for parsing and dealing with filters */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -70,7 +70,7 @@ get_filter(
         *              lessOrEqual     [6]     AttributeValueAssertion,
         *              present         [7]     AttributeType,,
         *              approxMatch     [8]     AttributeValueAssertion
-        *              extensibleMatch [9] MatchingRuleAssertion
+        *              extensibleMatch [9]     MatchingRuleAssertion
         *      }
         *
         *      SubstringFilter ::= SEQUENCE {
@@ -414,7 +414,7 @@ get_substring_filter(
                        goto return_error;
                }
 
-               /* valiate using equality matching rule validator! */
+               /* validate using equality matching rule validator! */
                rc = value_validate( f->f_sub_desc->ad_type->sat_equality,
                        &value, text );
                if( rc != LDAP_SUCCESS ) {
@@ -742,24 +742,9 @@ filter2bv( Filter *f, struct berval *fstr )
 
                break;
 
-       case LDAP_FILTER_EXT:
-               filter_escape_value( &f->f_mr_value, &tmp );
-#ifndef SLAP_X_MRA_MATCH_DNATTRS
-               fstr->bv_len = f->f_mr_desc->ad_cname.bv_len +
-                       ( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) +
-                       ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) +
-                       tmp.bv_len + ( sizeof("(:=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
-                       f->f_mr_desc->ad_cname.bv_val,
-                       f->f_mr_dnattrs ? ":dn" : "",
-                       f->f_mr_rule_text.bv_len ? ":" : "",
-                       f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "",
-                       tmp.bv_val );
-#else /* SLAP_X_MRA_MATCH_DNATTRS */
-               {
+       case LDAP_FILTER_EXT: {
                struct berval ad;
+               filter_escape_value( &f->f_mr_value, &tmp );
 
                if ( f->f_mr_desc ) {
                        ad = f->f_mr_desc->ad_cname;
@@ -780,10 +765,8 @@ filter2bv( Filter *f, struct berval *fstr )
                        f->f_mr_rule_text.bv_len ? ":" : "",
                        f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "",
                        tmp.bv_val );
-               }
-#endif /* SLAP_X_MRA_MATCH_DNATTRS */
                ber_memfree( tmp.bv_val );
-               break;
+               break;
 
        case SLAPD_FILTER_COMPUTED:
                ber_str2bv(
@@ -1308,25 +1291,9 @@ simple_vrFilter2bv( ValuesReturnFilter *f, struct berval *fstr )
                        f->f_desc->ad_cname.bv_val );
                break;
 
-       case LDAP_FILTER_EXT:
-               filter_escape_value( &f->f_mr_value, &tmp );
-
-#ifndef SLAP_X_MRA_MATCH_DNATTRS
-               fstr->bv_len = f->f_mr_desc->ad_cname.bv_len +
-                       ( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) +
-                       ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) +
-                       tmp.bv_len + ( sizeof("(:=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
-                       f->f_mr_desc->ad_cname.bv_val,
-                       f->f_mr_dnattrs ? ":dn" : "",
-                       f->f_mr_rule_text.bv_len ? ":" : "",
-                       f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "",
-                       tmp.bv_val );
-#else /* SLAP_X_MRA_MATCH_DNATTRS */
-               {
+       case LDAP_FILTER_EXT: {
                struct berval ad;
+               filter_escape_value( &f->f_mr_value, &tmp );
 
                if ( f->f_mr_desc ) {
                        ad = f->f_mr_desc->ad_cname;
@@ -1347,11 +1314,9 @@ simple_vrFilter2bv( ValuesReturnFilter *f, struct berval *fstr )
                        f->f_mr_rule_text.bv_len ? ":" : "",
                        f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "",
                        tmp.bv_val );
-               }
-#endif /* SLAP_X_MRA_MATCH_DNATTRS */
 
                ber_memfree( tmp.bv_val );
-               break;
+               break;
 
        case SLAPD_FILTER_COMPUTED:
                ber_str2bv(
@@ -1566,92 +1531,3 @@ return_error:
        return( LDAP_SUCCESS );
 }
 
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-static int filter_has_subordinates_list(
-       Filter          *filter );
-
-/*
- * FIXME: we could detect the need to filter
- * for hasSubordinates when parsing the filter ...
- */
-
-static int
-filter_has_subordinates_list(
-       Filter          *fl )
-{
-       Filter                  *f;
-
-       for ( f = fl; f != NULL; f = f->f_next ) {
-               int     rc;
-
-               rc = filter_has_subordinates( f );
-
-               if ( rc ) {
-                       return rc;
-               }
-       }
-
-       return 0;
-}
-
-int
-filter_has_subordinates(
-       Filter          *f )
-{
-       AttributeDescription    *ad = NULL;
-
-       switch ( f->f_choice ) {
-       case LDAP_FILTER_PRESENT:
-               ad = f->f_desc;
-               break;
-
-       case LDAP_FILTER_EQUALITY:
-       case LDAP_FILTER_APPROX:
-       case LDAP_FILTER_GE:
-       case LDAP_FILTER_LE:
-               ad = f->f_ava->aa_desc;
-               break;
-
-       case LDAP_FILTER_SUBSTRINGS:
-               ad = f->f_sub_desc;
-               break;
-
-       case LDAP_FILTER_EXT:
-               /* could be null; however here it is harmless */
-               ad = f->f_mra->ma_desc;
-               break;
-
-       case LDAP_FILTER_NOT:
-               return filter_has_subordinates( f->f_not );
-
-       case LDAP_FILTER_AND:
-               return filter_has_subordinates_list( f->f_and );
-
-       case LDAP_FILTER_OR:
-               return filter_has_subordinates_list( f->f_or );
-
-       case SLAPD_FILTER_COMPUTED:
-               /*
-                * something wrong?
-                */
-               return 0;
-
-       default:
-               /*
-                * this means a new type of filter has been implemented,
-                * which is not handled yet in this function; we should
-                * issue a developer's warning, e.g. an assertion
-                */
-               assert( 0 );
-               return -1;
-       }
-
-       if ( ad == slap_schema.si_ad_hasSubordinates ) {
-               return 1;
-       }
-
-       return 0;
-}
-
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
-