| Add BOB support to geomyidae. - geomyidae - A small C-based gopherd. | |
| git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| LICENSE | |
| --- | |
| commit 55786ce96a30a89b836e2ebdda0a284dfecffefe | |
| parent 9f57161218c2528eb3ba17e30d6c44a970101888 | |
| Author: Christoph Lohmann <[email protected]> | |
| Date: Fri, 24 Feb 2023 18:52:16 +0100 | |
| Add BOB support to geomyidae. | |
| Diffstat: | |
| A bob/README.md | 13 +++++++++++++ | |
| A bob/eval-bob | 53 ++++++++++++++++++++++++++++++ | |
| A bob/index.bob | 14 ++++++++++++++ | |
| A bob/index.dbob | 13 +++++++++++++ | |
| M filetypes.h | 2 ++ | |
| M main.c | 2 +- | |
| 6 files changed, 96 insertions(+), 1 deletion(-) | |
| --- | |
| diff --git a/bob/README.md b/bob/README.md | |
| @@ -0,0 +1,13 @@ | |
| +Why BOB? | |
| + | |
| +Too many people use the Internet drunken. See the web, PHP and other | |
| +technologies, where this will end. | |
| + | |
| +To show you how not to write code drunken and simplify things, this is an | |
| +example of how to add your own dynamic handler language to geomyidae. | |
| + | |
| +We support that people should use gopherspace only when being sober. | |
| + | |
| +Do not accidently ruin someone's life with your strange hype idea you | |
| +created drunken at 2am at night! | |
| + | |
| diff --git a/bob/eval-bob b/bob/eval-bob | |
| @@ -0,0 +1,53 @@ | |
| +#!/bin/sh | |
| +# | |
| +# Don't drink and code. | |
| +# Eval BOB! | |
| +# | |
| +# https://www.bob.be/ | |
| +# | |
| +# We want to create awareness of people writing code while being drunken. | |
| +# See PHP or Ruby on Rails for how to not do it. You will end up in a | |
| +# life of misery, where you cannot escape and need to keep going until | |
| +# your pension with some ugly language, reinventing what has been done | |
| +# before. Noone will remember you, since you write shit code and the next | |
| +# hype kid replaced your idea with their own hype, rewriting what you | |
| +# already did. | |
| +# | |
| +# Example BOB file: | |
| +# | |
| +# <?geomyidae echo hello bob ?> | |
| +# | |
| +# See index.bob for an example file. | |
| +# | |
| + | |
| +if [ -z "$1" ]; | |
| +then | |
| + input="/dev/stdin" | |
| +else | |
| + input="$1" | |
| +fi | |
| + | |
| +{ | |
| + awk -v "bob=1" \ | |
| + 'BEGIN { | |
| + print "cat <<BOBEND" bob ";" | |
| + } | |
| + /^#!\// && NR==1 { | |
| + next; | |
| + } | |
| + /<\?geomyidae/ { | |
| + sub(/<\?geomyidae/, "BOBEND" bob "\n"); | |
| + bob=bob+1; | |
| + } | |
| + /\?>/ { | |
| + sub(/?>/,"\ncat <<BOBEND" bob ";\n"); | |
| + } | |
| + { | |
| + print; | |
| + } | |
| + END { | |
| + print "BOBEND" bob | |
| + } | |
| + ' "${input}" | |
| +} | |
| + | |
| diff --git a/bob/index.bob b/bob/index.bob | |
| @@ -0,0 +1,14 @@ | |
| +#!/usr/bin/env eval-bob | |
| +[h|BOB is great.|URL:https://www.bob.be|server|port] | |
| +<?geomyidae | |
| + echo aaaaahhhh | |
| + a="sober" | |
| +?> | |
| +<?geomyidae printf "BOB is programming "; ?> | |
| +extra $a | |
| +<?geomyidae | |
| + for i in $(seq 10); | |
| + do | |
| + printf "%s\n" "$a"; | |
| + done | |
| +?> | |
| diff --git a/bob/index.dbob b/bob/index.dbob | |
| @@ -0,0 +1,13 @@ | |
| +#!/usr/bin/env eval-bob | |
| +<?geomyidae | |
| + echo aaaaahhhh | |
| + a="sober" | |
| +?> | |
| +<?geomyidae printf "BOB is programming "; ?> | |
| +extra $a | |
| +<?geomyidae | |
| + for i in $(seq 10); | |
| + do | |
| + printf "%s\n" "$a"; | |
| + done | |
| +?> | |
| diff --git a/filetypes.h b/filetypes.h | |
| @@ -17,6 +17,8 @@ filetype type[] = { | |
| {"gph", "1", handlegph}, | |
| {"cgi", "0", handlecgi}, | |
| {"dcgi", "1", handledcgi}, | |
| + {"bob", "0", handlecgi}, | |
| + {"dbob", "1", handledcgi}, | |
| {"bin", "9", handlebin}, | |
| {"tgz", "9", handlebin}, | |
| {"gz", "9", handlebin}, | |
| diff --git a/main.c b/main.c | |
| @@ -59,7 +59,7 @@ int nlistfds = 0; | |
| char *argv0; | |
| char stdbase[] = "/var/gopher"; | |
| char *stdport = "70"; | |
| -char *indexf[] = {"/index.gph", "/index.cgi", "/index.dcgi", "/index.bin"}; | |
| +char *indexf[] = {"/index.gph", "/index.cgi", "/index.dcgi", "/index.bob", "/i… | |
| char *nocgierr = "3Sorry, execution of the token '%s' was requested, but this " | |
| "is disabled in the server configuration.\tErr" | |
| "\tlocalhost\t70\r\n"; |