diff options
Diffstat (limited to 'adapter/protocol/cha-finger')
-rwxr-xr-x | adapter/protocol/cha-finger | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/adapter/protocol/cha-finger b/adapter/protocol/cha-finger new file mode 100755 index 00000000..e963b339 --- /dev/null +++ b/adapter/protocol/cha-finger @@ -0,0 +1,39 @@ +#!/bin/sh +# Finger protocol adapter for Chawan. Requires curl. +# (It does *not* work without the environment variables MAPPED_URI_*, so no +# w3m support.) +# +# Usage: put this script in your cgi-bin folder, then add the following line to +# your urimethodmap: +# +# finger: /cgi-bin/cha-finger?%s +# +# Note: the Chawan default configuration already does this, so normally you +# don't need to do anything to use the finger protocol. + +die() { + echo "$1" + exit 1 +} + +type curl >/dev/null || \ + die "curl must be installed on your computer to use finger." + +printf 'Content-Type: text/plain\n\n' + +PORT="${MAPPED_URI_PORT:-79}" +test "$PORT" = 79 || die "Invalid port" + +if test -n "$MAPPED_URI_USERNAME" +then USER="$MAPPED_URI_USERNAME" +else case "$MAPPED_URI_PATH" in + /w*) USER="/w ${MAPPED_URI_PATH#/w}" ;; + *) USER="$MAPPED_URI_PATH" ;; + esac +fi +URL="telnet://$MAPPED_URI_HOST:$PORT" + +printf '%s\r\n' "$USER" | if test -n "$ALL_PROXY" +then curl -x "$ALL_PROXY" -- "$URL" +else curl -- "$URL" +fi 2>/dev/null |