[comp.unix.questions...] filter for HP LaserJet II/III connected to a LAT printer under ULTRIX
Robert D. Haskins
HASKINS at MAINE.BITNET
Thu Aug 23 09:54:12 AEST 1990
Archive-name: blu-laserjet-filter/22-Aug-90
Original-posting-by: HASKINS at MAINE.BITNET (Robert D. Haskins)
Original-subject: filter for HP LaserJet II/III connected to a LAT printer under ULTRIX
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)
[Reposted from comp.unix.questions,comp.unix.ultrix.
Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti).]
The following is an archive file for generating several files, two of which
are the input/output file filters. I dont think these have been posted
recently, but if they have, my apologies.
!bob
#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Makefile
# README
# iffil.c
# offil.c
# printcap
# rasterfil.c
# This archive created: Thu Jan 21 09:18:50 1988
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(162 characters)'
if test -f 'Makefile'
then
echo shar: over-writing existing file "'Makefile'"
fi
sed 's/^X//' << \SHAR_EOF > 'Makefile'
XCFLAGS = -O
XOBJS = offil iffil rasterfil
X
Xrasterfil : rasterfil.c
X $(LINK.c) -o $@ $< -lpixrect
X
Xinstall : $(OBJS)
X strip $(OBJS)
X mv $(OBJS) /usr/local/filters
SHAR_EOF
if test 162 -ne "`wc -c 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 162 characters)'
fi
echo shar: extracting "'README'" '(1030 characters)'
if test -f 'README'
then
echo shar: over-writing existing file "'README'"
fi
sed 's/^X//' << \SHAR_EOF > 'README'
XThese are the filters and printcap entries I use for printing on
Xan HP LaserJet Series II Laser Printer from my Sun 3/50. I have the
Xprinter attached to serial port b on the Sun and the serial port
Xon the Laser Printer.
XThese were written by someone (me) who didn't have any idea what was
Xsupposed to go into filters like this. I picked up everything from the
Xmanuals and SMI support. If there is something that is not done correctly
Xor there are any bugs, please let me know. For instance, I wasn't really
Xsure what to do with the -c option of lpr. And I don't know what the
Xcapital E is doing there in the 'tr' value of the printcap entry. It was
Xin the printcap that was distributed recently, and it seemed to make things
Xwork better.
XI hope this is of some use.
X
XBrian Utterback UUCP:ihnp4!cray!hall!blu
XCray Research Inc. sun!tundra!hall!blu
XOne Tara Blvd. ARPA:blu%hall.cray.com at uc.msc.umn.edu
XSuite 301
XNashua NH. 03062 Tele:(603) 888-3083
X
SHAR_EOF
if test 1030 -ne "`wc -c 'README'`"
then
echo shar: error transmitting "'README'" '(should have been 1030 characters)'
fi
echo shar: extracting "'iffil.c'" '(1588 characters)'
if test -f 'iffil.c'
then
echo shar: over-writing existing file "'iffil.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'iffil.c'
X/*
X iffil, a printcap filter to print on the HP LaserJet Series II
X
X Written by Brian Utterback
X December 1987
X
X*/
X
X#include <stdio.h>
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int c,atoi();
X int contr,width,length;
X int nlines=0,npages=2;
X FILE *fopen(), *fp;
X char *cp,*indent;
X char *logi,*host,*actf;
X
X while (--argc) {
X if (*(cp = *++argv) == '-' ) {
X switch (cp[1]) {
X case 'w':
X width = atoi(&cp[2]);
X break;
X
X case 'l':
X length = atoi(&cp[2]);
X break;
X
X case 'c':
X contr++;
X break;
X
X case 'i':
X indent = &cp[2];
X break;
X
X case 'n':
X logi = argv[1];
X break;
X
X case 'h':
X host = argv[1];
X actf = argv[2];
X break;
X }
X }
X };
X
X
X
X printf("\033E"); /* Reset the printer */
X printf("\033&k3G"); /* cr || nl -> cr+nl */
X if ( length == 78 ) /* Legal paper */
X printf("\033&l3a2H"); /* Hand feed */
X if ( length == 45 ) { /* Landscape */
X if (width == 136 || width == 226 )
X printf("\033&l3a2H"); /* Legal again */
X printf("\033&l1O"); /* set to Landscape */
X };
X if (width == 132 || width == 176 || width == 226 )
X printf("\033(s16.66H"); /* Compressed print */
X printf("\033&a%sL",indent); /* Indented */
X while ( (c = getchar()) != EOF) {
X if ( c == '\n' || c == '\r' ) nlines++;
X if ( c == '\f' || nlines > length) {
X nlines = 0;
X npages++;
X };
X putchar(c);
X };
X if (access(actf, 02) >= 0 && (fp = fopen(actf,"a")) != NULL ) {
X fprintf(fp,"%7.2f\t%s:%s\n",(float)npages,host,logi);
X fclose(fp);
X } else {
X fprintf(stderr,
X "iffil: Can't open %s\n", actf);
X exit(1);
X };
X}
SHAR_EOF
if test 1588 -ne "`wc -c 'iffil.c'`"
then
echo shar: error transmitting "'iffil.c'" '(should have been 1588 characters)'
fi
echo shar: extracting "'offil.c'" '(1067 characters)'
if test -f 'offil.c'
then
echo shar: over-writing existing file "'offil.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'offil.c'
X/*
X offil, a printcap filter for printing the header page.
X
X Written by Brian Utterback
X December 19878
X
X*/
X
X#include <stdio.h>
X#include <signal.h>
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X register char *cp;
X register int ch;
X
X /* 'of' filters are only passed width and length arguments from lpd */
X while (--argc) {
X if (*(cp = *++argv) == '-' ) {
X switch (cp[1]) {
X case 'w':
X /* this filter does nothing with width */
X break;
X
X case 'l':
X /* this filter does nothing with length */
X break;
X
X }
X }
X }
X
X printf("\033E");
X printf("\033&k3G");
X while ((ch=getchar()) != EOF) {
X switch(ch) {
X
X case '\31':
X /*
X * LPD needs to use a different filter to
X * print data so stop what we are doing
X * and wait for lpd to restart us.
X */
X if ((ch = getchar()) == '\01') {
X (void) fflush(stdout);
X (void) kill(getpid(), SIGSTOP);
X printf("\033E");
X printf("\033&k3G");
X break;
X } else {
X (void) ungetc(ch,stdin);
X ch='\31';
X }
X default:
X putchar(ch);
X break;
X }
X }
X exit(0);
X}
SHAR_EOF
if test 1067 -ne "`wc -c 'offil.c'`"
then
echo shar: error transmitting "'offil.c'" '(should have been 1067 characters)'
fi
echo shar: extracting "'printcap'" '(2029 characters)'
if test -f 'printcap'
then
echo shar: over-writing existing file "'printcap'"
fi
sed 's/^X//' << \SHAR_EOF > 'printcap'
X##
X## This is a sample of printcap entries used by various printers/plotters
X##
X## DecWriter over a tty line.
X#ap|arpa|ucbarpa|LA-180 DecWriter III:\
X# :br#1200:fs#06320:tr=\f:of=/usr/lib/lpf:lf=/usr/adm/lpd-errs:
X## typical remote printer entry
X#ucbvax|vax|vx|ucbvax line printer:\
X# :lp=:rm=ucbvax:sd=/usr/spool/vaxlpd:lf=/usr/adm/lpd-errs:
X#varian|va|Benson Varian:\
X# :lp=/dev/va0:sd=/usr/spool/vad:mx#2000:pl#58:px#2112:py#1700:tr=\f:\
X# :of=/usr/lib/vpf:if=/usr/lib/vpf:tf=/usr/lib/rvcat:cf=/usr/lib/vdmp:\
X# :gf=/usr/lib/vplotf:df=/usr/local/dvif:\
X# :vf=/usr/lib/vpltdmp:lf=/usr/adm/lpd-errs:
X#versatec|vp|Versatec plotter:\
X# :lp=/dev/vp0:sd=/usr/spool/vpd:sb:sf:mx#0:pw#106:pl#86:px#7040:py#2400:\
X# :of=/usr/lib/vpfW:if=/usr/lib/vpsf:tf=/usr/lib/vcat:cf=/usr/lib/vdmp:\
X# :gf=/usr/lib/vplotf:vf=/usr/lib/vpltdmp:lf=/usr/adm/lpd-errs:\
X# :tr=\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
X#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
X#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n:
X# HP LaserJet Series II on Serial Port B
Xlaserlp|HP|LJ|HP-LaserJet-II|versatec:\
X :br#9600:fc#177777:fs#06021:lf=/usr/adm/lpd-errs:lp=/dev/ttyb:\
X :sd=/usr/spool/lpd:af=/usr/adm/lpd-acct:if=/usr/local/filters/iffil:\
X :xs#00040:tr=\Ef:of=/usr/local/filters/offil:\
X :tf=/usr/local/filters/troff2lj:vf=/usr/local/filters/rasterfil:
Xlp|lasp|laser portrait:\
X :pl#60:pw#80:tc=laserlp:
Xlasl|laser landscape|:\
X :pl#45:pw#106:tc=laserlp:
Xlaspc|laser portrait compressed:\
X :pl#60:pw#132:tc=laserlp:
Xlaslc|laser landscape compressed:\
X :pl#45:pw#176:tc=laserlp:
Xleglc|legal landscape compressed:\
X :pl#45:pw#226:tc=laserlp:
Xlegl|legal landscape:\
X :pl#45:pw#136:tc=laserlp:
Xlegp|legal portrait:\
X :pl#78:pw#80:tc=laserlp:
Xlegpc|legal portrait compressed:\
X :pl#78:pw#132:tc=laserlp:
Xrast300|rasterfile 300 lpi:\
X :px#2400:tc=laserlp:
Xrast150|rasterfile 150 lpi:\
X :px#1200:tc=laserlp:
Xrast100|rasterfile 100 lpi:\
X :px#800:tc=laserlp:
Xrast75|rasterfile 75 lpi:\
X :px#600:tc=laserlp:
SHAR_EOF
if test 2029 -ne "`wc -c 'printcap'`"
then
echo shar: error transmitting "'printcap'" '(should have been 2029 characters)'
fi
echo shar: extracting "'rasterfil.c'" '(2705 characters)'
if test -f 'rasterfil.c'
then
echo shar: over-writing existing file "'rasterfil.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'rasterfil.c'
X/*
X rasterfil a printcap filter for printing rasterfile format.
X
X Written by Brian Utterback
X December 1987
X
X*/
X
X
X#include <stdio.h>
X#include <assert.h>
X#include <varargs.h>
X#include <sys/types.h>
X#include <pixrect/pixrect_hs.h>
X
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X Pixrect *pr, *mpr;
X struct rasterfile rh;
X colormap_t colormap;
X int i,lineby, l,maxbytes,numlines;
X int npages=2;
X char *dd;
X int atoi();
X int xwidth;
X FILE *fopen(), *fp;
X char *cp;
X char *logi,*host,*actf;
X
X while (--argc) {
X if (*(cp = *++argv) == '-' ) {
X switch (cp[1]) {
X case 'x':
X xwidth = atoi(&cp[2]);
X break;
X
X case 'y':
X /* don't do anything with y */
X break;
X
X case 'n':
X logi = argv[1];
X break;
X
X case 'h':
X host = argv[1];
X actf = argv[2];
X break;
X }
X }
X };
X
X
X if ((fp = fopen(actf,"a")) == NULL ) {
X fprintf(stderr,
X "Rasterfilter: Can't open %s\n", actf);
X exit(1);
X };
X fprintf(fp,"%7.2f\t%s:%s\n",(float)npages,host,logi);
X fclose(fp);
X
X /*
X * Load the rasterfile header and check if the input file
X * is in the standard format or the format we are supposed
X * to be able to convert.
X */
X if (pr_load_header(stdin, &rh)) {
X fprintf(stderr,
X "Rasterfilter: unable to load header:%d\n",
X PR_IO_ERR_RASREAD);
X exit(2);
X };
X
X switch (rh.ras_type) {
X case RT_STANDARD:
X case RT_BYTE_ENCODED:
X break;
X
X default:
X fprintf(stderr,
X "Rasterfilter: incorrect type %d\n", rh.ras_type);
X exit(2);
X }
X
X /* load the colormap and image */
X colormap.type = RMT_NONE;
X if (pr_load_colormap(stdin, &rh, &colormap) ||
X !(pr = pr_load_image(stdin, &rh, &colormap))) {
X fprintf(stderr,
X "Rasterfilter: unable to load image:%d\n",
X PR_IO_ERR_RASREAD);
X
X exit(2);
X };
X
X /* Make the memory pixrect */
X mpr = mem_create(pr->pr_size.x,1,1);
X
X /* reset the printer */
X printf("\033E");
X /* position the cursor */
X printf("\033*p0x0Y");
X /* set the resolution */
X if (xwidth == 0 ) xwidth = 1200;
X maxbytes = xwidth / 8;
X numlines = maxbytes * 11;
X printf("\033*t%dR",maxbytes);
X /* set the graphics margin */
X printf("\033*r1A");
X fflush(stdout);
X
X /* for each row in the pixrect, transfer the data to the printer */
X numlines = (numlines < pr->pr_size.y) ? numlines : pr->pr_size.y;
X for (i = 0; i < numlines ; i++ ) {
X pr_rop(mpr, 0, 0, pr->pr_size.x,1, PIX_SRC, pr,0,i);
X /* set up the transfer */
X printf("\033*b");
X /* get the number of bytes */
X lineby = mpr_mdlinebytes(mpr);
X lineby = (lineby > maxbytes) ? maxbytes : lineby;
X printf("%dW",lineby);
X /* write out the bytes */
X l = fwrite((char *)(mpr_d(mpr)->md_image),sizeof(*dd),
X lineby,stdout);
X assert(l==lineby);
X };
X printf("\033*rB");
X printf("\033E");
X
X exit(0);
X}
X
SHAR_EOF
if test 2705 -ne "`wc -c 'rasterfil.c'`"
then
echo shar: error transmitting "'rasterfil.c'" '(should have been 2705
characters)'
fi
# End of shell archive
exit 0
More information about the Alt.sources
mailing list