comparison misc/dccman2html @ 0:c7f6b056b673

First import of vendor version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 13:49:58 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c7f6b056b673
1 #! /bin/sh -e
2
3 # elaborate man2html and do not depend on whether perl is in /usr/bin or
4 # /usr/local/bin
5
6 # Copyright (c) 2008 by Rhyolite Software, LLC
7 #
8 # This agreement is not applicable to any entity which sells anti-spam
9 # solutions to others or provides an anti-spam solution as part of a
10 # security solution sold to other entities, or to a private network
11 # which employs the DCC or uses data provided by operation of the DCC
12 # but does not provide corresponding data to other users.
13 #
14 # Permission to use, copy, modify, and distribute this software without
15 # changes for any purpose with or without fee is hereby granted, provided
16 # that the above copyright notice and this permission notice appear in all
17 # copies and any distributed versions or copies are either unchanged
18 # or not called anything similar to "DCC" or "Distributed Checksum
19 # Clearinghouse".
20 #
21 # Parties not eligible to receive a license under this agreement can
22 # obtain a commercial license to use DCC by contacting Rhyolite Software
23 # at sales@rhyolite.com.
24 #
25 # A commercial license would be for Distributed Checksum and Reputation
26 # Clearinghouse software. That software includes additional features. This
27 # free license for Distributed ChecksumClearinghouse Software does not in any
28 # way grant permision to use Distributed Checksum and Reputation Clearinghouse
29 # software
30 #
31 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
32 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
33 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
34 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
35 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
36 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
37 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
38 # SOFTWARE.
39 # Rhyolite Software DCC 1.3.103-1.18 $Revision$
40
41 MAN2HTML=misc/man2html
42 OFILE=/dev/null
43 TFILE=/tmp/dccman2html.$$
44
45 USAGE="`basename $0`: [-x] [-m man2html] [-t name] [-o ofile]"
46 while getopts "xm:t:o::" c; do
47 case $c in
48 x) set -x; DEBUG=-x;;
49 m) MAN2HTML=$OPTARG;;
50 t) Title="$OPTARG.8"; exec <"$OPTARG";;
51 o) OFILE=$OPTARG;;
52 *) echo "$USAGE" 1>&2; exit 1;;
53 esac
54 done
55 shift `expr $OPTIND - 1 || true`
56 if test "$#" -ne 0; then
57 echo "$USAGE" 1>&2
58 exit 1
59 fi
60
61 trap "/bin/rm -f $TFILE" 0 1 2 15
62
63 BURL=http://www.rhyolite.com/
64 perl $MAN2HTML -botm 0 -topm 0 -Title "$Title" \
65 -cgiurlexp '(($TITLE = ${title}) =~ tr/A-Z/a-z/, $TITLE).".html"' \
66 | sed \
67 -e '# remove stray page header not deleted by man2html' \
68 -e '/^FreeBSD [1-9]/d' \
69 -e '# remove HTTP references to non-DCC man pages' \
70 -e 's@<\(A HREF="cdcc.html"\)@<Z\1@g' \
71 -e 's@<\(A HREF="dbclean.html"\)@<Z\1@g' \
72 -e 's@<\(A HREF="dblist.html"\)@<Z\1@g' \
73 -e 's@<\(A HREF="dcc[dm]*.html"\)@<Z\1@g' \
74 -e 's@<\(A HREF="cdcc.html"\)@<Z\1@g' \
75 -e 's@<\(A HREF="dccproc.html"\)@<Z\1@g' \
76 -e 's@<\(A HREF="dccifd.html"\)@<Z\1@g' \
77 -e 's@<\(A HREF="dccsight.html"\)@<Z\1@g' \
78 -e 's@<A HREF="[^>]*>\([^<]*\)</A>@\1@g' \
79 -e 's@<ZA HREF=@<A HREF=@g' \
80 -e '# remove useless tags' \
81 -e 's@</B> <B>@ @g' \
82 -e '# add anchor names to sections' \
83 -e 's@^\( \)\(<B>\)\([^<]*\)</B>$@\1<A NAME="\3">\2\3</B></A>@' \
84 -e 's@\(<A NAME="[^"]*\)</*B>@\1@g' \
85 -e 's@\(<A NAME="[^"]*\)</*B>@\1@g' \
86 -e 's@^\(<H[0-9]>\)\([^<]*\)@\1<A NAME="\2">\2</A>@' \
87 -e '# add anchor names to option definitions' \
88 -e '/NAME="DESCRIPTION"/,/NAME="FILES""/s@^ <B>-\([-_a-zA-Z0-9]\)</B>@ <A NAME="OPTION-\1"><B>-\1</B></A>@' \
89 -e '# add anchor names to cdcc operations' \
90 -e '/NAME="OPERATIONS"/,/NAME="FILES"/s@^ <B>\([-_a-zA-Z0-9 ]*\)</B>@ <A NAME="OPERATION-\1"><B>\1</B></A>@' \
91 -e '# add anchor names to file descriptions' \
92 -e '/NAME="FILES"/,/^<H2>/s@^ \([a-zA-Z0-9_/.]\{1,\}\)@ <A NAME="FILE-\1">\1</A>@' \
93 -e '# convert blanks in anchor names to dashes' \
94 -e 's/\(<A NAME="[^"]*\) /\1-/g' \
95 -e 's/\(<A NAME="[^"]*\) /\1-/g' \
96 -e 's/\(<A NAME="[^"]*\) /\1-/g' \
97 -e 's/\(<A NAME="[^"]*\) /\1-/g' \
98 -e 's/\(<A NAME="[^"]*\) /\1-/g' \
99 -e 's/\(<A HREF="[^"]*\) /\1-/g' \
100 -e 's/\(<A HREF="[^"]*\) /\1-/g' \
101 -e 's/\(<A HREF="[^"]*\) /\1-/g' \
102 -e 's/\(<A HREF="[^"]*\) /\1-/g' \
103 -e 's/\(<A HREF="[^"]*\) /\1-/g' \
104 -e '# replace reference the Rhyolite Software with URL' \
105 -e 's@Rhyolite Software, LLC,@<A HREF="'$BURL'">&</A>@' \
106 -e 's@'$BURL'\(">[^<]*</A>\)[, ]*\('$BURL'[^ ]*\)@\2\1@' \
107 -e '# make references to HTML documents in .8 files into links' \
108 -e 's@INSTALL.html@<A HREF="&">&</A>@' \
109 > $TFILE
110
111 cp $TFILE $OFILE
112