#! /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 1 (of 4)."
# Contents:  Makefile README crc.1 genie.c gz init.com minirb.1
#   minirb.c ptest.sh rbsb.c vmodem.h vrzsz.c vupl.t vuplfile.t
#   vvmodem.c zmodem.h zmr.c zupl.t
# Wrapped by hankin@sauron on Tue Dec  5 10:22:26 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(2766 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for Unix/Xenix rz and sz programs
X# the makefile is not too well tested yet
XCC=cc
XOFLAG=
X
XTLBFILES= zmodem.h zm.c zmr.c crctab.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c init.com crc.c
X
XARCFILES= $(TLBFILES) README rbsb.c gz ptest.sh *.t minirb.c genie.c *.1
X
Xnothing:
X	@echo
X	@echo "Please study the #ifdef's in crctab.c, rbsb.c, rz.c and sz.c,"
X	@echo "make any necessary hacks for oddball or merged SYSV/BSD systems,"
X	@echo "then type 'make SYSTEM' where SYSTEM is one of:"
X	@echo
X	@echo "	sysvr3	SYSTEM 5.3 Unix with mkdir(2)"
X	@echo "	sysv	SYSTEM 3/5 Unix"
X	@echo "	xenix	Xenix"
X	@echo "	x386	386 Xenix"
X	@echo "	bsd	Berkeley 4.x BSD, Ultrix, V7"
X	@echo
X
Xusenet:unix
X	shar -f /tmp/rzsz README Makefile zmodem.h zm.c sz.c rz.c rbsb.c \
X	 init.com crc.c vmodem.h vvmodem.c vrzsz.c crctab.c minirb.c \
X	 zmr.c *.1 gz ptest.sh *.t
X
Xshar:unix
X	shar -f /tmp/rzsz -m 2000000 README Makefile zmodem.h zm.c \
X	 zmr.c init.com vmodem.h vvmodem.c vrzsz.c sz.c rz.c crctab.c \
X	 genie.c crc.c rbsb.c minirb.c *.1 gz ptest.sh *.t
X
Xunixforum: shar
X	compress -b12 /tmp/rzsz.sh
X
Xtlbcmd:
X	mktlb.sh README. $(TLBFILES)
X
Xunix:
X	undos $(ARCFILES)
X
Xdos:
X	todos $(ARCFILES)
X
Xarc:
X	rm -f /tmp/rzsz.arc
X	arc aq /tmp/rzsz README Makefile zmodem.h zm.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c crctab.c rbsb.c \
X	 zmr.c genie.c init.com crc.c *.1 gz ptest.sh *.t minirb.c
X	chmod og-w /tmp/rzsz.arc
X	mv /tmp/rzsz.arc /t/yam
X
Xzoo:
X	rm -f /tmp/rzsz.zoo
X	zoo a /tmp/rzsz README Makefile zmodem.h zm.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c crctab.c rbsb.c *.1 \
X	 zmr.c genie.c init.com crc.c gz ptest.sh *.t minirb.c
X	touch /tmp/rzsz.zoo
X	chmod og-w /tmp/rzsz.zoo
X	mv /tmp/rzsz.zoo /t/yam
X
Xtags:
X	ctags sz.c rz.c zm.c zmr.c rbsb.c
X
X.PRECIOUS:rz sz
X
Xxenix:
X	$(CC) $(CFLAGS) $(OFLAG) -M0 -Ox -K -i -DTXBSIZE=16384
	-DNFGVMIN -DREADCHECK sz.c -lx -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X	$(CC) $(CFLAGS) $(OFLAG) -M0 -Ox -K -i -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X
Xx386:
X	$(CC) $(CFLAGS) $(OFLAG) -Ox -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	$(CC) $(CFLAGS) $(OFLAG) -Ox -DTXBSIZE=32768 -DNFGVMIN
	-DREADCHECK sz.c -lx -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
Xsysv:
X	$(CC) $(CFLAGS) $(OFLAG) -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	$(CC) $(CFLAGS) $(OFLAG) -DSV -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
Xsysvr3:
X	$(CC) $(CFLAGS) $(OFLAG) -DMD=2 rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	$(CC) $(CFLAGS) $(OFLAG) -DSV -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
Xbsd:
X	$(CC) $(CFLAGS) $(OFLAG) -DMD=2 -Dstrchr=index -DV7 rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	$(CC) $(CFLAGS) $(OFLAG) -DV7 -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
Xsz: nothing
Xsb: nothing
Xrz: nothing
Xrb: nothing
END_OF_FILE
if test 2766 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2697 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XMay 1989: Corrections for undefined variable and multiply defined rdchk().
X
XNew for April 1989:  ZMODEM compression and other compatible extensions
Xhave been added to the rz and sz programs.  Please read the comments in
Xthe rz.c and sz.c source code for licensing information for commercial use.
X
XPrevious versions of rz and sz (April 1988) remain Public Domain.
X
XNew for April 1988:  VMS C flavors of rz and sz especially for tired
Xfrog stompers.  The following performance log entries give the story!
X
X 2400 Z  splat.arc         3968  220   18  0  0   0  512  30 (rz) 0 ccvax off
X 2400 K  splat.arc         3968  110   36  0  0   0   89  -1 get  -1 ccvax off
X
XThe contents of RZSZ.ARC can be uploaded to a VAX/XMS system by ZCOMM or
XProfessional-YAM using the supplied vupl.t script.  Connect to your VMS
Xsystem, select an empty directory, and then give the YAM/ZCOMM command:
X"source vupl.t".  This will attempt to start a Kermit server ans upload
Xthe files to it.  If the script can't fire up a Kermit server, the
Xscript will use the VMS DCL "create" command to upload the files
Xdirectly.  In the latter case, use a clean line for best results.
X
XThe contents of RZSZ.ARC can be uploaded to a Unix or Xenix system by
XZCOMM or Professional-YAM using the supplied zupl.t script.  Connect to
Xyour Unix/Xenix system, select an empty directory, and then give the
XYAM/ZCOMM command: "source zupl.t".  This will upload minirb.c, compile
Xit, and then use minirb to upload the rz/sz files.
X
XOnce these files are on your Unix system, you can type "make".
XThe Makefile will list the various systems it knows how to
Xcompile the programs for, and the command to do so (e.g., "make bsd").
X
XThe Makefile is self explanatory; just say "make".
X
XNaturally, rz and sz work best with comm programs that seamlessly
Xsupport ZMODEM command and file AutoDownload (Pro-YAM and ZCOMM).
X
XThe "DSZ" shareware program allows ZMODEM file transfers with
Xtraditional DOS comm programs, but it must be called manually.
X(The computer should do that for you!)  DSZ provides a "mini term
Xfunction" that supports ZMODEM AutoDownload.  DSZ (part of DSZ.ARC) and
Xthe ZMODEM protocol description (YZMODEM.ARC) are on TeleGodzilla and
Xother fine bulletin boards.
X
XChuck Forsberg WA7KGX Author of Pro-YAM communications Tools for PCDOS and Unix
X...!tektronix!reed!omen!caf  Omen Technology Inc "The High Reliability Software"
X  17505-V Northwest Sauvie Island Road Portland OR 97231  Voice: 503-621-3406
XTeleGodzilla BBS: 621-3746 2400/1200  CIS:70007,2304  Genie:CAF  Source:TCE022
X  omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
X  omen!/usr/spool/uucppublic/FILES lists all uucp-able files, updated hourly
END_OF_FILE
if test 2697 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'crc.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'crc.1'\"
else
echo shar: Extracting \"'crc.1'\" \(884 characters\)
sed "s/^X//" >'crc.1' <<'END_OF_FILE'
X.TH CRC 1 OMEN 
X.SH NAME
Xcrc \- checksum files
X.SH SYNOPSIS
X.B crc
Xfile ...
X.SH DESCRIPTION
XFor each file,
X.I crc\^
Xcalculates and prints a 32-bit CRC,
Xthe byte count, and the file name.
XIt is typically used to validate files transferred between
Xdifferent systems, and is useful in detecting subtle disk corruption.
X.I Crc\^
Xuses a checksum compatible with the
XDOS
Xversion of crc,
Xthe 32 bit CRC used by PKZIP version 0.9,
Xas well as the "crc" command in ZCOMM and Professional-YAM
X(high reliability communications programs).
X
XThe 32-bit CRC used is the frame
Xcheck sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71
Xand FED-STD-1003, the U.S. versions of CCITT's X.25 link-level
Xprotocol).
X
X32 bit CRC code courtesy Gary S. Brown.
X.SH BUGS
XAlthough most unlikely,
Xfiles with different data may still produce the same crc value.
X.SH "SEE ALSO"
Xchek(1), tocpm(1), sum(1), wc(1).
END_OF_FILE
if test 884 -ne `wc -c <'crc.1'`; then
    echo shar: \"'crc.1'\" unpacked with wrong size!
