diff options
author | June McEnroe <june@causal.agency> | 2019-10-23 00:16:31 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-10-23 00:16:31 -0400 |
commit | e0d292cb2fd1b535d601cfc45c370533919c8420 (patch) | |
tree | d58f25c659ca993aa7c3c7716010f2505f120985 /server.c | |
parent | Add README.7 (diff) | |
download | pounce-e0d292cb2fd1b535d601cfc45c370533919c8420.tar.gz pounce-e0d292cb2fd1b535d601cfc45c370533919c8420.zip |
Add state
Diffstat (limited to '')
-rw-r--r-- | server.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/server.c b/server.c index 4c22287..628ced7 100644 --- a/server.c +++ b/server.c @@ -148,3 +148,35 @@ void serverLogin( } format("NICK %s\r\nUSER %s 0 * :%s\r\n", nick, user, real); } + +void serverAuth(void) { + format("AUTHENTICATE PLAIN\r\nAUTHENTICATE %s\r\nCAP END\r\n", authBase64); +} + +void serverJoin(const char *join) { + format("JOIN :%s\r\n", join); +} + +void serverRecv(void) { + static char buf[4096]; + static size_t len; + + ssize_t read = tls_read(client, &buf[len], sizeof(buf) - len); + if (read == TLS_WANT_POLLIN || read == TLS_WANT_POLLOUT) return; + if (read < 0) errx(EX_IOERR, "tls_read: %s", tls_error(client)); + if (!read) errx(EX_DATAERR, "tls_read: eof"); + len += read; + + char *crlf; + char *line = buf; + for (;;) { + crlf = memmem(line, &buf[len] - line, "\r\n", 2); + if (!crlf) break; + crlf[0] = '\0'; + // TODO: Add line to ring if stateReady(). + stateParse(line); + line = crlf + 2; + } + len -= line - buf; + memmove(buf, line, len); +} |