aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-23 18:51:14 +0100
committerMax Kellermann <max@duempel.org>2009-01-23 18:51:14 +0100
commit48d3404727e78c64c58fabcc45c7dd2116ca798a (patch)
treeac2909165e4032dbb2af44c6c4a03297077d47bf /src/command.c
parent0e5af7d0f6406ada62500a30cedf0089073ee8cb (diff)
downloadmpd-48d3404727e78c64c58fabcc45c7dd2116ca798a.tar.gz
mpd-48d3404727e78c64c58fabcc45c7dd2116ca798a.tar.xz
mpd-48d3404727e78c64c58fabcc45c7dd2116ca798a.zip
commands: don't advertise "sticker" unless configured
In the return value of the "commands" command, don't list the "sticker" command if no sticker file is configured.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/command.c b/src/command.c
index 224c2e0f4..af19b29d1 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1550,6 +1550,17 @@ static const struct command commands[] = {
static const unsigned num_commands = sizeof(commands) / sizeof(commands[0]);
+static bool
+command_available(const struct command *cmd)
+{
+#ifdef ENABLE_SQLITE
+ if (strcmp(cmd->cmd, "sticker") == 0)
+ return sticker_enabled();
+#endif
+
+ return true;
+}
+
/* don't be fooled, this is the command handler for "commands" command */
static enum command_return
handle_commands(struct client *client,
@@ -1561,7 +1572,8 @@ handle_commands(struct client *client,
for (unsigned i = 0; i < num_commands; ++i) {
cmd = &commands[i];
- if (cmd->permission == (permission & cmd->permission))
+ if (cmd->permission == (permission & cmd->permission) &&
+ command_available(cmd))
client_printf(client, "command: %s\n", cmd->cmd);
}