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     *_url_c_ident_ = "@(#)url.c	1.14 03/12/12";
27 #endif
28 
29 #include "fcddb.h"
30 
31 
32 /*
33  * CddbURL_GetCategory
34  *	Return the URL category
35  */
36 CddbResult
CddbURL_GetCategory(CddbURLPtr urlp,CddbStr * pval)37 CddbURL_GetCategory(CddbURLPtr urlp, CddbStr *pval)
38 {
39 	cddb_url_t	*up = (cddb_url_t *) urlp;
40 
41 	*pval = (CddbStr) (up->category == NULL ? "" : up->category);
42 	return Cddb_OK;
43 }
44 
45 
46 /*
47  * CddbURL_GetDescription
48  *	Return the URL description
49  */
50 CddbResult
CddbURL_GetDescription(CddbURLPtr urlp,CddbStr * pval)51 CddbURL_GetDescription(CddbURLPtr urlp, CddbStr *pval)
52 {
53 	cddb_url_t	*up = (cddb_url_t *) urlp;
54 
55 	*pval = (CddbStr) (up->description == NULL ? "" : up->description);
56 	return Cddb_OK;
57 }
58 
59 
60 /*
61  * CddbURL_GetDisplayLink
62  *	Return the URL display link
63  */
64 CddbResult
CddbURL_GetDisplayLink(CddbURLPtr urlp,CddbStr * pval)65 CddbURL_GetDisplayLink(CddbURLPtr urlp, CddbStr *pval)
66 {
67 	cddb_url_t	*up = (cddb_url_t *) urlp;
68 
69 	*pval = (CddbStr) (up->displaylink == NULL ? "" : up->displaylink);
70 	return Cddb_OK;
71 }
72 
73 
74 /*
75  * CddbURL_GetDisplayText
76  *	Return the URL display text
77  */
78 CddbResult
CddbURL_GetDisplayText(CddbURLPtr urlp,CddbStr * pval)79 CddbURL_GetDisplayText(CddbURLPtr urlp, CddbStr *pval)
80 {
81 	cddb_url_t	*up = (cddb_url_t *) urlp;
82 
83 	*pval = (CddbStr) (up->displaytext == NULL ? "" : up->displaytext);
84 	return Cddb_OK;
85 }
86 
87 
88 /*
89  * CddbURL_GetHref
90  *	Return the URL HREF
91  */
92 CddbResult
CddbURL_GetHref(CddbURLPtr urlp,CddbStr * pval)93 CddbURL_GetHref(CddbURLPtr urlp, CddbStr *pval)
94 {
95 	cddb_url_t	*up = (cddb_url_t *) urlp;
96 
97 	*pval = (CddbStr) (up->href == NULL ? "" : up->href);
98 	return Cddb_OK;
99 }
100 
101 
102 /*
103  * CddbURL_GetSize
104  *	Return the display size
105  */
106 /*ARGSUSED*/
107 CddbResult
CddbURL_GetSize(CddbURLPtr urlp,CddbStr * pval)108 CddbURL_GetSize(CddbURLPtr urlp, CddbStr *pval)
109 {
110 	*pval = "";	/* Not supported in CDDB1 */
111 	return Cddb_OK;
112 }
113 
114 
115 /*
116  * CddbURL_GetType
117  *	Return the URL type
118  */
119 CddbResult
CddbURL_GetType(CddbURLPtr urlp,CddbStr * pval)120 CddbURL_GetType(CddbURLPtr urlp, CddbStr *pval)
121 {
122 	cddb_url_t	*up = (cddb_url_t *) urlp;
123 
124 	*pval = (CddbStr) (up->type == NULL ? "" : up->type);
125 	return Cddb_OK;
126 }
127 
128 
129 /*
130  * CddbURL_GetWeight
131  *	Return the display weight
132  */
133 /*ARGSUSED*/
134 CddbResult
CddbURL_GetWeight(CddbURLPtr urlp,CddbStr * pval)135 CddbURL_GetWeight(CddbURLPtr urlp, CddbStr *pval)
136 {
137 	*pval = "";	/* Not supported in CDDB1 */
138 	return Cddb_OK;
139 }
140 
141 
142 /*
143  * CddbURL_PutCategory
144  *	Set the URL category
145  */
146 CddbResult
CddbURL_PutCategory(CddbURLPtr urlp,CddbConstStr newval)147 CddbURL_PutCategory(CddbURLPtr urlp, CddbConstStr newval)
148 {
149 	cddb_url_t	*up = (cddb_url_t *) urlp;
150 
151 	if (up->category != NULL)
152 		MEM_FREE(up->category);
153 
154 	if (newval == NULL || newval[0] == '\0')
155 		up->category = NULL;
156 	else
157 		up->category = (CddbStr) fcddb_strdup((char *) newval);
158 
159 	return Cddb_OK;
160 }
161 
162 
163 /*
164  * CddbURL_PutDescription
165  *	Set the URL description
166  */
167 CddbResult
CddbURL_PutDescription(CddbURLPtr urlp,CddbConstStr newval)168 CddbURL_PutDescription(CddbURLPtr urlp, CddbConstStr newval)
169 {
170 	cddb_url_t	*up = (cddb_url_t *) urlp;
171 
172 	if (up->description != NULL)
173 		MEM_FREE(up->description);
174 
175 	if (newval == NULL || newval[0] == '\0')
176 		up->description = NULL;
177 	else
178 		up->description = (CddbStr) fcddb_strdup((char *) newval);
179 
180 	return Cddb_OK;
181 }
182 
183 
184 /*
185  * CddbURL_PutDisplayLink
186  *	Set the URL display link
187  */
188 CddbResult
CddbURL_PutDisplayLink(CddbURLPtr urlp,CddbConstStr newval)189 CddbURL_PutDisplayLink(CddbURLPtr urlp, CddbConstStr newval)
190 {
191 	cddb_url_t	*up = (cddb_url_t *) urlp;
192 
193 	if (up->displaylink != NULL)
194 		MEM_FREE(up->displaylink);
195 
196 	if (newval == NULL || newval[0] == '\0')
197 		up->displaylink = NULL;
198 	else
199 		up->displaylink = (CddbStr) fcddb_strdup((char *) newval);
200 
201 	return Cddb_OK;
202 }
203 
204 
205 /*
206  * CddbURL_PutDisplayText
207  *	Set the URL display text
208  */
209 CddbResult
CddbURL_PutDisplayText(CddbURLPtr urlp,CddbConstStr newval)210 CddbURL_PutDisplayText(CddbURLPtr urlp, CddbConstStr newval)
211 {
212 	cddb_url_t	*up = (cddb_url_t *) urlp;
213 
214 	if (up->displaytext != NULL)
215 		MEM_FREE(up->displaytext);
216 
217 	if (newval == NULL || newval[0] == '\0')
218 		up->displaytext = NULL;
219 	else
220 		up->displaytext = (CddbStr) fcddb_strdup((char *) newval);
221 
222 	return Cddb_OK;
223 }
224 
225 
226 /*
227  * CddbURL_PutHref
228  *	Set the URL HREF
229  */
230 CddbResult
CddbURL_PutHref(CddbURLPtr urlp,CddbConstStr newval)231 CddbURL_PutHref(CddbURLPtr urlp, CddbConstStr newval)
232 {
233 	cddb_url_t	*up = (cddb_url_t *) urlp;
234 
235 	if (up->href != NULL)
236 		MEM_FREE(up->href);
237 
238 	if (newval == NULL || newval[0] == '\0')
239 		up->href = NULL;
240 	else
241 		up->href = (CddbStr) fcddb_strdup((char *) newval);
242 
243 	return Cddb_OK;
244 }
245 
246 
247 /*
248  * CddbURL_PutSize
249  *	Set the display size
250  */
251 /*ARGSUSED*/
252 CddbResult
CddbURL_PutSize(CddbURLPtr urlp,CddbConstStr newval)253 CddbURL_PutSize(CddbURLPtr urlp, CddbConstStr newval)
254 {
255 	/* Not supported in CDDB1 */
256 	return Cddb_OK;
257 }
258 
259 
260 /*
261  * CddbURL_PutType
262  *	Set the URL type
263  */
264 CddbResult
CddbURL_PutType(CddbURLPtr urlp,CddbConstStr newval)265 CddbURL_PutType(CddbURLPtr urlp, CddbConstStr newval)
266 {
267 	cddb_url_t	*up = (cddb_url_t *) urlp;
268 
269 	if (up->type != NULL)
270 		MEM_FREE(up->type);
271 
272 	if (newval == NULL || newval[0] == '\0')
273 		up->type = NULL;
274 	else
275 		up->type = (CddbStr) fcddb_strdup((char *) newval);
276 
277 	return Cddb_OK;
278 }
279 
280 
281 /*
282  * CddbURL_PutWeight
283  *	Set the display weight
284  */
285 /*ARGSUSED*/
286 CddbResult
CddbURL_PutWeight(CddbURLPtr urlp,CddbConstStr newval)287 CddbURL_PutWeight(CddbURLPtr urlp, CddbConstStr newval)
288 {
289 	/* Not supported in CDDB1 */
290 	return Cddb_OK;
291 }
292 
293 
294