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 # Your G2 Gateway callsign can be up to 6 characters
# This will also be used to connect to the remote ircDDB server # 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 = 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 # 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... # 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. # 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. # 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 # Example for a 2m DVRPTR connected to an antenna 10 meters above ground level with a range of 10 miles
# (Yes, if you use good cable connected to an outside antenna, your dvap can go a mile! I've done it.) # RPTR_C = 1 | 146.5 | 0 | 16093.44 | 10 | 42.0000 | -73.0000 | Mytown, MyState | MyCountry or MyGridSquare | github.com/ac2ie/g2_ircddb
# RPTR_C = 0 | 146.5 | 0 | 1609.344 | 10 | 42.0000 | -73.0000 | Mytown, MyState | MyGrid | github.com/ac2ie/g2_ircddb # YOU MUST DEFINE AT LEAST ONE REPEATER!
RPTR_A =
RPTR_B = #RPTR_A = 1 | | | | | | | | | github.com/ac2ie/g2_ircddb
RPTR_C = #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 # Which local address on your Linux box will be used
# to report to the remote IRC database server(group2, group1,...) # 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 # 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 # that is assigned to that specific ethernet card
# If you have one ethernet card, you can use 0.0.0.0 # 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 # You should NOT change the value for APRS_HOST
# Leave it set to: rotate.aprs.net # Leave it set to: rotate.aprs.net
# The only time to change it is when you have your own APRS_HOST server # 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 # 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 # How often to report the aprs beacon, in minutes, Do NOT make it less than 40
APRS_INTERVAL = 40 #APRS_INTERVAL = 40
APRS_FILTER= #APRS_FILTER=
# The G2 external port of this Gateway server # The G2 external port of this Gateway server
# Remote gateways will route data here # 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 # The G2 internal port of this Gateway server
# Our local repeater modules will send data here # Our local repeater modules will send data here
G2_INTERNAL_IP = 0.0.0.0
G2_INTERNAL_PORT = 19000
# Where is the g2_link running ? #G2_INTERNAL_IP = 0.0.0.0
TO_G2_LINK_IP = 127.0.0.1 #G2_INTERNAL_PORT = 19000
TO_G2_LINK_PORT = 18997
# Where is the g2_link running?
#TO_G2_LINK_IP = 127.0.0.1
#TO_G2_LINK_PORT = 18997
# The repeater modules of this repeater # The repeater modules of this repeater
TO_RPTR_IP_A = 127.0.0.1 #TO_RPTR_IP_A = 127.0.0.1
TO_RPTR_PORT_A = 19998 #TO_RPTR_PORT_A = 19998
TO_RPTR_IP_B = 127.0.0.1 #TO_RPTR_IP_B = 127.0.0.1
TO_RPTR_PORT_B = 19999 #TO_RPTR_PORT_B = 19999
TO_RPTR_IP_C = 127.0.0.1 #TO_RPTR_IP_C = 127.0.0.1
TO_RPTR_PORT_C = 20000 #TO_RPTR_PORT_C = 20000
# Timeouts in seconds # Timeouts in seconds
# We need these timeouts because the END-OF-AUDIO packet can get lost. # 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: # Echotest-recording timeout:
# If after 1 second, audio stops coming in for echotest-recording, # If after 1 second, audio stops coming in for echotest-recording,
# we will stop recording for ECHOTEST # we will stop recording for ECHOTEST
ECHOTEST_REC_TIMEOUT = 1
#ECHOTEST_REC_TIMEOUT = 1
# Voicemail-recording timeout: # Voicemail-recording timeout:
# If after 1 second, audio stops coming in for voicemail-recording, # If after 1 second, audio stops coming in for voicemail-recording,
# we will stop recording for voicemail # 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, # If after 2 seconds, we do not receive any more packets from remote system,
# we will assume that the remote QSO has stopped # 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 # 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. # 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 # print QSO details
QSO_DETAILS = Y
#QSO_DETAILS = Y
# These 2 options limit the lines in the log. # These 2 options limit the lines in the log.
# For production systems, we recommend: IRC_DEBUG=N # 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 # Do you want to re-generate the HEADER if there is a timeout from
# messages arriving from remote systems(reflectors, gateways, ...) # messages arriving from remote systems(reflectors, gateways, ...)
REGEN_HDR = Y
#REGEN_HDR = Y
# LINK STATUS file # LINK STATUS file
# This file is created by g2_link # This file is created by g2_link
# This gateway will ONLY read that status file # This gateway will ONLY read that status file
# to determine if any module is linked to anything # 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 # 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. # How many SECONDS to wait before starting to playback the recorded file.
# 1 second is enough, some repeaters require 2 seconds to re-initialize # 1 second is enough, some repeaters require 2 seconds to re-initialize
# before they accept new streams again. # 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 # How many MILLIseconds to delay when playing back each of the recorded packets
# Normal VoIP is 20 milliseconds or a little less # 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 # The remote ircDDB database
# For US, Canada and North America # For US, Canada and North America
# IRC_DDB_HOST=group2-irc.ircddb.net # IRC_DDB_HOST=group2-irc.ircddb.net
@ -153,11 +178,15 @@ IRC_DDB_HOST = rr.openquad.net
# IRC_DDB_HOST=group1-irc.ircddb.net # IRC_DDB_HOST=group1-irc.ircddb.net
# For registration free routing, use OpenQuad's round-robin, rr.openquad.net # For registration free routing, use OpenQuad's round-robin, rr.openquad.net
#IRC_DDB_HOST = rr.openquad.net
# The remote ircDDB port # The remote ircDDB port
IRC_DDB_PORT = 9007
#IRC_DDB_PORT = 9007
# Your ircDDB password given to you by the German ircDDB team. # Your ircDDB password given to you by the German ircDDB team.
# Put your correct password here. # Put your correct password here.
# you will only need this with a club call using group1-irc # 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 <regex.h>
#include <string> #include <string>
#include <map>
#include <utility> #include <utility>
using namespace std; using namespace std;
@ -546,409 +547,442 @@ static char *trim(char *s)
// remove trailing whitespace // remove trailing whitespace
while (strlen(s) && isspace(s[strlen(s)-1])) while (strlen(s) && isspace(s[strlen(s)-1]))
s[strlen(s)-1] = (char)NULL; s[strlen(s)-1] = (char)NULL;
// count leading whitespace // move s to first non-space char
int i = 0; while (isspace(*s))
while (isspace(s[i])) s++;
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);
}
} }
// the returned value doesn't have to be used. s didn't change!
return s; 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 */ /* process configuration file */
static int read_config(char *cfgFile) static int read_config(char *cfgFile)
{ {
short int valid_params = 39;
short int params = 0;
unsigned short i; unsigned short i;
FILE *cnf = NULL;
char aline[1024];
char *tok = NULL; char *tok = NULL;
const char *Tstr = "TRUE"; const char *Tstr = "TRUE";
const char *Fstr = "FALSE"; const char *Fstr = "FALSE";
char zero = (char)NULL; char zero = (char)NULL;
cnf = fopen(cfgFile, "r"); map<string, string> param;
if (!cnf) {
traceit("Failed to open file %s\n", cfgFile);
return 1;
}
traceit("Reading file %s\n", cfgFile); traceit("Reading file %s\n", cfgFile);
while (fgets(aline, 1024, cnf) != NULL) { if (! parse_config(cfgFile, param))
(void)trim(aline); return 1;
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")) { map<string, string>::iterator pit = param.find("OWNER");
if (3>strlen(value) || CALL_SIZE-2<strlen(value)) if (param.end() == pit) {
traceit("OWNER value '%s' invalid\n", value); traceit("OWNER not defined!\n");
else { return 1;
strcpy(OWNER, value); }
strcpy(owner, value); if (pit->second.length()<3 || pit->second.length() > CALL_SIZE-2) {
traceit("OWNER value '%s' invalid\n", pit->second.c_str());
for (i=0; i < strlen(OWNER); i++) { return 1;
if (isupper(owner[i])) }
owner[i] = tolower(owner[i]); strcpy(OWNER, pit->second.c_str());
if (islower(OWNER[i])) strcpy(owner, pit->second.c_str());
OWNER[i] = toupper(OWNER[i]); for (i=0; i<strlen(OWNER); i++) {
} if (isupper(owner[i]))
traceit("OWNER=[%s]\n", OWNER); OWNER[i] = toupper(OWNER[i]);
while (CALL_SIZE > strlen(OWNER)) else
strcat(OWNER, " "); owner[i] = tolower(owner[i]);
params ++; }
} traceit("OWNER=[%s]\n", OWNER);
while (strlen(OWNER) < CALL_SIZE)
} else if (0 == strcmp(param, "STATUS_FILE")) { strcat(OWNER, " ");
strncpy(STATUS_FILE, value ,FILENAME_MAX);
STATUS_FILE[FILENAME_MAX] = zero; for (short int m=0; m<3; m++) {
traceit("STATUS_FILE=[%s]\n",STATUS_FILE); string key = "RPTR_";
params ++; key += m + 'A';
pit = param.find(key);
} else if (0 == strcmp(param, "LOCAL_IRC_IP")) { if (param.end() == pit)
if (strlen(value) < 7) rptr.mod[m].defined = false;
traceit("LOCAL_IRC_IP value [%s] invalid\n", value); else {
else { rptr.mod[m].defined = true;
strncpy(LOCAL_IRC_IP, value, IP_SIZE); char value[128];
LOCAL_IRC_IP[IP_SIZE] = zero; strncpy(value, param[key].c_str(), 128);
traceit("LOCAL_IRC_IP=[%s]\n", LOCAL_IRC_IP); value[127] = zero;
params ++; for (i=0; i<10; i++) {
} tok = strtok(i?NULL:value, "|");
switch (i) {
} else if (0 == strcmp(param,"SEND_QRGS_MAPS")) { case 0:
if ('Y'==value[0] || 'y'==value[0]) (void)trim(tok);
SEND_QRGS_MAPS = true; switch (tok[0]) {
else case '0':
SEND_QRGS_MAPS = false; strcpy(rptr.mod[m].package_version, DVAP_VERSION);
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) {
for (i=0; i<10; i++) {
tok = strtok(i?NULL:value, "|");
switch (i) {
case 0:
(void)trim(tok);
switch (tok[0]) {
case '0':
strcpy(rptr.mod[m].package_version, DVAP_VERSION);
break;
case '1':
strcpy(rptr.mod[m].package_version, DVRPTR_VERSION);
break;
default:
rptr.mod[m].package_version[0] = zero;
break;
}
break;
case 1:
rptr.mod[m].frequency = tok ? atof(tok) : 0.0;
break;
case 2:
rptr.mod[m].offset = tok ? atof(tok) : 0.0;
break;
case 3:
rptr.mod[m].range = tok ? atof(tok) : 0.0;
break;
case 4:
rptr.mod[m].agl = tok ? atof(tok) : 0.0;
break;
case 5:
rptr.mod[m].latitude = tok ? atof(tok) : 0.0;
break;
case 6:
rptr.mod[m].longitude = tok ? atof(tok) : 0.0;
break;
case 7:
if (tok)
strncpy(rptr.mod[m].desc1, trim(tok), 20);
rptr.mod[m].desc1[tok ? 20 : 0] = zero;
break; break;
case 8: case '1':
if (tok) strcpy(rptr.mod[m].package_version, DVRPTR_VERSION);
strncpy(rptr.mod[m].desc2, trim(tok), 20);
rptr.mod[m].desc2[tok ? 20 : 0] = zero;
break; break;
case 9: default:
if (tok) { traceit("%s type %s not defined!\n", key.c_str(), tok);
char *instr = strstr(tok, "//"); return 1;
if (instr) {
char *p = tok;
while (p < instr+2)
*p++ = ' ';
}
(void)trim(tok);
strncpy(rptr.mod[m].url, tok, 64);
}
rptr.mod[m].url[tok ? 64 : 0] = zero;
} }
} break;
if (strlen(rptr.mod[m].package_version)) { case 1:
params++; rptr.mod[m].frequency = tok ? atof(tok) : 0.0;
break;
// make the long description case 2:
strcpy(rptr.mod[m].desc, rptr.mod[m].desc1); rptr.mod[m].offset = tok ? atof(tok) : 0.0;
if (strlen(rptr.mod[m].desc2)) { break;
strcat(rptr.mod[m].desc, "%s "); case 3:
strcat(rptr.mod[m].desc, rptr.mod[m].desc2); rptr.mod[m].range = tok ? atof(tok) : 0.0;
break;
case 4:
rptr.mod[m].agl = tok ? atof(tok) : 0.0;
break;
case 5:
rptr.mod[m].latitude = tok ? atof(tok) : 0.0;
break;
case 6:
rptr.mod[m].longitude = tok ? atof(tok) : 0.0;
break;
case 7:
if (tok)
strncpy(rptr.mod[m].desc1, trim(tok), 20);
rptr.mod[m].desc1[tok ? 20 : 0] = zero;
break;
case 8:
if (tok)
strncpy(rptr.mod[m].desc2, trim(tok), 20);
rptr.mod[m].desc2[tok ? 20 : 0] = zero;
break;
case 9:
if (tok) {
char *instr = strstr(tok, "//");
if (instr) {
char *p = tok;
while (p < instr+2)
*p++ = ' ';
}
(void)trim(tok);
strncpy(rptr.mod[m].url, tok, 64);
} }
traceit("Mod%c:\n", cm); rptr.mod[m].url[tok ? 64 : 0] = zero;
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);
traceit("\trange =%lg\n", rptr.mod[m].range);
traceit("\tagl =%lg\n", rptr.mod[m].agl);
traceit("\tlatitude =%lg\n", rptr.mod[m].latitude);
traceit("\tlongitude=%lg\n", rptr.mod[m].longitude);
traceit("\tdesc1 =%s\n", rptr.mod[m].desc1);
traceit("\tdesc2 =%s\n", rptr.mod[m].desc2);
traceit("\turl =%s\n", rptr.mod[m].url);
} else
traceit("RPTR_%c Type not defined\n", cm);
} else
params++; // empty value for RPTR_X
} else
traceit("RPTR_ID_%c? must be A, B or C\n", cm);
} else if (0 == strcmp(param, "G2_EXTERNAL_IP")) {
if (strlen(value) < 7)
traceit("G2_EXTERNAL_IP value [%s] invalid\n", value);
else {
strncpy(G2_EXTERNAL_IP, value, IP_SIZE);
G2_EXTERNAL_IP[IP_SIZE] = zero;
traceit("G2_EXTERNAL_IP=[%s]\n", G2_EXTERNAL_IP);
params ++;
} }
// make the long description
} else if (0 == strcmp(param, "G2_EXTERNAL_PORT")) { strcpy(rptr.mod[m].desc, rptr.mod[m].desc1);
G2_EXTERNAL_PORT = atoi(value); if (strlen(rptr.mod[m].desc2)) {
traceit("G2_EXTERNAL_PORT=[%d]\n", G2_EXTERNAL_PORT); if (strlen(rptr.mod[m].desc))
params ++; strcat(rptr.mod[m].desc, " ");
strcat(rptr.mod[m].desc, rptr.mod[m].desc2);
} else if (0 == strcmp(param, "G2_INTERNAL_IP")) {
if (strlen(value) < 7)
traceit("G2_INTERNAL_IP value [%s] invalid\n", value);
else {
strncpy(G2_INTERNAL_IP, value, IP_SIZE);
G2_INTERNAL_IP[IP_SIZE] = zero;
traceit("G2_INTERNAL_IP=[%s]\n", G2_INTERNAL_IP);
params ++;
} }
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);
traceit("\trange =%lg\n", rptr.mod[m].range);
traceit("\tagl =%lg\n", rptr.mod[m].agl);
traceit("\tlatitude =%lg\n", rptr.mod[m].latitude);
traceit("\tlongitude=%lg\n", rptr.mod[m].longitude);
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;
}
} else if (0 == strcmp(param, "G2_INTERNAL_PORT")) { pit = param.find("STATUS_FILE");
G2_INTERNAL_PORT = atoi(value); if (param.end() == pit)
traceit("G2_INTERNAL_PORT=[%d]\n", G2_INTERNAL_PORT); strcpy(STATUS_FILE, "/usr/local/etc/RPT_STATUS.txt");
params ++; else {
strncpy(STATUS_FILE, pit->second.c_str() ,FILENAME_MAX);
} else if (0 == strcmp(param, "TO_G2_LINK_IP")) { STATUS_FILE[FILENAME_MAX] = zero;
if (strlen(value) < 7) }
traceit("TO_G2_LINK_IP value [%s] invalid\n", value); traceit("STATUS_FILE=[%s]\n", STATUS_FILE);
else {
strncpy(TO_G2_LINK_IP, value, IP_SIZE); pit = param.find("LOCAL_IRC_IP");
TO_G2_LINK_IP[IP_SIZE] = zero; if (param.end() == pit)
traceit("TO_G2_LINK_IP=[%s]\n", TO_G2_LINK_IP); strcpy(LOCAL_IRC_IP, "0.0.0.0");
params ++; 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
strcpy(LOCAL_IRC_IP, pit->second.c_str());
}
traceit("LOCAL_IRC_IP=[%s]\n", LOCAL_IRC_IP);
} else if (0 == strcmp(param, "TO_G2_LINK_PORT")) { pit = param.find("SEND_QRGS_MAPS");
TO_G2_LINK_PORT = atoi(value); if (param.end() == pit)
traceit("TO_G2_LINK_PORT=[%d]\n", TO_G2_LINK_PORT); SEND_QRGS_MAPS = true;
params ++; else
SEND_QRGS_MAPS = ('Y'==toupper(pit->second.at(0))) ? true : false;
} else if (0 == strncmp(param, "TO_RPTR_IP_", 11)) { traceit("SEND_QRGS_MAPS=[%s]\n", SEND_QRGS_MAPS ? Tstr : Fstr);
char cm = param[11];
int m = cm - 'A'; pit = param.find("APRS_HOST");
if (0<=m && m<3) { if (param.end() == pit)
if (strlen(value) < 7) strcpy(rptr.aprs_host, "rotate.aprs.net");
traceit("TO_RPTR_IP_$c value [%s] invalid\n", cm, value); else {
else { if (pit->second.length() > MAXHOSTNAMELEN) {
strncpy(TO_RPTR_IP[m], value, IP_SIZE); traceit("APRS_HOST definition is too long\n");
TO_RPTR_IP[m][IP_SIZE] = '\0'; return 1;
traceit("TO_RPTR_IP_%c=[%s]\n", cm, TO_RPTR_IP[m]); } else
params ++; strcpy(rptr.aprs_host, pit->second.c_str());
} rptr.aprs_host[MAXHOSTNAMELEN] = zero;
} else }
traceit("TO_RPTR_IP_%c is invalid\n", cm); traceit("APRS_HOST=[%s]\n", rptr.aprs_host);
} else if (0 == strncmp(param, "TO_RPTR_PORT_", 13)) { pit = param.find("APRS_PORT");
char cm = param[13]; rptr.aprs_port = (param.end()==pit) ? 14580 : atoi(pit->second.c_str());
int m = cm - 'A'; traceit("APRS_PORT=[%d]\n", rptr.aprs_port);
if (0<=m && m<3) {
TO_RPTR_PORT[m] = atoi(value); pit = param.find("APRS_INTERVAL");
traceit("TO_RPTR_PORT_%c=[%d]\n", cm, TO_RPTR_PORT[m]); rptr.aprs_interval = (param.end()==pit) ? 40 : atoi(pit->second.c_str());
params ++; 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
rptr.aprs_filter[0] = zero;
traceit("APRS_filter=[%s]\n", rptr.aprs_filter);
pit = param.find("G2_EXTERNAL_IP");
if (param.end() == pit)
strcpy(G2_EXTERNAL_IP, "0.0.0.0");
else {
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);
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);
pit = param.find("G2_INTERNAL_IP");
if (param.end() == pit)
strcpy(G2_INTERNAL_IP, "0.0.0.0");
else {
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);
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);
pit = param.find("TO_G2_LINK_IP");
if (param.end() == pit)
strcpy(TO_G2_LINK_IP, "127.0.0.1");
else {
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);
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);
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 {
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 } 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")) { key = "TO_RPTR_PORT_";
if ('Y'==value[0] || 'y'==value[0]) key += i + 'A';
QSO_DETAILS = true; pit = param.find(key);
else TO_RPTR_PORT[i] = (param.end() == pit) ? 19998+i : atoi(pit->second.c_str());
QSO_DETAILS = false; traceit("%s=[%d]\n", key.c_str(), TO_RPTR_PORT[i]);
traceit("QSO_DETAILS=[%s]\n", QSO_DETAILS ? Tstr : Fstr); }
params ++;
} else if (0 == strcmp(param, "IRC_DEBUG")) { pit = param.find("QSO_DETAILS");
if ('Y'==value[0] || 'y'==value[0]) if (param.end() == pit)
IRC_DEBUG = true; QSO_DETAILS = true;
else else
IRC_DEBUG = false; QSO_DETAILS = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("IRC_DEBUG=[%s]\n", IRC_DEBUG ? Tstr : Fstr); traceit("QSO_DETAILS=[%s]\n", QSO_DETAILS ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "DTMF_DEBUG")) { pit = param.find("IRC_DEBUG");
if ('Y'==value[0] || 'y'==value[0]) if (param.end() == pit)
DTMF_DEBUG = true; IRC_DEBUG = false;
else else
DTMF_DEBUG = false; IRC_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("DTMF_DEBUG=[%s]\n", DTMF_DEBUG ? Tstr : Fstr); traceit("IRC_DEBUG=[%s]\n", IRC_DEBUG ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param,"REGEN_HDR")) { pit = param.find("DTMF_DEBUG");
if ('Y'==value[0] || 'y'==value[0]) if (param.end() == pit)
REGEN_HDR = true; DTMF_DEBUG = false;
else else
REGEN_HDR = false; DTMF_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("REGEN_HDR=[%s]\n", REGEN_HDR ? Tstr : Fstr); traceit("DTMF_DEBUG=[%s]\n", DTMF_DEBUG ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "SEND_APRS")) { pit = param.find("REGEN_HDR");
if ('Y'==value[0] || 'y'==value[0]) if (param.end() == pit)
SEND_APRS = true; REGEN_HDR = false;
else else
SEND_APRS = false; REGEN_HDR = ('Y' == toupper(pit->second.at(0))) ? true : false;
traceit("SEND_APRS=[%s]\n", SEND_APRS ? Tstr : Fstr); traceit("REGEN_HDR=[%s]\n", REGEN_HDR ? Tstr : Fstr);
params ++;
} else if (0 == strcmp(param, "ECHOTEST_DIR")) {
strncpy(ECHOTEST_DIR, value, FILENAME_MAX);
ECHOTEST_DIR[FILENAME_MAX] = zero;
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;
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;
traceit("PLAY_DELAY=[%d]\n", PLAY_DELAY);
params ++;
} else if (0 == strcmp(param, "ECHOTEST_REC_TIMEOUT")) {
ECHOTEST_REC_TIMEOUT = atoi(value);
traceit("ECHOTEST_REC_TIMEOUT=[%d]\n", ECHOTEST_REC_TIMEOUT);
params ++;
} else if (0 == strcmp(param, "VOICEMAIL_REC_TIMEOUT")) {
VOICEMAIL_REC_TIMEOUT = atoi(value);
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);
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);
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);
else {
strncpy(IRC_DDB_HOST, value, 512);
IRC_DDB_HOST[512] = zero;
traceit("IRC_DDB_HOST=[%s]\n", IRC_DDB_HOST);
params ++;
}
} else if (0 == strcmp(param, "IRC_DDB_PORT")) { pit = param.find("SEND_APRS");
IRC_DDB_PORT = atoi(value); if (param.end() == pit)
traceit("IRC_DDB_PORT=[%d]\n",IRC_DDB_PORT); SEND_APRS = true;
params ++; else
SEND_APRS = ('Y' == toupper(pit->second.at(0))) ? true : false;
} else if (0 == strcmp(param, "IRC_PASS")) { traceit("SEND_APRS=[%s]\n", SEND_APRS ? Tstr : Fstr);
strncpy(IRC_PASS, value, 512);
IRC_PASS[511] = zero; pit = param.find("ECHOTEST_DIR");
params ++; if (param.end() == pit)
strcpy(ECHOTEST_DIR, "/tmp");
} else if (0 == strcmp(param,"DTMF_DIR")) { else {
strncpy(DTMF_DIR, value, FILENAME_MAX); if (pit->second.length() > FILENAME_MAX) {
DTMF_DIR[FILENAME_MAX] = zero; traceit("ECHOTEST_DIR definition is too long!\n");
traceit("DTMF_DIR=[%s]\n", DTMF_DIR); return 1;
params ++; } else
strcpy(ECHOTEST_DIR, pit->second.c_str());
}
traceit("ECHOTEST_DIR=[%s]\n", ECHOTEST_DIR);
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);
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);
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);
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);
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);
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);
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 {
traceit("IRC_DDB_HOST definition is too long\n");
return 1;
}
}
} else { pit = param.find("IRC_DDB_PORT");
traceit("UNKNOWN: %s = %s\n", param, value); 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);
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) { pit = param.find("DTMF_DIR");
traceit("Configuration file %s invalid, only found %d of %d parameters\n",cfgFile, params, valid_params); if (param.end() == pit)
return 1; 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; return 0;
} }

@ -1,4 +1,4 @@
// version strings must be 55 characters or less! // 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 DVAP_VERSION "linux-dvap_rptr-3.0.0"
#define DVRPTR_VERSION "linux-dvrptr-2.0.0" #define DVRPTR_VERSION "linux-dvrptr-2.0.0"

Loading…
Cancel
Save

Powered by TurnKey Linux.