1 /*
2 * libcddb - CDDB Interface Library for xmcd/cda
3 *
4 * This library implements an interface to access the "classic"
5 * CDDB1 services.
6 *
7 * Copyright (C) 1993-2004 Ti Kan
8 * E-mail: xmcd@amb.org
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 #ifndef lint
26 static char *_genrelist_c_ident_ = "@(#)genrelist.c 1.10 03/12/12";
27 #endif
28
29 #include "fcddb.h"
30
31
32 /*
33 * CddbGenreList_GetCount
34 * Return the number of genres in list
35 */
36 CddbResult
CddbGenreList_GetCount(CddbGenreListPtr glistp,long * pval)37 CddbGenreList_GetCount(CddbGenreListPtr glistp, long *pval)
38 {
39 cddb_genrelist_t *p = (cddb_genrelist_t *) glistp;
40 cddb_genre_t *gp;
41 long i;
42
43 for (i = 0, gp = p->genres; gp != NULL; i++, gp = gp->next)
44 ;
45
46 *pval = i;
47 return Cddb_OK;
48 }
49
50
51 /*
52 * CddbGenreList_GetGenre
53 * Return a genre in the list
54 */
55 CddbResult
CddbGenreList_GetGenre(CddbGenreListPtr glistp,long item,CddbGenrePtr * pval)56 CddbGenreList_GetGenre(CddbGenreListPtr glistp, long item, CddbGenrePtr *pval)
57 {
58 cddb_genrelist_t *p = (cddb_genrelist_t *) glistp;
59 cddb_genre_t *gp;
60 long i;
61
62 for (i = 1, gp = p->genres; gp != NULL; i++, gp = gp->next) {
63 if (i == item)
64 break;
65 }
66 if (i > item) {
67 *pval = NULL;
68 return Cddb_E_INVALIDARG;
69 }
70
71 *pval = (CddbGenrePtr) gp;
72 return Cddb_OK;
73 }
74
75
76