[unlim-networks] indentation fix

This commit is contained in:
Alexander Mokrov UR6LKW
2025-06-01 17:04:44 +03:00
parent ec5c32b57a
commit 68e68c9c79

156
Conf.cpp
View File

@@ -197,80 +197,80 @@ CConf::~CConf()
bool CConf::read()
{
FILE* fp = ::fopen(m_file.c_str(), "rt");
if (fp == nullptr) {
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
return false;
}
SECTION section = SECTION::NONE;
char buffer[BUFFER_SIZE];
while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
if (buffer[0U] == '[') {
if (::strncmp(buffer, "[General]", 9U) == 0)
section = SECTION::GENERAL;
else if (::strncmp(buffer, "[Log]", 5U) == 0)
section = SECTION::LOG;
else if (::strncmp(buffer, "[Voice]", 7U) == 0)
section = SECTION::VOICE;
else if (::strncmp(buffer, "[Info]", 6U) == 0)
section = SECTION::INFO;
else if (::strncmp(buffer, "[XLX Network]", 13U) == 0)
section = SECTION::XLX_NETWORK;
else if (::strncmp(buffer, "[DMR Network 1]", 15U) == 0)
section = SECTION::DMR_NETWORK_1;
else if (::strncmp(buffer, "[DMR Network 2]", 15U) == 0)
section = SECTION::DMR_NETWORK_2;
else if (::strncmp(buffer, "[DMR Network 3]", 15U) == 0)
section = SECTION::DMR_NETWORK_3;
else if (::strncmp(buffer, "[DMR Network 4]", 15U) == 0)
section = SECTION::DMR_NETWORK_4;
else if (::strncmp(buffer, "[DMR Network 5]", 15U) == 0)
section = SECTION::DMR_NETWORK_5;
else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
section = SECTION::GPSD;
else if (::strncmp(buffer, "[APRS]", 6U) == 0)
section = SECTION::APRS;
else if (::strncmp(buffer, "[Dynamic TG Control]", 20U) == 0)
section = SECTION::DYNAMIC_TG_CONTROL;
else if (::strncmp(buffer, "[Remote Control]", 16U) == 0)
section = SECTION::REMOTE_CONTROL;
else
section = SECTION::NONE;
continue;
FILE* fp = ::fopen(m_file.c_str(), "rt");
if (fp == nullptr) {
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
return false;
}
char* key = ::strtok(buffer, " \t=\r\n");
if (key == nullptr)
continue;
SECTION section = SECTION::NONE;
char* value = ::strtok(nullptr, "\r\n");
if (value == nullptr)
continue;
char buffer[BUFFER_SIZE];
while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
// Remove quotes from the value
size_t len = ::strlen(value);
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
value[len - 1U] = '\0';
value++;
} else {
char *p;
if (buffer[0U] == '[') {
if (::strncmp(buffer, "[General]", 9U) == 0)
section = SECTION::GENERAL;
else if (::strncmp(buffer, "[Log]", 5U) == 0)
section = SECTION::LOG;
else if (::strncmp(buffer, "[Voice]", 7U) == 0)
section = SECTION::VOICE;
else if (::strncmp(buffer, "[Info]", 6U) == 0)
section = SECTION::INFO;
else if (::strncmp(buffer, "[XLX Network]", 13U) == 0)
section = SECTION::XLX_NETWORK;
else if (::strncmp(buffer, "[DMR Network 1]", 15U) == 0)
section = SECTION::DMR_NETWORK_1;
else if (::strncmp(buffer, "[DMR Network 2]", 15U) == 0)
section = SECTION::DMR_NETWORK_2;
else if (::strncmp(buffer, "[DMR Network 3]", 15U) == 0)
section = SECTION::DMR_NETWORK_3;
else if (::strncmp(buffer, "[DMR Network 4]", 15U) == 0)
section = SECTION::DMR_NETWORK_4;
else if (::strncmp(buffer, "[DMR Network 5]", 15U) == 0)
section = SECTION::DMR_NETWORK_5;
else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
section = SECTION::GPSD;
else if (::strncmp(buffer, "[APRS]", 6U) == 0)
section = SECTION::APRS;
else if (::strncmp(buffer, "[Dynamic TG Control]", 20U) == 0)
section = SECTION::DYNAMIC_TG_CONTROL;
else if (::strncmp(buffer, "[Remote Control]", 16U) == 0)
section = SECTION::REMOTE_CONTROL;
else
section = SECTION::NONE;
// if value is not quoted, remove after # (to make comment)
if ((p = strchr(value, '#')) != nullptr)
*p = '\0';
continue;
}
// remove trailing tab/space
for (p = value + strlen(value) - 1U; p >= value && (*p == '\t' || *p == ' '); p--)
*p = '\0';
}
char* key = ::strtok(buffer, " \t=\r\n");
if (key == nullptr)
continue;
if (section == SECTION::GENERAL) {
char* value = ::strtok(nullptr, "\r\n");
if (value == nullptr)
continue;
// Remove quotes from the value
size_t len = ::strlen(value);
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
value[len - 1U] = '\0';
value++;
} else {
char *p;
// if value is not quoted, remove after # (to make comment)
if ((p = strchr(value, '#')) != nullptr)
*p = '\0';
// remove trailing tab/space
for (p = value + strlen(value) - 1U; p >= value && (*p == '\t' || *p == ' '); p--)
*p = '\0';
}
if (section == SECTION::GENERAL) {
if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
else if (::strcmp(key, "Timeout") == 0)
@@ -350,7 +350,7 @@ bool CConf::read()
// Right align, then pads with zeros, as XLX IDs are 3 characters length
snprintf(buffer, sizeof(buffer), "%3s", value);
while ((*p != '\0') && (*p == ' '))
*p++ = '0';
*p++ = '0';
m_xlxNetworkStartup = std::string(buffer);
}
@@ -358,10 +358,10 @@ bool CConf::read()
m_xlxNetworkRelink = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_xlxNetworkDebug = ::atoi(value) == 1;
else if (::strcmp(key, "UserControl") == 0)
m_xlxNetworkUserControl = ::atoi(value) ==1;
else if (::strcmp(key, "Module") == 0)
m_xlxNetworkModule = ::toupper(value[0]);
else if (::strcmp(key, "UserControl") == 0)
m_xlxNetworkUserControl = ::atoi(value) ==1;
else if (::strcmp(key, "Module") == 0)
m_xlxNetworkModule = ::toupper(value[0]);
} else if (section == SECTION::DMR_NETWORK_1) {
if (::strcmp(key, "Enabled") == 0)
m_dmrNetwork1Enabled = ::atoi(value) == 1;
@@ -990,8 +990,8 @@ bool CConf::read()
m_aprsSuffix = value;
else if (::strcmp(key, "Description") == 0)
m_aprsDescription = value;
else if (::strcmp(key, "Symbol") == 0)
m_aprsSymbol = value;
else if (::strcmp(key, "Symbol") == 0)
m_aprsSymbol = value;
} else if (section == SECTION::DYNAMIC_TG_CONTROL) {
if (::strcmp(key, "Enabled") == 0)
m_dynamicTGControlEnabled = ::atoi(value) == 1;
@@ -1144,17 +1144,17 @@ std::string CConf::getXLXNetworkFile() const
unsigned int CConf::getXLXNetworkReloadTime() const
{
return m_xlxNetworkReloadTime;
return m_xlxNetworkReloadTime;
}
unsigned short CConf::getXLXNetworkPort() const
{
return m_xlxNetworkPort;
return m_xlxNetworkPort;
}
std::string CConf::getXLXNetworkPassword() const
{
return m_xlxNetworkPassword;
return m_xlxNetworkPassword;
}
unsigned short CConf::getXLXNetworkLocal() const
@@ -1707,7 +1707,7 @@ std::string CConf::getAPRSDescription() const
std::string CConf::getAPRSSymbol() const
{
return m_aprsSymbol;
return m_aprsSymbol;
}
bool CConf::getDynamicTGControlEnabled() const