Logo Search packages:      
Sourcecode: libmpdclient version File versions  Download package

mpd_malloc struct mpd_output* mpd_recv_output ( struct mpd_connection connection  )  [read]

Reads the next mpd_output from the MPD response. Free the return value with mpd_output_free().

Returns:
a mpd_output object on success, NULL on error or end-of-response

Definition at line 44 of file coutput.c.

References mpd_connection::error, mpd_enqueue_pair(), MPD_ERROR_OOM, mpd_output_begin(), mpd_output_feed(), mpd_output_free(), mpd_recv_output(), mpd_recv_pair(), mpd_recv_pair_named(), and mpd_return_pair().

Referenced by mpd_recv_output().

{
      struct mpd_output *output;
      struct mpd_pair *pair;

      pair = mpd_recv_pair_named(connection, "outputid");
      if (pair == NULL)
            return NULL;

      output = mpd_output_begin(pair);
      mpd_return_pair(connection, pair);
      if (output == NULL) {
            mpd_error_code(&connection->error, MPD_ERROR_OOM);
            return NULL;
      }

      while ((pair = mpd_recv_pair(connection)) != NULL &&
             mpd_output_feed(output, pair))
            mpd_return_pair(connection, pair);

      if (mpd_error_is_defined(&connection->error)) {
            assert(pair == NULL);

            mpd_output_free(output);
            return NULL;
      }

      mpd_enqueue_pair(connection, pair);
      return output;
}


Generated by  Doxygen 1.6.0   Back to index