aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-22 09:59:01 +0200
committerMax Kellermann <max@duempel.org>2008-10-22 09:59:01 +0200
commit84d0f56eaf58b5628ac41bb34b449466ef10f743 (patch)
tree26dac689d742310643580bded26fc6b34125cea7
parent4b4f7df93383d6e8c9c579d21aa5fa33c38287db (diff)
downloadmpd-84d0f56eaf58b5628ac41bb34b449466ef10f743.tar.gz
mpd-84d0f56eaf58b5628ac41bb34b449466ef10f743.tar.xz
mpd-84d0f56eaf58b5628ac41bb34b449466ef10f743.zip
command: make command pointers constant
The command pointers which are passed around aren't being modified - in fact, no command pointer must be modified once it has been added to the commandList.
-rw-r--r--src/command.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c
index a13a00250..014d3cd6a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1192,10 +1192,10 @@ static int handleCommands(struct client *client,
{
const unsigned permission = client_get_permission(client);
ListNode *node = commandList->firstNode;
- struct command *cmd;
+ const struct command *cmd;
while (node != NULL) {
- cmd = (struct command *) node->data;
+ cmd = (const struct command *) node->data;
if (cmd->reqPermission == (permission & cmd->reqPermission)) {
client_printf(client, "command: %s\n", cmd->cmd);
}
@@ -1211,10 +1211,10 @@ static int handleNotcommands(struct client *client,
{
const unsigned permission = client_get_permission(client);
ListNode *node = commandList->firstNode;
- struct command *cmd;
+ const struct command *cmd;
while (node != NULL) {
- cmd = (struct command *) node->data;
+ cmd = (const struct command *) node->data;
if (cmd->reqPermission != (permission & cmd->reqPermission)) {
client_printf(client, "command: %s\n", cmd->cmd);
@@ -1345,8 +1345,9 @@ void finishCommands(void)
freeList(commandList);
}
-static int checkArgcAndPermission(struct command *cmd, struct client *client,
- unsigned permission, int argc, char *argv[])
+static int
+checkArgcAndPermission(const struct command *cmd, struct client *client,
+ unsigned permission, int argc, char *argv[])
{
int min = cmd->min + 1;
int max = cmd->max + 1;
@@ -1382,13 +1383,13 @@ static int checkArgcAndPermission(struct command *cmd, struct client *client,
return 0;
}
-static struct command *getCommandEntryAndCheckArgcAndPermission(struct client *client,
- unsigned permission,
- int argc,
- char *argv[])
+static const struct command *
+getCommandEntryAndCheckArgcAndPermission(struct client *client,
+ unsigned permission,
+ int argc, char *argv[])
{
static char unknown[] = "";
- struct command *cmd;
+ const struct command *cmd;
current_command = unknown;
@@ -1415,7 +1416,7 @@ int processCommand(struct client *client, char *commandString)
{
int argc;
char *argv[COMMAND_ARGV_MAX] = { NULL };
- struct command *cmd;
+ const struct command *cmd;
int ret = -1;
if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX)))