Mercurial > audlegacy
view libaudacious/urldecode.c @ 2303:a19f86d81427 trunk
[svn] Initial XDG basedir support.
author | js |
---|---|
date | Tue, 09 Jan 2007 14:51:38 -0800 |
parents | f363009b7410 |
children |
line wrap: on
line source
/* Audacious - Cross-platform multimedia player * Copyright (C) 2005-2007 Audacious development team * * Based on BMP: * Copyright (C) 2003-2004 BMP development team. * * Based on XMMS: * Copyright (C) 1998-2003 XMMS development team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; under version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "urldecode.h" #include <glib.h> #include <stdio.h> #include <string.h> #include "util.h" gchar * xmms_urldecode_plain(const gchar * encoded_path) { const gchar *cur, *ext; gchar *path, *tmp; gint realchar; if (!encoded_path) return NULL; cur = encoded_path; if (*cur == '/') while (cur[1] == '/') cur++; tmp = g_malloc0(strlen(cur) + 1); while ((ext = strchr(cur, '%')) != NULL) { strncat(tmp, cur, ext - cur); ext++; cur = ext + 2; if (!sscanf(ext, "%2x", &realchar)) { /* * Assume it is a literal '%'. Several file * managers send unencoded file: urls on on * drag and drop. */ realchar = '%'; cur -= 2; } tmp[strlen(tmp)] = realchar; } path = g_strconcat(tmp, cur, NULL); g_free(tmp); return path; }