summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e630634)
raw | patch | inline | side by side (parent: e630634)
author | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 16:13:49 +0000 (18:13 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 16:13:49 +0000 (18:13 +0200) |
src/mpdclient.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index a82278a47be1f3217be5fddd04f84a0d79836216..9b896e2691b6613ffa42e680f17be09b8fa701d6 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
return mpdclient_finish_command(c);
}
+static GList *
+recv_tag_values(struct mpd_connection *connection, enum mpd_tag_type tag)
+{
+ GList *list = NULL;
+ struct mpd_pair *pair;
+
+ while ((pair = mpd_recv_pair_tag(connection, tag)) != NULL) {
+ list = g_list_append(list, g_strdup(pair->value));
+ mpd_return_pair(connection, pair);
+ }
+
+ return list;
+}
+
GList *
mpdclient_get_artists(struct mpdclient *c)
{
struct mpd_connection *connection = mpdclient_get_connection(c);
- GList *list = NULL;
- struct mpd_pair *pair;
+ GList *list;
if (connection == NULL)
return NULL;
mpd_search_db_tags(connection, MPD_TAG_ARTIST);
mpd_search_commit(connection);
- while ((pair = mpd_recv_pair_tag(connection,
- MPD_TAG_ARTIST)) != NULL) {
- list = g_list_append(list, g_strdup(pair->value));
- mpd_return_pair(connection, pair);
- }
+ list = recv_tag_values(connection, MPD_TAG_ARTIST);
if (!mpdclient_finish_command(c))
return string_list_free(list);
mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8)
{
struct mpd_connection *connection = mpdclient_get_connection(c);
- GList *list = NULL;
- struct mpd_pair *pair;
+ GList *list;
if (connection == NULL)
return NULL;
MPD_TAG_ARTIST, artist_utf8);
mpd_search_commit(connection);
- while ((pair = mpd_recv_pair_tag(connection,
- MPD_TAG_ALBUM)) != NULL) {
- list = g_list_append(list, g_strdup(pair->value));
- mpd_return_pair(connection, pair);
- }
+ list = recv_tag_values(connection, MPD_TAG_ALBUM);
if (!mpdclient_finish_command(c))
return string_list_free(list);