added conditional messages to find command with "-a" option and include condition prefix for CSV format

also allow passing scan messages with --checkconfig and --scanconfig (without --inject)
be more verbose on errors in configuration files
improved code style
This commit is contained in:
john30
2017-05-01 15:31:09 +02:00
parent 3d4d876d5e
commit 7b11a540b6
32 changed files with 1946 additions and 1949 deletions
+9 -9
View File
@@ -42,7 +42,7 @@ Device::~Device() {
close();
}
Device* Device::create(const char* name, const bool checkDevice, const bool readOnly, const bool initialSend) {
Device* Device::create(const char* name, bool checkDevice, bool readOnly, bool initialSend) {
if (strchr(name, '/') == NULL && strchr(name, ':') != NULL) {
char* in = strdup(name);
bool udp = false;
@@ -57,7 +57,7 @@ Device* Device::create(const char* name, const bool checkDevice, const bool read
return NULL; // invalid protocol or missing port
}
result_t result = RESULT_OK;
unsigned int port = parseInt(portpos+1, 10, 1, 65535, result);
unsigned int port = parseInt(portpos+1, 10, 1, 65535, &result);
if (result != RESULT_OK) {
free(in);
return NULL; // invalid port
@@ -98,7 +98,7 @@ bool Device::isValid() {
return m_fd != -1;
}
result_t Device::send(const symbol_t value) {
result_t Device::send(symbol_t value) {
if (!isValid()) {
return RESULT_ERR_DEVICE;
}
@@ -111,7 +111,7 @@ result_t Device::send(const symbol_t value) {
return RESULT_OK;
}
result_t Device::recv(const unsigned int timeout, symbol_t& value) {
result_t Device::recv(unsigned int timeout, symbol_t* value) {
if (!isValid()) {
return RESULT_ERR_DEVICE;
}
@@ -162,7 +162,7 @@ result_t Device::recv(const unsigned int timeout, symbol_t& value) {
return RESULT_ERR_DEVICE;
}
if (m_listener != NULL) {
m_listener->notifyDeviceData(value, true);
m_listener->notifyDeviceData(*value, true);
}
return RESULT_OK;
}
@@ -299,14 +299,14 @@ bool NetworkDevice::available() {
return m_buffer && m_bufLen > 0;
}
ssize_t NetworkDevice::write(const symbol_t value) {
ssize_t NetworkDevice::write(symbol_t value) {
m_bufLen = 0; // flush read buffer
return Device::write(value);
}
ssize_t NetworkDevice::read(symbol_t& value) {
ssize_t NetworkDevice::read(symbol_t* value) {
if (available()) {
value = m_buffer[m_bufPos];
*value = m_buffer[m_bufPos];
m_bufPos = (m_bufPos+1)%m_bufSize;
m_bufLen--;
return 1;
@@ -316,7 +316,7 @@ ssize_t NetworkDevice::read(symbol_t& value) {
if (size <= 0) {
return size;
}
value = m_buffer[0];
*value = m_buffer[0];
m_bufPos = 1;
m_bufLen = size-1;
return size;