map parsing of configuration file

pull/1/head
Tom Early 10 years ago
parent 582087386d
commit fa47e1fe16

@ -20,27 +20,33 @@
# Your G2 Gateway callsign can be up to 6 characters
# This will also be used to connect to the remote ircDDB server
# and validate you on the DStar trust system
# and validate you on the DStar system
# YOU MUST SET THIS TO A VAILD CALLSIGN
OWNER =
# This is for APRS/GPS
SEND_APRS = Y
# This is for the Live IRC site, or Quadnet
# if you don't want you frequency, location or url sent, set this to "N", or leave the "RPTR_X" fields empty.
SEND_QRGS_MAPS = Y
# RPTR_X = Type | Frequency(MHz) | Offset(MHz) | Range(m) | above ground level(m) | latitude | longitude | description#1 | description#2 | URL
# If you do NOT want to define a parameter for a module, then leave the parameter BLANK, except...
# Type: 0 is DVAP, 1 is DVRPTR. YOU MUST SPECIFY THIS PARAMETER.
# only the first 20 characters of the descriptions and 64 characters of the URL will be used.
# Example for a 2m DVAP connected to an antenna 10 meters above ground level with a range of 1 mile
# (Yes, if you use good cable connected to an outside antenna, your dvap can go a mile! I've done it.)
# RPTR_C = 0 | 146.5 | 0 | 1609.344 | 10 | 42.0000 | -73.0000 | Mytown, MyState | MyGrid | github.com/ac2ie/g2_ircddb
RPTR_A =
RPTR_B =
RPTR_C =
# Example for a 2m DVRPTR connected to an antenna 10 meters above ground level with a range of 10 miles
# RPTR_C = 1 | 146.5 | 0 | 16093.44 | 10 | 42.0000 | -73.0000 | Mytown, MyState | MyCountry or MyGridSquare | github.com/ac2ie/g2_ircddb
# YOU MUST DEFINE AT LEAST ONE REPEATER!
#RPTR_A = 1 | | | | | | | | | github.com/ac2ie/g2_ircddb
#RPTR_B = 1 | | | | | | | | | github.com/ac2ie/g2_ircddb
RPTR_C = 0 | | | | | | | | | github.com/ac2ie/g2_ircddb
###################################################################################################
# All other parameters are optional. Uncomment the assignments to set a different value.
# This is for APRS/GPS
#SEND_APRS = Y
# This is for the Live IRC site, or Quadnet
# if you don't want you frequency, location or url sent, set this to "N", or some of the RPTR_X fields empty.
#SEND_QRGS_MAPS = Y
# Which local address on your Linux box will be used
# to report to the remote IRC database server(group2, group1,...)
@ -48,42 +54,47 @@ RPTR_C =
# If you have more than one ethernet card, then you may set it to a specific local IP
# that is assigned to that specific ethernet card
# If you have one ethernet card, you can use 0.0.0.0
LOCAL_IRC_IP = 0.0.0.0
#LOCAL_IRC_IP = 0.0.0.0
# You should NOT change the value for APRS_HOST
# Leave it set to: rotate.aprs.net
# The only time to change it is when you have your own APRS_HOST server
# or when you have a server that is closer to your QTH
APRS_HOST = rotate.aprs.net
APRS_PORT = 14580
#APRS_HOST = rotate.aprs.net
#APRS_PORT = 14580
# How often to report the aprs beacon, in minutes, Do NOT make it less than 40
APRS_INTERVAL = 40
APRS_FILTER=
#APRS_INTERVAL = 40
#APRS_FILTER=
# The G2 external port of this Gateway server
# Remote gateways will route data here
G2_EXTERNAL_IP = 0.0.0.0
G2_EXTERNAL_PORT = 40000
#G2_EXTERNAL_IP = 0.0.0.0
#G2_EXTERNAL_PORT = 40000
# The G2 internal port of this Gateway server
# Our local repeater modules will send data here
G2_INTERNAL_IP = 0.0.0.0
G2_INTERNAL_PORT = 19000
#G2_INTERNAL_IP = 0.0.0.0
#G2_INTERNAL_PORT = 19000
# Where is the g2_link running?
TO_G2_LINK_IP = 127.0.0.1
TO_G2_LINK_PORT = 18997
#TO_G2_LINK_IP = 127.0.0.1
#TO_G2_LINK_PORT = 18997
# The repeater modules of this repeater
TO_RPTR_IP_A = 127.0.0.1
TO_RPTR_PORT_A = 19998
#TO_RPTR_IP_A = 127.0.0.1
#TO_RPTR_PORT_A = 19998
TO_RPTR_IP_B = 127.0.0.1
TO_RPTR_PORT_B = 19999
#TO_RPTR_IP_B = 127.0.0.1
#TO_RPTR_PORT_B = 19999
TO_RPTR_IP_C = 127.0.0.1
TO_RPTR_PORT_C = 20000
#TO_RPTR_IP_C = 127.0.0.1
#TO_RPTR_PORT_C = 20000
# Timeouts in seconds
# We need these timeouts because the END-OF-AUDIO packet can get lost.
@ -100,52 +111,66 @@ TO_RPTR_PORT_C = 20000
# Echotest-recording timeout:
# If after 1 second, audio stops coming in for echotest-recording,
# we will stop recording for ECHOTEST
ECHOTEST_REC_TIMEOUT = 1
#ECHOTEST_REC_TIMEOUT = 1
# Voicemail-recording timeout:
# If after 1 second, audio stops coming in for voicemail-recording,
# we will stop recording for voicemail
VOICEMAIL_REC_TIMEOUT = 1
#VOICEMAIL_REC_TIMEOUT = 1
# If after 2 seconds, we do not receive any more packets from remote system,
# we will assume that the remote QSO has stopped
FROM_REMOTE_G2_TIMEOUT = 2
#FROM_REMOTE_G2_TIMEOUT = 2
# If after 1 second, we do not receive any more packets from
# our local repeater, we will assume that the local RF user has stopped talking.
FROM_LOCAL_RPTR_TIMEOUT = 1
#FROM_LOCAL_RPTR_TIMEOUT = 1
# print QSO details
QSO_DETAILS = Y
#QSO_DETAILS = Y
# These 2 options limit the lines in the log.
# For production systems, we recommend: IRC_DEBUG=N
IRC_DEBUG = N
DTMF_DEBUG = N
#IRC_DEBUG = N
#DTMF_DEBUG = N
# Do you want to re-generate the HEADER if there is a timeout from
# messages arriving from remote systems(reflectors, gateways, ...)
REGEN_HDR = Y
#REGEN_HDR = Y
# LINK STATUS file
# This file is created by g2_link
# This gateway will ONLY read that status file
# to determine if any module is linked to anything
STATUS_FILE = /usr/local/etc/RPT_STATUS.txt
DTMF_DIR = /tmp
#STATUS_FILE = /usr/local/etc/RPT_STATUS.txt
#DTMF_DIR = /tmp
# Directory of recorded files created in ECHOTEST/playback mode
ECHOTEST_DIR = /tmp
#ECHOTEST_DIR = /tmp
# How many SECONDS to wait before starting to playback the recorded file.
# 1 second is enough, some repeaters require 2 seconds to re-initialize
# before they accept new streams again.
PLAY_WAIT = 2
# must be between 1 and 10
# PLAY_WAIT = 2
# How many MILLIseconds to delay when playing back each of the recorded packets
# Normal VoIP is 20 milliseconds or a little less
PLAY_DELAY = 19
# must be between 10 and 50
#PLAY_DELAY = 19
IRC_DDB_HOST = rr.openquad.net
# The remote ircDDB database
# For US, Canada and North America
# IRC_DDB_HOST=group2-irc.ircddb.net
@ -153,11 +178,15 @@ IRC_DDB_HOST = rr.openquad.net
# IRC_DDB_HOST=group1-irc.ircddb.net
# For registration free routing, use OpenQuad's round-robin, rr.openquad.net
#IRC_DDB_HOST = rr.openquad.net
# The remote ircDDB port
IRC_DDB_PORT = 9007
#IRC_DDB_PORT = 9007
# Your ircDDB password given to you by the German ircDDB team.
# Put your correct password here.
# you will only need this with a club call using group1-irc
IRC_PASS = 1111111111111111
#IRC_PASS = 1111111111111111

