read messages before starting main loop, allow readonly combined with scanconfig for listening to other units doing the scan
This commit is contained in:
+12
-15
@@ -261,11 +261,11 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
opt->noDeviceCheck = true;
|
opt->noDeviceCheck = true;
|
||||||
break;
|
break;
|
||||||
case 'r': // --readonly
|
case 'r': // --readonly
|
||||||
opt->readOnly = true;
|
if (opt->answer || opt->generateSyn) {
|
||||||
if (opt->scanConfig || opt->answer || opt->generateSyn) {
|
argp_error(state, "cannot combine readonly with answer/generatesyn");
|
||||||
argp_error(state, "cannot combine readonly with scanconfig/answer/generatesyn");
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
opt->readOnly = true;
|
||||||
break;
|
break;
|
||||||
case O_INISND: // --initsend
|
case O_INISND: // --initsend
|
||||||
opt->initialSend = true;
|
opt->initialSend = true;
|
||||||
@@ -288,10 +288,6 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
break;
|
break;
|
||||||
case 's': // --scanconfig[=ADDR] (ADDR=<empty>|full|<hexaddr>)
|
case 's': // --scanconfig[=ADDR] (ADDR=<empty>|full|<hexaddr>)
|
||||||
opt->scanConfig = true;
|
opt->scanConfig = true;
|
||||||
if (opt->readOnly) {
|
|
||||||
argp_error(state, "cannot combine readonly with scanconfig/answer/generatesyn");
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
if (opt->pollInterval == 0) {
|
if (opt->pollInterval == 0) {
|
||||||
argp_error(state, "scanconfig without polling may lead to invalid files included for certain products!");
|
argp_error(state, "scanconfig without polling may lead to invalid files included for certain products!");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@@ -344,11 +340,11 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case O_ANSWER: // --answer
|
case O_ANSWER: // --answer
|
||||||
opt->answer = true;
|
|
||||||
if (opt->readOnly) {
|
if (opt->readOnly) {
|
||||||
argp_error(state, "cannot combine readonly with scanconfig/answer/generatesyn");
|
argp_error(state, "cannot combine readonly with answer/generatesyn");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
opt->answer = true;
|
||||||
break;
|
break;
|
||||||
case O_ACQTIM: // --acquiretimeout=9400
|
case O_ACQTIM: // --acquiretimeout=9400
|
||||||
opt->acquireTimeout = parseInt(arg, 10, 1000, 100000, result);
|
opt->acquireTimeout = parseInt(arg, 10, 1000, 100000, result);
|
||||||
@@ -386,11 +382,11 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case O_GENSYN: // --generatesyn
|
case O_GENSYN: // --generatesyn
|
||||||
opt->generateSyn = true;
|
|
||||||
if (opt->readOnly) {
|
if (opt->readOnly) {
|
||||||
argp_error(state, "cannot combine readonly with scanconfig/answer/generatesyn");
|
argp_error(state, "cannot combine readonly with answer/generatesyn");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
opt->generateSyn = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Daemon options:
|
// Daemon options:
|
||||||
@@ -1141,15 +1137,16 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
logNotice(lf_main, PACKAGE_STRING "." REVISION " started");
|
logNotice(lf_main, PACKAGE_STRING "." REVISION " started");
|
||||||
|
|
||||||
// create the MainLoop and start it
|
|
||||||
s_mainLoop = new MainLoop(opt, device, s_messageMap);
|
|
||||||
s_mainLoop->start("mainloop");
|
|
||||||
|
|
||||||
// load configuration files
|
// load configuration files
|
||||||
loadConfigFiles(s_messageMap);
|
loadConfigFiles(s_messageMap);
|
||||||
if (s_messageMap->sizeConditions() > 0 && opt.pollInterval == 0) {
|
if (s_messageMap->sizeConditions() > 0 && opt.pollInterval == 0) {
|
||||||
logError(lf_main, "conditions require a poll interval > 0");
|
logError(lf_main, "conditions require a poll interval > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create the MainLoop and start it
|
||||||
|
s_mainLoop = new MainLoop(opt, device, s_messageMap);
|
||||||
|
s_mainLoop->start("mainloop");
|
||||||
|
|
||||||
// wait for end of MainLoop
|
// wait for end of MainLoop
|
||||||
s_mainLoop->join();
|
s_mainLoop->join();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user