[comp.sys.handhelds] pf-bootstrap-v1.1a part 8 of 9

dan@i10s7.ira.uka.de (Dan Mosedale) (05/17/91)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 8 (of 9)."
# Contents:  pf-bootstrap-v1.1a/tipx-p1/cmds.c
#   pf-bootstrap-v1.1a/xmodem-3.9/README
# Wrapped by dan@nostromo on Fri May 17 02:31:43 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'pf-bootstrap-v1.1a/tipx-p1/cmds.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/cmds.c'\"
else
echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/cmds.c'\" \(21091 characters\)
sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/cmds.c' <<'END_OF_FILE'
X/*
X * Copyright (c) 1983 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)cmds.c	5.8 (Berkeley) 9/2/88";
X#endif /* not lint */
X
X#include "tip.h"
X/*
X * tip
X *
X * miscellaneous commands
X */
X
Xint	quant[] = { 60, 60, 24 };
X
Xchar	null = '\0';
Xchar	*sep[] = { "second", "minute", "hour" };
Xstatic char *argv[10];		/* argument vector for take and put */
X
Xsigfunc_t	timeout();	/* timeout function called on alarm */
Xsigfunc_t	stopsnd();	/* SIGINT handler during file transfers */
Xsigfunc_t	intprompt();	/* used in handling SIG_INT during prompt */
Xsigfunc_t	intcopy();	/* interrupt routine for file transfers */
X
X/*
X * FTP - remote ==> local
X *  get a file from the remote host
X */
Xgetfl(c)
X	char c;
X{
X	char buf[256], *cp, *expand();
X	
X	putchar(c);
X	/*
X	 * get the UNIX receiving file's name
X	 */
X	if (prompt("Local file name? ", copyname))
X		return;
X	cp = expand(copyname);
X	if ((sfd = creat(cp, 0666)) < 0) {
X		printf("\r\n%s: cannot creat\r\n", copyname);
X		return;
X	}
X	
X	/*
X	 * collect parameters
X	 */
X	if (prompt("List command for remote system? ", buf)) {
X		unlink(copyname);
X		return;
X	}
X	transfer(buf, sfd, value(EOFREAD));
X}
X
X/*
X * Cu-like take command
X */
X/*ARGUSED*/
Xcu_take(cc)
X	char cc;
X{
X	int fd, argc;
X	char line[BUFSIZ], *expand(), *cp;
X
X	if (prompt("[take] ", copyname))
X		return;
X	if ((argc = args(copyname, argv)) < 1 || argc > 2) {
X		printf("usage: <take> from [to]\r\n");
X		return;
X	}
X	if (argc == 1)
X		argv[1] = argv[0];
X	cp = expand(argv[1]);
X	if ((fd = creat(cp, 0666)) < 0) {
X		printf("\r\n%s: cannot create\r\n", argv[1]);
X		return;
X	}
X	sprintf(line, "cat %s;echo \01", argv[0]);
X	transfer(line, fd, "\01");
X}
X
Xstatic	jmp_buf intbuf;
X/*
X * Bulk transfer routine --
X *  used by getfl(), cu_take(), and pipefile()
X */
Xtransfer(buf, fd, eofchars)
X	char *buf, *eofchars;
X{
X	register int ct;
X	char c, buffer[BUFSIZ];
X	register char *p = buffer;
X	register int cnt, eof;
X	time_t start;
X	sigfunc_t (*f)();
X
X	pwrite(FD, buf, size(buf));
X	quit = 0;
X	kill(pid, SIGIOT);
X	read(repdes[0], (char *)&ccc, 1);  /* Wait until read process stops */
X	
X	/*
X	 * finish command
X	 */
X	pwrite(FD, "\r", 1);
X	do
X		read(FD, &c, 1); 
X	while ((c&0177) != '\n');
X	ioctl(0, TIOCSETC, &defchars);
X	
X	(void) setjmp(intbuf);
X	f = signal(SIGINT, intcopy);
X	start = time(0);
X	for (ct = 0; !quit;) {
X		eof = read(FD, &c, 1) <= 0;
X		c &= 0177;
X		if (quit)
X			continue;
X  		if (eof || any(c, eofchars))
X  			break;
X		if (c == 0)
X			continue;	/* ignore nulls */
X		if (c == '\r')
X			continue;
X		*p++ = c;
X
X		if (c == '\n' && boolean(value(VERBOSE)))
X			printf("\r%d", ++ct);
X		if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) {
X			if (write(fd, buffer, cnt) != cnt) {
X				printf("\r\nwrite error\r\n");
X				quit = 1;
X			}
X			p = buffer;
X		}
X	}
X	if (cnt = (p-buffer))
X		if (write(fd, buffer, cnt) != cnt)
X			printf("\r\nwrite error\r\n");
X
X	if (boolean(value(VERBOSE)))
X		prtime(" lines transferred in ", time(0)-start);
X	ioctl(0, TIOCSETC, &tchars);
X	write(fildes[1], (char *)&ccc, 1);
X	signal(SIGINT, f);
X	close(fd);
X}
X
X/*
X * FTP - remote ==> local process
X *   send remote input to local process via pipe
X */
Xpipefile()
X{
X	int cpid, pdes[2];
X	char buf[256];
X	int status, p;
X	extern int errno;
X
X	if (prompt("Local command? ", buf))
X		return;
X
X	if (pipe(pdes)) {
X		printf("can't establish pipe\r\n");
X		return;
X	}
X
X	if ((cpid = fork()) < 0) {
X		printf("can't fork!\r\n");
X		return;
X	} else if (cpid) {
X		if (prompt("List command for remote system? ", buf)) {
X			close(pdes[0]), close(pdes[1]);
X			kill (cpid, SIGKILL);
X		} else {
X			sigfunc_t (*f)();
X
X			close(pdes[0]);
X			f = signal(SIGPIPE, intcopy);
X			transfer(buf, pdes[1], value(EOFREAD));
X			signal(SIGPIPE, f);
X			while ((p = wait(&status)) > 0 && p != cpid)
X				;
X		}
X	} else {
X		register int f;
X
X		dup2(pdes[0], 0);
X		close(pdes[0]);
X		for (f = 3; f < 20; f++)
X			close(f);
X		execute(buf);
X		printf("can't execl!\r\n");
X		exit(0);
X	}
X}
X
X/*
X * Interrupt service routine for FTP
X */
Xsigfunc_t
Xstopsnd()
X{
X
X	stop = 1;
X	signal(SIGINT, SIG_IGN);
X}
X
X/*
X * FTP - local ==> remote
X *  send local file to remote host
X *  terminate transmission with pseudo EOF sequence
X */
Xsendfile(cc)
X	char cc;
X{
X	FILE *fd;
X	char *fnamex;
X	char *expand();
X
X	putchar(cc);
X	/*
X	 * get file name
X	 */
X	if (prompt("Local file name? ", fname))
X		return;
X
X	/*
X	 * look up file
X	 */
X	fnamex = expand(fname);
X	if ((fd = fopen(fnamex, "r")) == NULL) {
X		printf("%s: cannot open\r\n", fname);
X		return;
X	}
X	transmit(fd, value(EOFWRITE), NULL);
X	if (!boolean(value(ECHOCHECK)) || boolean(value(LINESYNC))) {
X		struct sgttyb buf;
X
X		ioctl(FD, TIOCGETP, &buf);	/* this does a */
X		ioctl(FD, TIOCSETP, &buf);	/*   wflushtty */
X	}
X}
X
X/*
X * Bulk transfer routine to remote host --
X *   used by sendfile() and cu_put()
X */
Xtransmit(fd, eofchars, command)
X	FILE *fd;
X	char *eofchars, *command;
X{
X	char *pc, lastc;
X	int c, ccount, lcount;
X	time_t start_t, stop_t;
X	sigfunc_t (*f)();
X
X	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
X	stop = 0;
X	f = signal(SIGINT, stopsnd);
X	ioctl(0, TIOCSETC, &defchars);
X	read(repdes[0], (char *)&ccc, 1);
X	if (command != NULL) {
X		for (pc = command; *pc; pc++)
X			send(*pc);
X		if (boolean(value(ECHOCHECK)) || boolean(value(LINESYNC)))
X			read(FD, (char *)&c, 1);	/* trailing \n */
X		else {
X			struct sgttyb buf;
X
X			ioctl(FD, TIOCGETP, &buf);	/* this does a */
X			ioctl(FD, TIOCSETP, &buf);	/*   wflushtty */
X			sleep(5); /* wait for remote stty to take effect */
X		}
X	}
X	lcount = 0;
X	lastc = '\0';
X	start_t = time(0);
X	while (1) {
X		ccount = 0;
X		do {
X			c = getc(fd);
X			if (stop)
X				goto out;
X			if (c == EOF)
X				goto out;
X			if (c == 0177 && !boolean(value(RAWFTP)))
X				continue;
X			lastc = c;
X			if (c < 040) {
X				if (c == '\n') {
X					if (!boolean(value(RAWFTP)))
X						c = '\r';
X				}
X				else if (c == '\t') {
X					if (!boolean(value(RAWFTP))) {
X						if (boolean(value(TABEXPAND))) {
X							send(' ');
X							while ((++ccount % 8) != 0)
X								send(' ');
X							continue;
X						}
X					}
X				} else
X					if (!boolean(value(RAWFTP)))
X						continue;
X			}
X			send(c);
X		} while (c != '\r' && !boolean(value(RAWFTP)));
X		if (boolean(value(VERBOSE)))
X			printf("\r%d", ++lcount);
X		if (boolean(value(ECHOCHECK)) || boolean(value(LINESYNC))) {
X			timedout = 0;
X			alarm(value(ETIMEOUT));
X			do {	/* wait for prompt */
X				read(FD, (char *)&c, 1);
X				if (timedout || stop) {
X					if (timedout)
X						printf("\r\ntimed out at eol\r\n");
X					alarm(0);
X					goto out;
X				}
X			} while ((c&0177) != character(value(PROMPT)));
X			alarm(0);
X		}
X	}
Xout:
X	if (lastc != '\n' && !boolean(value(RAWFTP)))
X		send('\r');
X	for (pc = eofchars; *pc; pc++)
X		send(*pc);
X	stop_t = time(0);
X	fclose(fd);
X	signal(SIGINT, f);
X	if (boolean(value(VERBOSE)))
X		if (boolean(value(RAWFTP)))
X			prtime(" chars transferred in ", stop_t-start_t);
X		else
X			prtime(" lines transferred in ", stop_t-start_t);
X	write(fildes[1], (char *)&ccc, 1);
X	ioctl(0, TIOCSETC, &tchars);
X}
X
X/*
X * Cu-like put command
X */
X/*ARGUSED*/
Xcu_put(cc)
X	char cc;
X{
X	FILE *fd;
X	char line[BUFSIZ];
X	int argc;
X	char *expand();
X	char *copynamex;
X
X	if (prompt("[put] ", copyname))
X		return;
X	if ((argc = args(copyname, argv)) < 1 || argc > 2) {
X		printf("usage: <put> from [to]\r\n");
X		return;
X	}
X	if (argc == 1)
X		argv[1] = argv[0];
X	copynamex = expand(argv[0]);
X	if ((fd = fopen(copynamex, "r")) == NULL) {
X		printf("%s: cannot open\r\n", copynamex);
X		return;
X	}
X	if (boolean(value(ECHOCHECK)))
X		sprintf(line, "cat>%s\r", argv[1]);
X	else
X		sprintf(line, "stty -echo;cat>%s;stty echo\r", argv[1]);
X	transmit(fd, "\04", line);
X}
X
X/*
X * FTP - send single character
X *  wait for echo & handle timeout
X */
Xsend(c)
X	char c;
X{
X	char cc;
X	int retry = 0;
X
X	cc = c;
X	pwrite(FD, &cc, 1);
X#ifdef notdef
X	if (number(value(CDELAY)) > 0 && c != '\r')
X		nap(number(value(CDELAY)));
X#endif
X	if (!boolean(value(ECHOCHECK))) {
X#ifdef notdef
X		if (number(value(LDELAY)) > 0 && c == '\r')
X			nap(number(value(LDELAY)));
X#endif
X		return;
X	}
Xtryagain:
X	timedout = 0;
X	alarm(value(ETIMEOUT));
X	read(FD, &cc, 1);
X	alarm(0);
X	if (timedout) {
X		printf("\r\ntimeout error (%s)\r\n", ctrl(c));
X		if (retry++ > 3)
X			return;
X		pwrite(FD, &null, 1); /* poke it */
X		goto tryagain;
X	}
X}
X
Xsigfunc_t
Xtimeout()
X{
X	signal(SIGALRM, timeout);
X	timedout = 1;
X}
X
X/*
X * Stolen from consh() -- puts a remote file on the output of a local command.
X *	Identical to consh() except for where stdout goes.
X */
Xpipeout(c)
X{
X	char buf[256];
X	int cpid, status, p;
X	time_t start;
X
X	putchar(c);
X	if (prompt("Local command? ", buf))
X		return;
X	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
X	signal(SIGINT, SIG_IGN);
X	signal(SIGQUIT, SIG_IGN);
X	ioctl(0, TIOCSETC, &defchars);
X	read(repdes[0], (char *)&ccc, 1);
X	/*
X	 * Set up file descriptors in the child and
X	 *  let it go...
X	 */
X	if ((cpid = fork()) < 0)
X		printf("can't fork!\r\n");
X	else if (cpid) {
X		start = time(0);
X		while ((p = wait(&status)) > 0 && p != cpid)
X			;
X	} else {
X		register int i;
X
X		dup2(FD, 1);
X		for (i = 3; i < 20; i++)
X			close(i);
X		signal(SIGINT, SIG_DFL);
X		signal(SIGQUIT, SIG_DFL);
X		execute(buf);
X		printf("can't find `%s'\r\n", buf);
X		exit(0);
X	}
X	if (boolean(value(VERBOSE)))
X		prtime("away for ", time(0)-start);
X	write(fildes[1], (char *)&ccc, 1);
X	ioctl(0, TIOCSETC, &tchars);
X	signal(SIGINT, SIG_DFL);
X	signal(SIGQUIT, SIG_DFL);
X}
X
X#ifdef CONNECT
X/*
X * Fork a program with:
X *  0 <-> local tty in
X *  1 <-> local tty out
X *  2 <-> local tty out
X *  3 <-> remote tty in
X *  4 <-> remote tty out
X */
Xconsh(c)
X{
X	char buf[256];
X	int cpid, status, p;
X	time_t start;
X
X	putchar(c);
X	if (prompt("Local command? ", buf))
X		return;
X	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
X	signal(SIGINT, SIG_IGN);
X	signal(SIGQUIT, SIG_IGN);
X	ioctl(0, TIOCSETC, &defchars);
X	read(repdes[0], (char *)&ccc, 1);
X	/*
X	 * Set up file descriptors in the child and
X	 *  let it go...
X	 */
X	if ((cpid = fork()) < 0)
X		printf("can't fork!\r\n");
X	else if (cpid) {
X		start = time(0);
X		while ((p = wait(&status)) > 0 && p != cpid)
X			;
X	} else {
X		register int i;
X
X		dup2(FD, 3);
X		dup2(3, 4);
X		for (i = 5; i < 20; i++)
X			close(i);
X		signal(SIGINT, SIG_DFL);
X		signal(SIGQUIT, SIG_DFL);
X		execute(buf);
X		printf("can't find `%s'\r\n", buf);
X		exit(0);
X	}
X	if (boolean(value(VERBOSE)))
X		prtime("away for ", time(0)-start);
X	write(fildes[1], (char *)&ccc, 1);
X	ioctl(0, TIOCSETC, &tchars);
X	signal(SIGINT, SIG_DFL);
X	signal(SIGQUIT, SIG_DFL);
X}
X#endif
X
X#ifdef TIPX
X/*
X * filexfer_help
X *
X * Display help for ~X
X *   type = 0, general help, 1 = send help, 2 = receive help
X */
Xfilexfer_help(type)
Xint type;
X{
Xstatic char *ghelp[] =
X{
X	"for send help, type ~Xs?; for receive help, type ~Xr?",
X	"where ~ represents your escape character",
X	(char *)0,
X};
Xstatic char *shelp[] =
X{
X	"XMODEM (CHK, CRC) and XMODEM-1k/CRC",
X	"sx [-ak] filename  -a (ASCII) convert NL to CR/LF (default binary)",
X	"                   -k use 1024 blocks instead of 128 (XMODEM-1k)",
X	"YMODEM/CRC Batch",
X	"sy [-af] filelist  -a (ASCII) convert NL to CR/LF (default binary)",
X    "                   -f transfer using full pathanme (default simple)",
X	"ZMODEM (CRC-16, CRC-32)",
X	"sz [-af+nNyrwo] [-w #] [-L #] [-l #]  filelist",
X    "                   -a (ASCII) convert NL to CR/LF (default binary)",
X    " not all ZMODEM    -f transfer using full pathanme (default simple)",
X	" receivers accept  -+ Append to existing destination file",
X	" all overwrite     -n overwrite file if source newer",
X	" or append         -N overwrite file if source newer or longer",
X	" options           -y yes, absolutely overwrite existing file",
X	"                   -r Resume/Recover interrupted file transfer",
X	"                   -o use CRC-16 instead of CRC-32",
X	"                   -w # Window is # bytes (>= 256, multiple of 64)",
X	"                   -L # Limit subpacket length to # bytes",
X	"                   -l # Limit frame length to # bytes (l must >= L)",
X	(char *)0
X};
Xstatic char *rhelp[] =
X{
X	"XMODEM (CHK, CRC) (rcvr tries CRC, then checksum)",
X	"                          rx [-ab] filename",
X	"YMODEM/CRC Batch          ry [-abu]",
X	"ZMODEM (CRC-16, CRC-32)   rz [-abu]",
X	"Switches:    -a force ASCII translation on receive",
X	"             -b force binary transfer",
X	"             -u convert uppercase filenames to lower case",
X	(char *)0
X};
Xchar **hh;
X
X	switch(type)
X	{
X		case 0:  hh = ghelp; break;
X		case 1:  hh = shelp; break;
X		case 2:  hh = rhelp; break;
X	}
X	while(*hh)
X	{
X		fputs(*hh++,stdout);
X		fputs("\r\n",stdout);
X	}
X}
X#endif /* TIPX */
X
X#ifdef TIPX
X/*
X * filexfer
X *
X * Fork a file transfer with:
X *  0 <-> local tty in
X *  1 <-> local tty out
X *  2 <-> local tty out
X *  FD <-> remote tty in/out
X */
Xfilexfer(c)
X{
X	char buf[256];
X	char xcmd[256+24];
X	int cpid, status, p;
X	time_t start;
X
X	putchar(c);
X	if(prompt("\r\nfile transfer command? (? for help) ", buf))
X		return;
X	if(!strncmp(buf,"sz ",3))
X		sprintf(xcmd,"tipsz -Z -. %d ",FD);
X	else if(!strncmp(buf,"sy ",3))
X		sprintf(xcmd,"tipsz -Y -k -. %d ",FD);
X	else if(!strncmp(buf,"sx ",3))
X		sprintf(xcmd,"tipsz -X -. %d ",FD);
X	else if(!strncmp(buf,"rz",2))
X		sprintf(xcmd,"tiprz -Z -. %d ",FD);
X	else if(!strncmp(buf,"ry",2))
X		sprintf(xcmd,"tiprz -Y -. %d ",FD);
X	else if(!strncmp(buf,"rx ",3))
X		sprintf(xcmd,"tiprz -X -. %d ",FD);
X	else if(!strncmp(buf,"?",1))
X	{
X		filexfer_help(0);
X		return;
X	}
X	else if(!strncmp(buf,"s?",2))
X	{
X		filexfer_help(1);
X		return;
X	}
X	else if(!strncmp(buf,"r?",2))
X	{
X		filexfer_help(2);
X		return;
X	}
X	else
X	{
X		printf("unrecognized transfer command (use sz, rz, etc.)\r\n");
X		return;
X	}
X	strcat(xcmd,buf + 3);
X
X	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
X	signal(SIGINT, SIG_IGN);
X	signal(SIGQUIT, SIG_IGN);
X	unraw();
X	read(repdes[0], (char *)&ccc, 1);
X	if ((cpid = vfork()) < 0)
X		printf("can't fork!\r\n");
X	else if (cpid) {
X		start = time(0);
X		while ((p = wait(&status)) > 0 && p != cpid)
X			;
X	} else {
X		register int i;
X
X		for (i = 3; i < 20; i++)
X		{
X			if(i != FD)
X				close(i);
X		}
X		signal(SIGINT, SIG_DFL);
X		signal(SIGQUIT, SIG_DFL);
X		user_uid();
X		execl("/bin/sh", "sh", "-c", xcmd, (char *)0);
X		printf("can't execute `%s'\n", xcmd);
X		perror("execl");
X		exit(0);
X	}
X	prtime("away for ", time(0)-start);
X	write(fildes[1], (char *)&ccc, 1);
X	raw();
X	signal(SIGINT, SIG_DFL);
X	signal(SIGQUIT, SIG_DFL);
X}
X#endif
X
X/*
X * Escape to local shell
X */
Xshell()
X{
X	int shpid, status;
X	extern char **environ;
X	char *cp;
X
X	printf("[sh]\r\n");
X	signal(SIGINT, SIG_IGN);
X	signal(SIGQUIT, SIG_IGN);
X	unraw();
X	if (shpid = fork()) {
X		while (shpid != wait(&status));
X		raw();
X		printf("\r\n!\r\n");
X		signal(SIGINT, SIG_DFL);
X		signal(SIGQUIT, SIG_DFL);
X		return;
X	} else {
X		signal(SIGQUIT, SIG_DFL);
X		signal(SIGINT, SIG_DFL);
X		if ((cp = rindex(value(SHELL), '/')) == NULL)
X			cp = value(SHELL);
X		else
X			cp++;
X		shell_uid();
X		execl(value(SHELL), cp, 0);
X		printf("\r\ncan't execl!\r\n");
X		exit(1);
X	}
X}
X
X/*
X * TIPIN portion of scripting
X *   initiate the conversation with TIPOUT
X */
Xsetscript()
X{
X	char c;
X	/*
X	 * enable TIPOUT side for dialogue
X	 */
X	kill(pid, SIGEMT);
X	if (boolean(value(SCRIPT)))
X		write(fildes[1], value(RECORD), size(value(RECORD)));
X	write(fildes[1], "\n", 1);
X	/*
X	 * wait for TIPOUT to finish
X	 */
X	read(repdes[0], &c, 1);
X	if (c == 'n')
X		printf("can't create %s\r\n", value(RECORD));
X}
X
X/*
X * Change current working directory of
X *   local portion of tip
X */
Xchdirectory()
X{
X	char dirname[80];
X	register char *cp = dirname;
X
X	if (prompt("[cd] ", dirname)) {
X		if (stoprompt)
X			return;
X		cp = value(HOME);
X	}
X	if (chdir(cp) < 0)
X		printf("%s: bad directory\r\n", cp);
X	printf("!\r\n");
X}
X
Xabort(msg)
X	char *msg;
X{
X
X	kill(pid, SIGTERM);
X	disconnect(msg);
X	if (msg != NOSTR)
X		printf("\r\n%s", msg);
X	printf("\r\n[EOT]\r\n");
X	daemon_uid();
X	(void)uu_unlock(uucplock);
X	unraw();
X	exit(0);
X}
X
Xfinish()
X{
X	char *dismsg;
X
X	if ((dismsg = value(DISCONNECT)) != NOSTR) {
X		write(FD, dismsg, strlen(dismsg));
X		sleep(5);
X	}
X	abort(NOSTR);
X}
X
Xsigfunc_t
Xintcopy()
X{
X
X	raw();
X	quit = 1;
X	longjmp(intbuf, 1);
X}
X
Xexecute(s)
X	char *s;
X{
X	register char *cp;
X
X	if ((cp = rindex(value(SHELL), '/')) == NULL)
X		cp = value(SHELL);
X	else
X		cp++;
X	user_uid();
X	execl(value(SHELL), cp, "-c", s, 0);
X}
X
Xargs(buf, a)
X	char *buf, *a[];
X{
X	register char *p = buf, *start;
X	register char **parg = a;
X	register int n = 0;
X
X	do {
X		while (*p && (*p == ' ' || *p == '\t'))
X			p++;
X		start = p;
X		if (*p)
X			*parg = p;
X		while (*p && (*p != ' ' && *p != '\t'))
X			p++;
X		if (p != start)
X			parg++, n++;
X		if (*p)
X			*p++ = '\0';
X	} while (*p);
X
X	return(n);
X}
X
Xprtime(s, a)
X	char *s;
X	time_t a;
X{
X	register i;
X	int nums[3];
X
X	for (i = 0; i < 3; i++) {
X		nums[i] = (int)(a % quant[i]);
X		a /= quant[i];
X	}
X	printf("%s", s);
X	while (--i >= 0)
X		if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0)
X			printf("%d %s%c ", nums[i], sep[i],
X				nums[i] == 1 ? '\0' : 's');
X	printf("\r\n!\r\n");
X}
X
Xvariable()
X{
X	char	buf[256];
X
X	if (prompt("[set] ", buf))
X		return;
X	vlex(buf);
X	if (vtable[BEAUTIFY].v_access&CHANGED) {
X		vtable[BEAUTIFY].v_access &= ~CHANGED;
X		kill(pid, SIGSYS);
X	}
X	if (vtable[SCRIPT].v_access&CHANGED) {
X		vtable[SCRIPT].v_access &= ~CHANGED;
X		setscript();
X		/*
X		 * So that "set record=blah script" doesn't
X		 *  cause two transactions to occur.
X		 */
X		if (vtable[RECORD].v_access&CHANGED)
X			vtable[RECORD].v_access &= ~CHANGED;
X	}
X	if (vtable[RECORD].v_access&CHANGED) {
X		vtable[RECORD].v_access &= ~CHANGED;
X		if (boolean(value(SCRIPT)))
X			setscript();
X	}
X	if (vtable[TAND].v_access&CHANGED) {
X		vtable[TAND].v_access &= ~CHANGED;
X		if (boolean(value(TAND)))
X			tandem("on");
X		else
X			tandem("off");
X	}
X 	if (vtable[LECHO].v_access&CHANGED) {
X 		vtable[LECHO].v_access &= ~CHANGED;
X 		HD = boolean(value(LECHO));
X 	}
X	if (vtable[PARITY].v_access&CHANGED) {
X		vtable[PARITY].v_access &= ~CHANGED;
X		setparity();
X	}
X}
X
X/*
X * Turn tandem mode on or off for remote tty.
X */
Xtandem(option)
X	char *option;
X{
X	struct sgttyb rmtty;
X
X	ioctl(FD, TIOCGETP, &rmtty);
X	if (strcmp(option,"on") == 0) {
X		rmtty.sg_flags |= TANDEM;
X		arg.sg_flags |= TANDEM;
X	} else {
X		rmtty.sg_flags &= ~TANDEM;
X		arg.sg_flags &= ~TANDEM;
X	}
X	ioctl(FD, TIOCSETP, &rmtty);
X	ioctl(0,  TIOCSETP, &arg);
X}
X
X/*
X * Send a break.
X */
Xgenbrk()
X{
X
X	ioctl(FD, TIOCSBRK, NULL);
X	sleep(1);
X	ioctl(FD, TIOCCBRK, NULL);
X}
X
X/*
X * Send a ^S.
X */
X#ifdef TIPX
Xgenctls()
X{
Xstatic char ctls = 0x13;
X
X	printf("^S");
X	write(FD, &ctls, 1);
X}
X#endif
X
X/*
X * Send a ^Q.
X */
X#ifdef TIPX
Xgenctlq()
X{
Xstatic char ctlq = 0x11;
X
X	printf("^Q");
X	write(FD, &ctlq, 1);
X}
X#endif
X
X/*
X * control rawthru mode
X */
X#ifdef TIPX
Xrawthru_control(gch)
Xchar gch;
X{
Xextern int rawthru;
X	gch &= 0177;
X	write(2,&gch,1);
X	if(gch == 'R')
X	{
X		rawthru = 1;
X		kill(pid,SIGUSR1);
X	}
X	else
X	{
X		rawthru = 0;
X		kill(pid,SIGUSR2);
X	}
X}
X#endif
X
X/*
X * Suspend tip
X */
Xsuspend(c)
X	char c;
X{
X
X	unraw();
X	kill(c == CTRL('y') ? getpid() : 0, SIGTSTP);
X	raw();
X}
X
X/*
X *	expand a file name if it includes shell meta characters
X */
X
Xchar *
Xexpand(name)
X	char name[];
X{
X	static char xname[BUFSIZ];
X	char cmdbuf[BUFSIZ];
X	register int pid, l;
X	register char *cp, *Shell;
X	int s, pivec[2];
X
X	if (!anyof(name, "~{[*?$`'\"\\"))
X		return(name);
X	if (pipe(pivec) < 0) {
X		perror("pipe");
X		/* signal(SIGINT, sigint) */
X		return(name);
X	}
X	sprintf(cmdbuf, "echo %s", name);
X	if ((pid = vfork()) == 0) {
X		Shell = value(SHELL);
X		if (Shell == NOSTR)
X			Shell = "/bin/sh";
X		close(pivec[0]);
X		close(1);
X		dup(pivec[1]);
X		close(pivec[1]);
X		close(2);
X		shell_uid();
X		execl(Shell, Shell, "-c", cmdbuf, 0);
X		_exit(1);
X	}
X	if (pid == -1) {
X		perror("fork");
X		close(pivec[0]);
X		close(pivec[1]);
X		return(NOSTR);
X	}
X	close(pivec[1]);
X	l = read(pivec[0], xname, BUFSIZ);
X	close(pivec[0]);
X	while (wait(&s) != pid);
X		;
X	s &= 0377;
X	if (s != 0 && s != SIGPIPE) {
X		fprintf(stderr, "\"Echo\" failed\n");
X		return(NOSTR);
X	}
X	if (l < 0) {
X		perror("read");
X		return(NOSTR);
X	}
X	if (l == 0) {
X		fprintf(stderr, "\"%s\": No match\n", name);
X		return(NOSTR);
X	}
X	if (l == BUFSIZ) {
X		fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
X		return(NOSTR);
X	}
X	xname[l] = 0;
X	for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
X		;
X	*++cp = '\0';
X	return(xname);
X}
X
X/*
X * Are any of the characters in the two strings the same?
X */
X
Xanyof(s1, s2)
X	register char *s1, *s2;
X{
X	register int c;
X
X	while (c = *s1++)
X		if (any(c, s2))
X			return(1);
X	return(0);
X}
END_OF_FILE
if test 21091 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/cmds.c'`; then
    echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/cmds.c'\" unpacked with wrong size!
