X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=src%2Flib%2Fsubs%2Fjournal.c;h=3fafb6bf1469368033bac35e5cf8171c7574ecd6;hp=56361e971541177d3b38f80c1bcfa35b103a2dfa;hb=6be2e3f8c51a4669c584875fb2e6d69f8a5b5cc2;hpb=221471af6f3b16bac197ec5972b2770157f62176 diff --git a/src/lib/subs/journal.c b/src/lib/subs/journal.c index 56361e971..3fafb6bf1 100644 --- a/src/lib/subs/journal.c +++ b/src/lib/subs/journal.c @@ -69,6 +69,7 @@ static FILE *journal; static void journal_entry(char *fmt, ...) ATTRIBUTE((format (printf, 1, 2))); +static void journal_output_1(struct player *, char *, char *, int); static FILE * journal_open(void) @@ -171,14 +172,35 @@ journal_logout(void) } void -journal_output(struct player *pl, int id, char *output) +journal_output(struct player *pl, char *output) { + static char buf[1024]; + char *s, *e; + if (keep_journal < 2) return; + + for (s = output; (e = strchr(s, '\n')); s = e + 1) { + journal_output_1(pl, buf, s, (int)(e + 1 - s)); + buf[0] = 0; + } + if (strlen(buf) + strlen(s) < 1024) + strcpy(buf + strlen(buf), s); + else { + journal_output_1(pl, buf, s, -1); + buf[0] = 0; + } +} + +void +journal_output_1(struct player *pl, char *buf1, char *buf2, int buf2prec) +{ if (pl && pl->state == PS_PLAYING) - journal_entry("output %d %d %s", pl->cnum, id, output); + journal_entry("output %d %s%.*s", + pl->cnum, buf1, buf2prec, buf2); else - journal_entry("output %p %d %s", pl, id, output); + journal_entry("output %p %s%.*s", + pl, buf1, buf2prec, buf2); } void