1 /* libmpd (high level libmpdclient library)
2 * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
3 * Project homepage: http://gmpcwiki.sarine.nl/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <libmpd/libmpd.h>
24 int main(int argc
, char **argv
)
26 /* the main structure */
29 * A list that can hold the data that mpd returns
34 /* create a connection
39 mo
= mpd_new_default();
41 /* Make a connection and check for errors */
45 * to print an error message, you need to connect the
46 * error signal and catch that
48 /* clean up the connection and free the space needed by mpdObj */
50 printf("Failed to connect\n");
55 * If the list is at the end, mpd_data_get_next will automatically free
58 for(data
= mpd_database_get_artists(mo
);data
!= NULL
; data
= mpd_data_get_next(data
))
60 /* check if the entry is of the correct type */
61 if(data
->type
== MPD_DATA_TYPE_TAG
&& data
->tag_type
== MPD_TAG_ITEM_ARTIST
)
63 /* Another object to hold data */
64 MpdData
*albums
= NULL
;
65 printf("%s\n", data
->tag
);
66 for(albums
= mpd_database_get_albums(mo
, data
->tag
);
68 albums
= mpd_data_get_next(albums
))
70 if(albums
->type
== MPD_DATA_TYPE_TAG
&& albums
->tag_type
== MPD_TAG_ITEM_ALBUM
)
72 printf("\t%s\n", albums
->tag
);
82 /* clean up the connection and free the space needed by mpdObj */