fixed `fc' and `fs' when 0177777 is needed.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 18 Jun 1983 06:09:45 +0000 (22:09 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 18 Jun 1983 06:09:45 +0000 (22:09 -0800)
SCCS-vsn: usr.sbin/lpr/lpd/printjob.c 4.8
SCCS-vsn: usr.sbin/lpr/common_source/common.c 4.6
SCCS-vsn: usr.sbin/lpr/common_source/displayq.c 4.7
SCCS-vsn: usr.sbin/lpr/common_source/lp.h 4.3
SCCS-vsn: usr.sbin/lpr/common_source/lp.local.h 4.2
SCCS-vsn: usr.sbin/lpr/lpd/recvjob.c 4.5

usr/src/usr.sbin/lpr/common_source/common.c
usr/src/usr.sbin/lpr/common_source/displayq.c
usr/src/usr.sbin/lpr/common_source/lp.h
usr/src/usr.sbin/lpr/common_source/lp.local.h
usr/src/usr.sbin/lpr/lpd/printjob.c
usr/src/usr.sbin/lpr/lpd/recvjob.c

index 0f16a7c..90e1e59 100644 (file)
@@ -1,4 +1,4 @@
-/*     common.c        4.5     83/06/02        */
+/*     common.c        4.6     83/06/17        */
 /*
  * Routines and data common to all the line printer functions.
  */
 /*
  * Routines and data common to all the line printer functions.
  */
@@ -7,6 +7,7 @@
 
 int    DU;             /* daeomon user-id */
 int    MX;             /* maximum number of blocks to copy */
 
 int    DU;             /* daeomon user-id */
 int    MX;             /* maximum number of blocks to copy */
+int    MC;             /* maximum number of copies allowed */
 char   *LP;            /* line printer device name */
 char   *RM;            /* remote machine name */
 char   *RP;            /* remote printer name */
 char   *LP;            /* line printer device name */
 char   *RM;            /* remote machine name */
 char   *RP;            /* remote printer name */
@@ -26,6 +27,7 @@ char  *CF;            /* name of cifplot filter (per job) */
 char   *PF;            /* name of vrast filter (per job) */
 char   *FF;            /* form feed string */
 char   *TR;            /* trailer string to be output when Q empties */
 char   *PF;            /* name of vrast filter (per job) */
 char   *FF;            /* form feed string */
 char   *TR;            /* trailer string to be output when Q empties */
+short  SC;             /* suppress multiple copies */
 short  SF;             /* suppress FF on each print job */
 short  SH;             /* suppress header page */
 short  SB;             /* short banner instead of normal header */
 short  SF;             /* suppress FF on each print job */
 short  SH;             /* suppress header page */
 short  SB;             /* short banner instead of normal header */
@@ -35,10 +37,10 @@ short       PL;             /* page length */
 short  PX;             /* page width in pixels */
 short  PY;             /* page length in pixels */
 short  BR;             /* baud rate if lp is a tty */
 short  PX;             /* page width in pixels */
 short  PY;             /* page length in pixels */
 short  BR;             /* baud rate if lp is a tty */
-short  FC;             /* flags to clear if lp is a tty */
-short  FS;             /* flags to set if lp is a tty */
-short  XC;             /* flags to clear for local mode */
-short  XS;             /* flags to set for local mode */
+int    FC;             /* flags to clear if lp is a tty */
+int    FS;             /* flags to set if lp is a tty */
+int    XC;             /* flags to clear for local mode */
+int    XS;             /* flags to set for local mode */
 short  RS;             /* restricted to those with local accounts */
 
 char   line[BUFSIZ];
 short  RS;             /* restricted to those with local accounts */
 
 char   line[BUFSIZ];
@@ -169,7 +171,7 @@ getq(namelist)
        int arraysz, compar();
        DIR *dirp;
 
        int arraysz, compar();
        DIR *dirp;
 
-       if ((dirp = opendir(".")) == NULL)
+       if ((dirp = opendir(SD)) == NULL)
                return(-1);
        if (fstat(dirp->dd_fd, &stbuf) < 0)
                goto errdone;
                return(-1);
        if (fstat(dirp->dd_fd, &stbuf) < 0)
                goto errdone;
index 1c7b980..ce86140 100644 (file)
@@ -1,13 +1,13 @@
-/*     displayq.c      4.6     83/06/15        */
+/*     displayq.c      4.7     83/06/17        */
 /*
  * Routines to display the state of the queue.
  */
 
 #include "lp.h"
 
 /*
  * Routines to display the state of the queue.
  */
 
 #include "lp.h"
 
