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

mpd_malloc struct mpd_directory* mpd_recv_directory ( struct mpd_connection connection  )  [read]

Receives the next directory from the MPD server.

Returns:
a mpd_directory object, or NULL on error or if the directory list is finished

Definition at line 34 of file rdirectory.c.

References mpd_connection::error, mpd_directory_begin(), mpd_directory_feed(), mpd_directory_free(), mpd_enqueue_pair(), MPD_ERROR_OOM, mpd_recv_directory(), mpd_recv_pair(), mpd_recv_pair_named(), and mpd_return_pair().

Referenced by mpd_recv_directory().

{
      struct mpd_pair *pair;
      struct mpd_directory *directory;

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

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

      while ((pair = mpd_recv_pair(connection)) != NULL &&
             mpd_directory_feed(directory, pair))
            mpd_return_pair(connection, pair);

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

            mpd_directory_free(directory);
            return NULL;
      }

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

      return directory;
}


Generated by  Doxygen 1.6.0   Back to index