Debug info before opening log and debug files - fixes4

master
Alexey Khromov 2 months ago
parent c766c4a9f7
commit a6a1dc2881

@ -159,7 +159,7 @@ int conf_readconf(const char *confname, int inclevel)
if( i != (int)bforce_config[i].real_key ) if( i != (int)bforce_config[i].real_key )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"BF-DEBUG: invalid config table: found %d instead of %d", fprintf(stderr,"BF-DEBUG: invalid config table: found %d instead of %d\n",
bforce_config[i].real_key, i); bforce_config[i].real_key, i);
#endif #endif
return -1; return -1;
@ -170,12 +170,12 @@ int conf_readconf(const char *confname, int inclevel)
if( (fp = file_open(confname,"r")) == NULL ) if( (fp = file_open(confname,"r")) == NULL )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname); fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
#endif #endif
return(PROC_RC_IGNORE); return(PROC_RC_IGNORE);
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"", confname); fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);
#endif #endif
while( fgets(tmp, sizeof(tmp), fp) ) while( fgets(tmp, sizeof(tmp), fp) )
@ -188,7 +188,7 @@ int conf_readconf(const char *confname, int inclevel)
if( isifexpr ) if( isifexpr )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d", line); fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d\n", line);
#endif #endif
if( ifexpr ) { free(ifexpr); ifexpr = NULL; } if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
isifexpr = FALSE; isifexpr = FALSE;
@ -198,7 +198,7 @@ int conf_readconf(const char *confname, int inclevel)
continue; continue;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d", line); fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d\n", line);
#endif #endif
isappend = FALSE; isappend = FALSE;
@ -243,7 +243,7 @@ int conf_readconf(const char *confname, int inclevel)
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value); conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"", fprintf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"\n",
line, p_key, p_expr, p_value); line, p_key, p_expr, p_value);
#endif #endif
@ -270,14 +270,14 @@ int conf_readconf(const char *confname, int inclevel)
if( value == NULL || expr ) if( value == NULL || expr )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key); fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
#endif #endif
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
else if( inclevel < MAXINCLUDELEVEL ) else if( inclevel < MAXINCLUDELEVEL )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"", value); fprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"\n", value);
#endif #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;
@ -285,9 +285,8 @@ int conf_readconf(const char *confname, int inclevel)
else else
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include"); fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include\n");
#endif #endif
log("including level too deep");
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
} }
@ -296,7 +295,7 @@ int conf_readconf(const char *confname, int inclevel)
if( value || isifexpr ) if( value || isifexpr )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key); fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
#endif #endif
rc = PROC_RC_ABORT; rc = PROC_RC_ABORT;
} }
@ -314,7 +313,7 @@ int conf_readconf(const char *confname, int inclevel)
if( value || expr || !isifexpr ) if( value || expr || !isifexpr )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key); fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
#endif #endif
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
@ -328,7 +327,7 @@ int conf_readconf(const char *confname, int inclevel)
else else
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: unknown directive `%s'", p_key); fprintf(stderr, "BF-DEBUG: unknown directive `%s'\n", p_key);
#endif #endif
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
@ -338,7 +337,7 @@ int conf_readconf(const char *confname, int inclevel)
if( isifexpr && expr ) if( isifexpr && expr )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block"); fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block\n");
#endif #endif
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
@ -354,7 +353,7 @@ int conf_readconf(const char *confname, int inclevel)
else else
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: incorrect config string"); fprintf(stderr, "BF-DEBUG: incorrect config string %s\n", fullstr);
#endif #endif
rc = PROC_RC_IGNORE; rc = PROC_RC_IGNORE;
} }
@ -371,17 +370,17 @@ int conf_readconf(const char *confname, int inclevel)
break; break;
case PROC_RC_WARN: case PROC_RC_WARN:
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d", confname, line); fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d\n", confname, line);
#endif #endif
break; break;
case PROC_RC_IGNORE: case PROC_RC_IGNORE:
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"", line, confname); fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"\n", line, confname);
#endif #endif
break; break;
case PROC_RC_ABORT: case PROC_RC_ABORT:
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d", confname, line); fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d\n", confname, line);
#endif #endif
break; break;
default: default:
@ -397,7 +396,7 @@ int conf_readconf(const char *confname, int inclevel)
{ {
maxrc = 1; maxrc = 1;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'"); fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'\n");
#endif #endif
} }
@ -407,7 +406,7 @@ int conf_readconf(const char *confname, int inclevel)
free(ifexpr); free(ifexpr);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d", maxrc); fprintf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d\n", maxrc);
#endif #endif
/* update subsystems */ /* update subsystems */
@ -415,7 +414,7 @@ int conf_readconf(const char *confname, int inclevel)
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) ) if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "BF-DEBUG: can't continue without logging"); fprintf(stderr, "BF-DEBUG: can't continue without logging\n");
#endif #endif
exit(-1); exit(-1);
} }

Loading…
Cancel
Save