fi
# end of 'crc.1'
fi
if test -f 'genie.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'genie.c'\"
else
echo shar: Extracting \"'genie.c'\" \(1941 characters\)
sed "s/^X//" >'genie.c' <<'END_OF_FILE'
X/*
X *
X *  Rev 5-08-89
X *  This file contains GEnie specific code for setting terminal modes,
X *  very little is specific to ZMODEM or YMODEM per se (that code is in
X *  sz.c and rz.c).  The CRC-16 routines used by XMODEM, YMODEM, and ZMODEM
X *  are also in this file, a fast table driven macro version
X *
X *   This file is #included so the main file can set parameters such as HOWMANY.
X *   See the main file rz.c for compile instructions.
X */
X
X#include <string.h>
X#include <fcntl.h>
X
X#define XARGSFILE "/"
X#define XX
X
XSTATIC char Myattn[] = { 0335, 0336, 0336, 0,
X	 24,24,24,24,24,24,24,24,24,24,13
X};
X#define ALTCANOFF 4
X
X/*
Xextern unsigned int _fmode = O_BINARY;
X*/
X
X/*
X * return 1 iff stdout and stderr are different devices
X *  indicating this program operating with a modem on a
X *  different line
X */
Xint Fromcu;		/* Were called from cu or yam */
Xfrom_cu()
X{
X	return 0;
X}
Xcucheck()
X{
X}
X
X
Xint Twostop;		/* Use two stop bits */
X
X
X
X
X/*
X * mode(n)
X *  3: save old tty stat, set raw mode with flow control
X *  2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
X *  1: save old tty stat, set raw mode 
X *  0: restore original tty mode
X */
Xmode(n)
X{
X	static did0 = FALSE;
X
X	vfile("mode:%d", n);
X	switch(n) {
X	case 2:		/* Un-raw mode used by sz, sb when -g detected */
X	case 1:
X	case 3:
X		did0 = TRUE;
X		system("set x on");
X		system("set e off");
X		system("set t13,10");
X/*
X		system("set b3");
X*/
X		reset(1);
X		binary(1); 
X		/* Assume fd 1 is stdout (not documented in GEnie) */
X		fcntl(1, F_SETFL,
X		  ((fcntl(1, F_GETFL, 0)|O_BINARY)& ~O_POST_BREAK));
X		return OK;
X	case 0:
X		if(!did0)
X			return ERROR;
X
X		return OK;
X	default:
X		return ERROR;
X	}
X}
X
Xsendbrk()
X{
X}
X/*
X * readline(timeout) reads character(s) from file descriptor 0
X * timeout is in tenths of seconds
X */
Xreadline(timeout)
X{
X	static char byt[1];
X
X	fflush(stdout);
X	read(0, byt, 1);
X	return (byt[0]&0377);
X}
X
Xflushmo()
X{
X	fflush(stdout);
X}
X
Xpurgeline() {}
X
X
X/* End of genie.c */
END_OF_FILE
if test 1941 -ne `wc -c <'genie.c'`; then
    echo shar: \"'genie.c'\" unpacked with wrong size!
fi
# end of 'genie.c'
fi
if test -f 'gz' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gz'\"
else
echo shar: Extracting \"'gz'\" \(19 characters\)
sed "s/^X//" >'gz' <<'END_OF_FILE'
Xexec sz -c "sz $*"
END_OF_FILE
if test 19 -ne `wc -c <'gz'`; then
    echo shar: \"'gz'\" unpacked with wrong size!
fi
# end of 'gz'
fi
if test -f 'init.com' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'init.com'\"
else
echo shar: Extracting \"'init.com'\" \(167 characters\)
sed "s/^X//" >'init.com' <<'END_OF_FILE'
X$define lnk$library  sys$library:vaxcrtl.olb
X$sz :== $dua7:[802873]sz.exe
X$rz :== $dua7:[802873]rz.exe
X$crc :== $dua7:[802873]crc.exe
X$crcb :== $dua7:[802873]crcb.exe
END_OF_FILE
if test 167 -ne `wc -c <'init.com'`; then
    echo shar: \"'init.com'\" unpacked with wrong size!
fi
# end of 'init.com'
fi
if test -f 'minirb.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'minirb.1'\"
else
echo shar: Extracting \"'minirb.1'\" \(1241 characters\)
sed "s/^X//" >'minirb.1' <<'END_OF_FILE'
X'\" Revision Level 
X'\" Last Delta     09-08-87
X.TH MINIRB 1 OMEN
X.SH NAME
Xminirb \- Bootstrap YMODEM Batch file receive
X.SH SYNOPSIS
X.B minirb
X.SH DESCRIPTION
X.I Minirb
Xreceives one or more files with YMODEM batch file transfer protocol.
X.I Minirb
Xwas developed for use as a bootstrap to simplify uploading of the longer
X.I rz
Xand
X.I sz
Xprograms, such as are contained in the
X.I rzsz.zoo
X"zoo" archive or the
X.I rzsz.sh
Xshell archive.
X.SH SEE ALSO
XYMODEM.DOC,
XProfessional-YAM manual,
Xsz(omen)
X.SH NOTES
XThe source file
X.I minirb.c
Xhas been ruthlessly pruned
X(4k, 175 lines)
Xto simplify uploading without benefit of
Xan error correcting file transfer protocol.
XDo not reformat or add tabs to the source file
Xas this would complicate uploading.
X
XPlease read the uploading suggestions in the chapter
X.I "File Transfer Basics"
Xin the Professional-YAM or ZCOMM user's manual.
X
X.I Minirb
Xuses 8 bit checksum which may not be compatible with some programs
Xclaiming to support YMODEM batch transfers.
X
X.I Minirb
Xuses the
XYMODEM header
Xfile length information
Xto avoid storing extraneous characters.
X.I Minirb
Xdeletes carriage returns and CPMEOF (^Z) characters
Xencountered in uploaded files.
X
X.I Minirb
Xcalls stty(1) to set and reset raw tty mode.
END_OF_FILE
if test 1241 -ne `wc -c <'minirb.1'`; then
    echo shar: \"'minirb.1'\" unpacked with wrong size!
