From 1b3539a50d29a8956aa0bd2e668681e8afb968c0 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 19 May 2019 16:28:11 +0100 Subject: Announce the start and end of log replay. Also ensure log replay lines finish with CRLF when writing. --- blabouncer.c | 7 +++++++ replay.c | 3 +++ replay.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/blabouncer.c b/blabouncer.c index f250959..0d17468 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -449,6 +449,10 @@ int doreplay(int sourcefd, int replayseconds, struct client *clients, struct set return 1; } + // Announce the start + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Starting log replay....", ircdstrings->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings); + // Replay those lines! for (int i = 0; i < numlines; i++) { if (!readreplayline(replayseconds, i, outgoingmsg, settings->basedir)) { @@ -459,6 +463,9 @@ int doreplay(int sourcefd, int replayseconds, struct client *clients, struct set sendtoclient(sourcefd, outgoingmsg, clients, settings); } + // Announce the end + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Log replay complete.", ircdstrings->ircnick); + return 1; } diff --git a/replay.c b/replay.c index a898a7b..abd55c7 100644 --- a/replay.c +++ b/replay.c @@ -266,6 +266,9 @@ int writereplayline(char *str, char *basedir) { // Prepend the unixtime timestamp snprintf(line, MAXCHAR, "%s %s", timenowstr, str); + // Ensure the line finishes with CRLF + appendcrlf(line); + printf("Complete replay log string to write: '%s', length '%ld'.\n", line, strlen(line)); // Write complete line to file diff --git a/replay.h b/replay.h index 983e05b..169f297 100644 --- a/replay.h +++ b/replay.h @@ -9,6 +9,8 @@ #include #include +#include "functions.h" + #define MAXCHAR 1000 #define TIMELEN 11 // 32-bit unixtime is up to 10 characters (+1 for null char) // TODO - Make this Year 2038 proof #define TIMELENF 11 // [HH:MM:SS] = 10 characters + 1 for null char -- cgit v1.2.3