From 56e7b234152e5bd792d2885db2eabab008064b5e Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 10 Oct 2011 22:41:31 +0000 Subject: add about:imagecache some of teh implementation needs cleaning up svn path=/trunk/netsurf/; revision=13030 --- content/fetchers/about.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'content/fetchers') diff --git a/content/fetchers/about.c b/content/fetchers/about.c index 5c33c1881..cb533bc54 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -54,6 +54,7 @@ #include "utils/utils.h" #include "utils/ring.h" #include "utils/testament.h" +#include "image/image_cache.h" struct fetch_about_context; @@ -159,7 +160,88 @@ static bool fetch_about_licence_handler(struct fetch_about_context *ctx) return true; } +/** Handler to generate about:cache page. + * + * Shows details of current iamge cache + * + */ +static bool fetch_about_imagecache_handler(struct fetch_about_context *ctx) +{ + char buffer[1024]; /* output buffer */ + int code = 200; + int slen; + unsigned int cent_loop = 0; + int res = 0; + /* content is going to return ok */ + fetch_set_http_code(ctx->fetchh, code); + + /* content type */ + if (fetch_about_send_header(ctx, "Content-Type: text/html")) + goto fetch_about_imagecache_handler_aborted; + + slen = snprintf(buffer, sizeof buffer, + "\n\n" + "NetSurf Browser Image Cache Status\n" + "\n" + "\n" + "\n" + "

" + "" + "\"NetSurf\"" + "

\n" + "

NetSurf Browser Image Cache Status

\n" ); + if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, + slen, FETCH_ERROR_NO_ERROR)) + goto fetch_about_imagecache_handler_aborted; + + slen = image_cache_snsummaryf(buffer, sizeof(buffer), NULL); + + if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, + slen, FETCH_ERROR_NO_ERROR)) + goto fetch_about_imagecache_handler_aborted; + + slen = snprintf(buffer, sizeof buffer, + "\n" + "\n"); + do { + res = image_cache_snentryf(buffer + slen, sizeof buffer - slen, + cent_loop, + "\n"); + if (res <= 0) + break; /* last option */ + + if (res >= (int) (sizeof buffer - slen)) { + /* last entry would not fit in buffer, submit buffer */ + if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, + slen, FETCH_ERROR_NO_ERROR)) + goto fetch_about_imagecache_handler_aborted; + slen = 0; + } else { + /* normal addition */ + slen += res; + cent_loop++; + } + } while (res > 0); + + slen += snprintf(buffer + slen, sizeof buffer - slen, + "
EntryContent KeyRedraw CountConversion CountLast RedrawBitmap AgeBitmap Size
%e%k%r%c%a%g%s
\n\n\n"); + + if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen, + FETCH_ERROR_NO_ERROR)) + goto fetch_about_imagecache_handler_aborted; + + fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0, + FETCH_ERROR_NO_ERROR); + + return true; + +fetch_about_imagecache_handler_aborted: + return false; +} + +/** Handler to generate about:config page */ static bool fetch_about_config_handler(struct fetch_about_context *ctx) { char buffer[1024]; @@ -226,6 +308,7 @@ fetch_about_config_handler_aborted: return false; } + /** Generate the text of a Choices file which represents the current * in use options. */ @@ -408,7 +491,9 @@ struct about_handlers about_handler_list[] = { { "testament", SLEN("testament"), NULL, fetch_about_testament_handler, false }, { "about", SLEN("about"), NULL, fetch_about_about_handler, true }, { "logo", SLEN("logo"), NULL, fetch_about_logo_handler, true }, - /* The default */ + /* details about the cache */ + { "imagecache", SLEN("iamgecache"), NULL, fetch_about_imagecache_handler, true }, + /* The default blank page */ { "blank", SLEN("blank"), NULL, fetch_about_blank_handler, true } }; -- cgit v1.2.3