Xmacros are too much work.
This commit is contained in:
parent
3610253996
commit
5c9512ce27
@ -2,6 +2,8 @@
|
|||||||
#define ADDR_FILE "badass.addr"
|
#define ADDR_FILE "badass.addr"
|
||||||
#define HTML_FILE "badass.html"
|
#define HTML_FILE "badass.html"
|
||||||
#define VALID_REFERER "http://neil.chaosnet.org/"
|
#define VALID_REFERER "http://neil.chaosnet.org/"
|
||||||
|
#define VOTE_TITLE "Which of these professions is the most badass?"
|
||||||
|
#define VOTE_BACK "<a href = \"/\">http://neil.chaosnet.org/</a>"
|
||||||
|
|
||||||
/* #define VOTES(X) \
|
/* #define VOTES(X) \
|
||||||
X('a', "astronaut"), \
|
X('a', "astronaut"), \
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define ADDR_FILE "movie.addr"
|
#define ADDR_FILE "movie.addr"
|
||||||
#define HTML_FILE "movie.html"
|
#define HTML_FILE "movie.html"
|
||||||
#define VALID_REFERER "http://neil.chaosnet.org/multiverse/"
|
#define VALID_REFERER "http://neil.chaosnet.org/multiverse/"
|
||||||
|
#define VOTE_TITLE "Which movie should we watch?"
|
||||||
|
#define VOTE_BACK "<a href = \"/multiverse/\">Multiverse</a>"
|
||||||
|
|
||||||
/*#define VOTES(X) \
|
/*#define VOTES(X) \
|
||||||
X('a', "A"), \
|
X('a', "A"), \
|
||||||
|
16
src/vote.c
16
src/vote.c
@ -3,14 +3,15 @@
|
|||||||
|
|
||||||
@subtitle Vote
|
@subtitle Vote
|
||||||
|
|
||||||
These are hard-coded CGI programmes for simple voting. */
|
These are hard-coded CGI programmes for simple voting. Compile with different
|
||||||
|
headers to change the voting scheme. */
|
||||||
|
|
||||||
#include <stdlib.h> /* getenv(), atoi() */
|
#include <stdlib.h> /* getenv(), atoi() */
|
||||||
#include <stdio.h> /* printf(), FILE, f*() */
|
#include <stdio.h> /* printf(), FILE, f*() */
|
||||||
#include <string.h> /* strstr() */
|
#include <string.h> /* strstr() */
|
||||||
#include <time.h> /* time() */
|
#include <time.h> /* time() */
|
||||||
|
|
||||||
static struct vote {
|
struct vote {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned vote;
|
unsigned vote;
|
||||||
const char token;
|
const char token;
|
||||||
@ -143,7 +144,7 @@ static char *votes_html(void) {
|
|||||||
fprintf(htf, "<link rel = \"stylesheet\" href = \"/neil.css\">\n"
|
fprintf(htf, "<link rel = \"stylesheet\" href = \"/neil.css\">\n"
|
||||||
"</head>\n\n"
|
"</head>\n\n"
|
||||||
"<body>\n"
|
"<body>\n"
|
||||||
"<h1>Which of these professions is the most badass?</h1>"
|
"<h1>" VOTE_TITLE "</h1>\n\n"
|
||||||
"<p>\nCurrent results:\n</p>\n\n");
|
"<p>\nCurrent results:\n</p>\n\n");
|
||||||
/* write out each name and vote */
|
/* write out each name and vote */
|
||||||
for(votep = votes; votep < votes + votes_size; votep++)
|
for(votep = votes; votep < votes + votes_size; votep++)
|
||||||
@ -155,10 +156,9 @@ static char *votes_html(void) {
|
|||||||
fprintf(htf, "<em>%s</em>: %u vote%c</p>",
|
fprintf(htf, "<em>%s</em>: %u vote%c</p>",
|
||||||
votep->name, votep->vote, (votep->vote == 1) ? ' ' : 's');
|
votep->name, votep->vote, (votep->vote == 1) ? ' ' : 's');
|
||||||
}
|
}
|
||||||
fprintf(htf, "<p>Go back to "
|
fprintf(htf, "<p>Go back to " VOTE_BACK ".</p>\n"
|
||||||
"<a href = \"/\">http://neil.chaosnet.org/</a>.</p>\n");
|
"</body>\n\n"
|
||||||
fprintf(htf, "</body>\n\n");
|
"</html>\n");
|
||||||
fprintf(htf, "</html>\n");
|
|
||||||
fclose(htf);
|
fclose(htf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ int main(void) {
|
|||||||
"</head>\n\n"
|
"</head>\n\n"
|
||||||
"<body>\n"
|
"<body>\n"
|
||||||
"<p>\n%s\n</p>\n\n"
|
"<p>\n%s\n</p>\n\n"
|
||||||
"<p>\nGo back to <a href = \"/\">root</a>.\n</p>\n"
|
"<p>Go back to " VOTE_BACK ".\n</p>\n"
|
||||||
"</body>\n\n"
|
"</body>\n\n"
|
||||||
"</html>\n", error);
|
"</html>\n", error);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user