- struct entry_info info;
- struct berval normdn;
- struct berval prettydn;
-
- Operation op = {0};
- slap_callback cb = {callback_null_response,
- add_func, merge_func, NULL};
-
- Filter* filter = str2filter("(queryid=*)");
-
- dnPrettyNormal(0, &(e->e_name), &prettydn, &normdn);
-
- free(e->e_name.bv_val);
- e->e_name = prettydn;
- e->e_nname = normdn;
-
- info.entry = e;
- info.uuid = query_uuid;
- info.size_init = 0;
- info.size_final = 0;
- info.added = 0;
- info.glue_be = be;
- info.err = SUCCESS;
- cb.sc_private = &info;
-
- op.o_tag = LDAP_REQ_SEARCH;
- op.o_protocol = LDAP_VERSION3;
- op.o_ndn = conn->c_ndn;
- op.o_callback = &cb;
- op.o_caching_on = 1;
- op.o_time = slap_get_time();
- op.o_do_not_cache = 1;
-
- be->be_search( be, conn, &op, NULL, &(e->e_nname),
- LDAP_SCOPE_BASE, LDAP_DEREF_NEVER, 1, 0,
- filter, NULL, NULL, 0 );
- 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 (
- Backend *be_glue,
- Connection *conn,
- Operation *op,
- Entry *e,
- AttributeName *attrs,
- int attrsonly,
- LDAPControl **ctrls
-)
-{
- 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 */
- slap_callback *tmp = op->o_callback;
- struct entry_info* info = tmp->sc_private;
- Filter* filter = str2filter("(queryid=*)");
- 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;
-
- info->err = SUCCESS;
-
- be = select_backend(&entry->e_nname, 0, 0);
-
- info->size_init = get_entry_size(e, 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) );
-
- for (i=0; i < count; i++) {
- ber_dupbv(mod->sml_bvalues+i, a_new->a_vals+i);
- }
-
- mod->sml_bvalues[count].bv_val = 0;
- mod->sml_bvalues[count].bv_len = 0;
-
- mod->sml_desc = NULL;
- slap_bv2ad(&mod->sml_type, &mod->sml_desc, &text);
- mod->sml_next =NULL;
- *modtail = mod;
- modtail = &mod->sml_next;
- a_new = a_new->a_next;
- }