#!/bin/sh # # Script to break up rman html output into separate sections in a directory. # # Author: Robert Moniot # Date: 4 Aug 1998 # version="rman_html_split V1.0 (c) 1998 Robert K. Moniot" # Usage function prints synopsis and exits Usage(){ myname=`echo $0 | sed -e 's,.*/,,'` cat < $* EOF do_title } # This function puts out the title with name of manpage do_title(){ if [ -n "$title" ] then echo "

$title

" fi } # This function puts out ref to table of contents that # follows header for all but 1st and toc page. do_href_toc(){ cat <Table of Contents

EOF } # This function puts out ref to previous section do_href_prev(){ echo "

Previous: $2


" } # This function puts out footer needed by all but last page. do_footer(){ cat < EOF } # This function changes the trailing NAME anchor # of a section into an href to the next section. # The first edit is for sections. The second edit # handles the toc anchor, which has no href and so # is missed by the first edit. do_href_next(){ sed -e '$s,^.*]*>\([^<]*\).*$,


Next: \2,' \ -e '$s,]$/N' \ -e 's/\n/ /' \ -e 't top' $1 > $filename # If user did not supply title, get title for top of # each page from rman-generated line. If user # gave a blank title then leave it blank. if [ -z "$title" -a -z "$notitle" ] then title=`sed -e '/^<TITLE>/q' $filename | sed -n -e 's,^<TITLE>\([^<]*\).*$,\1,p'` fi # Get a list of all the sections. Separate it into a # list of merged sections and a list of all other sections. # Merged sects are combined and get special treatment besides. allsects=`sed -n 's,^.*<A NAME="\(sect[0-9][0-9]*\)".*$,\1,p' $filename` mergesects=`echo $allsects | \ awk '{for(i=1; i<=NF && i<'"$mergesect"+2'; i++) print \$i;}'` sectlist=`echo $allsects | awk '{for(i='"$mergesect"'+2; i<=NF; i++) print \$i;}'` # This little bit, copied from GNU configure, sets ac_n and ac_c such # that echo $ac_n "stuff $ac_c" yields "stuff " w/o following newline. if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # Create html directory if it does not exist. if [ -d $htmldir ] then echo "Re-using directory $htmldir." else echo "Creating directory $htmldir..." if mkdir $htmldir then true else echo "Failed!" exit 1 fi fi echo "Creating section pages..." # Produce index page. It is special, since it combines # merged sections and uses the rman-generated header. nextsect=`echo $sectlist | awk '{print $1;}'` echo $ac_n $mergesects "$ac_c" (do_title ; sed -n -e "1,/^<H[23]><A NAME=\"$nextsect\"/p" $filename | \ do_href_next | \ change_hrefs ; do_footer) > $htmldir/sect0.html # Produce pages for all other sections except toc. prevsect="sect$mergesect" prevtext=`sed -n 's,^<H[23]><A NAME="'$prevsect'" HREF="#toc[0-9][0-9]*">\([^<]*\).*$,\1,p' $filename | sed -e 's/ *$//'` for sect in $sectlist; do echo $ac_n "$sect $ac_c" headtext=`sed -n 's,^<H[23]><A NAME="'$sect'" HREF="#toc[0-9][0-9]*">\([^<]*\).*$,\1,p' $filename | sed -e 's/ *$//'` (do_header $headtext ; do_href_toc ; do_href_prev "$prevsect" "$prevtext" ; sed -n -e '/<A NAME="'$sect'"/,/<A NAME=/p' $filename | do_href_next | change_hrefs ; do_footer) > $htmldir/$sect.html prevsect="$sect" prevtext="$headtext" done # Produce table of contents echo "toc" (do_header Table of Contents ; sed -n -e '/<A NAME="toc">/,$p' $filename | \ change_hrefs ; ) > $htmldir/toc.html # Finally, make sure the symlinks index.html and # sect1.html -> sect0.html are in place, and if not, # create them. If --tocfirst is not specified, then # link index.html to section 0, otherwise link it to # index.html echo "Doing symlinks..." cd $htmldir rm -f index.html if [ -z "$tocfirst" ] then echo "Linking index.html -> sect0.html" ln -s sect0.html index.html else echo "Linking index.html -> toc.html" ln -s toc.html index.html fi for sect in $mergesects do if [ "$sect" != "sect0" ] then echo "Linking $sect.html -> sect0.html" rm -f $sect.html ln -fs sect0.html $sect.html fi done echo "Done."