summaryrefslogtreecommitdiff
path: root/content/fetchers/about.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2011-03-13 11:59:20 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2011-03-13 11:59:20 +0000
commitcc18b5f21e5c81c87e547b496eb4cf083aafb513 (patch)
treef81b24a0cc60302236b842eb8045c0e0675efac2 /content/fetchers/about.c
parentc29ae3efef044c5262db9c7e240c76b14874dc76 (diff)
downloadnetsurf-cc18b5f21e5c81c87e547b496eb4cf083aafb513.tar.gz
netsurf-cc18b5f21e5c81c87e547b496eb4cf083aafb513.tar.bz2
Initial testament functionality
svn path=/trunk/netsurf/; revision=12020
Diffstat (limited to 'content/fetchers/about.c')
-rw-r--r--content/fetchers/about.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 4d6b13ce0..1f441d485 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -46,6 +46,7 @@
#include "utils/url.h"
#include "utils/utils.h"
#include "utils/ring.h"
+#include "utils/testament.h"
struct fetch_about_context;
@@ -279,6 +280,88 @@ fetch_about_choices_handler_aborted:
return false;
}
+/** Generate the text of an svn testament which represents the current
+ * build-tree status
+ */
+typedef struct { const char *leaf; const char modtype; } modification_t;
+static bool fetch_about_testament_handler(struct fetch_about_context *ctx)
+{
+ static modification_t modifications[] = WT_MODIFICATIONS;
+ char buffer[1024];
+ int code = 200;
+ int slen;
+ int i;
+
+
+ /* 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_testament_handler_aborted;
+
+ slen = snprintf(buffer, sizeof buffer,
+ "# Automatically generated by NetSurf build system\n\n");
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+ slen = snprintf(buffer, sizeof buffer,
+#if defined(WT_BRANCHISTRUNK)
+ "# This is a *DEVELOPMENT* build from the trunk.\n\n"
+#elif defined(WT_BRANCHISRELEASE)
+ "# This is a release build of NetSurf\n\n"
+#else
+ "# This NetSurf was built from a branch.\n\n"
+#endif
+ );
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+
+ slen = snprintf(buffer, sizeof buffer,
+ "Built by %s (%s) from %s at revision %s\n\n",
+ GECOS, USERNAME, WT_BRANCHPATH, WT_REVID);
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+ if (WT_MODIFIED > 0) {
+ slen = snprintf(buffer, sizeof buffer,
+ "Working tree has %d modification%s\n\n",
+ WT_MODIFIED, WT_MODIFIED == 1 ? "" : "s");
+ } else {
+ slen = snprintf(buffer, sizeof buffer,
+ "Working tree is not modified.\n");
+ }
+
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+ for (i = 0; i < WT_MODIFIED; ++i) {
+ slen = snprintf(buffer, sizeof buffer,
+ " %c %s\n",
+ modifications[i].modtype,
+ modifications[i].leaf);
+ if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
+ FETCH_ERROR_NO_ERROR))
+ goto fetch_about_testament_handler_aborted;
+
+ }
+
+ fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
+ FETCH_ERROR_NO_ERROR);
+
+ return true;
+
+fetch_about_testament_handler_aborted:
+ return false;
+}
struct about_handlers {
const char *name;
@@ -290,6 +373,7 @@ struct about_handlers about_handler_list[] = {
{ "licence", fetch_about_licence_handler },
{ "config", fetch_about_config_handler },
{ "Choices", fetch_about_choices_handler },
+ { "testament", fetch_about_testament_handler },
{ "blank", fetch_about_blank_handler } /* The default */
};