From d01ba3e141977e2cb3a39f5498c46fdb2d129241 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 31 Jan 2025 16:20:28 +0100 Subject: [PATCH] defined why2_chat_init_authority --- src/chat/config.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/chat/config.c b/src/chat/config.c index 5d1d78a..443051f 100644 --- a/src/chat/config.c +++ b/src/chat/config.c @@ -137,6 +137,24 @@ void why2_chat_init_client_config(void) init_config(WHY2_CHAT_CONFIG_CLIENT); } +void why2_chat_init_authority(void) +{ + //CREATE USER CONFIG FOLDER [THIS SHOULDN'T HAPPEN ON CLIENT, BUT IT'S NEEDED ON FRESH SERVERS] + why2_directory(); + + //GET THE CONFIG TYPE + char *buffer = why2_malloc(strlen(WHY2_CONFIG_DIR) + strlen(WHY2_CHAT_AUTHORITY_DIR) + 2); + sprintf(buffer, "%s/%s", WHY2_CONFIG_DIR, WHY2_CHAT_AUTHORITY_DIR); + + char *path = why2_replace(buffer, "{HOME}", getenv("HOME")); + + if (access(path, R_OK) != 0) mkdir(path, 0700); //DIRECTORY DOESN'T EXIST; CREATE IT + + //DEALLOCATION + why2_deallocate(path); + why2_deallocate(buffer); +} + char *why2_chat_server_config(char *key) { return config(key, SERVER);