Mercurial > audlegacy
comparison audacious/util.c @ 2074:c725daec3849 trunk
[svn] - move xmms_urldecode_path() back into main binary
author | nenolod |
---|---|
date | Sat, 09 Dec 2006 02:01:53 -0800 |
parents | d3a62e1075e2 |
children | bc47a2129067 |
comparison
equal
deleted
inserted
replaced
2073:25308f10b50f | 2074:c725daec3849 |
---|---|
1924 ptr2 += (dblimg->bpl >> 1) - dblimg->width; | 1924 ptr2 += (dblimg->bpl >> 1) - dblimg->width; |
1925 } | 1925 } |
1926 } | 1926 } |
1927 return dblimg; | 1927 return dblimg; |
1928 } | 1928 } |
1929 | |
1930 /* URL-decode a file: URL path, return NULL if it's not what we expect */ | |
1931 gchar * | |
1932 xmms_urldecode_path(const gchar * encoded_path) | |
1933 { | |
1934 const gchar *cur, *ext; | |
1935 gchar *path, *tmp; | |
1936 gint realchar; | |
1937 | |
1938 if (!encoded_path) | |
1939 return NULL; | |
1940 | |
1941 if (!str_has_prefix_nocase(encoded_path, "file:")) | |
1942 return NULL; | |
1943 | |
1944 cur = encoded_path + 5; | |
1945 | |
1946 if (str_has_prefix_nocase(cur, "//localhost")) | |
1947 cur += 11; | |
1948 | |
1949 if (*cur == '/') | |
1950 while (cur[1] == '/') | |
1951 cur++; | |
1952 | |
1953 tmp = g_malloc0(strlen(cur) + 1); | |
1954 | |
1955 while ((ext = strchr(cur, '%')) != NULL) { | |
1956 strncat(tmp, cur, ext - cur); | |
1957 ext++; | |
1958 cur = ext + 2; | |
1959 if (!sscanf(ext, "%2x", &realchar)) { | |
1960 /* Assume it is a literal '%'. Several file | |
1961 * managers send unencoded file: urls on drag | |
1962 * and drop. */ | |
1963 realchar = '%'; | |
1964 cur -= 2; | |
1965 } | |
1966 tmp[strlen(tmp)] = realchar; | |
1967 } | |
1968 | |
1969 path = g_strconcat(tmp, cur, NULL); | |
1970 g_free(tmp); | |
1971 return path; | |
1972 } | |
1973 |