mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-23 23:05:38 +08:00
Linux cleanups.
This commit is contained in:
22
Conf.cpp
22
Conf.cpp
@@ -252,22 +252,22 @@ bool CConf::read()
|
|||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Remove quotes from the value
|
// Remove quotes from the value
|
||||||
size_t len = ::strlen(value);
|
size_t len = ::strlen(value);
|
||||||
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
|
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
|
||||||
value[len - 1U] = '\0';
|
value[len - 1U] = '\0';
|
||||||
value++;
|
value++;
|
||||||
} else {
|
} else {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
// if value is not quoted, remove after # (to make comment)
|
// if value is not quoted, remove after # (to make comment)
|
||||||
if ((p = strchr(value, '#')) != nullptr)
|
if ((p = strchr(value, '#')) != nullptr)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
// remove trailing tab/space
|
// remove trailing tab/space
|
||||||
for (p = value + strlen(value) - 1U; p >= value && (*p == '\t' || *p == ' '); p--)
|
for (p = value + strlen(value) - 1U; p >= value && (*p == '\t' || *p == ' '); p--)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section == SECTION::GENERAL) {
|
if (section == SECTION::GENERAL) {
|
||||||
if (::strcmp(key, "Daemon") == 0)
|
if (::strcmp(key, "Daemon") == 0)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ CMQTTConnection::~CMQTTConnection()
|
|||||||
bool CMQTTConnection::open()
|
bool CMQTTConnection::open()
|
||||||
{
|
{
|
||||||
char name[50U];
|
char name[50U];
|
||||||
::sprintf(name, "DMRGateway.%lld", ::time(nullptr));
|
::sprintf(name, "DMRGateway.%ld", ::time(nullptr));
|
||||||
|
|
||||||
::fprintf(stdout, "DMRGateway (%s) connecting to MQTT as %s\n", m_name.c_str(), name);
|
::fprintf(stdout, "DMRGateway (%s) connecting to MQTT as %s\n", m_name.c_str(), name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user