fi
# end of 'minirb.1'
fi
if test -f 'minirb.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'minirb.c'\"
else
echo shar: Extracting \"'minirb.c'\" \(4057 characters\)
sed "s/^X//" >'minirb.c' <<'END_OF_FILE'
X/*
X * minirb.c By Chuck Forsberg Omen Technology INC
X *        "The High Reliability Communications Software"
X *
X * A bootstrap program for Unix to receive files from computers running
X *  YMODEM Batch (Professional-YAM, PowerCom, ZCOMM, etc.).
X *
X *  Minirb uses system(3) to call stty, avoiding system dependent code.
X *   program strips CR and CPMEOF (^Z) characters (see putsec()).
X *  Please refer to rz.c for comments, etc.
X */
Xchar * Version = "minirb 2.00 05-25-87";
X
X#include <stdio.h>
X#include <signal.h>
X#include <setjmp.h>
X
X#define OK 0
X#define FALSE 0
X#define TRUE 1
X#define ERROR (-1)
X#define CAN ('X'&037)
X#define SOH 1
X#define STX 2
X#define EOT 4
X#define ACK 6
X#define NAK 025
X#define TIMEOUT (-2)
X#define RETRYMAX 9
X#define WCEOT (-10)
X
XFILE *fout;
Xlong Bytesleft;
Xint Blklen;
Xchar secbuf[1024];
Xchar linbuf[1024];
Xint Lleft=0;
Xjmp_buf tohere;
X
Xalrm() { longjmp(tohere, -1); }
X
Xbibi(n) {
X canit(); mode(0);
X fprintf(stderr, "minirb: caught signal %d; exiting", n);
X exit(128+n);
X}
X
Xmode(n) {
X if (n) system("stty raw -echo");
X else system("stty echo -raw");
X}
X
Xmain() {
X mode(1);
X if (signal(SIGINT, bibi) == SIG_IGN) {
X  signal(SIGINT, SIG_IGN); signal(SIGKILL, SIG_IGN);
X } else {
X  signal(SIGINT, bibi); signal(SIGKILL, bibi);
X }
X printf("minirb: Now send file(s) with \042sb file ...\042 command\r\n");
X
X if (wcreceive()==ERROR)
X  canit();
X mode(0); exit(0);
X}
X
Xwcreceive() {
X for (;;) {
X  if (wcrxpn(secbuf) == ERROR) break;
X  if (secbuf[0]==0) return OK;
X  if (procheader(secbuf)==ERROR || wcrx()==ERROR) break;
X }
X canit(); return ERROR;
X}
X
X
Xwcrxpn(rpn) char *rpn; {
X register c;
X
X purgeline();
Xet_tu:
X sendline(NAK); Lleft=0;
X while ((c = wcgetsec(rpn, 100)) != 0) {
X  if (c == WCEOT) { sendline(ACK); Lleft=0; readline(1); goto et_tu; }
X  return ERROR;
X }
X sendline(ACK); return OK;
X}
X
Xwcrx() {
X register int sectnum, sectcurr, sendchar, cblklen;
X
X sectnum=0; sendchar=NAK;
X for (;;) {
X  sendline(sendchar); Lleft=0;
X  sectcurr=wcgetsec(secbuf, 50);
X  if (sectcurr==(sectnum+1 & 0377)) {
X   sectnum++; cblklen = Bytesleft>Blklen ? Blklen:Bytesleft;
X   putsec(secbuf, cblklen);
X   if ((Bytesleft-=cblklen) < 0) Bytesleft = 0;
X   sendchar=ACK;
X  }
X  else if (sectcurr==(sectnum&0377)) sendchar=ACK;
X  else if (sectcurr==WCEOT) {
X   if (fclose(fout)==ERROR) return ERROR;
X   sendline(ACK); Lleft=0; return OK;
X  }
X  else if (sectcurr==ERROR) return ERROR;
X  else return ERROR;
X }
X}
X
Xwcgetsec(rxbuf, maxtime) char *rxbuf; int maxtime; {
X register checksum, wcj, firstch; register char *p; int sectcurr, errors;
X for (errors=0; errors<RETRYMAX; errors++) {
X  if ((firstch=readline(maxtime))==STX) { Blklen=1024; goto get2; }
X  if (firstch==SOH) {
X   Blklen=128;
Xget2:
X   sectcurr=readline(1); checksum=0;
X   if ((sectcurr+(readline(1)))==0377) {
X    for (p=rxbuf,wcj=Blklen; --wcj>=0; ) {
X     if ((firstch=readline(1)) < 0) goto bilge;
X     checksum += (*p++ = firstch);
X    }
X    if ((firstch=readline(1)) < 0) goto bilge;
X    if (((checksum-firstch)&0377)==0) return sectcurr;
X   }
X  }
X  else if (firstch==EOT) return WCEOT;
X  else if (firstch==CAN) return ERROR;
Xbilge:
X  while(readline(1)!=TIMEOUT)
X   ;
X  maxtime=40; sendline(NAK); Lleft=0;
X }
X canit(); return ERROR;
X}
X
Xreadline(timeout) int timeout; {
X register n; static char *cdq;
X
X if (--Lleft >= 0) return (*cdq++ & 0377);
X n = timeout/10;
X if (n < 2) n = 3;
X if (setjmp(tohere)) { Lleft = 0; return TIMEOUT; }
X signal(SIGALRM, alrm); alarm(n);
X Lleft=read(0, cdq=linbuf, 1024); alarm(0);
X if (Lleft < 1) return TIMEOUT;
X --Lleft; return (*cdq++ & 0377);
X}
X
Xpurgeline() { Lleft = 0; lseek(0, 0L, 2); }
X
X
Xprocheader(name) char *name; {
X register char *p;
X
X Bytesleft = 2000000000L; p = name + 1 + strlen(name);
X if (*p) sscanf(p, "%ld", &Bytesleft);
X if ((fout=fopen(name, "w")) == NULL) return ERROR;
X return OK;
X}
X
Xputsec(p, n) char *p; int n;
X{ for (; --n>=0; ++p) if (*p != 015 && *p != 032) putc(*p, fout); }
X
Xsendline(c) { char d; d = c; write(1, &d, 1); }
X
Xchar canistr[] = { 24,24,24,24,24,24,24,24,0 };
X
Xcanit() { printf(canistr); Lleft=0; }
X
X/* END of minirb.c */
X
END_OF_FILE
if test 4057 -ne `wc -c <'minirb.c'`; then
    echo shar: \"'minirb.c'\" unpacked with wrong size!
fi
# end of 'minirb.c'
fi
if test -f 'ptest.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ptest.sh'\"
else
echo shar: Extracting \"'ptest.sh'\" \(119 characters\)
sed "s/^X//" >'ptest.sh' <<'END_OF_FILE'
X#a short test for sz and rz using a named pipe - no modem used.
X/etc/mknod fifo p
Xsz <fifo /etc/motd |rz >fifo
Xrm fifo
END_OF_FILE
if test 119 -ne `wc -c <'ptest.sh'`; then
    echo shar: \"'ptest.sh'\" unpacked with wrong size!
