0
|
1 /*********************************************************************
|
|
2 *
|
|
3 * Copyright (C) 1999, 2001, 2002,
|
|
4 * Department of Computer Science, University of Tromsų
|
|
5 *
|
|
6 * Filename: id3_frame_url.c
|
|
7 * Description: Code for handling ID3 URL frames.
|
|
8 * Author: Espen Skoglund <espensk@stud.cs.uit.no>
|
|
9 * Created at: Tue Feb 9 21:10:45 1999
|
|
10 *
|
|
11 * $Id: id3_frame_url.c,v 1.6 2004/07/20 21:47:22 descender Exp $
|
|
12 *
|
|
13 * This program is free software; you can redistribute it and/or
|
|
14 * modify it under the terms of the GNU General Public License
|
|
15 * as published by the Free Software Foundation; either version 2
|
|
16 * of the License, or (at your option) any later version.
|
|
17 *
|
|
18 * This program is distributed in the hope that it will be useful,
|
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 * GNU General Public License for more details.
|
|
22 *
|
|
23 * You should have received a copy of the GNU General Public License
|
|
24 * along with this program; if not, write to the Free Software
|
|
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
26 *
|
|
27 ********************************************************************/
|
|
28 #include "config.h"
|
|
29
|
|
30 #include "xmms-id3.h"
|
|
31 #include "id3_header.h"
|
|
32
|
|
33
|
|
34
|
|
35 /*
|
|
36 * Function id3_get_url (frame)
|
|
37 *
|
|
38 * Return URL of frame.
|
|
39 *
|
|
40 */
|
|
41 char *
|
|
42 id3_get_url(struct id3_frame *frame)
|
|
43 {
|
|
44 /* Type check */
|
|
45 if (frame->fr_desc->fd_idstr[0] != 'W')
|
|
46 return NULL;
|
|
47
|
|
48 /* Check if frame is compressed */
|
|
49 if (id3_decompress_frame(frame) == -1)
|
|
50 return NULL;
|
|
51
|
|
52 if (frame->fr_desc->fd_id == ID3_WXXX) {
|
|
53 /*
|
|
54 * This is a user defined link frame. Skip the description.
|
|
55 */
|
|
56 switch (*(guint8 *) frame->fr_data) {
|
|
57 case ID3_ENCODING_ISO_8859_1:
|
|
58 {
|
|
59 char *text = (char *) frame->fr_data + 1;
|
|
60
|
|
61 while (*text != 0)
|
|
62 text++;
|
|
63
|
|
64 return g_strdup(++text);
|
|
65 }
|
|
66 case ID3_ENCODING_UTF16:
|
|
67 {
|
|
68 gint16 *text16 = (gint16 *) ((glong) frame->fr_data + 1);
|
|
69
|
|
70 while (*text16 != 0)
|
|
71 text16++;
|
|
72
|
|
73 return g_strdup((char *) (++text16));
|
|
74 }
|
|
75 default:
|
|
76 return NULL;
|
|
77 }
|
|
78 }
|
|
79
|
|
80 return g_strdup((char *) frame->fr_data);
|
|
81 }
|
|
82
|
|
83
|
|
84 /*
|
|
85 * Function id3_get_url_desc (frame)
|
|
86 *
|
|
87 * Get description of a URL.
|
|
88 *
|
|
89 */
|
|
90 char *
|
|
91 id3_get_url_desc(struct id3_frame *frame)
|
|
92 {
|
|
93 /* Type check */
|
|
94 if (frame->fr_desc->fd_idstr[0] != 'W')
|
|
95 return NULL;
|
|
96
|
|
97 /* If predefined link frame, return description. */
|
|
98 if (frame->fr_desc->fd_id != ID3_WXXX)
|
|
99 return frame->fr_desc->fd_description;
|
|
100
|
|
101 /* Check if frame is compressed */
|
|
102 if (id3_decompress_frame(frame) == -1)
|
|
103 return NULL;
|
|
104
|
|
105 if (*(guint8 *) frame->fr_data == ID3_ENCODING_ISO_8859_1)
|
|
106 return g_strdup((char *) frame->fr_data + 1);
|
|
107 else
|
|
108 return id3_utf16_to_ascii((gint16 *) ((glong) frame->fr_data + 1));
|
|
109 }
|