Xmacros are too much work.

This commit is contained in:
Neil 2021-06-11 23:22:08 -07:00
parent 3610253996
commit 5c9512ce27
3 changed files with 12 additions and 8 deletions

View File

@ -2,6 +2,8 @@
#define ADDR_FILE "badass.addr"
#define HTML_FILE "badass.html"
#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) \
X('a', "astronaut"), \

View File

@ -2,6 +2,8 @@
#define ADDR_FILE "movie.addr"
#define HTML_FILE "movie.html"
#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) \
X('a', "A"), \

View File

@ -3,14 +3,15 @@
@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 <stdio.h> /* printf(), FILE, f*() */
#include <string.h> /* strstr() */
#include <time.h> /* time() */
static struct vote {
struct vote {
const char *name;
unsigned vote;
const char token;
@ -143,7 +144,7 @@ static char *votes_html(void) {
fprintf(htf, "<link rel = \"stylesheet\" href = \"/neil.css\">\n"
"</head>\n\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");
/* write out each name and vote */
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>",
votep->name, votep->vote, (votep->vote == 1) ? ' ' : 's');
}
fprintf(htf, "<p>Go back to "
"<a href = \"/\">http://neil.chaosnet.org/</a>.</p>\n");
fprintf(htf, "</body>\n\n");
fprintf(htf, "</html>\n");
fprintf(htf, "<p>Go back to " VOTE_BACK ".</p>\n"
"</body>\n\n"
"</html>\n");
fclose(htf);
return 0;
}
@ -188,7 +188,7 @@ int main(void) {
"</head>\n\n"
"<body>\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"
"</html>\n", error);
return EXIT_FAILURE;