[comp.unix.sysv386] LPR for 386 UNIX

cpcahil@virtech.uucp (Conor P. Cahill) (03/24/91)

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 <wilbur!jon> 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 <sys/types.h>
X#include <unistd.h>
X#include <fcntl.h>
X#include <errno.h>
X#include <net/errno.h>
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 <sys/types.h>
X#include <sys/stat.h>
X#include <errno.h>
X#include <fcntl.h>
X#include <unistd.h>
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 <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#ifdef	i386
X# include <dirent.h>
X# include <sys/dir.h>
X#else
X# include <sys/dir.h>
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 <sys/termio.h>
X#include <ctype.h>
X#include <syslog.h>
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 <stdio.h>
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, &times));
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, &times));
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 <stdio.h>
X  #include <sys/param.h>
X  #include <sys/file.h>
X  #include <sys/dir.h>
X--- 22,31 -----
X   */
X  
X  #include <stdio.h>
X+ #ifdef	USG
X+ # include <sys/types.h>
X+ # include <limits.h>
X+ #endif
X  #include <sys/param.h>
X  #ifdef	USG
X  # include <fcntl.h>
X**************
X*** 23,30
X  
X  #include <stdio.h>
X  #include <sys/param.h>
X! #include <sys/file.h>
X! #include <sys/dir.h>
X  #include <sys/stat.h>
X  #include <sys/socket.h>
X  #include <sys/un.h>
X--- 27,40 -----
X  # include <limits.h>
X  #endif
X  #include <sys/param.h>
X! #ifdef	USG
X! # include <fcntl.h>
X! # include <dirent.h>
X! # define direct	dirent
X! #else
X! # include <sys/file.h>
X! # include <sys/dir.h>
X! #endif
X  #include <sys/stat.h>
X  #include <sys/socket.h>
X  #ifndef USG
X**************
X*** 27,32
X  #include <sys/dir.h>
X  #include <sys/stat.h>
X  #include <sys/socket.h>
X  #include <sys/un.h>
X  #include <netinet/in.h>
X  #include <netdb.h>
X--- 37,43 -----
X  #endif
X  #include <sys/stat.h>
X  #include <sys/socket.h>
X+ #ifndef USG
X  #include <sys/un.h>
X  #endif	/* USG */
X  #include <netinet/in.h>
X**************
X*** 28,33
X  #include <sys/stat.h>
X  #include <sys/socket.h>
X  #include <sys/un.h>
X  #include <netinet/in.h>
X  #include <netdb.h>
X  #include <pwd.h>
X--- 39,45 -----
X  #include <sys/socket.h>
X  #ifndef USG
X  #include <sys/un.h>
X+ #endif	/* USG */
X  #include <netinet/in.h>
X  #include <netdb.h>
X  #include <pwd.h>
X**************
X*** 33,38
X  #include <pwd.h>
X  #include <syslog.h>
X  #include <signal.h>
X  #include <sys/wait.h>
X  #include <sgtty.h>
X  #include <ctype.h>
X--- 45,51 -----
X  #include <pwd.h>
X  #include <syslog.h>
X  #include <signal.h>
X+ #ifndef USG
X  #include <sys/wait.h>
X  #else
X  
X**************
X*** 34,39
X  #include <syslog.h>
X  #include <signal.h>
X  #include <sys/wait.h>
X  #include <sgtty.h>
X  #include <ctype.h>
X  #include <errno.h>
X--- 47,56 -----
X  #include <signal.h>
X  #ifndef USG
X  #include <sys/wait.h>
X+ #else
X+ 
X+ #endif	/* USG */
X+ #ifndef USG
X  #include <sgtty.h>
X  #endif
X  #include <ctype.h>
X**************
X*** 35,40
X  #include <signal.h>
X  #include <sys/wait.h>
X  #include <sgtty.h>
X  #include <ctype.h>
X  #include <errno.h>
X  #include "lp.local.h"
X--- 52,58 -----
X  #endif	/* USG */
X  #ifndef USG
X  #include <sgtty.h>
X+ #endif
X  #include <ctype.h>
X  #include <errno.h>
X  #ifdef USG
X**************
X*** 37,42
X  #include <sgtty.h>
X  #include <ctype.h>
X  #include <errno.h>
X  #include "lp.local.h"
X  
X  extern int	DU;		/* daeomon user-id */
X--- 55,67 -----
X  #endif
X  #include <ctype.h>
X  #include <errno.h>
X+ #ifdef USG
X+ #include <net/errno.h>
X+ #undef FIOCLEX
X+ #undef FIONCLEX
X+ #include <sys/ioctl.h>
X+ #include <termio.h>
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 <a.out.h>
X  #include <ar.h>
X  
X--- 26,37 -----
X   *   printing objects files.
X   */
X  
X+ #ifdef	USG
X+ # include	<string.h>
X+ # define	index	strchr
X+ # define	rindex	strrchr
X+ #endif	/* USG */
X+ 
X  #include <a.out.h>
X  #include <ar.h>
X  
X**************
X*** 29,35
X  #include <a.out.h>
X  #include <ar.h>
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 <a.out.h>
X  #include <ar.h>
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 <stdio.h>
X  #include <sys/types.h>
X! #include <sys/file.h>
X  #include <sys/stat.h>
X  #include <pwd.h>
X  #include <grp.h>
X--- 34,44 -----
X  
X  #include <stdio.h>
X  #include <sys/types.h>
X! #ifdef	USG
X! # include <fcntl.h>
X! #else
X! # include <sys/file.h>
X! #endif	/* USG */
X  #include <sys/stat.h>
X  #include <pwd.h>
X  #include <grp.h>
X**************
X*** 43,48
X  #include <syslog.h>
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 <syslog.h>
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 

cpcahil@virtech.uucp (Conor P. Cahill) (03/24/91)

---- 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 

pgf@cayman.COM (Paul Fox) (04/03/91)

In article <1991Mar24.012918.23603@virtech.uucp> cpcahil@virtech.uucp (Conor P.
Cahill) writes:
>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.
>

There's another solution -- we (Cayman Systems) make freely available
an lp to lpr interface package that we provide for the benefit of our
customers that have GatorPrint.  GatorPrint is the software package
that runs on the GatorBox and provides lpr-to-LocalTalk printer
access.  It is equally adept at connecting lp to UNIX-based lpr's,
since the GatorPrint software is emulating an lpr daemon.  Our
package, lprclient, installs as an interface script under lp, so users
continue to type "lp", "lpstat", etc.  It is based (with permission)
on the lpr client code in Richard Stevens' book "UNIX Network
Programming".  (I don't have my copy handy -- hope I got the title
right -- it's from Prentice Hall)

You can ftp the package, a single shar file (lprclient.shar), from
ftp.cayman.com.

PLEASE DO NOT CALL THE CAYMAN SYSTEMS TECHNICAL SUPPORT GROUP WITH QUESTIONS
ABOUT THIS PACKAGE...  It's not that they can't answer them, but they'd
rather spend their time answering questions from paying customers.  :-)

I can answer questions sent via email, but will not respond to phone calls
about this.

		paul fox, pgf@cayman.com
                Cayman Systems, Inc., 26 Landsdowne St., Cambridge, MA 02139

-- 
		paul fox, pgf@cayman.com, (617)494-1999
		Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139