Add support for defaults in config file

If no section name is specified the configuration will be considered the
default one.

This allows to set e.g. a default color code for sections which do not
configure a color code.
This commit is contained in:
Martin Lund 2022-03-19 18:37:35 +01:00
parent 03cf4ef197
commit 09bcd91bf0

View file

@ -86,9 +86,10 @@ static int data_handler(void *user, const char *section, const char *name,
{
UNUSED(user);
if (strcmp(section, c->section_name))
return 0;
// If section matches user input or unnamed section
if ((!strcmp(section, c->section_name)) || (!strcmp(section, "")))
{
// Set configuration parameter if found
if (!strcmp(name, "tty"))
{
asprintf(&c->tty, value, c->match);
@ -150,7 +151,7 @@ static int data_handler(void *user, const char *section, const char *name,
{
option.color = atoi(value);
}
}
return 0;
}