|
|
@ -132,7 +132,7 @@ 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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
FILE *fp = NULL;
|
|
|
|
FILE *fp = NULL;
|
|
|
|
char tmp[BF_MAXCFGLINE + 1];
|
|
|
|
char tmp[BF_MAXCFGLINE + 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
|
|
|
|
printf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname);
|
|
|
|
vfprintf(stderr,"BF-DEBUG: can't open config file \"%s\"", confname);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr,"BF-DEBUG: start reading config \"%s\"", confname);
|
|
|
|
vfprintf(stderr,"BF-DEBUG: start reading config \"%s\"", 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
|
|
|
|
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
|
|
|
|
#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
|
|
|
|
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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
isappend = FALSE;
|
|
|
|
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);
|
|
|
|
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"",
|
|
|
|
vfprintf(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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if( p_value )
|
|
|
|
if( p_value )
|
|
|
@ -270,14 +270,14 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( value == NULL || expr )
|
|
|
|
if( value == NULL || expr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#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,7 +285,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr, "BF-DEBUG: conf_readconf: too deep include"));
|
|
|
|
vfprintf(stderr, "BF-DEBUG: conf_readconf: too deep include");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
log("including level too deep");
|
|
|
|
log("including level too deep");
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
@ -296,7 +296,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( value || isifexpr )
|
|
|
|
if( value || isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -314,7 +314,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -328,7 +328,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr, ("BF-DEBUG: unknown directive `%s'", p_key);
|
|
|
|
vfprintf(stderr, ("BF-DEBUG: unknown directive `%s'", p_key);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -338,7 +338,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( isifexpr && expr )
|
|
|
|
if( isifexpr && expr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -354,7 +354,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr, "BF-DEBUG: incorrect config string");
|
|
|
|
vfprintf(stderr, "BF-DEBUG: incorrect config string");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -371,17 +371,17 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PROC_RC_WARN:
|
|
|
|
case PROC_RC_WARN:
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
#ifdef DEBUG
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -397,7 +397,7 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
maxrc = 1;
|
|
|
|
maxrc = 1;
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(stderr, "BF-DEBUG: unterminated directive `#ifexp'");
|
|
|
|
vfprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -415,7 +415,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
|
|
|
|
printf(stderr, "BF-DEBUG: can't continue without logging");
|
|
|
|
vfprintf(stderr, "BF-DEBUG: can't continue without logging");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|