[net.bugs.uucp] updates for 4.3bsd uucp

rick@seismo.CSS.GOV (Rick Adams) (11/08/86)

Subject: uucico is SLOW and other minor problems
Index:	usr.bin/uucp 4.3BSD

Description:
	uucico is incredibly slow on systems with a lot of jobs queued up.
	This is an artifact of the way uucico was converted to use the new
	directory reading routines.
	The PC Pursuit suport is for the old style dial back PC Pursuit service.
	Support for the new one is provided.
	The 'g' protocol packet driver as a bug in it.
	Several other small bugs are fixed.
Repeat-By:
	Run uucico with 8000 jobs queued up and listen to your vax whine.
Fix:
	Delete the file gnamef.c. It is no longer used.
	Apply the following patches.

*** Makefile	Fri Nov  7 17:50:53 1986
--- ../nuucp/Makefile	Sun May 18 23:41:30 1986
***************
*** 1,4 ****
! #	Makefile	5.11	85/12/12
  #
  # This version expects the 4.2BSD directory reading routines to
  # located in libc.a.  If they aren't, augment LIBS.  Also, LIBS
--- 1,4 ----
! #	%W%	%G%
  #
  # This version expects the 4.2BSD directory reading routines to
  # located in libc.a.  If they aren't, augment LIBS.  Also, LIBS
***************
*** 12,18 ****
  # Common object files placed in uulib.a
  COMMON=	anlwrk.o anyread.o assert.o cfgets.o chkpth.o \
  	cpmv.o expfile.o gename.o getargs.o getprm.o \
! 	getpwinfo.o gnamef.o gnxseq.o lastpart.o logent.o mailst.o \
  	prefix.o setline.o strpbrk.o subdir.o sysacct.o systat.o \
  	ulockf.o uucpname.o versys.o xqt.o uucpdefs.o
  SRCS=	${USRCS} ${OSRCS} ${LSRCS}
--- 12,18 ----
  # Common object files placed in uulib.a
  COMMON=	anlwrk.o anyread.o assert.o cfgets.o chkpth.o \
  	cpmv.o expfile.o gename.o getargs.o getprm.o \
! 	getpwinfo.o gnxseq.o lastpart.o logent.o mailst.o \
  	prefix.o setline.o strpbrk.o subdir.o sysacct.o systat.o \
  	ulockf.o uucpname.o versys.o xqt.o uucpdefs.o
  SRCS=	${USRCS} ${OSRCS} ${LSRCS}
***************
*** 22,29 ****
  	uusend.c uusnap.c uux.c uuxqt.c uuq.c acucntrl.c
  LSRCS=	anlwrk.c anyread.c assert.c cfgets.c chkpth.c \
  	cpmv.c expfile.c \
! 	gename.c getargs.c getprm.c getpwinfo.c \
! 	gnamef.c gnxseq.c \
  	lastpart.c logent.c mailst.c prefix.c \
  	setline.c strpbrk.c subdir.c sysacct.c systat.c ulockf.c \
  	uucpdefs.c uucpname.c versys.c xqt.c
--- 22,28 ----
  	uusend.c uusnap.c uux.c uuxqt.c uuq.c acucntrl.c
  LSRCS=	anlwrk.c anyread.c assert.c cfgets.c chkpth.c \
  	cpmv.c expfile.c \
! 	gename.c getargs.c getprm.c getpwinfo.c gnxseq.c \
  	lastpart.c logent.c mailst.c prefix.c \
  	setline.c strpbrk.c subdir.c sysacct.c systat.c ulockf.c \
  	uucpdefs.c uucpname.c versys.c xqt.c
***************
*** 153,170 ****
  	for i in uucico uuclean; do \
  		install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${LIBDIR} ;\
  	done
! 	for i in uucp uux uulog uuname uusnap uupoll uuq uusend; do \
  		install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${BIN} ;\
  	done
  	rm -f ${BIN}/ruusend
  	ln ${BIN}/uusend ${BIN}/ruusend
  	install -s -m 6110 -o ${OWNER} -g ${GROUP} uuxqt ${LIBDIR}
! 	install -s -m 6110 -o root -g ${GROUP} acucntrl ${LIBDIR}
  	install -s -m 500 -o uucp uucpd ${ETC}
  	@echo Dont forget to fork off /etc/uucpd in /etc/rc.local
  	@echo if you are not running /etc/inetd
  	install -s uuencode ${BIN}
  	install -s uudecode ${BIN}
  
  clean:
  	rm -f *.o ${ALL} uulib.a
--- 152,170 ----
  	for i in uucico uuclean; do \
  		install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${LIBDIR} ;\
  	done
! 	for i in uucp uux uulog uuname uusnap uupoll uuq; do \
  		install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${BIN} ;\
  	done
  	rm -f ${BIN}/ruusend
  	ln ${BIN}/uusend ${BIN}/ruusend
  	install -s -m 6110 -o ${OWNER} -g ${GROUP} uuxqt ${LIBDIR}
! 	install -s -m 6111 -o root -g ${GROUP} acucntrl ${LIBDIR}
  	install -s -m 500 -o uucp uucpd ${ETC}
  	@echo Dont forget to fork off /etc/uucpd in /etc/rc.local
  	@echo if you are not running /etc/inetd
  	install -s uuencode ${BIN}
  	install -s uudecode ${BIN}
+ 	install -s uusend ${BIN}
  
  clean:
  	rm -f *.o ${ALL} uulib.a
***************
*** 274,282 ****
  gio.o: uucp.h
  gio.o: pk.h
  gio.o: /usr/include/setjmp.h
