From 4a65bec2a5ecd8948b089a7276c01fa139aeb273 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 29 Sep 2017 22:24:54 +1000 Subject: [PATCH] fix motd --- utils/magichat/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/magichat/main.c b/utils/magichat/main.c index 20b60ae..4180b1d 100644 --- a/utils/magichat/main.c +++ b/utils/magichat/main.c @@ -215,12 +215,14 @@ int main(int argc, char **argv) { if (fptr) { fgets(motd, 256, fptr); while (!feof(fptr)) { - if (motd[strlen(buffer) - 1] == '\n') { - motd[strlen(buffer) - 1] = '\0'; + if (motd[strlen(motd) - 1] == '\n') { + motd[strlen(motd) - 1] = '\0'; } snprintf(buffer, 1024, "{\"bbs\": \"SYSTEM\", \"nick\": \"SYSTEM\", \"msg\": \"%s\" }", motd); - send(clients[j]->fd, buffer, strlen(buffer) + 1, 0); + if (send(clients[j]->fd, buffer, strlen(buffer) + 1, 0) == -1) { + perror("send"); + } fgets(motd, 256, fptr); } fclose(fptr);