]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_close.c
Add ldap_*2name() in <include,libldap>/schema, use them in slapd/schema
[openldap] / servers / slapd / back-tcl / tcl_close.c
1 /* close.c - tcl close routines
2  *
3  * $Id: tcl_close.c,v 1.3 1999/02/17 01:02:11 bcollins Exp $
4  *
5  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
6  *
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.
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16
17 #include "slap.h"
18 #include "tcl_back.h"
19
20 int
21 tcl_back_close (
22         BackendInfo * bi
23 )
24 {
25         Tcl_DeleteInterp (global_i->interp);
26
27         return (0);
28 }
29
30 int
31 tcl_back_destroy (
32         BackendInfo * bi
33 )
34 {
35         free (global_i->interp);
36         free (global_i);
37         ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex);
38
39         return (0);
40 }
41
42 int
43 tcl_back_db_close (
44         BackendDB * bd
45 )
46 {
47         struct tclinfo *ti = (struct tclinfo *) bd->be_private;
48         struct i_info *ti_tmp;
49
50         /* Disable the interp and associated struct */
51         ti->ti_ii->count--;
52         if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
53                 /* no more db's using this and it's not the default */
54                 for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp
55                         = ti_tmp->next);
56                 /* This bypasses this interp struct in the global hash */
57                 ti_tmp->next = ti->ti_ii->next;
58                 Tcl_DeleteInterp (ti->ti_ii->interp);
59         }
60         return (0);
61 }
62
63 int
64 tcl_back_db_destroy (
65         BackendDB * bd
66 )
67 {
68         struct tclinfo *ti = (struct tclinfo *) bd->be_private;
69
70         /*
71          * Now free up the allocated memory used
72          */
73         ti->ti_ii->count--;
74         if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
75                 free (ti->ti_ii->interp);
76                 free (ti->ti_ii);
77                 free (ti);
78         }
79         free (bd->be_private);
80         bd->be_private = NULL;
81
82         return (0);
83 }