+/* $OpenLDAP$ */
/* add.c - tcl add routine
- *
- * $Id: tcl_add.c,v 1.5.6.1 1999/07/09 18:02:59 kdz Exp $
*
* Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
*
int
tcl_back_add (
- Backend * be,
- Connection * conn,
Operation * op,
- Entry * e
+ SlapReply * rs
)
{
- char *command, *suf_tcl, *entrystr, *results;
- int i, code, err = 0;
- struct tclinfo *ti = (struct tclinfo *) be->be_private;
+ char *command, *entrystr, *results;
+ struct berval suf_tcl;
+ int code;
+ struct tclinfo *ti = (struct tclinfo *) op->o_bd->be_private;
- if (ti->ti_add == NULL) {
- send_ldap_result (conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
- "add not implemented", NULL );
+ if (ti->ti_add.bv_len == 0) {
+ send_ldap_error (op, rs, LDAP_UNWILLING_TO_PERFORM,
+ "add not implemented" );
return (-1);
}
- for (i = 0; be->be_suffix[i] != NULL; i++);
- suf_tcl = Tcl_Merge (i, be->be_suffix);
+ if (tcl_merge_bvlist (op->o_bd->be_suffix, &suf_tcl) == NULL) {
+ send_ldap_error (op, rs, LDAP_OTHER, NULL);
+ return (-1);
+ }
- entrystr = tcl_clean_entry (e);
+ entrystr = tcl_clean_entry(op->oq_add.rs_e);
- command = (char *) ch_malloc (strlen (ti->ti_add) + strlen
- (suf_tcl) +
- strlen (entrystr) + 32);
- sprintf (command, "%s ADD {%ld} {%s} {%s}",
- ti->ti_add, op->o_msgid, suf_tcl, entrystr);
- Tcl_Free (suf_tcl);
+ command = (char *) ch_malloc (ti->ti_add.bv_len + suf_tcl.bv_len +
+ strlen(entrystr) + 52);
+ sprintf (command, "%s ADD {%ld/%ld} {%s} {%s}",
+ ti->ti_add.bv_val, op->o_connid, (long) op->o_msgid,
+ suf_tcl.bv_val, entrystr);
+ Tcl_Free (suf_tcl.bv_val);
free (entrystr);
ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
free (command);
if (code != TCL_OK) {
- err = LDAP_OPERATIONS_ERROR;
+ rs->sr_err = LDAP_OTHER;
Debug (LDAP_DEBUG_SHELL, "tcl_add_error: %s\n", results, 0, 0);
} else {
- interp_send_results (be, conn, op, results, NULL, 0);
+ interp_send_results (op, rs, results);
}
- if (err != LDAP_SUCCESS)
- send_ldap_result (conn, op, err, NULL,
- "internal backend error", NULL );
+ if (rs->sr_err != LDAP_SUCCESS) {
+ rs->sr_text = "internal backend error";
+ send_ldap_result (op, rs);
+ }
free (results);
- return (err);
+ return (rs->sr_err);
}