|
|
|
@ -132,7 +132,7 @@ static void conf_parsestr(char *str, char **key, char **expr, char **value)
|
|
|
|
|
int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr,"BF-DEBUG: Parsing config file: %s %d\n", confname, inclevel);
|
|
|
|
|
vfprintf(stderr,"BF-DEBUG: Parsing config file: %s %d\n", confname, inclevel);
|
|
|
|
|
#endif
|
|
|
|
|
FILE *fp = NULL;
|
|
|
|
|
char tmp[BF_MAXCFGLINE + 1];
|
|
|
|
@ -170,12 +170,12 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( (fp = file_open(confname,"r")) == NULL )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname);
|
|
|
|
|
vfprintf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname);
|
|
|
|
|
#endif
|
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr,"BF-DEBUG: start reading config \"%s\"", confname);
|
|
|
|
|
vfprintf(stderr,"BF-DEBUG: start reading config \"%s\"", confname);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while( fgets(tmp, sizeof(tmp), fp) )
|
|
|
|
@ -188,7 +188,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d", line);
|
|
|
|
|
vfprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d", line);
|
|
|
|
|
#endif
|
|
|
|
|
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
|
|
|
|
isifexpr = FALSE;
|
|
|
|
@ -198,7 +198,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr,"BF-DEBUG: warning: appending empty or comment line %d", line);
|
|
|
|
|
vfprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d", line);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
isappend = FALSE;
|
|
|
|
@ -243,8 +243,8 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
|
|
|
|
|
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"",
|
|
|
|
|
line, p_key, p_expr, p_value));
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"",
|
|
|
|
|
line, p_key, p_expr, p_value);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if( p_value )
|
|
|
|
@ -270,14 +270,14 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( value == NULL || expr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"", value);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"", value);
|
|
|
|
|
#endif
|
|
|
|
|
rc = conf_readconf(value, inclevel + 1);
|
|
|
|
|
if( rc ) rc = PROC_RC_IGNORE;
|
|
|
|
@ -285,7 +285,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: conf_readconf: too deep include"));
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: conf_readconf: too deep include");
|
|
|
|
|
#endif
|
|
|
|
|
log("including level too deep");
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
@ -296,7 +296,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( value || isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
|
}
|
|
|
|
@ -314,7 +314,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
@ -328,7 +328,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, ("BF-DEBUG: unknown directive `%s'", p_key);
|
|
|
|
|
vfprintf(stderr, ("BF-DEBUG: unknown directive `%s'", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
@ -338,7 +338,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( isifexpr && expr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block");
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block");
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
@ -354,7 +354,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: incorrect config string");
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: incorrect config string");
|
|
|
|
|
#endif
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
@ -371,17 +371,17 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_WARN:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: warning in config \"%s\" line %d", confname, line);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d", confname, line);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"", line, confname);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"", line, confname);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d", confname, line);
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d", confname, line);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -397,7 +397,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
maxrc = 1;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: unterminated directive `#ifexp'");
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -415,7 +415,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
printf(stderr, "BF-DEBUG: can't continue without logging");
|
|
|
|
|
vfprintf(stderr, "BF-DEBUG: can't continue without logging");
|
|
|
|
|
#endif
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|