Debug info before opening log and debug files
This commit is contained in:
parent
634fc3e3e5
commit
a01ea3fd63
@ -131,7 +131,9 @@ static void conf_parsestr(char *str, char **key, char **expr, char **value)
|
|||||||
|
|
||||||
int conf_readconf(const char *confname, int inclevel)
|
int conf_readconf(const char *confname, int inclevel)
|
||||||
{
|
{
|
||||||
// printf("%s %d\n", confname, inclevel);
|
#ifdef DEBUG
|
||||||
|
printf(stderr,"BF-DEBUG: Parsing config file: %s %d\n", confname, inclevel);
|
||||||
|
#endif
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char tmp[BF_MAXCFGLINE + 1];
|
char tmp[BF_MAXCFGLINE + 1];
|
||||||
int rc, maxrc = 0;
|
int rc, maxrc = 0;
|
||||||
@ -156,8 +158,10 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( i != (int)bforce_config[i].real_key )
|
if( i != (int)bforce_config[i].real_key )
|
||||||
{
|
{
|
||||||
log("invalid config table: found %d instead of %d",
|
#ifdef DEBUG
|
||||||
|
printf(stderr,"BF-DEBUG: invalid config table: found %d instead of %d",
|
||||||
bforce_config[i].real_key, i);
|
bforce_config[i].real_key, i);
|
||||||
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,11 +169,14 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
|
|
||||||
if( (fp = file_open(confname,"r")) == NULL )
|
if( (fp = file_open(confname,"r")) == NULL )
|
||||||
{
|
{
|
||||||
logerr("can't open config file \"%s\"", confname);
|
#ifdef DEBUG
|
||||||
|
printf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname);
|
||||||
|
#endif
|
||||||
return(PROC_RC_IGNORE);
|
return(PROC_RC_IGNORE);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
DEB((D_CONFIG, "readconfig: start reading config \"%s\"", confname));
|
printf(stderr,"BF-DEBUG: start reading config \"%s\"", confname);
|
||||||
|
#endif
|
||||||
|
|
||||||
while( fgets(tmp, sizeof(tmp), fp) )
|
while( fgets(tmp, sizeof(tmp), fp) )
|
||||||
{
|
{
|
||||||
@ -180,7 +187,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( isifexpr )
|
if( isifexpr )
|
||||||
{
|
{
|
||||||
log("warning: automatically close expression at empty line %d", line);
|
#ifdef DEBUG
|
||||||
|
printf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d", line);
|
||||||
|
#endif
|
||||||
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
||||||
isifexpr = FALSE;
|
isifexpr = FALSE;
|
||||||
}
|
}
|
||||||
@ -188,7 +197,10 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
if( !isappend )
|
if( !isappend )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
log("warning: appending empty or comment line %d", line);
|
#ifdef DEBUG
|
||||||
|
printf(stderr,"BF-DEBUG: warning: appending empty or comment line %d", line);
|
||||||
|
#endif
|
||||||
|
|
||||||
isappend = FALSE;
|
isappend = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,9 +242,10 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
p_value = NULL;
|
p_value = NULL;
|
||||||
|
|
||||||
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
|
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
|
||||||
|
#ifdef DEBUG
|
||||||
DEB((D_CONFIG, "conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"",
|
printf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"",
|
||||||
line, p_key, p_expr, p_value));
|
line, p_key, p_expr, p_value));
|
||||||
|
#endif
|
||||||
|
|
||||||
if( p_value )
|
if( p_value )
|
||||||
{
|
{
|
||||||
@ -256,18 +269,24 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( value == NULL || expr )
|
if( value == NULL || expr )
|
||||||
{
|
{
|
||||||
log("incorrect usage of `%s' directive", p_key);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
||||||
|
#endif
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
else if( inclevel < MAXINCLUDELEVEL )
|
else if( inclevel < MAXINCLUDELEVEL )
|
||||||
{
|
{
|
||||||
DEB((D_CONFIG, "conf_readconf: process inlude file \"%s\"", value));
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"", value);
|
||||||
|
#endif
|
||||||
rc = conf_readconf(value, inclevel + 1);
|
rc = conf_readconf(value, inclevel + 1);
|
||||||
if( rc ) rc = PROC_RC_IGNORE;
|
if( rc ) rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEB((D_CONFIG, "conf_readconf: too deep include"));
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: conf_readconf: too deep include"));
|
||||||
|
#endif
|
||||||
log("including level too deep");
|
log("including level too deep");
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
@ -276,7 +295,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( value || isifexpr )
|
if( value || isifexpr )
|
||||||
{
|
{
|
||||||
log("incorrect usage of `%s' directive", p_key);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
||||||
|
#endif
|
||||||
rc = PROC_RC_ABORT;
|
rc = PROC_RC_ABORT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -292,7 +313,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( value || expr || !isifexpr )
|
if( value || expr || !isifexpr )
|
||||||
{
|
{
|
||||||
log("incorrect usage of `%s' directive", p_key);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
||||||
|
#endif
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -301,69 +324,12 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
isifexpr = FALSE;
|
isifexpr = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* else if( strcasecmp(p_key+1, "logfile") == 0 )
|
|
||||||
{
|
|
||||||
if( value == NULL || expr )
|
|
||||||
{
|
|
||||||
log("incorrect usage of `%s' directive", p_key);
|
|
||||||
rc = PROC_RC_IGNORE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( log_reopen(value, NULL, NULL) )
|
|
||||||
{
|
|
||||||
log("can't continue without logging");
|
|
||||||
rc = PROC_RC_ABORT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( strcasecmp(p_key+1, "debugfile") == 0 )
|
|
||||||
{
|
|
||||||
if( value == NULL || expr )
|
|
||||||
{
|
|
||||||
log("incorrect usage of `%s' directive", p_key);
|
|
||||||
rc = PROC_RC_IGNORE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef DEBUG
|
|
||||||
{
|
|
||||||
if( debug_isopened() ) debug_close();
|
|
||||||
debug_setfilename(value);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
log("incorrect directive `%s': no debug code", p_key);
|
|
||||||
rc = PROC_RC_IGNORE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if( strcasecmp(p_key+1, "debuglevel") == 0 )
|
|
||||||
{
|
|
||||||
if( value == NULL || expr )
|
|
||||||
{
|
|
||||||
rc = PROC_RC_IGNORE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef DEBUG
|
|
||||||
{
|
|
||||||
unsigned long newlevel = 0L;
|
|
||||||
|
|
||||||
if( debug_parsestring(value, &newlevel) )
|
|
||||||
{
|
|
||||||
rc = PROC_RC_WARN;
|
|
||||||
}
|
|
||||||
debug_setlevel(newlevel, 1);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
log("incorrect directive `%s': no debug code", p_key);
|
|
||||||
rc = PROC_RC_IGNORE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}*/
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("unknown directive `%s'", p_key);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, ("BF-DEBUG: unknown directive `%s'", p_key);
|
||||||
|
#endif
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +337,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
{
|
{
|
||||||
if( isifexpr && expr )
|
if( isifexpr && expr )
|
||||||
{
|
{
|
||||||
log("can't use expressions inside $ifexpr block");
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block");
|
||||||
|
#endif
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
else if( isifexpr )
|
else if( isifexpr )
|
||||||
@ -385,7 +353,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("incorrect config string");
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: incorrect config string");
|
||||||
|
#endif
|
||||||
rc = PROC_RC_IGNORE;
|
rc = PROC_RC_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,13 +370,19 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
case PROC_RC_OK:
|
case PROC_RC_OK:
|
||||||
break;
|
break;
|
||||||
case PROC_RC_WARN:
|
case PROC_RC_WARN:
|
||||||
log("warning in config \"%s\" line %d", confname, line);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: warning in config \"%s\" line %d", confname, line);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case PROC_RC_IGNORE:
|
case PROC_RC_IGNORE:
|
||||||
log("ignore line %d in config \"%s\"", line, confname);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"", line, confname);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case PROC_RC_ABORT:
|
case PROC_RC_ABORT:
|
||||||
log("fatal error in config \"%s\" in line %d", confname, line);
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d", confname, line);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT_MSG();
|
ASSERT_MSG();
|
||||||
@ -418,20 +394,29 @@ int conf_readconf(const char *confname, int inclevel)
|
|||||||
file_close(fp);
|
file_close(fp);
|
||||||
|
|
||||||
if( isifexpr )
|
if( isifexpr )
|
||||||
{ maxrc = 1; log("unterminated directive `#ifexp'"); }
|
{
|
||||||
|
maxrc = 1;
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: unterminated directive `#ifexp'");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if( fullstr )
|
if( fullstr )
|
||||||
free(fullstr);
|
free(fullstr);
|
||||||
if( ifexpr )
|
if( ifexpr )
|
||||||
free(ifexpr);
|
free(ifexpr);
|
||||||
|
|
||||||
DEB((D_CONFIG, "readconfig: exit with maxrc = %d", maxrc));
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d", maxrc);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* update subsystems */
|
/* update subsystems */
|
||||||
if (inclevel==0) { // end of main config
|
if (inclevel==0) { // end of main config
|
||||||
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
||||||
{
|
{
|
||||||
log("can't continue without logging");
|
#ifdef DEBUG
|
||||||
|
printf(stderr, "BF-DEBUG: can't continue without logging");
|
||||||
|
#endif
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -3,7 +3,7 @@ dnl
|
|||||||
dnl $Id$
|
dnl $Id$
|
||||||
dnl
|
dnl
|
||||||
#AC_INIT(bforce/bforce.c)
|
#AC_INIT(bforce/bforce.c)
|
||||||
AC_INIT([bforce],[0.24],[sergey@fidoman.ru])
|
AC_INIT([bforce],[0.24.1],[sergey@fidoman.ru])
|
||||||
AC_CONFIG_HEADER(include/config.h)
|
AC_CONFIG_HEADER(include/config.h)
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
dnl # Minimum Autoconf version required.
|
dnl # Minimum Autoconf version required.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user