From 113075e58d9f93b9c5a569f9bf7d439866103fbb Mon Sep 17 00:00:00 2001 From: Michael Czigler Date: Fri, 21 Aug 2020 12:40:16 -0400 Subject: print formatted text (pre wordwrap) instead of raw to log add new parser2 function for testing removing unusable parser2 function remove test log file --- .gitignore | 1 + kirc.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b8c0d04..b1c04eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ kirc *.a *.o +*.txt diff --git a/kirc.c b/kirc.c index 0e40632..870a14c 100644 --- a/kirc.c +++ b/kirc.c @@ -30,9 +30,9 @@ static char * olog = NULL; /* log irc stream parh */ /* append string to specified file path */ static void -append_to_file(char *str) { - FILE *out = fopen(olog, "a"); - fprintf(out, "%s", str); +printa(char *str) { + FILE *out = fopen(olog, "a"); + fprintf(out, "%s", str); fclose(out); } @@ -85,7 +85,7 @@ raw(char *cmd_str, char *fmt, ...) { va_end(ap); if (verb) printf("<< %s", cmd_str); - if (olog) append_to_file(cmd_str); + if (olog) printa(cmd_str); write(conn, cmd_str, strlen(cmd_str)); } @@ -125,6 +125,8 @@ printw(const char *format, ...) { vsnprintf(line, IRC_MSG_MAX + 1, format, argptr); va_end(argptr); + if (olog) printa(line); + for (i = 0; isspace(line[i]); i++) printf("%c", line[i]); spaceleft = cmax + gutl - (i - 1); @@ -159,7 +161,6 @@ parser(int sl, char *s) { o = -1; if (verb) printf(">> %s", buf_c); - if (olog) append_to_file(buf_c); if (!strncmp(buf_c, "PING", 4)) { buf_c[1] = 'O'; -- cgit v1.2.3