#!/bin/ksh ### ### refset.sh ### ### Generate hyperlinked reference material using Lawson's dbdoc, dburf, and fldrpt utilities ### ### if [ "$1" = "" ] then echo "Usage: refset.sh prodline" exit 1 else xprodline=$1 fi ### Generate table documentation ### ### if [ -d dbdoc ] then echo "" else mkdir dbdoc fi PRODUCTLINE=`echo $1 | tr [a-z] [A-Z]` echo "Dumping $PRODUCTLINE" dbdump gen sysfile | \ cut -c1-36 | \ grep "^$PRODUCTLINE" | \ sed "s/ / /g" > tmp.$$ cut -c1-14 tmp.$$ | sed "s/^/dbdoc /g" > tmp1.$$ for i in `cut -c15-30 tmp.$$` do echo " $i > dbdoc/$i.txt" >> tmp2.$$ done paste tmp1.$$ tmp2.$$ > tmp1.sh chmod 777 tmp1.sh ./tmp1.sh rm tmp* ### Generate program documentation ### ### if [ -d dburf ] then echo "" else mkdir dburf fi rngdbdump -c gen program | \ grep -i $1 | \ cut -d, -f2,3 | \ sed "s/\"//g" | \ sed "s/,/ /g" | \ sed "s/^/dburf $1 /g" > tmp.out cut -d" " -f4 tmp.out | \ sed "s/^/ > dburf\//g" | \ sed "s/$/\.txt/g" > tmp1.out paste tmp.out tmp1.out > tmp.sh sh ./tmp.sh rm tmp* ### Generate field documentation ### ### if [ -d fldrpt ] then echo "" else mkdir fldrpt fi rngdbdump -cn gen element | \ cut -d, -f2 | \ sed "s/\"//g" > elements.list for x in `cat elements.list` do fldrpt -e $1 $x > fldrpt/$x.txt done ### Convert text files to html files ### ### for i in `ls dbdoc/*.txt` do file=`basename $i .txt` echo $i $file echo "<html>" > dbdoc/$file.html echo "<head><title>$file</title>" >> dbdoc/$file.html echo "</head>" >> dbdoc/$file.html echo "<body>" >> dbdoc/$file.html echo "<center><h1>dbdoc/$file</h1></center>" >> dbdoc/$file.html echo "<blockquote>" >> dbdoc/$file.html echo "<pre>" >> dbdoc/$file.html cat $i >> dbdoc/$file.html echo "</pre>" >> dbdoc/$file.html echo "</blockquote>" >> dbdoc/$file.html echo "</body>" >> dbdoc/$file.html echo "</html>" >> dbdoc/$file.html done for i in `ls fldrpt/*.txt` do file=`basename $i .txt` echo $i $file echo "<html>" > fldrpt/$file.html echo "<head><title>$file</title>" >> fldrpt/$file.html echo "</head>" >> fldrpt/$file.html echo "<body>" >> fldrpt/$file.html echo "<center><h1>$file</h1></center>" >> fldrpt/$file.html echo "<blockquote>" >> fldrpt/$file.html echo "<pre>" >> fldrpt/$file.html cat $i >> fldrpt/$file.html echo "</pre>" >> fldrpt/$file.html echo "</blockquote>" >> fldrpt/$file.html echo "</body>" >> fldrpt/$file.html echo "</html>" >> fldrpt/$file.html done for i in `ls dburf/*.txt` do file=`basename $i .txt` echo $i $file echo "<html>" > dburf/$file.html echo "<head><title>$file</title>" >> dburf/$file.html echo "</head>" >> dburf/$file.html echo "<body>" >> dburf/$file.html echo "<center><h1>$file</h1></center>" >> dburf/$file.html echo "<blockquote>" >> dburf/$file.html echo "<pre>" >> dburf/$file.html cat $i >> dburf/$file.html echo "</pre>" >> dburf/$file.html echo "</blockquote>" >> dburf/$file.html echo "</body>" >> dburf/$file.html echo "</html>" >> dburf/$file.html done ## Create program links in table documentation ## rm *.out 2>/dev/null ls dburf/*.html | egrep -v sh | egrep -v index > tmp9.out for i in `cat tmp9.out` do #echo $i basename $i .html >> program_list.out done for xprogram in `cat program_list.out` do fgrep $xprogram dbdoc/*.html | cut -d":" -f1 | sort | uniq > files.out for xfile in `cat files.out` do echo "Creating $xprogram in $xfile" xlen=`echo $xprogram | wc -c` if [ $xlen -eq 5 ] then sed "s/${xprogram}\./<a href=\"\.\.\/dburf\/${xprogram}\.html\">${xprogram}<\/a>\./g" $xfile > tmp2.out mv tmp2.out $xfile else sed "s/${xprogram}/<a href=\"\.\.\/dburf\/${xprogram}\.html\">${xprogram}<\/a>/g" $xfile > tmp2.out mv tmp2.out $xfile fi done done ### Create table links in program documentation ### ### rm *.out 2>/dev/null ls -r dbdoc | grep html | egrep -v index > tmp10.out for i in `cat tmp10.out` do basename $i .html >> filelist.out done for xtbl in `cat filelist.out` do echo $xtbl fgrep $xtbl dburf/*.html | cut -d":" -f1 | sort | uniq > element.out for xelement in `cat element.out` do echo "Creating $xtbl url in $xelement" sed "s/ ${xtbl} / <a href=\"\.\.\/dbdoc\/${xtbl}\.html\">${xtbl}<\/a> /g" $xelement > tmp2.out mv tmp2.out $xelement done done ### Create element/field links in table documentation ### ### rm *.out 2>/dev/null ls -1 fldrpt/*.html | grep -v index | sort > tmp9.out for i in `cat tmp9.out` do basename $i .html >> element_list.out done for xstring in `cat element_list.out` do grep "^...-$xstring " dbdoc/*.html | cut -d":" -f1 | sort | uniq > filelist.out for xfile in `cat filelist.out` do echo "Tweaking $xstring in $xfile" sed "/^...-$xstring /s/$xstring/<a href=\"\.\.\/fldrpt\/$xstring\.html\">$xstring<\/a>/g" $xfile > tmp2.out mv tmp2.out $xfile done done ### Create index.html files for dbdoc, dburf, and fldrpt directories ### ### ls -1 dbdoc/[A-Z]*.html > tmp.out cp tmp.out tmp1.out paste tmp.out tmp1.out | sed "s/dbdoc\///g" > tmp2.out echo "<html>" > dbdoc/index.html echo "<head>" >> dbdoc/index.html echo " <title> dbdoc - $xprodline </title>" >> dbdoc/index.html echo "</head>" >> dbdoc/index.html echo "<body>" >> dbdoc/index.html echo " <center>" >> dbdoc/index.html echo " <table width=\"80%\">" >> dbdoc/index.html echo " <TR>" >> dbdoc/index.html echo " <td><font class=grey2>" >> dbdoc/index.html echo " " >> dbdoc/index.html echo "<p> </p>" >> dbdoc/index.html echo "<center>" >> dbdoc/index.html echo "<h1> dbdoc - $xprodline </h1>" >> dbdoc/index.html echo "</center>" >> dbdoc/index.html echo "<p><hr noshade>" >> dbdoc/index.html echo "<ol>" >> dbdoc/index.html sed "s/^/<li><a href=\"/g" tmp2.out | \ sed "s/ /\">/g" | \ sed "s/$/<\/a>/g" >> dbdoc/index.html echo "</ol>" >> dbdoc/index.html echo "<p><hr noshade>" >> dbdoc/index.html echo "<h3><a href=\"../../index.html\">Home</a></h3>" >> dbdoc/index.html echo "<p><hr noshade>" >> dbdoc/index.html echo "" >> dbdoc/index.html echo " </td>" >> dbdoc/index.html echo " </tr>" >> dbdoc/index.html echo " </table>" >> dbdoc/index.html echo " </center>" >> dbdoc/index.html echo " </body>" >> dbdoc/index.html echo "</html>" >> dbdoc/index.html cat /dev/null > tmp1.out ls -1 dburf/[A-Z]*.html > tmp.out for i in `cat tmp.out` do x=`basename $i .html` xlen=`echo $x | wc -c` if [ $xlen -eq 5 ] then y=`grep "${x}.1 - " $i` #echo "1: $x $y $i $xlen" else y=`grep "$x - " $i` #echo "2: $x $y $i $xlen" fi if [ "$y" == "" ] then y=$x fi echo $y >> tmp1.out done paste tmp.out tmp1.out | sed "s/dburf\///g" > tmp2.out echo "<html>" > dburf/index.html echo "<head>" >> dburf/index.html echo " <title> dburf - $xprodline </title>" >> dburf/index.html echo "</head>" >> dburf/index.html echo "<body>" >> dburf/index.html echo " <center>" >> dburf/index.html echo " <table width=\"80%\">" >> dburf/index.html echo " <TR>" >> dburf/index.html echo " <td><font class=grey2>" >> dburf/index.html echo " " >> dburf/index.html echo "<p> </p>" >> dburf/index.html echo "<center>" >> dburf/index.html echo "<h1> dburf - $xprodline </h1>" >> dburf/index.html echo "</center>" >> dburf/index.html echo "<p><hr noshade>" >> dburf/index.html echo "<ol>" >> dburf/index.html sed "s/^/<li><a href=\"/g" tmp2.out | \ sed "s/ /\">/g" | \ sed "s/$/<\/a>/g" >> dburf/index.html echo "</ol>" >> dburf/index.html echo "<p><hr noshade>" >> dburf/index.html echo "<h3><a href=\"../../index.html\">Home</a></h3>" >> dburf/index.html echo "<p><hr noshade>" >> dburf/index.html echo "" >> dburf/index.html echo " </td>" >> dburf/index.html echo " </tr>" >> dburf/index.html echo " </table>" >> dburf/index.html echo " </center>" >> dburf/index.html echo " </body>" >> dburf/index.html echo "</html>" >> dburf/index.html ls -1 fldrpt/[A-Z]*.html > tmp.out cp tmp.out tmp1.out paste tmp.out tmp1.out | sed "s/fldrpt\///g" > tmp2.out echo "<html>" > fldrpt/index.html echo "<head>" >> fldrpt/index.html echo " <title> fldrpt - $xprodline </title>" >> fldrpt/index.html echo "</head>" >> fldrpt/index.html echo "<body>" >> fldrpt/index.html echo " <center>" >> fldrpt/index.html echo " <table width=\"80%\">" >> fldrpt/index.html echo " <TR>" >> fldrpt/index.html echo " <td><font class=grey2>" >> fldrpt/index.html echo " " >> fldrpt/index.html echo "<p> </p>" >> fldrpt/index.html echo "<center>" >> fldrpt/index.html echo "<h1> fldrpt - $xprodline </h1>" >> fldrpt/index.html echo "</center>" >> fldrpt/index.html echo "<p><hr noshade>" >> fldrpt/index.html echo "<ol>" >> fldrpt/index.html sed "s/^/<li><a href=\"/g" tmp2.out | \ sed "s/ /\">/g" | \ sed "s/$/<\/a>/g" >> fldrpt/index.html echo "</ol>" >> fldrpt/index.html echo "<p><hr noshade>" >> fldrpt/index.html echo "<h3><a href=\"../../index.html\">Home</a></h3>" >> fldrpt/index.html echo "<p><hr noshade>" >> fldrpt/index.html echo "" >> fldrpt/index.html echo " </td>" >> fldrpt/index.html echo " </tr>" >> fldrpt/index.html echo " </table>" >> fldrpt/index.html echo " </center>" >> fldrpt/index.html echo " </body>" >> fldrpt/index.html echo "</html>" >> fldrpt/index.html