diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-11-15 15:28:17 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-11-15 15:28:17 +0000 |
commit | d6874d05b1800f3f68cf109fb7818b68b59c213c (patch) | |
tree | 9613760ce98d167c8decce6e647a4339d734df81 /amiga/misc.c | |
parent | da2a89e43691d680563a44728688dc4e6b126e7f (diff) | |
download | netsurf-d6874d05b1800f3f68cf109fb7818b68b59c213c.tar.gz netsurf-d6874d05b1800f3f68cf109fb7818b68b59c213c.tar.bz2 |
Allow opening of local files from anywhere, not just the parent of the current dir.
svn path=/trunk/netsurf/; revision=5695
Diffstat (limited to 'amiga/misc.c')
-rwxr-xr-x | amiga/misc.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/amiga/misc.c b/amiga/misc.c index 851f3c837..c77788eae 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -1,5 +1,4 @@ /* - * Copyright 2004 James Bursa <bursa@users.sourceforge.net> * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ @@ -24,6 +23,7 @@ #include <proto/dos.h> #include "utils/messages.h" #include <stdlib.h> +#include <curl/curl.h> void warn_user(const char *warning, const char *detail) { @@ -51,14 +51,36 @@ void die(const char *error) char *url_to_path(const char *url) { - return (char *)strdup(url + 5); + char *tmps,*unesc; + CURL *curl; + + if(tmps = strchr(url,'/')) + { + if(tmps = strchr(tmps+1,'/')) + { + if(tmps = strchr(tmps+1,'/')) + { + if(curl = curl_easy_init()) + { + unesc = curl_easy_unescape(curl,tmps+1,0,NULL); + tmps = strdup(unesc); + curl_free(unesc); + curl_easy_cleanup(curl); + return tmps; + + } + } + } + } + + return strdup((char *)url); } char *path_to_url(const char *path) { - char *r = malloc(strlen(path) + 7 + 1); + char *r = malloc(strlen(path) + 8 + 1); - strcpy(r, "file://"); + strcpy(r, "file:///"); strcat(r, path); return r; |