home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.1 (User) / OpenStep 4.1 (User).iso / usr / netware / bin / PostScriptFilter < prev    next >
Encoding:
Text File  |  1996-09-01  |  8.8 KB  |  361 lines

  1. #!/bin/sh
  2.  
  3. #
  4. #    Copyright Novell Inc. 1991
  5. #    (C) Unpublished Copyright of Novell, Inc. All Rights Reserved.
  6. #
  7. #    No part of this file may be duplicated, revised, translated, localized
  8. #    or modified in any manner or compiled, linked or uploaded or
  9. #    downloaded to or from any computer system without the prior written
  10. #    consent of Novell, Inc.
  11. #
  12. #  NetWare Unix Client 
  13. #    Author:  Gary B. Tomlinson
  14. #    Created: 5/15/91
  15. #
  16. #       SCCS ID: 1.5
  17. #         delta: 2/14/92  15:34:15
  18. #
  19. #    MODULE:
  20. #      The PostScriptFilter -    The NUC Client Network Printer NeXT2_0
  21. #                    lpd spooler PostScript filter program.
  22. #                    Component of the NUC PCLIENT Services.
  23. #
  24. #    ABSTRACT:
  25. #      The PostScriptFilter.c contains the NeXT platform dependent
  26. #      printjob() PostScript filter interface program, which services all
  27. #      NetWare PostScript Printers in behalf of printjob() in the lpd(8)
  28. #      spooler.  This shell script establishes a pipe which reads from the
  29. #      print file mapped onto STDIN, any necessary print filter program,
  30. #      and the printjob_nucps(1) shell backend command.  The printjob()
  31. #      function linked into the lpd(8), PrintPanel(GUI) programs calls
  32. #      this program to spool print files to NetWare QMS print queues.
  33. #
  34. #    NOTE:
  35. #      The print system model implemented by Novell on NeXT platforms
  36. #      follows the file system model for dependent file systems.  The NetWare
  37. #      NCP Printer Service Class is represented by the following dependent
  38. #      shell commands:
  39. #        PostScriptFilter    (This Shell Script)
  40. #        independentFilter    (Parent Shell Script)
  41. #        displayq_nucps        (Related Shell Script)
  42. #        printjob_nucps        (This Scripts PIPE Child Program)
  43. #        rmjob_nucps        (Related Program)
  44. #
  45. #
  46.  
  47. #
  48. # BEGIN_MANUAL_ENTRY(PostScriptFilter(1), \
  49. #            ./man/shell/print/client/NeXT/PostScriptFilter)
  50. # NAME
  51. #    PostScriptFilter, IF, GF, NF, TF, RF, VF, CF, DF
  52. #            -    Set up Spoolng PIPE of a NeXT print file to
  53. #                NetWare QMS.  Member of the NUC PCLIENT Suite.
  54. #
  55. # SYNOPSIS
  56. #    ./PrinterFilters/PostScript/CF -xPxWidth -yPxLength -n userName
  57. #            -h hostName [-R resolution] [-M] -p printerName
  58. #            accountingFileName
  59. #
  60. #    ./PrinterFilters/PostScript/DF -xPxWidth -yPxLength -n userName
  61. #            -h hostName [-R resolution] [-M] -p printerName
  62. #            accountingFileName
  63. #
  64. #    ./PrinterFilters/PostScript/GF -xPxWidth -yPxLength -n userName
  65. #            -h hostName [-R resolution] [-M] -p printerName
  66. #            accountingFileName
  67. #
  68. #    ./PrinterFilters/PostScript/IF [-c] -wChWidth -lChLength -iChIndent
  69. #            [-f printFileName] -n userName -h hostName
  70. #            [-R resolution] [-M] -p printerName accountingFileName
  71. #
  72. #    ./PrinterFilters/PostScript/NF -xPxWidth -yPxLength -n userName
  73. #            -h hostName [-R resolution] [-M] -p printerName
  74. #            accountingFileName
  75. #
  76. #    ./PrinterFilters/PostScript/RF -wChWidth -lChLength -n userName
  77. #            -h hostName [-R resolution] [-M] -p printerName
  78. #            accountingFileName
  79. #
  80. #    ./PrinterFilters/PostScript/TF -xPxwidth -yPxLength -n userName
  81. #            -h hostName [-R resolution] [-M] -p printerName
  82. #            accountingFileName
  83. #
  84. #    ./PrinterFilters/PostScript/VF -xPxwidth -yPxLength -n userName
  85. #            -h hostName [-R resolution] [-M] -p printerName
  86. #            accountingFileName
  87. #
  88. # OPTIONS
  89. #    accountingFileName    - Name of accounting file.
  90. #    -c            - Pass control characers through.  Those in
  91. #                  addition to CR, LF, FF, and HT. Used with
  92. #                  ASCII files.
  93. #    -f printFileName    - Name of NeXT file being printed.
  94. #    -h hostName        - Name of host print file originated on.
  95. #    -iChIndent        - Left margin indentation in characters. Used
  96. #                  with ASCII files.
  97. #    -lChLength        - Length of page in lines. Used with
  98. #                  ASCII files.
  99. #    -n userName        - Name of User who spooled the file.
  100. #    -p printerName        - Name of printer known by on NeXT work station.
  101. #    -wChWidth        - Width of page in characters. Used with
  102. #                  ASCII files.
  103. #    -xPxWidth        - Width of page in pixels. Used for Bit Maps.
  104. #    -yPxLength        - Length of page in pixels. Used for Bit Maps.
  105. #    -M            - Printer is to be manually fed.
  106. #    -R resolution        - Resolution in Dots Per Inch of print
  107. #                  print resolution desired.
  108. #
  109. # INPUT
  110. #    None.
  111. #
  112. # OUTPUT
  113. #    Successfull    - Silently exits back to printjob() in parent lpd(8)
  114. #    Failure        - Abort message formatted and displayed on
  115. #              STDOUT.
  116. #
  117. # DESCRIPTION
  118. #    The PostScriptFilter sets up the unspooling PIPE of a file being
  119. #    scheduled for lpd[printjob.o] to a remote NetWare PostScript printer. It
  120. #    is invoked by its filter name in printcap(5)/netinfo(5).  This shell
  121. #    script sets up a pipe to its printjob_nucps(1) NetWare handler with the
  122. #    appropriate filter pushed.  All filtering is done on the NeXT work
  123. #    station prior to spooling it over the wire.
  124. #
  125. #    Note:
  126. #        All names are hard linked to the same shell script for 
  127. #        servicing.  The called name indicates the filter setup
  128. #        model to be used.
  129. #
  130. # FILES
  131. #       /usr/netware/bin/PrinterFilters/PostScript/CF
  132. #       /usr/netware/bin/PrinterFilters/PostScript/DF
  133. #       /usr/netware/bin/PrinterFilters/PostScript/GF
  134. #       /usr/netware/bin/PrinterFilters/PostScript/IF
  135. #       /usr/netware/bin/PrinterFilters/PostScript/NF
  136. #       /usr/netware/bin/PrinterFilters/PostScript/RF
  137. #       /usr/netware/bin/PrinterFilters/PostScript/TF
  138. #       /usr/netware/bin/PrinterFilters/PostScript/VF
  139. #
  140. # SEE ALSO
  141. #    NWcpsIntroduction(3), printjob_nucps(1)
  142. #
  143. # END_MANUAL_ENTRY
  144. #
  145.  
  146. #
  147. # Define the Adobe Transcript Filters
  148. #
  149. TRANSCRIPT_PATH="/usr/lib/transcript"
  150. PDITROFF="$TRANSCRIPT_PATH/psdit"
  151. PSENSCRIPT="/usr/bin/enscript"
  152. PTROFF="$TRANSCRIPT_PATH/pscat"
  153. PPLOT="$TRANSCRIPT_PATH/psplot"
  154.  
  155. #
  156. # Define The PostScript Magic Word
  157. #
  158. PS_MAGIC="^\%\!"
  159. #
  160. # Default the Variables
  161. #
  162. fileName=""
  163. PENSCRIPT=""
  164. ifProgramName=`basename $0`
  165. DEFAULT_FILTER="/bin/cat"
  166.  
  167. #
  168. # Note: The following was dervived from the Adobe Transcript psint.sh
  169. #    shell script.
  170. #
  171. # Note:
  172. #    The NeXT assumes its own printer, thus reversal desired.  In NetWare
  173. #    Many PostScript printers are supported, thus the .options will 
  174. #    determine client reversal filtering.
  175. #    REVERSE=//usr/lib/transcript/psrv
  176.  
  177. VERBOSELOG=1
  178. BANNERFIRST=0
  179. BANNERLAST=0
  180. BANNERPRO=$TRANSCRIPT_PATH/banner.pro
  181. # Note:
  182. #    The pstext encoder assumes Transcript Driver, thus NetWare uses the
  183. #    standard enscript encoder instead.
  184. #    PSTEXT=$TRANSCRIPT_PATH/pstext
  185.  
  186. # load the values from the .options file if present
  187. # NOTE:
  188. #    Only the REVERSE= environment variable is supported at this time.
  189. #    The BANNERFISRT, BANNERLAST, BANNERPRO, VERBOSELOG, and PSTEXT can
  190. #    be implemented with varying degrees of conformance when time permits.
  191. #
  192. test -r ./.options && . ./.options
  193.  
  194.  
  195. #
  196. # Parse the command line to shell script
  197. #
  198. while [ $# != 0 ]
  199. do
  200.     case "$1" in
  201.     
  202.     -c)    # Pass Control Characters, Ignored!!
  203.         ;;
  204.  
  205.     -f)    # Name of print file
  206.         fileName="$2";
  207.         shift;
  208.         ;;
  209.  
  210.     -h)    # Host name of user who spooled, Ignored!!
  211.         shift;
  212.         ;;
  213.  
  214.     -i*)    # Left margin indentation, Ignored!!
  215.         ;;
  216.  
  217.     -l*)    # Page Length in Character Lines, Ignored!!
  218.         ;;
  219.  
  220.     -n)    # User Name, Ignored!!
  221.         shift;
  222.         ;;
  223.  
  224.     -p)    # Local Printer Name, Ignored!!
  225.         shift
  226.         ;;
  227.  
  228.     -w*)    # Page Width in Characters, Ignored!!
  229.         ;;
  230.  
  231.     -x*)    # Page Width in Pixels, Ignored!!
  232.         ;;
  233.  
  234.     -y*)    # Page Length in Pixels, Ignored!!
  235.         ;;
  236.  
  237.     -M)    # Manual feed specified, Ignored!!
  238.         ;;
  239.  
  240.     -R)    # Printer Resolutin in DPI, Ignored!!
  241.         shift;
  242.         ;;
  243.  
  244.     *)    # Accounting File, Ignored!!
  245.         shift;
  246.         ;;
  247.     
  248.     esac
  249.     if [ $# != 0  ]
  250.     then
  251.         shift;
  252.     fi
  253. done
  254.  
  255. #
  256. # Decode the ifProgramName and set up the proper pipe
  257. #
  258. case $ifProgramName in
  259.  
  260. gf)
  261.     #
  262.     # They need a PostScript PLOT graphic filter, use
  263.     # the one provided by TransScript
  264.     #
  265.     if [ -n "$REVERSE" ]
  266.     then
  267.         # Run through Plot then page reversal
  268.          $PPLOT | $REVERSE
  269.     else
  270.         # Simply unspool the PostScript
  271.         $PPLOT
  272.     fi
  273.     ;;
  274.  
  275. "if")
  276.     #
  277.     # They need a PostScript Text ENSCRIPT filter, use
  278.     # the one provided by TransScript
  279.     #
  280.  
  281.     if [ -n "$fileName" ]
  282.     then
  283.         #
  284.         # Is the file alreay PostScript?
  285.         #
  286.         /usr/ucb/head -1 $fileName | grep $PS_MAGIC >/dev/null 2>&1
  287.         if [ $? != 0 ]
  288.         then
  289.             #
  290.             # No, setup for enscript encapsulation
  291.             #
  292.             if [ -z "$ENSCRIPT" ]
  293.             then
  294.                 # Default to line printer style
  295.                 ENSCRIPT="-B -p-"
  296.             fi
  297.             PENSCRIPT="$PSENSCRIPT $ENSCRIPT"
  298.         fi
  299.     fi
  300.  
  301.     if [ -n "$PENSCRIPT" -a -n "$REVERSE" ]
  302.     then
  303.         # Encapsulate and run through page reversal
  304.          $PENSCRIPT | $REVERSE
  305.  
  306.     elif [ -n "$PENSCRIPT" ]
  307.     then
  308.         # Run through encapsulation
  309.          $PENSCRIPT
  310.  
  311.     elif [ -n "$REVERSE" ]
  312.     then
  313.         # Run through page reversal
  314.          $REVERSE
  315.     else
  316.         # Simply unspool the PostScript
  317.         $DEFAULT_FILTER
  318.     fi
  319.     ;;
  320.  
  321. nf)
  322.     #
  323.     # They need a PostScript DITROFF phototypesetter filter, use
  324.     # the one provided by TransScript
  325.     #
  326.     if [ -n "$REVERSE" ]
  327.     then
  328.         # Run through Plot then page reversal
  329.          $PDITROFF | $REVERSE
  330.     else
  331.         # Simply unspool the PostScript
  332.         $PDITROFF
  333.     fi
  334.     ;;
  335.  
  336. tf)
  337.     #
  338.     # They need a PostScript TROFF phototypesetter filter, use
  339.     # the one provided by TransScript
  340.     #
  341.     if [ -n "$REVERSE" ]
  342.     then
  343.         # Run through Plot then page reversal
  344.          $PTROFF | $REVERSE
  345.     else
  346.         # Simply unspool the PostScript
  347.         $PTROFF
  348.     fi
  349.     ;;
  350.  
  351. *)
  352.     #
  353.     # How did we get called?
  354.     #
  355.     echo "$0: $ifProgramName Unknown print filter" >/dev/console;
  356.     exit 2;
  357.     ;;
  358. esac
  359.  
  360. exit
  361.