-#define JOBCOL 40      /* column for job # in -l format */
-#define OWNCOL 7       /* start of Owner column in normal */
-#define SIZCOL 62      /* start of Size column in normal */
+#define JOBCOL 40              /* column for job # in -l format */
+#define OWNCOL 7               /* start of Owner column in normal */
+#define SIZCOL 62              /* start of Size column in normal */
 
 /*
  * Stuff for handling job specifications
 
 /*
  * Stuff for handling job specifications
@@ -118,7 +118,7 @@ displayq(format)
        fp = fopen(LO, "r");
        if (fp == NULL || flock(fileno(fp), LOCK_SH|LOCK_NB) == 0) {
                if (fp != NULL)
        fp = fopen(LO, "r");
        if (fp == NULL || flock(fileno(fp), LOCK_SH|LOCK_NB) == 0) {
                if (fp != NULL)
-                       fclose(fp);
+                       fclose(fp);     /* unlocks as well */
                garbage = nitems;
                if (sendtorem)
                        printf("\n%s: ", host);
                garbage = nitems;
                if (sendtorem)
                        printf("\n%s: ", host);
@@ -146,7 +146,7 @@ displayq(format)
                        (void) flock(fd, LOCK_SH);
                        while ((i = read(fd, line, sizeof(line))) > 0)
                                (void) fwrite(line, 1, i, stdout);
                        (void) flock(fd, LOCK_SH);
                        while ((i = read(fd, line, sizeof(line))) > 0)
                                (void) fwrite(line, 1, i, stdout);
-                       (void) close(fd);
+                       (void) close(fd);       /* unlocks as well */
                } else
                        putchar('\n');
        }
                } else
                        putchar('\n');
        }
index 40ecf49..c3a1b53 100644 (file)
@@ -1,4 +1,4 @@
-/*     lp.h    4.2     83/05/13        */
+/*     lp.h    4.3     83/06/17        */
 /*
  * Global definitions for the line printer system.
  */
 /*
  * Global definitions for the line printer system.
  */
@@ -21,6 +21,7 @@
 
 extern int     DU;             /* daeomon user-id */
 extern int     MX;             /* maximum number of blocks to copy */
 
 extern int     DU;             /* daeomon user-id */
 extern int     MX;             /* maximum number of blocks to copy */
+extern int     MC;             /* maximum number of copies allowed */
 extern char    *LP;            /* line printer device name */
 extern char    *RM;            /* remote machine name */
 extern char    *RP;            /* remote printer name */
 extern char    *LP;            /* line printer device name */
 extern char    *RM;            /* remote machine name */
 extern char    *RP;            /* remote printer name */
@@ -39,6 +40,7 @@ extern char   *VF;            /* name of raster filter (per job) */
 extern char    *CF;            /* name of cifplot filter (per job) */
 extern char    *FF;            /* form feed string */
 extern char    *TR;            /* trailer string to be output when Q empties */
 extern char    *CF;            /* name of cifplot filter (per job) */
 extern char    *FF;            /* form feed string */
 extern char    *TR;            /* trailer string to be output when Q empties */
+extern short   SC;             /* suppress multiple copies */
 extern short   SF;             /* suppress FF on each print job */
 extern short   SH;             /* suppress header page */
 extern short   SB;             /* short banner instead of normal header */
 extern short   SF;             /* suppress FF on each print job */
 extern short   SH;             /* suppress header page */
 extern short   SB;             /* short banner instead of normal header */
@@ -48,10 +50,10 @@ extern short        PX;             /* page width in pixels */
 extern short   PY;             /* page length in pixels */
 extern short   PL;             /* page length */
 extern short   BR;             /* baud rate if lp is a tty */
 extern short   PY;             /* page length in pixels */
 extern short   PL;             /* page length */
 extern short   BR;             /* baud rate if lp is a tty */
-extern short   FC;             /* flags to clear if lp is a tty */
-extern short   FS;             /* flags to set if lp is a tty */
-extern short   XC;             /* flags to clear for local mode */
-extern short   XS;             /* flags to set for local mode */
+extern int     FC;             /* flags to clear if lp is a tty */
+extern int     FS;             /* flags to set if lp is a tty */
+extern int     XC;             /* flags to clear for local mode */
+extern int     XS;             /* flags to set for local mode */
 extern short   RS;             /* restricted to those with local accounts */
 
 extern char    line[BUFSIZ];
 extern short   RS;             /* restricted to those with local accounts */
 
 extern char    line[BUFSIZ];
index 9237005..3bb72d3 100644 (file)
@@ -1,4 +1,4 @@
-/*     lp.local.h      4.1     83/04/29        */
+/*     lp.local.h      4.2     83/06/17        */
 /*
  * Possibly, local parameters to the spooling system
  */
 /*
  * Possibly, local parameters to the spooling system
  */
@@ -32,6 +32,7 @@
 #define DEFRLPR                "/usr/lib/rlpr"
 #define DEFBINDIR      "/usr/ucb"
 #define        DEFMX           1000
 #define DEFRLPR                "/usr/lib/rlpr"
 #define DEFBINDIR      "/usr/ucb"
 #define        DEFMX           1000
+#define DEFMAXCOPIES   0
 #define DEFFF          "\f"
 #define DEFWIDTH       132
 #define DEFLENGTH      66
 #define DEFFF          "\f"
 #define DEFWIDTH       132
 #define DEFLENGTH      66
