From 8edb43af7dbf0b28892f9d8a8d8ddae523e41b73 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 25 Feb 2003 21:00:27 +0000 Subject: [project @ 2003-02-25 21:00:27 by bursa] Bug fixes, experimental JPEG support. svn path=/import/netsurf/; revision=100 --- content/content.c | 5 ++++- content/content.h | 11 ++++++----- content/fetch.c | 16 +++++++++------- content/fetchcache.c | 10 ++++++++-- 4 files changed, 27 insertions(+), 15 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index c8601400d..1b75f14ae 100644 --- a/content/content.c +++ b/content/content.c @@ -1,5 +1,5 @@ /** - * $Id: content.c,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: content.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ */ #include @@ -8,6 +8,7 @@ #include "netsurf/content/content.h" #include "netsurf/render/html.h" #include "netsurf/render/textplain.h" +#include "netsurf/riscos/jpeg.h" #include "netsurf/utils/utils.h" @@ -17,6 +18,7 @@ struct mime_entry { content_type type; }; static const struct mime_entry mime_map[] = { + {"image/jpeg", CONTENT_JPEG}, /* {"image/png", CONTENT_PNG}, {"text/css", CONTENT_CSS},*/ {"text/html", CONTENT_HTML}, @@ -37,6 +39,7 @@ static const struct handler_entry handler_map[] = { {html_create, html_process_data, html_convert, html_revive, html_reformat, html_destroy}, {textplain_create, textplain_process_data, textplain_convert, textplain_revive, textplain_reformat, textplain_destroy}, + {jpeg_create, jpeg_process_data, jpeg_convert, jpeg_revive, jpeg_destroy}, /* {css_create, css_process_data, css_convert, css_revive, css_destroy}, {png_create, png_process_data, png_convert, png_revive, png_destroy},*/ }; diff --git a/content/content.h b/content/content.h index ed93e7c24..94cbffe20 100644 --- a/content/content.h +++ b/content/content.h @@ -1,5 +1,5 @@ /** - * $Id: content.h,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: content.h,v 1.2 2003/02/25 21:00:27 bursa Exp $ */ #ifndef _NETSURF_DESKTOP_CONTENT_H_ @@ -26,7 +26,7 @@ * the content may be removed from the memory cache. */ -typedef enum {CONTENT_HTML, CONTENT_TEXTPLAIN, CONTENT_CSS, +typedef enum {CONTENT_HTML, CONTENT_TEXTPLAIN, CONTENT_JPEG, CONTENT_CSS, CONTENT_PNG, CONTENT_OTHER} content_type; struct box_position @@ -44,6 +44,7 @@ struct content char *url; content_type type; enum {CONTENT_LOADING, CONTENT_READY} status; + unsigned long width, height; union { @@ -72,9 +73,9 @@ struct content struct { - unsigned long width, height; - char * sprite; - } image; + char * data; + unsigned long length; + } jpeg; } data; diff --git a/content/fetch.c b/content/fetch.c index 63283238a..6e6e50ce3 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -1,5 +1,5 @@ /** - * $Id: fetch.c,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: fetch.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ */ #include @@ -9,11 +9,6 @@ #include "netsurf/utils/utils.h" #include "netsurf/utils/log.h" -#ifndef TEST -#else -#include -#endif - struct fetch { time_t start_time; @@ -94,6 +89,8 @@ struct fetch * fetch_start(char *url, char *referer, /* create the curl easy handle */ fetch->curl_handle = curl_easy_init(); assert(fetch->curl_handle != 0); /* TODO: handle curl errors */ + code = curl_easy_setopt(fetch->curl_handle, CURLOPT_VERBOSE, 1); + assert(code == CURLE_OK); code = curl_easy_setopt(fetch->curl_handle, CURLOPT_URL, fetch->url); assert(code == CURLE_OK); code = curl_easy_setopt(fetch->curl_handle, CURLOPT_PRIVATE, fetch); @@ -211,7 +208,7 @@ size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f) { f->in_callback = 1; - LOG(("fetch %p, size %lu", f, size * nmemb)); + LOG(("fetch %p, size %u", f, size * nmemb)); if (!f->had_headers) { /* find the content type and inform the caller */ @@ -248,6 +245,8 @@ size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f) */ #ifdef TEST +#include + struct test {char *url; struct fetch *f;}; void callback(fetch_msg msg, struct test *t, char *data, unsigned long size) @@ -273,8 +272,11 @@ void callback(fetch_msg msg, struct test *t, char *data, unsigned long size) } struct test test[] = { + {"http://127.0.0.1/", 0}, + {"http://netsurf.strcprstskrzkrk.co.uk/", 0}, {"http://www.oxfordstudent.com/", 0}, {"http://www.google.co.uk/", 0}, + {"http://news.bbc.co.uk/", 0}, {"http://doesnt.exist/", 0}, {"blah://blah", 0}, }; diff --git a/content/fetchcache.c b/content/fetchcache.c index cd41f62ff..96c865b67 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -1,5 +1,5 @@ /** - * $Id: fetchcache.c,v 1.1 2003/02/09 12:58:14 bursa Exp $ + * $Id: fetchcache.c,v 1.2 2003/02/25 21:00:27 bursa Exp $ */ #include @@ -59,9 +59,15 @@ void fetchcache_free(struct fetchcache *fc) void fetchcache_callback(fetch_msg msg, struct fetchcache *fc, char *data, unsigned long size) { content_type type; + char *mime_type; + char *semic; switch (msg) { case FETCH_TYPE: - type = content_lookup(data); + mime_type = strdup(data); + if ((semic = strchr(mime_type, ';')) != 0) + *semic = 0; /* remove "; charset=..." */ + type = content_lookup(mime_type); + free(mime_type); LOG(("FETCH_TYPE, type %u", type)); if (type == CONTENT_OTHER) { fetch_abort(fc->f); -- cgit v1.2.3