src/config.c: Introduce config_parse_str()

Be consistent with other parser helpers and with config_serialize_str().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-02-16 11:58:53 +01:00
parent 2ecfe91e04
commit b03b5694bc

View File

@ -77,6 +77,13 @@ config_parse_int (int *dest, const char *val)
return 1; return 1;
} }
static int
config_parse_str (char *dest, const char *val)
{
strncpy (dest, val, BUFSIZ);
return 1;
}
static int static int
config_parse_color (int *dest, const char *val) config_parse_color (int *dest, const char *val)
{ {
@ -183,30 +190,24 @@ config_set_conf (const char *key, const char *value)
if (!strcmp(key, "notify-bar_show")) if (!strcmp(key, "notify-bar_show"))
return config_parse_bool (&nbar.show, value); return config_parse_bool (&nbar.show, value);
if (!strcmp(key, "notify-bar_date")) { if (!strcmp(key, "notify-bar_date"))
strncpy (nbar.datefmt, value, strlen (value) + 1); return config_parse_str (nbar.datefmt, value);
return 1;
}
if (!strcmp(key, "notify-bar_clock")) { if (!strcmp(key, "notify-bar_clock"))
strncpy (nbar.timefmt, value, strlen (value) + 1); return config_parse_str (nbar.timefmt, value);
return 1;
}
if (!strcmp(key, "notify-bar_warning")) if (!strcmp(key, "notify-bar_warning"))
return config_parse_int (&nbar.cntdwn, value); return config_parse_int (&nbar.cntdwn, value);
if (!strcmp(key, "notify-bar_command")) { if (!strcmp(key, "notify-bar_command"))
strncpy (nbar.cmd, value, strlen (value) + 1); return config_parse_str (nbar.cmd, value);
return 1;
}
if (!strcmp(key, "notify-all")) if (!strcmp(key, "notify-all"))
return config_parse_bool(&nbar.notify_all, value); return config_parse_bool(&nbar.notify_all, value);
if (!strcmp(key, "output_datefmt")) { if (!strcmp(key, "output_datefmt")) {
if (value[0] != '\0') if (value[0] != '\0')
strncpy (conf.output_datefmt, value, strlen (value) + 1); return config_parse_str (conf.output_datefmt, value);
return 1; return 1;
} }