--- Makefile +++ Makefile 1994/04/15 20:12:28 @@ -0,0 +1,18 @@ +.EXPORT_ALL_VARIABLES: + +CFLAGS = -include /usr/include/bsd/bsd.h -I/usr/include/bsd \ + -O2 -m486 -fomit-frame-pointer -I../common_source +LDFLAGS = -N -s +LDLIBS = -lbsd -lcommon -L ../common_source + + +SUBDIRS = common_source filters lpc lpd lpq lpr lprm lptest pac + +all: + for i in $(SUBDIRS); do make -C $$i all; done + +install: + for i in $(SUBDIRS); do make -C $$i install; done + +clean: + for i in $(SUBDIRS); do make -C $$i clean; done --- common_source/Makefile +++ common_source/Makefile 1994/04/15 20:12:28 @@ -0,0 +1,11 @@ +OBJS = common.o displayq.o printcap.o rmjob.o startdaemon.o + +all: $(OBJS) + @ar rcv libcommon.a $(OBJS) + @ranlib libcommon.a + +install: all + +clean: + rm -f *.o *.a + --- common_source/common.c +++ common_source/common.c 1994/04/15 20:12:28 @@ -65,8 +65,8 @@ 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 _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 HL; /* print header last */ @@ -79,7 +79,7 @@ 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 */ +int _XS; /* flags to set for local mode */ short RS; /* restricted to those with local accounts */ char line[BUFSIZ]; @@ -182,7 +182,7 @@ getq(namelist) struct queue *(*namelist[]); { - register struct dirent *d; + register struct direct *d; register struct queue *q, **queue; register int nitems; struct stat stbuf; --- common_source/lp.h +++ common_source/lp.h 1994/04/15 20:12:28 @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -79,8 +79,8 @@ 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 _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 HL; /* print header last */ @@ -93,7 +93,7 @@ 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 int _XS; /* flags to set for local mode */ extern short RS; /* restricted to those with local accounts */ extern char line[BUFSIZ]; --- common_source/lp.local.h +++ common_source/lp.local.h 1994/04/15 20:12:28 @@ -47,10 +47,11 @@ #include #ifndef A_MAGIC1 /* must be a VM/UNIX system */ -#ifndef SARMAG +# define A_MAGIC1 OMAGIC +# define A_MAGIC2 NMAGIC +# define A_MAGIC3 ZMAGIC # undef ARMAG # define ARMAG 0177545 -#endif #endif /* --- common_source/pathnames.h +++ common_source/pathnames.h 1994/04/15 20:12:28 @@ -37,13 +37,13 @@ #include #define _PATH_DEFDEVLP "/dev/lp" -#define _PATH_DEFSPOOL "/var/spool/output/lpd" +#define _PATH_DEFSPOOL "/var/spool/lpd" #define _PATH_HOSTSEQUIV "/etc/hosts.equiv" #define _PATH_HOSTSLPD "/etc/hosts.lpd" -#define _PATH_MASTERLOCK "/var/spool/output/lpd.lock" +#define _PATH_MASTERLOCK "/var/spool/lpd/lpd.lock" #define _PATH_PR "/usr/bin/pr" #define _PATH_PRINTCAP "/etc/printcap" -#define _PATH_SOCKETNAME "/var/run/printer" +#define _PATH_SOCKETNAME "/dev/printer" #define _PATH_VFONT "/usr/libdata/vfont/" #define _PATH_VFONTB "/usr/libdata/vfont/B" #define _PATH_VFONTI "/usr/libdata/vfont/I" --- common_source/rmjob.c +++ common_source/rmjob.c 1994/04/15 20:12:28 @@ -63,7 +63,7 @@ { register int i, nitems; int assasinated = 0; - struct dirent **files; + struct direct **files; char *cp; if ((i = pgetent(line, printer)) < 0) --- filters/Makefile +++ filters/Makefile 1994/04/15 20:12:28 @@ -0,0 +1,10 @@ +all: lpf + +lpf: lpf.o + +install: lpf + install lpf /usr/sbin + +clean: + rm -f lpf *.o + --- lpc/Makefile +++ lpc/Makefile 1994/04/15 20:12:28 @@ -0,0 +1,11 @@ +all: lpc + +lpc: lpc.o cmds.o cmdtab.o + +install: lpc + install -g lp -m2555 lpc /usr/sbin/lpc + install -m644 lpc.8 /usr/man/man8 + +clean: + rm -f lpc *.o + --- lpc/cmds.c +++ lpc/cmds.c 1994/04/15 20:12:28 @@ -47,7 +47,7 @@ /* * kill an existing daemon and disable printing. */ -abort(argc, argv) +xabort(argc, argv) char *argv[]; { register int c, status; @@ -208,8 +208,8 @@ } } -select(d) -struct dirent *d; +xselect(d) +struct direct *d; { int c = d->d_name[0]; @@ -223,7 +223,7 @@ * by `cf', `tf', or `df', then by the sequence letter A-Z, a-z. */ sortq(d1, d2) -struct dirent **d1, **d2; +struct direct **d1, **d2; { int c1, c2; @@ -247,7 +247,7 @@ { register int i, n; register char *cp, *cp1, *lp; - struct dirent **queue; + struct direct **queue; int nitems; bp = pbuf; @@ -259,7 +259,7 @@ ; lp[-1] = '/'; - nitems = scandir(SD, &queue, select, sortq); + nitems = scandir(SD, &queue, xselect, sortq); if (nitems < 0) { printf("\tcannot examine spool directory\n"); return; @@ -696,7 +696,7 @@ { struct stat stbuf; register int fd, i; - register struct dirent *dp; + register struct direct *dp; DIR *dirp; bp = pbuf; --- lpc/cmdtab.c +++ lpc/cmdtab.c 1994/04/15 20:12:29 @@ -42,7 +42,7 @@ #include "lpc.h" -int abort(), clean(), enable(), disable(), down(), help(); +int xabort(), clean(), enable(), disable(), down(), help(); int quit(), restart(), start(), status(), stop(), topq(), up(); char aborthelp[] = "terminate a spooling daemon immediately and disable printing"; @@ -60,7 +60,7 @@ char uphelp[] = "enable everything and restart spooling daemon"; struct cmd cmdtab[] = { - { "abort", aborthelp, abort, 1 }, + { "abort", aborthelp, xabort, 1 }, { "clean", cleanhelp, clean, 1 }, { "enable", enablehelp, enable, 1 }, { "exit", quithelp, quit, 0 }, --- lpd/Makefile +++ lpd/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,11 @@ +all: lpd + +lpd: lpd.o lpdchar.o printjob.o recvjob.o + +install: lpd + install -m744 lpd /usr/sbin/lpd + install -m644 lpd.8 /usr/man/man8 + +clean: + rm -f lpd *.o + --- lpd/lpd.c +++ lpd/lpd.c 1994/04/15 20:13:19 @@ -134,7 +134,7 @@ syslog(LOG_ERR, "%s: %m", _PATH_MASTERLOCK); exit(1); } - signal(SIGCHLD, reapchild); + signal(SIGCHLD, SIG_IGN); /* * Restart all the printers. */ @@ -178,6 +178,7 @@ } bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; + sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = sp->s_port; if (bind(finet, (struct sockaddr *)&sin, sizeof(sin)) < 0) { syslog(LOG_ERR, "bind: %m"); --- lpd/printjob.c +++ lpd/printjob.c 1994/04/15 20:12:29 @@ -223,7 +223,7 @@ if (nitems == 0) { /* no more work to do */ done: if (count > 0) { /* Files actually printed */ - if (!SF && !tof) + if (!_SF && !tof) (void) write(ofd, FF, strlen(FF)); if (TR != NULL) /* output trailer */ (void) write(ofd, TR, strlen(TR)); @@ -266,7 +266,7 @@ */ for (i = 0; i < 4; i++) strcpy(fonts[i], ifonts[i]); - strcpy(width+2, "0"); + sprintf(&width[2], "%d", PW); strcpy(indent+2, "0"); /* @@ -461,7 +461,7 @@ if ((stb.st_mode & S_IFMT) == S_IFLNK && fstat(fi, &stb) == 0 && (stb.st_dev != fdev || stb.st_ino != fino)) return(ACCESS); - if (!SF && !tof) { /* start on a fresh page */ + if (!_SF && !tof) { /* start on a fresh page */ (void) write(ofd, FF, strlen(FF)); tof = 1; } @@ -589,7 +589,7 @@ while ((pid = wait3((int *)&status, WUNTRACED, 0)) > 0 && pid != ofilter) ; - if (status.w_stopval != WSTOPPED) { + if (!WIFSTOPPED(status)) { (void) close(fi); syslog(LOG_WARNING, "%s: output filter died (%d)", printer, status.w_retcode); @@ -830,7 +830,7 @@ extern char *ctime(); time(&tvec); - if (!SF && !tof) + if (!_SF && !tof) (void) write(ofd, FF, strlen(FF)); if (SB) { /* short banner only */ if (class[0]) { @@ -858,7 +858,7 @@ (void) write(ofd, ctime(&tvec), 24); (void) write(ofd, "\n", 1); } - if (!SF) + if (!_SF) (void) write(ofd, FF, strlen(FF)); tof = 1; } @@ -1104,7 +1104,7 @@ CF = pgetstr("cf", &bp); TR = pgetstr("tr", &bp); RS = pgetflag("rs"); - SF = pgetflag("sf"); + _SF = pgetflag("sf"); SH = pgetflag("sh"); SB = pgetflag("sb"); HL = pgetflag("hl"); @@ -1116,8 +1116,8 @@ FS = 0; if ((XC = pgetnum("xc")) < 0) XC = 0; - if ((XS = pgetnum("xs")) < 0) - XS = 0; + if ((_XS = pgetnum("xs")) < 0) + _XS = 0; tof = !pgetflag("fo"); } @@ -1230,15 +1230,11 @@ */ setty() { - struct sgttyb ttybuf; + struct termios ttybuf; register struct bauds *bp; - if (ioctl(pfd, TIOCEXCL, (char *)0) < 0) { - syslog(LOG_ERR, "%s: ioctl(TIOCEXCL): %m", printer); - exit(1); - } - if (ioctl(pfd, TIOCGETP, (char *)&ttybuf) < 0) { - syslog(LOG_ERR, "%s: ioctl(TIOCGETP): %m", printer); + if (ioctl(pfd, TCGETS, (char *)&ttybuf) < 0) { + syslog(LOG_ERR, "%s: ioctl(TCGETS): %m", printer); exit(1); } if (BR > 0) { @@ -1249,25 +1245,13 @@ syslog(LOG_ERR, "%s: illegal baud rate %d", printer, BR); exit(1); } - ttybuf.sg_ispeed = ttybuf.sg_ospeed = bp->speed; + ttybuf.c_cflag = (ttybuf.c_cflag &= ~CBAUD) | bp->speed; } - ttybuf.sg_flags &= ~FC; - ttybuf.sg_flags |= FS; - if (ioctl(pfd, TIOCSETP, (char *)&ttybuf) < 0) { - syslog(LOG_ERR, "%s: ioctl(TIOCSETP): %m", printer); + ttybuf.c_cflag &= ~FC; /* not quite right! */ + ttybuf.c_cflag |= FS; /* not quite right! */ + if (ioctl(pfd, TCSETS, (char *)&ttybuf) < 0) { + syslog(LOG_ERR, "%s: ioctl(TCSETS): %m", printer); exit(1); - } - if (XC) { - if (ioctl(pfd, TIOCLBIC, &XC) < 0) { - syslog(LOG_ERR, "%s: ioctl(TIOCLBIC): %m", printer); - exit(1); - } - } - if (XS) { - if (ioctl(pfd, TIOCLBIS, &XS) < 0) { - syslog(LOG_ERR, "%s: ioctl(TIOCLBIS): %m", printer); - exit(1); - } } } --- lpd/recvjob.c +++ lpd/recvjob.c 1994/04/15 20:12:29 @@ -245,6 +245,9 @@ chksize(size) int size; { +#ifdef __linux__ + return(1); +#else int spacefree; struct statfs sfb; @@ -257,6 +260,7 @@ if (minfree + size > spacefree) return(0); return(1); +#endif } read_number(fn) --- lpq/Makefile +++ lpq/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,10 @@ +all: lpq + +lpq: lpq.o + +install: lpq + install -m6555 lpq /usr/bin + +clean: + rm -f lpq *.o + --- lpr/Makefile +++ lpr/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,11 @@ +all: lpr + +lpr: lpr.o + +install: lpr + install -m6555 lpr /usr/bin + install -m644 lpr.1 /usr/man/man1 + +clean: + rm -f lpr *.o + --- lpr/lpr.c +++ lpr/lpr.c 1994/04/15 20:12:29 @@ -57,6 +57,7 @@ #include #include #include +#include #include "lp.local.h" #include "pathnames.h" @@ -94,7 +95,7 @@ char *SD; /* spool directory */ char *LO; /* lock file name */ char *RG; /* restrict group */ -short SC; /* suppress multiple copies */ +short _SC; /* suppress multiple copies */ char *getenv(); char *rindex(); @@ -245,7 +246,7 @@ if (printer == NULL && (printer = getenv("PRINTER")) == NULL) printer = DEFLP; chkprinter(printer); - if (SC && ncopies > 1) + if (_SC && ncopies > 1) fatal("multiple copies are not allowed"); if (MC > 0 && ncopies > MC) fatal("only %d copies are allowed", MC); @@ -568,6 +569,7 @@ printf("%s: cannot open %s\n", name, file); return(-1); } +#ifndef __linux__ if (read(fd, &execb, sizeof(execb)) == sizeof(execb)) { if(!N_BADMAG(execb) || #ifdef SARMAG @@ -596,6 +598,7 @@ } #endif } +#endif (void) close(fd); if (rflag) { if ((cp = rindex(file, '/')) == NULL) { @@ -662,7 +665,7 @@ MC = DEFMAXCOPIES; if ((DU = pgetnum("du")) < 0) DU = DEFUID; - SC = pgetflag("sc"); + _SC = pgetflag("sc"); } /* --- lprm/Makefile +++ lprm/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,11 @@ +all: lprm + +lprm: lprm.o + +install: lprm + install -m6555 lprm /usr/bin + install -m644 lprm.1 /usr/man/man1 + +clean: + rm -f lprm *.o + --- lptest/Makefile +++ lptest/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,11 @@ +all: lptest + +lptest: lptest.o + +install: lptest + install -m755 lptest /usr/bin + install -m644 lptest.1 /usr/man/man1 + +clean: + rm -f lptest *.o + --- pac/Makefile +++ pac/Makefile 1994/04/15 20:12:29 @@ -0,0 +1,11 @@ +all: pac + +pac: pac.o + +install: pac + install -m500 pac /usr/sbin + install -m644 pac.8 /usr/man/man8 + +clean: + rm -f lptest *.o +