summaryrefslogtreecommitdiff
path: root/client_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'client_network.c')
-rw-r--r--client_network.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/client_network.c b/client_network.c
index bbeaec3..ca82379 100644
--- a/client_network.c
+++ b/client_network.c
@@ -43,8 +43,6 @@
#include "table.h"
#include "tls.h"
-// TODO: Lock sends (everywhere)
-
struct table client_network_commands = {0};
struct string client_nick = {0};
uint8_t client_connected;
@@ -111,7 +109,7 @@ int client_user_handler(uint64_t argc, struct string *argv) {
SENDCLIENT(STRING(":hax.irc.andrewyu.org 001 "));
SENDCLIENT(client_nick);
- SENDCLIENT(STRING(" :Welcome to the RunxiIRC Network\r\n"));
+ SENDCLIENT(STRING(" :Welcome to the Rexnet IRC Network\r\n"));
SENDCLIENT(STRING(":hax.irc.andrewyu.org 002 "));
SENDCLIENT(client_nick);
SENDCLIENT(STRING(" :Your host is hax.irc.andrewyu.org, running a totally not sus IRCd\r\n"));
@@ -153,7 +151,6 @@ int client_join_handler(uint64_t argc, struct string *argv) {
}
current_time = (uint64_t)ctime;
}
- snprintf(current_time_nulstr, 22, "%lu", time(NULL));
struct string channels = argv[0];
while (1) {
@@ -174,6 +171,8 @@ int client_join_handler(uint64_t argc, struct string *argv) {
}
*channel_info = (struct channel_info){
.ts = current_time,
+ .topic = {.data = malloc(0), .len = 0},
+ .topic_ts = 0,
.modes = {.array = malloc(0), .len = 0},
.user_list = {.array = malloc(0), .len = 0},
.metadata = {.array = malloc(0), .len = 0},
@@ -181,33 +180,37 @@ int client_join_handler(uint64_t argc, struct string *argv) {
set_table_index(&channel_list, channels, channel_info);
}
+ if (channel_info->ts < current_time)
+ current_time = channel_info->ts;
- set_table_index(&(channel_info->user_list), STRING("1HC000001"), get_table_index(user_list, STRING("1HC000001"))); // TODO: Actually add local users to that
+ snprintf(current_time_nulstr, 22, "%lu", current_time);
SENDCLIENT(STRING(":"));
SENDCLIENT(client_nick);
SENDCLIENT(STRING("!e@e JOIN :"));
SENDCLIENT(channels);
+ for (uint64_t i = 0; i < channel_info->user_list.len; i++) {
+ struct string user;
+ struct user_info *info = channel_info->user_list.array[i].ptr;
+ if (info)
+ user = info->nick;
+ else
+ user = user_list.array[i].name;
+
+ if (i%5 != 0) {
+ SENDCLIENT(STRING(" "));
+ SENDCLIENT(user);
+ } else {
+ SENDCLIENT(STRING("\r\n"));
+ SENDCLIENT(STRING(":hax.irc.andrewyu.org 353 "));
+ SENDCLIENT(client_nick);
+ SENDCLIENT(STRING(" = "));
+ SENDCLIENT(channels);
+ SENDCLIENT(STRING(" :"));
+ SENDCLIENT(user);
+ }
+ }
SENDCLIENT(STRING("\r\n"));
- SENDCLIENT(STRING(":hax.irc.andrewyu.org 332 "));
- SENDCLIENT(client_nick);
- SENDCLIENT(STRING(" "));
- SENDCLIENT(channels);
- SENDCLIENT(STRING(" :\r\n")); // TODO: Actual topic
- SENDCLIENT(STRING(":hax.irc.andrewyu.org 333 "));
- SENDCLIENT(client_nick);
- SENDCLIENT(STRING(" "));
- SENDCLIENT(channels);
- SENDCLIENT(STRING(" "));
- SENDCLIENT(client_nick); // TODO: Actual channel creator
- SENDCLIENT(STRING(" :"));
- SENDCLIENT(((struct string){.data = current_time_nulstr, .len = strlen(current_time_nulstr)}));
- SENDCLIENT(STRING("\r\n"));
- SENDCLIENT(STRING(":hax.irc.andrewyu.org 353 "));
- SENDCLIENT(client_nick);
- SENDCLIENT(STRING(" = "));
- SENDCLIENT(channels);
- SENDCLIENT(STRING(" :\r\n")); // TODO: NAMES list
SENDCLIENT(STRING(":hax.irc.andrewyu.org 366 "));
SENDCLIENT(client_nick);
SENDCLIENT(STRING(" "));
@@ -218,7 +221,9 @@ int client_join_handler(uint64_t argc, struct string *argv) {
SEND(channels);
SEND(STRING(" "));
SEND(((struct string){.data = current_time_nulstr, .len = strlen(current_time_nulstr)}));
- SEND(STRING(" +Cnt :,1HC000001\n"));
+ SEND(STRING(" + :,1HC000001\n"));
+
+ set_table_index(&(channel_info->user_list), STRING("1HC000001"), get_table_index(user_list, STRING("1HC000001"))); // TODO: Actually add local users to user_list
channels.len = oldlen;