From 26c5b4d8312621f5136e5dd2d975d0c2b982924e Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 27 Apr 2024 11:33:00 +0200 Subject: [PATCH] implemented the command handler --- src/chat/main/client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chat/main/client.c b/src/chat/main/client.c index 3abad40..31206fa 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -95,6 +95,7 @@ int main(void) pthread_t thread_buffer; pthread_t thread_getline; why2_bool ssqc = 0; + char *cmd_arg = NULL; //DEFINE SERVER ADDRESS struct sockaddr_in server_addr; @@ -161,11 +162,11 @@ int main(void) //TODO: Remove accents - if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\n") == 0) //USER REQUESTED PROGRAM EXIT + if (command(line, WHY2_CHAT_COMMAND_EXIT, &cmd_arg)) //USER REQUESTED PROGRAM EXIT { printf("Exiting...\n"); exit_client(0); - } else if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\n") == 0) + } else if (command(line, WHY2_CHAT_COMMAND_HELP, &cmd_arg)) { printf ( @@ -190,6 +191,7 @@ int main(void) free(line); } + why2_deallocate(cmd_arg); why2_chat_deallocate_keys(); //DEALLOCATE GETTERS FOR KEYS why2_clean_memory(""); //RUN GARBAGE COLLECTOR