diff options
-rw-r--r-- | src/common.c | 11 | ||||
-rw-r--r-- | src/common.h | 3 | ||||
-rw-r--r-- | src/log.c | 11 | ||||
-rw-r--r-- | src/profanity.c | 2 |
4 files changed, 20 insertions, 7 deletions
diff --git a/src/common.c b/src/common.c index 5bdcbc23..59422c73 100644 --- a/src/common.c +++ b/src/common.c @@ -28,22 +28,23 @@ #include <glib.h> -static void _create_dir(char *name); +#include "common.h" void p_slist_free_full(GSList *items, GDestroyNotify free_func) { - g_slist_foreach (items, (GFunc) free_func, NULL); - g_slist_free (items); + g_slist_foreach (items, (GFunc) free_func, NULL); + g_slist_free (items); } void create_config_directory() { GString *dir = g_string_new(getenv("HOME")); g_string_append(dir, "/.profanity"); - _create_dir(dir->str); + create_dir(dir->str); + g_string_free(dir, TRUE); } -void _create_dir(char *name) +void create_dir(char *name) { int e; struct stat sb; diff --git a/src/common.h b/src/common.h index 1408aaa3..3cc5b766 100644 --- a/src/common.h +++ b/src/common.h @@ -50,6 +50,7 @@ typedef enum { #endif void p_slist_free_full(GSList *items, GDestroyNotify free_func); -void create_config_directory(); +void create_config_directory(void); +void create_dir(char *name); #endif diff --git a/src/log.c b/src/log.c index 676dfc0a..6462ca8b 100644 --- a/src/log.c +++ b/src/log.c @@ -21,8 +21,12 @@ */ #include <stdio.h> +#include <stdlib.h> + +#include "glib.h" #include "log.h" +#include "common.h" extern FILE *logp; @@ -33,7 +37,12 @@ void log_msg(const char * const area, const char * const msg) void log_init(void) { - logp = fopen("profanity.log", "a"); + GString *log_file = g_string_new(getenv("HOME")); + g_string_append(log_file, "/.profanity/log"); + create_dir(log_file->str); + g_string_append(log_file, "/profanity.log"); + logp = fopen(log_file->str, "a"); + g_string_free(log_file, TRUE); log_msg(PROF, "Starting Profanity..."); } diff --git a/src/profanity.c b/src/profanity.c index 047cc080..499a9b04 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -22,6 +22,8 @@ #include <string.h> #include <stdlib.h> +#include <stdio.h> + #include <glib.h> #include "profanity.h" |