home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / carp / carp2ps < prev    next >
Text File  |  1992-03-10  |  2KB  |  122 lines

  1. #!/bin/sh
  2. #
  3. # carp2ps carp_result_file
  4. #
  5. #   CARP 2 Postscript converter -- takes a carp text output file
  6. # (or standard in) and converts it to postscript output.
  7. #
  8. AWK=/bin/awk
  9. CAT=/bin/cat
  10. TEST=/bin/test
  11. ECHO=/bin/echo
  12. RM=/bin/rm
  13. carp_awk="./carp.awk"
  14.  
  15. if $TEST $# -ne "1" -o ! -f "$1" ; then
  16.     $ECHO "Usage: $0 carp_result_file"
  17.     exit 2;
  18.     fi
  19. carp_ps="$1.ps"
  20.  
  21. $CAT > $carp_ps << EO_PS
  22. %!
  23.  
  24. %set line height to 40 lines per page, assuming 50 point borders
  25. /lineht 692 40 div def
  26. /col1 80 def
  27. /col2 160 def
  28. /col3 240 def
  29.  
  30. /colwd {
  31.   612 col1 sub col3 sub numcols div
  32. } def
  33.  
  34. /dotitle {
  35.   /y 742 def
  36.   /Times-Roman findfont 20 scalefont setfont
  37.   title stringwidth pop 2 div 306 exch sub y moveto
  38.   title show
  39. } def
  40.  
  41. /doheader {
  42.   /y y 42 sub def
  43.   /Times-Roman findfont 12 scalefont setfont
  44.   col1 y moveto (Hostname) show
  45.   col2 y moveto (Report Date) show
  46.   /Times-Bold findfont 12 scalefont setfont
  47.   /x col3 def
  48.   1 2 numcols {
  49.     pop
  50.     newpath
  51.     x y 4 sub moveto 0 lineht rlineto colwd 0 rlineto 0 lineht neg rlineto
  52.     closepath 0.85 setgray fill 0 setgray
  53.     /x x colwd 2 mul add def
  54.   } for
  55.   /x col3 def
  56.   1 1 numcols {
  57.     x y moveto
  58.     headray exch 1 sub get
  59.     dup stringwidth pop /w exch def
  60.     w colwd 1 sub gt {
  61.       0.5 0 rmoveto
  62.       gsave colwd 1 sub w div 1 scale show grestore
  63.     } {
  64.       w 2 div neg colwd 2 div add 0 rmoveto
  65.       show
  66.     } ifelse
  67.     /x x colwd add def
  68.   } for
  69.   /y y 4 sub def
  70.   gsave 1.5 setlinewidth col1 y moveto 612 col1 sub y lineto stroke grestore
  71. } def
  72.  
  73. /newline {
  74.   /Times-Roman findfont 12 scalefont setfont
  75.   /y y lineht sub def
  76.   exch
  77.   col1 y moveto show
  78.   col2 y moveto show
  79.   /x col3 def
  80.   1 2 numcols {
  81.     pop
  82.     newpath
  83.     x y 2 sub moveto 0 lineht rlineto
  84.       colwd 0 rlineto 0 lineht neg rlineto
  85.       closepath 0.85 setgray fill 0 setgray
  86.     /x x colwd 2 mul add def
  87.   } for
  88.   /x col3 def
  89. } def
  90.  
  91. /donothing {
  92.   /x x colwd add def
  93. } def
  94.  
  95. /dofull {
  96.   newpath
  97.   x colwd 2 div add y 6 add 6 0 360 arc gsave fill grestore stroke
  98.   /x x colwd add def
  99. } def
  100.  
  101. /dohalf {
  102.   newpath
  103.   x colwd 2 div add y 6 add 6 0 360 arc gsave 1 setgray fill grestore stroke
  104.   x colwd 2 div add y 6 add 6 180 360 arc
  105.   closepath fill
  106.   /x x colwd add def
  107. } def
  108.  
  109. /doempty {
  110.   newpath
  111.   x colwd 2 div add y 6 add 6 0 360 arc gsave 1 setgray fill grestore stroke
  112.   /x x colwd add def
  113. } def
  114.  
  115. 0.5 setlinewidth
  116. EO_PS
  117.  
  118. # tack on the real results:
  119. $AWK -f $carp_awk $1 >> $carp_ps
  120.  
  121. # done
  122.