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