summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-06 17:18:05 -0500
committerJune McEnroe <june@causal.agency>2019-11-06 17:18:05 -0500
commitd8cd384622fe8b00c7c257814cfcfec59d1e928e (patch)
tree9322caa699402b6f0dc92dcbd3c6fe444f248d1c
parentDeclare more missing functions and deal with lack of SO_NOSIGPIPE (diff)
downloadpounce-d8cd384622fe8b00c7c257814cfcfec59d1e928e.tar.gz
pounce-d8cd384622fe8b00c7c257814cfcfec59d1e928e.zip
Use #defines for constant strings
GCC hates declaring static consts in headers and not using them, for
some stupid reason.
-rw-r--r--bounce.h6
-rw-r--r--client.c12
-rw-r--r--state.c4
3 files changed, 11 insertions, 11 deletions
diff --git a/bounce.h b/bounce.h
index 37cfc7c..08313d5 100644
--- a/bounce.h
+++ b/bounce.h
@@ -27,13 +27,13 @@
 #define CERTBOT_PATH "/usr/local/etc/letsencrypt"
 #endif
 
+#define SOURCE_URL "https://code.causal.agency/june/pounce"
+#define ORIGIN "irc.invalid"
+
 #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
 
 typedef unsigned char byte;
 
-static const char *SourceURL = "https://code.causal.agency/june/pounce";
-static const char *Origin = "irc.invalid";
-
 bool verbose;
 
 enum { ParamCap = 15 };
diff --git a/client.c b/client.c
index 8e4ed8e..3e8b15b 100644
--- a/client.c
+++ b/client.c
@@ -93,7 +93,7 @@ static void passRequired(struct Client *client) {
 		client,
 		":%s 464 * :Password incorrect\r\n"
 		"ERROR :Password incorrect\r\n",
-		Origin
+		ORIGIN
 	);
 	client->error = true;
 }
@@ -150,25 +150,25 @@ static void handleCap(struct Client *client, struct Message *msg) {
 
 	} else if (!strcmp(msg->params[0], "LS")) {
 		if (client->need) client->need |= NeedCapEnd;
-		clientFormat(client, ":%s CAP * LS :server-time\r\n", Origin);
+		clientFormat(client, ":%s CAP * LS :server-time\r\n", ORIGIN);
 
 	} else if (!strcmp(msg->params[0], "REQ") && msg->params[1]) {
 		if (client->need) client->need |= NeedCapEnd;
 		if (!strcmp(msg->params[1], "server-time")) {
 			client->serverTime = true;
-			clientFormat(client, ":%s CAP * ACK :server-time\r\n", Origin);
+			clientFormat(client, ":%s CAP * ACK :server-time\r\n", ORIGIN);
 		} else {
-			clientFormat(client, ":%s CAP * NAK :%s\r\n", Origin, msg->params[1]);
+			clientFormat(client, ":%s CAP * NAK :%s\r\n", ORIGIN, msg->params[1]);
 		}
 
 	} else if (!strcmp(msg->params[0], "LIST")) {
 		clientFormat(
 			client, ":%s CAP * LIST :%s\r\n",
-			Origin, (client->serverTime ? "server-time" : "")
+			ORIGIN, (client->serverTime ? "server-time" : "")
 		);
 
 	} else {
-		clientFormat(client, ":%s 410 * :Invalid CAP subcommand\r\n", Origin);
+		clientFormat(client, ":%s 410 * :Invalid CAP subcommand\r\n", ORIGIN);
 	}
 }
 
diff --git a/state.c b/state.c
index 6486dde..da5c96f 100644
--- a/state.c
+++ b/state.c
@@ -324,7 +324,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, SourceURL
+		ORIGIN, self.nick, SOURCE_URL
 	);
 
 	clientFormat(
@@ -373,7 +373,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
+				ORIGIN, self.nick, chan->name, chan->topic
 			);
 		}
 		if (stateJoinNames) serverFormat("NAMES %s\r\n", chan->name);
>2014-01-17Switch to exclusively using global ctxLukas Fleischer Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-16auth: have cgit calculate login addressJason A. Donenfeld This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16auth: lua string comparisons are time invariantJason A. Donenfeld By default, strings are compared by hash, so we can remove this comment. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16authentication: use hidden form instead of refererJason A. Donenfeld This also gives us some CSRF protection. Note that we make use of the hmac to protect the redirect value. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16auth: add basic authentication filter frameworkJason A. Donenfeld This leverages the new lua support. See filters/simple-authentication.lua for explaination of how this works. There is also additional documentation in cgitrc.5.txt. Though this is a cookie-based approach, cgit's caching mechanism is preserved for authenticated pages. Very plugable and extendable depending on user needs. The sample script uses an HMAC-SHA1 based cookie to store the currently logged in user, with an expiration date. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16t0111: Additions and fixesLukas Fleischer * Rename the capitalize-* filters to dump.* since they also dump the arguments. * Add full argument validation to the email filters. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-16parsing.c: Remove leading space from committerLukas Fleischer