fi
# end of 'ptest.sh'
fi
if test -f 'rbsb.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rbsb.c'\"
else
echo shar: Extracting \"'rbsb.c'\" \(6924 characters\)
sed "s/^X//" >'rbsb.c' <<'END_OF_FILE'
X/*
X *
X *  Rev 5-09-89
X *  This file contains Unix specific code for setting terminal modes,
X *  very little is specific to ZMODEM or YMODEM per se (that code is in
X *  sz.c and rz.c).  The CRC-16 routines used by XMODEM, YMODEM, and ZMODEM
X *  are also in this file, a fast table driven macro version
X *
X *	V7/BSD HACKERS:  SEE NOTES UNDER mode(2) !!!
X *
X *   This file is #included so the main file can set parameters such as HOWMANY.
X *   See the main files (rz.c/sz.c) for compile instructions.
X */
X
X#ifdef V7
X#include <sys/types.h>
X#include <sys/stat.h>
X#define STAT
X#include <sgtty.h>
X#define OS "V7/BSD"
X#define ROPMODE "r"
X#ifdef LLITOUT
Xlong Locmode;		/* Saved "local mode" for 4.x BSD "new driver" */
Xlong Locbit = LLITOUT;	/* Bit SUPPOSED to disable output translations */
X#include <strings.h>
X#endif
X#endif
X
X#ifndef OS
X#ifndef USG
X#define USG
X#endif
X#endif
X
X#ifdef USG
X#include <sys/types.h>
X#include <sys/stat.h>
X#define STAT
X#include <termio.h>
X#define OS "SYS III/V"
X#define ROPMODE "r"
X#define MODE2OK
X#include <string.h>
X#endif
X
X#if HOWMANY  > 255
XHowmany must be 255 or less
X#endif
X
X/*
X * return 1 iff stdout and stderr are different devices
X *  indicating this program operating with a modem on a
X *  different line
X */
Xint Fromcu;		/* Were called from cu or yam */
Xfrom_cu()
X{
X	struct stat a, b;
X
X	fstat(1, &a); fstat(2, &b);
X	Fromcu = a.st_rdev != b.st_rdev;
X	return;
X}
Xcucheck()
X{
X	if (Fromcu)
X		fprintf(stderr,"Please read the manual page BUGS chapter!\r\n");
X}
X
X
Xstruct {
X	unsigned baudr;
X	int speedcode;
X} speeds[] = {
X	110,	B110,
X	300,	B300,
X	600,	B600,
X	1200,	B1200,
X	2400,	B2400,
X	4800,	B4800,
X	9600,	B9600,
X	19200,	EXTA,
X	38400,	EXTB,
X	0,
X};
X
Xint Twostop;		/* Use two stop bits */
X
X
X/*
X *  The following uses an external rdchk() routine if available,
X *  otherwise defines the function for BSD or fakes it for SYSV.
X */
X
X#ifndef READCHECK
X#ifdef FIONREAD
X#define READCHECK
X/*
X *  Return non 0 iff something to read from io descriptor f
X */
Xrdchk(f)
X{
X	static long lf;
X
X	ioctl(f, FIONREAD, &lf);
X	return ((int) lf);
X}
X
X#else		/* FIONREAD */
X
X#ifdef SV
X#define READCHECK
X#include <fcntl.h>
X
Xint checked = 0;
X/*
X * Nonblocking I/O is a bit different in System V, Release 2
X *  Note: this rdchk vsn throws away a byte, OK for ZMODEM
X *  sender because protocol design anticipates this problem.
X */
X#define EATSIT
Xrdchk(f)
X{
X	int lf, savestat;
X	static char bchecked;
X
X	savestat = fcntl(f, F_GETFL) ;
X	fcntl(f, F_SETFL, savestat | O_NDELAY) ;
X	lf = read(f, &bchecked, 1) ;
X	fcntl(f, F_SETFL, savestat) ;
X	checked = bchecked & 0377;	/* force unsigned byte */
X	return(lf) ;
X}
X#endif
X#endif
X#endif
X
X
Xstatic unsigned
Xgetspeed(code)
X{
X	register n;
X
X	for (n=0; speeds[n].baudr; ++n)
X		if (speeds[n].speedcode == code)
X			return speeds[n].baudr;
X	return 38400;	/* Assume fifo if ioctl failed */
X}
X
X
X
X#ifdef ICANON
Xstruct termio oldtty, tty;
X#else
Xstruct sgttyb oldtty, tty;
Xstruct tchars oldtch, tch;
X#endif
X
X/*
X * mode(n)
X *  3: save old tty stat, set raw mode with flow control
X *  2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
X *  1: save old tty stat, set raw mode 
X *  0: restore original tty mode
X */
Xmode(n)
X{
X	static did0 = FALSE;
X
X	vfile("mode:%d", n);
X	switch(n) {
X#ifdef USG
X	case 2:		/* Un-raw mode used by sz, sb when -g detected */
X		if(!did0)
X			(void) ioctl(0, TCGETA, &oldtty);
X		tty = oldtty;
X
X		tty.c_iflag = BRKINT|IXON;
X
X		tty.c_oflag = 0;	/* Transparent output */
X
X		tty.c_cflag &= ~PARENB;	/* Disable parity */
X		tty.c_cflag |= CS8;	/* Set character size = 8 */
X		if (Twostop)
X			tty.c_cflag |= CSTOPB;	/* Set two stop bits */
X
X
X#ifdef READCHECK
X		tty.c_lflag = Zmodem ? 0 : ISIG;
X		tty.c_cc[VINTR] = Zmodem ? -1:030;	/* Interrupt char */
X#else
X		tty.c_lflag = ISIG;
X		tty.c_cc[VINTR] = Zmodem ? 03:030;	/* Interrupt char */
X#endif
X		tty.c_cc[VQUIT] = -1;			/* Quit char */
X#ifdef NFGVMIN
X		tty.c_cc[VMIN] = 1;
X#else
X		tty.c_cc[VMIN] = 3;	 /* This many chars satisfies reads */
X#endif
X		tty.c_cc[VTIME] = 1;	/* or in this many tenths of seconds */
X
X		(void) ioctl(0, TCSETAW, &tty);
X		did0 = TRUE;
X		return OK;
X	case 1:
X	case 3:
X		if(!did0)
X			(void) ioctl(0, TCGETA, &oldtty);
X		tty = oldtty;
X
X		tty.c_iflag = n==3 ? (IGNBRK|IXOFF) : IGNBRK;
X
X		 /* No echo, crlf mapping, INTR, QUIT, delays, no erase/kill */
X		tty.c_lflag &= ~(ECHO | ICANON | ISIG);
X
X		tty.c_oflag = 0;	/* Transparent output */
X
X		tty.c_cflag &= ~PARENB;	/* Same baud rate, disable parity */
X		tty.c_cflag |= CS8;	/* Set character size = 8 */
X		if (Twostop)
X			tty.c_cflag |= CSTOPB;	/* Set two stop bits */
X#ifdef NFGVMIN
X		tty.c_cc[VMIN] = 1; /* This many chars satisfies reads */
X#else
X		tty.c_cc[VMIN] = HOWMANY; /* This many chars satisfies reads */
X#endif
X		tty.c_cc[VTIME] = 1;	/* or in this many tenths of seconds */
X		(void) ioctl(0, TCSETAW, &tty);
X		did0 = TRUE;
X		Effbaud = Baudrate = getspeed(tty.c_cflag & CBAUD);
X		return OK;
X#endif
X#ifdef V7
X	/*
X	 *  NOTE: this should transmit all 8 bits and at the same time
X	 *   respond to XOFF/XON flow control.  If no FIONREAD or other
X	 *   rdchk() alternative, also must respond to INTRRUPT char
X	 *   This doesn't work with V7.  It should work with LLITOUT,
X	 *   but LLITOUT was broken on the machine I tried it on.
X	 */
X	case 2:		/* Un-raw mode used by sz, sb when -g detected */
X		if(!did0) {
X			ioctl(0, TIOCEXCL, 0);
X			ioctl(0, TIOCGETP, &oldtty);
X			ioctl(0, TIOCGETC, &oldtch);
X#ifdef LLITOUT
X			ioctl(0, TIOCLGET, &Locmode);
X#endif
X		}
X		tty = oldtty;
X		tch = oldtch;
X#ifdef READCHECK
X		tch.t_intrc = Zmodem ? -1:030;	/* Interrupt char */
X#else
X		tch.t_intrc = Zmodem ? 03:030;	/* Interrupt char */
X#endif
X		tty.sg_flags |= (ODDP|EVENP|CBREAK);
X		tty.sg_flags &= ~(ALLDELAY|CRMOD|ECHO|LCASE);
X		ioctl(0, TIOCSETP, &tty);
X		ioctl(0, TIOCSETC, &tch);
X#ifdef LLITOUT
X		ioctl(0, TIOCLBIS, &Locbit);
X#endif
X		bibi(99);	/* un-raw doesn't work w/o lit out */
X		did0 = TRUE;
X		return OK;
X	case 1:
X	case 3:
X		if(!did0) {
X			ioctl(0, TIOCEXCL, 0);
X			ioctl(0, TIOCGETP, &oldtty);
X			ioctl(0, TIOCGETC, &oldtch);
X#ifdef LLITOUT
X			ioctl(0, TIOCLGET, &Locmode);
X#endif
X		}
X		tty = oldtty;
X		tty.sg_flags |= (RAW|TANDEM);
X		tty.sg_flags &= ~ECHO;
X		ioctl(0, TIOCSETP, &tty);
X		did0 = TRUE;
X		Effbaud = Baudrate = getspeed(tty.sg_ospeed);
X		return OK;
X#endif
X	case 0:
X		if(!did0)
X			return ERROR;
X#ifdef USG
X		(void) ioctl(0, TCSBRK, 1);	/* Wait for output to drain */
X		(void) ioctl(0, TCFLSH, 1);	/* Flush input queue */
X		(void) ioctl(0, TCSETAW, &oldtty);	/* Restore modes */
X		(void) ioctl(0, TCXONC,1);	/* Restart output */
X#endif
X#ifdef V7
X		ioctl(0, TIOCSETP, &oldtty);
X		ioctl(0, TIOCSETC, &oldtch);
X		ioctl(0, TIOCNXCL, 0);
X#ifdef LLITOUT
X		ioctl(0, TIOCLSET, &Locmode);
X#endif
X#endif
X
X		return OK;
X	default:
X		return ERROR;
X	}
X}
X
Xsendbrk()
X{
X#ifdef V7
X#ifdef TIOCSBRK
X#define CANBREAK
X	sleep(1);
X	ioctl(0, TIOCSBRK, 0);
X	sleep(1);
X	ioctl(0, TIOCCBRK, 0);
X#endif
X#endif
X#ifdef USG
X#define CANBREAK
X	ioctl(0, TCSBRK, 0);
X#endif
X}
X
X/* End of rbsb.c */
END_OF_FILE
if test 6924 -ne `wc -c <'rbsb.c'`; then
    echo shar: \"'rbsb.c'\" unpacked with wrong size!
fi
# end of 'rbsb.c'
fi
if test -f 'vmodem.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vmodem.h'\"
else
echo shar: Extracting \"'vmodem.h'\" \(882 characters\)
sed "s/^X//" >'vmodem.h' <<'END_OF_FILE'
X/*
X *  VMODEM.H
X *  VMS support for UMODEM program
X *
X *	#INCLUDE files defining structures associated with terminal
X *	information structure TT_INFO.
X *	Information about the terminal is passed around in UMODEM in a
X *	STRUCT TT_INFO.
X *
X *  Walter Reiher
X *  Harvard University
X *  Department of Chemistry
X *  12 Oxford Street
X *  Cambridge, MA 02138
X *  March 10, 1983
X */
X
Xstruct	tt_mode				/*  Info for a IO$_SETMODE call  */
X{
X	char			class;
X	char			type;
X	short			page_width;
X	char			bcharacteristics[3];
X	char			page_length;
X	int			echaracteristics;
X};
X
Xstruct	tt_mode_iosb			/*  Terminal IO$_SENSEMODE IOSB  */
X{
X	short			status;
X	char			t_speed;
X	char			r_speed;
X	char			CR_fill;
X	char			LF_fill;
X	char			parity_flags;
X	char			unused2;
X};
X
Xstruct	tt_info				/*  Summary of terminal infomation  */
X{
X	struct	tt_mode		dev_characteristics;
X	struct	tt_mode_iosb	dev_modes;
X};
END_OF_FILE
if test 882 -ne `wc -c <'vmodem.h'`; then
    echo shar: \"'vmodem.h'\" unpacked with wrong size!
