Skip to content

Commit 113075e

Browse files
committed
print formatted text (pre wordwrap) instead of raw to log
add new parser2 function for testing removing unusable parser2 function remove test log file
1 parent 189bc5f commit 113075e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
kirc
22
*.a
33
*.o
4+
*.txt

kirc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ static char * olog = NULL; /* log irc stream parh */
3030

3131
/* append string to specified file path */
3232
static void
33-
append_to_file(char *str) {
34-
FILE *out = fopen(olog, "a");
35-
fprintf(out, "%s", str);
33+
printa(char *str) {
34+
FILE *out = fopen(olog, "a");
35+
fprintf(out, "%s", str);
3636
fclose(out);
3737
}
3838

@@ -85,7 +85,7 @@ raw(char *cmd_str, char *fmt, ...) {
8585
va_end(ap);
8686

8787
if (verb) printf("<< %s", cmd_str);
88-
if (olog) append_to_file(cmd_str);
88+
if (olog) printa(cmd_str);
8989

9090
write(conn, cmd_str, strlen(cmd_str));
9191
}
@@ -125,6 +125,8 @@ printw(const char *format, ...) {
125125
vsnprintf(line, IRC_MSG_MAX + 1, format, argptr);
126126
va_end(argptr);
127127

128+
if (olog) printa(line);
129+
128130
for (i = 0; isspace(line[i]); i++) printf("%c", line[i]);
129131

130132
spaceleft = cmax + gutl - (i - 1);
@@ -159,7 +161,6 @@ parser(int sl, char *s) {
159161
o = -1;
160162

161163
if (verb) printf(">> %s", buf_c);
162-
if (olog) append_to_file(buf_c);
163164

164165
if (!strncmp(buf_c, "PING", 4)) {
165166
buf_c[1] = 'O';

0 commit comments

Comments
 (0)