}
int
-parse_debug_level( const char *arg, int *levelp )
+parse_debug_unknowns( char **unknowns, int *levelp )
+{
+ int i, level, rc = 0;
+
+ for ( i = 0; unknowns[ i ] != NULL; i++ ) {
+ level = 0;
+ if ( str2loglevel( unknowns[ i ], &level )) {
+ fprintf( stderr,
+ "unrecognized log level \"%s\"\n", unknowns[ i ] );
+ rc = 1;
+ } else {
+ *levelp |= level;
+ }
+ }
+ return rc;
+}
+
+int
+parse_debug_level( const char *arg, int *levelp, char ***unknowns )
{
int level;
if ( arg != NULL && arg[ 0 ] != '-' && !isdigit( arg[ 0 ] ) )
{
- int i, goterr = 0;
+ int i;
char **levels;
levels = ldap_str2charray( arg, "," );
level = 0;
if ( str2loglevel( levels[ i ], &level ) ) {
+ /* remember this for later */
+ ldap_charray_add( unknowns, levels[ i ] );
fprintf( stderr,
- "unrecognized log level "
- "\"%s\"\n", levels[ i ] );
- goterr = 1;
- /* but keep parsing... */
-
+ "unrecognized log level \"%s\" (deferred)\n",
+ levels[ i ] );
} else {
*levelp |= level;
}
ldap_charray_free( levels );
- if ( goterr ) {
- return 1;
- }
-
} else {
if ( lutil_atoix( &level, arg, 0 ) != 0 ) {
fprintf( stderr,
struct sync_cookie *scp = NULL;
struct sync_cookie *scp_entry = NULL;
+ char **debug_unknowns = NULL;
+ char **syslog_unknowns = NULL;
+
char *serverNamePrefix = "";
size_t l;
int level = 0;
no_detach = 1;
- if ( parse_debug_level( optarg, &level ) ) {
+ if ( parse_debug_level( optarg, &level, &debug_unknowns ) ) {
goto destroy;
}
#ifdef LDAP_DEBUG
}
case 's': /* set syslog level */
- if ( parse_debug_level( optarg, &ldap_syslog ) ) {
+ if ( parse_debug_level( optarg, &ldap_syslog, &syslog_unknowns ) ) {
goto destroy;
}
break;
goto destroy;
}
+ if ( debug_unknowns ) {
+ rc = parse_debug_unknowns( debug_unknowns, &slap_debug );
+ ldap_charray_free( debug_unknowns );
+ debug_unknowns = NULL;
+ if ( rc )
+ goto destroy;
+ }
+ if ( syslog_unknowns ) {
+ rc = parse_debug_unknowns( syslog_unknowns, &ldap_syslog );
+ ldap_charray_free( syslog_unknowns );
+ syslog_unknowns = NULL;
+ if ( rc )
+ goto destroy;
+ }
+
if ( check & CHECK_CONFIG ) {
fprintf( stderr, "config check succeeded\n" );
char *filterstr = NULL;
char *subtree = NULL;
char *ldiffile = NULL;
+ char **debug_unknowns = NULL;
int rc, i, dbnum;
int mode = SLAP_TOOL_MODE;
int truncatemode = 0;
case 'd': { /* turn on debugging */
int level = 0;
- if ( parse_debug_level( optarg, &level ) ) {
+ if ( parse_debug_level( optarg, &level, &debug_unknowns ) ) {
usage( tool, progname );
}
#ifdef LDAP_DEBUG
exit( EXIT_FAILURE );
}
+ if ( debug_unknowns ) {
+ rc = parse_debug_unknowns( debug_unknowns, &slap_debug );
+ ldap_charray_free( debug_unknowns );
+ debug_unknowns = NULL;
+ if ( rc )
+ exit( EXIT_FAILURE );
+ }
+
at_oc_cache = 1;
switch ( tool ) {