#! /bin/sh -e
# elaborate man2html and do not depend on whether perl is in /usr/bin or
# /usr/local/bin
# Copyright (c) 2006 by Rhyolite Software, LLC
#
# This agreement is not applicable to any entity which sells anti-spam
# solutions to others or provides an anti-spam solution as part of a
# security solution sold to other entities, or to a private network
# which employs the DCC or uses data provided by operation of the DCC
# but does not provide corresponding data to other users.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# Parties not eligible to receive a license under this agreement can
# obtain a commercial license to use DCC and permission to use
# U.S. Patent 6,330,590 by contacting Commtouch at http://www.commtouch.com/
# or by email to nospam@commtouch.com.
#
# A commercial license would be for Distributed Checksum and Reputation
# Clearinghouse software. That software includes additional features. This
# free license for Distributed ChecksumClearinghouse Software does not in any
# way grant permision to use Distributed Checksum and Reputation Clearinghouse
# software
#
# THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
# BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# Rhyolite Software DCC 1.3.50-1.17 $Revision$
MAN2HTML=misc/man2html
OFILE=/dev/null
TFILE=/tmp/dccman2html.$$
USAGE="`basename $0`: [-x] [-m man2html] [-t name] [-o ofile]"
while getopts "xm:t:o::" c; do
case $c in
x) set -x; DEBUG=-x;;
m) MAN2HTML=$OPTARG;;
t) Title="$OPTARG.8"; exec < $OPTARG.0;;
o) OFILE=$OPTARG;;
*) echo "$USAGE" 1>&2; exit 1;;
esac
done
shift `expr $OPTIND - 1 || true`
if test "$#" -ne 0; then
echo "$USAGE" 1>&2
exit 1
fi
trap "/bin/rm -f $TFILE" 0 1 2 15
BURL=http://www.rhyolite.com/
perl $MAN2HTML -botm 0 -topm 0 -Title "$Title" \
-cgiurlexp '(($TITLE = ${title}) =~ tr/A-Z/a-z/, $TITLE).".html"' \
| sed \
-e '# remove stray page header not deleted by man2html' \
-e '/^FreeBSD [1-9]/d' \
-e '# remove HTTP references to non-DCC man pages' \
-e 's@<\(A HREF="cdcc.html"\)@\2\3@' \
-e 's@\(@\1@g' \
-e 's@\(@\1@g' \
-e 's@^\(\)\([^<]*\)@\1\2@' \
-e '# add anchor names to option definitions' \
-e '/NAME="DESCRIPTION"/,/NAME="FILES""/s@^ -\([-_a-zA-Z0-9]\)@ -\1@' \
-e '# add anchor names to cdcc operations' \
-e '/NAME="OPERATIONS"/,/NAME="FILES"/s@^ \([-_a-zA-Z0-9 ]*\)@ \1@' \
-e '# add anchor names to file descriptions' \
-e '/NAME="FILES"/,/^/s@^ \([a-zA-Z0-9_/.]\{1,\}\)@ \1@' \
-e '# convert blanks in anchor names to dashes' \
-e 's/\(&@' \
-e 's@'$BURL'\(">[^<]*
\)[, ]*\('$BURL'[^ ]*\)@\2\1@' \
-e '# make references to HTML documents in .8 files into links' \
-e 's@INSTALL.html@&@' \
> $TFILE
cp $TFILE $OFILE