code style
This commit is contained in:
+7
-6
@@ -193,8 +193,8 @@ static const struct argp_option argpoptions[] = {
|
|||||||
{"latency", O_DEVLAT, "MSEC", 0, "Extra transfer latency in ms [0]", 0 },
|
{"latency", O_DEVLAT, "MSEC", 0, "Extra transfer latency in ms [0]", 0 },
|
||||||
|
|
||||||
{nullptr, 0, nullptr, 0, "Message configuration options:", 2 },
|
{nullptr, 0, nullptr, 0, "Message configuration options:", 2 },
|
||||||
{"configpath", 'c', "PATH", 0, "Read CSV config files from PATH (local folder or HTTPS URL) [" CONFIG_PATH
|
{"configpath", 'c', "PATH", 0, "Read CSV config files from PATH (local folder or HTTPS URL) ["
|
||||||
"]", 0 },
|
CONFIG_PATH "]", 0 },
|
||||||
{"scanconfig", 's', "ADDR", OPTION_ARG_OPTIONAL, "Pick CSV config files matching initial scan (ADDR="
|
{"scanconfig", 's', "ADDR", OPTION_ARG_OPTIONAL, "Pick CSV config files matching initial scan (ADDR="
|
||||||
"\"none\" or empty for no initial scan message, \"full\" for full scan, or a single hex address to scan, "
|
"\"none\" or empty for no initial scan message, \"full\" for full scan, or a single hex address to scan, "
|
||||||
"default is broadcast ident message). If combined with --checkconfig, you can add scan message data as "
|
"default is broadcast ident message). If combined with --checkconfig, you can add scan message data as "
|
||||||
@@ -202,7 +202,8 @@ static const struct argp_option argpoptions[] = {
|
|||||||
{"configlang", O_CFGLNG, "LANG", 0,
|
{"configlang", O_CFGLNG, "LANG", 0,
|
||||||
"Prefer LANG in multilingual configuration files [system default language]", 0 },
|
"Prefer LANG in multilingual configuration files [system default language]", 0 },
|
||||||
{"checkconfig", O_CHKCFG, nullptr, 0, "Check config files, then stop", 0 },
|
{"checkconfig", O_CHKCFG, nullptr, 0, "Check config files, then stop", 0 },
|
||||||
{"dumpconfig", O_DMPCFG, "FORMAT", OPTION_ARG_OPTIONAL, "Check and dump config files in FORMAT (\"json\" or \"csv\"), then stop", 0 },
|
{"dumpconfig", O_DMPCFG, "FORMAT", OPTION_ARG_OPTIONAL,
|
||||||
|
"Check and dump config files in FORMAT (\"json\" or \"csv\"), then stop", 0 },
|
||||||
{"pollinterval", O_POLINT, "SEC", 0, "Poll for data every SEC seconds (0=disable) [5]", 0 },
|
{"pollinterval", O_POLINT, "SEC", 0, "Poll for data every SEC seconds (0=disable) [5]", 0 },
|
||||||
{"inject", 'i', nullptr, 0, "Inject remaining arguments as already seen messages (e.g. "
|
{"inject", 'i', nullptr, 0, "Inject remaining arguments as already seen messages (e.g. "
|
||||||
"\"FF08070400/0AB5454850303003277201\")", 0 },
|
"\"FF08070400/0AB5454850303003277201\")", 0 },
|
||||||
@@ -1263,7 +1264,7 @@ int main(int argc, char* argv[]) {
|
|||||||
if (len <= 1 || len > sizeof(envname)-3) { // no single char long args
|
if (len <= 1 || len > sizeof(envname)-3) { // no single char long args
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<len; i++) {
|
for (size_t i=0; i < len; i++) {
|
||||||
envopt[i] = static_cast<char>(tolower(start[i]));
|
envopt[i] = static_cast<char>(tolower(start[i]));
|
||||||
}
|
}
|
||||||
envopt[len] = 0;
|
envopt[len] = 0;
|
||||||
@@ -1286,7 +1287,7 @@ int main(int argc, char* argv[]) {
|
|||||||
opt.injectMessages = true; // for skipping unknown values
|
opt.injectMessages = true; // for skipping unknown values
|
||||||
error_t err = argp_parse(&aargp, cnt, envargv, ARGP_PARSE_ARGV0|ARGP_SILENT|ARGP_IN_ORDER,
|
error_t err = argp_parse(&aargp, cnt, envargv, ARGP_PARSE_ARGV0|ARGP_SILENT|ARGP_IN_ORDER,
|
||||||
&idx, &opt);
|
&idx, &opt);
|
||||||
if (err!=0 && idx==-1) { // ignore args for non-arg boolean options
|
if (err != 0 && idx == -1) { // ignore args for non-arg boolean options
|
||||||
logError(lf_main, "invalid/unknown argument in env: %s", envopt);
|
logError(lf_main, "invalid/unknown argument in env: %s", envopt);
|
||||||
}
|
}
|
||||||
opt.injectMessages = false; // restore
|
opt.injectMessages = false; // restore
|
||||||
@@ -1312,7 +1313,7 @@ int main(int argc, char* argv[]) {
|
|||||||
logError(lf_main, "invalid configPath URL");
|
logError(lf_main, "invalid configPath URL");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
if (!s_configHttpClient.connect(configHost, configPort, proto=="https", PACKAGE_NAME "/" PACKAGE_VERSION)) {
|
if (!s_configHttpClient.connect(configHost, configPort, proto == "https", PACKAGE_NAME "/" PACKAGE_VERSION)) {
|
||||||
logError(lf_main, "invalid configPath URL");
|
logError(lf_main, "invalid configPath URL");
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ std::pair<string, int> makeField(const string& name, bool isField) {
|
|||||||
void addPart(ostringstream& stack, int inField, vector<std::pair<string, int>>& parts) {
|
void addPart(ostringstream& stack, int inField, vector<std::pair<string, int>>& parts) {
|
||||||
string str = stack.str();
|
string str = stack.str();
|
||||||
if (inField == 1 && str == "_") {
|
if (inField == 1 && str == "_") {
|
||||||
inField = 0; // single "%_" pattern to reduce to "_"
|
inField = 0; // single "%_" pattern to reduce to "_"
|
||||||
} else if (inField == 2) {
|
} else if (inField == 2) {
|
||||||
str = "%{" + str;
|
str = "%{" + str;
|
||||||
inField = 0;
|
inField = 0;
|
||||||
@@ -894,7 +894,7 @@ void MqttHandler::parseIntegration(const string& line) {
|
|||||||
string value = line.substr(pos+1);
|
string value = line.substr(pos+1);
|
||||||
FileReader::trim(&value);
|
FileReader::trim(&value);
|
||||||
if (value.find('%') == string::npos) {
|
if (value.find('%') == string::npos) {
|
||||||
m_replacers.set(key, value); // constant value
|
m_replacers.set(key, value); // constant value
|
||||||
} else {
|
} else {
|
||||||
// simple variable
|
// simple variable
|
||||||
m_replacers.get(key).parse(value, false, false, emptyIfMissing);
|
m_replacers.get(key).parse(value, false, false, emptyIfMissing);
|
||||||
@@ -1555,7 +1555,7 @@ void MqttHandler::run() {
|
|||||||
if (!typeSwitchNames.empty()) {
|
if (!typeSwitchNames.empty()) {
|
||||||
vector<string> strs;
|
vector<string> strs;
|
||||||
splitFields(typeSwitch, &strs);
|
splitFields(typeSwitch, &strs);
|
||||||
for (size_t pos = 0; pos<strs.size() && pos < typeSwitchNames.size(); pos++) {
|
for (size_t pos = 0; pos < strs.size() && pos < typeSwitchNames.size(); pos++) {
|
||||||
values.set(typeSwitchNames[pos], strs[pos]);
|
values.set(typeSwitchNames[pos], strs[pos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ class MqttReplacer {
|
|||||||
* is empty or not defined.
|
* is empty or not defined.
|
||||||
* @return true on success, false on malformed template string.
|
* @return true on success, false on malformed template string.
|
||||||
*/
|
*/
|
||||||
bool parse(const string& templateStr, bool onlyKnown = false, bool noKnownDuplicates = false, bool emptyIfMissing = false);
|
bool parse(const string& templateStr, bool onlyKnown = false, bool noKnownDuplicates = false,
|
||||||
|
bool emptyIfMissing = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure the default topic parts are present (circuit and message).
|
* Ensure the default topic parts are present (circuit and message).
|
||||||
|
|||||||
@@ -620,7 +620,7 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
|
|||||||
case 0x0802:
|
case 0x0802:
|
||||||
stream << (m_infoId == 1 ? "ID" : "config");
|
stream << (m_infoId == 1 ? "ID" : "config");
|
||||||
stream << std::hex << std::setfill('0');
|
stream << std::hex << std::setfill('0');
|
||||||
for (uint8_t pos = 0; pos<m_infoPos; pos++) {
|
for (uint8_t pos = 0; pos < m_infoPos; pos++) {
|
||||||
stream << " " << std::setw(2) << static_cast<unsigned>(m_infoBuf[pos]);
|
stream << " " << std::setw(2) << static_cast<unsigned>(m_infoBuf[pos]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long res = BIO_do_connect(bio);
|
long res = BIO_do_connect(bio);
|
||||||
while (res != 1 && BIO_should_retry(bio) && time(nullptr)<until) {
|
while (res != 1 && BIO_should_retry(bio) && time(nullptr) < until) {
|
||||||
usleep(SLEEP_NANOS);
|
usleep(SLEEP_NANOS);
|
||||||
res = BIO_do_connect(bio);
|
res = BIO_do_connect(bio);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user