[comp.unix.questions] HP LaserJet Filter

TABAKIN@vms.cis.pitt.edu (08/04/90)

Dear Glenn:  Concerning Hp laserjet and a Decstation, I have a laserjet iii
running off a Decstation3100 in plain hp mode and also with a postscript cartridge.
The info was provided, after several attempts , by DEC.
The file plain_lj.c plus the printcap file does the trick.
Hope it helps.   frank

--------------------plain)lj.c-----------------------------------------
/* xtab - filter out tabs;  replace with correct number of spaces */
#include <stdio.h>
#define D_TABWIDTH 8    /* default tab width */
int tabwidth = D_TABWIDTH;

#define nexttab(x) ((x+tabwidth)-(x%tabwidth)) /* calculate next tab position */

int
main(argc, argv)
int argc;
char *argv[];
{
	register int
		c,          /* incoming char */
		dest,       /* destination column number for tab logic */
                col;        /* next column to print into */
        char *cp, *tcp;

	fputs("\033E\033&k2G\033&166p2e7.6c66F",stdout);
	col = 0;

	while ((c=getchar())  != EOF)  {
		if(c< ' ') {
		       if (c == '\t') {
			       for (dest = nexttab(col) ; col < dest;
col++)
                                      putchar(' ');
                               continue;
                        }
			else if (( c == '\n')  || (c == '\r'))  {
				 putchar(c);
				 col = 0;
				 continue;
                         }
			 else if (c == '\b') {
				 if (col > 0)  {
					 putchar('\b');
					 col--;
                                  }
				  continue;
                          }
		}
                putchar(c);
	        col++;
	}/* while */
	fputs("\033E",stdout);
}

		 
------------------------------------------------------------

------------------printcap------------------------------------------
# set up for printing on hplaseriii in hpl mode
lpj|lp1|lj3|hp:\
	:af=/usr/adm/lp1acct:\
	:br#9600:\
	:fc#0177476:\
	:ff=:\  ff=\033E:\
	:fs#0000301:\
	:lf=/usr/adm/lp1err:\
	:lp=/dev/tty01:\
	:of=/usr/local/plain_lj:\
	:sh:\
	:sb:\
	:sd=/usr/spool/lpd1:\
	:xc#077737:\
	:xs#000040:


------------------------------------------------------------