diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-06-24 01:43:31 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-06-26 03:35:05 +0200 |
commit | 6e9217e5d05d95849fbaa795f92eca4ad86b1507 (patch) | |
tree | 78f143c29eb1c72bf3150c8c86c9dce509e794bd | |
parent | 3835b6e49975039a9f72b8920238f3141e7becea (diff) | |
download | liberty-6e9217e5d05d95849fbaa795f92eca4ad86b1507.tar.gz liberty-6e9217e5d05d95849fbaa795f92eca4ad86b1507.tar.xz liberty-6e9217e5d05d95849fbaa795f92eca4ad86b1507.zip |
MPD client: +mpd_client_send_command_raw()
-rw-r--r-- | liberty-proto.c | 32 |
1 files 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 |