blob: 7c515d17b21f6f2ed8a3a07a7e9e49377eac5ce6 (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/bin/sh
# man2html cgi script - uses /usr/bin/man2html to format man pages
# auxiliary text files in /home/httpd/cgi-aux/man
# aeb@cwi.nl - 980109
MAN2HTML="/usr/bin/man2html"
MANX="/home/httpd/cgi-aux/man/man.aux"
# Do we need lynxcgi URLs? For the moment our criterion is
# 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset.
AGENT="${HTTP_USER_AGENT-unknown}"
case "$AGENT" in
Lynx*|lynx*)
HH="${HTTP_HOST-nohh}"
SED="s/%lynx //"
;;
*)
HH=nolynx
SED="/%lynx/d"
;;
esac
SERVER="${SERVER_NAME-localhost}"
case "$HH" in
nohh)
LL="-l"
CG="lynxcgi:/home/httpd/cgi-bin/man"
;;
*)
LL="-H$SERVER"
CG="http://$SERVER/cgi-bin/man"
;;
esac
# Find the required page - expect to be called with "man2html [sec] page".
# There may a prefixed "-M manpath" option.
if [ $# -ge 2 -a x"$1" = x-M ]; then
MANPATH="$2"
export MANPATH
shift; shift
MP=" using the given MANPATH"
else
MP=""
fi
# If no arguments given, show a start page.
if [ $# = 0 ]; then
if [ -r $MANX ]; then
cat $MANX | sed "s#%cg#$CG#g; $SED"
else
"$MAN2HTML" -E "man2html: cannot open $MANX"
fi
exit 0
fi
if [ $# -gt 2 ]; then
"$MAN2HTML" -E "man2html: bad invocation: too many arguments"
exit 0
fi
# A single argument may be an explicitly give path name
# Otherwise, ask man where to find it
if [ $# = 1 ]; then
case "$1" in
/*)
PAGE="$1"
;;
*)
PAGE=`man -w -c "$@" 2>/dev/null`
;;
esac
else
PAGE=`man -w -c "$@" 2>/dev/null`
fi
if [ x"$PAGE" = x ]; then
complaint="man2html: cannot find a page"
if [ $# = 1 ]; then
"$MAN2HTML" -E "$complaint for $1$MP"
else
"$MAN2HTML" -E "$complaint for $2 in section $1$MP"
fi
exit 0
fi
if [ -r "$PAGE" ]
then
case "$PAGE" in
*.gz)
zcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE"
;;
*.bz2)
bzcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE"
;;
*)
"$MAN2HTML" "$LL" "$PAGE"
;;
esac
elif [ -r "$PAGE".gz ]
then
zcat "$PAGE".gz | "$MAN2HTML" "$LL" -D "$PAGE"
elif [ -r "$PAGE".bz2 ]
then
bzcat "$PAGE".bz2 | "$MAN2HTML" "$LL" -D "$PAGE"
else
"$MAN2HTML" -E "Strange... Cannot find (or read) $PAGE."
fi
exit 0
|