9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: David Presotto <presotto@closedmind.org>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] AFPL Ghostscript-8.13 plus hpijs-1.5
Date: Tue, 24 Feb 2004 10:04:04 -0500	[thread overview]
Message-ID: <5f3b79b4d24b73c53e008e32664e8cba@plan9.bell-labs.com> (raw)
In-Reply-To: <9fab7466fa083b26a6ea23adda6a8cb6@granite.cias.osakafu-u.ac.jp>

[-- Attachment #1: Type: text/plain, Size: 65 bytes --]

I stuck your /sys/lib/lp/process/{generic,pdfgsijs} onto sources.

[-- Attachment #2: Type: message/rfc822, Size: 9866 bytes --]

From: Kenji Okamoto <okamoto@granite.cias.osakafu-u.ac.jp>
To: okamoto@granite.cias.osakafu-u.ac.jp, 9fans@cse.psu.edu
Subject: Re: [9fans] AFPL Ghostscript-8.13 plus hpijs-1.5
Date: Tue Feb 17 13:44:54 JST 2004
Message-ID: <9fab7466fa083b26a6ea23adda6a8cb6@granite.cias.osakafu-u.ac.jp>


After one night sleep, I reminded two more necessary notes:

1) page program has to be modified a bit:
	ie. delete the -dSAFER flag from /sys/src/cmd/page/gs.c

2) to co-work with device ijs, pdf file must be converted to ps
	file prior to feed it to gs.   For this reason, I have following
	/sys/lib/lp/process/generic and /sys/lib/lp/process/pdfgsijs
	files as follows:

--------/sys/lib/lp/process/generic--------
#!/bin/rc
# Tries to determine what type of file you are printing and do the correct
# thing with it.
# It currently knows about images, troff intermediate, and ascii files.
TMPFILE=/tmp/lp$pid
fn sigexit { rm -f $TMPFILE; }
if (! ~ $DEBUG '') flag x +
if (~ $LPCLASS *nohead*) NOHEAD=1
if (~ $LPCLASS *duplex*) DUPLEX=1
cat >$TMPFILE
FILETYPE=`{file $TMPFILE}
switch ($FILETYPE(2)) {
case troff;
	switch ($LPCLASS) {
	case *Latin1* *post* *opost*;	switch ($FILETYPE(5)) {
					# Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9
					case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost

					case UTF; $LPLIB/process/tr2post < $TMPFILE
					}

	case *gs!* *gsijs!*;	switch ($FILETYPE(5)) {
					# Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9
					case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost |$LPLIB/process/gspipe

					case UTF; $LPLIB/process/tr2post < $TMPFILE |$LPLIB/process/gspipe
					}

	case *;		echo $FILETYPE(2) -T$FILETYPE(5) output is improper for $LPDEST >[1=2]
	}
case special;
	switch ($FILETYPE(4)) {
	case '#b';		switch ($LPCLASS) {
				case *post*;	$LPLIB/process/p9bitpost < $TMPFILE
				case *gs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
				case *gsijs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipeijs
				}

	case *;		echo $FILETYPE file is improper for $LPDEST >[1=2]
	}
case Compressed plan old;	# type is really 'Compressed image' or 'plan 9 image'
				# or 'old plan 9 image'
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/p9bitpost < $TMPFILE
	case *gs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipeijs
	}
case jpeg;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/jpgpost < $TMPFILE
	case *gs!*;	$LPLIB/process/jpgpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/jpgpost < $TMPFILE |$LPLIB/process/gspipeijs
	}

case GIF;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/gifpost < $TMPFILE
	case *gs!*;	$LPLIB/process/gifpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/gifpost < $TMPFILE |$LPLIB/process/gspipeijs
	}

case ccitt-g31;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/g3post < $TMPFILE
	case *gs!*;	$LPLIB/process/g3post < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/g3post < $TMPFILE |$LPLIB/process/gspipeijs
	}

# bitmap for research UNIX compatibility, does not work on Plan 9.
case bitmap;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/bpost < $TMPFILE
	case *mhcc*;	$LPLIB/process/bpost < $TMPFILE | $LPLIB/process/mhcc
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case tex;
	mv $TMPFILE $TMPFILE.dvi
	TMPFILE=$TMPFILE.dvi
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/dvipost $TMPFILE
	case *gs!*;	$LPLIB/process/dvipost $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/dvipost $TMPFILE |$LPLIB/process/gspipeijs
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case postscript;
	switch ($LPCLASS) {
	case *post*;		$LPLIB/process/post < $TMPFILE
	case *gs!*;		$LPLIB/process/post < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;		$LPLIB/process/post < $TMPFILE |$LPLIB/process/gspipeijs
	case *;			echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case HPJCL;
	switch ($LPCLASS) {
	case *HPJCL*;		$LPLIB/process/noproc < $TMPFILE
	case *;			echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case daisy;
	switch ($LPDEST) {
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case English short extended alef limbo [Aa]scii assembler c latin rc sh as mail email message/rfc822;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/ppost < $TMPFILE
	case *gs!*;	$LPLIB/process/ppost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/ppost < $TMPFILE |$LPLIB/process/gspipeijs
	case *canon*;	$LPLIB/process/can $* < $TMPFILE
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}

case tiff;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/tiffpost $TMPFILE
	case *gs!*;	$LPLIB/process/tiffpost $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/tiffpost $TMPFILE |$LPLIB/process/gspipeijs
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case PDF;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/pdfpost $TMPFILE
	case *gs!*;	$LPLIB/process/pdfgs $TMPFILE
	case *gsijs!*;	$LPLIB/process/pdfgsijs $TMPFILE
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case empty;
	echo file is empty >[1=2]
case cannot;
	echo cannot open file >[1=2]
case *;
	echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
}
wait
rv=$status
rm -f $TMPFILE
#exit $status
exit
---------end here-------

--------/sys/lib/lp/process/pdfgsijs---------
#!/bin/rc

# usage: pdfgsijs pdffile

gs -dSAFER -dNOPAUSE -dBATCH -q -s'DEVICE=pswrite' -d'LanguageLevel=2' -s'OutputFile=/tmp/pdf2ps.ps' $1

MODEL=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)(\+.*)?/\2/'}
NUMBER=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)\+(.*)?/\3/'}

GSTMPFILE=/tmp/pdf^$pid

switch($NUMBER) {
case 2100
	GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE  -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -dBATCH)
case 2500
	GSOPT=(-q -sDEVICE'='ijs -sIjsServer'='hpijs -sDeviceManufacturer'='HP '-sDeviceModel='"$MODEL^' '^$NUMBER" -r600 -sOutputFile'='^$GSTMPFILE -dDuplex'='true -sPAPERSIZE'='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE -DBATCH)
}


if(~ $OLIST '')
	gs $GSOPT /tmp/pdf2ps.ps
if not {
	PGLIST=`{echo $OLIST | sed 's/-o//;s/,/ /g;s/	/ /g' | tr -cd '0-9 -'}
	GSPGLIST=()
	for(i in $PGLIST){
		switch($i){
		case -*
			GSPGLIST=($GSPGLIST `{seq 1 `{echo $i|tr -d '-'}})
		case *-
			# BUG assume 100 >= number of pages
			GSPGLIST=($GSPGLIST `{seq `{echo $i|tr -d '-'} 100})
		case *-*
			GSPGLIST=($GSPGLIST `{seq `{echo $i|tr '-' ' '}})
		case *
			GSPGLIST=($GSPGLIST $i)
		}
	}
	GSPGLIST=$"GSPGLIST
	echo '
		/Page null def
		/Page# 0 def
		/PDFSave null def
		/DSCPageCount 0 def
		/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage} def
		GS_PDF_ProcSet begin
		pdfdict begin
		('^$1^') (r) file pdfopen begin
		/npage pdfpagecount def
		['^$GSPGLIST^']
		{
			dup dup
				1 ge exch npage le and
				{ DoPDFPage }
				{ pop }
			ifelse
		} forall
	' | gs $GSOPT - >/dev/null >[2=1]
}

