blob: e963b339dc52460e0b2531d6b99d15ad4e39ca71 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
|