]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_config.c
Fix cursor initialization, scope IDs
[openldap] / servers / slapd / back-tcl / tcl_config.c
1 /* $OpenLDAP$ */
2 /* config.c - tcl backend configuration file routine
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 struct i_info *global_i;
20
21 int
22 tcl_back_db_config (
23         BackendDB * bd,
24         const char *fname,
25         int lineno,
26         int argc,
27         char **argv
28 )
29 {
30         struct tclinfo *ti = (struct tclinfo *) bd->be_private;
31
32         if (ti == NULL) {
33                 fprintf (stderr,
34                         "%s: line %d: tcl backend info is null!\n", fname,
35                         lineno);
36                 return (1);
37         }
38         if (ti->ti_ii == NULL) {
39                 ti->ti_ii = global_i;
40         }
41
42         /* Script to load */
43         if (strcasecmp (argv[0], "scriptpath") == 0) {
44                 if (argc < 2) {
45                         Debug (LDAP_DEBUG_CONFIG,
46                                 "%s: line %d: missing script in \"scriptpath <script>\" line\n",
47                                 fname, lineno, 0);
48                         return (1);
49                 }
50                 ber_str2bv( argv[1], 0, 1, &ti->ti_script_path );
51
52                 /* use local interpreter */
53         } else if (strcasecmp (argv[0], "tclrealm") == 0) {
54                 struct i_info *ii;
55
56                 if (argc < 2) {
57                         Debug (LDAP_DEBUG_CONFIG,
58                                 "%s: line %d: missing script in \"tclrealm <name>\" line\n",
59                                 fname, lineno, 0);
60                         return (1);
61                 }
62                 ti->ti_ii = NULL;
63
64                 ii = global_i;
65                 /* Try to see if it already exists */
66                 do {
67                         if (ii != NULL && !strcasecmp (ii->name, argv[1]))
68                                 ti->ti_ii = ii;
69                         if (ii->next != NULL)
70                                 ii = ii->next;
71                 } while (ii->next != NULL);
72
73                 if (ti->ti_ii == NULL) {        /* we need to make a new one */
74                         ii->next = (struct i_info *) ch_malloc
75                                 (sizeof (struct i_info));
76
77                         ii->next->count = 0;
78                         ii->next->name = (char *) ch_strdup (argv[1]);
79                         ii->next->interp = NULL;
80                         ii->next->next = NULL;
81                         ti->ti_ii = ii->next;
82                 }
83
84                 /* proc for binds */
85         } else if (strcasecmp (argv[0], "bind") == 0) {
86                 if (argc < 2) {
87                         Debug (LDAP_DEBUG_CONFIG,
88                                 "%s: line %d: missing proc in \"bind <proc>\" line\n",
89                                 fname, lineno, 0);
90                         return (1);
91                 }
92                 ber_str2bv( argv[1], 0, 1, &ti->ti_bind );
93
94                 /* proc for unbinds */
95         } else if (strcasecmp (argv[0], "unbind") == 0) {
96                 if (argc < 2) {
97                         Debug (LDAP_DEBUG_CONFIG,
98                                 "%s: line %d: missing proc in \"unbind <proc>\" line\n",
99                                 fname, lineno, 0);
100                         return (1);
101                 }
102                 ber_str2bv( argv[1], 0, 1, &ti->ti_unbind );
103
104                 /* proc for search */
105         } else if (strcasecmp (argv[0], "search") == 0) {
106                 if (argc < 2) {
107                         Debug (LDAP_DEBUG_CONFIG,
108                                 "%s: line %d: missing proc in \"search <proc>\" line\n",
109                                 fname, lineno, 0);
110                         return (1);
111                 }
112                 ber_str2bv( argv[1], 0, 1, &ti->ti_search );
113
114                 /* proc for compares */
115         } else if (strcasecmp (argv[0], "compare") == 0) {
116                 if (argc < 2) {
117                         Debug (LDAP_DEBUG_CONFIG,
118                                 "%s: line %d: missing proc in \"compare <proc>\" line\n",
119                                 fname, lineno, 0);
120                         return (1);
121                 }
122                 ber_str2bv( argv[1], 0, 1, &ti->ti_compare );
123
124                 /* proc for modify */
125         } else if (strcasecmp (argv[0], "modify") == 0) {
126                 if (argc < 2) {
127                         Debug (LDAP_DEBUG_CONFIG,
128                                 "%s: line %d: missing proc in \"modify <proc>\" line\n",
129                                 fname, lineno, 0);
130                         return (1);
131                 }
132                 ber_str2bv( argv[1], 0, 1, &ti->ti_modify );
133
134                 /* proc for modrdn */
135         } else if (strcasecmp (argv[0], "modrdn") == 0) {
136                 if (argc < 2) {
137                         Debug (LDAP_DEBUG_CONFIG,
138                                 "%s: line %d: missing proc in \"modrdn <proc>\" line\n",
139                                 fname, lineno, 0);
140                         return (1);
141                 }
142                 ber_str2bv( argv[1], 0, 1, &ti->ti_modrdn );
143
144                 /* proc for add */
145         } else if (strcasecmp (argv[0], "add") == 0) {
146                 if (argc < 2) {
147                         Debug (LDAP_DEBUG_CONFIG,
148                                 "%s: line %d: missing proc in \"add <proc>\" line\n",
149                                 fname, lineno, 0);
150                         return (1);
151                 }
152                 ber_str2bv( argv[1], 0, 1, &ti->ti_add );
153
154                 /* proc for delete */
155         } else if (strcasecmp (argv[0], "delete") == 0) {
156                 if (argc < 2) {
157                         Debug (LDAP_DEBUG_CONFIG,
158                                 "%s: line %d: missing proc in \"delete <proc>\" line\n",
159                                 fname, lineno, 0);
160                         return (1);
161                 }
162                 ber_str2bv( argv[1], 0, 1, &ti->ti_delete );
163
164                 /* proc for abandon */
165         } else if (strcasecmp (argv[0], "abandon") == 0) {
166                 if (argc < 2) {
167                         Debug (LDAP_DEBUG_CONFIG,
168                                 "%s: line %d: missing proc in \"abandon <proc>\" line\n",
169                                 fname, lineno, 0);
170                         return (1);
171                 }
172                 ber_str2bv( argv[1], 0, 1, &ti->ti_abandon );
173
174         } else {
175                 Debug (LDAP_DEBUG_CONFIG,
176                         "Unknown tcl backend config: %s\n", argv[0], 0, 0);
177                 return (1);
178         }
179
180         return 0;
181 }