home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2092 / audit.S next >
Encoding:
Text File  |  1990-12-28  |  10.8 KB  |  430 lines

  1. %%STARTSHELL%%
  2. #    Psroff checking script 2.4 90/08/29
  3. chkinst=false
  4. for i
  5. do
  6.     case $i in
  7.     install)
  8.         chkinst=true
  9.         ;;
  10.     *)
  11.         printerlist="$printerlist $i"
  12.         ;;
  13.     esac
  14. done
  15. eval "`sed -n -e 's/[()]//g' \
  16.           -e 's/^LIBDIR.*=[     ]*/LIBDIR=/p' \
  17.           -e 's/^LJF.*=[     ]*/LJF=/p' \
  18.           -e 's/^FONTDIR.*=[     ]*/FONTDIR=/p' \
  19.          Makefile`"
  20. echo "LIBDIR  = $LIBDIR"
  21. echo "LJF     = $LJF"
  22. echo "FONTDIR = $FONTDIR"
  23. if [ -z "$FONTDIR" ]
  24. then
  25.     echo "ERROR: That's odd, can't find a FONTDIR setting in Makefile"
  26. elif [ ! -d $FONTDIR ]
  27. then
  28.     echo "ERROR: That's really odd, no such directory $FONTDIR"
  29.     echo "       This is where CAT's width tables are supposed to be"
  30.     echo "       It is usually /usr/lib/font"
  31.     FONTDIR=
  32. fi
  33. if [ -z "$LIBDIR" ]
  34. then
  35.     echo "ERROR: Bad configuration - no LIBDIR setting"
  36.     exit 1
  37. elif [ ! -d $LIBDIR ]
  38. then
  39.     echo "INFO: You've not installed psroff yet - no LIBDIR ($LIBDIR) exists"
  40.     if $chkinst
  41.     then
  42.     echo "ERROR: Can't check installed version unless it's installed"
  43.     exit 1
  44.     fi
  45. fi
  46.  
  47. if $chkinst
  48. then
  49.     psrofflib=$LIBDIR/lib/psrofflib
  50.     libbase=$LIBDIR/lib
  51. else
  52.     psrofflib=lib/psrofflib
  53.     libbase=lib
  54. fi
  55.  
  56. if [ ! -r $psrofflib ]
  57. then
  58.     echo "ERROR: no $psrofflib to check"
  59.     exit 1
  60. fi
  61.  
  62. eval `grep '^troff=' $psrofflib`
  63. echo "INFO: Your troff setting in psrofflib is troff=$troff"
  64. if [ -n "$troff" ]
  65. then
  66.     # This should be -x, but Ultrix sh doesn't believe in it
  67.     if [ ! -f $troff ]
  68.     then
  69.     echo "ERROR: troff setting in $psrofflib ($troff) doesn't exist"
  70.     troff=
  71.     fi
  72. else
  73.     mpath=`echo $PATH | sed -e 's/^:/.:/' -e 's/:$/:./' -e 's/:/ /g'`
  74.     echo "INFO: Your path is $mpath"
  75.     for i in $mpath
  76.     do
  77.     if [ -f $i/troff ]
  78.     then
  79.         echo "INFO: Troff appears to be $i/troff"
  80.         troff=$i/troff
  81.         break
  82.     fi
  83.     done
  84.     if [ -z "$troff" ]
  85.     then
  86.     echo "ERROR: Can't find troff!"
  87.     exit 1
  88.     fi
  89. fi
  90.  
  91. eval `grep '^trofftype=' $psrofflib`
  92. echo "INFO: Your trofftype setting in $psrofflib is trofftype='$trofftype'"
  93.  
  94. if [ ! -r $FONTDIR/ftR -o ! -r $FONTDIR/ftI -o ! -r $FONTDIR/ftB -o \
  95.     ! -r $FONTDIR/ftS ]
  96. then
  97. cat <<!
  98. WARNING: Missing one of the $FONTDIR/ft[RIBS] files.
  99.     I was hoping that FONTDIR was pointing at the place where
  100.     your version of troff keeps its width tables (by default
  101.     /usr/lib/font).  Since this is not true, I will not be able
  102.     to tell with complete accuracy whether your trofftype setting
  103.     works.  Therefore, take any ERROR messages about trofftype with
  104.     a grain of salt.  You could always copy widths/widthps/ft[RIBS]
  105.     (after make widths) into $FONTDIR, but, I NEED a ftR from
  106.     your ORIGINAL troff distribution to test HEADERSIZE properly.
  107. !
  108. fi
  109.  
  110. if [ -n "$FONTDIR" ]
  111. then
  112.     arglist="-F$FONTDIR/./ftXX"
  113. fi
  114. for i in $arglist -T. ''
  115. do
  116.     echo "INFO: Testing '$i' trofftype setting"
  117.     $troff -t $i < /dev/null > /dev/null
  118.     rc=$?
  119.     if [ $rc = 0 ]
  120.     then
  121.     echo "... $i worked"
  122.     case $i in
  123.         -F*)
  124.         workingtype="-F$FONTDIR/\$width/ftXX"
  125.         ;;
  126.         -T*)
  127.         if [ -n "$FONTDIR" -a "$FONTDIR" != /usr/lib/font ]
  128.         then
  129.             echo "ERROR: FONTDIR must be /usr/lib/font with this"
  130.             echo "       type of troff"
  131.         fi
  132.         workingtype="-T\$width"
  133.         ;;
  134.         *)
  135.         echo "INFO: Poor you, your troff doesn't understand -T or -F."
  136.         echo "      This means that you'll have to put all of your"
  137.         echo "      width files directly in $FONTDIR, and you'll not"
  138.         echo "      be able to support multiple sets of width tables"
  139.         workingtype=" "
  140.         ;;
  141.     esac
  142.     break
  143.     else
  144.     echo "... $i didn't work"
  145.     fi
  146. done
  147. if [ -z "$workingtype" ]
  148. then
  149.     echo "ERROR: Oh my, your troff doesn't seem to work AT ALL!"
  150.     echo "       It's giving me non-zero return codes when I try"
  151.     echo "       all of the known different ways of setting width table"
  152.     echo "       directory (including none!).  Egads.  Get Help!!!!!!!"
  153.     exit 1
  154. fi
  155.  
  156. if [ "$workingtype" != "$trofftype" ]
  157. then
  158.     echo "ERROR: You should have trofftype='$workingtype' in $psrofflib"
  159.     echo "       Psroff won't work AT ALL without this fixed"
  160. else
  161.     echo "INFO: Your trofftype setting ($trofftype) appears correct"
  162. fi
  163.  
  164. if [ ! -r $FONTDIR/ftR ]
  165. then
  166.     echo "INFO: There isn't a $FONTDIR/ftR (it should be if you've installed"
  167.     echo "      Troff on your system.  Without it, I can't test HEADERSIZE"
  168. else
  169.     hdrsize=`sed -n \
  170.     -e 's/^#define[     ]*HEADERSIZE[     ]*\([0-9]*\).*/\1/p' defs.h`
  171.     echo "INFO: You have HEADERSIZE defined as $hdrsize"
  172.     bytecount=`wc -c $FONTDIR/ftR | sed -e 's/^[     ]*//g' -e 's/[     ].*//`
  173.     case $bytecount in
  174.     224)
  175.         echo "INFO: You appear to have a Xenix-like troff - width tables"
  176.         echo "      have no extraneous garbage.  Lucky you!"
  177.         acthdr=0
  178.         ;;
  179.     *)
  180.         echo "INFO: H'mm, you don't have a Xenix-like troff - Assuming"
  181.         echo "      your troff puts a.out.h headers on width tables, I"
  182.         echo "      will try compiling a teensy program to find out how"
  183.         echo "      big a.out.h headers actually are...."
  184.         cat > AUDITP.c <<\!
  185. #include <a.out.h>
  186. #ifdef    X_EXEC
  187. /*    Xenix I think.... */
  188. #define    HEADERSIZE sizeof(struct xexec)
  189. #endif
  190. #ifdef    F_LNNO
  191. /*    COFF format headers */
  192. #define    HEADERSIZE (-sizeof(struct filehdr))
  193. #endif
  194. #ifndef HEADERSIZE
  195. /*    Generalized V7 or BSD - non-coff format headers */
  196. #define    HEADERSIZE sizeof(struct exec)
  197. #endif
  198. main() {
  199. printf ("%d\n", HEADERSIZE);
  200. }
  201. !
  202.         rm -f AUDITP
  203.         if [ -z "$MAKE" ]
  204.         then
  205.         MAKE=make
  206.         fi
  207.         $MAKE AUDITP > /dev/null 2>&1
  208.         if [ ! -f AUDITP ]
  209.         then
  210.         echo "INFO: H'm, Wouldn't compile ..."
  211.         #    Common for 32 bitters (Sun/Ultrix f'r instance)
  212.         acthdr=-32
  213.         else
  214.         acthdr=`./AUDITP`
  215.         fi
  216.         rm -f AUDITP AUDITP.c
  217.         case $acthdr in
  218.         -*)
  219.             echo 'INFO: The following HEADERSIZE is *purely* a guess:'
  220.             acthdr=`echo $acthdr | sed -e 's/-//'`
  221.             ;;
  222.         esac
  223.         echo "INFO: It looks like HEADERSIZE should be $acthdr"
  224.         ;;
  225.     esac
  226.     if [ "$hdrsize" != "$acthdr" ]
  227.     then
  228.     echo "ERROR: HEADERSIZE should be set to $acthdr, not $hdrsize"
  229.     else
  230.     echo "INFO: HEADERSIZE appears to be set correctly to $hdrsize"
  231.     fi
  232. fi
  233.  
  234. Topts="`sed -e '/^[a-zA-Z]/!d' -e '/^troff/d' \
  235.     -e '/^trofftype/d' -e 's/[     ].*//' $psrofflib | sort -u`"
  236. echo "INFO: Commencing psrofflib ($psrofflib) checking"
  237. if $chkinst
  238. then
  239.     msgtyp='ERROR  '
  240.     troff2ps=$LIBDIR/troff2ps
  241. else
  242.     msgtyp='WARNING'
  243.     troff2ps=./troff2ps
  244. fi
  245.  
  246. if [ ! -f $troff2ps ]
  247. then
  248.     echo "WARNING: Can't test drivers, because troff2ps isn't built"
  249. fi
  250. rm -f PRINTERLIST
  251.  
  252. for type in $Topts
  253. do
  254.     troff="<not set>"
  255.     trofftype="<not set>"
  256.     width="<not set>"
  257.     t2arg="<not set>"
  258.     lparg="<not set>"
  259.     ptr="<not set>"
  260. #    If your system has no awk (or a busted one), you may have to
  261. #    comment out the "line=`awk ... $psrofflib" lines, and uncomment
  262. #    the sed script.  If you do, you won't be able to continue
  263. #    psrofflib lines, so you'll have to "join" the entries in psrofflib
  264. #    (remembering to delete the name fields in the continuation lines).
  265.     line=`awk '
  266.     $1 ~ /^#/ {next}
  267.     $0 ~ /^troff/ { print $0 }
  268.     $1 == "'$type'" {
  269.         seen=1
  270.         print "F='T'" substr($0, length($1) + 1)
  271.         next
  272.     }
  273.     { if (seen) exit(0) }
  274.     ' $psrofflib`
  275.     eval "$line"
  276.     echo "INFO: psroff -T$type settings:"
  277.     echo "      troff      $troff"
  278.     echo "      trofftype  $trofftype"
  279.     echo "      width      $width"
  280.     if [ -n "$FONTDIR" -a ! -d $FONTDIR/$width ]
  281.     then
  282.     echo "   * $msgtyp: FONTDIR/$width not installed yet"
  283.     echo "              psroff -T$width won't work until you do"
  284.     fi
  285.     if [ ! -d widths/width${width} ]
  286.     then
  287.     echo "   * WARNING: no widths/width${width} directory"
  288.     fi
  289.     echo "      t2arg      $t2arg"
  290.     drivertype=`echo $t2arg | sed -n -e 's/.*-T\([^     ]*\).*/\1/p'`
  291.     printertype=`echo $t2arg | sed -n -e 's/.*-p\([^     ]*\).*/\1/p'`
  292.     if [ -z "$drivertype" ]
  293.     then
  294.     echo "   * INFO   : no -T in $psrofflib t2arg - assuming ps"
  295.     drivertype=ps
  296.     fi
  297.     if [ -z "$printertype" ]
  298.     then
  299.     printertype=$drivertype
  300.     fi
  301.     echo "          Driver type: $drivertype, library prefix: $printertype"
  302.     if [ -f $troff2ps ]
  303.     then
  304.     $troff2ps -T$drivertype < /dev/null > /dev/null 2>&1
  305.     if [ $? != 0 ]
  306.     then
  307.         echo "   * ERROR  : troff2ps driver $drivertype not" \
  308.         "configured psroff -T$width will die"
  309.     fi
  310.     fi
  311.     set +x
  312.     echo "      lparg      $lparg"
  313.     echo "      ptr        $ptr"
  314.     if [ ! -r $libbase/$printertype.lib ]
  315.     then
  316.     echo "   * WARNING: no $libbase/$printertype.lib (no prolog)"
  317.     fi
  318.     if [ ! -r $libbase/$printertype.fonts ]
  319.     then
  320.     echo "   * ERROR  : Can't find $libbase/$printertype.fonts"
  321.     echo "              Won't be able to give you list of fonts available"
  322.     continue
  323.     fi
  324.     echo "See $printertype.fonts below for listing of fonts"
  325.     echo $printertype >> PRINTERLIST
  326. done
  327.  
  328. if [ -z "$printerlist" -a -s PRINTERLIST ]
  329. then
  330.     printerlist=`sort -u PRINTERLIST`
  331. fi
  332. rm -f PRINTERLIST
  333.  
  334. for printertype in $printerlist
  335. do
  336.     (
  337.     if [ -n "$FONTDIR" -a -d "$FONTDIR/$printertype" ]
  338.     then
  339.         ls $FONTDIR/$printertype | sed -n -e 's/^.*ft//p' | sort -u
  340.     fi
  341.     echo "troff2ps"
  342.     cat $libbase/$printertype.fonts
  343.     ) | awk '
  344.     BEGIN {
  345.     fontdir = "'"$FONTDIR"'"
  346.     printertype = "'"$printertype"'"
  347.     catfonts[""] = 0
  348.     fonts[""] = 0
  349.     printf("\n\nPrinter type %s.fonts\n\n", printertype);
  350.     printf("%-4s %-20s %-25s %s\n", "Cat", "English Name", "Sequence", \
  351.         "Flags");
  352.     printf("Name\n\n");
  353.     ignoring = 0
  354.     }
  355.     $1 == "troff2ps" {
  356.     startlisting = 1;
  357.     next
  358.     }
  359.     $1 == "normal" || $1 == "symbol" {
  360.     ignoring = 1
  361.     }
  362.     $1 !~ /^[A-Za-z][A-Za-z]*/ {
  363.     next
  364.     }
  365.     NF >= 1 {
  366.     if (ignoring)
  367.         next
  368.     if (startlisting) {
  369.         english = ""
  370.         sequence = ""
  371.         flags = ""
  372.         name = $1
  373.         if (NF > 1)
  374.         english = $2
  375.         if (NF > 2)
  376.         sequence = $3
  377.         if (NF > 3)
  378.         flags = $4
  379.         printf("%-4s %-20s %-25s %s\n", name, english, sequence, flags);
  380.         fonts[name] = 1
  381.     } else {
  382.         catfonts[$1] = 1
  383.         ftdirfound = 1
  384.     }
  385.     }
  386.     END {
  387.     if (ftdirfound) {
  388.         for (name in fonts) {
  389.         if (name && !catfonts[name])
  390.             printf("  FONT %s: do not use: %s/%s/ft%s not installed\n",\
  391.             name, fontdir, printertype, name);
  392.         }
  393.     }
  394.     for (name in catfonts) {
  395.         if (name && !fonts[name]) {
  396.         printf("  FONT %s: do not use: %s/%s/ft%s exists, but", \
  397.             name, fontdir, printertype, name)
  398.         printf(" not in %s.fonts\n", printertype)
  399.         }
  400.     }
  401.     }'
  402.     if [ -n "$LJF" -a -d "$LJF" -a "$printertype" = lj ]
  403.     then
  404.     echo "I'm checking $printertype.fonts file for missing font"
  405.     echo "files, please have patience"
  406.     sed -e '/^[A-Za-z][A-Za-z]*/!d' $libbase/$printertype.fonts |
  407.         while read troffname english sequence flags
  408.         do
  409.             for i in 6 7 8 9 10 11 12 14 16 18 20 22 24 28 36
  410.         do
  411.             suffix=
  412.             case $flags in
  413.             n* | b*) ;;
  414.             p*)
  415.                 suffix=pk
  416.                 ;;
  417.             s*)
  418.                 suffix=sfp
  419.                 ;;
  420.             esac
  421.             if [ -n "$suffix" -a ! -r $LJF/$troffname.$i.$suffix ]
  422.             then
  423.             echo "ERROR: $LJF/$troffname.$i.$suffix missing"
  424.             fi
  425.             flags=`echo $flags | sed -e 's/.\(.*\)/\1/'`
  426.         done
  427.         done
  428.     fi
  429. done
  430.