]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-tcl/tcl_add.c
rework objectClass mucking to use syntax "pretty" routine
[openldap] / servers / slapd / back-tcl / tcl_add.c
index e2d324bba63fb996759f574cd6226946b41e3ade..fdc3f4619e9607f9ecd076f7991af33ec4177d95 100644 (file)
 
 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, 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);
@@ -54,16 +55,17 @@ tcl_back_add (
        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, 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);
 }