/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <stdio.h>
#include <rewrite.h>
+#include <lutil.h>
+#include <ldap.h>
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
-char *
+static void
apply(
FILE *fin,
const char *rewriteContext,
rewrite_session_init( info, cookie );
- string = strdup( arg );
+ string = (char *)arg;
for ( sep = strchr( rewriteContext, ',' );
rewriteContext != NULL;
rewriteContext = sep,
- sep ? sep = strchr( rewriteContext, ',' ) : NULL ) {
+ sep ? sep = strchr( rewriteContext, ',' ) : NULL )
+ {
char *errmsg = "";
if ( sep != NULL ) {
if ( result == NULL ) {
break;
}
- free( string );
+ if ( string != arg && string != result ) {
+ free( string );
+ }
string = result;
}
- free( string );
+ if ( result && result != arg ) {
+ free( result );
+ }
rewrite_session_delete( info, cookie );
rewrite_info_delete( &info );
-
- return result;
}
int
main( int argc, char *argv[] )
{
- FILE *fin = NULL;
- char *rewriteContext = REWRITE_DEFAULT_CONTEXT;
+ FILE *fin = NULL;
+ char *rewriteContext = REWRITE_DEFAULT_CONTEXT;
+ int debug = 0;
while ( 1 ) {
- int opt = getopt( argc, argv, "f:hr:" );
+ int opt = getopt( argc, argv, "d:f:hr:" );
if ( opt == EOF ) {
break;
}
switch ( opt ) {
+ case 'd':
+ if ( lutil_atoi( &debug, optarg ) != 0 ) {
+ fprintf( stderr, "illegal log level '%s'\n",
+ optarg );
+ exit( EXIT_FAILURE );
+ }
+ break;
+
case 'f':
fin = fopen( optarg, "r" );
if ( fin == NULL ) {
}
}
+ if ( debug != 0 ) {
+ ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &debug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+ }
+
if ( optind >= argc ) {
return -1;
}