BSD-lpr patches for System V part 02/02
Conor P. Cahill
cpcahil at virtech.uucp
Thu Sep 13 11:32:57 AEST 1990
Here is part 2.
---- Cut Here and unpack ----
#!/bin/sh
# this is part 2 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file lpr.diff.2 continued
#
CurArch=2
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
if test "$Scheck" != $CurArch
then echo "Please unpack part $Scheck next!"
exit 1;
else exit 0; fi
) < s2_seq_.tmp || exit 1
sed 's/^X//' << 'SHAR_EOF' >> lpr.diff.2
X }
X if (fchown(f, userid, -1) < 0) {
X printf("%s: cannot chown %s\n", name, n);
X cleanup();
X }
X--- 488,494 -----
X if (chown(n, userid, getgid ()) < 0) {
X #else
X if (fchown(f, userid, -1) < 0) {
X+ #endif /* USG */
X printf("%s: cannot chown %s\n", name, n);
X cleanup();
X }
X**************
X*** 512,517
X * Return -1 if it is not, 0 if its printable, and 1 if
X * we should remove it after printing.
X */
X test(file)
X char *file;
X {
X--- 538,549 -----
X * Return -1 if it is not, 0 if its printable, and 1 if
X * we should remove it after printing.
X */
X+ #ifdef USG
X+ #define exec filehdr
X+ #define execb filehdrb
X+ #define a_magic f_magic
X+ #endif
X+
X test(file)
X char *file;
X {
X**************
X*** 576,581
X return(-1);
X }
X
X /*
X * itoa - integer to string conversion
X */
X--- 608,619 -----
X return(-1);
X }
X
X+ #ifdef USG
X+ #undef exec
X+ #undef execb
X+ #undef a_magic
X+ #endif
X+
X /*
X * itoa - integer to string conversion
X */
X**************
X*** 679,684
X return(s);
X }
X
X /*VARARGS1*/
X fatal(msg, a1, a2, a3)
X char *msg;
X--- 717,723 -----
X return(s);
X }
X
X+ #ifdef NOTDEF /* this is also in common.c */
X /*VARARGS1*/
X fatal(msg, a1, a2, a3)
X char *msg;
X**************
X*** 688,690
X putchar('\n');
X exit(1);
X }
X--- 727,730 -----
X putchar('\n');
X exit(1);
X }
X+ #endif /* NOTDEF */
X*** lprm.1
X--- ../goodlpr/lprm.1
X*** lprm.c
X--- ../goodlpr/lprm.c
X*** lptest.1
X--- ../goodlpr/lptest.1
X*** lptest.c
X--- ../goodlpr/lptest.c
X*** pac.8
X--- ../goodlpr/pac.8
X*** pac.c
X--- ../goodlpr/pac.c
X*** printcap.c
X--- ../goodlpr/printcap.c
X*** printjob.c
X--- ../goodlpr/printjob.c
X**************
X*** 65,71
X char pxwidth[10] = "-x"; /* page width in pixels */
X char pxlength[10] = "-y"; /* page length in pixels */
X char indent[10] = "-i0"; /* indentation size in characters */
X! char tmpfile[] = "errsXXXXXX"; /* file name for filter output */
X
X printjob()
X {
X--- 65,71 -----
X char pxwidth[10] = "-x"; /* page width in pixels */
X char pxlength[10] = "-y"; /* page length in pixels */
X char indent[10] = "-i0"; /* indentation size in characters */
X! char tmpfil[] = "errsXXXXXX"; /* file name for filter output */
X
X #ifdef USG
X char *TT = (char *)0; /* tty (termio) settings, string form */
X**************
X*** 67,72
X char indent[10] = "-i0"; /* indentation size in characters */
X char tmpfile[] = "errsXXXXXX"; /* file name for filter output */
X
X printjob()
X {
X struct stat stb;
X--- 67,77 -----
X char indent[10] = "-i0"; /* indentation size in characters */
X char tmpfil[] = "errsXXXXXX"; /* file name for filter output */
X
X+ #ifdef USG
X+ char *TT = (char *)0; /* tty (termio) settings, string form */
X+ #endif USG
X+
X+
X printjob()
X {
X struct stat stb;
X**************
X*** 92,98
X signal(SIGQUIT, abortpr);
X signal(SIGTERM, abortpr);
X
X! (void) mktemp(tmpfile);
X
X /*
X * uses short form file names
X--- 97,103 -----
X signal(SIGQUIT, abortpr);
X signal(SIGTERM, abortpr);
X
X! (void) mktemp(tmpfil);
X
X /*
X * uses short form file names
X**************
X*** 114,119
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X exit(1);
X }
X ftruncate(lfd, 0);
X /*
X * write process id for others to know
X--- 119,125 -----
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X exit(1);
X }
X+
X ftruncate(lfd, 0);
X /*
X * write process id for others to know
X**************
X*** 132,137
X exit(1);
X }
X if (nitems == 0) /* no work to do */
X exit(0);
X if (stb.st_mode & 01) { /* reset queue flag */
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X--- 138,147 -----
X exit(1);
X }
X if (nitems == 0) /* no work to do */
X+ {
X+ #ifdef DEBUG
X+ syslog (LOG_ERR, "%s: no work to do?", printer);
X+ #endif DEBUG
X exit(0);
X }
X if (stb.st_mode & 01) { /* reset queue flag */
X**************
X*** 133,138
X }
X if (nitems == 0) /* no work to do */
X exit(0);
X if (stb.st_mode & 01) { /* reset queue flag */
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X--- 143,149 -----
X syslog (LOG_ERR, "%s: no work to do?", printer);
X #endif DEBUG
X exit(0);
X+ }
X if (stb.st_mode & 01) { /* reset queue flag */
X #ifdef USG
X if (chmod(LO, stb.st_mode & 0776) < 0)
X**************
X*** 134,139
X if (nitems == 0) /* no work to do */
X exit(0);
X if (stb.st_mode & 01) { /* reset queue flag */
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X }
X--- 145,153 -----
X exit(0);
X }
X if (stb.st_mode & 01) { /* reset queue flag */
X+ #ifdef USG
X+ if (chmod(LO, stb.st_mode & 0776) < 0)
X+ #else
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X #endif USG
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X**************
X*** 135,140
X exit(0);
X if (stb.st_mode & 01) { /* reset queue flag */
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X }
X openpr(); /* open printer or remote */
X--- 149,155 -----
X if (chmod(LO, stb.st_mode & 0776) < 0)
X #else
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X+ #endif USG
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X }
X openpr(); /* open printer or remote */
X**************
X*** 138,143
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X }
X openpr(); /* open printer or remote */
X again:
X /*
X * we found something to do now do it --
X--- 153,161 -----
X syslog(LOG_ERR, "%s: %s: %m", printer, LO);
X }
X openpr(); /* open printer or remote */
X+ #ifdef DEBUG
X+ syslog (LOG_ERR, "%s: got device open", printer);
X+ #endif DEBUG
X again:
X /*
X * we found something to do now do it --
X**************
X*** 147,152
X for (qp = queue; nitems--; free((char *) q)) {
X q = *qp++;
X if (stat(q->q_name, &stb) < 0)
X continue;
X restart:
X (void) lseek(lfd, pidoff, 0);
X--- 165,173 -----
X for (qp = queue; nitems--; free((char *) q)) {
X q = *qp++;
X if (stat(q->q_name, &stb) < 0)
X+ {
X+ syslog(LOG_ERR, "%s: cannot stat %s: %m",
X+ printer, q->q_name);
X continue;
X }
X restart:
X**************
X*** 148,153
X q = *qp++;
X if (stat(q->q_name, &stb) < 0)
X continue;
X restart:
X (void) lseek(lfd, pidoff, 0);
X (void) sprintf(line, "%s\n", q->q_name);
X--- 169,175 -----
X syslog(LOG_ERR, "%s: cannot stat %s: %m",
X printer, q->q_name);
X continue;
X+ }
X restart:
X (void) lseek(lfd, pidoff, 0);
X (void) sprintf(line, "%s\n", q->q_name);
X**************
X*** 170,175
X if (stb.st_mode & 01) {
X for (free((char *) q); nitems--; free((char *) q))
X q = *qp++;
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X syslog(LOG_WARNING, "%s: %s: %m",
X printer, LO);
X--- 192,200 -----
X if (stb.st_mode & 01) {
X for (free((char *) q); nitems--; free((char *) q))
X q = *qp++;
X+ #ifdef USG
X+ if (chmod(LO, stb.st_mode & 0776) < 0)
X+ #else
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X #endif USG
X syslog(LOG_WARNING, "%s: %s: %m",
X**************
X*** 171,176
X for (free((char *) q); nitems--; free((char *) q))
X q = *qp++;
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X syslog(LOG_WARNING, "%s: %s: %m",
X printer, LO);
X break;
X--- 196,202 -----
X if (chmod(LO, stb.st_mode & 0776) < 0)
X #else
X if (fchmod(lfd, stb.st_mode & 0776) < 0)
X+ #endif USG
X syslog(LOG_WARNING, "%s: %s: %m",
X printer, LO);
X break;
X**************
X*** 177,182
X }
X }
X if (i == OK) /* file ok and printed */
X count++;
X else if (i == REPRINT) { /* try reprinting the job */
X syslog(LOG_INFO, "restarting %s", printer);
X--- 203,213 -----
X }
X }
X if (i == OK) /* file ok and printed */
X+ {
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: printed %s okay",
X+ printer, q->q_name);
X+ #endif DEBUG
X count++;
X }
X else if (i == REPRINT) { /* try reprinting the job */
X**************
X*** 178,183
X }
X if (i == OK) /* file ok and printed */
X count++;
X else if (i == REPRINT) { /* try reprinting the job */
X syslog(LOG_INFO, "restarting %s", printer);
X if (ofilter > 0) {
X--- 209,215 -----
X printer, q->q_name);
X #endif DEBUG
X count++;
X+ }
X else if (i == REPRINT) { /* try reprinting the job */
X syslog(LOG_INFO, "restarting %s", printer);
X if (ofilter > 0) {
X**************
X*** 181,186
X else if (i == REPRINT) { /* try reprinting the job */
X syslog(LOG_INFO, "restarting %s", printer);
X if (ofilter > 0) {
X kill(ofilter, SIGCONT); /* to be sure */
X (void) close(ofd);
X while ((i = wait(0)) > 0 && i != ofilter)
X--- 213,222 -----
X else if (i == REPRINT) { /* try reprinting the job */
X syslog(LOG_INFO, "restarting %s", printer);
X if (ofilter > 0) {
X+ #ifdef USG
X+ kill(ofilter, SIGUSR1); /* to be sure */
X+ #endif USG
X+ #ifdef SIGCONT
X kill(ofilter, SIGCONT); /* to be sure */
X #endif SIGCONT
X (void) close(ofd);
X**************
X*** 182,187
X syslog(LOG_INFO, "restarting %s", printer);
X if (ofilter > 0) {
X kill(ofilter, SIGCONT); /* to be sure */
X (void) close(ofd);
X while ((i = wait(0)) > 0 && i != ofilter)
X ;
X--- 218,224 -----
X #endif USG
X #ifdef SIGCONT
X kill(ofilter, SIGCONT); /* to be sure */
X+ #endif SIGCONT
X (void) close(ofd);
X while ((i = wait(0)) > 0 && i != ofilter)
X ;
X**************
X*** 210,216
X if (TR != NULL) /* output trailer */
X (void) write(ofd, TR, strlen(TR));
X }
X! (void) unlink(tmpfile);
X exit(0);
X }
X goto again;
X--- 247,253 -----
X if (TR != NULL) /* output trailer */
X (void) write(ofd, TR, strlen(TR));
X }
X! (void) unlink(tmpfil);
X exit(0);
X }
X goto again;
X**************
X*** 236,241
X char *cp;
X int bombed = OK;
X
X /*
X * open control file; ignore if no longer there.
X */
X--- 273,282 -----
X char *cp;
X int bombed = OK;
X
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: printing %s", printer, file);
X+ #endif DEBUG
X+
X /*
X * open control file; ignore if no longer there.
X */
X**************
X*** 429,434
X int fi, fo;
X char *av[15], buf[BUFSIZ];
X int pid, p[2], stopped = 0;
X union wait status;
X struct stat stb;
X
X--- 470,478 -----
X int fi, fo;
X char *av[15], buf[BUFSIZ];
X int pid, p[2], stopped = 0;
X+ #ifdef USG
X+ int status;
X+ #else
X union wait status;
X #endif USG
X struct stat stb;
X**************
X*** 430,435
X char *av[15], buf[BUFSIZ];
X int pid, p[2], stopped = 0;
X union wait status;
X struct stat stb;
X
X if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X--- 474,480 -----
X int status;
X #else
X union wait status;
X+ #endif USG
X struct stat stb;
X
X #ifdef DEBUG
X**************
X*** 432,437
X union wait status;
X struct stat stb;
X
X if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X return(ERROR);
X /*
X--- 477,487 -----
X #endif USG
X struct stat stb;
X
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: print(%s), format='%c'", printer, file, format);
X+ #endif DEBUG
X+
X+ #ifdef S_IFLNK
X if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X #else
X if (stat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X**************
X*** 433,438
X struct stat stb;
X
X if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X return(ERROR);
X /*
X * Check to see if data file is a symbolic link. If so, it should
X--- 483,491 -----
X
X #ifdef S_IFLNK
X if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X+ #else
X+ if (stat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0)
X+ #endif S_IFLNK
X return(ERROR);
X /*
X * Check to see if data file is a symbolic link. If so, it should
X**************
X*** 439,444
X * still point to the same file or someone is trying to print
X * something he shouldn't.
X */
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X--- 492,498 -----
X * still point to the same file or someone is trying to print
X * something he shouldn't.
X */
X+ #ifdef S_IFLNK
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X**************
X*** 442,447
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X if (!SF && !tof) { /* start on a fresh page */
X (void) write(ofd, FF, strlen(FF));
X tof = 1;
X--- 496,502 -----
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X+ #endif S_IFLNK
X if (!SF && !tof) { /* start on a fresh page */
X (void) write(ofd, FF, strlen(FF));
X tof = 1;
X**************
X*** 447,452
X tof = 1;
X }
X if (IF == NULL && (format == 'f' || format == 'l')) {
X tof = 0;
X while ((n = read(fi, buf, BUFSIZ)) > 0)
X if (write(ofd, buf, n) != n) {
X--- 502,510 -----
X tof = 1;
X }
X if (IF == NULL && (format == 'f' || format == 'l')) {
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: IF is null, format='%c'", printer, format);
X+ #endif DEBUG
X tof = 0;
X while ((n = read(fi, buf, BUFSIZ)) > 0)
X if (write(ofd, buf, n) != n) {
X**************
X*** 450,455
X tof = 0;
X while ((n = read(fi, buf, BUFSIZ)) > 0)
X if (write(ofd, buf, n) != n) {
X (void) close(fi);
X return(REPRINT);
X }
X--- 508,515 -----
X tof = 0;
X while ((n = read(fi, buf, BUFSIZ)) > 0)
X if (write(ofd, buf, n) != n) {
X+ syslog(LOG_ERR, "%s: output write error: %m",
X+ printer);
X (void) close(fi);
X return(REPRINT);
X }
X**************
X*** 565,570
X av[n] = 0;
X fo = pfd;
X if (ofilter > 0) { /* stop output filter */
X write(ofd, "\031\1", 2);
X while ((pid = wait3(&status, WUNTRACED, 0)) > 0 && pid != ofilter)
X ;
X--- 625,633 -----
X av[n] = 0;
X fo = pfd;
X if (ofilter > 0) { /* stop output filter */
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: stopping filter?", printer);
X+ #endif DEBUG
X write(ofd, "\031\1", 2);
X #ifndef USG
X while ((pid = wait3(&status, WUNTRACED, 0)) > 0 && pid != ofilter)
X**************
X*** 566,571
X fo = pfd;
X if (ofilter > 0) { /* stop output filter */
X write(ofd, "\031\1", 2);
X while ((pid = wait3(&status, WUNTRACED, 0)) > 0 && pid != ofilter)
X ;
X if (status.w_stopval != WSTOPPED) {
X--- 629,635 -----
X syslog(LOG_ERR, "%s: stopping filter?", printer);
X #endif DEBUG
X write(ofd, "\031\1", 2);
X+ #ifndef USG
X while ((pid = wait3(&status, WUNTRACED, 0)) > 0 && pid != ofilter)
X ;
X if (status.w_stopval != WSTOPPED) {
X**************
X*** 574,579
X printer, status.w_retcode);
X return(REPRINT);
X }
X stopped++;
X }
X start:
X--- 638,644 -----
X printer, status.w_retcode);
X return(REPRINT);
X }
X+ #endif USG
X stopped++;
X }
X #ifdef DEBUG
X**************
X*** 576,581
X }
X stopped++;
X }
X start:
X if ((child = dofork(DORETURN)) == 0) { /* child */
X dup2(fi, 0);
X--- 641,649 -----
X #endif USG
X stopped++;
X }
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: starting child '%s'", printer, prog);
X+ #endif DEBUG
X start:
X if ((child = dofork(DORETURN)) == 0) { /* child */
X dup2(fi, 0);
X**************
X*** 580,586
X if ((child = dofork(DORETURN)) == 0) { /* child */
X dup2(fi, 0);
X dup2(fo, 1);
X! n = open(tmpfile, O_WRONLY|O_CREAT|O_TRUNC, 0664);
X if (n >= 0)
X dup2(n, 2);
X for (n = 3; n < NOFILE; n++)
X--- 648,654 -----
X if ((child = dofork(DORETURN)) == 0) { /* child */
X dup2(fi, 0);
X dup2(fo, 1);
X! n = open(tmpfil, O_WRONLY|O_CREAT|O_TRUNC, 0664);
X if (n >= 0)
X dup2(n, 2);
X for (n = 3; n < NOFILE; n++)
X**************
X*** 591,598
X }
X (void) close(fi);
X if (child < 0)
X! status.w_retcode = 100;
X! else
X while ((pid = wait(&status)) > 0 && pid != child)
X ;
X child = 0;
X--- 659,673 -----
X }
X (void) close(fi);
X if (child < 0)
X! #ifdef USG
X! status = 100 << 8;
X! #else
X! status.w_retcode = 100;
X! #endif
X! else {
X! #ifdef USG
X! status = 0;
X! #endif USG
X while ((pid = wait(&status)) > 0 && pid != child)
X ;
X }
X**************
X*** 595,600
X else
X while ((pid = wait(&status)) > 0 && pid != child)
X ;
X child = 0;
X prchild = 0;
X if (stopped) { /* restart output filter */
X--- 670,676 -----
X #endif USG
X while ((pid = wait(&status)) > 0 && pid != child)
X ;
X+ }
X child = 0;
X prchild = 0;
X if (stopped) { /* restart output filter */
X**************
X*** 598,603
X child = 0;
X prchild = 0;
X if (stopped) { /* restart output filter */
X if (kill(ofilter, SIGCONT) < 0) {
X syslog(LOG_ERR, "cannot restart output filter");
X exit(1);
X--- 674,689 -----
X child = 0;
X prchild = 0;
X if (stopped) { /* restart output filter */
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: restarting output filter...", printer);
X+ #endif DEBUG
X+ #ifdef USG
X+ if (kill(ofilter, SIGUSR1) < 0) {
X+ syslog(LOG_ERR, "cannot restart output filter: %m");
X+ exit(1);
X+ }
X+ #endif USG
X+ #ifdef SIGCONT
X if (kill(ofilter, SIGCONT) < 0) {
X syslog(LOG_ERR, "cannot restart output filter");
X exit(1);
X**************
X*** 602,607
X syslog(LOG_ERR, "cannot restart output filter");
X exit(1);
X }
X }
X tof = 0;
X if (!WIFEXITED(status)) {
X--- 688,694 -----
X syslog(LOG_ERR, "cannot restart output filter");
X exit(1);
X }
X+ #endif SIGCONT
X }
X tof = 0;
X #ifdef DEBUG
X**************
X*** 604,609
X }
X }
X tof = 0;
X if (!WIFEXITED(status)) {
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X printer, format, status.w_termsig);
X--- 691,702 -----
X #endif SIGCONT
X }
X tof = 0;
X+ #ifdef DEBUG
X+ syslog(LOG_ERR, "%s: filter status %d (0x%x)", printer, status, status);
X+ #endif DEBUG
X+ #ifdef USG
X+ if ((status & 0377) != 0) { /* filter took a signal */
X+ #else
X if (!WIFEXITED(status)) {
X #endif USG
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X**************
X*** 605,610
X }
X tof = 0;
X if (!WIFEXITED(status)) {
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X printer, format, status.w_termsig);
X return(ERROR);
X--- 698,704 -----
X if ((status & 0377) != 0) { /* filter took a signal */
X #else
X if (!WIFEXITED(status)) {
X+ #endif USG
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X #ifdef USG
X printer, format, status & 0177);
X**************
X*** 606,611
X tof = 0;
X if (!WIFEXITED(status)) {
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X printer, format, status.w_termsig);
X return(ERROR);
X }
X--- 700,708 -----
X if (!WIFEXITED(status)) {
X #endif USG
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X+ #ifdef USG
X+ printer, format, status & 0177);
X+ #else
X printer, format, status.w_termsig);
X #endif USG
X return(ERROR);
X**************
X*** 607,612
X if (!WIFEXITED(status)) {
X syslog(LOG_WARNING, "%s: Daemon filter '%c' terminated (%d)",
X printer, format, status.w_termsig);
X return(ERROR);
X }
X switch (status.w_retcode) {
X--- 704,710 -----
X printer, format, status & 0177);
X #else
X printer, format, status.w_termsig);
X+ #endif USG
X return(ERROR);
X }
X #ifdef USG
X**************
X*** 609,614
X printer, format, status.w_termsig);
X return(ERROR);
X }
X switch (status.w_retcode) {
X case 0:
X tof = 1;
X--- 707,715 -----
X #endif USG
X return(ERROR);
X }
X+ #ifdef USG
X+ switch ((status >> 8) & 0377) {
X+ #else
X switch (status.w_retcode) {
X #endif USG
X case 0:
X**************
X*** 610,615
X return(ERROR);
X }
X switch (status.w_retcode) {
X case 0:
X tof = 1;
X return(OK);
X--- 711,717 -----
X switch ((status >> 8) & 0377) {
X #else
X switch (status.w_retcode) {
X+ #endif USG
X case 0:
X tof = 1;
X return(OK);
X**************
X*** 617,622
X return(REPRINT);
X default:
X syslog(LOG_WARNING, "%s: Daemon filter '%c' exited (%d)",
X printer, format, status.w_retcode);
X case 2:
X return(ERROR);
X--- 719,727 -----
X return(REPRINT);
X default:
X syslog(LOG_WARNING, "%s: Daemon filter '%c' exited (%d)",
X+ #ifdef USG
X+ printer, format, (status >> 8) & 0377);
X+ #else
X printer, format, status.w_retcode);
X #endif /* USG */
X case 2:
X**************
X*** 618,623
X default:
X syslog(LOG_WARNING, "%s: Daemon filter '%c' exited (%d)",
X printer, format, status.w_retcode);
X case 2:
X return(ERROR);
X }
X--- 723,729 -----
X printer, format, (status >> 8) & 0377);
X #else
X printer, format, status.w_retcode);
X+ #endif /* USG */
X case 2:
X return(ERROR);
X }
X**************
X*** 721,726
X char buf[BUFSIZ];
X int sizerr, resp;
X
X if (lstat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X return(ERROR);
X /*
X--- 827,833 -----
X char buf[BUFSIZ];
X int sizerr, resp;
X
X+ #ifdef S_IFLNK
X if (lstat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X #else
X if (stat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X**************
X*** 722,727
X int sizerr, resp;
X
X if (lstat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X return(ERROR);
X /*
X * Check to see if data file is a symbolic link. If so, it should
X--- 829,837 -----
X
X #ifdef S_IFLNK
X if (lstat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X+ #else
X+ if (stat(file, &stb) < 0 || (f = open(file, O_RDONLY)) < 0)
X+ #endif S_IFLNK
X return(ERROR);
X /*
X * Check to see if data file is a symbolic link. If so, it should
X**************
X*** 728,733
X * still point to the same file or someone is trying to print something
X * he shouldn't.
X */
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X--- 838,844 -----
X * still point to the same file or someone is trying to print something
X * he shouldn't.
X */
X+ #ifdef S_IFLNK
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X**************
X*** 731,736
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X (void) sprintf(buf, "%c%d %s\n", type, stb.st_size, file);
X amt = strlen(buf);
X for (i = 0; ; i++) {
X--- 842,848 -----
X if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(f, &stb) == 0 &&
X (stb.st_dev != fdev || stb.st_ino != fino))
X return(ACCESS);
X+ #endif S_IFLNK
X (void) sprintf(buf, "%c%d %s\n", type, stb.st_size, file);
X amt = strlen(buf);
X for (i = 0; ; i++) {
X**************
X*** 811,816
X (void) write(ofd, name2, strlen(name2));
X (void) write(ofd, " Date: ", 8);
X (void) write(ofd, ctime(&tvec), 24);
X (void) write(ofd, "\n", 1);
X } else { /* normal banner */
X (void) write(ofd, "\n\n\n", 3);
X--- 923,931 -----
X (void) write(ofd, name2, strlen(name2));
X (void) write(ofd, " Date: ", 8);
X (void) write(ofd, ctime(&tvec), 24);
X+ #ifdef USG
X+ (void) write(ofd, "\r\n", 2);
X+ #else
X (void) write(ofd, "\n", 1);
X #endif USG
X } else { /* normal banner */
X**************
X*** 812,817
X (void) write(ofd, " Date: ", 8);
X (void) write(ofd, ctime(&tvec), 24);
X (void) write(ofd, "\n", 1);
X } else { /* normal banner */
X (void) write(ofd, "\n\n\n", 3);
X scan_out(ofd, name1, '\0');
X--- 927,933 -----
X (void) write(ofd, "\r\n", 2);
X #else
X (void) write(ofd, "\n", 1);
X+ #endif USG
X } else { /* normal banner */
X #ifdef USG
X (void) write(ofd, "\n\n\n", 3);
X**************
X*** 813,818
X (void) write(ofd, ctime(&tvec), 24);
X (void) write(ofd, "\n", 1);
X } else { /* normal banner */
X (void) write(ofd, "\n\n\n", 3);
X scan_out(ofd, name1, '\0');
X (void) write(ofd, "\n\n", 2);
X--- 929,935 -----
X (void) write(ofd, "\n", 1);
X #endif USG
X } else { /* normal banner */
X+ #ifdef USG
X (void) write(ofd, "\n\n\n", 3);
X scan_out(ofd, name1, '\0');
X (void) write(ofd, "\r\n\n", 3);
X**************
X*** 815,821
X } else { /* normal banner */
X (void) write(ofd, "\n\n\n", 3);
X scan_out(ofd, name1, '\0');
X! (void) write(ofd, "\n\n", 2);
X scan_out(ofd, name2, '\0');
X if (class[0]) {
X (void) write(ofd,"\n\n\n",3);
X--- 932,938 -----
X #ifdef USG
X (void) write(ofd, "\n\n\n", 3);
X scan_out(ofd, name1, '\0');
X! (void) write(ofd, "\r\n\n", 3);
X scan_out(ofd, name2, '\0');
X if (class[0]) {
X (void) write(ofd,"\r\n\n\n", 4);
X**************
X*** 818,823
X (void) write(ofd, "\n\n", 2);
X scan_out(ofd, name2, '\0');
X if (class[0]) {
X (void) write(ofd,"\n\n\n",3);
X scan_out(ofd, class, '\0');
X }
X--- 935,954 -----
X (void) write(ofd, "\r\n\n", 3);
X scan_out(ofd, name2, '\0');
X if (class[0]) {
X+ (void) write(ofd,"\r\n\n\n", 4);
X+ scan_out(ofd, class, '\0');
X+ }
X+ (void) write(ofd, "\r\n\n\n\n\t\t\t\t\tJob: ", 16);
X+ (void) write(ofd, name2, strlen(name2));
X+ (void) write(ofd, "\r\n\t\t\t\t\tDate: ", 13);
X+ (void) write(ofd, ctime(&tvec), 24);
X+ (void) write(ofd, "\r\n", 2);
X+ #else
X+ (void) write(ofd, "\n\n\n", 3);
X+ scan_out(ofd, name1, '\0');
X+ (void) write(ofd, "\n\n", 2);
X+ scan_out(ofd, name2, '\0');
X+ if (class[0]) {
X (void) write(ofd,"\n\n\n",3);
X scan_out(ofd, class, '\0');
X }
X**************
X*** 826,831
X (void) write(ofd, "\n\t\t\t\t\tDate: ", 12);
X (void) write(ofd, ctime(&tvec), 24);
X (void) write(ofd, "\n", 1);
X }
X if (!SF)
X (void) write(ofd, FF, strlen(FF));
X--- 957,963 -----
X (void) write(ofd, "\n\t\t\t\t\tDate: ", 12);
X (void) write(ofd, ctime(&tvec), 24);
X (void) write(ofd, "\n", 1);
X+ #endif USG
X }
X if (!SF)
X (void) write(ofd, FF, strlen(FF));
X**************
X*** 876,881
X while (*--strp == BACKGND && strp >= outbuf)
X ;
X strp++;
X *strp++ = '\n';
X (void) write(scfd, outbuf, strp-outbuf);
X }
X--- 1008,1016 -----
X while (*--strp == BACKGND && strp >= outbuf)
X ;
X strp++;
X+ #ifdef USG
X+ *strp++ = '\r';
X+ #endif USG
X *strp++ = '\n';
X (void) write(scfd, outbuf, strp-outbuf);
X }
X**************
X*** 947,954
X printf("\ncould not be printed without an account on %s\n", host);
X break;
X case FILTERERR:
X! if (stat(tmpfile, &stb) < 0 || stb.st_size == 0 ||
X! (fp = fopen(tmpfile, "r")) == NULL) {
X printf("\nwas printed but had some errors\n");
X break;
X }
X--- 1082,1089 -----
X printf("\ncould not be printed without an account on %s\n", host);
X break;
X case FILTERERR:
X! if (stat(tmpfil, &stb) < 0 || stb.st_size == 0 ||
X! (fp = fopen(tmpfil, "r")) == NULL) {
X printf("\nwas printed but had some errors\n");
X break;
X }
X**************
X*** 1007,1013
X */
X abortpr()
X {
X! (void) unlink(tmpfile);
X kill(0, SIGINT);
X if (ofilter > 0)
X kill(ofilter, SIGCONT);
X--- 1142,1148 -----
X */
X abortpr()
X {
X! (void) unlink(tmpfil);
X kill(0, SIGINT);
X #ifdef SIGCONT
X if (ofilter > 0)
X**************
X*** 1009,1014
X {
X (void) unlink(tmpfile);
X kill(0, SIGINT);
X if (ofilter > 0)
X kill(ofilter, SIGCONT);
X while (wait(0) > 0)
X--- 1144,1150 -----
X {
X (void) unlink(tmpfil);
X kill(0, SIGINT);
X+ #ifdef SIGCONT
X if (ofilter > 0)
X kill(ofilter, SIGCONT);
X #endif SIGCONT
X**************
X*** 1011,1016
X kill(0, SIGINT);
X if (ofilter > 0)
X kill(ofilter, SIGCONT);
X while (wait(0) > 0)
X ;
X exit(0);
X--- 1147,1153 -----
X #ifdef SIGCONT
X if (ofilter > 0)
X kill(ofilter, SIGCONT);
X+ #endif SIGCONT
X while (wait(0) > 0)
X ;
X exit(0);
X**************
X*** 1107,1112
X HL = pgetflag("hl");
X RW = pgetflag("rw");
X BR = pgetnum("br");
X if ((FC = pgetnum("fc")) < 0)
X FC = 0;
X if ((FS = pgetnum("fs")) < 0)
X--- 1244,1266 -----
X HL = pgetflag("hl");
X RW = pgetflag("rw");
X BR = pgetnum("br");
X+ #ifdef USG
X+ /* first look for tty (termio) settings in string form */
X+ if ((TT = pgetstr("tt", &bp)) == (char *)0) {
X+ if ((IC = pgetnum("ic")) < 0)
X+ IC = 0;
X+ if ((IS = pgetnum("is")) < 0)
X+ IS = 0;
X+ if ((OC = pgetnum("oc")) < 0)
X+ OC = 0;
X+ if ((OS = pgetnum("os")) < 0)
X+ OS = 0;
X+ if ((CC = pgetnum("cc")) < 0)
X+ CC = 0;
X+ if ((CS = pgetnum("cs")) < 0)
X+ CS = 0;
X+ }
X+ #else
X if ((FC = pgetnum("fc")) < 0)
X FC = 0;
X if ((FS = pgetnum("fs")) < 0)
X**************
X*** 1115,1120
X XC = 0;
X if ((XS = pgetnum("xs")) < 0)
X XS = 0;
X tof = !pgetflag("fo");
X }
X
X--- 1269,1275 -----
X XC = 0;
X if ((XS = pgetnum("xs")) < 0)
X XS = 0;
X+ #endif
X tof = !pgetflag("fo");
X }
X
X**************
X*** 1227,1233
X */
X setty()
X {
X- struct sgttyb ttybuf;
X register struct bauds *bp;
X
X if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) {
X--- 1382,1387 -----
X */
X setty()
X {
X register struct bauds *bp;
X
X #ifdef USG
X**************
X*** 1230,1235
X struct sgttyb ttybuf;
X register struct bauds *bp;
X
X if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) {
X syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer);
X exit(1);
X--- 1384,1430 -----
X {
X register struct bauds *bp;
X
X+ #ifdef USG
X+ struct termio ttybuf;
X+
X+ /* can't do exclusive lock on device once its opened, can we? */
X+
X+ if (ioctl(pfd, TCGETA, (char *)&ttybuf) < 0) {
X+ syslog(LOG_ERR, "%s: ioctl(TCGETA): %m", printer);
X+ exit(1);
X+ }
X+
X+ if (BR > 0) {
X+ for (bp = bauds; bp->baud; bp++)
X+ if (BR == bp->baud)
X+ break;
X+ if (!bp->baud) {
X+ syslog(LOG_ERR, "%s: illegal baud rate %d", printer, BR);
X+ exit(1);
X+ }
X+ ttybuf.c_cflag = (ttybuf.c_cflag & ~CBAUD) | bp->baud;
X+ }
X+
X+ if (TT) {
X+ termioflags (&ttybuf, TT);
X+ } else {
X+ ttybuf.c_iflag &= ~IC;
X+ ttybuf.c_iflag |= IS;
X+
X+ ttybuf.c_oflag &= ~OC;
X+ ttybuf.c_oflag |= OS;
X+
X+ ttybuf.c_cflag &= ~CC;
X+ ttybuf.c_cflag |= CS;
X+ }
X+
X+ if (ioctl(pfd, TCSETA, (char *)&ttybuf) < 0) {
X+ syslog(LOG_ERR, "%s: ioctl(TCSETA): %m", printer);
X+ exit(1);
X+ }
X+ #else
X+ struct sgttyb ttybuf;
X+
X if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) {
X syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer);
X exit(1);
X**************
X*** 1234,1239
X syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer);
X exit(1);
X }
X if (ioctl(pfd, TIOCGETP, (char *)&ttybuf) < 0) {
X syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer);
X exit(1);
X--- 1429,1435 -----
X syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer);
X exit(1);
X }
X+
X if (ioctl(pfd, TIOCGETP, (char *)&ttybuf) < 0) {
X syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer);
X exit(1);
X**************
X*** 1238,1243
X syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer);
X exit(1);
X }
X if (BR > 0) {
X for (bp = bauds; bp->baud; bp++)
X if (BR == bp->baud)
X--- 1434,1440 -----
X syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer);
X exit(1);
X }
X+
X if (BR > 0) {
X for (bp = bauds; bp->baud; bp++)
X if (BR == bp->baud)
X**************
X*** 1274,1279
X exit(1);
X }
X }
X }
X
X /*VARARGS1*/
X--- 1471,1477 -----
X exit(1);
X }
X }
X+ #endif
X }
X
X /*VARARGS1*/
X*** recvjob.c
X--- ../goodlpr/recvjob.c
X**************
X*** 25,31
X */
X
X #include "lp.h"
X! #include <sys/fs.h>
X
X char *sp = "";
X #define ack() (void) write(1, sp, 1);
X--- 25,35 -----
X */
X
X #include "lp.h"
X! #ifdef USG
X! # include <sys/statfs.h>
X! #else
X! # include <sys/fs.h>
X! #endif
X
X #ifdef USG
X #define major(x) (x >> 8 & 255)
X**************
X*** 27,32
X #include "lp.h"
X #include <sys/fs.h>
X
X char *sp = "";
X #define ack() (void) write(1, sp, 1);
X
X--- 31,41 -----
X # include <sys/fs.h>
X #endif
X
X+ #ifdef USG
X+ #define major(x) (x >> 8 & 255)
X+ #define minor(x) (x & 255)
X+ #endif
X+
X char *sp = "";
X #define ack() (void) write(1, sp, 1);
X
X**************
X*** 259,264
X chksize(size)
X int size;
X {
X struct stat stb;
X register char *ddev;
X int spacefree;
X--- 268,281 -----
X chksize(size)
X int size;
X {
X+ #ifdef USG
X+ struct statfs st;
X+
X+ if (dfd < 0 || fstatfs (dfd, &st, sizeof (st), 0) < 0)
X+ return 1;
X+ if (st.f_bsize * st.f_bfree < size)
X+ return 0;
X+ #else
X struct stat stb;
X register char *ddev;
X int spacefree;
X**************
X*** 272,277
X size = (size + 1023) / 1024;
X if (minfree + size > spacefree)
X return(0);
X return(1);
X }
X
X--- 289,295 -----
X size = (size + 1023) / 1024;
X if (minfree + size > spacefree)
X return(0);
X+ #endif
X return(1);
X }
X
X*** rmjob.c
X--- ../goodlpr/rmjob.c
X*** startdaemon.c
X--- ../goodlpr/startdaemon.c
X**************
X*** 26,33
X #include <stdio.h>
X #include <sys/types.h>
X #include <sys/socket.h>
X- #include <sys/un.h>
X- #include "lp.local.h"
X
X startdaemon(printer)
X char *printer;
X--- 26,31 -----
X #include <stdio.h>
X #include <sys/types.h>
X #include <sys/socket.h>
X
X #ifdef USG
X # include <fcntl.h>
X**************
X*** 29,34
X #include <sys/un.h>
X #include "lp.local.h"
X
X startdaemon(printer)
X char *printer;
X {
X--- 27,40 -----
X #include <sys/types.h>
X #include <sys/socket.h>
X
X+ #ifdef USG
X+ # include <fcntl.h>
X+ #else
X+ # include <sys/un.h>
X+ #endif USG
X+
X+ #include "lp.local.h"
X+
X startdaemon(printer)
X char *printer;
X {
X**************
X*** 32,37
X startdaemon(printer)
X char *printer;
X {
X struct sockaddr_un sun;
X register int s, n;
X char buf[BUFSIZ];
X--- 38,44 -----
X startdaemon(printer)
X char *printer;
X {
X+ #ifndef USG
X struct sockaddr_un sun;
X #endif USG
X register int s, n;
X**************
X*** 33,38
X char *printer;
X {
X struct sockaddr_un sun;
X register int s, n;
X char buf[BUFSIZ];
X
X--- 40,46 -----
X {
X #ifndef USG
X struct sockaddr_un sun;
X+ #endif USG
X register int s, n;
X char buf[BUFSIZ];
X
X**************
X*** 36,42
X register int s, n;
X char buf[BUFSIZ];
X
X! s = socket(AF_UNIX, SOCK_STREAM, 0);
X if (s < 0) {
X perr("socket");
X return(0);
X--- 44,52 -----
X register int s, n;
X char buf[BUFSIZ];
X
X! #ifdef USG
X! gethostname (buf, sizeof buf);
X! s = getport (buf);
X if (s < 0) {
X perr("socket");
X return(0);
X**************
X*** 41,46
X perr("socket");
X return(0);
X }
X sun.sun_family = AF_UNIX;
X strcpy(sun.sun_path, SOCKETNAME);
X if (connect(s, &sun, strlen(sun.sun_path) + 2) < 0) {
X--- 51,62 -----
X perr("socket");
X return(0);
X }
X+ #else
X+ s = socket(AF_UNIX, SOCK_STREAM, 0);
X+ if (s < 0) {
X+ perr("socket");
X+ return(0);
X+ }
X sun.sun_family = AF_UNIX;
X strcpy(sun.sun_path, SOCKETNAME);
X if (connect(s, &sun, strlen(sun.sun_path) + 2) < 0) {
X**************
X*** 48,53
X (void) close(s);
X return(0);
X }
X (void) sprintf(buf, "\1%s\n", printer);
X n = strlen(buf);
X if (write(s, buf, n) != n) {
X--- 64,70 -----
X (void) close(s);
X return(0);
X }
X+ #endif USG
X (void) sprintf(buf, "\1%s\n", printer);
X n = strlen(buf);
X if (write(s, buf, n) != n) {
SHAR_EOF
chmod 0644 lpr.diff.2 || echo "restore of lpr.diff.2 fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0
--
Conor P. Cahill (703)430-9247 Virtual Technologies, Inc.,
uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160
Sterling, VA 22170
More information about the Comp.unix.sysv386
mailing list