From 4e11e2960ba4e10e3fba61abed2e97c745581245 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 5 Oct 2008 00:47:35 -0700 Subject: command: fix return status This got broken when listHandlerFunc was removed. Since we no longer need it and it's confusing, remove processCommandInternal and just use process_command. --- src/command.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/command.c b/src/command.c index cc5f615c7..6ce5cbed5 100644 --- a/src/command.c +++ b/src/command.c @@ -1357,24 +1357,19 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd, return cmd; } -static int processCommandInternal(int fd, mpd_unused int *permission, - char *commandString, struct strnode *cmdnode) +int processCommand(int fd, int *perm, char *commandString) { int argc; char *argv[COMMAND_ARGV_MAX] = { NULL }; CommandEntry *cmd; int ret = -1; - argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX); - - if (argc == 0) + if (!(argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX))) return 0; - if ((cmd = getCommandEntryAndCheckArgcAndPermission(fd, permission, - argc, argv))) { - if (!cmdnode) - ret = cmd->handler(fd, permission, argc, argv); - } + cmd = getCommandEntryAndCheckArgcAndPermission(fd, perm, argc, argv); + if (cmd) + ret = cmd->handler(fd, perm, argc, argv); current_command = NULL; @@ -1392,7 +1387,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 = processCommand(fd, permission, cur->data); DEBUG("processListOfCommands: command returned %i\n", ret); if (ret != 0 || (*expired) != 0) goto out; @@ -1406,11 +1401,6 @@ out: return ret; } -int processCommand(int fd, int *permission, char *commandString) -{ - return processCommandInternal(fd, permission, commandString, NULL); -} - mpd_fprintf_ void commandError(int fd, int error, const char *fmt, ...) { va_list args; -- cgit v1.2.3