aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-02-16 10:45:09 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-02-16 10:45:09 +0100
commitb105bf8fab5ca69e9857bbe93db0b30078a2f8a3 (patch)
treec95da314aabeba50e94262f2ada31ba7a750475f
parent4c5d6fe612f8e80dbc6279b1b1cdf6eb568dd4da (diff)
downloadcalcurse-b105bf8fab5ca69e9857bbe93db0b30078a2f8a3.tar.gz
calcurse-b105bf8fab5ca69e9857bbe93db0b30078a2f8a3.zip
src/config.c: Add junk callback to config_file_walk()
This can be used if we care about junk, such as empty lines and comments. Currently unused since we skip these when parsing configuration settings. This makes sense if we want to make slight modifications to the configuration file without losing formatting and comments, though. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/config.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/config.c b/src/config.c
index 14294cc..f91b643 100644
--- a/src/config.c
+++ b/src/config.c
@@ -39,6 +39,7 @@
#include "calcurse.h"
typedef int (*config_fn_walk_cb_t) (const char *, const char *, void *);
+typedef int (*config_fn_walk_junk_cb_t) (const char *, void *);
static int
config_parse_bool (unsigned *dest, const char *val)
@@ -228,7 +229,8 @@ config_set_conf (const char *key, const char *value)
}
static void
-config_file_walk (config_fn_walk_cb_t fn_cb, void *data)
+config_file_walk (config_fn_walk_cb_t fn_cb,
+ config_fn_walk_junk_cb_t fn_junk_cb, void *data)
{
FILE *data_file;
char *mesg_line1 = _("Failed to open config file");
@@ -253,7 +255,11 @@ config_file_walk (config_fn_walk_cb_t fn_cb, void *data)
io_extract_data (e_conf, buf, sizeof buf);
if (*e_conf == '\0')
- continue;
+ {
+ if (fn_junk_cb)
+ fn_junk_cb (buf, data);
+ continue;
+ }
key = e_conf;
value = strchr (e_conf, '=');
@@ -297,7 +303,7 @@ config_load_cb (const char *key, const char *value, void *dummy)
void
config_load (void)
{
- config_file_walk (config_load_cb, NULL);
+ config_file_walk (config_load_cb, NULL, NULL);
}
/*