home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / unix / pntps_ls.sha / macfilter.csh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1987-06-07  |  3KB  |  72 lines

  1. #!/bin/csh -f
  2. #    macfilter
  3. #  Filter for Macintosh-generated PostScript code.
  4. #  By Ron Hitchens & Brian Powell
  5. #    hitchens@sally.utexas.edu    brian@sally.utexas.edu
  6. #    hitchens@ut-sally.UUCP        brian@ut-sally.UUCP
  7. #
  8. #  Modification History
  9. #    BHP    March, 1987    Extracted from psfilter.csh and updated to
  10. #                support the 3.1 and 3.3 LW drivers.
  11. #    BHP    May, 1987    Updated to support the 4.0 LW driver.
  12. #
  13. #   This filter prepends the necessary LaserPrep file to the Mac file, then
  14. # sends it through a filter to escape 8-bit characters (otherwise lost by the
  15. # UNIX printer driver.)  This version supports the Macintosh LaserWriter driver
  16. # versions 1.1 (LaserPrep version 12), 3.1 (LaserPrep version 40), 3.3
  17. # (LaserPrep version 49), and 4.0 (LaserPrep version 65).
  18. #   The difference between the four versions is deduced by looking at the
  19. # first line of the input to this script.  The first line from the 1.1 driver
  20. # consists entirely of "md begin".  The first line from the 3.1 driver consists
  21. # of "%!PS-Adobe-1.0".  The first line from the 3.3 driver consists of
  22. # "%!PS-Adobe-1.2".  The first line from the 4.0 driver consists of
  23. # "%!PS-Adobe-2.0".  This script fgreps for those strings in the first line of
  24. # the input file and prepends the corresponding LaserPrep version.
  25. #   NOTE:  Other versions of the LaserWriter driver (most notably version 3.0)
  26. # produce output that is not easily distinguishable from output from Laser-
  27. # Writer driver 3.1.  For this reason, this filter cannot provide warnings
  28. # about incorrect input.  In general, the different versions are incompatible,
  29. # and correct output from anything other than PostScript from the Macintosh
  30. # LaserWriter drivers 1.1, 3.1, 3.3, and 4.0 cannot be expected.
  31.  
  32.  
  33. set prepdir=/usr/local/lib/allfonts/postscript    # dir where the prep files live
  34.  
  35. cat > /tmp/mac$$            # save stdin so we can look at it
  36.  
  37. # search the first line of stdin for "Adobe-1.0", "Adobe-1.2" and "Adobe-2.0".
  38. # The variable stat1 is true if "Adobe-1.0" isn't found, the variable stat2
  39. # is true if "Adobe-1.2" isn't found, and stat3 is true if "Adobe-2.0" isn't
  40. # found.
  41.  
  42. head -1 /tmp/mac$$ | fgrep -s Adobe-1.0 >& /dev/null
  43. set stat1=$status
  44. head -1 /tmp/mac$$ | fgrep -s Adobe-1.2 >& /dev/null
  45. set stat2=$status
  46. head -1 /tmp/mac$$ | fgrep -s Adobe-2.0 >& /dev/null
  47. set stat3=$status
  48.  
  49. if ( ! $stat1 ) then
  50.     set prep=laser-prep-40.pro    # found "Adobe-1.0"; use version 40
  51. else if ( ! $stat2 ) then
  52.     set prep=laser-prep-49.pro    # found "Adobe-1.2"; use version 49
  53. else if ( ! $stat3 ) then
  54.     set prep=laser-prep-65.pro    # found "Adobe-2.0"; use version 65
  55. else
  56.     set prep=laser-prep-12.pro    # not found; assume version 12
  57. endif
  58.  
  59. # Concatenate the prep and the Mac job.  The combined Postscript is then
  60. # piped thru a filter to escape any chars with the high bit set.  (The more
  61. # recent drivers are better about not generating those sorts of characters,
  62. # but we might as well go ahead and do it.)  The final result goes down our
  63. # stdout which is usually being piped into the printer driver (psif or pscomm)
  64.  
  65. cat $prepdir/$prep /tmp/mac$$ | /usr/local/lib/ps8
  66.  
  67. set result=$status        # save the result for our exit code
  68.  
  69. rm -f /tmp/mac$$        # make sure rm runs silently
  70.  
  71. exit $result            # that's all
  72.