Printcap for HP Laserjet II
Dan O'Neill
dan at asihub.UUCP
Sat Aug 12 07:18:15 AEST 1989
Here is a copy of the "generic" filter as posted by George Robbins a
while back.
#! /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
# lpf.c
# This archive created: Wed Jul 12 04:11:28 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(1418 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
X#
X# Copyright (c) 1987 Regents of the University of California.
X# All rights reserved.
X#
X# Redistribution and use in source and binary forms are permitted
X# provided that the above copyright notice and this paragraph are
X# duplicated in all such forms and that any documentation,
X# advertising materials, and other materials related to such
X# distribution and use acknowledge that the software was developed
X# by the University of California, Berkeley. The name of the
X# University may not be used to endorse or promote products derived
X# from this software without specific prior written permission.
X# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X#
X# @(#)Makefile 5.5 (Berkeley) 6/30/88
X#
XCFLAGS= -O
XLIBC= /lib/libc.a
XLIBDIR= /usr/lib
XSRCS= lpf.c
XOBJS= lpf.o
X
Xall: lpf
X
Xlpf: lpf.c
X ${CC} -o $@ ${CFLAGS} lpf.c
X
Xclean: FRC
X rm -f ${OBJS} core lpf
X
Xdepend: FRC
X mkdep -p ${CFLAGS} ${SRCS}
X
Xinstall: FRC
X install -s -o bin -g bin -m 755 lpf ${DESTDIR}/${LIBDIR}/lpf
X
Xlint: FRC
X lint ${CFLAGS} ${SRCS}
X
Xtags: FRC
X ctags ${SRCS}
X
XFRC:
X
X# DO NOT DELETE THIS LINE -- mkdep uses it.
X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
X
Xlpf: lpf.c /usr/include/stdio.h /usr/include/signal.h
Xlpf: /usr/include/machine/trap.h
X
X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
SHAR_EOF
if test 1418 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 1418 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'lpf.c'" '(4323 characters)'
if test -f 'lpf.c'
then
echo shar: will not over-write existing file "'lpf.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'lpf.c'
X/*
X * Copyright (c) 1983 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley. The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1983 Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)lpf.c 5.3 (Berkeley) 6/30/88";
X#endif /* not lint */
X
X/*
X * filter which reads the output of nroff and converts lines
X * with ^H's to overwritten lines. Thus this works like 'ul'
X * but is much better: it can handle more than 2 overwrites
X * and it is written with some style.
X * modified by kls to use register references instead of arrays
X * to try to gain a little speed.
X */
X
X#include <stdio.h>
X#include <signal.h>
X
X#define MAXWIDTH 132
X#define MAXREP 10
X
Xchar buf[MAXREP][MAXWIDTH];
Xint maxcol[MAXREP] = {-1};
Xint lineno;
Xint width = 132; /* default line length */
Xint length = 66; /* page length */
Xint indent; /* indentation length */
Xint npages = 1;
Xint literal; /* print control characters */
Xchar *name; /* user's login name */
Xchar *host; /* user's machine name */
Xchar *acctfile; /* accounting information file */
X
Xmain(argc, argv)
X int argc;
X char *argv[];
X{
X register FILE *p = stdin, *o = stdout;
X register int i, col;
X register char *cp;
X int done, linedone, maxrep;
X char ch, *limit;
X
X while (--argc) {
X if (*(cp = *++argv) == '-') {
X switch (cp[1]) {
X case 'n':
X argc--;
X name = *++argv;
X break;
X
X case 'h':
X argc--;
X host = *++argv;
X break;
X
X case 'w':
X if ((i = atoi(&cp[2])) > 0 && i <= MAXWIDTH)
X width = i;
X break;
X
X case 'l':
X length = atoi(&cp[2]);
X break;
X
X case 'i':
X indent = atoi(&cp[2]);
X break;
X
X case 'c': /* Print control chars */
X literal++;
X break;
X }
X } else
X acctfile = cp;
X }
X
X for (cp = buf[0], limit = buf[MAXREP]; cp < limit; *cp++ = ' ');
X done = 0;
X
X while (!done) {
X col = indent;
X maxrep = -1;
X linedone = 0;
X while (!linedone) {
X switch (ch = getc(p)) {
X case EOF:
X linedone = done = 1;
X ch = '\n';
X break;
X
X case '\f':
X lineno = length;
X case '\n':
X if (maxrep < 0)
X maxrep = 0;
X linedone = 1;
X break;
X
X case '\b':
X if (--col < indent)
X col = indent;
X break;
X
X case '\r':
X col = indent;
X break;
X
X case '\t':
X col = ((col - indent) | 07) + indent + 1;
X break;
X
X case '\031':
X /*
X * lpd needs to use a different filter to
X * print data so stop what we are doing and
X * wait for lpd to restart us.
X */
X if ((ch = getchar()) == '\1') {
X fflush(stdout);
X kill(getpid(), SIGSTOP);
X break;
X } else {
X ungetc(ch, stdin);
X ch = '\031';
X }
X
X default:
X if (col >= width || !literal && ch < ' ') {
X col++;
X break;
X }
X cp = &buf[0][col];
X for (i = 0; i < MAXREP; i++) {
X if (i > maxrep)
X maxrep = i;
X if (*cp == ' ') {
X *cp = ch;
X if (col > maxcol[i])
X maxcol[i] = col;
X break;
X }
X cp += MAXWIDTH;
X }
X col++;
X break;
X }
X }
X
X /* print out lines */
X for (i = 0; i <= maxrep; i++) {
X for (cp = buf[i], limit = cp+maxcol[i]; cp <= limit;) {
X putc(*cp, o);
X *cp++ = ' ';
X }
X if (i < maxrep)
X putc('\r', o);
X else
X putc(ch, o);
X if (++lineno >= length) {
X fflush(o);
X npages++;
X lineno = 0;
X }
X maxcol[i] = -1;
X }
X }
X if (lineno) { /* be sure to end on a page boundary */
X putchar('\f');
X npages++;
X }
X if (name && acctfile && access(acctfile, 02) >= 0 &&
X freopen(acctfile, "a", stdout) != NULL) {
X printf("%7.2f\t%s:%s\n", (float)npages, host, name);
X }
X exit(0);
X}
SHAR_EOF
if test 4323 -ne "`wc -c < 'lpf.c'`"
then
echo shar: error transmitting "'lpf.c'" '(should have been 4323 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--
Dan O'Neill dan at asihub.uucp {uunet|ncr-sd}!asihub!dan
Automated Systems, Inc. San Diego R&D
More information about the Comp.unix.ultrix
mailing list