|
|
@ -129,11 +129,11 @@ static void conf_parsestr(char *str, char **key, char **expr, char **value)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int conf_readconf(const char *confname, int inclevel)
|
|
|
|
int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: Parsing config file: %s %d\n", confname, inclevel);
|
|
|
|
fprintf(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;
|
|
|
@ -158,10 +158,9 @@ 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
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: invalid config table: found %d instead of %d\n",
|
|
|
|
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
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -169,14 +168,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
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
|
|
|
|
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);
|
|
|
|
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while( fgets(tmp, sizeof(tmp), fp) )
|
|
|
|
while( fgets(tmp, sizeof(tmp), fp) )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -187,9 +184,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( isifexpr )
|
|
|
|
if( isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d\n", line);
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d\n", line);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
|
|
|
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
|
|
|
isifexpr = FALSE;
|
|
|
|
isifexpr = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -197,9 +194,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( !isappend )
|
|
|
|
if( !isappend )
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d\n", line);
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d\n", line);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isappend = FALSE;
|
|
|
|
isappend = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -242,10 +239,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
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: [%d] key \"%s\" expr \"%s\" value \"%s\"\n",
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( p_value )
|
|
|
|
if( p_value )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -269,24 +266,24 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( value == NULL || expr )
|
|
|
|
if( value == NULL || expr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"\n", value);
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"\n", value);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = conf_readconf(value, inclevel + 1);
|
|
|
|
rc = conf_readconf(value, inclevel + 1, earlydbg);
|
|
|
|
if( rc ) rc = PROC_RC_IGNORE;
|
|
|
|
if( rc ) rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include\n");
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,9 +291,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( value || isifexpr )
|
|
|
|
if( value || isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -312,9 +309,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -326,9 +323,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: unknown directive `%s'\n", p_key);
|
|
|
|
fprintf(stderr, "BF-DEBUG: unknown directive `%s'\n", p_key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -336,9 +333,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( isifexpr && expr )
|
|
|
|
if( isifexpr && expr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block\n");
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( isifexpr )
|
|
|
|
else if( isifexpr )
|
|
|
@ -352,9 +349,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect config string %s\n", fullstr);
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect config string %s\n", fullstr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -369,19 +366,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:
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d\n", confname, line);
|
|
|
|
fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d\n", confname, line);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"\n", line, confname);
|
|
|
|
fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"\n", line, confname);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d\n", confname, line);
|
|
|
|
fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d\n", confname, line);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
ASSERT_MSG();
|
|
|
|
ASSERT_MSG();
|
|
|
@ -395,9 +392,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( isifexpr )
|
|
|
|
if( isifexpr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
maxrc = 1;
|
|
|
|
maxrc = 1;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'\n");
|
|
|
|
fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( fullstr )
|
|
|
|
if( fullstr )
|
|
|
@ -405,17 +402,17 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
if( ifexpr )
|
|
|
|
if( ifexpr )
|
|
|
|
free(ifexpr);
|
|
|
|
free(ifexpr);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d\n", maxrc);
|
|
|
|
fprintf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d\n", 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) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (earlydbg)
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't continue without logging\n");
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't continue without logging\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
@ -427,29 +424,3 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
return maxrc;
|
|
|
|
return maxrc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
/*void debug_override(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
s_cval_entry *ptrl;
|
|
|
|
|
|
|
|
char abuf[BF_MAXADDRSTR+1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "debug_override: BEGIN"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( ptrl = bforce_config[cf_override].data; ptrl; ptrl = ptrl->next )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "log_overridelist: address %s",
|
|
|
|
|
|
|
|
ftn_addrstr(abuf, ptrl->d.override.addr)));
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "log_overridelist: \tIpaddr = \"%s\"",
|
|
|
|
|
|
|
|
ptrl->d.override.sIpaddr));
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "log_overridelist: \tPhone = \"%s\"",
|
|
|
|
|
|
|
|
ptrl->d.override.sPhone));
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "log_overridelist: \tWorktime = \"%s\"",
|
|
|
|
|
|
|
|
timevec_string(abuf, &ptrl->d.override.worktime, sizeof(abuf))));
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "log_overridelist: \tFlags = \"%s\"",
|
|
|
|
|
|
|
|
ptrl->d.override.sFlags));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEB((D_CONFIG, "debug_override: END"));
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|