diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-05-26 23:43:36 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-05-26 23:52:36 +0100 |
commit | 00b6cfc57e27f8146d9b41ba8e63038a4f9df70e (patch) | |
tree | badf71a43a81975098d3f1294073d8c76bc994ea /framebuffer | |
parent | 1f337f292d1c98c396d5f8d5d294f9ba13963586 (diff) | |
download | netsurf-00b6cfc57e27f8146d9b41ba8e63038a4f9df70e.tar.gz netsurf-00b6cfc57e27f8146d9b41ba8e63038a4f9df70e.tar.bz2 |
rework path to url mapping functions to convert from and to nsurl
Diffstat (limited to 'framebuffer')
-rw-r--r-- | framebuffer/fetch.c | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/framebuffer/fetch.c b/framebuffer/fetch.c index 6d97cfda7..b32a95168 100644 --- a/framebuffer/fetch.c +++ b/framebuffer/fetch.c @@ -26,66 +26,15 @@ #include <limits.h> #include "utils/nsurl.h" -#include "utils/url.h" #include "utils/log.h" #include "utils/filepath.h" +#include "utils/file.h" #include "desktop/gui.h" #include "framebuffer/findfile.h" #include "framebuffer/fetch.h" -/** - * Convert a pathname to a file: URL. - * - * \param path pathname - * \return URL, allocated on heap, or NULL on failure - */ -static char *path_to_url(const char *path) -{ - int urllen; - char *url; - - if (path == NULL) - return NULL; - - urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1; - url = malloc(urllen); - - if (*path == '/') { - path++; /* file: paths are already absolute */ - } - - snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path); - - return url; -} - -/** - * Convert a file: URL to a pathname. - * - * \param url a file: URL - * \return pathname, allocated on heap, or NULL on failure - */ -static char *url_to_path(const char *url) -{ - char *path; - char *respath; - nserror res; /* result from url routines */ - - res = url_path(url, &path); - if (res != NSERROR_OK) { - return NULL; - } - - res = url_unescape(path, &respath); - free(path); - if (res != NSERROR_OK) { - return NULL; - } - - return respath; -} /** * Translate resource to full url. @@ -101,17 +50,12 @@ static char *url_to_path(const char *url) static nsurl *get_resource_url(const char *path) { char buf[PATH_MAX]; - char *raw; nsurl *url = NULL; if (strcmp(path, "favicon.ico") == 0) path = "favicon.png"; - raw = path_to_url(filepath_sfind(respaths, buf, path)); - if (raw != NULL) { - nsurl_create(raw, &url); - free(raw); - } + netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url); return url; } @@ -148,8 +92,6 @@ static const char *fetch_filetype(const char *unix_path) /* table for fetch operations */ static struct gui_fetch_table fetch_table = { .filetype = fetch_filetype, - .path_to_url = path_to_url, - .url_to_path = url_to_path, .get_resource_url = get_resource_url, }; |