aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--kirc.c11
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';