index 7f0f623..be23a1f 100644 (file)
@@ -1,4 +1,4 @@
-/*     printjob.c      4.7     83/06/15        */
+/*     printjob.c      4.8     83/06/17        */
 /*
  * printjob -- print jobs in the queue.
  *
 /*
  * printjob -- print jobs in the queue.
  *
@@ -60,11 +60,15 @@ printjob()
        }
        if (stat(LO, &stb) == 0 && (stb.st_mode & 0100))
                exit(0);                /* printing disabled */
        }
        if (stat(LO, &stb) == 0 && (stb.st_mode & 0100))
                exit(0);                /* printing disabled */
-       lfd = open(LO, O_WRONLY|O_CREAT, 0664);
-       if (lfd < 0 || flock(lfd, LOCK_EX|LOCK_NB) < 0) {
+       lfd = open(LO, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+       if (lfd < 0) {
+               log("cannot create %s", LO);
+               exit(1);
+       }
+       if (flock(lfd, LOCK_EX|LOCK_NB) < 0) {
                if (errno == EWOULDBLOCK)       /* active deamon present */
                        exit(0);
                if (errno == EWOULDBLOCK)       /* active deamon present */
                        exit(0);
-               log("cannot create %s", LO);
+               log("cannot lock %s", LO);
                exit(1);
        }
        ftruncate(lfd, 0);
                exit(1);
        }
        ftruncate(lfd, 0);
@@ -86,6 +90,10 @@ printjob()
        }
        if (nitems == 0)                /* no work to do */
                exit(0);
        }
        if (nitems == 0)                /* no work to do */
                exit(0);
+       if (stb.st_mode & 01) {         /* reset queue flag */
+               if (fchmod(lfd, stb.st_mode & 0776) < 0)
+                       log("cannot chmod %s", LO);
+       }
        openpr();                       /* open printer or remote */
 again:
        /*
        openpr();                       /* open printer or remote */
 again:
        /*
@@ -108,10 +116,20 @@ again:
                else
                        i = sendit(q->q_name);
                /*
                else
                        i = sendit(q->q_name);
                /*
-                * Check to see if we are supposed to stop printing.
+                * Check to see if we are supposed to stop printing or
+                * if we are to rebuild the queue.
                 */
                 */
-               if (stat(LO, &stb) == 0 && (stb.st_mode & 0100))
-                       goto done;
+               if (fstat(lfd, &stb) == 0) {
+                       if (stb.st_mode & 0100)
+                               goto done;
+                       if (stb.st_mode & 01) {
+                               for (free((char *) q); nitems--; free((char *) q))
+                                       q = *qp++;
+                               if (fchmod(lfd, stb.st_mode & 0776) < 0)
+                                       log("cannot chmod %s", LO);
+                               break;
+                       }
+               }
                /*
                 * Check to see if we should try reprinting the job.
                 */
                /*
                 * Check to see if we should try reprinting the job.
                 */
@@ -866,13 +884,10 @@ init()
 {
        int status;
 
 {
        int status;
 
-       if ((status = pgetent(line, printer)) < 0) {
-               log("can't open printer description file");
-               exit(1);
-       } else if (status == 0) {
-               log("unknown printer");
-               exit(1);
-       }
+       if ((status = pgetent(line, printer)) < 0)
+               fatal("can't open printer description file");
+       else if (status == 0)
+               fatal("unknown printer");
        if ((LP = pgetstr("lp", &bp)) == NULL)
                LP = DEFDEVLP;
        if ((RP = pgetstr("rp", &bp)) == NULL)
        if ((LP = pgetstr("lp", &bp)) == NULL)
                LP = DEFDEVLP;
        if ((RP = pgetstr("rp", &bp)) == NULL)
@@ -1054,10 +1069,8 @@ setty()
                }
                ttybuf.sg_ispeed = ttybuf.sg_ospeed = bp->speed;
        }
                }
                ttybuf.sg_ispeed = ttybuf.sg_ospeed = bp->speed;
        }
-       if (FC)
-               ttybuf.sg_flags &= ~FC;
-       if (FS)
-               ttybuf.sg_flags |= FS;
+       ttybuf.sg_flags &= ~FC;
+       ttybuf.sg_flags |= FS;
        if (ioctl(pfd, TIOCSETP, (char *)&ttybuf) < 0) {
                log("cannot set tty parameters");
                exit(1);
        if (ioctl(pfd, TIOCSETP, (char *)&ttybuf) < 0) {
                log("cannot set tty parameters");
                exit(1);
index 638e603..1b957f7 100644 (file)
@@ -1,4 +1,4 @@
-/*     recvjob.c       4.4     83/06/15        */
+/*     recvjob.c       4.5     83/06/17        */
 /*
  * Receive printer jobs from the network, queue them and
  * start the printer daemon.
 /*
  * Receive printer jobs from the network, queue them and
  * start the printer daemon.
@@ -143,8 +143,10 @@ readfile(file, size)
                amt = BUFSIZ;
                if (i + amt > size)
                        amt = size - i;
                amt = BUFSIZ;
                if (i + amt > size)
                        amt = size - i;
-               if (err == 0 && write(fd, buf, amt) != amt)
+               if (write(fd, buf, amt) != amt) {
                        err++;
                        err++;
+                       break;
+               }
        }
        (void) close(fd);
        if (err)
        }
        (void) close(fd);
        if (err)