1 /* tcl_init.c - tcl backend initialization
3 * $Id: tcl_init.c,v 1.10 1999/08/06 11:16:27 hyc Exp $
5 * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
7 * Redistribution and use in source and binary forms are permitted only
8 * as authorized by the OpenLDAP Public License. A copy of this
9 * license is available at http://www.OpenLDAP.org/license.html or
10 * in file LICENSE in the top-level directory of the distribution.
17 #include <ac/socket.h>
22 ldap_pvt_thread_mutex_t tcl_interpreter_mutex;
24 #ifdef SLAPD_TCL_DYNAMIC
26 void back_tcl_LTX_init_module(int argc, char *argv[]) {
29 memset( &bi, 0, sizeof(bi) );
31 bi.bi_init = tcl_back_initialize;
36 #endif /* SLAPD_TCL_DYNAMIC */
43 /* Initialize the global interpreter array */
44 global_i = (struct i_info *) ch_malloc (sizeof (struct i_info));
47 global_i->name = "default";
48 global_i->next = NULL;
49 global_i->interp = Tcl_CreateInterp ();
50 Tcl_Init (global_i->interp);
52 /* Initialize the global interpreter lock */
53 ldap_pvt_thread_mutex_init (&tcl_interpreter_mutex);
55 bi->bi_open = tcl_back_open;
57 bi->bi_close = tcl_back_close;
58 bi->bi_destroy = tcl_back_destroy;
60 bi->bi_db_init = tcl_back_db_init;
61 bi->bi_db_config = tcl_back_db_config;
62 bi->bi_db_open = tcl_back_db_open;
63 bi->bi_db_close = tcl_back_db_close;
64 bi->bi_db_destroy = tcl_back_db_destroy;
66 bi->bi_op_bind = tcl_back_bind;
67 bi->bi_op_unbind = tcl_back_unbind;
68 bi->bi_op_search = tcl_back_search;
69 bi->bi_op_compare = tcl_back_compare;
70 bi->bi_op_modify = tcl_back_modify;
71 bi->bi_op_modrdn = tcl_back_modrdn;
72 bi->bi_op_add = tcl_back_add;
73 bi->bi_op_delete = tcl_back_delete;
74 bi->bi_op_abandon = tcl_back_abandon;
78 bi->bi_connection_init = 0;
79 bi->bi_connection_destroy = 0;
89 /* Initialize the global interpreter array */
90 global_i = (struct i_info *) ch_malloc (sizeof (struct i_info));
93 global_i->name = "default";
94 global_i->next = NULL;
95 global_i->interp = Tcl_CreateInterp ();
96 Tcl_Init (global_i->interp);
98 /* Initialize the global interpreter lock */
99 ldap_pvt_thread_mutex_init (&tcl_interpreter_mutex);
111 ti = (struct tclinfo *) ch_calloc (1, sizeof (struct tclinfo));
114 * For some reason this causes problems
115 * specifically set to NULL
118 ti->ti_unbind = NULL;
119 ti->ti_search = NULL;
120 ti->ti_compare = NULL;
121 ti->ti_modify = NULL;
122 ti->ti_modrdn = NULL;
124 ti->ti_delete = NULL;
125 ti->ti_abandon = NULL;
137 struct tclinfo *ti = (struct tclinfo *) bd->be_private;
139 if (ti->ti_ii->interp == NULL) { /* we need to make a new one */
140 ti->ti_ii->interp = Tcl_CreateInterp ();
141 Tcl_Init (ti->ti_ii->interp);
144 /* raise that count for the interpreter */
147 /* now let's (try to) load the script */
148 readtclscript (ti->script_path, ti->ti_ii->interp);
150 /* Intall the debug command */
151 Tcl_CreateCommand (ti->ti_ii->interp, "ldap:debug", &tcl_ldap_debug,