about summary refs log tree commit diff
path: root/command.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-11 22:39:29 -0500
committerJune McEnroe <june@causal.agency>2020-02-11 22:39:29 -0500
commit10ae7bedbd1dac946ee97c3fb27676cde2237621 (patch)
tree9d9f3123d94681ffb9aa90b9c79211343609f1a8 /command.c
parentAdd chroot target (diff)
downloadcatgirl-10ae7bedbd1dac946ee97c3fb27676cde2237621.tar.gz
catgirl-10ae7bedbd1dac946ee97c3fb27676cde2237621.zip
Add -R restricted flag
Diffstat (limited to 'command.c')
-rw-r--r--command.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/command.c b/command.c
index 5cb43cf..3505a5e 100644
--- a/command.c
+++ b/command.c
@@ -194,25 +194,26 @@ static void commandHelp(size_t id, char *params) {
 static const struct Handler {
 	const char *cmd;
 	Command *fn;
+	bool restricted;
 } Commands[] = {
-	{ "/close", commandClose },
-	{ "/copy", commandCopy },
-	{ "/debug", commandDebug },
-	{ "/help", commandHelp },
-	{ "/join", commandJoin },
-	{ "/me", commandMe },
-	{ "/msg", commandMsg },
-	{ "/names", commandNames },
-	{ "/nick", commandNick },
-	{ "/notice", commandNotice },
-	{ "/open", commandOpen },
-	{ "/part", commandPart },
-	{ "/query", commandQuery },
-	{ "/quit", commandQuit },
-	{ "/quote", commandQuote },
-	{ "/topic", commandTopic },
-	{ "/whois", commandWhois },
-	{ "/window", commandWindow },
+	{ "/close", .fn = commandClose },
+	{ "/copy", .fn = commandCopy, .restricted = true },
+	{ "/debug", .fn = commandDebug, .restricted = true },
+	{ "/help", .fn = commandHelp },
+	{ "/join", .fn = commandJoin, .restricted = true },
+	{ "/me", .fn = commandMe },
+	{ "/msg", .fn = commandMsg, .restricted = true },
+	{ "/names", .fn = commandNames },
+	{ "/nick", .fn = commandNick },
+	{ "/notice", .fn = commandNotice },
+	{ "/open", .fn = commandOpen, .restricted = true },
+	{ "/part", .fn = commandPart },
+	{ "/query", .fn = commandQuery, .restricted = true },
+	{ "/quit", .fn = commandQuit },
+	{ "/quote", .fn = commandQuote, .restricted = true },
+	{ "/topic", .fn = commandTopic },
+	{ "/whois", .fn = commandWhois },
+	{ "/window", .fn = commandWindow },
 };
 
 static int compar(const void *cmd, const void *_handler) {
@@ -258,6 +259,9 @@ void command(size_t id, char *input) {
 		const struct Handler *handler = bsearch(
 			cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
 		);
+		if (self.restricted && handler && handler->restricted) {
+			handler = NULL;
+		}
 		if (handler) {
 			if (input) {
 				input += strspn(input, " ");