summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-06-29 06:05:29 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-06-29 06:05:29 +0000
commit6ab058fb464c8ac5e7ae7dedf514fd12cdb00eca (patch)
treedd7d66f5ebf4676fa31741ccc297dbcf1dae5b22
parentbd6c8840206cc9a378a82035914ce48df5fd2534 (diff)
downloadnetsurf-6ab058fb464c8ac5e7ae7dedf514fd12cdb00eca.tar.gz
netsurf-6ab058fb464c8ac5e7ae7dedf514fd12cdb00eca.tar.bz2
Make test compile
svn path=/trunk/netsurf/; revision=10587
-rw-r--r--test/llcache.c59
1 files changed, 53 insertions, 6 deletions
diff --git a/test/llcache.c b/test/llcache.c
index be0df60ad..b7b6fd05c 100644
--- a/test/llcache.c
+++ b/test/llcache.c
@@ -1,5 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#include <curl/curl.h>
#include "content/fetch.h"
#include "content/llcache.h"
@@ -27,6 +30,20 @@ void warn_user(const char *warning, const char *detail)
fprintf(stderr, "%s %s\n", warning, detail);
}
+/* utils/utils.h */
+char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
/* content/fetch.h */
const char *fetch_filetype(const char *unix_path)
{
@@ -39,6 +56,38 @@ char *fetch_mimetype(const char *ro_path)
return NULL;
}
+/* utils/url.h */
+char *path_to_url(const char *path)
+{
+ int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
+ char *url = malloc(urllen);
+
+ if (url == NULL) {
+ return NULL;
+ }
+
+ if (*path == '/') {
+ path++; /* file: paths are already absolute */
+ }
+
+ snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
+
+ return url;
+}
+
+/* utils/url.h */
+char *url_to_path(const char *url)
+{
+ char *url_path = curl_unescape(url, 0);
+ char *path;
+
+ /* return the absolute path including leading / */
+ path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1));
+ curl_free(url_path);
+
+ return path;
+}
+
/******************************************************************************
* Things that are absolutely not reasonable, and should disappear *
******************************************************************************/
@@ -120,7 +169,7 @@ void test_finalise(const char *scheme)
void *test_setup_fetch(struct fetch *parent, const char *url, bool only_2xx,
const char *post_urlenc,
- struct fetch_multipart_data *post_multipart,
+ const struct fetch_multipart_data *post_multipart,
const char **headers)
{
test_context *ctx = calloc(1, sizeof(test_context));
@@ -198,7 +247,7 @@ nserror query_handler(const llcache_query *query, void *pw,
return NSERROR_OK;
}
-nserror event_handler(const llcache_handle *handle,
+nserror event_handler(llcache_handle *handle,
const llcache_event *event, void *pw)
{
static char *event_names[] = {
@@ -266,10 +315,8 @@ int main(int argc, char **argv)
llcache_poll();
}
- fprintf(stdout, "%p -> %p\n", handle,
- llcache_object_from_handle(handle));
- fprintf(stdout, "%p -> %p\n", handle2,
- llcache_object_from_handle(handle2));
+ fprintf(stdout, "%p, %p -> %d\n", handle, handle2,
+ llcache_handle_references_same_object(handle, handle2));
/* Cleanup */
llcache_handle_release(handle2);