]> git.armaanb.net Git - bin.git/commitdiff
fortune-cgi: rename from fortune-online
authorArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 17:29:46 +0000 (13:29 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 17:29:46 +0000 (13:29 -0400)
fortune-cgi.c [new file with mode: 0644]
fortune-online.c [deleted file]

diff --git a/fortune-cgi.c b/fortune-cgi.c
new file mode 100644 (file)
index 0000000..63693d7
--- /dev/null
@@ -0,0 +1,36 @@
+// CGI program to get fortunes. Powers https://fortune.armaanb.net.
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void)
+{
+       const char *path = getenv("PATH_INFO");
+       FILE *fp;
+       char buf[255];
+
+       if (strcmp(path, "/latin-cowsay") == 0) {
+               fp = popen("phrases | cowsay", "r");
+       } else if (strcmp(path, "/cowsay") == 0) {
+               fp = popen("fortune | cowsay", "r");
+       } else if (strcmp(path, "/latin") == 0) {
+               fp = popen("phrases", "r");
+       } else if (strcmp(path, "/") == 0) {
+               fp = popen("fortune", "r");
+       } else {
+               printf("Status: 404"
+                                        "Content-type: text/plain\n\n"
+                                        "Page not found. Try /, /cowsay, /latin, or /latin-cowsay\n");
+               return 0;
+       }
+
+       printf("Content-type: text/plain\n\n");
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
+               printf("%s", buf);
+       }
+       pclose(fp);
+
+       return 0;
+}
diff --git a/fortune-online.c b/fortune-online.c
deleted file mode 100644 (file)
index 63693d7..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// CGI program to get fortunes. Powers https://fortune.armaanb.net.
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(void)
-{
-       const char *path = getenv("PATH_INFO");
-       FILE *fp;
-       char buf[255];
-
-       if (strcmp(path, "/latin-cowsay") == 0) {
-               fp = popen("phrases | cowsay", "r");
-       } else if (strcmp(path, "/cowsay") == 0) {
-               fp = popen("fortune | cowsay", "r");
-       } else if (strcmp(path, "/latin") == 0) {
-               fp = popen("phrases", "r");
-       } else if (strcmp(path, "/") == 0) {
-               fp = popen("fortune", "r");
-       } else {
-               printf("Status: 404"
-                                        "Content-type: text/plain\n\n"
-                                        "Page not found. Try /, /cowsay, /latin, or /latin-cowsay\n");
-               return 0;
-       }
-
-       printf("Content-type: text/plain\n\n");
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               printf("%s", buf);
-       }
-       pclose(fp);
-
-       return 0;
-}