|
|
a1aaaf |
From 2648eb9e983e1b0792f94f3b70920a1fb0225aac Mon Sep 17 00:00:00 2001
|
|
|
a1aaaf |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
a1aaaf |
Date: Fri, 8 Nov 2013 17:08:05 +0100
|
|
|
a1aaaf |
Subject: [LIBREPORT PATCH 36/36] Load a config file from several directories
|
|
|
a1aaaf |
|
|
|
a1aaaf |
Related to abrt/abrt#752
|
|
|
a1aaaf |
---
|
|
|
a1aaaf |
src/include/internal_libreport.h | 3 +
|
|
|
a1aaaf |
src/lib/load_plugin_settings.c | 23 +++++
|
|
|
a1aaaf |
8 files changed, 240 insertions(+), 2 deletions(-)
|
|
|
a1aaaf |
|
|
|
a1aaaf |
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
|
|
|
a1aaaf |
index db2ffd8..30458c3 100644
|
|
|
a1aaaf |
--- a/src/include/internal_libreport.h
|
|
|
a1aaaf |
+++ b/src/include/internal_libreport.h
|
|
|
a1aaaf |
@@ -715,6 +715,9 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version
|
|
|
a1aaaf |
#define load_conf_file libreport_load_conf_file
|
|
|
a1aaaf |
bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
a1aaaf |
|
|
|
a1aaaf |
+#define load_conf_file_from_dirs libreport_load_conf_file_from_dirs
|
|
|
a1aaaf |
+bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
a1aaaf |
+
|
|
|
a1aaaf |
#define save_conf_file libreport_save_conf_file
|
|
|
a1aaaf |
bool save_conf_file(const char *path, map_string_t *settings);
|
|
|
a1aaaf |
|
|
|
a1aaaf |
diff --git a/src/lib/load_plugin_settings.c b/src/lib/load_plugin_settings.c
|
|
|
a1aaaf |
index 84ebd63..b56ba7f 100644
|
|
|
a1aaaf |
--- a/src/lib/load_plugin_settings.c
|
|
|
a1aaaf |
+++ b/src/lib/load_plugin_settings.c
|
|
|
a1aaaf |
@@ -103,3 +103,26 @@ bool load_conf_file(const char *path, map_string_t *settings, bool skipKeysWitho
|
|
|
a1aaaf |
|
|
|
a1aaaf |
return true;
|
|
|
a1aaaf |
}
|
|
|
a1aaaf |
+
|
|
|
a1aaaf |
+bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue)
|
|
|
a1aaaf |
+{
|
|
|
a1aaaf |
+ if (NULL == directories || NULL == *directories)
|
|
|
a1aaaf |
+ {
|
|
|
a1aaaf |
+ error_msg("No configuration directory specified");
|
|
|
a1aaaf |
+ return false;
|
|
|
a1aaaf |
+ }
|
|
|
a1aaaf |
+
|
|
|
a1aaaf |
+ bool result = true;
|
|
|
a1aaaf |
+ for (const char *const *dir = directories; *dir != NULL; ++dir)
|
|
|
a1aaaf |
+ {
|
|
|
a1aaaf |
+ char *conf_file = concat_path_file(*dir, base_name);
|
|
|
a1aaaf |
+ if (!load_conf_file(conf_file, settings, skipKeysWithoutValue))
|
|
|
a1aaaf |
+ {
|
|
|
a1aaaf |
+ perror_msg("Can't open '%s'", conf_file);
|
|
|
a1aaaf |
+ result = false;
|
|
|
a1aaaf |
+ }
|
|
|
a1aaaf |
+ free(conf_file);
|
|
|
a1aaaf |
+ }
|
|
|
a1aaaf |
+
|
|
|
a1aaaf |
+ return result;
|
|
|
a1aaaf |
+}
|
|
|
a1aaaf |
+m4_include([configuration_files.at])
|
|
|
a1aaaf |
--
|
|
|
a1aaaf |
1.8.3.1
|
|
|
a1aaaf |
|