summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bounce.c2
-rw-r--r--bounce.h5
-rw-r--r--server.c18
3 files changed, 12 insertions, 13 deletions
diff --git a/bounce.c b/bounce.c
index 33d4e9d..6de5e5d 100644
--- a/bounce.c
+++ b/bounce.c
@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
 	while (!stateReady()) {
 		serverRecv();
 	}
-	if (join) serverJoin(join);
+	if (join) serverFormat("JOIN :%s\r\n", join);
 
 	for (size_t i = 0; i < binds; ++i) {
 		int error = listen(bind[i], 1);
diff --git a/bounce.h b/bouJune McEnroe
2020-02-12Add 378 to list of WHOIS responses/a> @@ -62,9 +62,10 @@ void serverLogin( const char *nick, const char *user, const char *real ); void serverAuth(void); -void serverJoin(const char *join); -void serverSend(const char *ptr, size_t len); void serverRecv(void); +void serverSend(const char *ptr, size_t len); +void serverFormat(const char *format, ...) + __attribute__((format(printf, 1, 2))); char *clientPass; struct Client *clientAlloc(struct tls *tls); diff --git a/server.c b/server.c index 1583d1c..5e23a71 100644 --- a/server.c +++ b/server.c @@ -91,7 +91,7 @@ void serverSend(const char *ptr, size_t len) { } } -static void format(const char *format, ...) { +void serverFormat(const char *format, ...) { char buf[513]; va_list ap; va_start(ap, format); @@ -141,7 +141,7 @@ void serverLogin( const char *pass, const char *auth, const char *nick, const char *user, const char *real ) { - if (pass) format("PASS :%s\r\n", pass); + if (pass) serverFormat("PASS :%s\r\n", pass); if (auth) { byte plain[1 + strlen(auth)]; plain[0] = 0; @@ -149,22 +149,20 @@ void serverLogin( plain[1 + i] = (auth[i] == ':' ? 0 : auth[i]); } authBase64 = base64(plain, sizeof(plain)); - format("CAP REQ :sasl\r\n"); + serverFormat("CAP REQ :sasl\r\n"); } - format("NICK %s\r\nUSER %s 0 * :%s\r\n", nick, user, real); + serverFormat("NICK %s\r\nUSER %s 0 * :%s\r\n", nick, user, real); } void serverAuth(void) { assert(authBase64); - format("AUTHENTICATE PLAIN\r\nAUTHENTICATE %s\r\nCAP END\r\n", authBase64); + serverFormat( + "AUTHENTICATE PLAIN\r\nAUTHENTICATE %s\r\nCAP END\r\n", authBase64 + ); free(authBase64); authBase64 = NULL; } -void serverJoin(const char *join) { - format("JOIN :%s\r\n", join); -} - void serverRecv(void) { static char buf[4096]; static size_t len; @@ -185,7 +183,7 @@ void serverRecv(void) { if (verbose) fprintf(stderr, "\x1B[32m%s\x1B[m\n", line); if (!strncmp(line, "PING ", 5)) { line[1] = 'O'; - format("%s\r\n", line); + serverFormat("%s\r\n", line); } else { // TODO: Add line to ring if stateReady(). stateParse(line);
or non-mentionsJune McEnroe 2020-02-11Take first two words in colorMentionsJune McEnroe 2020-02-11Use time_t for save signatureJune McEnroe 2020-02-11Set self.nick to * initiallyJune McEnroe 2020-02-11Define ColorCap instead of hardcoding 100June McEnroe 2020-02-11Move hash to top of chat.hJune McEnroe 2020-02-11Move base64 out of chat.hJune McEnroe 2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe 2020-02-11Fix whois idle unit calculationJune McEnroe 2020-02-11Cast towupper to wchar_tJune McEnroe 2020-02-11Cast set but unused variables to voidJune McEnroe 2020-02-11Declare strlcatJune McEnroe 2020-02-11Check if VDSUSP existsJune McEnroe 2020-02-11Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe