1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-18 10:18:39 +08:00
|
|
|
/* config.c - tcl backend configuration file routine
|
1999-02-15 03:20:14 +08:00
|
|
|
*
|
|
|
|
* Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted only
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "tcl_back.h"
|
|
|
|
|
|
|
|
struct i_info *global_i;
|
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
int
|
|
|
|
tcl_back_db_config (
|
1999-02-15 03:20:14 +08:00
|
|
|
BackendDB * bd,
|
1999-08-21 03:29:43 +08:00
|
|
|
const char *fname,
|
1999-02-15 03:20:14 +08:00
|
|
|
int lineno,
|
|
|
|
int argc,
|
|
|
|
char **argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
struct tclinfo *ti = (struct tclinfo *) bd->be_private;
|
|
|
|
|
|
|
|
if (ti == NULL) {
|
1999-02-18 10:18:39 +08:00
|
|
|
fprintf (stderr,
|
|
|
|
"%s: line %d: tcl backend info is null!\n", fname,
|
1999-02-15 03:20:14 +08:00
|
|
|
lineno);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
if (ti->ti_ii == NULL) {
|
|
|
|
ti->ti_ii = global_i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Script to load */
|
|
|
|
if (strcasecmp (argv[0], "scriptpath") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing script in \"scriptpath <script>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_script_path );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* use local interpreter */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "tclrealm") == 0) {
|
|
|
|
struct i_info *ii;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing script in \"tclrealm <name>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
ti->ti_ii = NULL;
|
|
|
|
|
|
|
|
ii = global_i;
|
1999-02-17 09:53:59 +08:00
|
|
|
/* Try to see if it already exists */
|
1999-02-15 03:20:14 +08:00
|
|
|
do {
|
|
|
|
if (ii != NULL && !strcasecmp (ii->name, argv[1]))
|
1999-02-18 10:18:39 +08:00
|
|
|
ti->ti_ii = ii;
|
1999-02-15 03:20:14 +08:00
|
|
|
if (ii->next != NULL)
|
1999-02-18 10:18:39 +08:00
|
|
|
ii = ii->next;
|
1999-02-15 03:20:14 +08:00
|
|
|
} while (ii->next != NULL);
|
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
if (ti->ti_ii == NULL) { /* we need to make a new one */
|
1999-02-17 09:53:59 +08:00
|
|
|
ii->next = (struct i_info *) ch_malloc
|
|
|
|
(sizeof (struct i_info));
|
1999-02-15 03:20:14 +08:00
|
|
|
|
|
|
|
ii->next->count = 0;
|
1999-02-19 15:55:20 +08:00
|
|
|
ii->next->name = (char *) ch_strdup (argv[1]);
|
1999-02-17 09:53:59 +08:00
|
|
|
ii->next->interp = NULL;
|
1999-02-15 03:20:14 +08:00
|
|
|
ii->next->next = NULL;
|
1999-02-17 09:53:59 +08:00
|
|
|
ti->ti_ii = ii->next;
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for binds */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "bind") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"bind <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_bind );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for unbinds */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "unbind") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-18 10:18:39 +08:00
|
|
|
"%s: line %d: missing proc in \"unbind <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_unbind );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for search */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "search") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"search <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_search );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for compares */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "compare") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"compare <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_compare );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for modify */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "modify") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"modify <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_modify );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for modrdn */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "modrdn") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"modrdn <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_modrdn );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for add */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "add") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"add <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_add );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for delete */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "delete") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"delete <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_delete );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/* proc for abandon */
|
1999-02-15 03:20:14 +08:00
|
|
|
} else if (strcasecmp (argv[0], "abandon") == 0) {
|
|
|
|
if (argc < 2) {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-15 03:20:14 +08:00
|
|
|
"%s: line %d: missing proc in \"abandon <proc>\" line\n",
|
|
|
|
fname, lineno, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
ber_str2bv( argv[1], 0, 1, &ti->ti_abandon );
|
1999-02-15 03:20:14 +08:00
|
|
|
|
|
|
|
} else {
|
1999-02-23 11:51:33 +08:00
|
|
|
Debug (LDAP_DEBUG_CONFIG,
|
1999-02-17 08:30:36 +08:00
|
|
|
"Unknown tcl backend config: %s\n", argv[0], 0, 0);
|
1999-02-18 10:18:39 +08:00
|
|
|
return (1);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|