1 // CGI program to get fortunes. Powers https://fortune.armaanb.net.
10 const char *path = getenv("PATH_INFO");
14 if (strcmp(path, "/latin-cowsay") == 0) {
15 fp = popen("phrases | cowsay", "r");
16 } else if (strcmp(path, "/cowsay") == 0) {
17 fp = popen("fortune | cowsay", "r");
18 } else if (strcmp(path, "/latin") == 0) {
19 fp = popen("phrases", "r");
20 } else if (strcmp(path, "/") == 0) {
21 fp = popen("fortune", "r");
24 "Content-type: text/plain\n\n"
25 "Page not found. Try /, /cowsay, /latin, or /latin-cowsay\n");
29 printf("Content-type: text/plain\n\n");
30 while (fgets(buf, sizeof(buf), fp) != NULL) {