fi
# end of 'vmodem.h'
fi
if test -f 'vrzsz.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vrzsz.c'\"
else
echo shar: Extracting \"'vrzsz.c'\" \(4440 characters\)
sed "s/^X//" >'vrzsz.c' <<'END_OF_FILE'
X#include "vmodem.h"
X#include ssdef
X#include tt2def
X#include ttdef
X#define SS_NORMAL SS$_NORMAL
X
X/*  VMS structures  */
X/*
X *	TT_INFO structures are used for passing information about
X *	the terminal.  Used in GTTY and STTY calls.
X */
Xstruct	tt_info	ttys, ttysnew, ttystemp;
X
X/*
X *
X */
X
X/*
X * return 1 iff stdout and stderr are different devices
X *  indicating this program operating with a modem on a
X *  different line
X */
Xint Fromcu;		/* Were called from cu or yam */
Xfrom_cu()
X{
X}
Xcucheck()
X{
X}
X
X
X
X/*
X * mode(n)
X *  3: save old tty stat, set raw mode with flow control
X *  2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
X *  1: save old tty stat, set raw mode 
X *  0: restore original tty mode
X */
Xmode(n)
X{
X	int	*iptr, parameters;
X	static savedmodes = FALSE;
X
X	vfile("mode:%d", n);
X
X	if (!savedmodes) {
X		if (gtty(&ttys) != SS$_NORMAL)
X			death("SETMODES:  error return from GTTY (1)");
X		if (gtty(&ttysnew) != SS$_NORMAL)
X			death("SETMODES:  error return from GTTY (2)");
X		savedmodes = TRUE;
X	}
X
X	/*
X	 * Set new terminal parameters.
X	 *  Note:  there are three bytes of terminal characteristics,
X	 *  so we should make sure the fourth byte of the integer is unchanged.
X	 */
X	switch (n) {
X	case 1:
X	case 2:
X	case 3:
X		iptr	= &(ttysnew.dev_characteristics.bcharacteristics);
X		parameters	= *iptr;
X
X		parameters	&= ~TT$M_ESCAPE;	/*  ESCAPE   OFF  */
X		parameters	&= ~TT$M_HOSTSYNC;	/*  HOSTSYNC OFF  */
X		parameters	|=  TT$M_NOECHO;	/*  NOECHO   ON   */
X		parameters	|=  TT$M_PASSALL;	/*  PASSALL  ON   */
X		parameters	&= ~TT$M_READSYNC;	/*  READSYNC OFF  */
X		parameters	&= ~TT$M_TTSYNC;	/*  TTSYNC   OFF  */
X		parameters	&= ~TT$M_WRAP;		/*  WRAP     OFF  */
X		parameters	|= TT$M_EIGHTBIT;	/*  EIGHTBIT ON   */
X		if (n == 3) {
X			parameters |= TT$M_HOSTSYNC;	/*  HOSTSYNC On  */
X		}
X		if (n == 2) {
X			parameters |= TT$M_TTSYNC;	/*  TTSYNC On  */
X		}
X
X		*iptr		= parameters;
X
X		if (stty(&ttysnew) != SS_NORMAL)
X			fatal("SETMODES:  error return from STTY");
X		break;
X	case 0:
X		stty(&ttys);		/*  Restore original modes  */
X					/* error return to /dev/null */
X	break;
X	}
X}
X
X
X
X/* set tty modes for vrzsz transfers */
Xsetmodes()
X{
X/*  Device characteristics for VMS  */
X}
X
Xfatal(msg)
Xchar *msg;
X{
X	mode(0);  		/* put back normal tty modes */
X	printf("vrzsz:  %s\n", msg);
X	exit(SS_NORMAL);
X}
X
X/* Call this instead if funny modes haven't been set yet */
Xdeath(msg)
Xchar *msg;
X{
X	printf("vrzsz:  %s\n", msg);
X	exit(SS_NORMAL);
X}
X
X#define LSIZE 64	/* Size of send & receive buffers */
X#ifdef BUFREAD
X
Xchar Rxlbuf[LSIZE+1];
Xint Rxleft=0;		/* number of characters in Rxlbuf */
Xchar *Rxcdq = Rxlbuf;	/* pointer for removing chars from Rxlbuf */
X
X/*
X * This version of readline is reasoably well suited for
X * reading many characters.
X *
X * timeout is in tenths of seconds
X */
X
Xreadline(timeout)
Xint timeout;
X{
X	register int c;
X	extern errno;
X
X	if (--Rxleft>=0)
X		return (*Rxcdq++ & 0377);
X#ifdef DEBUGG
X	eprintf("Calling read: ");
X#endif
X	if ((c = timeout/10)<2)
X		c=2;
X
X	do {
X		Rxleft = raw_read(LSIZE, Rxcdq=Rxlbuf, 1);
X	} while (Rxleft == SS$_TIMEOUT   &&   --c >= 0);
X#ifdef DEBUGG
X	eprintf("Read returned %d bytes\n", Rxleft);
X#endif
X	if (Rxleft == SS$_TIMEOUT || --Rxleft < 0) {
X		Rxleft = 0;
X		return TIMEOUT;
X	}
X	return (*Rxcdq++ & 0377);
X}
X
Xpurgeline()
X{
X	Rxleft=0;
X}
X
X
X#else	/* BUFREAD */
X
X
X/* get a byte from data stream -- timeout if "dseconds" elapses */
X/*	NOTE, however, that this function returns an INT, not a BYTE!!!  */
Xreadline(dseconds)
X{
X	int seconds;
X	int ret, c;
X
X	seconds = dseconds/10;
X	if (seconds < 2)
X		seconds = 2;
X	ret	= raw_read(1, &c, seconds);
X
X	if (ret == SS$_TIMEOUT)
X		return(TIMEOUT);
X
X	return(c & 0377);  /* return the char */
X}
X
Xpurgeline()
X{
X	int c;
X
X	do {
X		c = readline(1);
X	} while (c != TIMEOUT);
X}
X#endif
X
X
X#ifdef BUFWRITE
Xchar Txlbuf[LSIZE+1];
Xint Txleft=LSIZE;		/* number of characters in Txlbuf */
Xchar *Txcq = Txlbuf;	/* pointer for removing chars from Rxlbuf */
X
Xsendline(c)
X{
X	if (--Txleft >= 0)
X		*Txcq++ = c;
X	else {
X		Txleft = 0;
X		flushmoc();
X		--Txleft;
X		*Txcq++ = c;
X	}
X}
X
Xflushmoc()
X{
X	register int n;
X
X	n = LSIZE - Txleft;
X	Txcq=Txlbuf;  Txleft = LSIZE;
X	raw_wbuf(n, Txlbuf);
X}
X
X/*
X *  Wait for the modem line outbuffer to drain
X */
Xflushmo()
X{
X	fflush(stdout);
X	flushmoc();
X}
X
X#else	/* BUFWRITE */
X
X/* send a byte to data stream */
Xsendline(data)
X{
X	char	dataout;
X
X	dataout	= data;
X	raw_write(dataout);
X
X}
X
Xflushmo() {}
Xflushmoc() {}
X#endif
X
Xsendbrk()
X{
X}
X
X
X/* End of vrzsz.c */
END_OF_FILE
if test 4440 -ne `wc -c <'vrzsz.c'`; then
    echo shar: \"'vrzsz.c'\" unpacked with wrong size!
fi
# end of 'vrzsz.c'
fi
if test -f 'vupl.t' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vupl.t'\"
else
echo shar: Extracting \"'vupl.t'\" \(541 characters\)
sed "s/^X//" >'vupl.t' <<'END_OF_FILE'
X	echo "ProYAM/ZCOMM script to upload rz/sz files to VMS"
X	if !fvmodem.h echo "Can't find vmodem.h !!";  abort
X	pat
X	pat 1 "Server"
X	pat 2 "unrecognized command verb"
X	put "kermit server\r"
X	wait -f15
X	if 1 goto frog
X	if !2 echo "Unexpected response from VMS!"; abort
X	expand vuplfile.t vmodem.h rz.c sz.c vrzsz.c vvmodem.c 
X	expand vuplfile.t zm.c zmr.c zmodem.h crctab.c init.com
X	echo "vupl.t finished."
X	return
Xfrog:	send vmodem.h rz.c sz.c vrzsz.c vvmodem.c zm.c
X	send zmodem.h crctab.c init.com
X	finish
X	echo "vupl.t finished."
X	return
END_OF_FILE
if test 541 -ne `wc -c <'vupl.t'`; then
    echo shar: \"'vupl.t'\" unpacked with wrong size!