- gnamef.o: gnamef.c
- gnamef.o: uucp.h
- gnamef.o: /usr/include/sys/dir.h
  gnsys.o: gnsys.c
  gnsys.o: uucp.h
  gnsys.o: /usr/include/sys/dir.h
--- 274,279 ----
*** anlwrk.c	Fri Nov  7 17:50:54 1986
--- ../nuucp/anlwrk.c	Tue Oct 28 16:34:29 1986
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)anlwrk.c	5.5 (Berkeley) 6/19/85";
  #endif
  
  #include "uucp.h"
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "%W%	%G%";
  #endif
  
  #include "uucp.h"
***************
*** 12,18 ****
  #endif
  #include <ctype.h>
  
! #define TLIMIT	(5*60L)
  #define NITEMS(X)	(sizeof (X) / sizeof ((X)[0]))
  
  int Nfiles = 0;
--- 12,18 ----
  #endif
  #include <ctype.h>
  
! #define TLIMIT	(15*60L)
  #define NITEMS(X)	(sizeof (X) / sizeof ((X)[0]))
  
  int Nfiles = 0;
***************
*** 61,67 ****
  			bnp = rindex(file, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : file);
  			xmv(file, rqstr);
! 			logent(subfile(file), "CMD FILE UNREADABLE");
  			unlink(subfile(file));
  			return 0;
  		}
--- 61,67 ----
  			bnp = rindex(file, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : file);
  			xmv(file, rqstr);
! 			assert("CMD FILE UNREADABLE", subfile(file), 0);
  			unlink(subfile(file));
  			return 0;
  		}
***************
*** 113,122 ****
  register char *dir, *pre;
  {
  	static DIR  *dirp = NULL;
! 	register nfound;
! 	char filename[NAMESIZE];
! 	int plen = strlen (pre);
! 	int flen;
  	extern char MaxGrade;
  
  	if (dirp == NULL) {
--- 113,121 ----
  register char *dir, *pre;
  {
  	static DIR  *dirp = NULL;
! 	register struct direct *dentp;
! 	register int i;
! 	int plen = strlen(pre);
  	extern char MaxGrade;
  
  	if (dirp == NULL) {
***************
*** 124,133 ****
  			DEBUG(1,"opendir(%s) FAILS\n",subdir(dir,pre[0]));
  			return 0;
  		}
! 	}
! 	else
  		rewinddir(dirp);
! 	for (nfound = 0, Nfiles = 0; gnamef(dirp, filename);) {
  		/* Check for two systems with the same prefix.
  		 * Magic number "5" is 1 for "grade" character plus
  		 * 4 for sequence number.  The point here is to not
--- 123,133 ----
  			DEBUG(1,"opendir(%s) FAILS\n",subdir(dir,pre[0]));
  			return 0;
  		}
! 	} else
  		rewinddir(dirp);
! 
! 	Nfiles = 0;
! 	while ((dentp = readdir(dirp)) != NULL && Nfiles < LLEN) {
  		/* Check for two systems with the same prefix.
  		 * Magic number "5" is 1 for "grade" character plus
  		 * 4 for sequence number.  The point here is to not
***************
*** 136,185 ****
  		 * Special case: prefix "X." does not do this check
  		 * so uuxqt can use bldflst.
  		 */
! 		flen = strlen(filename);
! 		if (!prefix(pre, filename) || (plen != 2 && flen-plen != 5)) {
! 			DEBUG(99,"bldflst rejects %s\n",filename);
  			continue;
  		}
! 		if (filename[flen-5] > MaxGrade ) {
! 			DEBUG(8,"bldflst rejects %s, grade too low\n",filename);
  			continue;
  		}
- 		nfound++;
  		if (*reqst == 'c')
  			return 1;
- 		entflst(filename);
- 	}
- 	return  nfound? 1: 0;
- }
  
! /*
!  *	put new name if list is not full  or new name is less than the MAX
!  *		  now in the list.
!  *
!  */
  
! /* LOCAL only */
! int
! entflst(file)
! register char *file;
! {
! 	register int i;
  
- 	/* locate position for the new file and make room for it */
- 	for (i = Nfiles; i > 0; i--) {
- 		if (pcompar(file, Filent[i-1]) <= 0)
- 			break;
- 		if (i <LLEN)
- 			strcpy(Filent[i], Filent[i-1]);
  	}
! 
! 	/* add new file (if there is room), and increase Nfiles if need be */
! 	if (i < LLEN) {
! 		strcpy(Filent[i], file);
! 		if (Nfiles < LLEN)
! 			Nfiles++;
! 	}
  }
  
  /*
--- 136,171 ----
  		 * Special case: prefix "X." does not do this check
  		 * so uuxqt can use bldflst.
  		 */
! 		if (!prefix(pre, dentp->d_name) ||
! 			(plen != 2 && (dentp->d_namlen-plen) != 5)) {
! 			DEBUG(99,"bldflst rejects %s\n",dentp->d_name);
  			continue;
  		}
! 		if (dentp->d_name[dentp->d_namlen-5] > MaxGrade) {
! 			DEBUG(8, "bldflst rejects %s, grade too low\n",
! 				dentp->d_name);
  			continue;
  		}
  		if (*reqst == 'c')
  			return 1;
  
! 		/* locate position for the new file and make room for it */
! 		for (i = Nfiles; i > 0; i--) {
! 			if (pcompar(dentp->d_name, Filent[i-1]) <= 0)
! 				break;
! 			if (i <LLEN)
! 				strcpy(Filent[i], Filent[i-1]);
! 		}
  
! 		/* add new file (if there is room), and increase Nfiles if need be */
! 		if (i < LLEN) {
! 			strcpy(Filent[i], dentp->d_name);
! 			if (Nfiles < LLEN)
! 				Nfiles++;
! 		}
  
  	}
