return rc;
}
+/*
+ * if a normalization function is defined for the equality matchingRule
+ * of desc, the value is normalized and stored in nval; otherwise nval
+ * is NULL
+ */
int
-attr_merge_normalize(
- Entry *e,
- AttributeDescription *desc,
- BerVarray vals,
- void *memctx )
+attr_normalize(
+ AttributeDescription *desc,
+ BerVarray vals,
+ BerVarray *nvalsp,
+ void *memctx )
{
+ int rc = LDAP_SUCCESS;
BerVarray nvals = NULL;
- int rc;
+
+ *nvalsp = NULL;
if ( desc->ad_type->sat_equality &&
desc->ad_type->sat_equality->smr_normalize )
nvals = slap_sl_calloc( sizeof(struct berval), i + 1, memctx );
for ( i = 0; !BER_BVISNULL( &vals[i] ); i++ ) {
- rc = (*desc->ad_type->sat_equality->smr_normalize)(
+ rc = desc->ad_type->sat_equality->smr_normalize(
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
desc->ad_type->sat_syntax,
desc->ad_type->sat_equality,
if ( rc != LDAP_SUCCESS ) {
BER_BVZERO( &nvals[i + 1] );
- goto error_return;
+ break;
}
}
BER_BVZERO( &nvals[i] );
+ *nvalsp = nvals;
}
- rc = attr_merge( e, desc, vals, nvals );
-
error_return:;
- if ( nvals != NULL ) {
+ if ( rc != LDAP_SUCCESS && nvals != NULL ) {
ber_bvarray_free_x( nvals, memctx );
}
+
+ return rc;
+}
+
+int
+attr_merge_normalize(
+ Entry *e,
+ AttributeDescription *desc,
+ BerVarray vals,
+ void *memctx )
+{
+ BerVarray nvals = NULL;
+ int rc;
+
+ rc = attr_normalize( desc, vals, &nvals, memctx );
+ if ( rc == LDAP_SUCCESS ) {
+ rc = attr_merge( e, desc, vals, nvals );
+ if ( nvals != NULL ) {
+ ber_bvarray_free_x( nvals, memctx );
+ }
+ }
+
return rc;
}
return rc;
}
+/*
+ * if a normalization function is defined for the equality matchingRule
+ * of desc, the value is normalized and stored in nval; otherwise nval
+ * is NULL
+ */
int
-attr_merge_normalize_one(
- Entry *e,
+attr_normalize_one(
AttributeDescription *desc,
struct berval *val,
+ struct berval *nval,
void *memctx )
{
- struct berval nval;
- struct berval *nvalp = NULL;
- int rc;
+ int rc = LDAP_SUCCESS;
+
+ BER_BVZERO( nval );
if ( desc->ad_type->sat_equality &&
desc->ad_type->sat_equality->smr_normalize )
{
- rc = (*desc->ad_type->sat_equality->smr_normalize)(
+ rc = desc->ad_type->sat_equality->smr_normalize(
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
desc->ad_type->sat_syntax,
desc->ad_type->sat_equality,
- val, &nval, memctx );
+ val, nval, memctx );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
+ }
+
+ return rc;
+}
+
+int
+attr_merge_normalize_one(
+ Entry *e,
+ AttributeDescription *desc,
+ struct berval *val,
+ void *memctx )
+{
+ struct berval nval = BER_BVNULL;
+ struct berval *nvalp = NULL;
+ int rc;
+
+ rc = attr_normalize_one( desc, val, &nval, memctx );
+ if ( rc == LDAP_SUCCESS && !BER_BVISNULL( &nval ) ) {
nvalp = &nval;
}