fi
# end of 'vupl.t'
fi
if test -f 'vuplfile.t' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vuplfile.t'\"
else
echo shar: Extracting \"'vuplfile.t'\" \(274 characters\)
sed "s/^X//" >'vuplfile.t' <<'END_OF_FILE'
X	echo "Uploading %item to VMS using DCL create command"
X	pat
X	if S>2400 pt1; ena -t
X	putw "set terminal/hostsync/noecho\r"
X	putw "create %item\r"
X	sleep 10
X	f -xHr %item
X	pat 1 "\044"
X	put "\032"
X	wait -f30
X	if !1 echo "create failed!"
X	putw "set terminal/echo\r"
X	dis -Htx
END_OF_FILE
if test 274 -ne `wc -c <'vuplfile.t'`; then
    echo shar: \"'vuplfile.t'\" unpacked with wrong size!
fi
# end of 'vuplfile.t'
fi
if test -f 'vvmodem.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vvmodem.c'\"
else
echo shar: Extracting \"'vvmodem.c'\" \(6120 characters\)
sed "s/^X//" >'vvmodem.c' <<'END_OF_FILE'
X/*
X *  VMODEM
X *  VMS support for UMODEM and vvrb/vvsb programs
X *
X *	Defined herein are some utility routines to make the UNIX
X *	program UMODEM run under VAX/VMS C:
X *
X *		assign_channel	Calls the VMS System Service $ASSIGN
X *				to assign a channel to a device.
X *				The routine currently has the device
X *				"TT" hardwired into it.
X *		gtty		Gets terminal characteristics, almost
X *				like the UNIX GTTY system call.
X *		raw_read	Reads characters from the terminal
X *				without any echoing or interpretation
X *				and with an optional timeout period.
X *		raw_write	Writes a character to the terminal
X *				without any interpretation.
X *		raw_wbuf	Writes a buffer to the terminal
X *				without any interpretation.
X *		stty		Sets terminal characteristics, almost
X *				like the UNIX STTY system call.
X *
X *	Some of the ideas used here were obtained from code written
X *	by Max Benson and Robert Bruccoleri.
X *
X *  Walter Reiher
X *  Harvard University
X *  Department of Chemistry
X *  12 Oxford Street
X *  Cambridge, MA 02138
X *  March 11, 1983
X *
X *  Modified 4-20-88 Chuck Forsberg, Omen Technology INC
X *  17505-V NW Sauvie IS RD Portland OR 97231 omen!caf
X *   Added primitives for for ZMODEM use.
X */
X#include descrip
X#include iodef
X#include rms
X#include ssdef
X#include stdio
X#include "vmodem.h"
X
X#define  TRUE	1
X#define  FALSE	0
X
Xstatic char	tt_name[]	= "TT";
Xstatic short	tt_chan		= -1;		/*  Terminal channel number  */
X
Xstruct	tt_io_iosb				/*  Terminal I/O IOSB  */
X{
X	short	status;
X	short	byte_count;
X	short	terminator;
X	short	terminator_size;
X};
X
X
Xstruct	tt_io_tacf				/* Terminal I/O type ahead */
X{
X	short	byte_count;
X	char	firstchar;
X	char	something;
X	short	whatever;
X};
X
X/*
X *	Terminator mask for PASSALL reads.
X *	Permits reads of all possible 8-bit characters.
X */
Xint	t_mask[32] =  {
X	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
X	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
X	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
X	0,  0	};
X
Xstruct	terminator_mask {
X	short	size ;
X	short	unused ;
X	int	*mask ;
X}
X
Xtermin_mask	= { 32, 0, t_mask };
X
X/*
X *	ASSIGN a channel to the logical name TT, which is usually
X *	the terminal.
X */
Xassign_channel()
X{
X	int	status;
X	$DESCRIPTOR(tt_descriptor, tt_name);
X
X	if (tt_chan == -1)
X		status	= sys$assign(&tt_descriptor, &tt_chan, 0, 0);
X	else
X		status	= SS$_NORMAL;
X
X	if (status != SS$_NORMAL || tt_chan == -1)
X		fatal("ASSIGN_CHANNEL:  error in SYS$ASSIGN\n");
X
X	return;
X}
X
X/*
X *	Gets terminal information from VMS.
X */
Xgtty(tt_characteristics)
Xstruct	tt_info	*tt_characteristics;
X{
X	int c;
X	int				status;
X	extern unsigned Baudrate;
X	int speeds[] = { 2400, 50, 75, 110, 134, 150, 300, 600, 1200, 1800,
X	  2000, 2400, 3600, 4800, 7200, 9600, 19200 };
X
X	if (tt_chan == -1)
X		assign_channel();
X
X	status	= sys$qiow(0, tt_chan, IO$_SENSEMODE,
X	  &(tt_characteristics->dev_modes), NULL, 0,
X	  &(tt_characteristics->dev_characteristics), 12,
X	  0, 0, 0, 0);
X	if (status != SS$_NORMAL ||
X	  tt_characteristics->dev_modes.status != SS$_NORMAL)
X		fatal("GTTY:  sense mode QIO error return.\n");
X
X	c = tt_characteristics->dev_modes.t_speed % 17;
X	Baudrate = speeds[c];
X
X	return(status);
X}
X
X/*
X *	Return the number of characters waiting in TTY input buffer
X */
Xrdchk()
X{
X	int		status;
X	struct	tt_io_iosb	iosb;
X	struct	tt_io_tacf typeahead;
X
X	status	= sys$qiow(0, tt_chan, IO$_SENSEMODE|IO$M_TYPEAHDCNT,
X	  &iosb, NULL, 0,
X	  &typeahead, 0,
X	  0, 0, 0, 0);
X
X	return(typeahead.byte_count);
X}
X
X/*
X *	Read NCHAR characters from the terminal without echoing or
X *	interpretation.
X *	If the argument SECONDS is non-zero, use that as the
X *	timeout period in seconds for the read.
X *
X *	Returns SS$_TIMEOUT in case of timeout or other error.
X *	  Otherwise, returns the number of characters read.
X */
Xraw_read(nchar, charbuf, seconds)
Xchar		*charbuf;
Xint		nchar;
Xunsigned	seconds;
X{
X	short			function;
X	int			status;
X	struct	tt_io_iosb	iosb;
X
X	if (tt_chan == -1)
X		assign_channel();
X
X	function	= IO$_READVBLK | IO$M_NOECHO | IO$M_NOFILTR;
X
X	if (seconds)
X		status	= sys$qiow(0, tt_chan, function | IO$M_TIMED,
X		  &iosb, NULL, 0,
X		  charbuf, nchar, seconds,
X		  &termin_mask, NULL, 0);
X	else
X		status	= sys$qiow(0, tt_chan, function,
X		  &iosb, NULL, 0,
X		  charbuf, nchar, 0,
X		  &termin_mask, NULL, 0);
X
X	if (iosb.byte_count)
X		return iosb.byte_count;
X	return SS$_TIMEOUT;
X}
X
X/*
X *	Writes a character to the terminal without echoing or
X *	interpretation.
X */
Xraw_write(c)
Xchar	c;
X{
X	int			status;
X	struct	tt_io_iosb	iosb;
X
X	if (tt_chan == -1)
X		assign_channel();
X
X	status	= sys$qiow(0, tt_chan,
X	  IO$_WRITEVBLK | IO$M_CANCTRLO | IO$M_NOFORMAT,
X	  &iosb, NULL, 0,
X	  &c, 1, 0, 0, 0, 0);
X
X	if (status != SS$_NORMAL || iosb.status != SS$_NORMAL)
X		fatal("RAW_WRITE:  write QIO error return.\n");
X
X	return;
X}
X
X/*
X *	Writes a buffer to the terminal without echoing or
X *	interpretation.
X */
Xraw_wbuf(nchar, charbuf)
Xchar		*charbuf;
Xint		nchar;
X{
X	int			status;
X	struct	tt_io_iosb	iosb;
X
X	if (tt_chan == -1)
X		assign_channel();
X
X	status	= sys$qiow(0, tt_chan,
X	  IO$_WRITEVBLK | IO$M_CANCTRLO | IO$M_NOFORMAT,
X	  &iosb, NULL, 0,
X	  charbuf, nchar, 0, 0, 0, 0);
X
X	if (status != SS$_NORMAL || iosb.status != SS$_NORMAL)
X		fatal("RAW_WRITE:  write QIO error return.\n");
X
X	return;
X}
X
X/*
X *  Sets terminal information from VMS.
X *	 Modified 12-85 Larry Farr/Chuck Forsberg to not use
X *	 bad parity returned by VMS 4.
X */
Xstty(tt_characteristics)
Xstruct	tt_info	*tt_characteristics;
X{
X	short			*f_ptr, /* *p_ptr, */ *s_ptr;
X	int			status;
X	struct	tt_mode_iosb	iosb;
X
X	if (tt_chan == -1)
X		assign_channel();
X
X/*
X *	We do the following in order to get a full short, concatenating
X *	two adjacent chars:
X */
X	s_ptr	= &(tt_characteristics->dev_modes.t_speed);	/*  Speeds  */
X	f_ptr	= &(tt_characteristics->dev_modes.CR_fill);	/*  Fills  */
X	/* p_ptr	= &(tt_characteristics->dev_modes.parity_flags); */
X
X	status	= sys$qiow(0, tt_chan, IO$_SETMODE,
X	  &iosb, NULL, 0,
X	  &(tt_characteristics->dev_characteristics), 12,
X	  /* *s_ptr, *f_ptr, *p_ptr, 0);	*/
X	  *s_ptr, *f_ptr, 0, 0);
X	if (status != SS$_NORMAL || iosb.status != SS$_NORMAL)
X		printf("STTY:  set mode QIO returned %d\n", status);
X
X	return(status);
X}
X
END_OF_FILE
if test 6120 -ne `wc -c <'vvmodem.c'`; then
    echo shar: \"'vvmodem.c'\" unpacked with wrong size!