! 	return Nfiles > 0;
  }
  
  /*
***************
*** 216,247 ****
  }
  
  /*
-  *	get next work file
-  *
-  *	return value:
-  *
-  *		0  - No file gotten
-  *		1  - File successfully gotten.
-  *
-  */
- 
- /* LOCAL only */
- gtwrkf(dir, file)
- char *file, *dir;
- {
- 	register int i;
- 
- 	if (Nfiles-- <= 0) {
- 		Nfiles = 0;
- 		return 0;
- 	}
- 	sprintf(file, "%s/%s", dir, Filent[0]);
- 	for (i=0; i<Nfiles;i++)
- 		strcpy(Filent[i], Filent[i+1]);
- 	return 1;
- }
- 
- /*
   *	get work vector
   *
   *	return codes:
--- 202,207 ----
***************
*** 284,335 ****
  register char *file, *reqst, *dir, *pre;
  {
  	static char *lastpre = 0;
! 	register ret;
  
  	/* Starting new system; re-init */
! 	if (lastpre == 0 || strcmp(lastpre,pre) != 0) {
! 		anlwrk ("", (char **)0);	/* Force close of work file */
  
  		/* Save last worked-on prefix */
  		if (lastpre != 0)
! 			free (lastpre);
  		lastpre = malloc((unsigned)(strlen(pre)+1));
! 		strcpy (lastpre, pre);
  
! 		/* Set the external indexes properly
! 		 */
  		Nfiles = 0;
  	}
  
! 	/* If the list is empty or new files have entered
  	 * the spool area, call "bldflst" to read
! 	 * some file names into it.  Because names can
! 	 * be put in the list that later turn out to
! 	 * be unusable (from "gtwrkf"), this operation
! 	 * continues until either "bldflst" can't find
! 	 * any new files, or "gtwrkf" signals success.
  	 */
! 	for (;;) {
! 		ret = 0;
! 		if (Nfiles <= 0 || newspool((time_t)TLIMIT)) {
! 			ret = bldflst (reqst, dir, pre);
! 			DEBUG(99,"bldflst returns %d\n",ret);
! 		}
  
! 		/* If they only wanted to check, return
! 		 * boolean list not empty.  NB: the list
! 		 * will be forcibly emptied as soon as
! 		 * a new system name is mentioned.
! 		 */
! 		if (*reqst == 'c')
! 			return ret;
  
! 		if (Nfiles <= 0)
! 			return 0;
! 
! 		if (gtwrkf(dir, file))
! 			return 1;
  	}
  }
  
  /* Return non-zero if there is new work in the spool
--- 244,295 ----
  register char *file, *reqst, *dir, *pre;
  {
  	static char *lastpre = 0;
! 	register ret = 0;
! 	int i;
  
  	/* Starting new system; re-init */
! 	if (lastpre == 0 || strcmp(lastpre, pre) != SAME) {
! 		/* Force close of work file */
! 		anlwrk("", (char **)0);
  
  		/* Save last worked-on prefix */
  		if (lastpre != 0)
! 			free(lastpre);
  		lastpre = malloc((unsigned)(strlen(pre)+1));
! 		strcpy(lastpre, pre);
  
! 		/* Set the external indexes properly */
  		Nfiles = 0;
  	}
  
! 	/*
! 	 * If the list is empty or new files have entered
  	 * the spool area, call "bldflst" to read
! 	 * some file names into it. 
  	 */
! 	if (Nfiles <= 0 || newspool((time_t)TLIMIT)) {
! 		ret = bldflst(reqst, dir, pre);
! 		DEBUG(99, "bldflst returns %d\n", ret);
! 	}
  
! 	/* If they only wanted to check, return
! 	 * boolean list not empty.  NB: the list
! 	 * will be forcibly emptied as soon as
! 	 * a new system name is mentioned.
! 	 */
! 	if (*reqst == 'c')
! 		return ret;
  
! 	if (Nfiles-- <= 0) {
! 		/* Didn't find any files in the spool area */
! 		Nfiles = 0;
! 		return 0;
  	}
+ 	/* Found some files, return the first one */
+ 	sprintf(file, "%s/%s", dir, Filent[0]);
+ 	for (i = 0; i < Nfiles; i++)
+ 		strcpy(Filent[i], Filent[i+1]);
+ 	return 1;
  }
  
  /* Return non-zero if there is new work in the spool
*** cico.c	Fri Nov  7 17:50:57 1986
--- ../nuucp/cico.c	Wed May 21 18:48:21 1986
***************
*** 220,226 ****
  		/*
  		 * Determine if we are on TCPIP
  		 */
! 		if (isatty(Ifn) < 0) {
  			IsTcpIp = 1;
  			DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
  		} else
--- 220,226 ----
  		/*
  		 * Determine if we are on TCPIP
  		 */
! 		if (isatty(Ifn) == 0) {
  			IsTcpIp = 1;
  			DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
  		} else
*** cntrl.c	Fri Nov  7 17:50:59 1986
--- ../nuucp/cntrl.c	Sun May 18 23:44:20 1986
***************
*** 198,204 ****
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			logent(Wfile, "CMD FILE CORRUPTED");
  			Wfile[0] = '\0';
  			goto top;
  		}
--- 198,204 ----
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			assert("CMD FILE CORRUPTED", Wfile, narg);
  			Wfile[0] = '\0';
  			goto top;
  		}
***************
*** 392,399 ****
  			}
  			notify(mailopt, W_USER, W_FILE1, Rmtname, &msg[1]);
  			ASSERT(role == MASTER, "WRONG ROLE - SN", CNULL, role);
! 			if (msg[1] != '4')
! 				unlinkdf(W_DFILE);
  			goto top;
  		}
  
