From 4fe82b42b6f6fb1a69da2fb2823831e6b3eaa036 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 20 Oct 2024 19:40:09 +0200 Subject: Added mvp implementations of the server and client for testing --- common.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'common.c') diff --git a/common.c b/common.c index d72ead3..232cf64 100644 --- a/common.c +++ b/common.c @@ -1,5 +1,4 @@ #include "common.h" -#include "config.h" #include #include @@ -9,8 +8,8 @@ void writef(char *format, ...) { + char buf[255 + 1]; va_list args; - char buf[BUF_MAX + 1]; va_start(args, format); vsnprintf(buf, sizeof(buf), format, args); @@ -50,8 +49,8 @@ u8 save_message(struct message *msg, FILE *f) if (len == 0) err = 1; - fwrite(&msg->timestamp, sizeof(*msg->timestamp) * MSG_TIMESTAMP_LEN, 1, f); - fwrite(&msg->author, sizeof(*msg->author) * MSG_AUTHOR_LEN, 1, f); + fwrite(&msg->timestamp, sizeof(*msg->timestamp) * MESSAGE_TIMESTAMP_LEN, 1, f); + fwrite(&msg->author, sizeof(*msg->author) * MESSAGE_AUTHOR_LEN, 1, f); fwrite(&len, sizeof(len), 1, f); fputs(msg->text, f); @@ -60,7 +59,7 @@ u8 save_message(struct message *msg, FILE *f) u8 load_message(struct message *msg, FILE *f) { - fread(msg, sizeof(*msg->timestamp) * MSG_TIMESTAMP_LEN + sizeof(*msg->author) * MSG_AUTHOR_LEN, 1, f); + fread(msg, sizeof(*msg->timestamp) * MESSAGE_TIMESTAMP_LEN + sizeof(*msg->author) * MESSAGE_AUTHOR_LEN, 1, f); u16 len; fread(&len, sizeof(len), 1, f); if (len == 0) { -- cgit v1.2.3