]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/component.c
Added a new parameter (ConfigArgs*) to the _db_init, _db_open, _db_close and
[openldap] / servers / slapd / component.c
index 7d74c191117517165366d6db370c2b0367f62629..95413c30a2afac8b430c81cefa64c9c2e6836577 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2007 The OpenLDAP Foundation.
  * Portions Copyright 2004 by IBM Corporation.
  * All rights reserved.
  *
@@ -99,7 +99,7 @@ componentFilterMatch (
 {
        ComponentSyntaxInfo *csi_attr = (ComponentSyntaxInfo*)value;
        MatchingRuleAssertion * ma = (MatchingRuleAssertion*)assertedValue;
-       int num_attr, rc, i;
+       int rc;
 
        if ( !mr || !ma->ma_cf ) return LDAP_INAPPROPRIATE_MATCHING;
 
@@ -154,8 +154,6 @@ allComponentsMatch(
 static int
 slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav )
 {
-       int len;
-
        cav->cav_ptr = cav->cav_buf = bv->bv_val;
        cav->cav_end = bv->bv_val + bv->bv_len;
 
@@ -165,11 +163,9 @@ slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav )
 ComponentReference*
 dup_comp_ref ( Operation* op, ComponentReference* cr )
 {
-       int rc, count = 0;
        ComponentReference* dup_cr;
        ComponentId* ci_curr;
        ComponentId** ci_temp;
-       ber_int_t type;
 
        dup_cr = op->o_tmpalloc( sizeof( ComponentReference ), op->o_tmpmemctx );
 
@@ -183,7 +179,7 @@ dup_comp_ref ( Operation* op, ComponentReference* cr )
                ci_curr = ci_curr->ci_next, ci_temp = &(*ci_temp)->ci_next )
        {
                *ci_temp = op->o_tmpalloc( sizeof( ComponentId ), op->o_tmpmemctx );
-               if ( !ci_temp ) return NULL;
+               if ( !*ci_temp ) return NULL;
                **ci_temp = *ci_curr;
        }
 
@@ -234,7 +230,6 @@ dup_comp_filter_item (
        ComponentAssertion* in_ca,
        ComponentAssertion** out_ca )
 {
-       ComponentAssertion* ca;
        int len;
 
        if ( !in_ca->ca_comp_ref ) return SLAPD_DISCONNECT;
@@ -298,15 +293,31 @@ dup_comp_filter (
        return( rc );
 }
 
+int
+get_aliased_filter_aa ( Operation* op, AttributeAssertion* a_assert, AttributeAliasing* aa, const char** text )
+{
+       struct berval assert_bv;
+
+       Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 );
+
+       if ( !aa->aa_cf  )
+               return LDAP_PROTOCOL_ERROR;
+
+       assert_bv = a_assert->aa_value;
+       /*
+        * Duplicate aa->aa_cf to ma->ma_cf by replacing the
+        * the component assertion value in assert_bv
+        * Multiple values may be separated with '$'
+        */
+       return dup_comp_filter ( op, &assert_bv, aa->aa_cf, &a_assert->aa_cf );
+}
 
 int
 get_aliased_filter( Operation* op,
        MatchingRuleAssertion* ma, AttributeAliasing* aa,
        const char** text )
 {
-       int rc;
        struct berval assert_bv;
-       ComponentAssertion* ca;
 
        Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 );
 
@@ -427,7 +438,8 @@ get_componentId( Operation *op, ComponentAssertionValue* cav,
 
        type = peek_componentId_type( cav );
 
-       Debug( LDAP_DEBUG_FILTER, "get_compId [%d]\n", type, 0, 0 );
+       Debug( LDAP_DEBUG_FILTER, "get_compId [%lu]\n",
+               (unsigned long) type, 0, 0 );
        len = 0;
        _cid.ci_type = type;
        _cid.ci_next = NULL;
@@ -568,6 +580,11 @@ get_component_reference(
                        cr_list = &(*cr_list)->ci_next;
 
                } else if ( rc == LDAP_COMPREF_UNDEFINED ) {
+                       if ( op ) {
+                               op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx );
+                       } else {
+                               free( ca_comp_ref );
+                       }
                        return rc;
                }
        }
@@ -582,16 +599,8 @@ get_component_reference(
                return rc;
        }
 
-       if ( rc == LDAP_SUCCESS ) {     
-               *cr = ca_comp_ref;
-               **cr = *ca_comp_ref;    
-
-       } else if ( op ) {
-                op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx );
-
-       } else {
-                free( ca_comp_ref ) ;
-       }
+       *cr = ca_comp_ref;
+       **cr = *ca_comp_ref;    
 
        (*cr)->cr_string.bv_val = start;
        (*cr)->cr_string.bv_len = end - start + 1;
@@ -890,7 +899,7 @@ strip_cav_str( ComponentAssertionValue* cav, char* str)
 /*
  * TAG : "item", "and", "or", "not"
  */
-static int
+static ber_tag_t
 strip_cav_tag( ComponentAssertionValue* cav )
 {
 
@@ -935,7 +944,6 @@ get_item( Operation *op, ComponentAssertionValue* cav, ComponentAssertion** ca,
 {
        int rc;
        ComponentAssertion* _ca;
-       struct berval t_bv;
        struct berval value;
        MatchingRule* mr;
 
@@ -1065,7 +1073,7 @@ parse_comp_filter( Operation* op, ComponentAssertionValue* cav,
        ber_tag_t       tag;
        int             err;
        ComponentFilter f;
-       /* TAG : item, and, or, not in RFC 2254 */
+       /* TAG : item, and, or, not in RFC 4515 */
        tag = strip_cav_tag( cav );
 
        if ( tag == LBER_ERROR ) {
@@ -1247,7 +1255,7 @@ test_comp_filter_item(
        ComponentSyntaxInfo *csi_attr,
        ComponentAssertion *ca )
 {
-       int rc, len;
+       int rc;
        void *attr_nm, *assert_nm;
 
        if ( strcmp(ca->ca_ma_rule->smr_mrule.mr_oid,
@@ -1369,4 +1377,11 @@ component_free( ComponentFilter *f ) {
        free_comp_filter( f );
 }
 
+void
+free_ComponentData( Attribute *a ) {
+       if ( a->a_comp_data->cd_mem_op )
+               component_destructor( a->a_comp_data->cd_mem_op );
+       free ( a->a_comp_data );
+       a->a_comp_data = NULL;
+}
 #endif