aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:51:59 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:51:59 +0200
commit54371add1349e72684506868f72ee4919fd69b0a (patch)
tree832d83955a37152e6ce22fe6a796a4b32138558d /src/command.c
parent4ddc0a48e2e53acc58990ec72e907a136e51d77e (diff)
downloadmpd-54371add1349e72684506868f72ee4919fd69b0a.tar.gz
mpd-54371add1349e72684506868f72ee4919fd69b0a.tar.xz
mpd-54371add1349e72684506868f72ee4919fd69b0a.zip
command: added command_success() and command_error()
These two functions take a client struct instead of the file descriptor. We will now begin passing the client struct around instead of a raw file descriptor (which needed a linear lookup in the client list to be useful).
Diffstat (limited to '')
-rw-r--r--src/command.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 9b579e37d..2b81aaf92 100644
--- a/src/command.c
+++ b/src/command.c
@@ -186,6 +186,34 @@ static void command_error_va(int fd, int error, const char *fmt, va_list args)
}
}
+void command_success(struct client *client)
+{
+ client_puts(client, "OK\n");
+}
+
+static void command_error_v(struct client *client, int error,
+ const char *fmt, va_list args)
+{
+ assert(client != NULL);
+ assert(current_command != NULL);
+
+ client_printf(client, "ACK [%i@%i] {%s} ",
+ (int)error, command_listNum, current_command);
+ client_vprintf(client, fmt, args);
+ client_puts(client, "\n");
+
+ current_command = NULL;
+}
+
+mpd_fprintf_ void command_error(struct client *client, int error,
+ const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ command_error_v(client, error, fmt, args);
+ va_end(args);
+}
+
static int mpd_fprintf__ check_uint32(int fd, mpd_uint32 *dst,
const char *s, const char *fmt, ...)
{