summaryrefslogtreecommitdiff
path: root/content/fetchers/about.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-02-20 21:04:53 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-02-20 21:04:53 +0000
commit675a07083acbfd276c4d80fbf5df4d18fb8e5742 (patch)
tree1640f3d772b95090a403d15cf9d9e8633eb6da43 /content/fetchers/about.c
parent2668db202427c2b89d15ef0b91dfe0d173350b4e (diff)
downloadnetsurf-675a07083acbfd276c4d80fbf5df4d18fb8e5742.tar.gz
netsurf-675a07083acbfd276c4d80fbf5df4d18fb8e5742.tar.bz2
add options display to about: scheme
svn path=/trunk/netsurf/; revision=11733
Diffstat (limited to 'content/fetchers/about.c')
-rw-r--r--content/fetchers/about.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index c0507aaa4..c93fdbad4 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -175,6 +175,120 @@ fetch_about_credits_handler_aborted:
return false;
}
+static bool fetch_about_config_handler(struct fetch_about_context *ctx)
+{
+ 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/html"))
+ goto fetch_about_config_handler_aborted;
+
+ slen = snprintf(buffer, sizeof buffer,
+ "<html><head><title>NetSurf Browser Config</title>"
+ "<style type=\"text/css\">"
+ ".null-content { font-style: italic }"
+ "</style></head>"
+ "<body><h1>NetSurf Browser Config</h1>"
+ "<table><tr><th></th><th></th><th></th></tr>");
+
+ do {
+ res = snoptionf(buffer + slen, sizeof buffer - slen, opt_loop,
+ "<tr><td>%k</td><td>%t</td><td>%V</td></tr>");
+ if (res <= 0)
+ break; /* last option */
+
+ if (res >= (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_config_handler_aborted;
+ slen = 0;
+ } else {
+ /* normal addition */
+ slen += res;
+ opt_loop++;
+ }
+ } while (res > 0);
+
+ slen += snprintf(buffer + slen, sizeof buffer - slen,
+ "</table></body></html>");
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_config_handler_aborted;
+
+ fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
+ FETCH_ERROR_NO_ERROR);
+
+ return true;
+
+fetch_about_config_handler_aborted:
+ return false;
+}
+
+/** Generate the text of a Choices file which represents the current
+ * in use options.
+ */
+static bool fetch_about_choices_handler(struct fetch_about_context *ctx)
+{
+ 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;
+
+ slen = snprintf(buffer, sizeof buffer,
+ "# Automatically generated current NetSurf browser Choices\n");
+
+ do {
+ res = snoptionf(buffer + slen,
+ sizeof buffer - slen,
+ opt_loop,
+ "%k:%v\n");
+ if (res <= 0)
+ break; /* last option */
+
+ if (res >= (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_choices_handler_aborted;
+ slen = 0;
+ } else {
+ /* normal addition */
+ slen += res;
+ opt_loop++;
+ }
+ } while (res > 0);
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_choices_handler_aborted;
+
+ fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
+ FETCH_ERROR_NO_ERROR);
+
+ return true;
+
+fetch_about_choices_handler_aborted:
+ return false;
+}
+
+
struct about_handlers {
const char *name;
fetch_about_handler handler;
@@ -182,6 +296,8 @@ struct about_handlers {
struct about_handlers about_handler_list[] = {
{ "credits", fetch_about_credits_handler },
+ { "config", fetch_about_config_handler },
+ { "Choices", fetch_about_choices_handler },
{ "blank", fetch_about_blank_handler } /* The default */
};