|
|
|
@ -167,17 +167,40 @@ static bool read_config(const char *cfgFile)
|
|
|
|
const std::string estr; // an empty string
|
|
|
|
const std::string estr; // an empty string
|
|
|
|
std::string type;
|
|
|
|
std::string type;
|
|
|
|
std::string dvap_path("module_");
|
|
|
|
std::string dvap_path("module_");
|
|
|
|
|
|
|
|
if (0 > assigned_module) {
|
|
|
|
|
|
|
|
// we need to find the lone dvap module
|
|
|
|
|
|
|
|
for (int i=0; i<3; i++) {
|
|
|
|
|
|
|
|
std::string test(dvap_path);
|
|
|
|
|
|
|
|
test.append(1, 'a'+i);
|
|
|
|
|
|
|
|
if (cfg.KeyExists(test)) {
|
|
|
|
|
|
|
|
cfg.GetValue(test, estr, type, 1, 16);
|
|
|
|
|
|
|
|
if (type.compare("dvap")) {
|
|
|
|
|
|
|
|
fprintf(stderr, "%s = '%s', expecting 'dvap'!\n", test.c_str(), type.c_str());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dvap_path.assign(test);
|
|
|
|
|
|
|
|
assigned_module = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > assigned_module) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Error: no 'dvap' module found\n!");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// make sure dvap module is defined
|
|
|
|
dvap_path.append(1, 'a' + assigned_module);
|
|
|
|
dvap_path.append(1, 'a' + assigned_module);
|
|
|
|
if (cfg.KeyExists(dvap_path)) {
|
|
|
|
if (cfg.KeyExists(dvap_path)) {
|
|
|
|
cfg.GetValue(dvap_path, estr, type, 1, 16);
|
|
|
|
cfg.GetValue(dvap_path, estr, type, 1, 16);
|
|
|
|
if (type.compare("dvap")) {
|
|
|
|
if (type.compare("dvap")) {
|
|
|
|
fprintf(stderr, "assigned module '%c' type is not 'dvap'\n", 'a' + assigned_module);
|
|
|
|
fprintf(stderr, "%s = %s is not 'dvap' type!\n", dvap_path.c_str(), type.c_str());
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "%s is not defined!\n", dvap_path.c_str());
|
|
|
|
fprintf(stderr, "Module '%c' is not defined.\n", 'a'+assigned_module);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
RPTR_MOD = 'A' + assigned_module;
|
|
|
|
RPTR_MOD = 'A' + assigned_module;
|
|
|
|
cfg.GetValue(dvap_path+"_gate2modem"+std::to_string(assigned_module), type, gate2modem, 1, FILENAME_MAX);
|
|
|
|
cfg.GetValue(dvap_path+"_gate2modem"+std::to_string(assigned_module), type, gate2modem, 1, FILENAME_MAX);
|
|
|
|
cfg.GetValue(dvap_path+"_modem2gate"+std::to_string(assigned_module), type, modem2gate, 1, FILENAME_MAX);
|
|
|
|
cfg.GetValue(dvap_path+"_modem2gate"+std::to_string(assigned_module), type, modem2gate, 1, FILENAME_MAX);
|
|
|
|
@ -502,33 +525,44 @@ int main(int argc, const char **argv)
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
|
|
|
printf("dvap_rptr VERSION %s\n", VERSION);
|
|
|
|
printf("dvap_rptr VERSION %s\n", VERSION);
|
|
|
|
|
|
|
|
|
|
|
|
if (argc != 3) {
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "Usage: %s assigned_module dvap_rptr.cfg\n", argv[0]);
|
|
|
|
fprintf(stderr, "Usage: %s dvap_rptr.cfg\n", argv[0]);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ('-' == argv[1][0]) {
|
|
|
|
|
|
|
|
printf("\nQnetDVAP Version #%s Copyright (C) 2018-2019 by Thomas A. Early N7TAE\n", DVAP_VERSION);
|
|
|
|
|
|
|
|
printf("QnetDVAP comes with ABSOLUTELY NO WARRANTY; see the LICENSE for details.\n");
|
|
|
|
|
|
|
|
printf("This is free software, and you are welcome to distribute it\nunder certain conditions that are discussed in the LICENSE file.\n\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *qn = strstr(argv[0], "qndvap");
|
|
|
|
|
|
|
|
if (NULL == qn) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Error finding 'qndvap' in %s!\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qn += 6;
|
|
|
|
|
|
|
|
|
|
|
|
switch (argv[1][0]) {
|
|
|
|
switch (argv[1][0]) {
|
|
|
|
case '0':
|
|
|
|
case NULL:
|
|
|
|
|
|
|
|
assigned_module = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
case 'a':
|
|
|
|
case 'A':
|
|
|
|
|
|
|
|
assigned_module = 0;
|
|
|
|
assigned_module = 0;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
case 'b':
|
|
|
|
case 'B':
|
|
|
|
|
|
|
|
assigned_module = 1;
|
|
|
|
assigned_module = 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
|
|
|
|
assigned_module = 2;
|
|
|
|
assigned_module = 2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "ERROR: '%s' is not a valid module\nassigned module must be 0, a, A, 1, b, B, 2, c or C\n", argv[1]);
|
|
|
|
fprintf(stderr, "ERROR: '%s' is not a valid module\nassigned module must be a, b or c\n", argv[1]);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (read_config(argv[2])) {
|
|
|
|
if (read_config(argv[1])) {
|
|
|
|
printf("Failed to process config file %s\n", argv[2]);
|
|
|
|
printf("Failed to process config file %s\n", argv[2]);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|