aboutsummaryrefslogtreecommitdiff
path: root/liberty.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-08-16 23:49:57 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-08-16 23:49:57 +0200
commit792b074e3dcaa978a66d57907b95f4fc4a8ba027 (patch)
tree94a514e68b3f127cea1881174c2d7ff5f4b7c7f1 /liberty.c
parentbb2de1fd488bf8b7660ad578fe331eb50f903e12 (diff)
downloadliberty-792b074e3dcaa978a66d57907b95f4fc4a8ba027.tar.gz
liberty-792b074e3dcaa978a66d57907b95f4fc4a8ba027.tar.xz
liberty-792b074e3dcaa978a66d57907b95f4fc4a8ba027.zip
Rename configuration to simple_config_*
So that it doesn't conflict with the enhanced one in uirc3.
Diffstat (limited to 'liberty.c')
-rw-r--r--liberty.c20
1 files 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);