normalize while merging values

This commit is contained in:
Pierangelo Masarati 2003-04-08 23:27:22 +00:00
parent 06a99afbdb
commit 43b1658160
2 changed files with 73 additions and 4 deletions

View 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.

View 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((