From 8667671d1733b344c51150e28a3090bc4d64feb2 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Thu, 18 Feb 1999 02:18:39 +0000 Subject: [PATCH] * Removed uneeded cvs keywords * Fixed unfree'd 'char *results' in all tcl_* functions (only unfree'd in certain cases, moved the free to the actual function) so no more mem leaks. Tested this with over 500,000 access's for testing :) * Miscellaneous source style and tabulation fixes --- servers/slapd/back-tcl/TODO | 2 - servers/slapd/back-tcl/Version.c | 3 +- servers/slapd/back-tcl/external.h | 73 ++++++----- servers/slapd/back-tcl/tcl_abandon.c | 59 ++++----- servers/slapd/back-tcl/tcl_add.c | 48 +++---- servers/slapd/back-tcl/tcl_back.h | 67 +++++----- servers/slapd/back-tcl/tcl_bind.c | 47 +++---- servers/slapd/back-tcl/tcl_close.c | 64 +++++----- servers/slapd/back-tcl/tcl_compare.c | 47 ++++--- servers/slapd/back-tcl/tcl_config.c | 95 ++++++-------- servers/slapd/back-tcl/tcl_delete.c | 43 ++++--- servers/slapd/back-tcl/tcl_init.c | 47 ++++--- servers/slapd/back-tcl/tcl_modify.c | 87 ++++++------- servers/slapd/back-tcl/tcl_modrdn.c | 49 ++++---- servers/slapd/back-tcl/tcl_search.c | 58 ++++----- servers/slapd/back-tcl/tcl_unbind.c | 47 +++---- servers/slapd/back-tcl/tcl_util.c | 182 ++++++++++++++++----------- 17 files changed, 508 insertions(+), 510 deletions(-) diff --git a/servers/slapd/back-tcl/TODO b/servers/slapd/back-tcl/TODO index 2a85e15e92..f118d731e1 100644 --- a/servers/slapd/back-tcl/TODO +++ b/servers/slapd/back-tcl/TODO @@ -2,5 +2,3 @@ * Add a version, callable from the tcl script for checking features -* don't expand tabs for spaces... - diff --git a/servers/slapd/back-tcl/Version.c b/servers/slapd/back-tcl/Version.c index 7518460f36..ad78076533 100644 --- a/servers/slapd/back-tcl/Version.c +++ b/servers/slapd/back-tcl/Version.c @@ -1,4 +1,5 @@ -/* +/* $Id$ + * * Copyright 1999, Ben Collins , All rights reserved. * * Redistribution and use in source and binary forms are permitted only diff --git a/servers/slapd/back-tcl/external.h b/servers/slapd/back-tcl/external.h index e65fb2edc7..62b75e8018 100644 --- a/servers/slapd/back-tcl/external.h +++ b/servers/slapd/back-tcl/external.h @@ -1,59 +1,56 @@ -/* - * $Id: external.h,v 1.3 1999/02/16 23:26:05 bcollins Exp $ - */ +/* $Id: external.h,v 1.4 1999/02/17 00:55:03 bcollins Exp $ */ #ifndef _TCL_EXTERNAL_H #define _TCL_EXTERNAL_H LDAP_BEGIN_DECL -extern int tcl_back_initialize LDAP_P(( BackendInfo *bi )); -extern int tcl_back_open LDAP_P(( BackendInfo *bi )); -extern int tcl_back_close LDAP_P(( BackendInfo *bi )); -extern int tcl_back_destroy LDAP_P(( BackendInfo *bi )); +extern int tcl_back_initialize LDAP_P ((BackendInfo * bi)); +extern int tcl_back_open LDAP_P ((BackendInfo * bi)); +extern int tcl_back_close LDAP_P ((BackendInfo * bi)); +extern int tcl_back_destroy LDAP_P ((BackendInfo * bi)); -extern int tcl_back_db_init LDAP_P(( BackendDB *bd )); -extern int tcl_back_db_open LDAP_P(( BackendDB *bd )); -extern int tcl_back_db_close LDAP_P(( BackendDB *bd )); -extern int tcl_back_db_destroy LDAP_P(( BackendDB *bd )); +extern int tcl_back_db_init LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_open LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_close LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_destroy LDAP_P ((BackendDB * bd)); -extern int tcl_back_db_config LDAP_P(( BackendDB *bd, - char *fname, int lineno, int argc, char **argv )); +extern int tcl_back_db_config LDAP_P ((BackendDB * bd, + char *fname, int lineno, int argc, char **argv)); -extern int tcl_back_bind LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, - char *dn, int method, struct berval *cred, char** edn )); +extern int tcl_back_bind LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, int method, struct berval * cred, char **edn)); -extern int tcl_back_unbind LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op )); +extern int tcl_back_unbind LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op)); -extern int tcl_back_search LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, - char *base, int scope, int deref, int sizelimit, int timelimit, - Filter *filter, char *filterstr, char **attrs, int attrsonly )); +extern int tcl_back_search LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *base, int scope, int deref, int sizelimit, int timelimit, + Filter * filter, char *filterstr, char **attrs, int attrsonly)); -extern int tcl_back_compare LDAP_P((BackendDB *bd, - Connection *conn, Operation *op, - char *dn, Ava *ava )); +extern int tcl_back_compare LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, Ava * ava)); -extern int tcl_back_modify LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, - char *dn, LDAPModList *ml )); +extern int tcl_back_modify LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, LDAPModList * ml)); -extern int tcl_back_modrdn LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, - char *dn, char*newrdn, int deleteoldrdn )); +extern int tcl_back_modrdn LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, char *newrdn, int deleteoldrdn)); -extern int tcl_back_add LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, Entry *e )); +extern int tcl_back_add LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, Entry * e)); -extern int tcl_back_delete LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, char *dn )); +extern int tcl_back_delete LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, char *dn)); -extern int tcl_back_abandon LDAP_P(( BackendDB *bd, - Connection *conn, Operation *op, int msgid )); +extern int tcl_back_abandon LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, int msgid)); LDAP_END_DECL #endif /* _TCL_EXTERNAL_H */ - diff --git a/servers/slapd/back-tcl/tcl_abandon.c b/servers/slapd/back-tcl/tcl_abandon.c index b563e1b8d8..dcd07cca81 100644 --- a/servers/slapd/back-tcl/tcl_abandon.c +++ b/servers/slapd/back-tcl/tcl_abandon.c @@ -1,5 +1,6 @@ -/* - * abandon.c - tcl abandon routine +/* abandon.c - tcl abandon routine + * + * $Id: tcl_abandon.c,v 1.2 1999/02/16 23:32:49 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,10 +8,6 @@ * 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. - * - * $Id$ - * - * $Log$ */ #include "portable.h" @@ -20,11 +17,12 @@ #include "slap.h" #include "tcl_back.h" -int tcl_back_abandon ( - Backend *be, - Connection *conn, - Operation *op, - int msgid +int +tcl_back_abandon ( + Backend * be, + Connection * conn, + Operation * op, + int msgid ) { char *suf_tcl, *results, *command; @@ -32,27 +30,30 @@ int tcl_back_abandon ( struct tclinfo *ti = (struct tclinfo *) be->be_private; if (ti->ti_abandon == NULL) { - return; + return (-1); } - for ( i = 0; be->be_suffix[i] != NULL; i++ ) - ; - suf_tcl = Tcl_Merge(i, be->be_suffix); + for (i = 0; be->be_suffix[i] != NULL; i++); + suf_tcl = Tcl_Merge (i, be->be_suffix); - command = (char *) ch_malloc (strlen(ti->ti_abandon) + strlen(suf_tcl) + command = (char *) ch_malloc (strlen (ti->ti_abandon) + strlen (suf_tcl) + 20); - sprintf(command, "%s ABANDON {%ld} {%s}", + sprintf (command, "%s ABANDON {%ld} {%s}", ti->ti_abandon, op->o_msgid, suf_tcl); - Tcl_Free(suf_tcl); - - ldap_pvt_thread_mutex_lock( &tcl_interpreter_mutex ); - code = Tcl_GlobalEval(ti->ti_ii->interp, command); - results = (char *) strdup(ti->ti_ii->interp->result); - ldap_pvt_thread_mutex_unlock( &tcl_interpreter_mutex ); - free(command); - - if (code != TCL_OK) { - Debug(LDAP_DEBUG_ANY, "tcl_abandon_error: %s\n", results, 0, 0); - } - return( 0 ); + Tcl_Free (suf_tcl); + + ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex); + code = Tcl_GlobalEval (ti->ti_ii->interp, command); + results = (char *) strdup (ti->ti_ii->interp->result); + ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex); + free (command); + + if (code != TCL_OK) { + err = LDAP_OPERATIONS_ERROR; + Debug (LDAP_DEBUG_ANY, "tcl_abandon_error: %s\n", results, + 0, 0); + } + + free(results); + return (err); } diff --git a/servers/slapd/back-tcl/tcl_add.c b/servers/slapd/back-tcl/tcl_add.c index 531ef0a390..2eb0406674 100644 --- a/servers/slapd/back-tcl/tcl_add.c +++ b/servers/slapd/back-tcl/tcl_add.c @@ -1,5 +1,6 @@ -/* - * add.c - tcl add routine +/* add.c - tcl add routine + * + * $Id: tcl_add.c,v 1.2 1999/02/17 01:05:28 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,10 +8,6 @@ * 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. - * - * $Id$ - * - * $Log$ */ #include "portable.h" @@ -20,7 +17,8 @@ #include "slap.h" #include "tcl_back.h" -int tcl_back_add ( +int +tcl_back_add ( Backend * be, Connection * conn, Operation * op, @@ -37,34 +35,36 @@ int tcl_back_add ( return (-1); } - for ( i = 0; be->be_suffix[i] != NULL; i++ ) - ; - suf_tcl = Tcl_Merge(i, be->be_suffix); + for (i = 0; be->be_suffix[i] != NULL; i++); + suf_tcl = Tcl_Merge (i, be->be_suffix); - entrystr = tcl_clean_entry(e); + entrystr = tcl_clean_entry (e); - command = (char *) ch_malloc (strlen(ti->ti_add) + strlen(suf_tcl) + - strlen(entrystr) + 32); - sprintf(command, "%s ADD {%ld} {%s} {%s}", + command = (char *) ch_malloc (strlen (ti->ti_add) + strlen + (suf_tcl) + + strlen (entrystr) + 32); + sprintf (command, "%s ADD {%ld} {%s} {%s}", ti->ti_add, op->o_msgid, suf_tcl, entrystr); - Tcl_Free(suf_tcl); + Tcl_Free (suf_tcl); free (entrystr); - ldap_pvt_thread_mutex_lock( &tcl_interpreter_mutex ); - code = Tcl_GlobalEval(ti->ti_ii->interp, command); - results = (char *) strdup(ti->ti_ii->interp->result); - ldap_pvt_thread_mutex_unlock( &tcl_interpreter_mutex ); - free(command); + ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex); + code = Tcl_GlobalEval (ti->ti_ii->interp, command); + results = (char *) strdup (ti->ti_ii->interp->result); + ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex); + free (command); if (code != TCL_OK) { err = LDAP_OPERATIONS_ERROR; - Debug(LDAP_DEBUG_ANY, "tcl_add_error: %s\n", results, 0, 0); + Debug (LDAP_DEBUG_ANY, "tcl_add_error: %s\n", results, 0, 0); } else { - interp_send_results ( be, conn, op, results, NULL, 0 ); + interp_send_results (be, conn, op, results, NULL, 0); } if (err != LDAP_SUCCESS) - send_ldap_result (conn, op, err, NULL, "internal backend error"); + send_ldap_result (conn, op, err, NULL, + "internal backend error"); + + free(results); return (err); } - diff --git a/servers/slapd/back-tcl/tcl_back.h b/servers/slapd/back-tcl/tcl_back.h index 60e6cd00dc..3ad290e240 100644 --- a/servers/slapd/back-tcl/tcl_back.h +++ b/servers/slapd/back-tcl/tcl_back.h @@ -1,5 +1,6 @@ -/* - * tcl_back.h - tcl backend header (structs, functions) +/* tcl_back.h - tcl backend header (structs, functions) + * + * $Id: tcl_back.h,v 1.1 1999/02/17 01:23:18 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,10 +8,6 @@ * 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. - * - * $Id$ - * - * $Log$ */ #include @@ -21,48 +18,48 @@ #include #include "external.h" -extern ldap_pvt_thread_mutex_t tcl_interpreter_mutex; +extern ldap_pvt_thread_mutex_t tcl_interpreter_mutex; struct i_info { - Tcl_Interp *interp; - char *name; - struct i_info *next; - int count; + Tcl_Interp *interp; + char *name; + struct i_info *next; + int count; }; extern struct i_info *global_i; struct tclinfo { - char *script_path; - struct i_info *ti_ii; - char *ti_bind; - char *ti_unbind; - char *ti_search; - char *ti_compare; - char *ti_modify; - char *ti_modrdn; - char *ti_add; - char *ti_delete; - char *ti_abandon; + char *script_path; + struct i_info *ti_ii; + char *ti_bind; + char *ti_unbind; + char *ti_search; + char *ti_compare; + char *ti_modify; + char *ti_modrdn; + char *ti_add; + char *ti_delete; + char *ti_abandon; }; void readtclscript (char *script, Tcl_Interp * my_tcl); -char *tcl_clean_entry (Entry *e); +char *tcl_clean_entry (Entry * e); + int tcl_ldap_debug ( - ClientData clientData, - Tcl_Interp *interp, - int argc, - char *argv[] + ClientData clientData, + Tcl_Interp * interp, + int argc, + char *argv[] ); -int interp_send_results( - Backend *be, - Connection *conn, - Operation *op, - char *result, - char **attrs, - int attrsonly +int interp_send_results ( + Backend * be, + Connection * conn, + Operation * op, + char *result, + char **attrs, + int attrsonly ); #endif - diff --git a/servers/slapd/back-tcl/tcl_bind.c b/servers/slapd/back-tcl/tcl_bind.c index f758bf7773..20b4dae301 100644 --- a/servers/slapd/back-tcl/tcl_bind.c +++ b/servers/slapd/back-tcl/tcl_bind.c @@ -1,5 +1,6 @@ -/* - * bind.c - tcl bind routines +/* bind.c - tcl bind routines + * + * $Id: tcl_bind.c,v 1.2 1999/02/17 01:05:28 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,10 +8,6 @@ * 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. - * - * $Id$ - * - * $Log$ */ #include "portable.h" @@ -20,14 +17,15 @@ #include "slap.h" #include "tcl_back.h" -int tcl_back_bind ( +int +tcl_back_bind ( Backend * be, Connection * conn, Operation * op, char *dn, int method, struct berval *cred, - char** edn + char **edn ) { char *command, *suf_tcl, *results; @@ -42,31 +40,34 @@ int tcl_back_bind ( return (-1); } - for ( i = 0; be->be_suffix[i] != NULL; i++ ) - ; - suf_tcl = Tcl_Merge(i, be->be_suffix); + for (i = 0; be->be_suffix[i] != NULL; i++); + suf_tcl = Tcl_Merge (i, be->be_suffix); - command = (char *) ch_malloc (strlen(ti->ti_bind) + strlen(suf_tcl) + - strlen(dn) + strlen(cred->bv_val) + 64); - sprintf(command, "%s BIND {%ld} {%s} {%s} {%d} {%lu} {%s}", + command = (char *) ch_malloc (strlen (ti->ti_bind) + strlen + (suf_tcl) + + strlen (dn) + strlen (cred->bv_val) + 64); + sprintf (command, "%s BIND {%ld} {%s} {%s} {%d} {%lu} {%s}", ti->ti_bind, op->o_msgid, suf_tcl, dn, method, cred->bv_len, cred->bv_val); - Tcl_Free(suf_tcl); + Tcl_Free (suf_tcl); - ldap_pvt_thread_mutex_lock( &tcl_interpreter_mutex ); - code = Tcl_GlobalEval(ti->ti_ii->interp, command); - results = (char *) strdup(ti->ti_ii->interp->result); - ldap_pvt_thread_mutex_unlock( &tcl_interpreter_mutex ); - free(command); + ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex); + code = Tcl_GlobalEval (ti->ti_ii->interp, command); + results = (char *) strdup (ti->ti_ii->interp->result); + ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex); + free (command); if (code != TCL_OK) { err = LDAP_OPERATIONS_ERROR; - Debug(LDAP_DEBUG_ANY, "tcl_bind_error: %s\n", results, 0, 0); + Debug (LDAP_DEBUG_ANY, "tcl_bind_error: %s\n", results, 0, 0); } else { - err = interp_send_results ( be, conn, op, results, NULL, 0 ); + err = interp_send_results (be, conn, op, results, NULL, 0); } if (err != LDAP_SUCCESS) - send_ldap_result (conn, op, err, NULL, "internal backend error"); + send_ldap_result (conn, op, err, NULL, + "internal backend error"); + + free(results); return (err); } diff --git a/servers/slapd/back-tcl/tcl_close.c b/servers/slapd/back-tcl/tcl_close.c index 7f9726f684..f01b9eefa6 100644 --- a/servers/slapd/back-tcl/tcl_close.c +++ b/servers/slapd/back-tcl/tcl_close.c @@ -1,5 +1,6 @@ -/* - * close.c - tcl close routines +/* close.c - tcl close routines + * + * $Id: tcl_close.c,v 1.3 1999/02/17 01:02:11 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,13 +8,6 @@ * 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. - * - * $Id: tcl_close.c,v 1.2 1999/02/17 00:55:03 bcollins Exp $ - * - * $Log: tcl_close.c,v $ - * Revision 1.2 1999/02/17 00:55:03 bcollins - * Implemented all of the (db_)destroy and (db_)close functions - * */ #include "portable.h" @@ -28,26 +22,26 @@ tcl_back_close ( BackendInfo * bi ) { - Tcl_DeleteInterp(global_i->interp); + Tcl_DeleteInterp (global_i->interp); - return( 0 ); + return (0); } int -tcl_back_destroy( - BackendInfo *bi +tcl_back_destroy ( + BackendInfo * bi ) { - Tcl_Free(global_i->interp); - free(global_i); - ldap_pvt_thread_mutex_destroy( &tcl_interpreter_mutex ); + free (global_i->interp); + free (global_i); + ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex); - return( 0 ); + return (0); } int -tcl_back_db_close( - BackendDB *bd +tcl_back_db_close ( + BackendDB * bd ) { struct tclinfo *ti = (struct tclinfo *) bd->be_private; @@ -55,35 +49,35 @@ tcl_back_db_close( /* Disable the interp and associated struct */ ti->ti_ii->count--; - if (!ti->ti_ii->count && strcasecmp("default", ti->ti_ii->name)) { + if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) { /* no more db's using this and it's not the default */ - for(ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp = ti_tmp->next) - ; + for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp + = ti_tmp->next); /* This bypasses this interp struct in the global hash */ ti_tmp->next = ti->ti_ii->next; - Tcl_DeleteInterp(ti->ti_ii->interp); + Tcl_DeleteInterp (ti->ti_ii->interp); } - return( 0 ); + return (0); } int -tcl_back_db_destroy( - BackendDB *bd +tcl_back_db_destroy ( + BackendDB * bd ) { struct tclinfo *ti = (struct tclinfo *) bd->be_private; - /* - * Now free up the allocated memory used - */ + /* + * Now free up the allocated memory used + */ ti->ti_ii->count--; - if (!ti->ti_ii->count && strcasecmp("default", ti->ti_ii->name)) { - Tcl_Free(ti->ti_ii->interp); - free(ti->ti_ii); - free(ti); + if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) { + free (ti->ti_ii->interp); + free (ti->ti_ii); + free (ti); } - free( bd->be_private ); + free (bd->be_private); bd->be_private = NULL; - return( 0 ); + return (0); } diff --git a/servers/slapd/back-tcl/tcl_compare.c b/servers/slapd/back-tcl/tcl_compare.c index 599fa09239..1882605e12 100644 --- a/servers/slapd/back-tcl/tcl_compare.c +++ b/servers/slapd/back-tcl/tcl_compare.c @@ -1,5 +1,6 @@ -/* - * compare.c - tcl compare routines +/* compare.c - tcl compare routines + * + * $Id: tcl_compare.c,v 1.2 1999/02/17 01:05:28 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,10 +8,6 @@ * 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. - * - * $Id$ - * - * $Log$ */ #include "portable.h" @@ -39,33 +36,35 @@ tcl_back_compare ( return (-1); } - for ( i = 0; be->be_suffix[i] != NULL; i++ ) - ; - suf_tcl = Tcl_Merge(i, be->be_suffix); + for (i = 0; be->be_suffix[i] != NULL; i++); + suf_tcl = Tcl_Merge (i, be->be_suffix); - command = (char *) ch_malloc (strlen(ti->ti_compare) + - strlen(suf_tcl) + strlen(dn) + strlen(ava->ava_type) + - strlen(ava->ava_value.bv_val) + 64); - sprintf(command, "%s COMPARE {%ld} {%s} {%s} {%s: %s}", + command = (char *) ch_malloc (strlen (ti->ti_compare) + + strlen (suf_tcl) + strlen (dn) + strlen (ava->ava_type) + + strlen (ava->ava_value.bv_val) + 64); + sprintf (command, "%s COMPARE {%ld} {%s} {%s} {%s: %s}", ti->ti_compare, op->o_msgid, suf_tcl, dn, ava->ava_type, - ava->ava_value.bv_val); - Tcl_Free(suf_tcl); + ava->ava_value.bv_val); + Tcl_Free (suf_tcl); - ldap_pvt_thread_mutex_lock( &tcl_interpreter_mutex ); - code = Tcl_GlobalEval(ti->ti_ii->interp, command); - results = (char *) strdup(ti->ti_ii->interp->result); - ldap_pvt_thread_mutex_unlock( &tcl_interpreter_mutex ); - free(command); + ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex); + code = Tcl_GlobalEval (ti->ti_ii->interp, command); + results = (char *) strdup (ti->ti_ii->interp->result); + ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex); + free (command); if (code != TCL_OK) { err = LDAP_OPERATIONS_ERROR; - Debug(LDAP_DEBUG_ANY, "tcl_compare_error: %s\n", results, 0, 0); + Debug (LDAP_DEBUG_ANY, "tcl_compare_error: %s\n", results, + 0, 0); } else { - interp_send_results ( be, conn, op, results, NULL, 0 ); + interp_send_results (be, conn, op, results, NULL, 0); } if (err != LDAP_SUCCESS) - send_ldap_result (conn, op, err, NULL, "internal backend error"); - return (0); + send_ldap_result (conn, op, err, NULL, + "internal backend error"); + free(results); + return (err); } diff --git a/servers/slapd/back-tcl/tcl_config.c b/servers/slapd/back-tcl/tcl_config.c index 2b083c9ef7..d5378e36a7 100644 --- a/servers/slapd/back-tcl/tcl_config.c +++ b/servers/slapd/back-tcl/tcl_config.c @@ -1,5 +1,6 @@ -/* - * config.c - tcl backend configuration file routine +/* config.c - tcl backend configuration file routine + * + * $Id: tcl_config.c,v 1.3 1999/02/17 00:53:59 bcollins Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -7,13 +8,6 @@ * 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. - * - * $Id: tcl_config.c,v 1.2 1999/02/16 23:30:36 bcollins Exp $ - * - * $Log: tcl_config.c,v $ - * Revision 1.2 1999/02/16 23:30:36 bcollins - * fixed exit()'s to be return()'s - * */ #include "portable.h" @@ -25,7 +19,8 @@ struct i_info *global_i; -int tcl_back_db_config ( +int +tcl_back_db_config ( BackendDB * bd, char *fname, int lineno, @@ -37,9 +32,10 @@ int tcl_back_db_config ( int script_loaded = 0; if (ti == NULL) { - fprintf (stderr, "%s: line %d: tcl backend info is null!\n", fname, + fprintf (stderr, + "%s: line %d: tcl backend info is null!\n", fname, lineno); - return( 1 ); + return (1); } if (ti->ti_ii == NULL) { ti->ti_ii = global_i; @@ -51,11 +47,11 @@ int tcl_back_db_config ( Debug (LDAP_DEBUG_ANY, "%s: line %d: missing script in \"scriptpath