cat $GSTMPFILE
rm -f $GSTMPFILE
rm -f /tmp/pdf2ps.ps
exit ''
-------to here-------

3) I'm using usb psc2550 here which is connected to a cpu server
     machine called "diabase"
     Then, for an example, I have /rc/bin/psc2550lp command like this:

-------------/rc/bin/psc2550lp-----------
#!/bin/rc

if(! test -r /dev/usb1)
	import -a diabase '#'U /dev

if(! ~ `{ps |grep usbd} *usbd)
	usb/usbd
for(i in `{seq 20}){
	if (grep -s '3 0x020107' /dev/usb1/$i/status >[2]/dev/null){
		echo -n 'ep 3 bulk w 64 32' >/dev/usb1/$i/ctl
		bind /dev/usb1/$i/ep3data /n/lp
		exit ''
	}
}
exit 'no printer'
---------------end here---------


      To use this command on acme,
       Local psc2550lp
then
       lp -dpsc2550 foo.pdf

4) my /sys/lib/lp/devices line for psc2550 is as follows:

# Hewlett-Packard All-in-One Printer PSC 2500
psc2550 ThisRoom	-	/n/lp	-	gsijs!psc+2500	generic	nospool	-	-	-	-


Kenji

  parent reply	other threads:[~2004-02-24 15:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-17  4:44 Kenji Okamoto
2004-02-18  5:34 ` Kenji Okamoto
2004-02-24 15:04 ` David Presotto [this message]
2004-02-25  0:50   ` Kenji Okamoto
2004-02-25  0:54     ` David Presotto
  -- strict thread matches above, loose matches on Subject: below --
2004-02-17  2:08 Kenji Okamoto
2004-02-17  2:11 ` Geoff Collyer
2004-02-17  2:18   ` Kenji Okamoto
2004-02-17  2:35     ` Kenji Okamoto
2004-02-17  4:42       ` Kenji Okamoto
2004-02-17 13:04 ` David Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f3b79b4d24b73c53e008e32664e8cba@plan9.bell-labs.com \
    --to=presotto@closedmind.org \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).