|
|
|
@ -129,11 +129,11 @@ static void conf_parsestr(char *str, char **key, char **expr, char **value)
|
|
|
|
|
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);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
FILE *fp = NULL;
|
|
|
|
|
char tmp[BF_MAXCFGLINE + 1];
|
|
|
|
|
int rc, maxrc = 0;
|
|
|
|
@ -158,10 +158,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
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",
|
|
|
|
|
bforce_config[i].real_key, i);
|
|
|
|
|
#endif
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -169,14 +168,12 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
|
|
|
|
|
if( (fp = file_open(confname,"r")) == NULL )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
|
|
|
|
|
#endif
|
|
|
|
|
return(PROC_RC_IGNORE);
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while( fgets(tmp, sizeof(tmp), fp) )
|
|
|
|
|
{
|
|
|
|
@ -187,9 +184,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
if( isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d\n", line);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
|
|
|
|
isifexpr = FALSE;
|
|
|
|
|
}
|
|
|
|
@ -197,9 +194,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( !isappend )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d\n", line);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isappend = FALSE;
|
|
|
|
|
}
|
|
|
|
@ -242,10 +239,10 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
p_value = NULL;
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
|
line, p_key, p_expr, p_value);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( p_value )
|
|
|
|
|
{
|
|
|
|
@ -269,24 +266,24 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
if( value == NULL || expr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
else if( inclevel < MAXINCLUDELEVEL )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -294,9 +291,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
if( value || isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_ABORT;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -312,9 +309,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
if( value || expr || !isifexpr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -326,9 +323,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: unknown directive `%s'\n", p_key);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -336,9 +333,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
{
|
|
|
|
|
if( isifexpr && expr )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
else if( isifexpr )
|
|
|
|
@ -352,9 +349,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: incorrect config string %s\n", fullstr);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rc = PROC_RC_IGNORE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -369,19 +366,19 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
case PROC_RC_OK:
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_WARN:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d\n", confname, line);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_IGNORE:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"\n", line, confname);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case PROC_RC_ABORT:
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d\n", confname, line);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT_MSG();
|
|
|
|
@ -395,9 +392,9 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( isifexpr )
|
|
|
|
|
{
|
|
|
|
|
maxrc = 1;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( fullstr )
|
|
|
|
@ -405,17 +402,17 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
if( ifexpr )
|
|
|
|
|
free(ifexpr);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: readconfig: exit with maxrc = %d\n", maxrc);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* update subsystems */
|
|
|
|
|
if (inclevel==0) { // end of main config
|
|
|
|
|
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (earlydbg)
|
|
|
|
|
fprintf(stderr, "BF-DEBUG: can't continue without logging\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
@ -427,29 +424,3 @@ int conf_readconf(const char *confname, int inclevel)
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
|
|