mirror of
https://github.com/ShaYmez/NXDNClients.git
synced 2025-08-03 13:22:26 -04:00
Upgrade the ini file parsing.
This commit is contained in:
parent
c6deee572f
commit
3794f321e9
@ -139,6 +139,26 @@ bool CConf::read()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
char* value = ::strtok(NULL, "\r\n");
|
char* value = ::strtok(NULL, "\r\n");
|
||||||
|
if (value == NULL)
|
||||||
|
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, '#')) != NULL)
|
||||||
|
*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 (section == SECTION_GENERAL) {
|
||||||
if (::strcmp(key, "Callsign") == 0) {
|
if (::strcmp(key, "Callsign") == 0) {
|
||||||
// Convert the callsign to upper case
|
// Convert the callsign to upper case
|
||||||
|
@ -104,6 +104,26 @@ bool CConf::read()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
char* value = ::strtok(NULL, "\r\n");
|
char* value = ::strtok(NULL, "\r\n");
|
||||||
|
if (value == NULL)
|
||||||
|
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, '#')) != NULL)
|
||||||
|
*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 (section == SECTION_GENERAL) {
|
||||||
if (::strcmp(key, "Daemon") == 0)
|
if (::strcmp(key, "Daemon") == 0)
|
||||||
m_daemon = ::atoi(value) == 1;
|
m_daemon = ::atoi(value) == 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user