Blame SOURCES/0162-lib-introduce-a-new-function-returning-base-user-con.patch

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