From 23b6f28a211e743df6dca3a802e2cfb4aa4653dd Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 12 Sep 2010 22:15:06 -0600 Subject: [PATCH] Make puzzles generate static HTML --- src/Makefile | 6 +++--- src/common.c | 9 ++++++--- src/{puzzles.cgi.c => puzzles.c} | 12 ------------ 3 files changed, 9 insertions(+), 18 deletions(-) rename src/{puzzles.cgi.c => puzzles.c} (94%) diff --git a/src/Makefile b/src/Makefile index 4c85e90..35f1ef1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,13 +1,13 @@ -TARGETS = in.tokend claim.cgi puzzler.cgi pointscli +TARGETS = in.tokend claim.cgi puzzler.cgi pointscli puzzles all: $(TARGETS) in.tokend: in.tokend.o xxtea.o +puzzles: puzzles.o common.o +pointscli: pointscli.o common.o claim.cgi: claim.cgi.o common.o puzzler.cgi: puzzler.cgi.o common.o -puzzles.cgi: puzzles.cgi.o common.o -pointscli: common.o pointscli.o clean: rm -f $(TARGETS) *.o diff --git a/src/common.c b/src/common.c index a21c677..3adeb60 100644 --- a/src/common.c +++ b/src/common.c @@ -13,6 +13,7 @@ * CGI */ static size_t inlen = 0; +static int is_cgi = 0; int cgi_init() @@ -30,6 +31,7 @@ cgi_init() } inlen = atoi(getenv("CONTENT_LENGTH")); + is_cgi = 1; return 0; } @@ -102,9 +104,10 @@ cgi_item(char *str, size_t maxlen) void cgi_head(char *title) { - printf(("Content-type: text/html\r\n" - "\r\n" - "\n" + if (is_cgi) { + printf("Content-type: text/html\r\n\r\n"); + } + printf(("\n" "\n" " \n" " %s\n" diff --git a/src/puzzles.cgi.c b/src/puzzles.c similarity index 94% rename from src/puzzles.cgi.c rename to src/puzzles.c index 643c64b..e565a14 100644 --- a/src/puzzles.cgi.c +++ b/src/puzzles.c @@ -59,20 +59,8 @@ main(int argc, char *argv[]) int i; DIR *srv; -#if 0 - if (! cgi_init()) { - return 0; - } -#endif - read_points_by_cat(); -#if 0 - for (i = 0; i < ncats; i += 1) { - printf("%s: %ld\n", points_by_cat[i].cat, points_by_cat[i].points); - } -#endif - /* Open /srv/ */ srv = opendir("/srv"); if (NULL == srv) {