annotate src/audacious/urldecode.c @ 2489:e56a55d07935 trunk

[svn] - revise r3986 to only override tuple->track_name on lengthless streams
author nenolod
date Thu, 08 Feb 2007 08:42:01 -0800
parents 0fd7f4f969ad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2416
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
3 *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
4 * Based on BMP:
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
6 *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
7 * Based on XMMS:
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
9 *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
12 * the Free Software Foundation; under version 2 of the License.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
13 *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
17 * GNU General Public License for more details.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
18 *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
22 */
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
23
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
24 #include "urldecode.h"
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
25
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
26 #include <glib.h>
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
27 #include <stdio.h>
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
28 #include <string.h>
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
29
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
30 #include "util.h"
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
31
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
32 gchar *
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
33 xmms_urldecode_plain(const gchar * encoded_path)
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
34 {
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
35 const gchar *cur, *ext;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
36 gchar *path, *tmp;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
37 gint realchar;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
38
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
39 if (!encoded_path)
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
40 return NULL;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
41
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
42 cur = encoded_path;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
43 if (*cur == '/')
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
44 while (cur[1] == '/')
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
45 cur++;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
46
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
47 tmp = g_malloc0(strlen(cur) + 1);
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
48
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
49 while ((ext = strchr(cur, '%')) != NULL) {
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
50 strncat(tmp, cur, ext - cur);
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
51 ext++;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
52 cur = ext + 2;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
53 if (!sscanf(ext, "%2x", &realchar)) {
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
54 /*
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
55 * Assume it is a literal '%'. Several file
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
56 * managers send unencoded file: urls on on
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
57 * drag and drop.
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
58 */
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
59 realchar = '%';
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
60 cur -= 2;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
61 }
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
62 tmp[strlen(tmp)] = realchar;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
63 }
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
64
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
65 path = g_strconcat(tmp, cur, NULL);
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
66 g_free(tmp);
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
67 return path;
0fd7f4f969ad [svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
diff changeset
68 }