aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:36:42 +0200
committerMax Kellermann <max@duempel.org>2008-08-29 09:36:42 +0200
commit8b1b82b36374e95bcef8195fcd15e4014e73567d (patch)
tree90efdb2f715a44e2ccc3387e479cf56512225e01 /src/command.c
parent2c8aa8efde879b6b9396aaa06edfa4506c55842e (diff)
downloadmpd-8b1b82b36374e95bcef8195fcd15e4014e73567d.tar.gz
mpd-8b1b82b36374e95bcef8195fcd15e4014e73567d.tar.xz
mpd-8b1b82b36374e95bcef8195fcd15e4014e73567d.zip
client: pass the client struct to processCommand()
Start exporting the client struct as an opaque struct. For now, pass it only to processCommand() and processListOfCommands(), and provide a function to extract the socket handle. Later, we will propagate the pointer to all command implementations, and of course to client_print() etc.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/command.c b/src/command.c
index 7078e781e..f2468d0b1 100644
--- a/src/command.c
+++ b/src/command.c
@@ -34,6 +34,7 @@
#include "ack.h"
#include "audio.h"
#include "dbUtils.h"
+#include "client.h"
#include "os_compat.h"
#define COMMAND_PLAY "play"
@@ -1204,9 +1205,11 @@ static CommandEntry *getCommandEntryFromString(char *string, int *permission)
return cmd;
}
-static int processCommandInternal(int fd, mpd_unused int *permission,
+static int processCommandInternal(struct client *client,
+ mpd_unused int *permission,
char *commandString, struct strnode *cmdnode)
{
+ int fd = client_get_fd(client);
int argc;
char *argv[COMMAND_ARGV_MAX] = { NULL };
CommandEntry *cmd;
@@ -1232,9 +1235,10 @@ static int processCommandInternal(int fd, mpd_unused int *permission,
return ret;
}
-int processListOfCommands(int fd, int *permission, int *expired,
+int processListOfCommands(struct client *client, int *permission, int *expired,
int listOK, struct strnode *list)
{
+ int fd = client_get_fd(client);
struct strnode *cur = list;
int ret = 0;
@@ -1243,7 +1247,7 @@ int processListOfCommands(int fd, int *permission, int *expired,
while (cur) {
DEBUG("processListOfCommands: process command \"%s\"\n",
cur->data);
- ret = processCommandInternal(fd, permission, cur->data, cur);
+ ret = processCommandInternal(client, permission, cur->data, cur);
DEBUG("processListOfCommands: command returned %i\n", ret);
if (ret != 0 || (*expired) != 0)
goto out;
@@ -1257,9 +1261,9 @@ out:
return ret;
}
-int processCommand(int fd, int *permission, char *commandString)
+int processCommand(struct client *client, int *permission, char *commandString)
{
- return processCommandInternal(fd, permission, commandString, NULL);
+ return processCommandInternal(client, permission, commandString, NULL);
}
mpd_fprintf_ void commandError(int fd, int error, const char *fmt, ...)