Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.sysv386 Subject: LPR for 386 UNIX (part 1/2) Message-ID: <1991Mar24.012918.23603@virtech.uucp> Date: 24 Mar 91 01:29:18 GMT References: <1991Mar21.215151.594@stat.appstate.edu> Organization: Virtual Technologies Inc. Lines: 2088 moorejm@stat.appstate.edu writes: > I have an enviroment of 3 Sun 4/110's 4 VAX/VMS boxes and 1 AT&T >6386wgs running AT&T SYS V 3.2. The SYS V box uses AT&T enhanced TCP/IP >WIN/386. This tcp implementation lacks lpr/lpd. 8-( Has any one ported >lpr/lpd to this enviroment??? *PLEASE say yes* The other machines Yes. A port was done and has been posted here several times. I guess it's time to post it again, so here it is. To use this you need to get the 4.3BSD lpr sources and then apply these patches. NOTE 1: The work was done by Jonathan Broome and Dave Rand. I have not used this stuff, but have heard good comments from others that had. NOTE 2: This is in two parts which will be in separate responses. Good luck. ---- Cut Here and unpack ---- #!/bin/sh # shar: Shell Archiver (v1.22) # Packed Mon May 21 12:53:35 PDT 1990 by dlr # from directory /u/dlr/src/lpr # # This is part 1 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # # Run the following text with /bin/sh to create: # readme # flock.c # ftruncate.c # scandir.c # termio.c # lpr.diff.1 # lpr.diff.2 # if test -r s2_seq_.tmp then echo "Must unpack archives in sequence!" next=`cat s2_seq_.tmp`; echo "Please unpack part $next next" exit 1; fi sed 's/^X//' << 'SHAR_EOF' > readme && XMon May 21 12:49:15 PDT 1990 X XWhile 386/ix (tm Interactive) has a number of network services from BSD, Xlpr is not one of them. This does not cause a real problem, as the Xshell scripts of lp can be used to perform remote printing. It is Xnot a very good solution when interacting with other Sun or BSD Xsystems. X XJonathan C. Broome did the original port to 386/ix from the Xfreed lpr sources. I added a few modifications, and re-did the context Xdiffs from the tar file on uunet (~ftp/bsd-sources/src/network/lpr.tar.Z) X XNo guarantee that this will work for you, but it works for me. X XTo use: X XUnpack the shell archive, then apply the two patch files lpr.diff.1 Xand lpr.diff.2 with patch. The unaltered source files from the lpr Xtar file must be used. The C files included must be in the lpr Xdirectory. X X XDave Rand X{pyramid|mips|sun|vsi1}!daver!dlr Internet: dlr@daver.bungi.com SHAR_EOF chmod 0664 readme || echo "restore of readme fails" sed 's/^X//' << 'SHAR_EOF' > flock.c && X#include X#include X#include X#include X#include X#include "lp.local.h" X X Xflock (fd, how) Xint fd, X how; X{ X int cmd, X ret; X struct flock lck; X X#ifdef DEBUG X printf ("in flock, fd=%d, how=0x%x\n", fd, how); X#endif /* DEBUG */ X X if (how & LOCK_NB) /* want non-blocking */ X cmd = F_SETLK; /* always returns immediately */ X else X cmd = F_SETLKW; /* waits until lock can be done */ X X if (how & LOCK_SH) /* shared usually means reading */ X lck.l_type = F_RDLCK; X else if (how & LOCK_EX) /* exclusive -- writing */ X lck.l_type = F_WRLCK; X else if (how & LOCK_UN) /* unlock */ X lck.l_type = F_UNLCK; X X lck.l_whence = SEEK_SET; /* from start of file */ X lck.l_start = 0L; /* from start of extent */ X lck.l_len = 0L; /* to end of file */ X X X /* X * Do the deed. X */ X ret = fcntl (fd, cmd, &lck); X X /* X * if a non-blocking lock was specified and it failed, set errno X * to EWOULDBLOCK as BSD does it. X */ X if (ret == -1 && cmd == F_SETLK && (errno == EACCES || errno == EAGAIN)) X errno = EWOULDBLOCK; X X#ifdef DEBUG X printf ("returning %d.\n", ret); X#endif /* DEBUG */ X return ret; X} SHAR_EOF chmod 0644 flock.c || echo "restore of flock.c fails" sed 's/^X//' << 'SHAR_EOF' > ftruncate.c && X#ifdef COMMENT X XPath: ism780c!ico!isis!udenva!pikes!boulder!ncar!ames!apple!amdahl!kucharsk XFrom: kucharsk@uts.amdahl.com (William Kucharski) XNewsgroups: comp.unix.wizards,comp.sources.wanted XSubject: Re: ftruncate(2) for System V.3.2 needed XMessage-ID: <02KJ02SJ3cms01@amdahl.uts.amdahl.com> XDate: 7 Jul 89 22:10:57 GMT XReferences: <1132@ssp15.idca.tds.philips.nl> XReply-To: kucharsk@amdahl.uts.amdahl.com (William Kucharski) XOrganization: Amdahl Coup, UTS Products Hen House XLines: 71 XXref: ism780c comp.unix.wizards:18265 comp.sources.wanted:9111 X XIn article <1132@ssp15.idca.tds.philips.nl> jos@idca.tds.PHILIPS.nl (Jos Vos) writes: X >I need the ftruncate(2) function from BSD4.3 UNIX on System V.3.2. X >For non-BSD-manual-owners, here's the description of ftruncate(2)... X XI can see that this one is going to make it into the "frequently asked Xquestion" section... X X-- X William Kucharski X XARPA: kucharsk@uts.amdahl.com XUUCP: ...!{ames,decwrl,sun,uunet}!amdahl!kucharsk X X#endif /* COMMENT */ X X#include X#include X#include X#include X#include X Xint Xftruncate(fd, length) Xint fd; /* file descriptor */ Xoff_t length; /* length to set file to */ X{ X extern long lseek(); X X struct flock fl; X struct stat filebuf; X X if (fstat(fd, &filebuf) < 0) X return(-1); X X if (filebuf.st_size < length) { X /* extend file length */ X X if ((lseek(fd, (length - 1), SEEK_SET)) < 0) X return(-1); X X /* write a "0" byte */ X X if ((write(fd, "", 1)) != 1) X return(-1); X } else { X /* truncate length */ X X fl.l_whence = 0; X fl.l_len = 0; X fl.l_start = length; X fl.l_type = F_WRLCK; /* write lock on file space */ X X /* X * This relies on the UNDOCUMENTED F_FREESP argument to X * fcntl(2), which truncates the file so that it ends at the X * position indicated by fl.l_start. X * X * Will minor miracles never cease? X */ X X if (fcntl(fd, F_FREESP, &fl) < 0) X return(-1); X X } X X return(0); X} X SHAR_EOF chmod 0644 ftruncate.c || echo "restore of ftruncate.c fails" sed 's/^X//' << 'SHAR_EOF' > scandir.c && X/* X * Copyright (c) 1983 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#if defined(LIBC_SCCS) && !defined(lint) Xstatic char sccsid[] = "@(#)scandir.c 5.2 (Berkeley) 3/9/86"; X#endif /* LIBC_SCCS and not lint */ X X/* X * Scan the directory dirname calling select to make a list of selected X * directory entries then sort using qsort and compare routine dcomp. X * Returns the number of entries and a pointer to a list of pointers to X * struct direct (through namelist). Returns -1 if there were any errors. X */ X X#include X#include X#include X#ifdef i386 X# include X# include X#else X# include X#endif X Xscandir(dirname, namelist, select, dcomp) X char *dirname; X#ifdef i386 X struct dirent *(*namelist[]); X#else X struct direct *(*namelist[]); X#endif X int (*select)(), (*dcomp)(); X{ X#ifdef i386 X register struct dirent *d, *p, **names; X#else X register struct direct *d, *p, **names; X#endif X register int nitems; X register char *cp1, *cp2; X struct stat stb; X long arraysz; X DIR *dirp; X X if ((dirp = opendir(dirname)) == NULL) X return(-1); X if (fstat(dirp->dd_fd, &stb) < 0) X return(-1); X X /* X * estimate the array size by taking the size of the directory file X * and dividing it by a multiple of the minimum size entry. X */ X#ifdef i386 X arraysz = (stb.st_size / sizeof (struct direct)); X arraysz = (stb.st_size / 1); /*XXX!*/ X names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); X#else X arraysz = (stb.st_size / 24); X names = (struct direct **)malloc(arraysz * sizeof(struct direct *)); X#endif X if (names == NULL) X return(-1); X X nitems = 0; X while ((d = readdir(dirp)) != NULL) { X if (select != NULL && !(*select)(d)) X continue; /* just selected names */ X /* X * Make a minimum size copy of the data X */ X#ifdef i386 X p = (struct dirent *)malloc(64); /*XXX! 64 had better work! */ X#else X p = (struct direct *)malloc(DIRSIZ(d)); X#endif X if (p == NULL) X return(-1); X p->d_ino = d->d_ino; X p->d_reclen = d->d_reclen; X#ifndef i386 X p->d_namlen = d->d_namlen; X#endif X for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; ); X /* X * Check to make sure the array has space left and X * realloc the maximum size. X */ X if (++nitems >= arraysz) { X if (fstat(dirp->dd_fd, &stb) < 0) X return(-1); /* just might have grown */ X arraysz = stb.st_size / 12; X#ifdef i386 X names = (struct dirent **)realloc((char *)names, X#else X names = (struct direct **)realloc((char *)names, X#endif X arraysz * sizeof(struct direct *)); X if (names == NULL) X return(-1); X } X names[nitems-1] = p; X } X closedir(dirp); X if (nitems && dcomp != NULL) X#ifdef i386 X qsort(names, nitems, sizeof(struct dirent *), dcomp); X#else X qsort(names, nitems, sizeof(struct direct *), dcomp); X#endif X *namelist = names; X return(nitems); X} X X/* X * Alphabetic order comparison routine for those who want it. X */ Xalphasort(d1, d2) X#ifdef i386 X struct dirent **d1, **d2; X#else X struct direct **d1, **d2; X#endif X{ X return(strcmp((*d1)->d_name, (*d2)->d_name)); X} SHAR_EOF chmod 0644 scandir.c || echo "restore of scandir.c fails" sed 's/^X//' << 'SHAR_EOF' > termio.c && X#ifdef USG X X#include X#include X#include X X Xstruct var { X char *name; X unsigned short value, X mask; X}; X Xstatic struct var input[] = { X "IGNBRK", IGNBRK, 0, X "BRKINT", BRKINT, 0, X "IGNPAR", IGNPAR, 0, X "PARMRK", PARMRK, 0, X "INPCK", INPCK, 0, X "ISTRIP", ISTRIP, 0, X "INLCR", INLCR, 0, X "IGNCR", IGNCR, 0, X "ICRNL", ICRNL, 0, X "IUCLC", IUCLC, 0, X "IXON", IXON, 0, X "IXANY", IXANY, 0, X "IXOFF", IXOFF, 0, X "DOSMODE", DOSMODE, 0, X (char *)0, 0, 0 X}; X Xstatic struct var output[] = { X/* output modes */ X "OPOST", OPOST, 0, X "OLCUC", OLCUC, 0, X "ONLCR", ONLCR, 0, X "OCRNL", OCRNL, 0, X "ONOCR", ONOCR, 0, X "ONLRET", ONLRET, 0, X "OFILL", OFILL, 0, X "OFDEL", OFDEL, 0, X "NLDLY", 0, NLDLY, X "NL0", NL0, NLDLY, X "NL1", NL1, NLDLY, X "CRDLY", 0, CRDLY, X "CR0", CR0, CRDLY, X "CR1", CR1, CRDLY, X "CR2", CR2, CRDLY, X "CR3", CR3, CRDLY, X "TABDLY", 0, TABDLY, X "TAB0", TAB0, TABDLY, X "TAB1", TAB1, TABDLY, X "TAB2", TAB2, TABDLY, X "TAB3", TAB3, TABDLY, X "BSDLY", 0, BSDLY, X "BS0", BS0, BSDLY, X "BS1", BS1, BSDLY, X "VTDLY", 0, VTDLY, X "VT0", VT0, VTDLY, X "VT1", VT1, VTDLY, X "FFDLY", 0, FFDLY, X "FF0", FF0, FFDLY, X "FF1", FF1, FFDLY, X (char *)0, 0, 0 X}; X Xstatic struct var control[] = { X/* control modes */ X "CBAUD", CBAUD, 0, X "B0", B0, CBAUD, X "B50", B50, CBAUD, X "B75", B75, CBAUD, X "B110", B110, CBAUD, X "B134", B134, CBAUD, X "B150", B150, CBAUD, X "B200", B200, CBAUD, X "B300", B300, CBAUD, X "B600", B600, CBAUD, X "B1200", B1200, CBAUD, X "B1800", B1800, CBAUD, X "B2400", B2400, CBAUD, X "B4800", B4800, CBAUD, X "B9600", B9600, CBAUD, X "B19200", B19200, CBAUD, X "EXTA", EXTA, CBAUD, X "B38400", B38400, CBAUD, X "EXTB", EXTB, CBAUD, X "CSIZE", 0, CSIZE, X "CS5", CS5, CSIZE, X "CS6", CS6, CSIZE, X "CS7", CS7, CSIZE, X "CS8", CS8, CSIZE, X "CSTOPB", CSTOPB, 0, X "CREAD", CREAD, 0, X "PARENB", PARENB, 0, X "PARODD", PARODD, 0, X "HUPCL", HUPCL, 0, X "CLOCAL", CLOCAL, 0, X "RCV1EN", RCV1EN, 0, X "XMT1EN", XMT1EN, 0, X "LOBLK", LOBLK, 0, X "XCLUDE", XCLUDE, 0, X (char *)0, 0, 0 X}; X Xstatic struct var ldisc[] = { X/* line discipline 0 modes */ X "ISIG", ISIG, 0, X "ICANON", ICANON, 0, X "XCASE", XCASE, 0, X "ECHO", ECHO, 0, X "ECHOE", ECHOE, 0, X "ECHOK", ECHOK, 0, X "ECHONL", ECHONL, 0, X "NOFLSH", NOFLSH, 0, X (char *)0, 0, 0 X}; X X Xtermioflags (t, s) Xstruct termio *t; Xchar *s; X{ X struct var *var; X char *name, X c; X int what, /* 1 = add, -1 = subtract */ X found; X X /* first see if leading character is NOT '+' or '-' */ X while (*s && isspace (*s)) X s++; X if (*s && *s != '+' && *s != '-') { /* zero out flags */ X t->c_iflag = 0; X t->c_oflag = 0; X t->c_cflag &= CBAUD; /* clear all but baud rate */ X t->c_lflag = 0; X } X X while (*s) { X /* skip space */ X while (isspace (*s)) X s++; X if (! *s) X break; X X /* look for "+" or "-" */ X if (*s == '+') X what = 1, s++; X else if (*s == '-') X what = -1, s++; X else X what = 1; /* default = add */ X X /* skip space again */ X while (isspace (*s)) X s++; X if (! *s) X break; X X /* save name */ X name = s; X /* find end of name */ X while (*s && isalnum (*s)) X s++; X c = *s; /* save trailing character */ X *s = '\0'; /* zap it */ X X found = 0; X X /* find var in values */ X for (var = input; var->name; var++) X if (strcmp (var->name, name) == 0) { X if (what == 1) { X t->c_iflag &= ~var->mask; X t->c_iflag |= var->value; X } else X t->c_iflag &= ~var->value; X found++; X break; X } X for (var = output; var->name; var++) X if (strcmp (var->name, name) == 0) { X if (what == 1) { X t->c_oflag &= ~var->mask; X t->c_oflag |= var->value; X } else X t->c_oflag &= ~var->value; X found++; X break; X } X X for (var = control; var->name; var++) X if (strcmp (var->name, name) == 0) { X if (what == 1) { X t->c_cflag &= ~var->mask; X t->c_cflag |= var->value; X } else X t->c_cflag &= ~var->value; X found++; X break; X } X X for (var = ldisc; var->name; var++) X if (strcmp (var->name, name) == 0) { X if (what == 1) { X t->c_lflag &= ~var->mask; X t->c_lflag |= var->value; X } else X t->c_lflag &= ~var->value; X found++; X break; X } X X /* Should complain if token wasn't found. */ X if (! found) X syslog (LOG_ERR, "unknown termio flag: %s", name); X X *s = c; /* put character back */ X } X X /* force CREAD on always, as the port won't work without it */ X t->c_cflag |= CREAD; X} X X#endif USG X X X#ifdef MAIN X#include X Xmain (argc, argv) Xint argc; Xchar **argv; X{ X struct termio t; X int fd; X int c; X char buf[16]; X int cnt; X X if ((fd = open ("/dev/tty03", 2)) < 0) { X perror ("open /dev/tty03"); X exit (1); X } X X if (ioctl (fd, TCGETA, &t) < 0) { X perror ("TCGETA"); X exit (2); X } X#ifdef DEBUG X puts ("Was:"); X printf ("iflag = 0%o\n", t.c_iflag); X printf ("oflag = 0%o\n", t.c_oflag); X printf ("cflag = 0%o\n", t.c_cflag); X printf ("lflag = 0%o\n", t.c_lflag); X#endif DEBUG X X /************************** X t.c_iflag = INPCK | PARMRK; X t.c_oflag = FF0 | ONLCR; X t.c_cflag = ISIG; X t.c_lflag = FF0; X **************************/ X X termioflags (&t, argc > 1 ? argv[1] : "B9600 CS8 CREAD CLOCAL"); X X#ifdef DEBUG X puts ("Now:"); X printf ("iflag = 0%o\n", t.c_iflag); X printf ("oflag = 0%o\n", t.c_oflag); X printf ("cflag = 0%o\n", t.c_cflag); X printf ("lflag = 0%o\n", t.c_lflag); X#endif DEBUG X X if (ioctl (fd, TCSETA, &t) < 0) { X perror ("TCSETA"); X exit (3); X } X X while ((c = getc (stdin)) != EOF) { X cnt = 0; X if (c == '\n') X buf[cnt++] = '\r'; X buf[cnt++] = c; X if (write (fd, buf, cnt) != cnt) { X perror ("write error"); X break; X } X } X X buf[0] = '\f'; X if (write (fd, buf, 1) != 1) X perror ("ff write error"); X X exit (0); X} X#endif MAIN SHAR_EOF chmod 0644 termio.c || echo "restore of termio.c fails" sed 's/^X//' << 'SHAR_EOF' > lpr.diff.1 && X*** Makefile X--- ../goodlpr/Makefile X************** X*** 21,27 X # DAEMON someone special X # SPGRP the group id of the spooling programs X # X! CFLAGS= -O X LIBDIR= /usr/lib X BINDIR= /usr/ucb X SPLDIR= /usr/spool/lpd X--- 21,28 ----- X # DAEMON someone special X # SPGRP the group id of the spooling programs X # X! LIBS= -linet -lc_s -s X! CFLAGS= -O -DUSG X LIBDIR= /usr/lib X BINDIR= /usr/ucb X SPLDIR= /usr/spool/lpd X************** X*** 28,33 X DAEMON= daemon X SPGRP= daemon X LIBC= /lib/libc.a X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X lpdchar.c common.c printcap.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X--- 29,36 ----- X DAEMON= daemon X SPGRP= daemon X LIBC= /lib/libc.a X+ EMUSRC= flock.c ftruncate.c scandir.c X+ EMUOBJ= flock.o ftruncate.o scandir.o X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X lpdchar.c common.c printcap.c ${EMUSRC} termio.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X************** X*** 29,35 X SPGRP= daemon X LIBC= /lib/libc.a X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X! lpdchar.c common.c printcap.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X lpdchar.o common.o printcap.o X L2SRCS= lpr.c startdaemon.c printcap.c X--- 32,38 ----- X EMUSRC= flock.c ftruncate.c scandir.c X EMUOBJ= flock.o ftruncate.o scandir.o X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X! lpdchar.c common.c printcap.c ${EMUSRC} termio.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X lpdchar.o common.o printcap.o ${EMUOBJ} termio.o X L2SRCS= lpr.c startdaemon.c printcap.c ${EMUSRC} common.c X************** X*** 31,49 X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X lpdchar.c common.c printcap.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X! lpdchar.o common.o printcap.o X! L2SRCS= lpr.c startdaemon.c printcap.c X! L2OBJS= lpr.o startdaemon.o printcap.o X! L3SRCS= lpq.c displayq.c common.c printcap.c X! L3OBJS= lpq.o displayq.o common.o printcap.o X! L4SRCS= lprm.c rmjob.c startdaemon.c common.c printcap.c X! L4OBJS= lprm.o rmjob.o startdaemon.o common.o printcap.o X! L5SRCS= lpc.c cmds.c cmdtab.c startdaemon.c common.c printcap.c X! L5OBJS= lpc.o cmds.o cmdtab.o startdaemon.o common.o printcap.o X! L6SRCS= lptest.c X! L6OBJS= lptest.o X! L7SRCS= pac.c printcap.c X! L7OBJS= pac.o printcap.o X SRCS= lpd.c lpr.c lpq.c lprm.c pac.c lpd.c cmds.c cmdtab.c printjob.c \ X recvjob.c displayq.c rmjob.c startdaemon.c common.c printcap.c \ X lpdchar.c X--- 34,52 ----- X L1SRCS= lpd.c printjob.c recvjob.c displayq.c rmjob.c startdaemon.c \ X lpdchar.c common.c printcap.c ${EMUSRC} termio.c X L1OBJS= lpd.o printjob.o recvjob.o displayq.o rmjob.o startdaemon.o \ X! lpdchar.o common.o printcap.o ${EMUOBJ} termio.o X! L2SRCS= lpr.c startdaemon.c printcap.c ${EMUSRC} common.c X! L2OBJS= lpr.o startdaemon.o printcap.o ${EMUOBJ} common.o X! L3SRCS= lpq.c displayq.c common.c printcap.c ${EMUSRC} X! L3OBJS= lpq.o displayq.o common.o printcap.o ${EMUOBJ} X! L4SRCS= lprm.c rmjob.c startdaemon.c common.c printcap.c ${EMUSRC} X! L4OBJS= lprm.o rmjob.o startdaemon.o common.o printcap.o ${EMUOBJ} X! L5SRCS= lpc.c cmds.c cmdtab.c startdaemon.c common.c printcap.c ${EMUSRC} X! L5OBJS= lpc.o cmds.o cmdtab.o startdaemon.o common.o printcap.o ${EMUOBJ} X! L6SRCS= lptest.c ${EMUSRC} X! L6OBJS= lptest.o ${EMUOBJ} X! L7SRCS= pac.c printcap.c ${EMUSRC} X! L7OBJS= pac.o printcap.o ${EMUOBJ} X SRCS= lpd.c lpr.c lpq.c lprm.c pac.c lpd.c cmds.c cmdtab.c printjob.c \ X recvjob.c displayq.c rmjob.c startdaemon.c common.c printcap.c \ X lpdchar.c ${EMUSRC} X************** X*** 46,53 X L7OBJS= pac.o printcap.o X SRCS= lpd.c lpr.c lpq.c lprm.c pac.c lpd.c cmds.c cmdtab.c printjob.c \ X recvjob.c displayq.c rmjob.c startdaemon.c common.c printcap.c \ X! lpdchar.c X! OBJS= ${L1OBJS} ${L2OBJS} ${L3OBJS} ${L4OBJS} ${L5OBJS} ${L6OBJS} ${L7OBJS} X MAN1= lpq.0 lpr.0 lprm.0 lptest.0 X MAN8= lpc.0 lpd.0 pac.0 X MAN= ${MAN1} ${MAN8} X--- 49,56 ----- X L7OBJS= pac.o printcap.o ${EMUOBJ} X SRCS= lpd.c lpr.c lpq.c lprm.c pac.c lpd.c cmds.c cmdtab.c printjob.c \ X recvjob.c displayq.c rmjob.c startdaemon.c common.c printcap.c \ X! lpdchar.c ${EMUSRC} X! OBJS= ${L1OBJS} ${L2OBJS} ${L3OBJS} ${L4OBJS} ${L5OBJS} ${L6OBJS} ${L7OBJS} ${EMUOBJ} X MAN1= lpq.0 lpr.0 lprm.0 lptest.0 X MAN8= lpc.0 lpd.0 pac.0 X MAN= ${MAN1} ${MAN8} X************** X*** 56,62 X all: ${ALL} FILTERS VFILTERS X X lpd: ${L1OBJS} ${LIBC} X! ${CC} -o $@ ${L1OBJS} X X lpr: ${L2OBJS} ${LIBC} X ${CC} -o $@ ${L2OBJS} X--- 59,65 ----- X all: ${ALL} FILTERS VFILTERS X X lpd: ${L1OBJS} ${LIBC} X! ${CC} -o $@ ${L1OBJS} ${LIBS} X X lpr: ${L2OBJS} ${LIBC} X ${CC} -o $@ ${L2OBJS} ${LIBS} X************** X*** 59,65 X ${CC} -o $@ ${L1OBJS} X X lpr: ${L2OBJS} ${LIBC} X! ${CC} -o $@ ${L2OBJS} X X lpq: ${L3OBJS} ${LIBC} X ${CC} -o $@ ${L3OBJS} X--- 62,68 ----- X ${CC} -o $@ ${L1OBJS} ${LIBS} X X lpr: ${L2OBJS} ${LIBC} X! ${CC} -o $@ ${L2OBJS} ${LIBS} X X lpq: ${L3OBJS} ${LIBC} X ${CC} -o $@ ${L3OBJS} ${LIBS} X************** X*** 62,68 X ${CC} -o $@ ${L2OBJS} X X lpq: ${L3OBJS} ${LIBC} X! ${CC} -o $@ ${L3OBJS} X X lprm: ${L4OBJS} ${LIBC} X ${CC} -o $@ ${L4OBJS} X--- 65,71 ----- X ${CC} -o $@ ${L2OBJS} ${LIBS} X X lpq: ${L3OBJS} ${LIBC} X! ${CC} -o $@ ${L3OBJS} ${LIBS} X X lprm: ${L4OBJS} ${LIBC} X ${CC} -o $@ ${L4OBJS} ${LIBS} X************** X*** 65,71 X ${CC} -o $@ ${L3OBJS} X X lprm: ${L4OBJS} ${LIBC} X! ${CC} -o $@ ${L4OBJS} X X lpc: ${L5OBJS} ${LIBC} X ${CC} -o $@ ${L5OBJS} X--- 68,74 ----- X ${CC} -o $@ ${L3OBJS} ${LIBS} X X lprm: ${L4OBJS} ${LIBC} X! ${CC} -o $@ ${L4OBJS} ${LIBS} X X lpc: ${L5OBJS} ${LIBC} X ${CC} -o $@ ${L5OBJS} ${LIBS} X************** X*** 68,74 X ${CC} -o $@ ${L4OBJS} X X lpc: ${L5OBJS} ${LIBC} X! ${CC} -o $@ ${L5OBJS} X X lptest: ${L6OBJS} ${LIBC} X ${CC} ${CFLAGS} -o $@ ${L6OBJS} X--- 71,77 ----- X ${CC} -o $@ ${L4OBJS} ${LIBS} X X lpc: ${L5OBJS} ${LIBC} X! ${CC} -o $@ ${L5OBJS} ${LIBS} X X lptest: ${L6OBJS} ${LIBC} X ${CC} ${CFLAGS} -o $@ ${L6OBJS} ${LIBS} X************** X*** 71,77 X ${CC} -o $@ ${L5OBJS} X X lptest: ${L6OBJS} ${LIBC} X! ${CC} ${CFLAGS} -o $@ ${L6OBJS} X X pac: ${L7OBJS} ${LIBC} X ${CC} -o $@ ${L7OBJS} X--- 74,80 ----- X ${CC} -o $@ ${L5OBJS} ${LIBS} X X lptest: ${L6OBJS} ${LIBC} X! ${CC} ${CFLAGS} -o $@ ${L6OBJS} ${LIBS} X X pac: ${L7OBJS} ${LIBC} X ${CC} -o $@ ${L7OBJS} ${LIBS} X************** X*** 74,80 X ${CC} ${CFLAGS} -o $@ ${L6OBJS} X X pac: ${L7OBJS} ${LIBC} X! ${CC} -o $@ ${L7OBJS} X X FILTERS: X cd filters; make ${MFLAGS} X--- 77,83 ----- X ${CC} ${CFLAGS} -o $@ ${L6OBJS} ${LIBS} X X pac: ${L7OBJS} ${LIBC} X! ${CC} -o $@ ${L7OBJS} ${LIBS} X X FILTERS: X cd filters; make ${MFLAGS} X************** X*** 80,86 X cd filters; make ${MFLAGS} X X VFILTERS: X! cd vfilters; make ${MFLAGS} X X clean: X rm -f ${OBJS} core ${ALL} X--- 83,89 ----- X cd filters; make ${MFLAGS} X X VFILTERS: X! # cd vfilters; make ${MFLAGS} X X clean: X rm -f ${OBJS} core ${ALL} X*** cmds.c X--- ../goodlpr/cmds.c X************** X*** 160,165 X } X } X X select(d) X struct direct *d; X { X--- 160,168 ----- X } X } X X+ #ifdef USG X+ lp_select(d) X+ #else X select(d) X #endif X struct direct *d; X************** X*** 161,166 X } X X select(d) X struct direct *d; X { X int c = d->d_name[0]; X--- 164,170 ----- X lp_select(d) X #else X select(d) X+ #endif X struct direct *d; X { X int c = d->d_name[0]; X************** X*** 211,216 X ; X lp[-1] = '/'; X X nitems = scandir(SD, &queue, select, sortq); X if (nitems < 0) { X printf("\tcannot examine spool directory\n"); X--- 215,223 ----- X ; X lp[-1] = '/'; X X+ #ifdef USG X+ nitems = scandir(SD, &queue, lp_select, sortq); X+ #else X nitems = scandir(SD, &queue, select, sortq); X #endif /* USG */ X if (nitems < 0) { X************** X*** 212,217 X lp[-1] = '/'; X X nitems = scandir(SD, &queue, select, sortq); X if (nitems < 0) { X printf("\tcannot examine spool directory\n"); X return; X--- 219,225 ----- X nitems = scandir(SD, &queue, lp_select, sortq); X #else X nitems = scandir(SD, &queue, select, sortq); X+ #endif /* USG */ X if (nitems < 0) { X printf("\tcannot examine spool directory\n"); X return; X************** X*** 850,856 X touch(q) X struct queue *q; X { X! struct timeval tvp[2]; X X tvp[0].tv_sec = tvp[1].tv_sec = --mtime; X tvp[0].tv_usec = tvp[1].tv_usec = 0; X--- 858,868 ----- X touch(q) X struct queue *q; X { X! #ifdef USG X! struct { X! time_t actime, X! modtime; X! } times; X X times.actime = times.modtime = --mtime; X return(utime(q->q_name, ×)); X************** X*** 852,857 X { X struct timeval tvp[2]; X X tvp[0].tv_sec = tvp[1].tv_sec = --mtime; X tvp[0].tv_usec = tvp[1].tv_usec = 0; X return(utimes(q->q_name, tvp)); X--- 864,874 ----- X modtime; X } times; X X+ times.actime = times.modtime = --mtime; X+ return(utime(q->q_name, ×)); X+ #else X+ struct timeval tvp[2]; X+ X tvp[0].tv_sec = tvp[1].tv_sec = --mtime; X tvp[0].tv_usec = tvp[1].tv_usec = 0; X return(utimes(q->q_name, tvp)); X************** X*** 855,860 X tvp[0].tv_sec = tvp[1].tv_sec = --mtime; X tvp[0].tv_usec = tvp[1].tv_usec = 0; X return(utimes(q->q_name, tvp)); X } X X /* X--- 872,878 ----- X tvp[0].tv_sec = tvp[1].tv_sec = --mtime; X tvp[0].tv_usec = tvp[1].tv_usec = 0; X return(utimes(q->q_name, tvp)); X+ #endif /* USG */ X } X X /* X*** cmdtab.c X--- ../goodlpr/cmdtab.c X************** X*** 24,29 X */ X X #include "lpc.h" X X int abort(), clean(), enable(), disable(), down(), help(); X int quit(), restart(), start(), status(), stop(), topq(), up(); X--- 24,30 ----- X */ X X #include "lpc.h" X+ #include "lp.local.h" X X int abort(), clean(), enable(), disable(), down(), help(); X int quit(), restart(), start(), status(), stop(), topq(), up(); X*** common.c X--- ../goodlpr/common.c X************** X*** 59,64 X short PX; /* page width in pixels */ X short PY; /* page length in pixels */ X short BR; /* baud rate if lp is a tty */ X int FC; /* flags to clear if lp is a tty */ X int FS; /* flags to set if lp is a tty */ X int XC; /* flags to clear for local mode */ X--- 59,72 ----- X short PX; /* page width in pixels */ X short PY; /* page length in pixels */ X short BR; /* baud rate if lp is a tty */ X+ #ifdef USG X+ int IC; /* input flags to clear if lp is a tty */ X+ int IS; /* input flags to set if lp is a tty */ X+ int OC; /* output flags to clear if lp is a tty */ X+ int OS; /* output flags to set if lp is a tty */ X+ int CC; /* control flags to clear if lp is a tty */ X+ int CS; /* control flags to set if lp is a tty */ X+ #else X int FC; /* flags to clear if lp is a tty */ X int FS; /* flags to set if lp is a tty */ X int XC; /* flags to clear for local mode */ X************** X*** 63,68 X int FS; /* flags to set if lp is a tty */ X int XC; /* flags to clear for local mode */ X int XS; /* flags to set for local mode */ X short RS; /* restricted to those with local accounts */ X X char line[BUFSIZ]; X--- 71,77 ----- X int FS; /* flags to set if lp is a tty */ X int XC; /* flags to clear for local mode */ X int XS; /* flags to set for local mode */ X+ #endif X short RS; /* restricted to those with local accounts */ X X char line[BUFSIZ]; X************** X*** 69,75 X char pbuf[BUFSIZ/2]; /* buffer for printcap strings */ X char *bp = pbuf; /* pointer into pbuf for pgetent() */ X char *name; /* program name */ X! char *printer; /* printer name */ X char host[32]; /* host machine name */ X char *from = host; /* client's machine name */ X X--- 78,84 ----- X char pbuf[BUFSIZ/2]; /* buffer for printcap strings */ X char *bp = pbuf; /* pointer into pbuf for pgetent() */ X char *name; /* program name */ X! char *printer = (char *)0; /* printer name */ X char host[32]; /* host machine name */ X char *from = host; /* client's machine name */ X X*** displayq.c X--- ../goodlpr/displayq.c X*** etc.printcap X--- ../goodlpr/etc.printcap X*** lp.h X--- ../goodlpr/lp.h X************** X*** 22,27 X */ X X #include X #include X #include X #include X--- 22,31 ----- X */ X X #include X+ #ifdef USG X+ # include X+ # include X+ #endif X #include X #ifdef USG X # include X************** X*** 23,30 X X #include X #include X! #include X! #include X #include X #include X #include X--- 27,40 ----- X # include X #endif X #include X! #ifdef USG X! # include X! # include X! # define direct dirent X! #else X! # include X! # include X! #endif X #include X #include X #ifndef USG X************** X*** 27,32 X #include X #include X #include X #include X #include X #include X--- 37,43 ----- X #endif X #include X #include X+ #ifndef USG X #include X #endif /* USG */ X #include X************** X*** 28,33 X #include X #include X #include X #include X #include X #include X--- 39,45 ----- X #include X #ifndef USG X #include X+ #endif /* USG */ X #include X #include X #include X************** X*** 33,38 X #include X #include X #include X #include X #include X #include X--- 45,51 ----- X #include X #include X #include X+ #ifndef USG X #include X #else X X************** X*** 34,39 X #include X #include X #include X #include X #include X #include X--- 47,56 ----- X #include X #ifndef USG X #include X+ #else X+ X+ #endif /* USG */ X+ #ifndef USG X #include X #endif X #include X************** X*** 35,40 X #include X #include X #include X #include X #include X #include "lp.local.h" X--- 52,58 ----- X #endif /* USG */ X #ifndef USG X #include X+ #endif X #include X #include X #ifdef USG X************** X*** 37,42 X #include X #include X #include X #include "lp.local.h" X X extern int DU; /* daeomon user-id */ X--- 55,67 ----- X #endif X #include X #include X+ #ifdef USG X+ #include X+ #undef FIOCLEX X+ #undef FIONCLEX X+ #include X+ #include X+ #endif X #include "lp.local.h" X X extern int DU; /* daeomon user-id */ X************** X*** 73,78 X extern short PY; /* page length in pixels */ X extern short PL; /* page length */ X extern short BR; /* baud rate if lp is a tty */ X extern int FC; /* flags to clear if lp is a tty */ X extern int FS; /* flags to set if lp is a tty */ X extern int XC; /* flags to clear for local mode */ X--- 98,111 ----- X extern short PY; /* page length in pixels */ X extern short PL; /* page length */ X extern short BR; /* baud rate if lp is a tty */ X+ #ifdef USG X+ extern int IC; /* input flags to clear if lp is a tty */ X+ extern int IS; /* input flags to set if lp is a tty */ X+ extern int OC; /* output flags to clear if lp is a tty */ X+ extern int OS; /* output flags to set if lp is a tty */ X+ extern int CC; /* control flags to clear if lp is a tty */ X+ extern int CS; /* control flags to set if lp is a tty */ X+ #else X extern int FC; /* flags to clear if lp is a tty */ X extern int FS; /* flags to set if lp is a tty */ X extern int XC; /* flags to clear for local mode */ X************** X*** 77,82 X extern int FS; /* flags to set if lp is a tty */ X extern int XC; /* flags to clear for local mode */ X extern int XS; /* flags to set for local mode */ X extern short RS; /* restricted to those with local accounts */ X X extern char line[BUFSIZ]; X--- 110,116 ----- X extern int FS; /* flags to set if lp is a tty */ X extern int XC; /* flags to clear for local mode */ X extern int XS; /* flags to set for local mode */ X+ #endif X extern short RS; /* restricted to those with local accounts */ X X extern char line[BUFSIZ]; X*** lp.local.h X--- ../goodlpr/lp.local.h X************** X*** 26,31 X * printing objects files. X */ X X #include X #include X X--- 26,37 ----- X * printing objects files. X */ X X+ #ifdef USG X+ # include X+ # define index strchr X+ # define rindex strrchr X+ #endif /* USG */ X+ X #include X #include X X************** X*** 29,35 X #include X #include X X! #ifndef A_MAGIC1 /* must be a VM/UNIX system */ X # define A_MAGIC1 OMAGIC X # define A_MAGIC2 NMAGIC X # define A_MAGIC3 ZMAGIC X--- 35,51 ----- X #include X #include X X! #ifdef USG X! # ifndef A_MAGIC1 X! # define A_MAGIC1 0520 /* COFF object */ X! # define A_MAGIC2 0407 /* 4.0 executable */ X! # define A_MAGIC3 0410 /* 4.0 pure executable */ X! # define A_MAGIC4 0570 /* 5.0 executable */ X! # undef ARMAG X! # define ARMAG 0177545 /* archive magic */ X! # endif X! #else X! # ifndef A_MAGIC1 /* must be a VM/UNIX system */ X # define A_MAGIC1 OMAGIC X # define A_MAGIC2 NMAGIC X # define A_MAGIC3 ZMAGIC X************** X*** 35,40 X # define A_MAGIC3 ZMAGIC X # undef ARMAG X # define ARMAG 0177545 X #endif X X /* X--- 51,57 ----- X # define A_MAGIC3 ZMAGIC X # undef ARMAG X # define ARMAG 0177545 X+ # endif X #endif X X /* X************** X*** 44,50 X #define DEFLOCK "lock" X #define DEFSTAT "status" X #define DEFSPOOL "/usr/spool/lpd" X- #define DEFDAEMON "/usr/lib/lpd" X #define DEFLOGF "/dev/console" X #define DEFDEVLP "/dev/lp" X #define DEFRLPR "/usr/lib/rlpr" X--- 61,66 ----- X #define DEFLOCK "lock" X #define DEFSTAT "status" X #define DEFSPOOL "/usr/spool/lpd" X #define DEFLOGF "/dev/console" X #define DEFDEVLP "/dev/lp" X #ifdef USG X************** X*** 47,52 X #define DEFDAEMON "/usr/lib/lpd" X #define DEFLOGF "/dev/console" X #define DEFDEVLP "/dev/lp" X #define DEFRLPR "/usr/lib/rlpr" X #define DEFBINDIR "/usr/ucb" X #define DEFMX 1000 X--- 63,70 ----- X #define DEFSPOOL "/usr/spool/lpd" X #define DEFLOGF "/dev/console" X #define DEFDEVLP "/dev/lp" X+ #ifdef USG X+ #define DEFDAEMON "/usr/lib/lpd" X #define DEFRLPR "/usr/lib/rlpr" X #define DEFBINDIR "/usr/ucb" X #else X************** X*** 49,54 X #define DEFDEVLP "/dev/lp" X #define DEFRLPR "/usr/lib/rlpr" X #define DEFBINDIR "/usr/ucb" X #define DEFMX 1000 X #define DEFMAXCOPIES 0 X #define DEFFF "\f" X--- 67,77 ----- X #define DEFDAEMON "/usr/lib/lpd" X #define DEFRLPR "/usr/lib/rlpr" X #define DEFBINDIR "/usr/ucb" X+ #else X+ #define DEFDAEMON "/usr/lib/lpd" X+ #define DEFRLPR "/usr/lib/rlpr" X+ #define DEFBINDIR "/usr/ucb" X+ #endif X #define DEFMX 1000 X #define DEFMAXCOPIES 0 X #define DEFFF "\f" X************** X*** 96,98 X */ X #define MAXUSERS 50 X #define MAXREQUESTS 50 X--- 119,155 ----- X */ X #define MAXUSERS 50 X #define MAXREQUESTS 50 X+ X+ X+ /* X+ * Redefine some function names in order to avoid conflicts with X+ * some library functions (not all of these are even documented!) X+ */ X+ #ifdef USG X+ #define abort lp_abort X+ #define abortpr lp_abortpr X+ #define account lp_account X+ #define clean lp_clean X+ #define cleanpr lp_cleanpr X+ #define cleanup lp_cleanup X+ #define disable lp_disable X+ #define disablepr lp_disablepr X+ #define down lp_down X+ #define dump lp_dump X+ #define dumpit lp_dumpit X+ #define enable lp_enable X+ #define enablepr lp_enablepr X+ #define getq lp_getq X+ #define mktemps lp_mktemps X+ #define putch lp_putch X+ #define putmsg lp_putmsg X+ #define response lp_response X+ #define touch lp_touch X+ #endif /* USG */ X+ X+ #ifndef LOCK_EX X+ # define LOCK_EX 0x01 /* exclusive lock */ X+ # define LOCK_SH 0x02 /* shared lock */ X+ # define LOCK_UN 0x04 /* unlock the lock */ X+ # define LOCK_NB 0x10 /* non-blocking lock */ X+ #endif X*** lpc.8 X--- ../goodlpr/lpc.8 X*** lpc.c X--- ../goodlpr/lpc.c X************** X*** 53,60 X register struct cmd *c; X extern char *name; X X- name = argv[0]; X- openlog("lpd", 0, LOG_LPR); X X if (--argc > 0) { X c = getcmd(*++argv); X--- 53,58 ----- X register struct cmd *c; X extern char *name; X X X name = argv[0]; X X************** X*** 56,61 X name = argv[0]; X openlog("lpd", 0, LOG_LPR); X X if (--argc > 0) { X c = getcmd(*++argv); X if (c == (struct cmd *)-1) { X--- 54,63 ----- X extern char *name; X X X+ name = argv[0]; X+ X+ openlog("lpd", 0, LOG_LPR); X+ X if (--argc > 0) { X c = getcmd(*++argv); X if (c == (struct cmd *)-1) { X************** X*** 141,147 X longest = 0; X nmatches = 0; X found = 0; X! for (c = cmdtab; p = c->c_name; c++) { X for (q = name; *q == *p++; q++) X if (*q == 0) /* exact match? */ X return(c); X--- 143,149 ----- X longest = 0; X nmatches = 0; X found = 0; X! for (c = cmdtab; (p = c->c_name) && c->c_handler; c++) { X for (q = name; *q == *p++; q++) X if (*q == 0) /* exact match? */ X return(c); X************** X*** 215,221 X for (i = 0; i < lines; i++) { X for (j = 0; j < columns; j++) { X c = cmdtab + j * lines + i; X! printf("%s", c->c_name); X if (c + lines >= &cmdtab[NCMDS]) { X printf("\n"); X break; X--- 217,224 ----- X for (i = 0; i < lines; i++) { X for (j = 0; j < columns; j++) { X c = cmdtab + j * lines + i; X! if (c->c_name) X! printf("%s", c->c_name); X if (c + lines >= &cmdtab[NCMDS]) { X printf("\n"); X break; X*** lpc.h X--- ../goodlpr/lpc.h X*** lpd.8 X--- ../goodlpr/lpd.8 X*** lpd.c X--- ../goodlpr/lpd.c X************** X*** 66,71 X char **argv; X { X int f, funix, finet, options, defreadfds, fromlen; X struct sockaddr_un sun, fromunix; X struct sockaddr_in sin, frominet; X int omask, lfd; X--- 66,72 ----- X char **argv; X { X int f, funix, finet, options, defreadfds, fromlen; X+ #ifndef USG X struct sockaddr_un sun, fromunix; X #endif USG X struct sockaddr_in sin, frominet; X************** X*** 67,72 X { X int f, funix, finet, options, defreadfds, fromlen; X struct sockaddr_un sun, fromunix; X struct sockaddr_in sin, frominet; X int omask, lfd; X X--- 68,74 ----- X int f, funix, finet, options, defreadfds, fromlen; X #ifndef USG X struct sockaddr_un sun, fromunix; X+ #endif USG X struct sockaddr_in sin, frominet; X int omask, lfd; X X************** X*** 97,102 X (void) open("/dev/null", O_RDONLY); X (void) open("/dev/null", O_WRONLY); X (void) dup(1); X f = open("/dev/tty", O_RDWR); X if (f > 0) { X ioctl(f, TIOCNOTTY, 0); X--- 99,107 ----- X (void) open("/dev/null", O_RDONLY); X (void) open("/dev/null", O_WRONLY); X (void) dup(1); X+ #ifdef USG X+ setpgrp (); X+ #else X f = open("/dev/tty", O_RDWR); X if (f > 0) { X ioctl(f, TIOCNOTTY, 0); X************** X*** 102,107 X ioctl(f, TIOCNOTTY, 0); X (void) close(f); X } X #endif X X openlog("lpd", LOG_PID, LOG_LPR); X--- 107,113 ----- X ioctl(f, TIOCNOTTY, 0); X (void) close(f); X } X+ #endif USG X #endif X X openlog("lpd", LOG_PID, LOG_LPR); X************** X*** 127,132 X syslog(LOG_ERR, "%s: %m", MASTERLOCK); X exit(1); X } X signal(SIGCHLD, reapchild); X /* X * Restart all the printers. X--- 133,139 ----- X syslog(LOG_ERR, "%s: %m", MASTERLOCK); X exit(1); X } X+ #ifdef SIGCHLD X signal(SIGCHLD, reapchild); X #else X signal(SIGCLD, reapchild); X************** X*** 128,133 X exit(1); X } X signal(SIGCHLD, reapchild); X /* X * Restart all the printers. X */ X--- 135,143 ----- X } X #ifdef SIGCHLD X signal(SIGCHLD, reapchild); X+ #else X+ signal(SIGCLD, reapchild); X+ #endif X /* X * Restart all the printers. X */ X************** X*** 132,137 X * Restart all the printers. X */ X startup(); X (void) unlink(SOCKETNAME); X funix = socket(AF_UNIX, SOCK_STREAM, 0); X if (funix < 0) { X--- 142,148 ----- X * Restart all the printers. X */ X startup(); X+ #ifndef USG X (void) unlink(SOCKETNAME); X funix = socket(AF_UNIX, SOCK_STREAM, 0); X if (funix < 0) { X************** X*** 138,143 X syslog(LOG_ERR, "socket: %m"); X exit(1); X } X #define mask(s) (1 << ((s) - 1)) X omask = sigblock(mask(SIGHUP)|mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM)); X signal(SIGHUP, mcleanup); X--- 149,156 ----- X syslog(LOG_ERR, "socket: %m"); X exit(1); X } X+ #endif USG X+ X #define mask(s) (1 << ((s) - 1)) X #ifndef USG X omask = sigblock(mask(SIGHUP)|mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM)); X************** X*** 139,144 X exit(1); X } X #define mask(s) (1 << ((s) - 1)) X omask = sigblock(mask(SIGHUP)|mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM)); X signal(SIGHUP, mcleanup); X signal(SIGINT, mcleanup); X--- 152,158 ----- X #endif USG X X #define mask(s) (1 << ((s) - 1)) X+ #ifndef USG X omask = sigblock(mask(SIGHUP)|mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM)); X signal(SIGHUP, mcleanup); X signal(SIGINT, mcleanup); X************** X*** 153,158 X sigsetmask(omask); X defreadfds = 1 << funix; X listen(funix, 5); X finet = socket(AF_INET, SOCK_STREAM, 0); X if (finet >= 0) { X struct servent *sp; X--- 167,175 ----- X sigsetmask(omask); X defreadfds = 1 << funix; X listen(funix, 5); X+ #else X+ defreadfds = 0; X+ #endif USG X finet = socket(AF_INET, SOCK_STREAM, 0); X if (finet >= 0) { X struct servent *sp; X************** X*** 157,162 X if (finet >= 0) { X struct servent *sp; X X if (options & SO_DEBUG) X if (setsockopt(finet, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) { X syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m"); X--- 174,180 ----- X if (finet >= 0) { X struct servent *sp; X X+ #ifndef USG X if (options & SO_DEBUG) X if (setsockopt(finet, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) { X syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m"); X************** X*** 162,167 X syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m"); X mcleanup(); X } X sp = getservbyname("printer", "tcp"); X if (sp == NULL) { X syslog(LOG_ERR, "printer/tcp: unknown service"); X--- 180,186 ----- X syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m"); X mcleanup(); X } X+ #endif USG X sp = getservbyname("printer", "tcp"); X if (sp == NULL) { X syslog(LOG_ERR, "printer/tcp: unknown service"); X************** X*** 188,193 X syslog(LOG_WARNING, "select: %m"); X continue; X } X if (readfds & (1 << funix)) { X domain = AF_UNIX, fromlen = sizeof(fromunix); X s = accept(funix, &fromunix, &fromlen); X--- 207,213 ----- X syslog(LOG_WARNING, "select: %m"); X continue; X } X+ #ifndef USG X if (readfds & (1 << funix)) { X domain = AF_UNIX, fromlen = sizeof(fromunix); X s = accept(funix, &fromunix, &fromlen); X************** X*** 192,197 X domain = AF_UNIX, fromlen = sizeof(fromunix); X s = accept(funix, &fromunix, &fromlen); X } else if (readfds & (1 << finet)) { X domain = AF_INET, fromlen = sizeof(frominet); X s = accept(finet, &frominet, &fromlen); X } X--- 212,220 ----- X domain = AF_UNIX, fromlen = sizeof(fromunix); X s = accept(funix, &fromunix, &fromlen); X } else if (readfds & (1 << finet)) { X+ #else X+ if (readfds & (1 << finet)) { X+ #endif USG X domain = AF_INET, fromlen = sizeof(frominet); X s = accept(finet, &frominet, &fromlen); X } X************** X*** 201,206 X continue; X } X if (fork() == 0) { X signal(SIGCHLD, SIG_IGN); X signal(SIGHUP, SIG_IGN); X signal(SIGINT, SIG_IGN); X--- 224,230 ----- X continue; X } X if (fork() == 0) { X+ #ifdef SIGCHLD X signal(SIGCHLD, SIG_IGN); X #else X signal(SIGCLD, SIG_IGN); X************** X*** 202,207 X } X if (fork() == 0) { X signal(SIGCHLD, SIG_IGN); X signal(SIGHUP, SIG_IGN); X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X--- 226,234 ----- X if (fork() == 0) { X #ifdef SIGCHLD X signal(SIGCHLD, SIG_IGN); X+ #else X+ signal(SIGCLD, SIG_IGN); X+ #endif SIGCHLD X signal(SIGHUP, SIG_IGN); X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X************** X*** 206,211 X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X signal(SIGTERM, SIG_IGN); X (void) close(funix); X (void) close(finet); X dup2(s, 1); X--- 233,239 ----- X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X signal(SIGTERM, SIG_IGN); X+ #ifndef USG X (void) close(funix); X #endif USG X (void) close(finet); X************** X*** 207,212 X signal(SIGQUIT, SIG_IGN); X signal(SIGTERM, SIG_IGN); X (void) close(funix); X (void) close(finet); X dup2(s, 1); X (void) close(s); X--- 235,241 ----- X signal(SIGTERM, SIG_IGN); X #ifndef USG X (void) close(funix); X+ #endif USG X (void) close(finet); X dup2(s, 1); X (void) close(s); X************** X*** 221,226 X X reapchild() X { X union wait status; X X while (wait3(&status, WNOHANG, 0) > 0) X--- 250,260 ----- X X reapchild() X { X+ #ifdef USG X+ int status; X+ (void) wait (&status); X+ signal (SIGCLD, reapchild); X+ #else X union wait status; X X while (wait3(&status, WNOHANG, 0) > 0) X************** X*** 225,230 X X while (wait3(&status, WNOHANG, 0) > 0) X ; X } X X mcleanup() X--- 259,265 ----- X X while (wait3(&status, WNOHANG, 0) > 0) X ; X+ #endif USG X } X X mcleanup() X************** X*** 231,236 X { X if (lflag) X syslog(LOG_INFO, "exiting"); X unlink(SOCKETNAME); X exit(0); X } X--- 266,272 ----- X { X if (lflag) X syslog(LOG_INFO, "exiting"); X+ #ifndef USG X unlink(SOCKETNAME); X #endif USG X exit(0); X************** X*** 232,237 X if (lflag) X syslog(LOG_INFO, "exiting"); X unlink(SOCKETNAME); X exit(0); X } X X--- 268,274 ----- X syslog(LOG_INFO, "exiting"); X #ifndef USG X unlink(SOCKETNAME); X+ #endif USG X exit(0); X } X X*** lpdchar.c X--- ../goodlpr/lpdchar.c X*** lpq.1 X--- ../goodlpr/lpq.1 X*** lpq.c X--- ../goodlpr/lpq.c X*** lpr.1 X--- ../goodlpr/lpr.1 SHAR_EOF chmod 0644 lpr.diff.1 || echo "restore of lpr.diff.1 fails" sed 's/^X//' << 'SHAR_EOF' > lpr.diff.2 && X*** lpr.c X--- ../goodlpr/lpr.c X************** X*** 34,40 X X #include X #include X! #include X #include X #include X #include X--- 34,44 ----- X X #include X #include X! #ifdef USG X! # include X! #else X! # include X! #endif /* USG */ X #include X #include X #include X************** X*** 43,48 X #include X #include "lp.local.h" X X char *tfname; /* tmp copy of cf before linking */ X char *cfname; /* daemon control files, linked from tf's */ X char *dfname; /* data files */ X--- 47,57 ----- X #include X #include "lp.local.h" X X+ #ifdef USG X+ extern struct passwd *getpwuid(); X+ extern struct group *getgrnam(); X+ #endif /* USG */ X+ X char *tfname; /* tmp copy of cf before linking */ X char *cfname; /* daemon control files, linked from tf's */ X char *dfname; /* data files */ X************** X*** 258,263 X */ X mktemps(); X tfd = nfile(tfname); X (void) fchown(tfd, DU, -1); /* owned by daemon for protection */ X card('H', host); X card('P', person); X--- 267,275 ----- X */ X mktemps(); X tfd = nfile(tfname); X+ #ifdef USG X+ (void) chown(tfname, DU, getgid()); /* owned by daemon for protection */ X+ #else X (void) fchown(tfd, DU, -1); /* owned by daemon for protection */ X #endif /* USG */ X card('H', host); X************** X*** 259,264 X mktemps(); X tfd = nfile(tfname); X (void) fchown(tfd, DU, -1); /* owned by daemon for protection */ X card('H', host); X card('P', person); X if (hdr) { X--- 271,277 ----- X (void) chown(tfname, DU, getgid()); /* owned by daemon for protection */ X #else X (void) fchown(tfd, DU, -1); /* owned by daemon for protection */ X+ #endif /* USG */ X card('H', host); X card('P', person); X if (hdr) { X************** X*** 404,410 X static char buf[BUFSIZ]; X X if (*file != '/') { X! if (getwd(buf) == NULL) X return(NULL); X while (file[0] == '.') { X switch (file[1]) { X--- 417,424 ----- X static char buf[BUFSIZ]; X X if (*file != '/') { X! #ifdef USG X! if (getcwd(buf, sizeof buf) == NULL) X return(NULL); X #else X if (getwd(buf) == NULL) X************** X*** 406,411 X if (*file != '/') { X if (getwd(buf) == NULL) X return(NULL); X while (file[0] == '.') { X switch (file[1]) { X case '/': X--- 420,429 ----- X #ifdef USG X if (getcwd(buf, sizeof buf) == NULL) X return(NULL); X+ #else X+ if (getwd(buf) == NULL) X+ return(NULL); X+ #endif /* USG */ X while (file[0] == '.') { X switch (file[1]) { X case '/': X************** X*** 425,430 X strcat(buf, file); X file = buf; X } X return(symlink(file, dfname) ? NULL : file); X } X X--- 443,451 ----- X strcat(buf, file); X file = buf; X } X+ #ifdef USG X+ return(link(file, dfname) ? NULL : file); /*XXX*/ X+ #else X return(symlink(file, dfname) ? NULL : file); X #endif USG X } X************** X*** 426,431 X file = buf; X } X return(symlink(file, dfname) ? NULL : file); X } X X /* X--- 447,453 ----- X return(link(file, dfname) ? NULL : file); /*XXX*/ X #else X return(symlink(file, dfname) ? NULL : file); X+ #endif USG X } X X /* X************** X*** 462,467 X printf("%s: cannot create %s\n", name, n); X cleanup(); X } X if (fchown(f, userid, -1) < 0) { X printf("%s: cannot chown %s\n", name, n); X cleanup(); X--- 484,492 ----- X printf("%s: cannot create %s\n", name, n); X cleanup(); X } X+ #ifdef USG 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************** X*** 463,468 X cleanup(); SHAR_EOF echo "End of part 1, continue with part 2" echo "2" > s2_seq_.tmp exit 0 -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170