From 792b074e3dcaa978a66d57907b95f4fc4a8ba027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sun, 16 Aug 2015 23:49:57 +0200 Subject: [PATCH] Rename configuration to simple_config_* So that it doesn't conflict with the enhanced one in uirc3. --- liberty.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/liberty.c b/liberty.c index c559e9b..5349a0a 100644 --- a/liberty.c +++ b/liberty.c @@ -2893,11 +2893,11 @@ regex_cache_match (struct str_map *cache, const char *regex, int flags, return regexec (re, s, 0, NULL, 0) != REG_NOMATCH; } -// --- Configuration ----------------------------------------------------------- +// --- Simple configuration ---------------------------------------------------- // The keys are stripped of surrounding whitespace, the values are not. -struct config_item +struct simple_config_item { const char *key; const char *default_value; @@ -2905,7 +2905,8 @@ struct config_item }; static void -load_config_defaults (struct str_map *config, const struct config_item *table) +simple_config_load_defaults + (struct str_map *config, const struct simple_config_item *table) { for (; table->key != NULL; table++) if (table->default_value) @@ -2915,7 +2916,7 @@ load_config_defaults (struct str_map *config, const struct config_item *table) } static bool -read_config_file (struct str_map *config, struct error **e) +simple_config_update_from_file (struct str_map *config, struct error **e) { char *filename = resolve_filename (PROGRAM_NAME ".conf", resolve_relative_config_filename); @@ -2969,8 +2970,8 @@ read_config_file (struct str_map *config, struct error **e) } static char * -write_default_config (const char *filename, const char *prolog, - const struct config_item *table, struct error **e) +simple_config_write_default (const char *filename, const char *prolog, + const struct simple_config_item *table, struct error **e) { struct str path, base; @@ -3032,11 +3033,12 @@ error: str_free (&base); str_free (&path); return NULL; - } +/// Convenience wrapper suitable for most simple applications static void -call_write_default_config (const char *hint, const struct config_item *table) +call_simple_config_write_default + (const char *hint, const struct simple_config_item *table) { static const char *prolog = "# " PROGRAM_NAME " " PROGRAM_VERSION " configuration file\n" @@ -3046,7 +3048,7 @@ call_write_default_config (const char *hint, const struct config_item *table) "\n"; struct error *e = NULL; - char *filename = write_default_config (hint, prolog, table, &e); + char *filename = simple_config_write_default (hint, prolog, table, &e); if (!filename) { print_error ("%s", e->message);