From 62245d13ec60e3c0fc78221f0a8f754f33c2b6a1 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 5 Jan 2004 02:10:59 +0000 Subject: [project @ 2004-01-05 02:10:59 by jmb] Add ability to turn off browser features in build. This may be useful when hunting down bugs. svn path=/import/netsurf/; revision=480 --- content/content.c | 39 +++++++++++++++++++++++++++++++++++++++ content/content.h | 39 +++++++++++++++++++++++++++++++++++++++ content/fetch.c | 27 ++++++++++++++++++++++++++- content/fetch.h | 20 +++++++++++++++++--- content/fetchcache.c | 17 +++++++++++++---- content/fetchcache.h | 7 ++++++- 6 files changed, 140 insertions(+), 9 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index a3ff9f777..91481ff48 100644 --- a/content/content.c +++ b/content/content.c @@ -15,19 +15,32 @@ #include #include #include +#include "netsurf/utils/config.h" #include "netsurf/content/content.h" #include "netsurf/content/other.h" #include "netsurf/css/css.h" #include "netsurf/render/html.h" #include "netsurf/render/textplain.h" #ifdef riscos +#ifdef WITH_JPEG #include "netsurf/riscos/jpeg.h" +#endif +#ifdef WITH_PNG #include "netsurf/riscos/png.h" +#endif +#ifdef WITH_GIF #include "netsurf/riscos/gif.h" +#endif +#ifdef WITH_SPRITE #include "netsurf/riscos/sprite.h" +#endif +#ifdef WITH_DRAW #include "netsurf/riscos/draw.h" +#endif +#ifdef WITH_PLUGIN #include "netsurf/riscos/plugin.h" #endif +#endif #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -40,14 +53,26 @@ struct mime_entry { /** A map from MIME type to ::content_type. Must be sorted by mime_type. */ static const struct mime_entry mime_map[] = { #ifdef riscos +#ifdef WITH_DRAW {"application/drawfile", CONTENT_DRAW}, {"application/x-drawfile", CONTENT_DRAW}, {"image/drawfile", CONTENT_DRAW}, +#endif +#ifdef WITH_GIF {"image/gif", CONTENT_GIF}, +#endif +#ifdef WITH_JPEG {"image/jpeg", CONTENT_JPEG}, +#endif +#ifdef WITH_PNG {"image/png", CONTENT_PNG}, +#endif +#ifdef WITH_DRAW {"image/x-drawfile", CONTENT_DRAW}, +#endif +#ifdef WITH_SPRITE {"image/x-riscos-sprite", CONTENT_SPRITE}, +#endif #endif {"text/css", CONTENT_CSS}, {"text/html", CONTENT_HTML}, @@ -85,24 +110,36 @@ static const struct handler_entry handler_map[] = { {textplain_create, textplain_process_data, textplain_convert, textplain_revive, textplain_reformat, textplain_destroy, 0, 0, 0, 0}, #ifdef riscos +#ifdef WITH_JPEG {jpeg_create, jpeg_process_data, jpeg_convert, jpeg_revive, jpeg_reformat, jpeg_destroy, jpeg_redraw, 0, 0, 0}, +#endif #endif {css_create, css_process_data, css_convert, css_revive, css_reformat, css_destroy, 0, 0, 0, 0}, #ifdef riscos +#ifdef WITH_PNG {nspng_create, nspng_process_data, nspng_convert, nspng_revive, nspng_reformat, nspng_destroy, nspng_redraw, 0, 0, 0}, +#endif +#ifdef WITH_GIF {nsgif_create, nsgif_process_data, nsgif_convert, nsgif_revive, nsgif_reformat, nsgif_destroy, nsgif_redraw, 0, 0, 0}, +#endif +#ifdef WITH_SPRITE {sprite_create, sprite_process_data, sprite_convert, sprite_revive, sprite_reformat, sprite_destroy, sprite_redraw, 0, 0, 0}, +#endif +#ifdef WITH_DRAW {draw_create, draw_process_data, draw_convert, draw_revive, draw_reformat, draw_destroy, draw_redraw, 0, 0, 0}, +#endif +#ifdef WITH_PLUGIN {plugin_create, plugin_process_data, plugin_convert, plugin_revive, plugin_reformat, plugin_destroy, plugin_redraw, plugin_add_instance, plugin_remove_instance, plugin_reshape_instance}, +#endif #endif {other_create, other_process_data, other_convert, other_revive, other_reformat, other_destroy, 0, 0, 0, 0} @@ -123,8 +160,10 @@ content_type content_lookup(const char *mime_type) (int (*)(const void *, const void *)) strcmp); if (m == 0) { #ifdef riscos +#ifdef WITH_PLUGIN if (plugin_handleable(mime_type)) return CONTENT_PLUGIN; +#endif #endif return CONTENT_OTHER; } diff --git a/content/content.h b/content/content.h index 2e4a36f31..ffd73ab06 100644 --- a/content/content.h +++ b/content/content.h @@ -26,6 +26,7 @@ #define _NETSURF_DESKTOP_CONTENT_H_ #include "libxml/HTMLparser.h" +#include "netsurf/utils/config.h" #include "netsurf/content/cache.h" #include "netsurf/content/fetch.h" #include "netsurf/content/other.h" @@ -34,13 +35,25 @@ #include "netsurf/render/font.h" #include "netsurf/render/html.h" #ifdef riscos +#ifdef WITH_GIF #include "netsurf/riscos/gif.h" +#endif +#ifdef WITH_JPEG #include "netsurf/riscos/jpeg.h" +#endif +#ifdef WITH_PLUGIN #include "netsurf/riscos/plugin.h" +#endif +#ifdef WITH_PNG #include "netsurf/riscos/png.h" +#endif +#ifdef WITH_SPRITE #include "netsurf/riscos/sprite.h" +#endif +#ifdef WITH_DRAW #include "netsurf/riscos/draw.h" #endif +#endif /** The type of a content. */ @@ -48,15 +61,27 @@ typedef enum { CONTENT_HTML, CONTENT_TEXTPLAIN, #ifdef riscos +#ifdef WITH_JPEG CONTENT_JPEG, +#endif #endif CONTENT_CSS, #ifdef riscos +#ifdef WITH_PNG CONTENT_PNG, +#endif +#ifdef WITH_GIF CONTENT_GIF, +#endif +#ifdef WITH_SPRITE CONTENT_SPRITE, +#endif +#ifdef WITH_DRAW CONTENT_DRAW, +#endif +#ifdef WITH_PLUGIN CONTENT_PLUGIN, +#endif #endif CONTENT_OTHER, CONTENT_UNKNOWN /**< content-type not received yet */ @@ -72,7 +97,9 @@ typedef enum { CONTENT_MSG_STATUS, /**< new status string */ CONTENT_MSG_REDIRECT, /**< replacement URL */ CONTENT_MSG_REFORMAT, /**< content_reformat done */ +#ifdef WITH_AUTH CONTENT_MSG_AUTH /**< authentication required */ +#endif } content_msg; /** Linked list of users of a content. */ @@ -108,12 +135,24 @@ struct content { struct content_html_data html; struct content_css_data css; #ifdef riscos +#ifdef WITH_JPEG struct content_jpeg_data jpeg; +#endif +#ifdef WITH_PNG struct content_png_data png; +#endif +#ifdef WITH_GIF struct content_gif_data gif; +#endif +#ifdef WITH_SPRITE struct content_sprite_data sprite; +#endif +#ifdef WITH_DRAW struct content_draw_data draw; +#endif +#ifdef WITH_PLUGIN struct content_plugin_data plugin; +#endif #endif struct content_other_data other; } data; diff --git a/content/fetch.c b/content/fetch.c index 4df9d546b..87dbe79f5 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -27,12 +27,15 @@ #include #include "curl/curl.h" #include "libxml/uri.h" +#include "netsurf/utils/config.h" #include "netsurf/content/fetch.h" #ifdef riscos #include "netsurf/desktop/gui.h" #endif #include "netsurf/desktop/options.h" +#ifdef WITH_AUTH #include "netsurf/desktop/401login.h" +#endif #include "netsurf/render/form.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" @@ -58,7 +61,9 @@ struct fetch { char *host; /**< Host part of URL. */ char *location; /**< Response Location header, or 0. */ unsigned long content_length; /**< Response Content-Length, or 0. */ +#ifdef WITH_AUTH char *realm; /**< HTTP Auth Realm */ +#endif char *post_urlenc; /**< Url encoded POST string, or 0. */ struct HttpPost *post_multipart; /**< Multipart post data, or 0. */ struct fetch *queue_prev; /**< Previous fetch for this host. */ @@ -151,13 +156,19 @@ void fetch_quit(void) struct fetch * fetch_start(char *url, char *referer, void (*callback)(fetch_msg msg, void *p, char *data, unsigned long size), void *p, bool only_2xx, char *post_urlenc, - struct form_successful_control *post_multipart, bool cookies) + struct form_successful_control *post_multipart +#ifdef WITH_COOKIES + , bool cookies +#endif + ) { struct fetch *fetch = xcalloc(1, sizeof(*fetch)), *host_fetch; CURLcode code; CURLMcode codem; xmlURI *uri; +#ifdef WITH_AUTH struct login *li; +#endif LOG(("fetch %p, url '%s'", fetch, url)); @@ -278,6 +289,7 @@ struct fetch * fetch_start(char *url, char *referer, } /* HTTP auth */ +#ifdef WITH_AUTH if ((li=login_list_get(url)) != NULL) { code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); assert(code == CURLE_OK); @@ -286,6 +298,7 @@ struct fetch * fetch_start(char *url, char *referer, assert(code == CURLE_OK); } +#endif /* POST */ if (fetch->post_urlenc) { @@ -299,6 +312,7 @@ struct fetch * fetch_start(char *url, char *referer, } /* Cookies */ +#ifdef WITH_COOKIES if (cookies) { code = curl_easy_setopt(fetch->curl_handle, CURLOPT_COOKIEFILE, messages_get("cookiefile")); @@ -307,6 +321,7 @@ struct fetch * fetch_start(char *url, char *referer, messages_get("cookiejar")); assert(code == CURLE_OK); } +#endif /* add to the global curl multi handle */ codem = curl_multi_add_handle(curl_multi, fetch->curl_handle); @@ -323,7 +338,9 @@ struct fetch * fetch_start(char *url, char *referer, void fetch_abort(struct fetch *f) { CURLMcode codem; +#ifdef WITH_AUTH struct login *li; +#endif assert(f != 0); LOG(("fetch %p, url '%s'", f, f->url)); @@ -381,6 +398,7 @@ void fetch_abort(struct fetch *f) } /* HTTP auth */ +#ifdef WITH_AUTH if ((li=login_list_get(f->url)) != NULL) { code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); assert(code == CURLE_OK); @@ -389,6 +407,7 @@ void fetch_abort(struct fetch *f) assert(code == CURLE_OK); } +#endif /* POST */ if (fetch->post_urlenc) { @@ -425,7 +444,9 @@ void fetch_abort(struct fetch *f) free(f->host); free(f->referer); free(f->location); +#ifdef WITH_AUTH free(f->realm); +#endif free(f->post_urlenc); if (f->post_multipart) curl_formfree(f->post_multipart); @@ -552,12 +573,14 @@ size_t fetch_curl_header(char * data, size_t size, size_t nmemb, struct fetch *f ; if ('0' <= data[i] && data[i] <= '9') f->content_length = atol(data + i); +#ifdef WITH_AUTH } else if (16 < size && strncasecmp(data, "WWW-Authenticate",16) == 0) { /* extract Realm from WWW-Authenticate header */ f->realm = xcalloc(size, 1); for (i=16;(unsigned int)i!=strlen(data);i++) if(data[i]=='=')break; strncpy(f->realm, data+i+2, size-i-5); +#endif } return size; } @@ -589,10 +612,12 @@ bool fetch_process_headers(struct fetch *f) } /* handle HTTP 401 (Authentication errors) */ +#ifdef WITH_AUTH if (http_code == 401) { f->callback(FETCH_AUTH, f->p, f->realm,0); return true; } +#endif /* handle HTTP errors (non 2xx response codes) */ if (f->only_2xx && strncmp(f->url, "http", 4) == 0 && diff --git a/content/fetch.h b/content/fetch.h index 159921610..5075f6058 100644 --- a/content/fetch.h +++ b/content/fetch.h @@ -13,8 +13,18 @@ #define _NETSURF_DESKTOP_FETCH_H_ #include - -typedef enum {FETCH_TYPE, FETCH_DATA, FETCH_FINISHED, FETCH_ERROR, FETCH_REDIRECT, FETCH_AUTH} fetch_msg; +#include "netsurf/utils/config.h" + +typedef enum { + FETCH_TYPE, + FETCH_DATA, + FETCH_FINISHED, + FETCH_ERROR, + FETCH_REDIRECT, +#ifdef WITH_AUTH + FETCH_AUTH +#endif +} fetch_msg; struct content; struct fetch; @@ -26,7 +36,11 @@ void fetch_init(void); struct fetch * fetch_start(char *url, char *referer, void (*callback)(fetch_msg msg, void *p, char *data, unsigned long size), void *p, bool only_2xx, char *post_urlenc, - struct form_successful_control *post_multipart, bool cookies); + struct form_successful_control *post_multipart +#ifdef WITH_COOKIES + ,bool cookies +#endif + ); void fetch_abort(struct fetch *f); void fetch_poll(void); void fetch_quit(void); diff --git a/content/fetchcache.c b/content/fetchcache.c index cc755e73c..b3eac27fa 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -17,6 +17,7 @@ #include #include #include +#include "netsurf/utils/config.h" #include "netsurf/content/cache.h" #include "netsurf/content/content.h" #include "netsurf/content/fetchcache.h" @@ -47,7 +48,11 @@ struct content * fetchcache(const char *url0, char *referer, void *p2, const char *error), void *p1, void *p2, unsigned long width, unsigned long height, bool only_2xx, char *post_urlenc, - struct form_successful_control *post_multipart, bool cookies) + struct form_successful_control *post_multipart +#ifdef WITH_COOKIES + ,bool cookies +#endif + ) { struct content *c; char *url = xstrdup(url0); @@ -76,7 +81,11 @@ struct content * fetchcache(const char *url0, char *referer, c->width = width; c->height = height; c->fetch = fetch_start(url, referer, fetchcache_callback, c, only_2xx, - post_urlenc, post_multipart, cookies); + post_urlenc, post_multipart +#ifdef WITH_COOKIES + ,cookies +#endif + ); free(url); if (c->fetch == 0) { LOG(("warning: fetch_start failed")); @@ -162,7 +171,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size) cache_destroy(c); content_destroy(c); break; - +#ifdef WITH_AUTH case FETCH_AUTH: /* data -> string containing the Realm */ LOG(("FETCH_AUTH, '%s'", data)); @@ -170,7 +179,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size) content_broadcast(c, CONTENT_MSG_AUTH, data); cache_destroy(c); break; - +#endif default: assert(0); } diff --git a/content/fetchcache.h b/content/fetchcache.h index 12326970b..bc1cfb76e 100644 --- a/content/fetchcache.h +++ b/content/fetchcache.h @@ -16,6 +16,7 @@ #define _NETSURF_DESKTOP_FETCHCACHE_H_ #include +#include "netsurf/utils/config.h" #include "netsurf/content/content.h" struct form_successful_control; @@ -25,7 +26,11 @@ struct content * fetchcache(const char *url, char *referer, void *p2, const char *error), void *p1, void *p2, unsigned long width, unsigned long height, bool only_2xx, char *post_urlenc, - struct form_successful_control *post_multipart, bool cookies); + struct form_successful_control *post_multipart +#ifdef WITH_COOKIES + ,bool cookies +#endif + ); void fetchcache_init(void); #endif -- cgit v1.2.3