]> git.sur5r.net Git - openldap/commitdiff
normalize while merging values
authorPierangelo Masarati <ando@openldap.org>
Tue, 8 Apr 2003 23:27:22 +0000 (23:27 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 8 Apr 2003 23:27:22 +0000 (23:27 +0000)
servers/slapd/attr.c
servers/slapd/proto-slap.h

index ee283b6cef42bacaeecee7c2decd8d578fb1254e..a2a009aeff20bb3cb6d10d3fc536bcd0443b0e6b 100644 (file)
@@ -122,8 +122,8 @@ int
 attr_merge(
        Entry           *e,
        AttributeDescription *desc,
-       BerVarray       vals
-       , BerVarray     nvals
+       BerVarray       vals,
+       BerVarray       nvals
 ) {
        int rc;
 
@@ -152,12 +152,49 @@ attr_merge(
        return rc;
 }
 
+int
+attr_merge_normalize(
+       Entry           *e,
+       AttributeDescription *desc,
+       BerVarray       vals
+) {
+       BerVarray       nvals = NULL;
+       int             rc;
+
+       if ( desc->ad_type->sat_equality->smr_normalize ) {
+               int     i;
+               
+               for ( i = 0; vals[i].bv_val; i++);
+
+               nvals = ch_calloc( sizeof(struct berval), i + 1 );
+               for ( i = 0; vals[i].bv_val; i++ ) {
+                       rc = (*desc->ad_type->sat_equality->smr_normalize)(
+                                       0,
+                                       desc->ad_type->sat_syntax,
+                                       desc->ad_type->sat_equality,
+                                       &vals[i], &nvals[i] );
+
+                       if ( rc != LDAP_SUCCESS ) {
+                               nvals[i+1].bv_val = NULL;
+                               goto error_return;
+                       }
+               }
+               nvals[i].bv_val = NULL;
+       }
+
+       rc = attr_merge( e, desc, vals, nvals );
+
+error_return:;
+       ber_bvarray_free( nvals );
+       return rc;
+}
+
 int
 attr_merge_one(
        Entry           *e,
        AttributeDescription *desc,
-       struct berval   *val
-       , struct berval *nval
+       struct berval   *val,
+       struct berval   *nval
 ) {
        int rc;
        Attribute       **a;
@@ -184,6 +221,32 @@ attr_merge_one(
        return rc;
 }
 
+int
+attr_merge_normalize_one(
+       Entry           *e,
+       AttributeDescription *desc,
+       struct berval   *val
+) {
+       struct berval   nval;
+       int             rc;
+
+       if ( desc->ad_type->sat_equality->smr_normalize ) {
+               rc = (*desc->ad_type->sat_equality->smr_normalize)(
+                               0,
+                               desc->ad_type->sat_syntax,
+                               desc->ad_type->sat_equality,
+                               val, &nval );
+
+               if ( rc != LDAP_SUCCESS ) {
+                       return rc;
+               }
+       }
+
+       rc = attr_merge_one( e, desc, val, &nval );
+       ch_free( nval.bv_val );
+       return rc;
+}
+
 /*
  * attrs_find - find attribute(s) by AttributeDescription
  * returns next attribute which is subtype of provided description.
index f7434861043d5be995fb33bf01e00b8e0901a107..4844df4fdc0b777b8e9b2dbfe5d8da552fe7b46a 100644 (file)
@@ -146,6 +146,12 @@ LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
        AttributeDescription *desc,
        struct berval *val,
        struct berval *nval ));
+LDAP_SLAPD_F (int) attr_merge_normalize LDAP_P(( Entry *e,
+       AttributeDescription *desc,
+       BerVarray vals ));
+LDAP_SLAPD_F (int) attr_merge_normalize_one LDAP_P(( Entry *e,
+       AttributeDescription *desc,
+       struct berval *val ));
 LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
        Attribute *a, AttributeDescription *desc ));
 LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((