--- 392,398 ----
  			}
  			notify(mailopt, W_USER, W_FILE1, Rmtname, &msg[1]);
  			ASSERT(role == MASTER, "WRONG ROLE - SN", CNULL, role);
! 			unlinkdf(W_DFILE);
  			goto top;
  		}
  
***************
*** 431,437 ****
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			logent(Wfile, "CMD FILE CORRUPTED");
  			Wfile[0] = '\0';
  			goto top;
  		}
--- 430,436 ----
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			assert("CMD FILE CORRUPTED",Wfile, i);
  			Wfile[0] = '\0';
  			goto top;
  		}
***************
*** 606,612 ****
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			logent(Wfile, "CMD FILE CORRUPTED");
  			Wfile[0] = '\0';
  			goto top;
  		}
--- 605,611 ----
  			bnp = rindex(Wfile, '/');
  			sprintf(rqstr, "%s/%s", CORRUPT, bnp ? bnp + 1 : Wfile);
  			xmv(Wfile, rqstr);
! 			assert("CMD FILE CORRUPTED", Wfile, i);
  			Wfile[0] = '\0';
  			goto top;
  		}
*** condevs.c	Fri Nov  7 17:51:02 1986
--- ../nuucp/condevs.c	Sun May 18 23:45:30 1986
***************
*** 315,324 ****
  			}
  		}
  
! 		if (mlock(dev.D_line) == FAIL) {
! 			acustatus++;
  			continue;
! 		}
  		if (acustatus < 1)
  			acustatus = 1;	/* has been found */
  #ifdef DIALINOUT
--- 318,326 ----
  			}
  		}
  
! 		if (mlock(dev.D_line) == FAIL)
  			continue;
! 
  		if (acustatus < 1)
  			acustatus = 1;	/* has been found */
  #ifdef DIALINOUT
*** conn.c	Fri Nov  7 17:51:05 1986
--- ../nuucp/conn.c	Mon Jul 28 18:36:31 1986
***************
*** 61,70 ****
   */
  #define PCP_BAUD	3
  #define PCP_PHONE	4
! #define PCP_CALLBACK	8
! #define PCP_CITY	10
! #define PCP_RPHONE	12
! #define NPCFIELDS	15
  
  static char *PCFlds[] = {
  	"PC-PURSUIT",
--- 61,70 ----
   */
  #define PCP_BAUD	3
  #define PCP_PHONE	4
! #define PCP_CITY	14
! #define PCP_PASSWORD	16
! #define PCP_RPHONE	20
! #define NPCFIELDS	23
  
  static char *PCFlds[] = {
  	"PC-PURSUIT",
***************
*** 71,91 ****
  	"Any",
  	"ACU",
  	"1200",
! 	CNULL,	/* <--- **** Welcome to Telenet PC Pursuit ***** */
  	"ABORT",
! 	"Good",	/* Abort of Good bye! */
! 	")", 	/* <--- Enter your 7-digit phone number (xxx-xxxx) */
! 	CNULL,	/* ---> 528-1234 */
! 	"call?", 	/* <--- Which city do you wish to call? */
! 	CNULL,	/* ---> CHICAGO */
! 	")", 	/* <--- Enter the phone number you wish to call (xxx-xxxx) */
! 	CNULL,	/* ---> 690-7171 */
! 	"R)?", 	/* <--- You are #1 in the queue. Do you want to wait, or Restart (Y/N/R)? */
! 	"Y",
! 	CNULL 	/* <--- .....Good Bye! */
  };
  
! static char PCP_brand[20];
  
  /*
   *	place a telephone call to system and login, etc.
--- 71,99 ----
  	"Any",
  	"ACU",
  	"1200",
! 	CNULL,
! 	CNULL,
! 	"P_ZERO",	/* Telenet insists on zero parity */
  	"ABORT",
! 	"BUSY",		/* Abort on Busy Signal */
! 	CNULL,
! 	"\\d\\d\\r\\d\\r",	/* Get telenet's attention */
! 	"TERMINAL=~3-\r-TERM~3-\r-TERM~5", 	/* Terminal type ? */
! 	"\\r",
! 	"@",		/* telenet's prompt */
! 	"c\sdial312/21,telenetloginstring", /* overwritten later */
! 	"PASSWORD",
! 	CNULL,		/* telenet password */
! 	"CONNECTED",	/* We're now talking to a Hayes in the remote city */
! 	"ATZ",		/* Reset it */
! 	"OK",
! 	"ATDT6907171", /* overwritten */
! 	"CONNECT",	
! 	"\\d\\r",		/* We're in !*/
! 	CNULL,
  };
  
! static char PCP_brand[25];
  
  /*
   *	place a telephone call to system and login, etc.
***************
*** 141,146 ****
--- 149,155 ----
  			FILE *dfp;
  			int status;
  			static struct Devices dev;
+ 
  			dfp = fopen(DEVFILE, "r");
  			ASSERT(dfp != NULL, "Can't open", DEVFILE, 0);
  			while ((status=rddev(dfp, &dev)) != FAIL
***************
*** 156,180 ****
  			}
  			PCFlds[PCP_BAUD] = dev.D_class;
  			PCFlds[PCP_PHONE] = dev.D_calldev;
! 			PCFlds[PCP_CALLBACK] = dev.D_arg[D_CHAT];
! 			PCFlds[PCP_CITY] = Flds[F_CLASS];
! 			PCFlds[PCP_RPHONE] = Flds[F_PHONE];
  			strncpy(PCP_brand, dev.D_brand, sizeof(PCP_brand));
! 			if ((fcode = getto(PCFlds)) < 0)
  				continue;
  			Dcf = fcode;
  			fcode = login(NPCFIELDS, PCFlds, Dcf);
! 			clsacu(); /* Hang up, they'll call back */
! 			if (fcode != SUCCESS) {
! 				fcode = CF_DIAL;
! 				continue;
! 			}
! 			Flds[F_CLASS] = dev.D_class;
! 			Flds[F_PHONE] = dev.D_line;
! 			
! 		} /* end PC Pursuit */
! 		if ((fcode = getto(Flds)) > 0) 
  			break;
  	}
  
  	if (nf <= 0) {
--- 165,190 ----
  			}
  			PCFlds[PCP_BAUD] = dev.D_class;
  			PCFlds[PCP_PHONE] = dev.D_calldev;
