+ rc = value_add_one( &(*a)->a_vals, val );
+
+ if ( rc == LDAP_SUCCESS ) {
+ if ( nval ) {
+ rc = value_add_one( &(*a)->a_nvals, nval );
+ /* FIXME: what if rc != LDAP_SUCCESS ? */
+ } else {
+ (*a)->a_nvals = (*a)->a_vals;
+ }
+ }
+ 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_normalize_one(
+ AttributeDescription *desc,
+ struct berval *val,
+ struct berval *nval,
+ void *memctx )
+{
+ 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(
+ SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+ desc->ad_type->sat_syntax,
+ desc->ad_type->sat_equality,
+ 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;
+ }
+
+ rc = attr_merge_one( e, desc, val, nvalp );
+ if ( nvalp != NULL ) {
+ slap_sl_free( nval.bv_val, memctx );
+ }
+ return rc;