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

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