Compare commits
No commits in common. "2827504df48df5c9c82d0118a65652a0cbe9b4a0" and "d94ba35438f55ee8888d4bc8cbf33dc7bb01a793" have entirely different histories.
2827504df4
...
d94ba35438
@ -102,7 +102,6 @@ static void usage(void)
|
||||
" -S <connect_str> connect string (for slave mode only)\n"
|
||||
" -p <port> override modem port (must be defined in config)\n"
|
||||
" -u binkp|ifcico|telnet protocol to use over TCP/IP\n"
|
||||
" -v display early debug info on stderr\n"
|
||||
" -h show this help message\n"
|
||||
"\n",
|
||||
conf_getconfname()
|
||||
@ -258,7 +257,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||
|
||||
// parsing
|
||||
|
||||
while( (ch=getopt(argc, argv, "hfI:p:n:l:a:u:oivC:S:dq")) != (int)-1 )
|
||||
while( (ch=getopt(argc, argv, "hfI:p:n:l:a:u:oiC:S:dq")) != (int)-1 )
|
||||
{
|
||||
switch( ch ) {
|
||||
case 'h':
|
||||
@ -309,9 +308,6 @@ int main(int argc, char *argv[], char *envp[])
|
||||
//if( opts.runmode != MODE_ANSWER || opts.inetd ) { usage(); exit(BFERR_FATALERROR); }
|
||||
opts.inetd = 1;
|
||||
break;
|
||||
case 'v':
|
||||
opts.earlydbg = TRUE;
|
||||
break;
|
||||
case 'C':
|
||||
if( opts.confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
|
||||
opts.confname = (char *)xstrcpy(optarg);
|
||||
@ -439,16 +435,15 @@ int main(int argc, char *argv[], char *envp[])
|
||||
|
||||
/* Process primary config file */
|
||||
if( opts.confname && *opts.confname )
|
||||
rc = conf_readconf(opts.confname, 0, opts.earlydbg);
|
||||
rc = conf_readconf(opts.confname, 0);
|
||||
else
|
||||
rc = conf_readconf(conf_getconfname(), 0, opts.earlydbg);
|
||||
rc = conf_readconf(conf_getconfname(), 0);
|
||||
|
||||
if( rc ) gotoexit(BFERR_FATALERROR);
|
||||
|
||||
/* Process additional config file, ignore errors */
|
||||
if( opts.incname && *opts.incname )
|
||||
if (conf_readconf(opts.incname, 1, opts.earlydbg))
|
||||
gotoexit(BFERR_FATALERROR);
|
||||
(void)conf_readconf(opts.incname, 1);
|
||||
|
||||
/* Reopen log file if it was defined in config */
|
||||
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
||||
@ -464,7 +459,6 @@ int main(int argc, char *argv[], char *envp[])
|
||||
switch( opts.runmode )
|
||||
{
|
||||
case MODE_DAEMON:
|
||||
DEB((D_STATEM, "Daemon mode"));
|
||||
log("Daemon mode");
|
||||
rc = bforce_daemon(&opts);
|
||||
break;
|
||||
@ -472,17 +466,14 @@ case MODE_CALL_DEFAULT:
|
||||
case MODE_CALL_IP:
|
||||
case MODE_CALL_MODEM:
|
||||
case MODE_CALL_STDIO:
|
||||
DEB((D_STATEM, "Outgoing call"));
|
||||
log("Outgoing call");
|
||||
rc = bforce_master(&opts);
|
||||
break;
|
||||
case MODE_ANSWER:
|
||||
DEB((D_STATEM, "Start answer"));
|
||||
log("Start answer");
|
||||
rc = bforce_slave(&opts);
|
||||
break;
|
||||
default:
|
||||
DEB((D_STATEM, "Could not determine run mode"));
|
||||
log("Could not determine run mode");
|
||||
}
|
||||
|
||||
|
@ -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, bool earlydbg)
|
||||
int conf_readconf(const char *confname, int inclevel)
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
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,9 +158,10 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( i != (int)bforce_config[i].real_key )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"BF-DEBUG: invalid config table: found %d instead of %d\n",
|
||||
bforce_config[i].real_key, i);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -168,12 +169,14 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
|
||||
if( (fp = file_open(confname,"r")) == NULL )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"BF-DEBUG: can't open config file \"%s\"\n", confname);
|
||||
#endif
|
||||
return(PROC_RC_IGNORE);
|
||||
}
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"BF-DEBUG: start reading config \"%s\"\n", confname);
|
||||
#endif
|
||||
|
||||
while( fgets(tmp, sizeof(tmp), fp) )
|
||||
{
|
||||
@ -184,9 +187,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( isifexpr )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"BF-DEBUG: warning: automatically close expression at empty line %d\n", line);
|
||||
|
||||
#endif
|
||||
if( ifexpr ) { free(ifexpr); ifexpr = NULL; }
|
||||
isifexpr = FALSE;
|
||||
}
|
||||
@ -194,9 +197,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
if( !isappend )
|
||||
continue;
|
||||
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"BF-DEBUG: warning: appending empty or comment line %d\n", line);
|
||||
|
||||
#endif
|
||||
|
||||
isappend = FALSE;
|
||||
}
|
||||
@ -239,10 +242,10 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
p_value = NULL;
|
||||
|
||||
conf_parsestr(fullstr ? fullstr : tmp, &p_key, &p_expr, &p_value);
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
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 )
|
||||
{
|
||||
@ -266,24 +269,24 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( value == NULL || expr )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
else if( inclevel < MAXINCLUDELEVEL )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: conf_readconf: process inlude file \"%s\"\n", value);
|
||||
|
||||
rc = conf_readconf(value, inclevel + 1, earlydbg);
|
||||
#endif
|
||||
rc = conf_readconf(value, inclevel + 1);
|
||||
if( rc ) rc = PROC_RC_IGNORE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: conf_readconf: too deep include\n");
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
}
|
||||
@ -291,9 +294,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( value || isifexpr )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_ABORT;
|
||||
}
|
||||
else
|
||||
@ -309,9 +312,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( value || expr || !isifexpr )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: incorrect usage of `%s' directive\n", p_key);
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
else
|
||||
@ -323,9 +326,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
|
||||
else
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: unknown directive `%s'\n", p_key);
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
}
|
||||
@ -333,9 +336,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
{
|
||||
if( isifexpr && expr )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: can't use expressions inside $ifexpr block\n");
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
else if( isifexpr )
|
||||
@ -349,9 +352,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: incorrect config string %s\n", fullstr);
|
||||
|
||||
#endif
|
||||
rc = PROC_RC_IGNORE;
|
||||
}
|
||||
|
||||
@ -366,19 +369,19 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
case PROC_RC_OK:
|
||||
break;
|
||||
case PROC_RC_WARN:
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: warning in config \"%s\" line %d\n", confname, line);
|
||||
|
||||
#endif
|
||||
break;
|
||||
case PROC_RC_IGNORE:
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: ignore line %d in config \"%s\"\n", line, confname);
|
||||
|
||||
#endif
|
||||
break;
|
||||
case PROC_RC_ABORT:
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: fatal error in config \"%s\" in line %d\n", confname, line);
|
||||
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
ASSERT_MSG();
|
||||
@ -392,9 +395,9 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
if( isifexpr )
|
||||
{
|
||||
maxrc = 1;
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: unterminated directive `#ifexp'\n");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
if( fullstr )
|
||||
@ -402,24 +405,51 @@ int conf_readconf(const char *confname, int inclevel, bool earlydbg)
|
||||
if( ifexpr )
|
||||
free(ifexpr);
|
||||
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
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) )
|
||||
{
|
||||
if (earlydbg)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "BF-DEBUG: can't continue without logging\n");
|
||||
|
||||
#endif
|
||||
exit(-1);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
debug_configure();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
|
@ -938,15 +938,15 @@ int daemon_run(const char *confname, const char *incname, bool quit)
|
||||
|
||||
/* Read primary config file */
|
||||
if( confname && *confname )
|
||||
rc = conf_readconf(confname, 0, false);
|
||||
rc = conf_readconf(confname, 0);
|
||||
else
|
||||
rc = conf_readconf(conf_getconfname(), 0, false);
|
||||
rc = conf_readconf(conf_getconfname(), 0);
|
||||
|
||||
if( rc )
|
||||
return(BFERR_FATALERROR);
|
||||
|
||||
/* Read additional config file (manual include) */
|
||||
if( incname && *incname && conf_readconf(incname, 1, false) )
|
||||
if( incname && *incname && conf_readconf(incname, 1) )
|
||||
log("cannot read additional config (ignore)");
|
||||
|
||||
dmstate = DM_Start;
|
||||
|
@ -209,7 +209,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
}
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
if( conf_readconf(conf_getconfname(), 0) )
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ int main(int argc, char *argv[])
|
||||
/* Initialise current locale */
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
if( conf_readconf(conf_getconfname(), 0) )
|
||||
exit(1);
|
||||
|
||||
memset(&ocb, '\0', sizeof(s_outbound_callback_data));
|
||||
|
@ -159,7 +159,7 @@ int main(int argc, char *argv[])
|
||||
exit(BFERR_FATALERROR);
|
||||
}
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
if( conf_readconf(conf_getconfname(), 0) )
|
||||
exit(BFERR_FATALERROR);
|
||||
|
||||
if( rawstring )
|
||||
|
@ -151,7 +151,6 @@ typedef struct {
|
||||
bool daemon; /* Run as daemon? */
|
||||
bool quit; /* Quit from daemon */
|
||||
bool usestdio; /* Session on stdin and stdout */
|
||||
bool earlydbg; /* Early debug on stderr */
|
||||
int inetd; /* Called from inetd? */
|
||||
int force; /* Force call? */
|
||||
int hiddline; /* Hidden line number (0,1..) */
|
||||
|
@ -347,7 +347,7 @@ void deinit_translate(s_translate *dest);
|
||||
const char *conf_getconfname(void);
|
||||
int conf_postreadcheck(void);
|
||||
int conf_readpasswdlist(s_falist **pwdlist, char *fname);
|
||||
int conf_readconf(const char *confname, int inclevel, bool earlydbg);
|
||||
int conf_readconf(const char *confname, int inclevel);
|
||||
#ifdef DEBUG
|
||||
void log_overridelist(s_override *subst);
|
||||
void log_options(s_options *opt);
|
||||
|
@ -33,28 +33,28 @@ enum { LOG_FILE_DAEMON, LOG_FILE_SESSION, LOG_FILE_DEBUG, LOG_FILE_HISTORY };
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define D_CONFIG 0x0000001L
|
||||
#define D_OVERRIDE 0x0000002L
|
||||
#define D_EVENT 0x0000004L
|
||||
#define D_NODELIST 0x0000008L
|
||||
#define D_OUTBOUND 0x0000010L
|
||||
#define D_INFO 0x0000020L
|
||||
#define D_HSHAKE 0x0000040L
|
||||
#define D_TTYIO 0x0000080L
|
||||
#define D_MODEM 0x0000100L
|
||||
#define D_PROT 0x0000200L
|
||||
#define D_FREQ 0x0000400L
|
||||
#define D_STATEM 0x0000800L
|
||||
#define D_DAEMON 0x0001000L
|
||||
#define D_24554 0x0002000L
|
||||
#define D_FREE 0x0004000L
|
||||
#define D_FULL 0xfffffffL
|
||||
# define D_CONFIG 0x0000001L
|
||||
# define D_OVERRIDE 0x0000002L
|
||||
# define D_EVENT 0x0000004L
|
||||
# define D_NODELIST 0x0000008L
|
||||
# define D_OUTBOUND 0x0000010L
|
||||
# define D_INFO 0x0000020L
|
||||
# define D_HSHAKE 0x0000040L
|
||||
# define D_TTYIO 0x0000080L
|
||||
# define D_MODEM 0x0000100L
|
||||
# define D_PROT 0x0000200L
|
||||
# define D_FREQ 0x0000400L
|
||||
# define D_STATEM 0x0000800L
|
||||
# define D_DAEMON 0x0001000L
|
||||
# define D_24554 0x0002000L
|
||||
# define D_FREE 0x0004000L
|
||||
# define D_FULL 0xfffffffL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEB(what) debug what
|
||||
# define DEB(what) debug what
|
||||
#else
|
||||
#define DEB(what)
|
||||
# define DEB(what)
|
||||
#endif
|
||||
|
||||
const char *log_getfilename(int whatfor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user