-/*
- * tcl_init.c - tcl backend initialization
+/* tcl_init.c - tcl backend initialization
+ *
+ * $Id: tcl_init.c,v 1.9 1999/07/05 04:26:30 kdz Exp $
*
* Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
*
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
- *
- * $Id: tcl_init.c,v 1.2 1999/02/17 00:55:54 bcollins Exp $
- *
- * $Log: tcl_init.c,v $
- * Revision 1.2 1999/02/17 00:55:54 bcollins
- * Implemented the open, init functions correctly
- *
*/
#include "portable.h"
ldap_pvt_thread_mutex_t tcl_interpreter_mutex;
+#ifdef SLAPD_TCL_DYNAMIC
+#include <gmodule.h>
+
+G_MODULE_EXPORT void init_module(int argc, char *argv[]) {
+ BackendInfo bi;
+
+ memset( &bi, 0, sizeof(bi) );
+ bi.bi_type = "tcl";
+ bi.bi_init = tcl_back_initialize;
+
+ backend_add(&bi);
+}
+
+#endif /* SLAPD_TCL_DYNAMIC */
+
int
-tcl_back_initialize(
- BackendInfo *bi
+tcl_back_initialize (
+ BackendInfo * bi
)
{
/* Initialize the global interpreter array */
global_i = (struct i_info *) ch_malloc (sizeof (struct i_info));
+
global_i->count = 0;
global_i->name = "default";
global_i->next = NULL;
Tcl_Init (global_i->interp);
/* Initialize the global interpreter lock */
- ldap_pvt_thread_mutex_init( &tcl_interpreter_mutex );
+ ldap_pvt_thread_mutex_init (&tcl_interpreter_mutex);
bi->bi_open = tcl_back_open;
- bi->bi_config = NULL;
+ bi->bi_config = 0;
bi->bi_close = tcl_back_close;
bi->bi_destroy = tcl_back_destroy;
bi->bi_op_delete = tcl_back_delete;
bi->bi_op_abandon = tcl_back_abandon;
- bi->bi_acl_group = NULL;
+ bi->bi_acl_group = 0;
+
+ bi->bi_connection_init = 0;
+ bi->bi_connection_destroy = 0;
return 0;
}
int
-tcl_back_open(
- BackendInfo *bi
+tcl_back_open (
+ BackendInfo * bi
)
{
/* Initialize the global interpreter array */
global_i = (struct i_info *) ch_malloc (sizeof (struct i_info));
+
global_i->count = 0;
global_i->name = "default";
global_i->next = NULL;
Tcl_Init (global_i->interp);
/* Initialize the global interpreter lock */
- ldap_pvt_thread_mutex_init( &tcl_interpreter_mutex );
+ ldap_pvt_thread_mutex_init (&tcl_interpreter_mutex);
- return( 0 );
+ return (0);
}
int
-tcl_back_db_init(
- Backend *be
+tcl_back_db_init (
+ Backend * be
)
{
- struct tclinfo *ti;
+ struct tclinfo *ti;
- ti = (struct tclinfo *) ch_calloc( 1, sizeof(struct tclinfo) );
+ ti = (struct tclinfo *) ch_calloc (1, sizeof (struct tclinfo));
/*
* For some reason this causes problems
return ti == NULL;
}
-int tcl_back_db_open (
- BackendDB * bd
+int
+tcl_back_db_open (
+ BackendDB * bd
)
{
struct tclinfo *ti = (struct tclinfo *) bd->be_private;
- if (ti->ti_ii->interp == NULL) { /* we need to make a new one */
+ if (ti->ti_ii->interp == NULL) { /* we need to make a new one */
ti->ti_ii->interp = Tcl_CreateInterp ();
- Tcl_Init (ti->interp);
+ Tcl_Init (ti->ti_ii->interp);
}
/* raise that count for the interpreter */
readtclscript (ti->script_path, ti->ti_ii->interp);
/* Intall the debug command */
- Tcl_CreateCommand( ti->ti_ii->interp, "ldap:debug", &tcl_ldap_debug,
+ Tcl_CreateCommand (ti->ti_ii->interp, "ldap:debug", &tcl_ldap_debug,
NULL, NULL);
return 0;