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