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

mpd_malloc struct mpd_stats* mpd_recv_stats ( struct mpd_connection connection  )  [read]

Reads the "stats" response from MPD.

Returns:
a mpd_stats object, or NULL on error

Definition at line 48 of file cstats.c.

References mpd_connection::error, MPD_ERROR_OOM, mpd_recv_pair(), mpd_recv_stats(), mpd_return_pair(), mpd_stats_begin(), mpd_stats_feed(), and mpd_stats_free().

Referenced by mpd_recv_stats(), and mpd_run_stats().

{
      struct mpd_stats * stats;
      struct mpd_pair *pair;

      assert(connection != NULL);

      if (mpd_error_is_defined(&connection->error))
            /* refuse to receive a response if the connection's
               state is not clean */
            return NULL;

      stats = mpd_stats_begin();
      if (stats == NULL) {
            mpd_error_code(&connection->error, MPD_ERROR_OOM);
            return NULL;
      }

      /* read and parse all response lines */
      while ((pair = mpd_recv_pair(connection)) != NULL) {
            mpd_stats_feed(stats, pair);
            mpd_return_pair(connection, pair);
      }

      if (mpd_error_is_defined(&connection->error)) {
            /* an error has occurred; roll back */
            mpd_stats_free(stats);
            return NULL;
      }

      return stats;
}


Generated by  Doxygen 1.6.0   Back to index