fi
# end of 'pf-bootstrap-v1.1a/tipx-p1/cmds.c'
fi
if test -f 'pf-bootstrap-v1.1a/xmodem-3.9/README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/xmodem-3.9/README'\"
else
echo shar: Extracting \"'pf-bootstrap-v1.1a/xmodem-3.9/README'\" \(21493 characters\)
sed "s/^X//" >'pf-bootstrap-v1.1a/xmodem-3.9/README' <<'END_OF_FILE'
XThis is version 3.9 (circa 11/90) of the xmodem program which incorporates
Xa few bugfixes (one important!) and some enhancements: 1) status messages
Xwhen running xmodem through Sun's tip program ("p" flag); 2) delayed
Xstartup (via the "w" flag); 3) ability to turn off EOT verification (via
X"e" flag); 4) ability to allow CAN-CAN abort in the midst of a file
Xtransfer (via "n"  flag) and 5) YMODEM-G support (via the "g" flag).  See
Xupdate.doc for details. 
X
X--------------------------------------------------------------------------------
X
XThis is version 3.8 (circa 11/88) of the xmodem program which incorporates
Xminor enhancements over version 3.7 which incoporates minor enhancements
Xover version 3.6.  See update.doc. 
X
X--------------------------------------------------------------------------------
X
XThis is version 3.6 (finished 4/88) of the xmodem program which includes a
Xfew bugfixes and some enhancements (requested by Macintosh users)
Xstimulated by the xmodem release through comp.sources.unix.  See the file
Xupdate.doc for details. 
X
X--------------------------------------------------------------------------------
X
XThis is version 3.4 (finished 10/87) of the xmodem program, a full-featured
XXMODEM implementation for 4.3BSD.  Since the previous release (version
X3.2, see volume 7 of the archives), substantial improvements have been
Xmade. See the file update.doc for details.  Also, some attempt has been
Xmade to support SysV Unix systems; see below.
X
XAs far as I am concerned, this program has reached the end of its evolution.
XNewer protocols (such as ZMODEM) will not be incorporated into xmodem.  Check
Xout Chuck Forsberg's rz/sz programs if you are interested in ZMODEM.
X
X--------------------------------------------------------------------------------
X
XThe xmodem program implements the Christensen (XMODEM) file transfer
Xprotocol for moving files between 4.2/4.3BSD Unix systems and microcomputers.
XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K
Xblock protocol and the YMODEM batch protocol are all supported by xmodem.
XFor details of the protocols, see the document edited by Chuck Forsberg titled
XXMODEM/YMODEM Protocol Reference (the latest version is dated 6-18-88).
X
XThis program runs on 4.2/4.3BSD systems ONLY.  It has been tested on VAXes
Xand Suns against the MEX-PC program from Niteowl Software and the ZCOMM and
XDSZ programs from Omen Technology.
X
XI have tried to keep the 4.2isms (select system call, 4.2BSD/v7 tty structures,
Xgettimeofday system call, etc.) confined to the source file getput.c; but I 
Xmake no guarantees.  Also, I have made no attempt to keep variable names 
Xunder 7 characters.  A version of getput.c that MAY work on Sys V Unix
Xsystems is included.
X
X--------------------------------------------------------------------------------
X
XThanks to Emmet Gray (ihnp4!uiucuxc!fthood!egray) and John Rupley 
X(arizona!rupley!root) for the following notes about converting xmodem to Sys V.
XSince I don't have a Sys V system to test a Sys V version, I won't even try.
X
X1) Change the includes in xmodem.h from <sys/time.h> to <time.h>
X   and from <sgtty.h> to <termio.h>
X
X2) Convert the occurrences of rindex to strrchr in batch.c
X
X3) Substitute getput.sysv.c for getput.c
X
XA further "gotcha" regarding Sys V is contained in the following message :
X
XFrom: Bill Stubblebine <hplsdls!was@hp-lsd.UUCP>
XDate: Sat, 25 Jun 88 13:36:20 mdt
XTo: grandi@noao.arizona.edu
XSubject: xmodem3.6 bug, fix and THANKS!!
X
X						1:30 PM MDT
X						June 25, 1988
X
XFirst, thanks for posting a really useful program, xmodem 3.6.
X
XI installed the xmodem program on an HP 9000 Series 350 workstation,
Xrunning HP-UX version 6.01 (AT&T System V compatible) to talk to my
XCP/M system at home.  MODEM7 batch is particularly useful.
X
XI'd like to report a bug I found and the fix I developed in the source
Xfile getput.sysv.c so that you can include it in future releases.
X
XI've reproduced the relevant portion of getput.sysv.c, modified to fix
Xthe bug, at the end of this file.  See the routine getspeed() starting
Xat line 382.  Getspeed() derives the serial port speed from the
Xc_cflag ioctl parameter, for use in estimating transmission times.
X
XI suspected something was wrong when xmodem kept reporting 1200 baud
Xmodem connections as 1800 baud in the log file, but the transfers
Xstill worked OK at 1200 baud.  However, I also have a Courier HST 9600
Xbaud modem at home, and when I tried 9600 baud xmodem transfers,
Xxmodem would core dump on the UNIX host.
X
XOn line 386 of getput.sysv.c, in the procedure getspeed(), an array is
Xdeclared containing numerical constants representing the various baud
Xrates supported by the host terminal interface.  The appropriate baud
Xrate constant is selected by the statements in lines 392-394, which
Xmask the c_cflag baud rate bitfield to index into the speedtbl[]
Xarray.
X
XThere are two problems here.  The first problem is that speedtbl[] is
Xmissing some valid baud rate entries, as the modified declaration
Xshows.  I got the entries for the modified declaration from the
Xtermio(7) manpage in my System V user's manual.  The missing entries
Xthrow off the indexing arithmetic.  Notice, for example, that the
Xmissing entry 900 was responsible for mapping the c_cflag bits for
X1200 baud to the 1800 baud constant.
X
XOriginal declaration:
X  static int speedtbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600,
X  1200, 1800, 2400, 4800, 9600, 19200, 0};
X
XModified declaration:
X  static int speedtbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600,
X  900, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19200, 38400, 0};
X  ^^^                    ^^^^        ^^^^        ^^^^^  ^^^^^
X
XThe second problem didn't show up until I used 9600 baud.  The c_cflag
Xbitfield value for 9600 baud is 16 decimal (020 octal).  The masking
Xconstant in lines 392-394 was originally 017 octal, which masked the
X9600 baud bitfield to 0, indexing to the speedtbl[] value of 0.  Speed
Xcalculations using a baudrate of 0 caused floating point exceptions
Xleading to the host core dumps at 9600 baud.
X
XI changed the mask value from 017 octal to 037 octal (which is
Xactually the size of the c_cflag baudrate field), and changed the
Xlimit test in line 392 from 14 to 18, the new correct number of
Xelements in the speedtbl[] array.
X
XI'm not familiar with 4.2BSD, but I noticed that getput.c, the 4.2BSD
Xversion of the I/O routines, contains virtually the same code for
Xdetermining the baudrate as that in getput.sysv.c.  It may be OK for
X4.2BSD, but definitely not for System V.
X
XThe modified code now works great at all baud rates!  Thanks again for
Xposting the program.
X
X                                Bill Stubblebine
X                                Hewlett-Packard Logic Systems Div.
X				8245 N. Union Blvd.
X                                Colorado Springs, Co. 80918
X				ARPA: was%hp-lsd@hplabs.hp.com
X				UUCP: {hplabs,hpfcla}!{hpldola,hp-lsd}!was
X
X--------------------------------------------------------------------------------
X
XA common request to me concerns running xmodem through tip in order to do
XXMODEM or YMODEM transfers.  I have discovered that SunOS has a nice
Xfeature in tip (accessed through ~C) that connects a named program to a
Xremote machine.  It turns out that 4.3BSD tip has a similar (but
Xundocumented) feature, but far less convenient: SunOS tip connects file
Xdescriptor 0 of the program to the remote line input and file descriptor 1
Xto remote line output while 4.3BSD connects up file descriptors 3 and 4! 
X
XIf you would like to use xmodem through 4.3BSD tip, the following message
Xshould be of interest (note that the patches given below are against an old
Xversion of the source):
X
XTo: grandi@noao.edu (Steve Grandi CCS)
XSubject: Re: xmodem 
XDate: Tue, 02 Jan 90 12:34:58 -0500
XFrom: Benson I. Margulies <benson@odi.com>
X
X
X    Yes, I would like to receive the changes!
X
X    Steve, grandi@noao.edu
X
XOK, here are the diffs. I've tested them in receive mode,
Xbut I haven't been able to verify that they work for sending.
XThe reason why is a long sob story.
X
XIt would be good to do two additional things:
X
X1) add some \r's to the messages printed.
X2) when in tip mode, print more messages on stdout
Xto report progress, like a . every 100 blocks.
X
XRCS file: RCS/xmodem.c,v
Xretrieving revision 1.1
Xretrieving revision 1.2
Xdiff -c -r1.1 -r1.2
X*** /tmp/,RCSt1a02154	Tue Jan  2 12:33:12 1990
X--- /tmp/,RCSt2a02154	Tue Jan  2 12:33:12 1990
X***************
X*** 52,57 ****
X--- 52,60 ----
X  	MDM7BAT = FALSE;	/* no MODEM7 batch mode */
X  	YMDMBAT = FALSE;	/* no YMODEM batch mode */
X  	TOOBUSY = FALSE;	/* not too busy for sleeping in packet read */
X+ 	INFD = 0;
X+ 	OUTFD = 1;
X+ 	FDS_DISTINCT = 0;
X  
X  	fprintf(stderr, "XMODEM Version %d.%d", VERSION/10, VERSION%10);
X  	fprintf(stderr, " -- UNIX-Microcomputer Remote File Transfer Facility\n");
X***************
X*** 101,106 ****
X--- 104,115 ----
X  		case 's' : SENDFLAG = TRUE;  /* send file */
X  			   XMITTYPE = gettype(argv[1][index++]);
X  			   break;
X+ 		case 'p':  /* TIP */
X+ 		case 'P':
X+ 		           INFD = 3;
X+ 			   OUTFD = 4;
X+ 			   FDS_DISTINCT = TRUE;
X+ 			   break;
X  		default  : fprintf(stderr, "Invalid Flag %c ignored\n", flag);
X  			   break;
X  	   }
X***************
X*** 120,133 ****
X  		LOGFP = fopen(fname, "w");  /* new LOG file */
X  	     if (!LOGFP)
X  		error("Fatal - Can't Open Log File", FALSE);
X  
X  	     fprintf(LOGFP,"\n++++++++  %s", stamptime());
X  	     fprintf(LOGFP,"XMODEM Version %d.%d\n", VERSION/10, VERSION%10);
X  	     fprintf(LOGFP,"Command line: %s %s", argv[0], argv[1]);
X! 	     for (index=2; index<argc; ++index)
X! 		fprintf(LOGFP, " %s", argv[index]);
X  	     fprintf(LOGFP, "\n");
X! 	   }
X  
X  	getspeed();		/* get tty-speed for time estimates */
X  
X--- 129,147 ----
X  		LOGFP = fopen(fname, "w");  /* new LOG file */
X  	     if (!LOGFP)
X  		error("Fatal - Can't Open Log File", FALSE);
X+ 	     setlinebuf(LOGFP);
X  
X  	     fprintf(LOGFP,"\n++++++++  %s", stamptime());
X+ 		 
X  	     fprintf(LOGFP,"XMODEM Version %d.%d\n", VERSION/10, VERSION%10);
X+ 
X  	     fprintf(LOGFP,"Command line: %s %s", argv[0], argv[1]);
X! 
X! 	     for (index=2; index<argc; ++index) {
X! 		 fprintf(LOGFP, " %s", argv[index]);
X! 	     }
X  	     fprintf(LOGFP, "\n");
X! 	 }
X  
X  	getspeed();		/* get tty-speed for time estimates */
X  
X===================================================================
XRCS file: RCS/xmodem.h,v
Xretrieving revision 1.1
Xretrieving revision 1.2
Xdiff -c -r1.1 -r1.2
X*** /tmp/,RCSt1a02154	Tue Jan  2 12:33:13 1990
X--- /tmp/,RCSt2a02154	Tue Jan  2 12:33:14 1990
X***************
X*** 10,16 ****
X  #define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
X  #define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
X  
X! #define	     VERSION	36	/* Version Number */
X  #define      FALSE      0
X  #define      TRUE       1
X  
X--- 10,16 ----
X  #define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
X  #define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
X  
X! #define	     VERSION	37	/* Version Number */
X  #define      FALSE      0
X  #define      TRUE       1
X  
X***************
X*** 73,78 ****
X--- 73,81 ----
X  int	YMDMBAT;	/* YMODEM batch protocol */
X  int	TOOBUSY;	/* turn off sleeping in packet read routine */
X  int	CHECKLENGTH;	/* Are we truncating a file to a YMODEM length? */
X+ int 	INFD;		/* file descriptor for protocol reading */
X+ int	OUTFD;		/* file descriptor for protocol reading */
X+ int     FDS_DISTINCT;   /* in,out fd's not 0 and 1 */
X  
X  
X  /*   CRC-16 constants.  From Usenet contribution by Mark G. Mendel, 
X===================================================================
XRCS file: RCS/getput.c,v
Xretrieving revision 1.1
Xretrieving revision 1.2
Xdiff -c -r1.1 -r1.2
X*** /tmp/,RCSt1a02154	Tue Jan  2 12:33:14 1990
X--- /tmp/,RCSt2a02154	Tue Jan  2 12:33:15 1990
X***************
X*** 4,9 ****
X--- 4,10 ----
X   */
X  
X  #include "xmodem.h"
X+ #include <sys/types.h>
X  
X  /*
X   *
X***************
X*** 103,113 ****
X  /* get a byte from data stream -- timeout if "seconds" elapses */
X  /* This routine is VERY 4.2 specific */
X  
X  int
X  readbyte(seconds)
X  int seconds;
X  	{
X- 	int readfd;
X  	char c;
X  	struct timeval tmout;
X  
X--- 104,122 ----
X  /* get a byte from data stream -- timeout if "seconds" elapses */
X  /* This routine is VERY 4.2 specific */
X  
X+ int select_input (tmout)
X+ struct timeval * tmout;
X+ {
X+     fd_set readfd;		/* mask for select call */
X+     FD_ZERO(&readfd);
X+     FD_SET(INFD, &readfd);
X+     return select(getdtablesize(), &readfd, (int *)0, (int *)0, tmout);
X+ }
X+ 
X  int
X  readbyte(seconds)
X  int seconds;
X  	{
X  	char c;
X  	struct timeval tmout;
X  
X***************
X*** 114,125 ****
X  	tmout.tv_sec = seconds;
X  	tmout.tv_usec = 0;
X  
X- 	readfd = 1<<0;
X  
X! 	if ((select(1, &readfd, (int *)0, (int *)0, &tmout)) == 0)
X! 		return(TIMEOUT);
X  
X! 	read(0, &c, 1);
X  
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: readbyte %02xh\n", c & 0xff);
X--- 123,133 ----
X  	tmout.tv_sec = seconds;
X  	tmout.tv_usec = 0;
X  
X  
X! 	if (select_input(&tmout) == 0)
X! 	    return(TIMEOUT);
X  
X! 	read(INFD, &c, 1);
X  
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: readbyte %02xh\n", c & 0xff);
X***************
X*** 138,151 ****
X  	/* set up a usec timeout on stdin */
X  	tmout.tv_sec = 0;
X  	tmout.tv_usec = 1;
X! 	readfd = 1<<0;
X  
X  	/* any characters pending?; return if none */
X! 	if ((select(1, &readfd, (int *)0, (int *)0, &tmout)) == 0)
X! 		return;
X  
X  	/* read the characters to flush them (assume there are fewer than BBUFSIZ */
X! 	(void) read(0, inbuf, BBUFSIZ);
X  	}
X--- 146,159 ----
X  	/* set up a usec timeout on stdin */
X  	tmout.tv_sec = 0;
X  	tmout.tv_usec = 1;
X! 	readfd = 1<<INFD;
X  
X  	/* any characters pending?; return if none */
X! 	if (select_input(&tmout) == 0)
X! 	    return;
X  
X  	/* read the characters to flush them (assume there are fewer than BBUFSIZ */
X! 	(void) read(INFD, inbuf, BBUFSIZ);
X  	}
X***************
X*** 170,181 ****
X  long recvsectcnt;	/* running sector count (128 byte sectors) */
X  
X  {
X- 	int readfd;		/* mask for select call */
X- 	struct timeval tmout;	/* timeout structure for select */
X  	int numread;		/* number of chars read */
X  	int left;		/* number of chars left to read */
X  	int recfin = FALSE;		/* flag that EOF read */
X  	char inbuf[BBUFSIZ];	/* buffer for incoming packet */
X  	register unsigned char c;	/* character being processed */
X  	register unsigned short chksm;	/* working copy of checksum */
X  	register int bfctr;	/* working copy of bufctr */
X--- 178,188 ----
X  long recvsectcnt;	/* running sector count (128 byte sectors) */
X  
X  {
X  	int numread;		/* number of chars read */
X  	int left;		/* number of chars left to read */
X  	int recfin = FALSE;		/* flag that EOF read */
X  	char inbuf[BBUFSIZ];	/* buffer for incoming packet */
X+ 	struct timeval tmout;	/* timeout structure for select */
X  	register unsigned char c;	/* character being processed */
X  	register unsigned short chksm;	/* working copy of checksum */
X  	register int bfctr;	/* working copy of bufctr */
X***************
X*** 184,190 ****
X  
X  	tmout.tv_sec = seconds;
X  	tmout.tv_usec = 0;
X- 	readfd = 1<<0;
X  	chksm = 0;
X  	bfctr = 0;
X  
X--- 191,196 ----
X***************
X*** 192,201 ****
X  
X  		/* read however many chars are waiting */
X  
X! 		if ((select(1, &readfd, (int *)0, (int *)0, &tmout)) == 0)
X! 			return(TIMEOUT);
X  
X! 		numread = read(0, inbuf, left);
X  		left -= numread;
X  
X  		if (DEBUG)
X--- 198,207 ----
X  
X  		/* read however many chars are waiting */
X  
X! 		if (select_input(&tmout) == 0)
X! 		    return(TIMEOUT);
X  
X! 		numread = read(INFD, inbuf, left);
X  		left -= numread;
X  
X  		if (DEBUG)
X***************
X*** 275,281 ****
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: sendbyte %02xh\n", data & 0xff);
X  
X! 	if (write(1, &data, 1) != 1)  	/* write the byte (assume it goes NOW; no flushing needed) */
X  		error ("Write error on stream", TRUE);
X  	return;
X  	}
X--- 281,287 ----
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: sendbyte %02xh\n", data & 0xff);
X  
X! 	if (write(OUTFD, &data, 1) != 1)  	/* write the byte (assume it goes NOW; no flushing needed) */
X  		error ("Write error on stream", TRUE);
X  	return;
X  	}
X***************
X*** 289,295 ****
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: writebuf (%d bytes)\n", nbytes);
X  
X! 	if (write(1, buffer, nbytes) != nbytes)		/* write the buffer (assume no TIOCFLUSH needed) */
X  		error ("Write error on stream", TRUE);
X  	return;
X  	}
X--- 295,301 ----
X  	if (DEBUG)
X  		fprintf(LOGFP, "DEBUG: writebuf (%d bytes)\n", nbytes);
X  
X! 	if (write(OUTFD, buffer, nbytes) != nbytes)		/* write the buffer (assume no TIOCFLUSH needed) */
X  		error ("Write error on stream", TRUE);
X  	return;
X  	}
X***************
X*** 302,308 ****
X  int	milliseconds;
X  {
X  	struct	timeval	timeout;
X- 	int readfd;
X  
X  	if (milliseconds == 0)
X  		return;
X--- 308,313 ----
X***************
X*** 310,318 ****
X  		fprintf (LOGFP, "DEBUG: napping for %d ms\n", milliseconds);
X  	timeout.tv_sec = 0;
X  	timeout.tv_usec = milliseconds * 1000;
X- 	readfd = 0;
X  
X! 	(void) select(1, &readfd, (int *)0, (int *)0, &timeout);
X  }
X--- 315,322 ----
X  		fprintf (LOGFP, "DEBUG: napping for %d ms\n", milliseconds);
X  	timeout.tv_sec = 0;
X  	timeout.tv_usec = milliseconds * 1000;
X  
X! 	(void) select(0, (int *)0, (int *)0, (int *)0, &timeout);
X  }
X***************
X*** 335,344 ****
X  	extern onintr();
X  
X  	sleep(2);			/* let the output appear */
X! 	if (ioctl(0,TIOCGETP,&ttys)<0)  /* get tty params [V7] */
X  		error("Can't get TTY Parameters", TRUE);
X  
X! 	tty = ttyname(0);  /* identify current tty */
X  	
X  	ttysnew.sg_ispeed = ttys.sg_ispeed;	/* copy input speed */
X  	ttysnew.sg_ospeed = ttys.sg_ospeed;	/* copy input speed */
X--- 339,348 ----
X  	extern onintr();
X  
X  	sleep(2);			/* let the output appear */
X! 	if (ioctl(INFD,TIOCGETP,&ttys)<0)  /* get tty params [V7] */
X  		error("Can't get TTY Parameters", TRUE);
X  
X! 	tty = ttyname(INFD);  /* identify current tty */
X  	
X  	ttysnew.sg_ispeed = ttys.sg_ispeed;	/* copy input speed */
X  	ttysnew.sg_ospeed = ttys.sg_ospeed;	/* copy input speed */
X***************
X*** 347,358 ****
X  	ttysnew.sg_flags &= ~TANDEM;	/* turn off flow control */
X  
X  	/* set new paramters */
X! 	if (ioctl(0,TIOCSETP,&ttysnew) < 0)
X  		error("Can't set new TTY Parameters", TRUE);
X  
X  	/* Flush characters waiting for read or write */
X  	n = 0;
X! 	if (ioctl(0,TIOCFLUSH,&n) < 0)
X  		error("Can't flush terminal queue", TRUE);
X  
X  	/* get tty status */ 
X--- 351,362 ----
X  	ttysnew.sg_flags &= ~TANDEM;	/* turn off flow control */
X  
X  	/* set new paramters */
X! 	if (ioctl(INFD,TIOCSETP,&ttysnew) < 0)
X  		error("Can't set new TTY Parameters", TRUE);
X  
X  	/* Flush characters waiting for read or write */
X  	n = 0;
X! 	if (ioctl(INFD,TIOCFLUSH,&n) < 0)
X  		error("Can't flush terminal queue", TRUE);
X  
X  	/* get tty status */ 
X***************
X*** 381,387 ****
X  	if (wason)
X  		if (chmod(tty, (int)statbuf.st_mode | 022) < 0)
X  			error("Can't change TTY mode", FALSE);
X! 	if (ioctl(0,TIOCSETP,&ttys) < 0)
X  		{ if (!errcall)
X  		   error("RESET - Can't restore normal TTY Params", FALSE);
X  		else
X--- 385,391 ----
X  	if (wason)
X  		if (chmod(tty, (int)statbuf.st_mode | 022) < 0)
X  			error("Can't change TTY mode", FALSE);
X! 	if (ioctl(INFD,TIOCSETP,&ttys) < 0)
X  		{ if (!errcall)
X  		   error("RESET - Can't restore normal TTY Params", FALSE);
X  		else
X***************
X*** 423,429 ****
X  	{
X  	static int speedtbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 
X  	   1200, 1800, 2400, 4800, 9600, 19200, 0};
X! 	if (ioctl(0,TIOCGETP,&ttys) < 0)	/* get tty structure */
X  		error("Can't get TTY parameters", FALSE);
X  
X  	if (ttys.sg_ispeed >= 0 && ttys.sg_ispeed <= 14)
X--- 427,433 ----
X  	{
X  	static int speedtbl[] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 
X  	   1200, 1800, 2400, 4800, 9600, 19200, 0};
X! 	if (ioctl(INFD,TIOCGETP,&ttys) < 0)	/* get tty structure */
X  		error("Can't get TTY parameters", FALSE);
X  
X  	if (ttys.sg_ispeed >= 0 && ttys.sg_ispeed <= 14)
X
X--------------------------------------------------------------------------------
X
Xxmodem Program history:
X
XDescended from UMODEM 3.5 by Lauren Weinstein, Richard Conn, and others.
X
XBased on XMODEM Version 1.0 by Brian Kantor, UCSD (3/84)  (Don't blame him 
X    in any way for what follows....)
X
XVersion 2.0 (CRC-16 and Modem7 batch file transfer) (5/85) (Thanks to D'Anne
X    Thompson for the batch transfer code).
X
XVersion 2.1 (1K packets) (7/85)
X
XVersion 2.2 (general clean-ups and multi-character read speed-ups) (9/85)
X
XVersion 2.3 (nap while reading packets; split into several source files) (1/86)
X
XVersion 3.0 (Ymodem batch receive; associated changes) (2/86)
X
XVersion 3.1 (Ymodem batch send; associated changes) (8/86)
X
XVersion 3.2 (general cleanups) (9/86) 
X    (Released to the world 1/87)
X
XVersion 3.3 (general fixes and cleanups; see update.doc) (5/87)
X
XVersion 3.4 (general fixes and cleanups; see update.doc) (10/87) 
X    (Released to the world 3/88)
X
XVersion 3.5 (general fixes and cleanups; see update.doc) (3/88)
X
XVersion 3.6 (general fixes and cleanups; text file translation for Mac; 
X    see update.doc) (4/88) 
X    (Released to the world 4/88)
X
XVersion 3.7 (general fixes and cleanups; see update.doc) (5/88)
X
XVersion 3.8 (general fixes and cleanups; see update.doc) (11/88)
X
XVersion 3.9 (general fixes and cleanups; Sun tip support; 
X    see update.doc) (11/90)
X
X--------------------------------------------------------------------------------
X
XPlease send bug fixes, additions and comments to:
XSteve Grandi, National Optical Astronomy Observatories (Tucson, Arizona, USA)
X	grandi@noao.edu
END_OF_FILE
if test 21493 -ne `wc -c <'pf-bootstrap-v1.1a/xmodem-3.9/README'`; then
    echo shar: \"'pf-bootstrap-v1.1a/xmodem-3.9/README'\" unpacked with wrong size!
fi
# end of 'pf-bootstrap-v1.1a/xmodem-3.9/README'
fi
echo shar: End of archive 8 \(of 9\).
cp /dev/null ark8isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 9 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0