Add fortune cookie header, fix regression in zucc fallback. - bitreich-httpd - Bitreich HTTPD service
HTML git clone git://bitreich.org/bitreich-httpd git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-httpd
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 865ab23256ee80bea656a7cca229be47cbf2f8c7
DIR parent 246e4239200dd875c7fc4eaac138e2220562e4e0
HTML Author: Christoph Lohmann <20h@r-36.net>
Date: Sun, 21 Jul 2024 21:06:14 +0200
Add fortune cookie header, fix regression in zucc fallback.
Diffstat:
M bitreich-httpd.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
DIR diff --git a/bitreich-httpd.c b/bitreich-httpd.c
@@ -41,11 +41,28 @@ void
printheaders(char *ctype)
{
time_t t;
+ char fortunecookie[512];
+ FILE *fcstdout;
+ int fclen = 0;
+
+ bzero(fortunecookie, sizeof(fortunecookie));
+ fcstdout = popen("/home/annna/bin/fortune-cookie", "r");
+ if (fcstdout != NULL) {
+ fread(fortunecookie, sizeof(fortunecookie)-1, 1, fcstdout);
+ pclose(fcstdout);
+ fclen = strlen(fortunecookie);
+ if (fclen > 0) {
+ if (fortunecookie[fclen-1] == '\n')
+ fortunecookie[fclen-1] = '\0';
+ }
+ }
t = time(NULL);
if (t > 0)
printf("Date: %s", asctime(gmtime(&t)));
printf("X-Future: Gopher ftw!\r\n");
+ if (fclen > 0)
+ printf("X-Fortune-Cookie: %s\r\n", fortunecookie);
printf("Content-Type: %s\r\n", ctype);
printf("X-Irritate: Be irritated.\r\n");
printf("X-Use-Gopher: gophers://bitreich.org\r\n");
@@ -295,7 +312,7 @@ main(int argc, char *argv[])
ctype = "text/plain";
}
} else {
- if (strstr(hosthdr, "zuccless.org")) {
+ if (hosthdr != NULL && strstr(hosthdr, "zuccless.org")) {
tim = time(NULL);
srandom(tim);
wwwbase = zuccbase;