Make puzzles generate static HTML

This commit is contained in:
Neale Pickett 2010-09-12 22:15:06 -06:00
parent 61e6984777
commit 23b6f28a21
3 changed files with 9 additions and 18 deletions

View File

@ -1,13 +1,13 @@
TARGETS = in.tokend claim.cgi puzzler.cgi pointscli TARGETS = in.tokend claim.cgi puzzler.cgi pointscli puzzles
all: $(TARGETS) all: $(TARGETS)
in.tokend: in.tokend.o xxtea.o in.tokend: in.tokend.o xxtea.o
puzzles: puzzles.o common.o
pointscli: pointscli.o common.o
claim.cgi: claim.cgi.o common.o claim.cgi: claim.cgi.o common.o
puzzler.cgi: puzzler.cgi.o common.o puzzler.cgi: puzzler.cgi.o common.o
puzzles.cgi: puzzles.cgi.o common.o
pointscli: common.o pointscli.o
clean: clean:
rm -f $(TARGETS) *.o rm -f $(TARGETS) *.o

View File

@ -13,6 +13,7 @@
* CGI * CGI
*/ */
static size_t inlen = 0; static size_t inlen = 0;
static int is_cgi = 0;
int int
cgi_init() cgi_init()
@ -30,6 +31,7 @@ cgi_init()
} }
inlen = atoi(getenv("CONTENT_LENGTH")); inlen = atoi(getenv("CONTENT_LENGTH"));
is_cgi = 1;
return 0; return 0;
} }
@ -102,9 +104,10 @@ cgi_item(char *str, size_t maxlen)
void void
cgi_head(char *title) cgi_head(char *title)
{ {
printf(("Content-type: text/html\r\n" if (is_cgi) {
"\r\n" printf("Content-type: text/html\r\n\r\n");
"<!DOCTYPE html>\n" }
printf(("<!DOCTYPE html>\n"
"<html>\n" "<html>\n"
" <head>\n" " <head>\n"
" <title>%s</title>\n" " <title>%s</title>\n"

View File

@ -59,20 +59,8 @@ main(int argc, char *argv[])
int i; int i;
DIR *srv; DIR *srv;
#if 0
if (! cgi_init()) {
return 0;
}
#endif
read_points_by_cat(); 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/ */ /* Open /srv/ */
srv = opendir("/srv"); srv = opendir("/srv");
if (NULL == srv) { if (NULL == srv) {