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     *_credit_c_ident_ = "@(#)credit.c	1.15 03/12/12";
27 #endif
28 
29 #include "fcddb.h"
30 
31 
32 /*
33  * CddbCredit_GetFullName
34  *	Get full name object within a credit
35  */
36 CddbResult
37 CddbCredit_GetFullName(CddbCreditPtr credp, CddbFullNamePtr *pval)
38 {
39 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
40 
41 	*pval = (CddbFullNamePtr) &cp->fullname;
42 	return Cddb_OK;
43 }
44 
45 
46 /*
47  * CddbCredit_GetId
48  *	Get credit role ID
49  */
50 CddbResult
51 CddbCredit_GetId(CddbCreditPtr credp, CddbStr *pval)
52 {
53 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
54 
55 	if (cp->role == NULL)
56 		return Cddb_E_INVALIDARG;
57 
58 	*pval = (CddbStr) (cp->role->id == NULL ? "" : cp->role->id);
59 	return Cddb_OK;
60 }
61 
62 
63 /*
64  * CddbCredit_GetName
65  *	Get credit name
66  */
67 CddbResult
68 CddbCredit_GetName(CddbCreditPtr credp, CddbStr *pval)
69 {
70 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
71 
72 	*pval = (CddbStr) (cp->fullname.name == NULL ? "" : cp->fullname.name);
73 	return Cddb_OK;
74 }
75 
76 
77 /*
78  * CddbCredit_GetNotes
79  *	Get credit notes
80  */
81 CddbResult
82 CddbCredit_GetNotes(CddbCreditPtr credp, CddbStr *pval)
83 {
84 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
85 
86 	*pval = (CddbStr) (cp->notes == NULL ? "" : cp->notes);
87 	return Cddb_OK;
88 }
89 
90 
91 /*
92  * CddbCredit_PutFullName
93  *	Set the full name information within a credit
94  */
95 CddbResult
96 CddbCredit_PutFullName(CddbCreditPtr credp, const CddbFullNamePtr newval)
97 {
98 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
99 	cddb_fullname_t	*fnp = (cddb_fullname_t *) newval;
100 
101 	if (newval == NULL)
102 		return Cddb_E_INVALIDARG;
103 
104 	if (cp->fullname.name != NULL)
105 		MEM_FREE(cp->fullname.name);
106 	if (cp->fullname.lastname != NULL)
107 		MEM_FREE(cp->fullname.lastname);
108 	if (cp->fullname.firstname != NULL)
109 		MEM_FREE(cp->fullname.firstname);
110 	if (cp->fullname.the != NULL)
111 		MEM_FREE(cp->fullname.the);
112 
113 	cp->fullname.name = (CddbStr) fcddb_strdup(fnp->name);
114 	cp->fullname.lastname = (CddbStr) fcddb_strdup(fnp->lastname);
115 	cp->fullname.firstname = (CddbStr) fcddb_strdup(fnp->firstname);
116 	cp->fullname.the = (CddbStr) fcddb_strdup(fnp->the);
117 
118 	return Cddb_OK;
119 }
120 
121 
122 /*
123  * CddbCredit_PutNotes
124  *	Set credit notes
125  */
126 CddbResult
127 CddbCredit_PutNotes(CddbCreditPtr credp, CddbConstStr newval)
128 {
129 	cddb_credit_t	*cp = (cddb_credit_t *) credp;
130 
131 	if (cp->notes != NULL)
132 		MEM_FREE(cp->notes);
133 
134 	cp->notes = (CddbStr) fcddb_strdup((char *) newval);
135 	return Cddb_OK;
136 }
137 
138 
139