Mercurial > audlegacy
annotate libaudacious/urldecode.c @ 2126:dba25b0e98c8 trunk
[svn] - use playlist_get_active() at the top of each thread.
author | nenolod |
---|---|
date | Fri, 15 Dec 2006 07:52:09 -0800 |
parents | f18a5b617c34 |
children | f363009b7410 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
1460 | 8 * it under the terms of the GNU General Public License as published by |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
2074
diff
changeset
|
9 * the Free Software Foundation; under version 2 of the License. |
0 | 10 * |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
1459 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 19 */ |
20 | |
21 #include "urldecode.h" | |
22 | |
23 #include <glib.h> | |
24 #include <stdio.h> | |
25 #include <string.h> | |
26 | |
27 #include "util.h" | |
28 | |
29 gchar * | |
30 xmms_urldecode_plain(const gchar * encoded_path) | |
31 { | |
32 const gchar *cur, *ext; | |
33 gchar *path, *tmp; | |
34 gint realchar; | |
35 | |
36 if (!encoded_path) | |
37 return NULL; | |
38 | |
39 cur = encoded_path; | |
40 if (*cur == '/') | |
41 while (cur[1] == '/') | |
42 cur++; | |
43 | |
44 tmp = g_malloc0(strlen(cur) + 1); | |
45 | |
46 while ((ext = strchr(cur, '%')) != NULL) { | |
47 strncat(tmp, cur, ext - cur); | |
48 ext++; | |
49 cur = ext + 2; | |
50 if (!sscanf(ext, "%2x", &realchar)) { | |
51 /* | |
52 * Assume it is a literal '%'. Several file | |
53 * managers send unencoded file: urls on on | |
54 * drag and drop. | |
55 */ | |
56 realchar = '%'; | |
57 cur -= 2; | |
58 } | |
59 tmp[strlen(tmp)] = realchar; | |
60 } | |
61 | |
62 path = g_strconcat(tmp, cur, NULL); | |
63 g_free(tmp); | |
64 return path; | |
65 } |