]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_init.c
Import Ben Collins <bcollins@debian.org> Back-TCL for SLAPD.
[openldap] / servers / slapd / back-tcl / tcl_init.c
1 /*
2  * tcl_init.c - tcl backend initialization
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 <ac/socket.h>
17
18 #include "slap.h"
19 #include "tcl_back.h"
20
21 ldap_pvt_thread_mutex_t tcl_interpreter_mutex;
22
23 int
24 tcl_back_initialize(
25         BackendInfo     *bi
26 )
27 {
28         /* Initialize the global interpreter array */
29         global_i = (struct i_info *) ch_malloc (sizeof (struct i_info));
30         global_i->count = 0;
31         global_i->name = "default";
32         global_i->next = NULL;
33         global_i->interp = Tcl_CreateInterp ();
34         Tcl_Init (global_i->interp);
35
36         /* Initialize the global interpreter lock */
37         ldap_pvt_thread_mutex_init( &tcl_interpreter_mutex );
38         bi->bi_open = NULL;
39         bi->bi_config = NULL;
40         bi->bi_close = NULL;
41         bi->bi_destroy = NULL;
42
43         bi->bi_db_init = tcl_back_db_init;
44         bi->bi_db_config = tcl_back_db_config;
45         bi->bi_db_open = tcl_back_db_open;
46         bi->bi_db_close = NULL;
47         bi->bi_db_destroy = tcl_back_db_destroy;
48
49         bi->bi_op_bind = tcl_back_bind;
50         bi->bi_op_unbind = tcl_back_unbind;
51         bi->bi_op_search = tcl_back_search;
52         bi->bi_op_compare = tcl_back_compare;
53         bi->bi_op_modify = tcl_back_modify;
54         bi->bi_op_modrdn = tcl_back_modrdn;
55         bi->bi_op_add = tcl_back_add;
56         bi->bi_op_delete = tcl_back_delete;
57         bi->bi_op_abandon = tcl_back_abandon;
58
59         bi->bi_acl_group = NULL;
60
61         return 0;
62 }
63
64 int
65 tcl_back_db_init(
66         Backend *be
67 )
68 {
69         struct tclinfo  *ti;
70
71         ti = (struct tclinfo *) ch_calloc( 1, sizeof(struct tclinfo) );
72
73         /*
74          * For some reason this causes problems
75          * specifically set to NULL
76          */
77         ti->ti_bind = NULL;
78         ti->ti_unbind = NULL;
79         ti->ti_search = NULL;
80         ti->ti_compare = NULL;
81         ti->ti_modify = NULL;
82         ti->ti_modrdn = NULL;
83         ti->ti_add = NULL;
84         ti->ti_delete = NULL;
85         ti->ti_abandon = NULL;
86
87         be->be_private = ti;
88
89         return ti == NULL;
90 }
91
92 int
93 tcl_back_db_destroy(
94         Backend *be
95 )
96 {
97         free( be->be_private );
98         return 0;
99 }