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
-/* 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.
*/
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 */
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 */
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];
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;
-/* 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
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); /* unlocks as well */
garbage = nitems;
if (sendtorem)
printf("\n%s: ", host);
garbage = nitems;
if (sendtorem)
printf("\n%s: ", host);
(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); /* unlocks as well */
/*
* Global definitions for the line printer system.
*/
/*
* Global definitions for the line printer system.
*/
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 */
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 */
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];
-/* 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
*/
#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 DEFFF "\f"
#define DEFWIDTH 132
#define DEFLENGTH 66
#define DEFFF "\f"
#define DEFWIDTH 132
#define DEFLENGTH 66
-/* 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.
*
}
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);
}
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:
/*
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.
*/
- 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)
}
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);
-/* 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.
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) {
}
(void) close(fd);
if (err)
}
(void) close(fd);
if (err)