summary refs log tree commit diff
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--irc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/irc.c b/irc.c
index c1c0e7a..cf8aab7 100644
--- a/irc.c
+++ b/irc.c
@@ -101,6 +101,18 @@ int ircConnect(const char *host, const char *port) {
 	return sock;
 }
 
+static void debug(char dir, const char *line) {
+	if (!self.debug) return;
+	size_t len = strcspn(line, "\r\n");
+	/*uiFormat(
+		Debug, Cold, NULL, "\3%02d%c%c\3 %.*s",
+		Gray, dir, dir, (int)len, line
+	);*/
+	if (!isatty(STDERR_FILENO)) {
+		fprintf(stderr, "%c%c %.*s\n", dir, dir, (int)len, line);
+	}
+}
+
 void ircSend(const char *ptr, size_t len) {
 	assert(client);
 	while (len) {
@@ -119,6 +131,7 @@ void ircFormat(const char *format, ...) {
 	int len = vsnprintf(buf, sizeof(buf), format, ap);
 	va_end(ap);
 	assert((size_t)len < sizeof(buf));
+	debug('<', buf);
 	ircSend(buf, len);
 }
 
@@ -196,6 +209,7 @@ void ircRecv(void) {
 		crlf = memmem(line, &buf[len] - line, "\r\n", 2);
 		if (!crlf) break;
 		*crlf = '\0';
+		debug('>', line);
 		handle(parse(line));
 		line = crlf + 2;
 	}
/td>Rewrite Makefile once more with more organizationJune McEnroe 2019-07-27Reference png.h in bin.7June McEnroe 2019-07-27Revert "Use scheme to style HTMLs"June McEnroe 2019-07-27Remove scheme text linkJune McEnroe 2019-07-26Update Dark.terminalJune McEnroe 2019-07-26Lighten dark whiteJune McEnroe 2019-07-25Add png.3 man pageJune McEnroe 2019-07-25Use scheme to style HTMLsJune McEnroe 2019-07-25Don't match comments in strings in makeJune McEnroe 2019-07-25Generate index.html with links from bin.7June McEnroe 2019-07-24Warn when date has changedJune McEnroe 2019-07-24Add whenJune McEnroe 2019-07-24Remove histedit from bitJune McEnroe