home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume12 / psf2 / part02 / psfunix.LP < prev    next >
Encoding:
Text File  |  1990-05-19  |  2.3 KB  |  116 lines

  1. #ident    "x(#)lp:model/postscript    1.3.1.2
  2. #  Postscript serial or parallel printer using psf filters
  3. #
  4. #    The Install.unix script will use sed to replace "BINARY" with
  5. #        the binary library directory name such as /local/bin.
  6. #        "OPTIONS" will be replaced by the desired default
  7. #        options - usually the page size (-g Letter) generated
  8. #        with Install.unix.
  9.  
  10. # The following parameters are passed from "lp" at print time.
  11.  
  12. printer=`basename $0`
  13. request=$1
  14. name=$2
  15. title=$3
  16. copies=$4
  17. options=$5
  18. shift; shift; shift; shift; shift
  19.  
  20. # Modify the following for required stty settings.
  21.  
  22. stty onlcr ixon ixoff 0<&1
  23.  
  24. # get the banner option from the configuration file.
  25. # see if the user is allowed to override the banner spec.
  26. # The "Banner: on" and "Banner: on:Always" can be specified by lpadmin.
  27. # The "Banner: off" must be manually edited into the configuration file.
  28.  
  29. banner="yes"
  30. banopt=`sed -n 's/^Banner: *\(.*\).*$/\1/p' /usr/spool/lp/admins/lp/printers/$printer/configuration`
  31. mustbanner="no"
  32. for i in ${banopt}
  33. do
  34.     case "${i}" in
  35.     
  36.     on)        banner="yes"
  37.             mustbanner="no"
  38.             ;;
  39.     on:Always)    banner="yes"
  40.             mustbanner="yes"
  41.             ;;
  42.     off)        banner="no"
  43.             mustbanner="no"
  44.             ;;
  45.     *)        banner="yes"
  46.             mustbanner="no"
  47.             ;;
  48.     esac
  49. done
  50.  
  51. options=
  52. for i in ${option_list}
  53. do
  54.     case "${i}" in
  55.  
  56.     nobanner)
  57.         case "${mustbanner}" in
  58.         yes)    ;;
  59.         *)    banner="no"
  60.             ;;
  61.         esac
  62.         ;;
  63.     banner)
  64.         banner="yes"
  65.         ;;
  66.     *)
  67.         options="${options} ${i}"
  68.         ;;
  69.     esac;
  70. done
  71.  
  72.  
  73. today=`date`
  74.  
  75. [ "$banner" = yes ] && {
  76.  
  77. #    get the machine name uname.
  78.  
  79.     sysid=`uname -n`
  80.  
  81. #    get the user name from the GCOS field in /etc/passwd
  82.  
  83.     user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  84.  
  85.     BINARY/psbanner "$name" "$user" "$request" "$printer" "$options" "$today" "$sysid" "$title" BANNER
  86. }
  87.  
  88. #    If the input text file contains %! in the first line,
  89. #    then assume that it has already been wrapped in postscript
  90. #    code.  If the %! is missing, then filter through psf
  91. #
  92. #    The "OPTIONS" are default options forced in during "Install.unix"
  93. #    Typically, this specifies the default paper size e.g.:
  94. #
  95. #            -g Letter
  96. #
  97. #    The "$options" are passed by lp with  -o"opions"
  98.  
  99. while    [ "$copies" -gt 0 ]
  100. do
  101.     for file
  102.     do
  103.         BINARY/psdetect < "$file"
  104.  
  105.         case $? in
  106.  
  107.         0)    cat "$file" 2>&1;;
  108.  
  109.         1)    BINARY/psf OPTIONS $options "$file" 2>&1;;
  110.  
  111.         esac
  112.     done
  113.     copies=`expr $copies - 1`
  114. done
  115. exit 0
  116.