fi
# end of 'vvmodem.c'
fi
if test -f 'zmodem.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'zmodem.h'\"
else
echo shar: Extracting \"'zmodem.h'\" \(6032 characters\)
sed "s/^X//" >'zmodem.h' <<'END_OF_FILE'
X/*
X *   Z M O D E M . H     Manifest constants for ZMODEM
X *    application to application file transfer protocol
X *    04-17-89  Chuck Forsberg Omen Technology Inc
X */
X#define ZPAD '*'	/* 052 Padding character begins frames */
X#define ZDLE 030	/* Ctrl-X Zmodem escape - `ala BISYNC DLE */
X#define ZDLEE (ZDLE^0100)	/* Escaped ZDLE as transmitted */
X#define ZBIN 'A'	/* Binary frame indicator (CRC-16) */
X#define ZHEX 'B'	/* HEX frame indicator */
X#define ZBIN32 'C'	/* Binary frame with 32 bit FCS */
X#define ZBINR32 'D'	/* RLE packed Binary frame with 32 bit FCS */
X#define ZVBIN 'a'	/* Binary frame indicator (CRC-16) */
X#define ZVHEX 'b'	/* HEX frame indicator */
X#define ZVBIN32 'c'	/* Binary frame with 32 bit FCS */
X#define ZVBINR32 'd'	/* RLE packed Binary frame with 32 bit FCS */
X#define ZRESC	0176	/* RLE flag/escape character */
X#define ZMAXHLEN 16	/* Max header information length  NEVER CHANGE */
X#define ZMAXSPLEN 1024	/* Max subpacket length  NEVER CHANGE */
X
X/* Frame types (see array "frametypes" in zm.c) */
X#define ZRQINIT	0	/* Request receive init */
X#define ZRINIT	1	/* Receive init */
X#define ZSINIT 2	/* Send init sequence (optional) */
X#define ZACK 3		/* ACK to above */
X#define ZFILE 4		/* File name from sender */
X#define ZSKIP 5		/* To sender: skip this file */
X#define ZNAK 6		/* Last packet was garbled */
X#define ZABORT 7	/* Abort batch transfers */
X#define ZFIN 8		/* Finish session */
X#define ZRPOS 9		/* Resume data trans at this position */
X#define ZDATA 10	/* Data packet(s) follow */
X#define ZEOF 11		/* End of file */
X#define ZFERR 12	/* Fatal Read or Write error Detected */
X#define ZCRC 13		/* Request for file CRC and response */
X#define ZCHALLENGE 14	/* Receiver's Challenge */
X#define ZCOMPL 15	/* Request is complete */
X#define ZCAN 16		/* Other end canned session with CAN*5 */
X#define ZFREECNT 17	/* Request for free bytes on filesystem */
X#define ZCOMMAND 18	/* Command from sending program */
X#define ZSTDERR 19	/* Output to standard error, data follows */
X
X/* ZDLE sequences */
X#define ZCRCE 'h'	/* CRC next, frame ends, header packet follows */
X#define ZCRCG 'i'	/* CRC next, frame continues nonstop */
X#define ZCRCQ 'j'	/* CRC next, frame continues, ZACK expected */
X#define ZCRCW 'k'	/* CRC next, ZACK expected, end of frame */
X#define ZRUB0 'l'	/* Translate to rubout 0177 */
X#define ZRUB1 'm'	/* Translate to rubout 0377 */
X
X/* zdlread return values (internal) */
X/* -1 is general error, -2 is timeout */
X#define GOTOR 0400
X#define GOTCRCE (ZCRCE|GOTOR)	/* ZDLE-ZCRCE received */
X#define GOTCRCG (ZCRCG|GOTOR)	/* ZDLE-ZCRCG received */
X#define GOTCRCQ (ZCRCQ|GOTOR)	/* ZDLE-ZCRCQ received */
X#define GOTCRCW (ZCRCW|GOTOR)	/* ZDLE-ZCRCW received */
X#define GOTCAN	(GOTOR|030)	/* CAN*5 seen */
X
X/* Byte positions within header array */
X#define ZF0	3	/* First flags byte */
X#define ZF1	2
X#define ZF2	1
X#define ZF3	0
X#define ZP0	0	/* Low order 8 bits of position */
X#define ZP1	1
X#define ZP2	2
X#define ZP3	3	/* High order 8 bits of file position */
X
X/* Bit Masks for ZRINIT flags byte ZF0 */
X#define CANFDX	01	/* Rx can send and receive true FDX */
X#define CANOVIO	02	/* Rx can receive data during disk I/O */
X#define CANBRK	04	/* Rx can send a break signal */
X#define CANRLE	010	/* Receiver can decode RLE */
X#define CANLZW	020	/* Receiver can uncompress */
X#define CANFC32	040	/* Receiver can use 32 bit Frame Check */
X#define ESCCTL 0100	/* Receiver expects ctl chars to be escaped */
X#define ESC8   0200	/* Receiver expects 8th bit to be escaped */
X
X/* Bit Masks for ZRINIT flags byte ZF0 */
X#define CANVHDR	01	/* Variable headers OK */
X
X/* Parameters for ZSINIT frame */
X#define ZATTNLEN 32	/* Max length of attention string */
X#define ALTCOFF ZF1	/* Offset to alternate canit string, 0 if not used */
X/* Bit Masks for ZSINIT flags byte ZF0 */
X#define TESCCTL 0100	/* Transmitter expects ctl chars to be escaped */
X#define TESC8   0200	/* Transmitter expects 8th bit to be escaped */
X
X/* Parameters for ZFILE frame */
X/* Conversion options one of these in ZF0 */
X#define ZCBIN	1	/* Binary transfer - inhibit conversion */
X#define ZCNL	2	/* Convert NL to local end of line convention */
X#define ZCRESUM	3	/* Resume interrupted file transfer */
X/* Management include options, one of these ored in ZF1 */
X#define ZMSKNOLOC	0200	/* Skip file if not present at rx */
X/* Management options, one of these ored in ZF1 */
X#define ZMMASK	037	/* Mask for the choices below */
X#define ZMNEWL	1	/* Transfer if source newer or longer */
X#define ZMCRC	2	/* Transfer if different file CRC or length */
X#define ZMAPND	3	/* Append contents to existing file (if any) */
X#define ZMCLOB	4	/* Replace existing file */
X#define ZMNEW	5	/* Transfer if source newer */
X	/* Number 5 is alive ... */
X#define ZMDIFF	6	/* Transfer if dates or lengths different */
X#define ZMPROT	7	/* Protect destination file */
X/* Transport options, one of these in ZF2 */
X#define ZTLZW	1	/* Lempel-Ziv compression */
X#define ZTRLE	3	/* Run Length encoding */
X/* Extended options for ZF3, bit encoded */
X#define ZXSPARS	64	/* Encoding for sparse file operations */
X#define ZCANVHDR	01	/* Variable headers OK */
X
X/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
X#define ZCACK1	1	/* Acknowledge, then do command */
X
Xlong rclhdr();
X
X/* Globals used by ZMODEM functions */
Xextern Rxframeind;	/* ZBIN ZBIN32, or ZHEX type of frame */
Xextern Rxtype;		/* Type of header received */
Xextern Rxcount;		/* Count of data bytes received */
Xextern Rxtimeout;	/* Tenths of seconds to wait for something */
Xextern long Rxpos;	/* Received file position */
Xextern long Txpos;	/* Transmitted file position */
Xextern Txfcs32;		/* TURE means send binary frames with 32 bit FCS */
Xextern Crc32t;		/* Display flag indicating 32 bit CRC being sent */
Xextern Crc32;		/* Display flag indicating 32 bit CRC being received */
Xextern Znulls;		/* Number of nulls to send at beginning of ZDATA hdr */
Xextern char Attn[ZATTNLEN+1];	/* Attention string rx sends to tx on err */
Xextern char *Altcan;	/* Alternate canit string */
X
X/* End of ZMODEM.H */
END_OF_FILE
if test 6032 -ne `wc -c <'zmodem.h'`; then
    echo shar: \"'zmodem.h'\" unpacked with wrong size!