! 			sprintf(PCFlds[PCP_CITY], "c\\sdial%s/12,%s",
! 				Flds[F_CLASS], dev.D_arg[D_CHAT]);
! 			PCFlds[PCP_PASSWORD] = dev.D_line;
! 			strncpy(&PCFlds[PCP_RPHONE][4], Flds[F_PHONE], 7);
  			strncpy(PCP_brand, dev.D_brand, sizeof(PCP_brand));
! 			if ((fcode = getto(PCFlds)) < 0) {
! 				rmlock(PCP);
  				continue;
+ 			}
  			Dcf = fcode;
  			fcode = login(NPCFIELDS, PCFlds, Dcf);
! 			if (fcode == SUCCESS)
! 				break;
! 			fcode = CF_DIAL;
! 			rmlock(PCP);
! 			/* end PC Pursuit */
! 		} else if ((fcode = getto(Flds)) > 0)  {
! 			Dcf = fcode;
  			break;
+ 		}
  	}
  
  	if (nf <= 0) {
***************
*** 182,201 ****
  		return fcode ? fcode : nf;
  	}
  
- 	Dcf = fcode;
  
- 	if (fcode >= 0 && snccmp(LineType, PCP) == SAME) {
- 		AbortOn = "Good";	/* .... Good Bye */
- 		fcode = expect("****~300", Dcf);
- 		if (fcode != SUCCESS) {
- 			DEBUG(4, "\nexpect timed out\n", CNULL);
- 			fcode = CF_DIAL;
- 		}
- 	}
  	if (fcode >= 0) {
  		DEBUG(4, "login %s\n", "called");
! 		fcode = login(nf, Flds, Dcf);
! 	}
  	if (fcode < 0) {
  		clsacu();
  		if (fcode == ABORT) {
--- 192,201 ----
  		return fcode ? fcode : nf;
  	}
  
  
  	if (fcode >= 0) {
  		DEBUG(4, "login %s\n", "called");
! 		fcode = login(nf, Flds, Dcf); }
  	if (fcode < 0) {
  		clsacu();
  		if (fcode == ABORT) {
***************
*** 443,449 ****
  				sendthem(altern, fn);
  			} else
  				if (ok == ABORT) {
! 					logent("LOGIN ABORTED", _FAILED);
  					return ABORT;
  				}
  		}
--- 443,451 ----
  				sendthem(altern, fn);
  			} else
  				if (ok == ABORT) {
! 					char sbuf[MAXFULLNAME];
! 					sprintf(sbuf, "LOGIN ABORTED on \"%s\"",						AbortOn);
! 					logent(sbuf, _FAILED);
  					return ABORT;
  				}
  		}
*** gnsys.c	Fri Nov  7 17:51:06 1986
--- ../nuucp/gnsys.c	Sun May 18 23:43:50 1986
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)gnsys.c	5.4 (Berkeley) 6/20/85";
  #endif
  
  #include "uucp.h"
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "%W%	%G%";
  #endif
  
  #include "uucp.h"
***************
*** 25,45 ****
   *		SUCCESS  -  no more names
   *		FAIL  -  bad directory
   */
