From ff3b948ac0ee0142535bea9a6ebde57b7056c2eb Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 27 Sep 2020 00:39:56 +0100 Subject: split out choices about scheme handler --- content/fetchers/about/about.c | 68 +----------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'content/fetchers/about/about.c') diff --git a/content/fetchers/about/about.c b/content/fetchers/about/about.c index e41e6c899..1bc382b57 100644 --- a/content/fetchers/about/about.c +++ b/content/fetchers/about/about.c @@ -53,6 +53,7 @@ #include "imagecache.h" #include "atestament.h" #include "config.h" +#include "choices.h" #include "about.h" typedef bool (*fetch_about_handler)(struct fetch_about_context *); @@ -289,8 +290,6 @@ static bool fetch_about_licence_handler(struct fetch_about_context *ctx) } - - /** * Handler to generate the nscolours stylesheet * @@ -336,71 +335,6 @@ aborted: } -/** - * Generate the text of a Choices file which represents the current - * in use options. - * - * \param ctx The fetcher context. - * \return true if handled false if aborted. - */ -static bool fetch_about_choices_handler(struct fetch_about_context *ctx) -{ - fetch_msg msg; - char buffer[1024]; - int code = 200; - int slen; - unsigned int opt_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/plain")) - goto fetch_about_choices_handler_aborted; - - msg.type = FETCH_DATA; - msg.data.header_or_data.buf = (const uint8_t *) buffer; - - slen = snprintf(buffer, sizeof buffer, - "# Automatically generated current NetSurf browser Choices\n"); - - do { - res = nsoption_snoptionf(buffer + slen, - sizeof buffer - slen, - opt_loop, - "%k:%v\n"); - if (res <= 0) - break; /* last option */ - - if (res >= (int) (sizeof buffer - slen)) { - /* last entry would not fit in buffer, submit buffer */ - msg.data.header_or_data.len = slen; - if (fetch_about_send_callback(&msg, ctx)) - goto fetch_about_choices_handler_aborted; - slen = 0; - } else { - /* normal addition */ - slen += res; - opt_loop++; - } - } while (res > 0); - - msg.data.header_or_data.len = slen; - if (fetch_about_send_callback(&msg, ctx)) - goto fetch_about_choices_handler_aborted; - - fetch_about_send_finished(ctx); - - return true; - -fetch_about_choices_handler_aborted: - return false; -} - - - - /** * Handler to generate about scheme logo page * -- cgit v1.2.3