summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-02-16 11:58:53 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-02-17 10:02:22 +0100
commitb03b5694bc752d9cb75dada2f53edf4f9e78e2fb (patch)
tree2cfb87c21e62455f4628901ab3238da406392b0f /src/config.c
parent2ecfe91e049066a4034be8237542e6f161aa09f4 (diff)
downloadcalcurse-b03b5694bc752d9cb75dada2f53edf4f9e78e2fb.tar.gz
calcurse-b03b5694bc752d9cb75dada2f53edf4f9e78e2fb.zip
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>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/config.c b/src/config.c
index f744b67..8b7accf 100644
--- a/src/config.c
+++ b/src/config.c
@@ -78,6 +78,13 @@ config_parse_int (int *dest, const char *val)
}
static int
+config_parse_str (char *dest, const char *val)
+{
+ strncpy (dest, val, BUFSIZ);
+ return 1;
+}
+
+static int
config_parse_color (int *dest, const char *val)
{
if (!strcmp (val, "black"))
@@ -183,30 +190,24 @@ config_set_conf (const char *key, const char *value)
if (!strcmp(key, "notify-bar_show"))
return config_parse_bool (&nbar.show, value);
- if (!strcmp(key, "notify-bar_date")) {
- strncpy (nbar.datefmt, value, strlen (value) + 1);
- return 1;
- }
+ if (!strcmp(key, "notify-bar_date"))
+ return config_parse_str (nbar.datefmt, value);
- if (!strcmp(key, "notify-bar_clock")) {
- strncpy (nbar.timefmt, value, strlen (value) + 1);
- return 1;
- }
+ if (!strcmp(key, "notify-bar_clock"))
+ return config_parse_str (nbar.timefmt, value);
if (!strcmp(key, "notify-bar_warning"))
return config_parse_int (&nbar.cntdwn, value);
- if (!strcmp(key, "notify-bar_command")) {
- strncpy (nbar.cmd, value, strlen (value) + 1);
- return 1;
- }
+ if (!strcmp(key, "notify-bar_command"))
+ return config_parse_str (nbar.cmd, value);
if (!strcmp(key, "notify-all"))
return config_parse_bool(&nbar.notify_all, value);
if (!strcmp(key, "output_datefmt")) {
if (value[0] != '\0')
- strncpy (conf.output_datefmt, value, strlen (value) + 1);
+ return config_parse_str (conf.output_datefmt, value);
return 1;
}