mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
normalize while merging values
This commit is contained in:
parent
06a99afbdb
commit
43b1658160
@ -122,8 +122,8 @@ int
|
|||||||
attr_merge(
|
attr_merge(
|
||||||
Entry *e,
|
Entry *e,
|
||||||
AttributeDescription *desc,
|
AttributeDescription *desc,
|
||||||
BerVarray vals
|
BerVarray vals,
|
||||||
, BerVarray nvals
|
BerVarray nvals
|
||||||
) {
|
) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -152,12 +152,49 @@ attr_merge(
|
|||||||
return rc;
|
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
|
int
|
||||||
attr_merge_one(
|
attr_merge_one(
|
||||||
Entry *e,
|
Entry *e,
|
||||||
AttributeDescription *desc,
|
AttributeDescription *desc,
|
||||||
struct berval *val
|
struct berval *val,
|
||||||
, struct berval *nval
|
struct berval *nval
|
||||||
) {
|
) {
|
||||||
int rc;
|
int rc;
|
||||||
Attribute **a;
|
Attribute **a;
|
||||||
@ -184,6 +221,32 @@ attr_merge_one(
|
|||||||
return rc;
|
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
|
* attrs_find - find attribute(s) by AttributeDescription
|
||||||
* returns next attribute which is subtype of provided description.
|
* returns next attribute which is subtype of provided description.
|
||||||
|
@ -146,6 +146,12 @@ LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e,
|
|||||||
AttributeDescription *desc,
|
AttributeDescription *desc,
|
||||||
struct berval *val,
|
struct berval *val,
|
||||||
struct berval *nval ));
|
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((
|
LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
|
||||||
Attribute *a, AttributeDescription *desc ));
|
Attribute *a, AttributeDescription *desc ));
|
||||||
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((
|
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((
|
||||||
|
Loading…
Reference in New Issue
Block a user