about 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;
 	}
2019-11-09Avoid the reserved _A names with BIT macroJune McEnroe 2019-11-09Define macro for bit flag enumsJune McEnroe 2019-11-08Check that password is hashedJune McEnroe 2019-11-08Avoid calling getopt_long again after it returns -1June McEnroe On GNU, calling getopt_long again will reset optind back to the first non-option argument, which would cause an infinite loop of reading the same configurtion file forever. 2019-11-08Only change AWAY status for registered clientsJune McEnroe Turns out I did eventually fix this, because I may want to implement "passive clients" for logging or notification stuff, which wouldn't affect AWAY status either. 2019-11-07Just write the example normallyJune McEnroe 2019-11-07Include path in readlinkat errorJune McEnroe 2019-11-07Call clientConsume before clientRecvJune McEnroe This might reduce the frequency of a client getting its own message back because it was behind in the ring when it sent it. 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe