MPD client: +mpd_client_send_command_raw()

This commit is contained in:
Přemysl Eric Janouch 2017-06-24 01:43:31 +02:00
parent 3835b6e499
commit 6e9217e5d0
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -1681,8 +1681,9 @@ mpd_client_add_task
static void mpd_client_send_command static void mpd_client_send_command
(struct mpd_client *self, const char *command, ...) ATTRIBUTE_SENTINEL; (struct mpd_client *self, const char *command, ...) ATTRIBUTE_SENTINEL;
/// Avoid calling this method directly if you don't want things to explode
static void 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 // Automatically interrupt idle mode
if (self->idling) if (self->idling)
@ -1694,26 +1695,31 @@ mpd_client_send_commandv (struct mpd_client *self, char **commands)
mpd_client_send_command (self, "noidle", NULL); 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 (); struct str line = str_make ();
for (; *commands; commands++) for (; *fields; fields++)
{ {
if (line.len) if (line.len)
str_append_c (&line, ' '); str_append_c (&line, ' ');
if (mpd_client_must_quote (*commands)) if (mpd_client_must_quote (*fields))
mpd_client_quote (*commands, &line); mpd_client_quote (*fields, &line);
else else
str_append (&line, *commands); str_append (&line, *fields);
} }
mpd_client_send_command_raw (self, line.str);
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);
str_free (&line); str_free (&line);
mpd_client_update_poller (self);
} }
static void static void