return rc;
}
+int
+str2loglevel( const char *s, int *l )
+{
+ int i;
+
+ if ( loglevel_ops == NULL ) {
+ loglevel_init();
+ }
+
+ i = verb_to_mask( s, loglevel_ops );
+
+ if ( BER_BVISNULL( &loglevel_ops[ i ].word) ) {
+ return -1;
+ }
+
+ *l = loglevel_ops[ i ].mask;
+
+ return 0;
+}
+
static int
config_loglevel(ConfigArgs *c) {
int i;
return( 1 );
}
} else {
- int j = verb_to_mask(c->argv[i], loglevel_ops);
- if(BER_BVISNULL(&loglevel_ops[j].word)) {
+ if ( str2loglevel( c->argv[i], &level ) ) {
sprintf( c->msg, "<%s> unknown level", c->argv[0] );
Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
c->log, c->msg, c->argv[i]);
return( 1 );
}
- level = loglevel_ops[j].mask;
}
ldap_syslog |= level;
}
case 'd': /* set debug level and 'do not detach' flag */
no_detach = 1;
#ifdef LDAP_DEBUG
- slap_debug |= atoi( optarg );
+ if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
+ {
+ int level;
+
+ if ( str2loglevel( optarg, &level ) ) {
+ fprintf( stderr,
+ "unrecognized log level "
+ "\"%s\"\n", optarg );
+ goto destroy;
+ }
+
+ slap_debug |= level;
+ } else {
+ slap_debug |= atoi( optarg );
+ }
#else
if ( atoi( optarg ) != 0 )
fputs( "must compile with LDAP_DEBUG for debugging\n",