From c5718dd82fca4fb633846ae232838b477d95d16e Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Mon, 16 Sep 2019 16:57:50 -0400 Subject: Add restricted mode --- input.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'input.c') diff --git a/input.c b/input.c index c4f707e..8be8eaf 100644 --- a/input.c +++ b/input.c @@ -195,28 +195,29 @@ static void inputWindow(struct Tag tag, char *params) { static const struct { const char *command; Handler *handler; + bool limit; } Commands[] = { - { "/close", inputClose }, - { "/help", inputMan }, - { "/join", inputJoin }, - { "/list", inputList }, - { "/man", inputMan }, - { "/me", inputMe }, - { "/move", inputMove }, - { "/names", inputWho }, - { "/nick", inputNick }, - { "/open", inputOpen }, - { "/part", inputPart }, - { "/query", inputQuery }, - { "/quit", inputQuit }, - { "/quote", inputQuote }, - { "/raw", inputRaw }, - { "/topic", inputTopic }, - { "/url", inputURL }, - { "/who", inputWho }, - { "/whois", inputWhois }, - { "/window", inputWindow }, - { "/znc", inputZNC }, + { "/close", .handler = inputClose }, + { "/help", .handler = inputMan }, + { "/join", .handler = inputJoin, .limit = true }, + { "/list", .handler = inputList }, + { "/man", .handler = inputMan }, + { "/me", .handler = inputMe }, + { "/move", .handler = inputMove }, + { "/names", .handler = inputWho }, + { "/nick", .handler = inputNick }, + { "/open", .handler = inputOpen }, + { "/part", .handler = inputPart }, + { "/query", .handler = inputQuery, .limit = true }, + { "/quit", .handler = inputQuit }, + { "/quote", .handler = inputQuote, .limit = true }, + { "/raw", .handler = inputRaw, .limit = true }, + { "/topic", .handler = inputTopic }, + { "/url", .handler = inputURL }, + { "/who", .handler = inputWho }, + { "/whois", .handler = inputWhois }, + { "/window", .handler = inputWindow }, + { "/znc", .handler = inputZNC }, }; static const size_t CommandsLen = sizeof(Commands) / sizeof(Commands[0]); @@ -264,6 +265,10 @@ void input(struct Tag tag, char *input) { for (size_t i = 0; i < CommandsLen; ++i) { if (strcasecmp(command, Commands[i].command)) continue; + if (self.limit && Commands[i].limit) { + uiFmt(tag, UIHot, "%s isn't available in restricted mode", command); + return; + } Commands[i].handler(tag, input); return; } -- cgit 1.4.1-2-gfad0