From 03c8587c676c2860e4a0385a2df39c801cec8679 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 20 Apr 2023 21:35:18 +0200 Subject: [PATCH] implemented user variable in why2_chat_init_config --- src/chat/config.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/chat/config.c b/src/chat/config.c index 9ba6e6a..b4a3c33 100644 --- a/src/chat/config.c +++ b/src/chat/config.c @@ -19,6 +19,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -26,21 +27,24 @@ along with this program. If not, see . #include #include #include +#include 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, "{USER}", getenv("USER")); CURL *curl = curl_easy_init(); - FILE *fileBuffer = why2_fopen(WHY2_CHAT_CONFIG, "w+"); + FILE *file_buffer = why2_fopen(path, "w+"); curl_easy_setopt(curl, CURLOPT_URL, WHY2_CHAT_CONFIG_URL); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fileBuffer); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, file_buffer); curl_easy_setopt(curl, CURLOPT_TIMEOUT, WHY2_CURL_TIMEOUT); curl_easy_perform(curl); //CLEANUP curl_easy_cleanup(curl); - why2_deallocate(fileBuffer); + why2_deallocate(path); + why2_deallocate(file_buffer); } } \ No newline at end of file