diff --git a/src/chat/config.c b/src/chat/config.c
index b4a3c33..86abf5c 100644
--- a/src/chat/config.c
+++ b/src/chat/config.c
@@ -20,6 +20,7 @@ along with this program. If not, see .
#include
#include
+#include
#include
#include
@@ -31,13 +32,18 @@ along with this program. If not, see .
void why2_chat_init_config(void)
{
- if (access(WHY2_CHAT_CONFIG, R_OK) != 0) //CONFIG DOESN'T EXIST
+ char *path = why2_replace(WHY2_CHAT_CONFIG_DIR "/" WHY2_CHAT_CONFIG_SERVER, "{USER}", getenv("USER"));
+
+ if (access(path, R_OK) != 0) //CONFIG DOESN'T EXIST
{
- char *path = why2_replace(WHY2_CHAT_CONFIG, "{USER}", getenv("USER"));
+ char *config_dir = why2_replace(WHY2_CHAT_CONFIG_DIR, "{USER}", getenv("USER"));
+
+ mkdir(config_dir, 0700);
+
CURL *curl = curl_easy_init();
FILE *file_buffer = why2_fopen(path, "w+");
- curl_easy_setopt(curl, CURLOPT_URL, WHY2_CHAT_CONFIG_URL);
+ curl_easy_setopt(curl, CURLOPT_URL, WHY2_CHAT_CONFIG_SERVER_URL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file_buffer);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, WHY2_CURL_TIMEOUT);
curl_easy_perform(curl);
@@ -45,6 +51,7 @@ void why2_chat_init_config(void)
//CLEANUP
curl_easy_cleanup(curl);
why2_deallocate(path);
+ why2_deallocate(config_dir);
why2_deallocate(file_buffer);
}
}
\ No newline at end of file