From 6e9217e5d05d95849fbaa795f92eca4ad86b1507 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sat, 24 Jun 2017 01:43:31 +0200 Subject: MPD client: +mpd_client_send_command_raw() --- liberty-proto.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/liberty-proto.c b/liberty-proto.c index 3726f5c..e54cf10 100644 --- a/liberty-proto.c +++ b/liberty-proto.c @@ -1681,8 +1681,9 @@ mpd_client_add_task static void mpd_client_send_command (struct mpd_client *self, const char *command, ...) ATTRIBUTE_SENTINEL; +/// Avoid calling this method directly if you don't want things to explode static void -mpd_client_send_commandv (struct mpd_client *self, char **commands) +mpd_client_send_command_raw (struct mpd_client *self, const char *raw) { // Automatically interrupt idle mode if (self->idling) @@ -1694,26 +1695,31 @@ mpd_client_send_commandv (struct mpd_client *self, char **commands) mpd_client_send_command (self, "noidle", NULL); } + if (self->on_io_hook) + self->on_io_hook (self->user_data, true, raw); + + str_append (&self->write_buffer, raw); + str_append_c (&self->write_buffer, '\n'); + + mpd_client_update_poller (self); +} + +static void +mpd_client_send_commandv (struct mpd_client *self, char **fields) +{ struct str line = str_make (); - for (; *commands; commands++) + for (; *fields; fields++) { if (line.len) str_append_c (&line, ' '); - if (mpd_client_must_quote (*commands)) - mpd_client_quote (*commands, &line); + if (mpd_client_must_quote (*fields)) + mpd_client_quote (*fields, &line); else - str_append (&line, *commands); + str_append (&line, *fields); } - - if (self->on_io_hook) - self->on_io_hook (self->user_data, true, line.str); - - str_append_c (&line, '\n'); - str_append_str (&self->write_buffer, &line); + mpd_client_send_command_raw (self, line.str); str_free (&line); - - mpd_client_update_poller (self); } static void -- cgit v1.2.3-70-g09d2