summaryrefslogtreecommitdiff
path: root/server_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'server_network.c')
-rw-r--r--server_network.c66
1 files changed, 10 insertions, 56 deletions
diff --git a/server_network.c b/server_network.c
index 6fc84d7..b7694b1 100644
--- a/server_network.c
+++ b/server_network.c
@@ -289,7 +289,8 @@ int uid_handler(struct string sender, uint64_t argc, struct string *argv) {
.ident = ident,
.ip = ip,
.realname = realname,
- .metadata = (struct table){.array = malloc(0), .len = 0},
+ .opertype = {.data = malloc(0), .len = 0},
+ .metadata = {.array = malloc(0), .len = 0},
};
if (set_table_index(&user_list, argv[0], user) != 0)
@@ -338,6 +339,7 @@ int opertype_handler(struct string sender, uint64_t argc, struct string *argv) {
return 1;
}
+ free(user->opertype.data);
struct string opertype = {.data = malloc(argv[0].len), .len = argv[0].len};
if (!opertype.data) {
WRITES(2, STRING("OOM! (opertype_handler)\n"));
@@ -354,47 +356,10 @@ int opertype_handler(struct string sender, uint64_t argc, struct string *argv) {
}
int quit_handler(struct string sender, uint64_t argc, struct string *argv) {
- struct user_info *info = remove_table_index(&user_list, sender);
- if (!info) {
- WRITES(2, STRING("QUIT: Unknown user!\n"));
- 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, STRING("1HC000001"))) {
- SENDCLIENT(STRING(":"));
- SENDCLIENT(info->nick);
- SENDCLIENT(STRING("!"));
- SENDCLIENT(info->ident);
- SENDCLIENT(STRING("@"));
- SENDCLIENT(info->vhost);
- if (argc >= 1) {
- SENDCLIENT(STRING(" QUIT :"));
- SENDCLIENT(argv[0]);
- SENDCLIENT(STRING("\r\n"));
- } else {
- SENDCLIENT(STRING(" QUIT\r\n"));
- }
- }
-
- remove_table_index(&(chan_info->user_list), sender);
- }
-
- free(info->server.data);
- free(info->nick.data);
- if (info->opertype.len)
- free(info->opertype.data);
-
- // TODO: metadata
- free(info->metadata.array);
- free(info->realname.data);
- free(info->hostname.data);
- free(info->ip.data);
- free(info->vhost.data);
- free(info);
-
- return 0;
+ if (argc < 1)
+ return remove_user(sender, (struct string){0});
+ else
+ return remove_user(sender, argv[0]);
}
int kill_handler(struct string sender, uint64_t argc, struct string *argv) {
@@ -452,6 +417,8 @@ int kill_handler(struct string sender, uint64_t argc, struct string *argv) {
SEND(STRING("\n"));
}
}
+ } else {
+ return remove_user(argv[0], argv[1]);
}
return 0;
@@ -620,20 +587,7 @@ int squit_handler(struct string sender, uint64_t argc, struct string *argv) {
for (uint64_t i = 0; i < user_list.len;) {
struct user_info *info = user_list.array[i].ptr;
if (argv[0].len == info->server.len && memcmp(argv[0].data, info->server.data, argv[0].len) == 0) {
- remove_table_index(&user_list, user_list.array[i].name);
-
- free(info->server.data);
- free(info->nick.data);
- if (info->opertype.len)
- free(info->opertype.data);
-
- // TODO: metadata
- free(info->metadata.array);
- free(info->realname.data);
- free(info->hostname.data);
- free(info->ip.data);
- free(info->vhost.data);
- free(info);
+ remove_user(user_list.array[i].name, STRING("*.net *.split"));
} else {
i++; // removal of the user from the table shifts the next user into place for us
}