@ -51,6 +51,7 @@
#include <regex.h>
#include <string>
#include <map>
#include <utility>
using namespace std;
@ -546,137 +547,103 @@ static char *trim(char *s)
// remove trailing whitespace
while (strlen(s) && isspace(s[strlen(s)-1]))
s[strlen(s)-1] = (char)NULL;
// count leading whitespace
int i = 0;
while (isspace(s[i]))
i++;
// this could be used on malloc'ed char*, so we will not change where s points
// and this will keep free() working properly.
// Instead we will move the string to s and write over leading whitespace.
if (i) {
char *p1 = s - 1;
char *p2 = p1 + i;
do {
*++p1 = *++p2;
} while (*p1);
}
// move s to first non-space char
while (isspace(*s))
s++;
}
// the returned value doesn't have to be used. s didn't change!
return s;
}
static bool parse_config(const char *filename, map<string,string> &param)
{
struct stat s_buf;
int rc = stat(filename, &s_buf);
if (rc) {
traceit("Failed to stat '%s'\n", filename);
return false;
}
char *file = (char *)calloc((size_t)s_buf.st_size+1, sizeof(char));
if (NULL == file) {
traceit("failed to calloc memory\n");
return false;
}
FILE *f = fopen(filename, "r");
if (NULL == f) {
traceit("failed to open '%s'\n", filename);
return false;
}
if (s_buf.st_size != fread(file, sizeof(char), s_buf.st_size, f)) {
traceit("failed to read '%s'\n", filename);
fclose(f);
free(file);
return false;
}
fclose(f);
char *pline, *pvalue;
char *line = trim(strtok_r(file, "\n", &pline));
while (line) {
if (strlen(line) && *line!='#' && strchr(line, '=')) {
char *key = trim(strtok_r(line, "=", &pvalue));
if (strlen(key)) {
char *value = trim(strtok_r(NULL, "=", &pvalue));
if (value) {
param[key] = value;
}
}
}
line = trim(strtok_r(NULL, "\n", &pline));
}
free(file);
return true;
}
/* process configuration file */
static int read_config(char *cfgFile)
{
short int valid_params = 39;
short int params = 0;
unsigned short i;
FILE *cnf = NULL;
char aline[1024];
char *tok = NULL;
const char *Tstr = "TRUE";
const char *Fstr = "FALSE";
char zero = (char)NULL;
cnf = fopen(cfgFile, "r");
if (!cnf) {
traceit("Failed to open file %s\n", cfgFile);
return 1;
}
map<string, string> param;
traceit("Reading file %s\n", cfgFile);
while (fgets(aline, 1024, cnf) != NULL) {
(void)trim(aline);
if ('#'==aline[0] || NULL==strchr(aline, '=') || (char)NULL==aline[0])
continue;
char *param = strtok(aline, "=");
if (NULL == param)
continue;
(void)trim(param);
if (0 == strlen(param))
continue;
char *value = trim(strtok(NULL, "=")); // get the rest of the line, i.e., the value
// trim value
(void)trim(value);
if (NULL==value)
value = &zero;
if (0 == strcmp(param, "OWNER")) {
if (3>strlen(value) || CALL_SIZE-2<strlen(value))
traceit("OWNER value '%s' invalid\n", value);
else {
strcpy(OWNER, value);
strcpy(owner, value);
if (! parse_config(cfgFile, param))
return 1;
map<string, string>::iterator pit = param.find("OWNER");
if (param.end() == pit) {
traceit("OWNER not defined!\n");
return 1;
}
if (pit->second.length()<3 || pit->second.length() > CALL_SIZE-2) {
traceit("OWNER value '%s' invalid\n", pit->second.c_str());
return 1;
}
strcpy(OWNER, pit->second.c_str());
strcpy(owner, pit->second.c_str());
for (i=0; i<strlen(OWNER); i++) {
if (isupper(owner[i]))
owner[i] = tolower(owner[i]);
if (islower(OWNER[i]))
OWNER[i] = toupper(OWNER[i]);
else
owner[i] = tolower(owner[i]);
}
traceit("OWNER=[%s]\n", OWNER);
while (CALL_SIZE > strlen(OWNER))
while (strlen(OWNER) < CALL_SIZE)
strcat(OWNER, " ");
params ++;
}
} else if (0 == strcmp(param, "STATUS_FILE")) {
strncpy(STATUS_FILE, value ,FILENAME_MAX);
STATUS_FILE[FILENAME_MAX] = zero;
traceit("STATUS_FILE=[%s]\n",STATUS_FILE);
params ++;
} else if (0 == strcmp(param, "LOCAL_IRC_IP")) {
if (strlen(value) < 7)
traceit("LOCAL_IRC_IP value [%s] invalid\n", value);
for (short int m=0; m<3; m++) {
string key = "RPTR_";
key += m + 'A';
pit = param.find(key);
if (param.end() == pit)
rptr.mod[m].defined = false;
else {
strncpy(LOCAL_IRC_IP, value, IP_SIZE);
LOCAL_IRC_IP[IP_SIZE] = zero;
traceit("LOCAL_IRC_IP=[%s]\n", LOCAL_IRC_IP);
params ++;
}
} else if (0 == strcmp(param,"SEND_QRGS_MAPS")) {
if ('Y'==value[0] || 'y'==value[0])
SEND_QRGS_MAPS = true;
else
SEND_QRGS_MAPS = false;
traceit("SEND_QRGS_MAPS=[%s]\n", SEND_QRGS_MAPS ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "APRS_HOST")) {
strncpy(rptr.aprs_host, value, MAXHOSTNAMELEN);
rptr.aprs_host[MAXHOSTNAMELEN] = zero;
traceit("APRS_HOST=[%s]\n", rptr.aprs_host);
params++;
} else if (0 == strcmp(param, "APRS_PORT")) {
rptr.aprs_port = atoi(value);
traceit("APRS_PORT=[%d]\n", rptr.aprs_port);
params++;
} else if (0 == strcmp(param, "APRS_INTERVAL")) {
rptr.aprs_interval = atoi(value);
traceit("APRS_INTERVAL=[%d]\n", rptr.aprs_interval);
if (rptr.aprs_interval < 40) {
rptr.aprs_interval = 40;
traceit("APRS_INTERVAL is low number, re-setting to 40\n");
}
params++;
} else if (0 == strcmp(param, "APRS_FILTER")) {
strncpy(rptr.aprs_filter, value, 512);
rptr.aprs_filter[511] = zero;
traceit("APRS_filter=[%s]\n", rptr.aprs_filter);
params++;
} else if (0 == strncmp(param, "RPTR_", 5)) {
char cm = param[5];
int m = cm - 'A';
if (0<=m && m<3) {
rptr.mod[i].defined = strlen(value) ? true : false;
if (rptr.mod[i].defined) {
rptr.mod[m].defined = true;
char value[128];
strncpy(value, param[key].c_str(), 128);
value[127] = zero;
for (i=0; i<10; i++) {
tok = strtok(i?NULL:value, "|");
switch (i) {
@ -690,8 +657,8 @@ static int read_config(char *cfgFile)
strcpy(rptr.mod[m].package_version, DVRPTR_VERSION);
break;
default:
rptr.mod[m].package_version[0] = zero;
break;
traceit("%s type %s not defined!\n", key.c_str(), tok);
return 1;
}
break;
case 1:
@ -736,16 +703,14 @@ static int read_config(char *cfgFile)
rptr.mod[m].url[tok ? 64 : 0] = zero;
}
}
if (strlen(rptr.mod[m].package_version)) {
params++;
// make the long description
strcpy(rptr.mod[m].desc, rptr.mod[m].desc1);
if (strlen(rptr.mod[m].desc2)) {
strcat(rptr.mod[m].desc, "%s ");
if (strlen(rptr.mod[m].desc))
strcat(rptr.mod[m].desc, " ");
strcat(rptr.mod[m].desc, rptr.mod[m].desc2);
}
traceit("Mod%c:\n", cm);
traceit("RPTR_%c:\n", m+'A');
traceit("\tType =%s\n", rptr.mod[m].package_version);
traceit("\tfreq =%lg\n", rptr.mod[m].frequency);
traceit("\toffset =%lg\n", rptr.mod[m].offset);
@ -756,199 +721,268 @@ static int read_config(char *cfgFile)
traceit("\tdesc1 =%s\n", rptr.mod[m].desc1);
traceit("\tdesc2 =%s\n", rptr.mod[m].desc2);
traceit("\turl =%s\n", rptr.mod[m].url);
}
}
if (false==rptr.mod[0].defined && false==rptr.mod[1].defined && false==rptr.mod[2].defined) {
traceit("No repeaters defined!\n");
return 1;
}
pit = param.find("STATUS_FILE");
if (param.end() == pit)
strcpy(STATUS_FILE, "/usr/local/etc/RPT_STATUS.txt");
else {
strncpy(STATUS_FILE, pit->second.c_str() ,FILENAME_MAX);
STATUS_FILE[FILENAME_MAX] = zero;
}
traceit("STATUS_FILE=[%s]\n", STATUS_FILE);
pit = param.find("LOCAL_IRC_IP");
if (param.end() == pit)
strcpy(LOCAL_IRC_IP, "0.0.0.0");
else {
if (pit->second.length()>IP_SIZE || pit->second.length()<7) {
traceit("LOCAL_IRC_IP value [%s] invalid\n", pit->second.c_str());
return 1;
} else
traceit("RPTR_%c Type not defined\n", cm);
strcpy(LOCAL_IRC_IP, pit->second.c_str());
}
traceit("LOCAL_IRC_IP=[%s]\n", LOCAL_IRC_IP);
pit = param.find("SEND_QRGS_MAPS");
if (param.end() == pit)
SEND_QRGS_MAPS = true;
else
SEND_QRGS_MAPS = ('Y'==toupper(pit->second.at(0))) ? true : false;
traceit("SEND_QRGS_MAPS=[%s]\n", SEND_QRGS_MAPS ? Tstr : Fstr);
pit = param.find("APRS_HOST");
if (param.end() == pit)
strcpy(rptr.aprs_host, "rotate.aprs.net");
else {
if (pit->second.length() > MAXHOSTNAMELEN) {
traceit("APRS_HOST definition is too long\n");
return 1;
} else
params++; // empty value for RPTR_X
strcpy(rptr.aprs_host, pit->second.c_str());
rptr.aprs_host[MAXHOSTNAMELEN] = zero;
}
traceit("APRS_HOST=[%s]\n", rptr.aprs_host);
pit = param.find("APRS_PORT");
rptr.aprs_port = (param.end()==pit) ? 14580 : atoi(pit->second.c_str());
traceit("APRS_PORT=[%d]\n", rptr.aprs_port);
pit = param.find("APRS_INTERVAL");
rptr.aprs_interval = (param.end()==pit) ? 40 : atoi(pit->second.c_str());
traceit("APRS_INTERVAL=[%d]\n", rptr.aprs_interval);
if (rptr.aprs_interval < 40) {
rptr.aprs_interval = 40;
traceit("APRS_INTERVAL is low number, re-setting to 40\n");
}
pit = param.find("APRS_FILTER");
if (param.end() != pit) {
strncpy(rptr.aprs_filter, pit->second.c_str(), 512);
rptr.aprs_filter[511] = zero;
} else
traceit("RPTR_ID_%c? must be A, B or C\n", cm);
rptr.aprs_filter[0] = zero;
traceit("APRS_filter=[%s]\n", rptr.aprs_filter);
} else if (0 == strcmp(param, "G2_EXTERNAL_IP")) {
if (strlen(value) < 7)
traceit("G2_EXTERNAL_IP value [%s] invalid\n", value);
pit = param.find("G2_EXTERNAL_IP");
if (param.end() == pit)
strcpy(G2_EXTERNAL_IP, "0.0.0.0");
else {
strncpy(G2_EXTERNAL_IP, value, IP_SIZE);
G2_EXTERNAL_IP[IP_SIZE] = zero;
traceit("G2_EXTERNAL_IP=[%s]\n", G2_EXTERNAL_IP);
params ++;
if (pit->second.length()<7 || pit->second.length()>IP_SIZE) {
traceit("G2_EXTERNAL_IP value [%s] invalid\n", pit->second.c_str());
return 1;
} else
strcpy(G2_EXTERNAL_IP, pit->second.c_str());
}
traceit("G2_EXTERNAL_IP=[%s]\n", G2_EXTERNAL_IP);
} else if (0 == strcmp(param, "G2_EXTERNAL_PORT")) {
G2_EXTERNAL_PORT = atoi(value);
pit = param.find("G2_EXTERNAL_PORT");
G2_EXTERNAL_PORT = (param.end() == pit) ? 40000 : atoi(pit->second.c_str());
traceit("G2_EXTERNAL_PORT=[%d]\n", G2_EXTERNAL_PORT);
params ++;
} else if (0 == strcmp(param, "G2_INTERNAL_IP")) {
if (strlen(value) < 7)
traceit("G2_INTERNAL_IP value [%s] invalid\n", value);
pit = param.find("G2_INTERNAL_IP");
if (param.end() == pit)
strcpy(G2_INTERNAL_IP, "0.0.0.0");
else {
strncpy(G2_INTERNAL_IP, value, IP_SIZE);
G2_INTERNAL_IP[IP_SIZE] = zero;
traceit("G2_INTERNAL_IP=[%s]\n", G2_INTERNAL_IP);
params ++;
if (pit->second.length()<7 || pit->second.length()>IP_SIZE) {
traceit("G2_INTERNAL_IP value [%s] invalid\n", pit->second.c_str());
return 1;
} else
strcpy(G2_INTERNAL_IP, pit->second.c_str());
}
traceit("G2_INTERNAL_IP=[%s]\n", G2_INTERNAL_IP);
} else if (0 == strcmp(param, "G2_INTERNAL_PORT")) {
G2_INTERNAL_PORT = atoi(value);
pit = param.find("G2_INTERNAL_PORT");
G2_INTERNAL_PORT = (param.end() == pit) ? 19000 : atoi(pit->second.c_str());
traceit("G2_INTERNAL_PORT=[%d]\n", G2_INTERNAL_PORT);
params ++;
} else if (0 == strcmp(param, "TO_G2_LINK_IP")) {
if (strlen(value) < 7)
traceit("TO_G2_LINK_IP value [%s] invalid\n", value);
pit = param.find("TO_G2_LINK_IP");
if (param.end() == pit)
strcpy(TO_G2_LINK_IP, "127.0.0.1");
else {
strncpy(TO_G2_LINK_IP, value, IP_SIZE);
TO_G2_LINK_IP[IP_SIZE] = zero;
traceit("TO_G2_LINK_IP=[%s]\n", TO_G2_LINK_IP);
params ++;
if (pit->second.length()<7 || pit->second.length()>IP_SIZE) {
traceit("TO_G2_LINK_IP value [%s] invalid\n", pit->second.c_str());
return 1;
} else
strcpy(TO_G2_LINK_IP, pit->second.c_str());
}
traceit("TO_G2_LINK_IP=[%s]\n", TO_G2_LINK_IP);
} else if (0 == strcmp(param, "TO_G2_LINK_PORT")) {
TO_G2_LINK_PORT = atoi(value);
pit = param.find("TO_G2_LINK_PORT");
TO_G2_LINK_PORT = (param.end() == pit) ? 18997 : atoi(pit->second.c_str());
traceit("TO_G2_LINK_PORT=[%d]\n", TO_G2_LINK_PORT);
params ++;
} else if (0 == strncmp(param, "TO_RPTR_IP_", 11)) {
char cm = param[11];
int m = cm - 'A';
if (0<=m && m<3) {
if (strlen(value) < 7)
traceit("TO_RPTR_IP_$c value [%s] invalid\n", cm, value);
for (i=0; i<3; i++) {
string key = "TO_RPTR_IP_";
key += i + 'A';
pit = param.find(key);
if (param.end() == pit)
strcpy(TO_RPTR_IP[i], "127.0.0.1");
else {
strncpy(TO_RPTR_IP[m], value, IP_SIZE);
TO_RPTR_IP[m][IP_SIZE] = '\0';
traceit("TO_RPTR_IP_%c=[%s]\n", cm, TO_RPTR_IP[m]);
params ++;
}
} else
traceit("TO_RPTR_IP_%c is invalid\n", cm);
} else if (0 == strncmp(param, "TO_RPTR_PORT_", 13)) {
char cm = param[13];
int m = cm - 'A';
if (0<=m && m<3) {
TO_RPTR_PORT[m] = atoi(value);
traceit("TO_RPTR_PORT_%c=[%d]\n", cm, TO_RPTR_PORT[m]);
params ++;
if (pit->second.length()<7 || pit->second.length()>IP_SIZE) {
traceit("%s address %s is invalid\n", key.c_str(), pit->second.c_str());
return 1;
} else
traceit("TO_RPTR_PORT_%c is invalid\n", cm);
strcpy(TO_RPTR_IP[i], pit->second.c_str());
}
traceit("%s = [%s]\n", key.c_str(), TO_RPTR_IP[i]);
} else if (0 == strcmp(param, "QSO_DETAILS")) {
if ('Y'==value[0] || 'y'==value[0])
key = "TO_RPTR_PORT_";
key += i + 'A';
pit = param.find(key);
TO_RPTR_PORT[i] = (param.end() == pit) ? 19998+i : atoi(pit->second.c_str());
traceit("%s=[%d]\n", key.c_str(), TO_RPTR_PORT[i]);
}
pit = param.find("QSO_DETAILS");
if (param.end() == pit)
QSO_DETAILS = true;
else
QSO_DETAILS = false;
QSO_DETAILS = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("QSO_DETAILS=[%s]\n", QSO_DETAILS ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "IRC_DEBUG")) {
if ('Y'==value[0] || 'y'==value[0])
IRC_DEBUG = true;
else
pit = param.find("IRC_DEBUG");
if (param.end() == pit)
IRC_DEBUG = false;
else
IRC_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("IRC_DEBUG=[%s]\n", IRC_DEBUG ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "DTMF_DEBUG")) {
if ('Y'==value[0] || 'y'==value[0])
DTMF_DEBUG = true;
else
pit = param.find("DTMF_DEBUG");
if (param.end() == pit)
DTMF_DEBUG = false;
else
DTMF_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("DTMF_DEBUG=[%s]\n", DTMF_DEBUG ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param,"REGEN_HDR")) {
if ('Y'==value[0] || 'y'==value[0])
REGEN_HDR = true;
else
pit = param.find("REGEN_HDR");
if (param.end() == pit)
REGEN_HDR = false;
else
REGEN_HDR = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("REGEN_HDR=[%s]\n", REGEN_HDR ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "SEND_APRS")) {
if ('Y'==value[0] || 'y'==value[0])
pit = param.find("SEND_APRS");
if (param.end() == pit)
SEND_APRS = true;
else
SEND_APRS = false;
SEND_APRS = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("SEND_APRS=[%s]\n", SEND_APRS ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "ECHOTEST_DIR")) {
strncpy(ECHOTEST_DIR, value, FILENAME_MAX);
ECHOTEST_DIR[FILENAME_MAX] = zero;
pit = param.find("ECHOTEST_DIR");
if (param.end() == pit)
strcpy(ECHOTEST_DIR, "/tmp");
else {
if (pit->second.length() > FILENAME_MAX) {
traceit("ECHOTEST_DIR definition is too long!\n");
return 1;
} else
strcpy(ECHOTEST_DIR, pit->second.c_str());
}
traceit("ECHOTEST_DIR=[%s]\n", ECHOTEST_DIR);
params ++;
} else if (0 == strcmp(param, "PLAY_WAIT")) {
PLAY_WAIT = atoi(value);
if ((PLAY_WAIT > 10) || (PLAY_WAIT < 1))
PLAY_WAIT = 1;
pit = param.find("PLAY_WAIT");
PLAY_WAIT = (param.end() == pit) ? 2 : atoi(pit->second.c_str());
if (PLAY_WAIT>10 || PLAY_WAIT<1)
PLAY_WAIT = 2;
traceit("PLAY_WAIT=[%d]\n", PLAY_WAIT);
params ++;
} else if (0 == strcmp(param, "PLAY_DELAY")) {
PLAY_DELAY = atoi(value);
if ((PLAY_DELAY > 50) || (PLAY_DELAY < 10))
PLAY_DELAY = 20;
pit = param.find("PLAY_DELAY");
PLAY_DELAY = (param.end() == pit) ? 10 : atoi(pit->second.c_str());
if (PLAY_DELAY>50 || PLAY_DELAY<10)
PLAY_DELAY = 19;
traceit("PLAY_DELAY=[%d]\n", PLAY_DELAY);
params ++;
} else if (0 == strcmp(param, "ECHOTEST_REC_TIMEOUT")) {
ECHOTEST_REC_TIMEOUT = atoi(value);
pit = param.find("ECHOTEST_REC_TIMEOUT");
ECHOTEST_REC_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str());
if (1 > ECHOTEST_REC_TIMEOUT)
ECHOTEST_REC_TIMEOUT = 1;
traceit("ECHOTEST_REC_TIMEOUT=[%d]\n", ECHOTEST_REC_TIMEOUT);
params ++;
} else if (0 == strcmp(param, "VOICEMAIL_REC_TIMEOUT")) {
VOICEMAIL_REC_TIMEOUT = atoi(value);
pit = param.find("VOICEMAIL_REC_TIMEOUT");
VOICEMAIL_REC_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str());
if (1 > VOICEMAIL_REC_TIMEOUT)
VOICEMAIL_REC_TIMEOUT = 1;
traceit("VOICEMAIL_REC_TIMEOUT=[%d]\n", VOICEMAIL_REC_TIMEOUT);
params ++;
} else if (0 == strcmp(param, "FROM_REMOTE_G2_TIMEOUT")) {
FROM_REMOTE_G2_TIMEOUT = atoi(value);
pit = param.find("FROM_REMOTE_G2_TIMEOUT");
FROM_REMOTE_G2_TIMEOUT = (param.end() == pit) ? 2 : atoi(pit->second.c_str());
if (1 > FROM_REMOTE_G2_TIMEOUT)
FROM_REMOTE_G2_TIMEOUT = 2;
traceit("FROM_REMOTE_G2_TIMEOUT=[%d]\n", FROM_REMOTE_G2_TIMEOUT);
params ++;
} else if (0 == strcmp(param, "FROM_LOCAL_RPTR_TIMEOUT")) {
FROM_LOCAL_RPTR_TIMEOUT = atoi(value);
pit = param.find("FROM_LOCAL_RPTR_TIMEOUT");
FROM_LOCAL_RPTR_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str());
if (1 > FROM_LOCAL_RPTR_TIMEOUT)
FROM_LOCAL_RPTR_TIMEOUT = 1;
traceit("FROM_LOCAL_RPTR_TIMEOUT=[%d]\n", FROM_LOCAL_RPTR_TIMEOUT);
params ++;
} else if (0 == strcmp(param, "IRC_DDB_HOST")) {
if (strlen(value) < 7)
traceit("IRC_DDB_HOST value [%s] invalid\n", value);
pit = param.find("IRC_DDB_HOST");
if (param.end() == pit)
strcpy(IRC_DDB_HOST, "rr.openquad.net");
else {
if (pit->second.length() < 511)
strcpy(IRC_DDB_HOST, pit->second.c_str());
else {
strncpy(IRC_DDB_HOST, value, 512);
IRC_DDB_HOST[512] = zero;
traceit("IRC_DDB_HOST=[%s]\n", IRC_DDB_HOST);
params ++;
traceit("IRC_DDB_HOST definition is too long\n");
return 1;
}
}
} else if (0 == strcmp(param, "IRC_DDB_PORT")) {
IRC_DDB_PORT = atoi(value);
pit = param.find("IRC_DDB_PORT");
IRC_DDB_PORT = (param.end() == pit) ? 9007 : atoi(pit->second.c_str());
if (IRC_DDB_PORT < 1)
IRC_DDB_PORT = 9007;
traceit("IRC_DDB_PORT=[%d]\n",IRC_DDB_PORT);
params ++;
} else if (0 == strcmp(param, "IRC_PASS")) {
strncpy(IRC_PASS, value, 512);
IRC_PASS[511] = zero;
params ++;
} else if (0 == strcmp(param,"DTMF_DIR")) {
strncpy(DTMF_DIR, value, FILENAME_MAX);
DTMF_DIR[FILENAME_MAX] = zero;
traceit("DTMF_DIR=[%s]\n", DTMF_DIR);
params ++;
} else {
traceit("UNKNOWN: %s = %s\n", param, value);
pit = param.find("IRC_PASS");
if (param.end() == pit)
strcpy(IRC_PASS, "1111111111111111");
else {
if (pit->second.length() > 511) {
traceit("IRC_PASS is too long!\n");
return 1;
}
strcpy(IRC_PASS, pit->second.c_str());
}
fclose(cnf);
if (params != valid_params) {
traceit("Configuration file %s invalid, only found %d of %d parameters\n",cfgFile, params, valid_params);
pit = param.find("DTMF_DIR");
if (param.end() == pit)
strcpy(DTMF_DIR, "/tmp");
else {
if (pit->second.length() < FILENAME_MAX)
strcpy(DTMF_DIR, pit->second.c_str());
else {
traceit("DTMF_DIR definition is too long!\n");
return 1;
}
}
traceit("DTMF_DIR=[%s]\n", DTMF_DIR);
return 0;
}

@ -1,4 +1,4 @@
// version strings must be 55 characters or less!
#define IRCDDB_VERSION "linux-g2_ircddb-4.0.0"
#define IRCDDB_VERSION "linux-g2_ircddb-4.1.0"
#define DVAP_VERSION "linux-dvap_rptr-3.0.0"
#define DVRPTR_VERSION "linux-dvrptr-2.0.0"

Loading…
Cancel
Save

Powered by TurnKey Linux.