- 
  gnsys(sname, dir, pre)
  char *sname, *dir, pre;
  {
! 	register char *s, *p1, *p2;
! 	char px[3];
  	static char *list[LSIZE];
! 	static int nitem=0, n=0, base=0;
! 	char systname[NAMESIZE], filename[NAMESIZE];
! 	DIR *dirp;
  
  retry:
- 	px[0] = pre;
- 	px[1] = '.';
- 	px[2] = '\0';
  	if (nitem == base) {
  		/* get list of systems with work */
  		int i;
--- 25,40 ----
   *		SUCCESS  -  no more names
   *		FAIL  -  bad directory
   */
  gnsys(sname, dir, pre)
  char *sname, *dir, pre;
  {
! 	register DIR *dirp;
! 	register struct direct *dentp;
  	static char *list[LSIZE];
! 	static int nitem = 0, n = 0, base = 0;
! 	char systname[NAMESIZE];
  
  retry:
  	if (nitem == base) {
  		/* get list of systems with work */
  		int i;
***************
*** 47,58 ****
  		ASSERT(dirp != NULL, "BAD DIRECTORY", dir, 0);
  		for (i = base; i < LSIZE; i++)
  			list[i] = NULL;
! 		while (gnamef(dirp, filename) != 0) {
! 			if (!prefix(px, filename))
  				continue;
! 			p2 = filename + strlen(filename)
! 				- WSUFSIZE;
! 			p1 = filename + strlen(px);
  			for(s = systname; p1 <= p2; p1++)
  				*s++ = *p1;
  			*s = '\0';
--- 42,53 ----
  		ASSERT(dirp != NULL, "BAD DIRECTORY", dir, 0);
  		for (i = base; i < LSIZE; i++)
  			list[i] = NULL;
! 		while (dentp = readdir(dirp)) {
! 			register char *s, *p1, *p2;
! 			if (dentp->d_name[0] != pre || dentp->d_name[1] != '.')
  				continue;
! 			p2 = dentp->d_name + dentp->d_namlen - WSUFSIZE;
! 			p1 = dentp->d_name + 2;
  			for(s = systname; p1 <= p2; p1++)
  				*s++ = *p1;
  			*s = '\0';
***************
*** 59,67 ****
  			if (systname[0] == '\0')
  				continue;
  			nitem = srchst(systname, list, nitem);
! 			if (LSIZE <= nitem) break;
  		}
- 
  		closedir(dirp);
  	}
  
--- 54,62 ----
  			if (systname[0] == '\0')
  				continue;
  			nitem = srchst(systname, list, nitem);
! 			if (LSIZE <= nitem)
! 				break;
  		}
  		closedir(dirp);
  	}
  
***************
*** 71,77 ****
  				free(list[n]);
  		return SUCCESS;
  	}
! 	while(nitem > n) {
  		/* We only have at most a SYSNSIZE character site name encoded
  		 * in the file. However, we would like to use the full sitename
  		 * if possible. If the number of chars in list[n] is < SYSNSIZE
--- 66,72 ----
  				free(list[n]);
  		return SUCCESS;
  	}
! 	while (nitem > n) {
  		/* We only have at most a SYSNSIZE character site name encoded
  		 * in the file. However, we would like to use the full sitename
  		 * if possible. If the number of chars in list[n] is < SYSNSIZE
***************
*** 113,119 ****
   *	return codes:
   *		n - the number of items in the list
   */
- 
  srchst(name, list, n)
  char *name;
  register char **list;
--- 108,113 ----
*** pk.h	Fri Nov  7 17:51:07 1986
--- ../nuucp/pk.h	Sun May 18 23:43:35 1986
***************
*** 1,4 ****
! /*	pk.h	5.4	86/01/06	*/
  
  struct header {
  	char	sync;
--- 1,4 ----
! /*	%W%	%G%	*/
  
  struct header {
  	char	sync;
***************
*** 22,35 ****
  	struct	header p_ihbuf;	/* input header */
  	struct	header p_ohbuf; /* output header */
  	char	*p_rptr;
- 	char	p_mode;
  	char	**p_ipool;
  	char	p_xcount;	/* # active output buffers */
  	char	p_rcount;
- 	char	p_nout,p_tout;
  	char	p_lpsize;	/* log(psize/32) */
! 	char	p_timer;
! 	char	p_obusy;
  	char	p_srxmit;
  	char	p_rwindow;	/* window size */
  	char	p_swindow;
--- 22,32 ----
  	struct	header p_ihbuf;	/* input header */
  	struct	header p_ohbuf; /* output header */
  	char	*p_rptr;
  	char	**p_ipool;
  	char	p_xcount;	/* # active output buffers */
  	char	p_rcount;
  	char	p_lpsize;	/* log(psize/32) */
! 	char	p_obusy;	/* output busy? for reentrant pkoutput() */
  	char	p_srxmit;
  	char	p_rwindow;	/* window size */
  	char	p_swindow;
*** pk0.c	Fri Nov  7 17:51:08 1986
--- ../nuucp/pk0.c	Sun May 18 23:43:15 1986
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)pk0.c	5.7 (Berkeley) 5/30/86";
  #endif
  
  #include "uucp.h"
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "%W% (Berkeley) %G%";
  #endif
  
  #include "uucp.h"
***************
*** 453,459 ****
  		pkxstart(pk, x, seq);
  		pk->p_os[seq] = bstate;
  		pk->p_state &= ~RXMIT;
- 		pk->p_nout++;
  		goto out;
  	}
  	/*
--- 453,458 ----
***************
*** 461,467 ****
  	 * and transmission buffers are languishing
  	 */
  	if (pk->p_xcount) {
- 		pk->p_timer = 2;
  		pk->p_state |= WAITO;
  	} else
  		pk->p_state &= ~WAITO;
--- 460,465 ----
***************
*** 489,501 ****
  	 * try to flush output
  	 */
  	i = 0;
- 	pk->p_timer = 2;
  	while (pk->p_xcount && pk->p_state&LIVE) {
  		if (pk->p_state&(RCLOSE+DOWN) || ++i > 2)
  			break;
  		pkoutput(pk);
  	}
- 	pk->p_timer = 0;
  	pk->p_state |= DOWN;
  
  	/*
--- 487,497 ----
***************
*** 504,510 ****
  	i = 0;
  	while ((pk->p_state&RCLOSE)==0 && i<2) {
  		pk->p_msg = M_CLOSE;
- 		pk->p_timer = 2;
  		pkoutput(pk);
  		i++;
  	}
--- 500,505 ----
***************
*** 538,544 ****
  		char buf[256];
  
  		sprintf(buf, "PK0: rc %d rw %d", rcheck, pk->p_rwindow);
! 		logent(buf, "pkclose rcheck != p_rwindow");
  	}
  	free((char *)pk);
  }
--- 533,539 ----
  		char buf[256];
  
  		sprintf(buf, "PK0: rc %d rw %d", rcheck, pk->p_rwindow);
! 		assert(buf, Rmtname, 0);
  	}
  	free((char *)pk);
  }
*** pk1.c	Fri Nov  7 17:51:10 1986
--- ../nuucp/pk1.c	Sun Nov  2 21:12:49 1986
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)pk1.c	5.9 (Berkeley) 5/30/86";
  #endif
  
  #include <signal.h>
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "%W% (Berkeley) %G%";
  #endif
  
  #include <signal.h>
***************
*** 196,202 ****
  		return;
  	}
  	if (k && pksizes[k] == pk->p_rsize) {
! 		pk->p_rpr = (h->cntl >> 3) & MOD8;
  		pksack(pk);
  		bp = pk->p_ipool;
  		if (bp == NULL) {
--- 196,203 ----
  		return;
  	}
  	if (k && pksizes[k] == pk->p_rsize) {
! 		pk->p_rpr = h->cntl & MOD8;
! 		DEBUG(7, "end pksack 0%o\n", pk->p_rpr);
  		pksack(pk);
  		bp = pk->p_ipool;
  		if (bp == NULL) {
*** uuclean.c	Fri Nov  7 17:51:11 1986
--- ../nuucp/uuclean.c	Sun May 18 23:44:33 1986
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)uuclean.c	5.6 (Berkeley) 10/9/85";
  #endif
  
  #include <signal.h>
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "%W%	%G%";
  #endif
  
  #include <signal.h>
***************
*** 39,49 ****
  main(argc, argv)
  char *argv[];
  {
! 	DIR *dirp;
! 	char file[NAMESIZE];
  	time_t nomtime, ptime;
  	struct stat stbuf;
! 	int mflg=0;
  
  	strcpy(Progname, "uuclean");
  	uucpname(Myname);
--- 39,49 ----
  main(argc, argv)
  char *argv[];
  {
! 	register DIR *dirp;
! 	register struct direct *dentp;
  	time_t nomtime, ptime;
  	struct stat stbuf;
! 	int mflg = 0;
  
  	strcpy(Progname, "uuclean");
  	uucpname(Myname);
***************
*** 89,100 ****
  	}
  
  	time(&ptime);
! 	while (gnamef(dirp, file)) {
! 		if (checkprefix && !chkpre(file))
  			continue;
  
! 		if (stat(file, &stbuf) == -1) {
! 			DEBUG(4, "stat on %s failed\n", file);
  			continue;
  		}
  
--- 89,100 ----
  	}
  
  	time(&ptime);
! 	while (dentp = readdir(dirp)) {
! 		if (checkprefix && !chkpre(dentp->d_name))
  			continue;
  
! 		if (stat(dentp->d_name, &stbuf) == -1) {
! 			DEBUG(4, "stat on %s failed\n", dentp->d_name);
  			continue;
  		}
  
***************
*** 103,114 ****
  			continue;
  		if ((ptime - stbuf.st_mtime) < nomtime)
  			continue;
! 		if (file[0] == CMDPRE)
! 			notfyuser(file);
! 		DEBUG(4, "unlink file %s\n", file);
! 		unlink(file);
  		if (mflg)
! 			sdmail(file, stbuf.st_uid);
  	}
  
  	closedir(dirp);
--- 103,114 ----
  			continue;
  		if ((ptime - stbuf.st_mtime) < nomtime)
  			continue;
! 		if (dentp->d_name[0] == CMDPRE)
! 			notfyuser(dentp->d_name);
! 		DEBUG(4, "unlink file %s\n", dentp->d_name);
! 		unlink(dentp->d_name);
  		if (mflg)
! 			sdmail(dentp->d_name, stbuf.st_uid);
  	}
  
  	closedir(dirp);
*** uucp.c	Fri Nov  7 17:51:12 1986
--- ../nuucp/uucp.c	Sun May 18 23:42:37 1986
***************
*** 260,265 ****
--- 260,267 ----
  			return FAIL;
  		}
  		xcp(file1, file2);
+ 		/* With odd umask() might not be able to read it himself */
+ 		(void) chmod(file2, 0666);
  		logent("WORK HERE", "DONE");
  		return SUCCESS;
  	case 1:
*** uuq.c	Fri Nov  7 17:51:14 1986
--- ../nuucp/uuq.c	Wed May 28 18:58:39 1986
***************
*** 131,137 ****
  			/* The 80 * njobs is because of the uucp handshaking */
  			minutes = (float)(sp->s_bytes + 80 * sp->s_njobs)/baudrate;
  			hours = minutes/60;
! 			printf(", %d bytes, ", sp->s_bytes);
  			if (minutes > 60){
  				printf("%d hour%s, ",hours,
  					hours > 1 ? "s": "");
--- 131,137 ----
  			/* The 80 * njobs is because of the uucp handshaking */
  			minutes = (float)(sp->s_bytes + 80 * sp->s_njobs)/baudrate;
  			hours = minutes/60;
! 			printf(", %ld bytes, ", sp->s_bytes);
  			if (minutes > 60){
  				printf("%d hour%s, ",hours,
  					hours > 1 ? "s": "");
***************
*** 144,151 ****
  		if (hflag)
  			continue;
  		/* sort them babies! */
! 		sortjob = (struct job **)calloc(sp->s_njobs, sizeof (struct job
!  *));
  		for (i=0, jp=sp->s_jobp; i < sp->s_njobs; i++, jp=jp->j_jobp)
  			sortjob[i] = jp;
  		qsort(sortjob, sp->s_njobs, sizeof (struct job *), jcompare);
--- 144,150 ----
  		if (hflag)
  			continue;
  		/* sort them babies! */
! 		sortjob = (struct job **)calloc(sp->s_njobs, sizeof (struct job *));
  		for (i=0, jp=sp->s_jobp; i < sp->s_njobs; i++, jp=jp->j_jobp)
  			sortjob[i] = jp;
  		qsort(sortjob, sp->s_njobs, sizeof (struct job *), jcompare);
***************
*** 152,158 ****
  		for (i = 0; i < sp->s_njobs; i++) {
  			jp = sortjob[i];
  			if (lflag) {
! 				printf("%s %2d %-*s%7d%5.1f %-12.12s %c %.*s\n",
  	jp->j_jobno, jp->j_files, Maxulen, jp->j_user, jp->j_bytes, jp->j_bytes/baudrate,
  	ctime(&jp->j_date) + 4, jp->j_flags, sizeof (jp->j_fname), jp->j_fname
  				);
--- 151,157 ----
  		for (i = 0; i < sp->s_njobs; i++) {
  			jp = sortjob[i];
  			if (lflag) {
! 				printf("%s %2d %-*s%7ld%5.1f %-12.12s %c %.*s\n",
  	jp->j_jobno, jp->j_files, Maxulen, jp->j_user, jp->j_bytes, jp->j_bytes/baudrate,
  	ctime(&jp->j_date) + 4, jp->j_flags, sizeof (jp->j_fname), jp->j_fname
  				);
*** uuxqt.c	Fri Nov  7 17:51:16 1986
--- ../nuucp/uuxqt.c	Thu Jul  3 13:46:31 1986
***************
*** 18,23 ****
--- 18,25 ----
  char *p;\
  for (p = d; *p != '\0';) *cmdp++ = *p++; *cmdp++ = ' '; *cmdp = '\0';}
  
+ extern char Filent[LLEN][NAMESIZE];
+ 
  /*
   *	uuxqt will execute commands set up by a uux command,
   *	usually from a remote machine - set by uucp.
***************
*** 406,412 ****
  register char *file;
  {
  	char pre[3];
! 	int rechecked;
  	time_t ystrdy;		/* yesterday */
  	struct stat stbuf;	/* for X file age */
  
--- 408,414 ----
  register char *file;
  {
  	char pre[3];
! 	register int rechecked, i;
  	time_t ystrdy;		/* yesterday */
  	struct stat stbuf;	/* for X file age */
  
***************
*** 415,421 ****
  	pre[2] = '\0';
  	rechecked = 0;
  retry:
! 	if (!gtwrkf(Spool, file)) {
  		if (rechecked)
  			return 0;
  		rechecked = 1;
--- 417,424 ----
  	pre[2] = '\0';
  	rechecked = 0;
  retry:
! 	if (Nfiles-- <= 0) {
! 		Nfiles = 0;
  		if (rechecked)
  			return 0;
  		rechecked = 1;
***************
*** 423,428 ****
--- 426,435 ----
  		if (!iswrk(file, "get", Spool, pre))
  			return 0;
  	}
+ 	sprintf(file, "%s/%s", Spool, Filent[0]);
+ 	for (i=0; i<Nfiles;i++)
+ 		strcpy(Filent[i], Filent[i+1]);
+ 
  	DEBUG(4, "file - %s\n", file);
  	/* skip spurious subdirectories */
  	if (strcmp(pre, file) == SAME)
***************
*** 434,440 ****
  	    time(&ystrdy);
  	    ystrdy -= (4 * 3600L);		/* 4 hours ago */
  	    DEBUG(4, "gtxfile: Nfiles > LLEN/2\n", CNULL);
! 	    while (gtwrkf(Spool, file) && !gotfiles(file)) {
  		if (stat(subfile(file), &stbuf) == 0)
  		    if (stbuf.st_mtime <= ystrdy) {
  			char *bnp, cfilename[NAMESIZE];
--- 441,453 ----
  	    time(&ystrdy);
  	    ystrdy -= (4 * 3600L);		/* 4 hours ago */
  	    DEBUG(4, "gtxfile: Nfiles > LLEN/2\n", CNULL);
! 	    while (Nfiles-- > 0) {
! 		sprintf(file, "%s/%s", Spool, Filent[0]);
! 		for (i=0; i<Nfiles; i++)
! 			strcpy(Filent[i], Filent[i+1]);
! 
! 		if (gotfiles(file))
! 			return 1;
  		if (stat(subfile(file), &stbuf) == 0)
  		    if (stbuf.st_mtime <= ystrdy) {
  			char *bnp, cfilename[NAMESIZE];
***************
*** 444,452 ****
  			sprintf(cfilename, "%s/%s", CORRUPT,
  				bnp ? bnp + 1 : subfile(file));
  			xmv(subfile(file), cfilename);
! 			logent(file, "X. FILE CORRUPTED");
  		    }
  	    }
  	    DEBUG(4, "iswrk\n", CNULL);
  	    if (!iswrk(file, "get", Spool, pre))
  		return 0;
--- 457,466 ----
  			sprintf(cfilename, "%s/%s", CORRUPT,
  				bnp ? bnp + 1 : subfile(file));
  			xmv(subfile(file), cfilename);
! 			assert("X. FILE MISSING FILES", file, 0);
  		    }
  	    }
+  	    Nfiles = 0;
  	    DEBUG(4, "iswrk\n", CNULL);
  	    if (!iswrk(file, "get", Spool, pre))
  		return 0;
***************
*** 675,681 ****
  	int status, f;
  	int uid, pid, ret;
  	char path[MAXFULLNAME];
! 	char *args[20];
  	extern int errno;
  
  	if (fi == NULL)
--- 689,695 ----
  	int status, f;
  	int uid, pid, ret;
  	char path[MAXFULLNAME];
! 	char *args[128];
  	extern int errno;
  
  	if (fi == NULL)
***************
*** 683,689 ****
  	if (fo == NULL)
  		fo = DEVNULL;
  
! 	getargs(cmd, args, 20);
  	DEBUG(3, "shio - %s\n", cmd);
  #ifdef SIGCHLD
  	signal(SIGCHLD, SIG_IGN);
--- 697,703 ----
  	if (fo == NULL)
  		fo = DEVNULL;
  
! 	getargs(cmd, args, 128);
  	DEBUG(3, "shio - %s\n", cmd);
  #ifdef SIGCHLD
  	signal(SIGCHLD, SIG_IGN);