]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_close.c
Add OpenLDAP RCSid to *.[ch] in clients, libraries, and servers.
[openldap] / servers / slapd / back-tcl / tcl_close.c
1 /* $OpenLDAP$ */
2 /* close.c - tcl close 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_close (
21         BackendInfo * bi
22 )
23 {
24         Tcl_DeleteInterp (global_i->interp);
25
26         return (0);
27 }
28
29 int
30 tcl_back_destroy (
31         BackendInfo * bi
32 )
33 {
34         free (global_i->interp);
35         free (global_i);
36         ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex);
37
38         return (0);
39 }
40
41 int
42 tcl_back_db_close (
43         BackendDB * bd
44 )
45 {
46         struct tclinfo *ti = (struct tclinfo *) bd->be_private;
47         struct i_info *ti_tmp;
48
49         /* Disable the interp and associated struct */
50         ti->ti_ii->count--;
51         if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
52                 /* no more db's using this and it's not the default */
53                 for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp
54                         = ti_tmp->next);
55                 /* This bypasses this interp struct in the global hash */
56                 ti_tmp->next = ti->ti_ii->next;
57                 Tcl_DeleteInterp (ti->ti_ii->interp);
58         }
59         return (0);
60 }
61
62 int
63 tcl_back_db_destroy (
64         BackendDB * bd
65 )
66 {
67         struct tclinfo *ti = (struct tclinfo *) bd->be_private;
68
69         /*
70          * Now free up the allocated memory used
71          */
72         ti->ti_ii->count--;
73         if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
74                 free (ti->ti_ii->interp);
75                 free (ti->ti_ii);
76                 free (ti);
77         }
78         free (bd->be_private);
79         bd->be_private = NULL;
80
81         return (0);
82 }