diff options
author | Test_User <hax@andrewyu.org> | 2023-08-09 00:52:47 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2023-08-09 00:52:47 -0400 |
commit | 530d8cd8a6c2d28c1f358dc369613eb9e0e10a71 (patch) | |
tree | f814029e41f0fbf45be36df78ee379f0ac69c968 /general_network.c | |
parent | b557bac23688b304fbab0a766a2e3e93db78f429 (diff) | |
download | coupserv-530d8cd8a6c2d28c1f358dc369613eb9e0e10a71.tar.gz coupserv-530d8cd8a6c2d28c1f358dc369613eb9e0e10a71.zip |
Fix quit, kill, squit
Diffstat (limited to '')
-rw-r--r-- | general_network.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/general_network.c b/general_network.c index 9da36ce..861fadc 100644 --- a/general_network.c +++ b/general_network.c @@ -28,6 +28,7 @@ #include <string.h> #include <limits.h> +#include <stdlib.h> #include "network.h" #include "tls.h" @@ -137,3 +138,44 @@ int PRIVMSG(struct string source, struct string target, struct string message) { return 0; } + +int remove_user(struct string uid, struct string reason) { // If disconnecting the local client, set client_connected = 0 *before* calling this + struct user_info *info = remove_table_index(&user_list, uid); + if (!info) + return 1; + + for (uint64_t i = 0; i < channel_list.len; i++) { // TODO: Use channel list attached to the user (doesn't exist yet) + struct channel_info *chan_info = channel_list.array[i].ptr; + if (has_table_index(chan_info->user_list, uid)) { + if (client_connected && has_table_index(chan_info->user_list, STRING("1HC000001"))) { + SENDCLIENT(STRING(":")); + SENDCLIENT(info->nick); + SENDCLIENT(STRING("!")); + SENDCLIENT(info->ident); + SENDCLIENT(STRING("@")); + SENDCLIENT(info->vhost); + if (reason.len != 0) { + SENDCLIENT(STRING(" QUIT :")); + SENDCLIENT(reason); + SENDCLIENT(STRING("\r\n")); + } else { + SENDCLIENT(STRING(" QUIT\r\n")); + } + } + + remove_table_index(&(chan_info->user_list), uid); + } + } + + free(info->server.data); + free(info->nick.data); + free(info->opertype.data); + free(info->metadata.array); + free(info->realname.data); + free(info->hostname.data); + free(info->ip.data); + free(info->vhost.data); + free(info); + + return 0; +} |