about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-02 22:18:08 +0000
committerJames Booth <boothj5@gmail.com>2013-02-02 22:18:08 +0000
commitc58aca5640629684a7161b7b3c2048ad8ea9b452 (patch)
tree2f2a87347fbf3acf18b991517f8f12546bb3d9f6
parent0b4c464919d44851afd9091eaa435d3fb205e18e (diff)
downloadprofani-tty-c58aca5640629684a7161b7b3c2048ad8ea9b452.tar.gz
Moved function to get log dir to log.c
-rw-r--r--src/config/preferences.c20
-rw-r--r--src/files.c26
-rw-r--r--src/files.h2
-rw-r--r--src/log.c20
4 files changed, 33 insertions, 35 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c
index b2414fca..f942bb48 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -32,10 +32,10 @@
 #include <ncurses.h>
 #endif
 
-#include "preferences.h"
-
+#include "common.h"
 #include "files.h"
 #include "log.h"
+#include "preferences.h"
 #include "tools/autocomplete.h"
 
 static gchar *prefs_loc;
@@ -45,6 +45,7 @@ gint log_maxsize = 0;
 static Autocomplete boolean_choice_ac;
 
 static void _save_prefs(void);
+static gchar * _get_preferences_file(void);
 
 void
 prefs_load(void)
@@ -52,7 +53,7 @@ prefs_load(void)
     GError *err;
 
     log_info("Loading preferences");
-    prefs_loc = files_get_preferences_file();
+    prefs_loc = _get_preferences_file();
 
     prefs = g_key_file_new();
     g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS,
@@ -453,3 +454,16 @@ _save_prefs(void)
     char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
     g_file_set_contents(prefs_loc, g_prefs_data, g_data_size, NULL);
 }
+
+static gchar *
+_get_preferences_file(void)
+{
+    gchar *xdg_config = xdg_get_config_home();
+    GString *prefs_file = g_string_new(xdg_config);
+    g_string_append(prefs_file, "/profanity/profrc");
+    gchar *result = strdup(prefs_file->str);
+    g_free(xdg_config);
+    g_string_free(prefs_file, TRUE);
+
+    return result;
+}
diff --git a/src/files.c b/src/files.c
index bb339ad8..988baa36 100644
--- a/src/files.c
+++ b/src/files.c
@@ -46,32 +46,6 @@ files_create_directories(void)
 }
 
 gchar *
-files_get_preferences_file(void)
-{
-    gchar *xdg_config = xdg_get_config_home();
-    GString *prefs_file = g_string_new(xdg_config);
-    g_string_append(prefs_file, "/profanity/profrc");
-    gchar *result = strdup(prefs_file->str);
-    g_free(xdg_config);
-    g_string_free(prefs_file, TRUE);
-
-    return result;
-}
-
-gchar *
-files_get_log_file(void)
-{
-    gchar *xdg_data = xdg_get_data_home();
-    GString *logfile = g_string_new(xdg_data);
-    g_string_append(logfile, "/profanity/logs/profanity.log");
-    gchar *result = strdup(logfile->str);
-    g_free(xdg_data);
-    g_string_free(logfile, TRUE);
-
-    return result;
-}
-
-gchar *
 files_get_accounts_file(void)
 {
     gchar *xdg_data = xdg_get_data_home();
diff --git a/src/files.h b/src/files.h
index 5c34deaa..fc33f208 100644
--- a/src/files.h
+++ b/src/files.h
@@ -24,8 +24,6 @@
 #define FILES_H
 
 void files_create_directories(void);
-gchar* files_get_preferences_file(void);
-gchar* files_get_log_file(void);
 gchar* files_get_themes_dir(void);
 gchar* files_get_accounts_file(void);
 
diff --git a/src/log.c b/src/log.c
index 1fbdf72b..38e5a494 100644
--- a/src/log.c
+++ b/src/log.c
@@ -63,7 +63,7 @@ static gboolean _key_equals(void *key1, void *key2);
 static char * _get_log_filename(const char * const other, const char * const login,
     GDateTime *dt, gboolean create);
 static gchar * _get_chatlog_dir(void);
-
+static gchar * _get_log_file(void);
 static void _rotate_log_file(void);
 
 void
@@ -119,7 +119,7 @@ log_init(log_level_t filter)
 {
     level_filter = filter;
     tz = g_time_zone_new_local();
-    gchar *log_file = files_get_log_file();
+    gchar *log_file = _get_log_file();
     logp = fopen(log_file, "a");
     g_free(log_file);
 }
@@ -143,7 +143,7 @@ log_msg(log_level_t level, const char * const area, const char * const msg)
     if (level >= level_filter) {
         struct stat st;
         int result;
-        gchar *log_file = files_get_log_file();
+        gchar *log_file = _get_log_file();
         dt = g_date_time_new_now(tz);
 
         gchar *date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S");
@@ -165,7 +165,7 @@ log_msg(log_level_t level, const char * const area, const char * const msg)
 static void
 _rotate_log_file(void)
 {
-    gchar *log_file = files_get_log_file();
+    gchar *log_file = _get_log_file();
     size_t len = strlen(log_file);
     char *log_file_new = malloc(len + 3);
 
@@ -399,3 +399,15 @@ _get_chatlog_dir(void)
     return result;
 }
 
+static gchar *
+_get_log_file(void)
+{
+    gchar *xdg_data = xdg_get_data_home();
+    GString *logfile = g_string_new(xdg_data);
+    g_string_append(logfile, "/profanity/logs/profanity.log");
+    gchar *result = strdup(logfile->str);
+    g_free(xdg_data);
+    g_string_free(logfile, TRUE);
+
+    return result;
+}