|
|
0c9110 |
From 641176aaf757dac6442a2359f34c4b46537485f4 Mon Sep 17 00:00:00 2001
|
|
|
0c9110 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
0c9110 |
Date: Thu, 18 Dec 2014 23:59:29 +0100
|
|
|
0c9110 |
Subject: [LIBREPORT PATCH 122/124] lib: add functions to load/save plugin conf
|
|
|
0c9110 |
files
|
|
|
0c9110 |
|
|
|
0c9110 |
Related: #1140224, #1174833
|
|
|
0c9110 |
|
|
|
0c9110 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
0c9110 |
---
|
|
|
0c9110 |
src/include/internal_libreport.h | 4 ++++
|
|
|
0c9110 |
src/lib/configuration_files.c | 27 +++++++++++++++++++++++++++
|
|
|
0c9110 |
2 files changed, 31 insertions(+)
|
|
|
0c9110 |
|
|
|
0c9110 |
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
|
|
|
0c9110 |
index 585b807..967324b 100644
|
|
|
0c9110 |
--- a/src/include/internal_libreport.h
|
|
|
0c9110 |
+++ b/src/include/internal_libreport.h
|
|
|
0c9110 |
@@ -723,12 +723,16 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version
|
|
|
0c9110 |
*/
|
|
|
0c9110 |
#define load_conf_file libreport_load_conf_file
|
|
|
0c9110 |
bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
0c9110 |
+#define load_plugin_conf_file libreport_load_plugin_conf_file
|
|
|
0c9110 |
+bool load_plugin_conf_file(const char *name, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
0c9110 |
|
|
|
0c9110 |
#define load_conf_file_from_dirs libreport_load_conf_file_from_dirs
|
|
|
0c9110 |
bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
0c9110 |
|
|
|
0c9110 |
#define save_conf_file libreport_save_conf_file
|
|
|
0c9110 |
bool save_conf_file(const char *path, map_string_t *settings);
|
|
|
0c9110 |
+#define save_plugin_conf_file libreport_save_plugin_conf_file
|
|
|
0c9110 |
+bool save_plugin_conf_file(const char *name, map_string_t *settings);
|
|
|
0c9110 |
|
|
|
0c9110 |
#define save_app_conf_file libreport_save_app_conf_file
|
|
|
0c9110 |
bool save_app_conf_file(const char* application_name, map_string_t *settings);
|
|
|
0c9110 |
diff --git a/src/lib/configuration_files.c b/src/lib/configuration_files.c
|
|
|
0c9110 |
index bc1852e..4975d62 100644
|
|
|
0c9110 |
--- a/src/lib/configuration_files.c
|
|
|
0c9110 |
+++ b/src/lib/configuration_files.c
|
|
|
0c9110 |
@@ -341,6 +341,20 @@ bool load_conf_file_from_dirs(const char *base_name, const char *const *director
|
|
|
0c9110 |
return result;
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
+bool load_plugin_conf_file(const char *name, map_string_t *settings, bool skipKeysWithoutValue)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ const char *dirs[] = {
|
|
|
0c9110 |
+ PLUGINS_CONF_DIR,
|
|
|
0c9110 |
+ NULL,
|
|
|
0c9110 |
+ };
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ const char *plugins_conf_dir = getenv("LIBREPORT_DEBUG_PLUGINS_CONF_DIR");
|
|
|
0c9110 |
+ if (plugins_conf_dir != NULL)
|
|
|
0c9110 |
+ dirs[0] = plugins_conf_dir;
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ return load_conf_file_from_dirs(name, dirs, settings, skipKeysWithoutValue);
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
static int
|
|
|
0c9110 |
cmpstringp(const void *p1, const void *p2)
|
|
|
0c9110 |
{
|
|
|
0c9110 |
@@ -458,3 +472,16 @@ finalize:
|
|
|
0c9110 |
|
|
|
0c9110 |
return retval;
|
|
|
0c9110 |
}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+bool save_plugin_conf_file(const char *name, map_string_t *settings)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ const char *plugins_conf_dir = getenv("LIBREPORT_DEBUG_PLUGINS_CONF_DIR");
|
|
|
0c9110 |
+ if (plugins_conf_dir == NULL)
|
|
|
0c9110 |
+ plugins_conf_dir = PLUGINS_CONF_DIR;
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ char *conf_path = concat_path_file(plugins_conf_dir, name);
|
|
|
0c9110 |
+ bool ret = save_conf_file(conf_path, settings);
|
|
|
0c9110 |
+ free(conf_path);
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ return ret;
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
--
|
|
|
0c9110 |
1.8.3.1
|
|
|
0c9110 |
|