fi
# end of 'zmodem.h'
fi
if test -f 'zmr.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'zmr.c'\"
else
echo shar: Extracting \"'zmr.c'\" \(3942 characters\)
sed "s/^X//" >'zmr.c' <<'END_OF_FILE'
X/*
X * File: zmr.c 12-04-1988
X * Copyright 1988 Omen Technology Inc All Rights Reserved
X *
X *
X *	This code implements ZMODEM Run Length Encoding, not funded
X *	by the original Telenet development contract.  This software,
X *	including these features, may be freely used for non
X *	commercial and educational purposes.  This software may also
X *	be freely used to support file transfer operations to or from
X *	licensed Omen Technology products.  Contact Omen Technology
X *	for licensing for other uses.  Any programs which use part or
X *	all of this software must be provided in source form with this
X *	notice intact except by written permission from Omen
X *	Technology Incorporated.
X *
X *		Omen Technology Inc		FAX: 503-621-3745
X *		Post Office Box 4681
X *		Portland OR 97208
X *
X *	This code is made available in the hope it will be useful,
X *	BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANY
X *	DAMAGES OF ANY KIND.
X *	ZMODEM RLE compression and decompression functions
X */
X
X/* Send data subpacket RLE encoded with 32 bit FCS */
Xzsdar32(buf, length, frameend)
Xchar *buf;
X{
X	register int c, l, n;
X	register UNSL long crc;
X
X	crc = 0xFFFFFFFFL;  l = *buf++ & 0377;
X	if (length == 1) {
X		zsendline(l); crc = UPDC32(l, crc);
X		if (l == ZRESC) {
X			zsendline(1); crc = UPDC32(1, crc);
X		}
X	} else {
X		for (n = 0; --length >= 0; ++buf) {
X			if ((c = *buf & 0377) == l && n < 126 && length>0) {
X				++n;  continue;
X			}
X			switch (n) {
X			case 0:
X				zsendline(l);
X				crc = UPDC32(l, crc);
X				if (l == ZRESC) {
X					zsendline(0100); crc = UPDC32(0100, crc);
X				}
X				l = c; break;
X			case 1:
X				if (l != ZRESC) {
X					zsendline(l); zsendline(l);
X					crc = UPDC32(l, crc);
X					crc = UPDC32(l, crc);
X					n = 0; l = c; break;
X				}
X				/* **** FALL THRU TO **** */
X			default:
X				zsendline(ZRESC); crc = UPDC32(ZRESC, crc);
X				if (l == 040 && n < 34) {
X					n += 036;
X					zsendline(n); crc = UPDC32(n, crc);
X				}
X				else {
X					n += 0101;
X					zsendline(n); crc = UPDC32(n, crc);
X					zsendline(l); crc = UPDC32(l, crc);
X				}
X				n = 0; l = c; break;
X			}
X		}
X	}
X	xsendline(ZDLE); xsendline(frameend);
X	crc = UPDC32(frameend, crc);
X
X	crc = ~crc;
X	for (length=4; --length >= 0;) {
X		zsendline((int)crc);  crc >>= 8;
X	}
X}
X
X
X/* Receive data subpacket RLE encoded with 32 bit FCS */
Xzrdatr32(buf, length)
Xregister char *buf;
X{
X	register int c;
X	register UNSL long crc;
X	register char *end;
X	register int d;
X
X	crc = 0xFFFFFFFFL;  Rxcount = 0;  end = buf + length;
X	d = 0;	/* Use for RLE decoder state */
X	while (buf <= end) {
X		if ((c = zdlread()) & ~0377) {
Xcrcfoo:
X			switch (c) {
X			case GOTCRCE:
X			case GOTCRCG:
X			case GOTCRCQ:
X			case GOTCRCW:
X				d = c;  c &= 0377;
X				crc = UPDC32(c, crc);
X				if ((c = zdlread()) & ~0377)
X					goto crcfoo;
X				crc = UPDC32(c, crc);
X				if ((c = zdlread()) & ~0377)
X					goto crcfoo;
X				crc = UPDC32(c, crc);
X				if ((c = zdlread()) & ~0377)
X					goto crcfoo;
X				crc = UPDC32(c, crc);
X				if ((c = zdlread()) & ~0377)
X					goto crcfoo;
X				crc = UPDC32(c, crc);
X				if (crc != 0xDEBB20E3) {
X					zperr(badcrc);
X					return ERROR;
X				}
X				Rxcount = length - (end - buf);
X#ifndef DSZ
X				vfile("zrdatr32: %d %s", Rxcount,
X				  Zendnames[d-GOTCRCE&3]);
X#endif
X				return d;
X			case GOTCAN:
X				zperr("Sender Canceled");
X				return ZCAN;
X			case TIMEOUT:
X				zperr("TIMEOUT");
X				return c;
X			default:
X				zperr("Bad data subpacket");
X				return c;
X			}
X		}
X		crc = UPDC32(c, crc);
X		switch (d) {
X		case 0:
X			if (c == ZRESC) {
X				d = -1;  continue;
X			}
X			*buf++ = c;  continue;
X		case -1:
X			if (c >= 040 && c < 0100) {
X				d = c - 035; c = 040;  goto spaces;
X			}
X			if (c == 0100) {
X				d = 0;
X				*buf++ = ZRESC;  continue;
X			}
X			d = c;  continue;
X		default:
X			d -= 0100;
X			if (d < 1)
X				goto badpkt;
Xspaces:
X			if ((buf + d) > end)
X				goto badpkt;
X			while ( --d >= 0)
X				*buf++ = c;
X			d = 0;  continue;
X		}
X	}
Xbadpkt:
X	zperr("Data subpacket too long");
X	return ERROR;
X}
X
END_OF_FILE
if test 3942 -ne `wc -c <'zmr.c'`; then
    echo shar: \"'zmr.c'\" unpacked with wrong size!
fi
# end of 'zmr.c'
fi
if test -f 'zupl.t' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'zupl.t'\"
else
echo shar: Extracting \"'zupl.t'\" \(734 characters\)
sed "s/^X//" >'zupl.t' <<'END_OF_FILE'
X	echo "ProYAM/ZCOMM script to upload minirb and rz/sz to *nix"
X	if S>1200 pt1
X	ena -t
X	if !fminirb.c echo "Can't find minirb.c !!";  abort
X	putw "stty -echo; cat >minirb.c\r"
X	f -xHr minirb.c
X	putw "\r\4"
X	putw "stty echo\r"
X	dis -h
X	pat 1 "rwx"
X	pat 2 "%"
X	put "cc minirb.c -o minirb; ls -l minirb\r"
X	wait -f120
X	if 1 goto okok
X	echo "The compiiation appears to have failed."
X	echo "Please compile minirb.c to minirb, then"
X	echo "hit F5 to upload the rest of the rz/sz files."
X	set f5
X@putw minirb\r; sb README zmodem.h zm.c sz.c rz.c crctab.c rbsb.c *.1 gz ptest.sh
X	t
X	return
Xokok:	echo "Minirb Compilation Appears Successful."
X	put minirb\r
X	sb README ?akefile zmodem.h zm.c sz.c rz.c crctab.c rbsb.c *.1 gz ptest.sh
X	t
X	return
END_OF_FILE
if test 734 -ne `wc -c <'zupl.t'`; then
    echo shar: \"'zupl.t'\" unpacked with wrong size!
fi
# end of 'zupl.t'
fi
echo shar: End of archive 1 \(of 4\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

