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

mpd_malloc struct mpd_entity* mpd_recv_entity ( struct mpd_connection connection  )  [read]

Receives the next entity from the MPD server.

Returns:
an entity object, or NULL on error or if the entity list is finished

Definition at line 207 of file entity.c.

References mpd_connection::error, mpd_enqueue_pair(), mpd_entity_begin(), mpd_entity_feed(), mpd_entity_free(), MPD_ERROR_OOM, mpd_recv_entity(), mpd_recv_pair(), and mpd_return_pair().

Referenced by mpd_recv_entity().

{
      struct mpd_pair *pair;
      struct mpd_entity *entity;

      pair = mpd_recv_pair(connection);
      if (pair == NULL)
            return NULL;

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

      while ((pair = mpd_recv_pair(connection)) != NULL &&
             mpd_entity_feed(entity, pair))
            mpd_return_pair(connection, pair);

      if (mpd_error_is_defined(&connection->error)) {
            mpd_entity_free(entity);
            return NULL;
      }

      /* unread this pair for the next mpd_recv_entity() call */
      mpd_enqueue_pair(connection, pair);

      return entity;
}


Generated by  Doxygen 1.6.0   Back to index