summaryrefslogtreecommitdiff
path: root/content/fetchers/file.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-09-29 15:31:54 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-09-29 15:31:54 +0000
commit6cfd37e60f0181916906de67c9f86cf54ab565c2 (patch)
treed68c3e909b2f1f4a1403c8af73fb68d0e33fc97e /content/fetchers/file.c
parent828d8e0de8a643f74ddd019bd8afe663c65540e9 (diff)
downloadnetsurf-6cfd37e60f0181916906de67c9f86cf54ab565c2.tar.gz
netsurf-6cfd37e60f0181916906de67c9f86cf54ab565c2.tar.bz2
Convert fetchers to nsurl.
svn path=/trunk/netsurf/; revision=12910
Diffstat (limited to 'content/fetchers/file.c')
-rw-r--r--content/fetchers/file.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index cc41e8c54..cd4ad5c34 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -61,7 +61,7 @@ struct fetch_file_context {
bool aborted; /**< Flag indicating fetch has been aborted */
bool locked; /**< Flag indicating entry is already entered */
- char *url; /**< The full url the fetch refers to */
+ nsurl *url; /**< The full url the fetch refers to */
char *path; /**< The actual path to be used with open() */
time_t file_etag; /**< Request etag for file (previous st.m_time) */
@@ -113,7 +113,7 @@ static void fetch_file_finalise(lwc_string *scheme)
/** callback to set up a file fetch context. */
static void *
fetch_file_setup(struct fetch *fetchh,
- const char *url,
+ nsurl *url,
bool only_2xx,
const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
@@ -126,18 +126,13 @@ fetch_file_setup(struct fetch *fetchh,
if (ctx == NULL)
return NULL;
- ctx->path = url_to_path(url);
+ ctx->path = url_to_path(nsurl_access(url));
if (ctx->path == NULL) {
free(ctx);
return NULL;
}
- ctx->url = strdup(url);
- if (ctx->url == NULL) {
- free(ctx->path);
- free(ctx);
- return NULL;
- }
+ ctx->url = nsurl_ref(url);
/* Scan request headers looking for If-None-Match */
for (i = 0; headers[i] != NULL; i++) {
@@ -167,7 +162,7 @@ fetch_file_setup(struct fetch *fetchh,
static void fetch_file_free(void *ctx)
{
struct fetch_file_context *c = ctx;
- free(c->url);
+ nsurl_unref(c->url);
free(c->path);
RING_REMOVE(ring, c);
free(ctx);
@@ -226,7 +221,7 @@ static void fetch_file_process_error(struct fetch_file_context *ctx, int code)
snprintf(buffer, sizeof buffer, "<html><head><title>%s</title></head>"
"<body><h1>%s</h1>"
"<p>Error %d while fetching file %s</p></body></html>",
- title, title, code, ctx->url);
+ title, title, code, nsurl_access(ctx->url));
if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
FETCH_ERROR_NO_ERROR))
@@ -445,9 +440,9 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
goto fetch_file_process_dir_aborted;
/* Print parent directory link */
- res = url_parent(ctx->url, &up);
+ res = url_parent(nsurl_access(ctx->url), &up);
if (res == URL_FUNC_OK) {
- res = url_compare(ctx->url, up, false, &compare);
+ res = url_compare(nsurl_access(ctx->url), up, false, &compare);
if ((res == URL_FUNC_OK) && compare == false) {
dirlist_generate_parent_link(up, buffer, sizeof buffer);