]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_unbind.c
Add dummy reference to lutil_uuidstr() for dynamically loaded back-bdb
[openldap] / servers / slapd / back-tcl / tcl_unbind.c
1 /* $OpenLDAP$ */
2 /* unbind.c - tcl unbind routines
3  *
4  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #include "portable.h"
13
14 #include <stdio.h>
15
16 #include "slap.h"
17 #include "tcl_back.h"
18
19 int
20 tcl_back_unbind (
21         Backend * be,
22         Connection * conn,
23         Operation * op
24 )
25 {
26         char *command, *results;
27         struct berval suf_tcl;
28         int code, err = 0;
29         struct tclinfo *ti = (struct tclinfo *) be->be_private;
30
31         if (ti->ti_unbind.bv_len == 0) {
32                 return (-1);
33         }
34
35         if (tcl_merge_bvlist (be->be_suffix, &suf_tcl) == NULL) {
36                 return (-1);
37         }
38
39         command = (char *) ch_malloc (ti->ti_unbind.bv_len + suf_tcl.bv_len
40                 + conn->c_dn.bv_len + 84);
41         sprintf (command, "%s UNBIND {%ld/%ld} {%s} {%s}",
42                 ti->ti_unbind.bv_val, op->o_connid, (long) op->o_msgid,
43                 suf_tcl.bv_val, conn->c_dn.bv_val ?  conn->c_dn.bv_val : "");
44         Tcl_Free (suf_tcl.bv_val);
45
46         ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
47         code = Tcl_GlobalEval (ti->ti_ii->interp, command);
48         results = (char *) ch_strdup (ti->ti_ii->interp->result);
49         ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
50         free (command);
51
52         if (code != TCL_OK) {
53                 Debug (LDAP_DEBUG_SHELL, "tcl_unbind_error: %s\n", results,
54                         0, 0);
55         }
56
57         free (results);
58         return (err);
59 }