summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-03-29 18:00:29 -0400
committerJune McEnroe <june@causal.agency>2022-03-29 18:00:29 -0400
commit86a34c39e41c3d179214f267b7a1ec0259a1c609 (patch)
tree012904439c029937da11b972fe79d9b371b6f810
parentHandle CAP REQ causal.agency/passive after registration (diff)
downloadpounce-86a34c39e41c3d179214f267b7a1ec0259a1c609.tar.gz
pounce-86a34c39e41c3d179214f267b7a1ec0259a1c609.zip
Replace ORIGIN #define with clientOrigin variable
-rw-r--r--bounce.c4
-rw-r--r--bounce.h4
-rw-r--r--client.c30
-rw-r--r--state.c8
4 files changed, 27 insertions, 19 deletions
diff --git a/bounce.c b/bounce.c
index e9fcd0b..de455d4 100644
--- a/bounce.c
+++ b/bounce.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2019  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -413,7 +413,7 @@ int main(int argc, char *argv[]) {
 				if (revents & POLLOUT) {
 					clientConsume(client);
 					if (now - client->idle >= IdleTime) {
-						clientFormat(client, "PING :%s\r\n", ORIGIN);
+						clientFormat(client, "PING :%s\r\n", clientOrigin);
 					}
 				}
 				if (revents & POLLIN) clientRecv(client);
diff --git a/bounce.h b/bounce.h
index 8e6ed09..d714f97 100644
--- a/bounce.h
+++ b/bounce.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2019  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,6 @@
 #endif
 
 #define SOURCE_URL "https://git.causal.agency/pounce"
-#define ORIGIN "irc.invalid"
 
 #define BIT(x) x##Bit, x = 1 << x##Bit, x##Bit_ = x##Bit
 #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
@@ -226,6 +225,7 @@ struct Client {
 	size_t len;
 };
 extern enum Cap clientCaps;
+extern char *clientOrigin;
 extern char *clientPass;
 extern char *clientAway;
 struct Client *clientAlloc(int sock, struct tls *tls);
diff --git a/client.c b/client.c
index 6d6268d..e364a5a 100644
--- a/client.c
+++ b/client.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2019  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -43,6 +43,7 @@
 #include "bounce.h"
 
 enum Cap clientCaps = CapServerTime | CapConsumer | CapPassive | CapSTS;
+char *clientOrigin = "irc.invalid";
 char *clientPass;
 char *clientAway;
 
@@ -131,7 +132,7 @@ static void passRequired(struct Client *client) {
 		client,
 		":%s 464 * :Password incorrect\r\n"
 		"ERROR :Password incorrect\r\n",
-		ORIGIN
+		clientOrigin
 	);
 	client->error = true;
 }
@@ -210,12 +211,12 @@ static void handleCap(struct Client *client, struct Message *msg) {
 			if (avail & CapCapNotify) client->caps |= CapCapNotify;
 			clientFormat(
 				client, ":%s CAP * LS :%s\r\n",
-				ORIGIN, capList(avail, values)
+				clientOrigin, capList(avail, values)
 			);
 		} else {
 			clientFormat(
 				client, ":%s CAP * LS :%s\r\n",
-				ORIGIN, capList(avail, NULL)
+				clientOrigin, capList(avail, NULL)
 			);
 		}
 
@@ -230,19 +231,26 @@ static void handleCap(struct Client *client, struct Message *msg) {
 				activeDecr(client);
 			}
 			client->caps |= caps;
-			clientFormat(client, ":%s CAP * ACK :%s\r\n", ORIGIN, msg->params[1]);
+			clientFormat(
+				client, ":%s CAP * ACK :%s\r\n",
+				clientOrigin, msg->params[1]
+			);
 		} else {
-			clientFormat(client, ":%s CAP * NAK :%s\r\n", ORIGIN, msg->params[1]);
+			clientFormat(
+				client, ":%s CAP * NAK :%s\r\n",
+				clientOrigin, msg->params[1]);
 		}
 
 	} else if (!strcmp(msg->params[0], "LIST")) {
 		clientFormat(
 			client, ":%s CAP * LIST :%s\r\n",
-			ORIGIN, capList(client->caps, NULL)
+			clientOrigin, capList(client->caps, NULL)
 		);
 
 	} else {
-		clientFormat(client, ":%s 410 * :Invalid CAP subcommand\r\n", ORIGIN);
+		clientFormat(
+			client, ":%s 410 * :Invalid CAP subcommand\r\n", clientOrigin
+		);
 	}
 }
 
@@ -254,16 +262,16 @@ static void handleAuthenticate(struct Client *client, struct Message *msg) {
 	} else if (cert && !strcmp(msg->params[0], "+")) {
 		clientFormat(
 			client, ":%s 900 * %s * :You are now logged in as *\r\n",
-			ORIGIN, stateEcho()
+			clientOrigin, stateEcho()
 		);
 		clientFormat(
 			client, ":%s 903 * :SASL authentication successful\r\n",
-			ORIGIN
+			clientOrigin
 		);
 	} else {
 		clientFormat(
 			client, ":%s 904 * :SASL authentication failed\r\n",
-			ORIGIN
+			clientOrigin
 		);
 	}
 }
diff --git a/state.c b/state.c
index cb9419d..c3fc96c 100644
--- a/state.c
+++ b/state.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2019  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -393,7 +393,7 @@ void stateSync(struct Client *client) {
 		client,
 		":%s NOTICE %s :"
 		"pounce is GPLv3 fwee softwawe ^w^  code is avaiwable fwom %s\r\n",
-		ORIGIN, self.nick, SOURCE_URL
+		clientOrigin, self.nick, SOURCE_URL
 	);
 
 	clientFormat(
@@ -444,7 +444,7 @@ void stateSync(struct Client *client) {
 
 	clientFormat(
 		client, ":%s 422 %s :MOTD File is missing\r\n",
-		ORIGIN, self.nick
+		clientOrigin, self.nick
 	);
 
 	if (chans.len) assert(self.origin);
@@ -454,7 +454,7 @@ void stateSync(struct Client *client) {
 		if (chan->topic) {
 			clientFormat(
 				client, ":%s 332 %s %s :%s\r\n",
-				ORIGIN, self.nick, chan->name, chan->topic
+				clientOrigin, self.nick, chan->name, chan->topic
 			);
 		}
 		if (stateNoNames) continue;