bugs fixed and vpr options merged into lpr.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Fri, 11 Feb 1983 09:08:45 +0000 (01:08 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Fri, 11 Feb 1983 09:08:45 +0000 (01:08 -0800)
SCCS-vsn: usr.sbin/lpr/filters/lpf.c 4.5
SCCS-vsn: usr.sbin/lpr/Makefile 4.4
SCCS-vsn: usr.sbin/lpr/lpr/lpr.c 4.8
SCCS-vsn: usr.sbin/lpr/common_source/lp.local.h 1.6

usr/src/usr.sbin/lpr/Makefile
usr/src/usr.sbin/lpr/common_source/lp.local.h
usr/src/usr.sbin/lpr/filters/lpf.c
usr/src/usr.sbin/lpr/lpr/lpr.c

index 449ecc7..e0f286d 100644 (file)
@@ -1,3 +1,4 @@
+#      @(#)Makefile    4.4     (Berkeley)      %G%
 #
 # makefile for line printer spooling system
 #
 #
 # makefile for line printer spooling system
 #
@@ -6,7 +7,8 @@
 # DAEMON       someone special
 # SPGRP                the group id of the spooling programs
 #
 # DAEMON       someone special
 # SPGRP                the group id of the spooling programs
 #
-CFLAGS=-O
+
+CFLAGS=-O -DBSD41C
 LDFLAGS=
 LIBDIR=/usr/lib
 BINDIR=/usr/ucb
 LDFLAGS=
 LIBDIR=/usr/lib
 BINDIR=/usr/ucb
@@ -16,12 +18,15 @@ ROOT=root
 DAEMON=daemon
 SPGRP=daemon
 
 DAEMON=daemon
 SPGRP=daemon
 
-all: lpd rlpr lpr lpq lprm lpdrestart filters
+SRCS=lpd.c rlpr.c lpr.c lpq.c lprm.c lpdrestart.c lpdchar.c getq.c printcap.c \
+       lpf.c necf.c
+OBJS=lpd rlpr lpr lpq lprm lpdrestart
+filters=lpf necf
 
 
-filters: laf lpf necf
+all:   ${OBJS}
 
 lpd:   lpd.o lpdchar.o printcap.o getq.o
 
 lpd:   lpd.o lpdchar.o printcap.o getq.o
-       ${CC} -o lpd ${LDFLAGS} lpd.o lpdchar.o printcap.o getq.o
+       ${CC} -o lpd ${LDFLAGS} lpd.o lpdchar.o printcap.o getq.o -ljobs
 
 rlpr:  rlpr.o printcap.o
        ${CC} -o rlpr ${LDFLAGS} rlpr.o printcap.o
 
 rlpr:  rlpr.o printcap.o
        ${CC} -o rlpr ${LDFLAGS} rlpr.o printcap.o
@@ -38,9 +43,6 @@ lprm: lprm.o printcap.o
 lpdrestart: lpdrestart.o
        ${CC} -o lpdrestart ${LDFLAGS} lpdrestart.o
 
 lpdrestart: lpdrestart.o
        ${CC} -o lpdrestart ${LDFLAGS} lpdrestart.o
 
-laf:   laf.c
-       ${CC} -o laf ${CFLAGS} ${LDFLAGS} laf.c
-
 lpf:   lpf.c
        ${CC} -o lpf ${CFLAGS} ${LDFLAGS} lpf.c
 
 lpf:   lpf.c
        ${CC} -o lpf ${CFLAGS} ${LDFLAGS} lpf.c
 
@@ -50,7 +52,7 @@ necf: necf.c
 lpd.o rlpr.o lpr.o lpq.o lprm.o lpdrestart.o: lp.local.h
 lpd.o lpq.o getq.o: getq.h
 
 lpd.o rlpr.o lpr.o lpq.o lprm.o lpdrestart.o: lp.local.h
 lpd.o lpq.o getq.o: getq.h
 
-install: lpd rlpr lpr lpq lprm
+install: all
        install -o ${ROOT} -m 6711 lpd ${LIBDIR}/lpd
        install -o ${DAEMON} -m 6711 rlpr ${LIBDIR}/rlpr
        install -o ${ROOT} -m 6711 lpr ${BINDIR}/lpr
        install -o ${ROOT} -m 6711 lpd ${LIBDIR}/lpd
        install -o ${DAEMON} -m 6711 rlpr ${LIBDIR}/rlpr
        install -o ${ROOT} -m 6711 lpr ${BINDIR}/lpr
@@ -63,10 +65,9 @@ install: lpd rlpr lpr lpq lprm
        chmod 775 ${SPOOLDIR}
 
 clean:
        chmod 775 ${SPOOLDIR}
 
 clean:
-       rm -f lpd rlpr lpr lpq lprm lpdrestart laf lpf necf *.o
+       rm -f ${OBJS} *.o
 
 print:
        @pr makefile
        @${CXREF} *.c | pr -h XREF
        @pr *.h *.c
 
 print:
        @pr makefile
        @${CXREF} *.c | pr -h XREF
        @pr *.h *.c
-
index 7b46f6e..2b71e8a 100644 (file)
 #define DEFBINDIR      "/usr/ucb"
 #define        DEFMX           1000
 #define DEFFF          "\f"
 #define DEFBINDIR      "/usr/ucb"
 #define        DEFMX           1000
 #define DEFFF          "\f"
+#define DEFWIDTH       132
+#define DEFLENGTH      66
 #define DEFUID         1
 
 #define DEFUID         1
 
-/*
- * Some utilities used by lpd
- */
-#define PRLOC          "/bin/pr"
-#define MAIL           "/bin/mail"
-
 /*
  * When files are created in the spooling area, they are normally
  *   readable only by their owner and the spooling group.  If you
 /*
  * When files are created in the spooling area, they are normally
  *   readable only by their owner and the spooling group.  If you
index 0a02387..0f5c6fd 100644 (file)
-/*     lpf.c   4.4     83/01/05        */
-/*
- * lpf -- Line printer filter: handles underlines for those printers/
- *       device drivers that won't
+/*             lpf.c   4.5     83/02/10
+ *     filter which reads the output of nroff and converts lines
+ *     with ^H's to overwritten lines.  Thus this works like 'ul'
+ *     but is much better: it can handle more than 2 overwrites
+ *     and it is written with some style.
+ *     modified by kls to use register references instead of arrays
+ *     to try to gain a little speed.
  */
  */
-
 #include <stdio.h>
 #include <signal.h>
 
 #include <stdio.h>
 #include <signal.h>
 
-#define        LINELN  132
+#define MAXWIDTH  132
+#define MAXREP    10
 
 
-char   linebuf[LINELN+2];
-int    ov;
-int    ff;
-char   ovbuf[LINELN];
+char   buf[MAXREP][MAXWIDTH];
+int    maxcol[MAXREP] = {-1};
 
 main()
 {
 
 main()
 {
-       extern char _sobuf[BUFSIZ];
-
-       setbuf(stdout, _sobuf);
-       while (getline())
-               putline();
-       fflush(stdout);
-       if (ferror(stdout))
-               exit(1);
-       exit(0);
-}
-
-getline()
-{
-       register int col, maxcol, c;
-
-       ov = 0;
-       for (col = 0; col < LINELN; col++) {
-               linebuf[col] = ' ';
-               ovbuf[col] = 0;
-       }
-       col = 0;
-       maxcol = 0;
-       for (;;) switch (c = getchar()) {
-
-       case EOF:
-               return(0);
-
-       default:
-               if (c >= ' ') {
-                       if (col < LINELN) {
-                               if (linebuf[col] != ' ') {
-                                       ov++;
-                                       ovbuf[col] = c;
-                               } else
-                                       linebuf[col] = c;
-                               if (++col > maxcol)
-                                       maxcol = col;
+       register FILE *p = stdin, *o = stdout;
+       register int i, col;
+       register char *cp;
+       int done, linedone, maxrep;
+       char ch, *limit;
+
+       for (cp = buf[0], limit = buf[MAXREP]; cp < limit; *cp++ = ' ');
+       done = 0;
+       
+       while (!done) {
+               col = 0;
+               maxrep = 0;
+               linedone = 0;
+               while (!linedone) {
+                       switch (ch = getc(p)) {
+                       case EOF:
+                               linedone = done = 1;
+                               ch = '\n';
+                               break;
+
+                       case '\031':
+                               fflush(stdout);
+                               kill(getpid(), SIGSTOP);
+                               break;
+
+                       case '\f':
+                       case '\n':
+                               linedone = 1;
+                               break;
+
+                       case '\b':
+                               if (col-- < 0)
+                                       col = 0;
+                               break;
+
+                       case '\r':
+                               col = 0;
+                               break;
+
+                       case '\t':
+                               col = (col | 07) + 1;
+                               break;
+
+                       default:
+                               if (col >= MAXWIDTH)
+                                       break;
+                               cp = &buf[0][col];
+                               for (i = 0; i < MAXREP; i++) {
+                                       if (i > maxrep)
+                                               maxrep = i;
+                                       if (*cp == ' ') {
+                                               *cp = ch;
+                                               if (col > maxcol[i])
+                                                       maxcol[i] = col;
+                                               break;
+                                       }
+                                       cp += MAXWIDTH;
+                               }
+                               col++;
+                               break;
                        }
                }
                        }
                }
-               continue;
-
-       case ' ':
-               col++;
-               continue;
-
-       case '\t':
-               col = (col|07) + 1;
-               if (col > maxcol)
-                       maxcol = col;
-               continue;
-
-       case '\r':
-               col = 0;
-               continue;
-
-       case '\f':
-               ff = 1;         /* force form feed */
-       case '\n':
-               if (maxcol >= LINELN)
-                       maxcol = LINELN;
-               linebuf[maxcol] = 0;
-               return(1);
 
 
-       case '\b':
-               if (col > 0)
-                       col--;
-               continue;
-       }
-}
-
-putline()
-{
-       register char c, *lp;
-
-       lp = linebuf;
-       while (c = *lp++)
-               output(c);
-       if (ov) {
-               putchar('\r');
-               lp = ovbuf;
-               while (ov) {
-                       if (c = *lp++) {
-                               output(c);
-                               ov--;
-                       } else
-                               output(' ');
+               /* print out lines */
+               for (i = 0; i <= maxrep; i++) {
+                       for (cp = buf[i], limit = cp+maxcol[i]; cp <= limit;) {
+                               putc(*cp, o);
+                               *cp++ = ' ';
+                       }
+                       if (i < maxrep)
+                               putc('\r', o);
+                       else
+                               putc(ch, o);
+                       maxcol[i] = -1;
                }
        }
                }
        }
-       putchar('\n');
-       if (ff) {
-               ff = 0;
-               putchar('\f');
-       }
-       if (ferror(stdout))
-               exit(1);
-}
-
-output(c)
-register char c;
-{
-
-       if (c == -1)
-               return;
-       c &= 0177;
-       if (c == 0177)
-               putchar('^'), c = '?';
-       if (c == 033)
-               c = '$';
-       if (c < ' ') switch (c) {
-
-       case '\n':
-               break;
-
-       case '\f':
-       case '\b':
-       case '\t':
-       case '\r':
-               break;
-
-       default:
-               putchar('^');
-               c |= 0100;
-       }
-       putchar(c);
 }
 }
index 5848690..fcfbb78 100644 (file)
@@ -55,7 +55,7 @@
 
 char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
 
 
 char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
 
-/*     lpr.c   4.7     83/01/07        */
+/*     lpr.c   4.8     83/02/10        */
 /*
  *      lpr -- off line print
  *              also known as print
 /*
  *      lpr -- off line print
  *              also known as print