From 9a1fdcc9d24fe8dd20cacee0e25a57c6219651a2 Mon Sep 17 00:00:00 2001 From: Test_User Date: Sat, 2 Sep 2023 21:17:20 -0400 Subject: clear command, some other old stufff I forgot to commit --- client_network.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'client_network.c') diff --git a/client_network.c b/client_network.c index a043338..a0c25be 100644 --- a/client_network.c +++ b/client_network.c @@ -195,6 +195,18 @@ int client_nick_handler(uint64_t argc, struct string *argv) { void *tmp = malloc(argv[0].len); if (!tmp) return 1; + + void *name_for_tables; + if (client_connected) { + name_for_tables = malloc(argv[0].len); + if (!name_for_tables) { + free(tmp); + return 1; + } + + memcpy(name_for_tables, argv[0].data, argv[0].len); + } + memcpy(tmp, argv[0].data, argv[0].len); if (client_connected) { @@ -211,6 +223,17 @@ int client_nick_handler(uint64_t argc, struct string *argv) { client_nick.len = argv[0].len; if (client_connected) { + struct user_info *client = get_table_index(user_list, STRING("1HC000001")); + if (client) { + free(client->nick.data); + client->nick.data = name_for_tables; // Will not be used uninitialized, ignore the compiler's complaint here + client->nick.len = argv[0].len; + } else { + free(name_for_tables); + WRITES(2, STRING("Client connected but client data missing!\n")); + return 1; + } + SEND(STRING(":1HC000001 NICK ")); SEND(client_nick); SEND(STRING(" ")); -- cgit v1.2.3