]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_abandon.c
Implemented the open, init functions correctly
[openldap] / servers / slapd / back-tcl / tcl_abandon.c
1 /*
2  * abandon.c - tcl abandon routine
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  * $Id$
12  *
13  * $Log$
14  */
15
16 #include "portable.h"
17
18 #include <stdio.h>
19
20 #include "slap.h"
21 #include "tcl_back.h"
22
23 int tcl_back_abandon (
24         Backend *be,
25         Connection      *conn,
26         Operation       *op,
27         int             msgid
28 )
29 {
30         char *suf_tcl, *results, *command;
31         int i, code, err = 0;
32         struct tclinfo *ti = (struct tclinfo *) be->be_private;
33
34         if (ti->ti_abandon == NULL) {
35                 return;
36         }
37
38         for ( i = 0; be->be_suffix[i] != NULL; i++ )
39                 ;
40         suf_tcl = Tcl_Merge(i, be->be_suffix);
41
42         command = (char *) ch_malloc (strlen(ti->ti_abandon) + strlen(suf_tcl)
43                 + 20);
44         sprintf(command, "%s ABANDON {%ld} {%s}",
45                 ti->ti_abandon, op->o_msgid, suf_tcl);
46         Tcl_Free(suf_tcl);
47
48         ldap_pvt_thread_mutex_lock( &tcl_interpreter_mutex );
49         code = Tcl_GlobalEval(ti->ti_ii->interp, command);
50         results = (char *) strdup(ti->ti_ii->interp->result);
51         ldap_pvt_thread_mutex_unlock( &tcl_interpreter_mutex );
52         free(command);
53
54         if (code != TCL_OK) {
55                 Debug(LDAP_DEBUG_ANY, "tcl_abandon_error: %s\n", results, 0, 0);
56         }
57         return( 0 );
58 }