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     *_fullname_c_ident_ = "@(#)fullname.c	1.12 03/12/12";
27 #endif
28 
29 #include "fcddb.h"
30 
31 
32 /*
33  * CddbFullName_GetFirstName
34  *	Return first name of the full name object
35  */
36 CddbResult
CddbFullName_GetFirstName(CddbFullNamePtr fnamep,CddbStr * pval)37 CddbFullName_GetFirstName(CddbFullNamePtr fnamep, CddbStr *pval)
38 {
39 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
40 
41 	*pval = (fnp->firstname == NULL) ? "" : fnp->firstname;
42 	return Cddb_OK;
43 }
44 
45 
46 /*
47  * CddbFullName_GetLastName
48  *	Return last name of the full name object
49  */
50 CddbResult
CddbFullName_GetLastName(CddbFullNamePtr fnamep,CddbStr * pval)51 CddbFullName_GetLastName(CddbFullNamePtr fnamep, CddbStr *pval)
52 {
53 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
54 
55 	*pval = (fnp->lastname == NULL) ? "" : fnp->lastname;
56 	return Cddb_OK;
57 }
58 
59 
60 /*
61  * CddbFullName_GetName
62  *	Return display name of the full name object
63  */
64 CddbResult
CddbFullName_GetName(CddbFullNamePtr fnamep,CddbStr * pval)65 CddbFullName_GetName(CddbFullNamePtr fnamep, CddbStr *pval)
66 {
67 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
68 
69 	*pval = (fnp->name == NULL) ? "" : fnp->name;
70 	return Cddb_OK;
71 }
72 
73 
74 /*
75  * CddbFullName_GetThe
76  *	Return "The" string of the full name object
77  */
78 CddbResult
CddbFullName_GetThe(CddbFullNamePtr fnamep,CddbStr * pval)79 CddbFullName_GetThe(CddbFullNamePtr fnamep, CddbStr *pval)
80 {
81 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
82 
83 	*pval = (fnp->the == NULL) ? "" : fnp->the;
84 	return Cddb_OK;
85 }
86 
87 
88 /*
89  * CddbFullName_PutFirstName
90  *	Set the first name of the full name object
91  */
92 CddbResult
CddbFullName_PutFirstName(CddbFullNamePtr fnamep,CddbConstStr newval)93 CddbFullName_PutFirstName(CddbFullNamePtr fnamep, CddbConstStr newval)
94 {
95 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
96 
97 	if (fnp->firstname != NULL)
98 		MEM_FREE(fnp->firstname);
99 
100 	if (newval == NULL || newval[0] == '\0')
101 		fnp->firstname = NULL;
102 	else
103 		fnp->firstname = (CddbStr) fcddb_strdup((char *) newval);
104 
105 	return Cddb_OK;
106 }
107 
108 
109 /*
110  * CddbFullName_PutLastName
111  *	Set the last name of the full name object
112  */
113 CddbResult
CddbFullName_PutLastName(CddbFullNamePtr fnamep,CddbConstStr newval)114 CddbFullName_PutLastName(CddbFullNamePtr fnamep, CddbConstStr newval)
115 {
116 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
117 
118 	if (fnp->lastname != NULL)
119 		MEM_FREE(fnp->lastname);
120 
121 	if (newval == NULL || newval[0] == '\0')
122 		fnp->lastname = NULL;
123 	else
124 		fnp->lastname = (CddbStr) fcddb_strdup((char *) newval);
125 
126 	return Cddb_OK;
127 }
128 
129 
130 /*
131  * CddbFullName_PutName
132  *	Set the display name of the full name object
133  */
134 CddbResult
CddbFullName_PutName(CddbFullNamePtr fnamep,CddbConstStr newval)135 CddbFullName_PutName(CddbFullNamePtr fnamep, CddbConstStr newval)
136 {
137 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
138 
139 	if (fnp->name != NULL)
140 		MEM_FREE(fnp->name);
141 
142 	if (newval == NULL || newval[0] == '\0')
143 		fnp->name = NULL;
144 	else
145 		fnp->name = (CddbStr) fcddb_strdup((char *) newval);
146 
147 	return Cddb_OK;
148 }
149 
150 
151 /*
152  * CddbFullName_PutThe
153  *	Set the "The" string of the full name object
154  */
155 CddbResult
CddbFullName_PutThe(CddbFullNamePtr fnamep,CddbConstStr newval)156 CddbFullName_PutThe(CddbFullNamePtr fnamep, CddbConstStr newval)
157 {
158 	cddb_fullname_t	*fnp = (cddb_fullname_t *) fnamep;
159 
160 	if (fnp->the != NULL)
161 		MEM_FREE(fnp->the);
162 
163 	if (newval == NULL || newval[0] == '\0')
164 		fnp->the = NULL;
165 	else
166 		fnp->the = (CddbStr) fcddb_strdup((char *) newval);
167 
168 	return Cddb_OK;
169 }
170 
171 
172