- dnPrettyNormal(0, &rs->sr_entry->e_name, &prettydn, &normdn,
- op->o_tmpmemctx);
-
- free(rs->sr_entry->e_name.bv_val);
- rs->sr_entry->e_name = prettydn;
- if (rs->sr_entry->e_nname.bv_val) free(rs->sr_entry->e_nname.bv_val);
- rs->sr_entry->e_nname = normdn;
-
- info.entry = rs->sr_entry;
- info.uuid = query_uuid;
- info.size_init = 0;
- info.size_final = 0;
- info.added = 0;
- info.glue_be = op->o_bd;
- info.err = SUCCESS;
- cb.sc_private = &info;
-
- op_tmp.o_tag = LDAP_REQ_SEARCH;
- op_tmp.o_protocol = LDAP_VERSION3;
- op_tmp.o_callback = &cb;
- op_tmp.o_caching_on = 1;
- op_tmp.o_time = slap_get_time();
- op_tmp.o_do_not_cache = 1;
-
- op_tmp.o_req_dn = rs->sr_entry->e_name;
- op_tmp.o_req_ndn = rs->sr_entry->e_nname;
- op_tmp.ors_scope = LDAP_SCOPE_BASE;
- op_tmp.ors_deref = LDAP_DEREF_NEVER;
- op_tmp.ors_slimit = 1;
- op_tmp.ors_tlimit = 0;
- op_tmp.ors_filter = filter;
- op_tmp.ors_filterstr = bv_queryid_any;
- op_tmp.ors_attrs = NULL;
- op_tmp.ors_attrsonly = 0;
-
- op->o_bd->be_search( &op_tmp, &sreply );
- result->type = info.err;
- if ( result->type == SUCCESS )
- result->rc = info.added;
- else
- result->rc = 0;
- return ( info.size_final - info.size_init );
-}
-
-static int
-merge_func (
- Operation *op,
- SlapReply *rs
-)
-{
- Backend *be;
- char *new_attr_name;
- Attribute *a_new, *a;
- int i = 0;
- int rc = 0;
-
- int count;
- struct timeval time; /* time */
- long timediff; /* time */
- struct entry_info *info = op->o_callback->sc_private;
- Filter *filter = str2filter( bv_queryid_any.bv_val );
- Entry *entry = info->entry;
- struct berval *uuid = info->uuid;
- Modifications *modhead = NULL;
- Modifications *mod;
- Modifications **modtail = &modhead;
- AttributeDescription *a_new_desc;
- const char *text = NULL;
- Operation op_tmp = *op;
- SlapReply sreply = {REP_RESULT};
- SlapReply sreply1 = {REP_RESULT};
-
- info->err = SUCCESS;
-
- be = select_backend(&entry->e_nname, 0, 0);
-
- info->size_init = get_entry_size(rs->sr_entry, 0, 0);
- a_new = entry->e_attrs;
-
- while (a_new != NULL) {
- a_new_desc = a_new->a_desc;
- mod = (Modifications *) malloc( sizeof(Modifications) );
- mod->sml_op = LDAP_MOD_REPLACE;
- ber_dupbv(&mod->sml_type, &a_new_desc->ad_cname);
-
- for ( count = 0; a_new->a_vals[count].bv_val; count++ )
- ;
-
- mod->sml_bvalues = (struct berval*) malloc(
- (count+1) * sizeof( struct berval) );
-
- mod->sml_nvalues = (struct berval*) malloc(
- (count+1) * sizeof( struct berval) );
-
- for ( i = 0; i < count; i++ ) {
- ber_dupbv(mod->sml_bvalues+i, a_new->a_vals+i);
- if ( a_new->a_desc->ad_type->sat_equality &&
- a_new->a_desc->ad_type->sat_equality->smr_normalize ) {
- rc = a_new->a_desc->ad_type->sat_equality->smr_normalize(
- 0,
- a_new->a_desc->ad_type->sat_syntax,
- a_new->a_desc->ad_type->sat_equality,
- a_new->a_vals+i, mod->sml_nvalues+i, NULL );
- if (rc) {
- info->err = MERGE_ERR;
- return 0;
- }
- }
- else {
- ber_dupbv( mod->sml_nvalues+i, a_new->a_vals+i );
- }
- }