about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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/bounce.h
index 1c47094..aac414f 100644
--- a/bounce.h
+++ b/bounce.h
@@ -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);