2
$Id: do_album.c,v 1.1 2006/10/15 09:04:08 airborne Exp $
4
Copyright (C) 2006 Kris Verbeeck <airborne@advalvas.be>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public
17
License along with this library; if not, write to the
18
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA.
25
void do_album(cddb_conn_t *conn, cddb_disc_t *disc, int quiet)
29
/* Try searching the database for information about the provided
30
album and/or artits. This function will return the number of
31
matches that were found. A return value of 0 means that no
32
matches were found. The data of the first match (when found)
33
will be filled in into the disc structure passed to it. */
34
matches = cddb_album(conn, disc);
36
/* If an error occured then the return value will be -1 and the
37
internal libcddb error number will be set. */
39
/* Print an explanatory message on stderr. Other routines are
40
available for retrieving the message without printing it or
41
printing it on a stream other than stderr. */
43
cddb_error_print(cddb_errno(conn));
45
/* Return to calling fucntion. */
49
printf("Number of matches: %d\n", matches);
50
/* A CDDB album command will not return all the disc information.
51
It will return a subset that can afterwards be used to do a
52
CDDB read. This enables you to first show a pop-up listing the
53
found matches before doing further reads for the full data.
54
The data that is returned for each match is: the disc CDDB
55
category, the disc ID as known by the server, the disc title
56
and the artist's name. */
58
/* Let's loop over the matches. */
61
/* Increment the match counter. */
64
/* Print out the information for the current match. */
65
printf("Match %d\n", i);
66
/* Retrieve and print the category and disc ID. */
67
printf(" category: %s (%d)\t%08x\n", cddb_disc_get_category_str(disc),
68
cddb_disc_get_category(disc), cddb_disc_get_discid(disc));
69
/* Retrieve and print the disc title and artist name. */
70
printf(" '%s' by %s\n", cddb_disc_get_title(disc),
71
cddb_disc_get_artist(disc));
73
/* Get the next match, if there is one left. */
75
/* If there are multiple matches, then you can use the
76
following function to retrieve the matches beyond the
77
first. This function will overwrite any data that
78
might be present in the disc structure passed to it.
79
So if you still need that disc for anything else, then
80
first create a new disc and use that to call this
81
function. If there are no more matches left, false
82
(i.e. 0) will be returned. */
83
if (!cddb_album_next(conn, disc)) {
84
error_exit(cddb_errno(conn), "album index out of bounds");