|
|
2c83a8 |
From b429af7c61bb1abe791ceb34fb6b6cf7382f832b Mon Sep 17 00:00:00 2001
|
|
|
2c83a8 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
2c83a8 |
Date: Fri, 12 Feb 2016 14:25:05 +0100
|
|
|
2c83a8 |
Subject: [PATCH] lib: introduce a new function returning base user conf
|
|
|
2c83a8 |
directory
|
|
|
2c83a8 |
|
|
|
2c83a8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
2c83a8 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
2c83a8 |
---
|
|
|
2c83a8 |
src/include/internal_libreport.h | 3 +++
|
|
|
2c83a8 |
src/lib/configuration_files.c | 9 +++++++++
|
|
|
2c83a8 |
src/lib/user_settings.c | 12 +++++-------
|
|
|
2c83a8 |
3 files changed, 17 insertions(+), 7 deletions(-)
|
|
|
2c83a8 |
|
|
|
2c83a8 |
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
|
|
|
2c83a8 |
index b36cbd9..38d75a1 100644
|
|
|
2c83a8 |
--- a/src/include/internal_libreport.h
|
|
|
2c83a8 |
+++ b/src/include/internal_libreport.h
|
|
|
2c83a8 |
@@ -738,6 +738,9 @@ bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWith
|
|
|
2c83a8 |
#define load_plugin_conf_file libreport_load_plugin_conf_file
|
|
|
2c83a8 |
bool load_plugin_conf_file(const char *name, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
2c83a8 |
|
|
|
2c83a8 |
+#define get_user_conf_base_dir libreport_get_user_conf_base_dir
|
|
|
2c83a8 |
+const char *get_user_conf_base_dir(void);
|
|
|
2c83a8 |
+
|
|
|
2c83a8 |
#define load_conf_file_from_dirs libreport_load_conf_file_from_dirs
|
|
|
2c83a8 |
bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue);
|
|
|
2c83a8 |
|
|
|
2c83a8 |
diff --git a/src/lib/configuration_files.c b/src/lib/configuration_files.c
|
|
|
2c83a8 |
index 4975d62..b145b9f 100644
|
|
|
2c83a8 |
--- a/src/lib/configuration_files.c
|
|
|
2c83a8 |
+++ b/src/lib/configuration_files.c
|
|
|
2c83a8 |
@@ -318,6 +318,15 @@ finalize:
|
|
|
2c83a8 |
return retval;
|
|
|
2c83a8 |
}
|
|
|
2c83a8 |
|
|
|
2c83a8 |
+const char *get_user_conf_base_dir(void)
|
|
|
2c83a8 |
+{
|
|
|
2c83a8 |
+ static char *base_dir = NULL;
|
|
|
2c83a8 |
+ if (base_dir == NULL)
|
|
|
2c83a8 |
+ base_dir = concat_path_file(g_get_user_config_dir(), "abrt/settings/");
|
|
|
2c83a8 |
+
|
|
|
2c83a8 |
+ return base_dir;
|
|
|
2c83a8 |
+}
|
|
|
2c83a8 |
+
|
|
|
2c83a8 |
bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue)
|
|
|
2c83a8 |
{
|
|
|
2c83a8 |
if (NULL == directories || NULL == *directories)
|
|
|
2c83a8 |
diff --git a/src/lib/user_settings.c b/src/lib/user_settings.c
|
|
|
2c83a8 |
index 4cd87ff..cdc8482 100644
|
|
|
2c83a8 |
--- a/src/lib/user_settings.c
|
|
|
2c83a8 |
+++ b/src/lib/user_settings.c
|
|
|
2c83a8 |
@@ -18,21 +18,19 @@
|
|
|
2c83a8 |
#include "internal_libreport.h"
|
|
|
2c83a8 |
#include <augeas.h>
|
|
|
2c83a8 |
|
|
|
2c83a8 |
-#define BASE_DIR_FOR_USER_CONFIG_FILE "abrt/settings/"
|
|
|
2c83a8 |
-
|
|
|
2c83a8 |
static map_string_t *user_settings;
|
|
|
2c83a8 |
static char *conf_path;
|
|
|
2c83a8 |
|
|
|
2c83a8 |
static char *get_user_config_file_path(const char *name, const char *suffix)
|
|
|
2c83a8 |
{
|
|
|
2c83a8 |
- char *s, *conf;
|
|
|
2c83a8 |
+ char *s = NULL;
|
|
|
2c83a8 |
+ char *conf;
|
|
|
2c83a8 |
|
|
|
2c83a8 |
if (suffix != NULL)
|
|
|
2c83a8 |
- s = xasprintf(BASE_DIR_FOR_USER_CONFIG_FILE"%s.%s", name, suffix);
|
|
|
2c83a8 |
- else
|
|
|
2c83a8 |
- s = xasprintf(BASE_DIR_FOR_USER_CONFIG_FILE"%s", name);
|
|
|
2c83a8 |
+ s = xasprintf("%s.%s", name, suffix);
|
|
|
2c83a8 |
+
|
|
|
2c83a8 |
+ conf = concat_path_file(get_user_conf_base_dir(), s != NULL ? s : name);
|
|
|
2c83a8 |
|
|
|
2c83a8 |
- conf = concat_path_file(g_get_user_config_dir(), s);
|
|
|
2c83a8 |
free(s);
|
|
|
2c83a8 |
return conf;
|
|
|
2c83a8 |
}
|
|
|
2c83a8 |
--
|
|
|
2c83a8 |
1.8.3.1
|
|
|
2c83a8 |
|