[comp.os.minix] Zmodem file transfer for Minix Part 01/03

jdoss@killer.Dallas.TX.US (Joe M. Doss, Jr.) (03/26/89)

Here is the source for the send & receive programs to implement
the Zmodem protocol under Minix.  For those of you who don't
know, Zmodem is about the fastest, most efficient file transfer
protocol around.  It is much more efficient than regular xmodem,
especially over packet-switched networks like Telenet or Tymnet.
			Enjoy,
				Joe M. Doss, Jr.
				jdoss@killer.Dallas.TX.US

#-----------------------Cut Here---------------------------------------
#! /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 3)."
# Contents:  MANIFEST Makefile Makefile.old README README.caf crctab.c
#   rbsb.c rz.1 stdio.h.cdiff sz.1 zmodem.h
# Wrapped by root@jmdst on Sat Mar 25 15:38:05 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(875 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	this shipping list
X Makefile                   1	the Makefile I use
X Makefile.old               1	the Makefile from the original distribution
X README                     1	general description of the programs
X README.caf                 1	Original Author's README
X crctab.c                   1	CRC calculation routines
X rbsb.c                     1	Unix-specific functions
X rz.1                       1	man page for rz, rb, rx
X rz.c                       2	main rz source file
X stdio.h.cdiff              1	Patch for stdio.h
X sz.1                       1	man page for sz, sb, sx
X sz.c                       3	main sz source file
X zm.c                       2	low-level zmodem functions
X zmodem.h                   1	common header file for both progs
END_OF_FILE
if test 875 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(576 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# makefile for zmodem receive and send programs rz & sz
X#  Minix version
X#
all: rz sz
X
CC = cc
TMPDIR=/spool/tmp
CFLAGS=-O -T$(TMPDIR) -DV7
X# destination for calling from cu
BIN=/usr/lib
X
rz: rz.c rbsb.c zm.c zmodem.h
X	$(CC) $(CFLAGS) -o rz rz.c
X	chmem =10000 rz
X
sz: sz.c rbsb.c zm.c zmodem.h
X	$(CC) $(CFLAGS) -o sz sz.c
X	chmem =10000 sz
X
X#
X# install in appropriate directory
X#
install: sz rz
X	rm -f $(BIN)/rb $(BIN)/sb $(BIN)/rz $(BIN)/sz $(BIN)/rx $(BIN)/sx
X	cp rz sz $(BIN)
X	ln $(BIN)/rz $(BIN)/rb
X	ln $(BIN)/rz $(BIN)/rx
X	ln $(BIN)/sz $(BIN)/sb
X	ln $(BIN)/sz $(BIN)/sx
END_OF_FILE
if test 576 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'Makefile.old' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile.old'\"
else
echo shar: Extracting \"'Makefile.old'\" \(2128 characters\)
sed "s/^X//" >'Makefile.old' <<'END_OF_FILE'
X# Makefile for Unix/Xenix rz and sz programs
X# the makefile is not too well tested yet
X
X# use TMPDIR if /tmp isn't big enough (ramdisk)
TMPDIR=/spool/tmp
X
nothing:
X	@echo
X	@echo "Please study the #ifdef's in crctab.c rbsb.c, rz.c and sz.c,"
X	@echo "then type 'make system' where system is one of:"
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
usenet:
X	shar -f rzsz.shar README Makefile zmodem.h zm.c sz.c rz.c rbsb.c \
X	crctab.c *.1
X
unix:
X	undos README zmodem.h zm.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c crctab.c *.1 \
X	 init.com crc.c *.t 
X
dos:
X	todos README zmodem.h zm.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c crctab.c *.1 \
X	 init.com crc.c *.t 
arc:
X	rm -f /tmp/rzsz.arc
X	arc a /tmp/rzsz README Makefile zmodem.h zm.c sz.c rz.c \
X	 vmodem.h vvmodem.c vrzsz.c crctab.c rbsb.c \
X	 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
zoo:
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	 init.com crc.c gz ptest.sh *.t minirb.c
X	chmod og-w /tmp/rzsz.zoo
X	mv /tmp/rzsz.zoo /t/yam
X
tags:
X	ctags sz.c rz.c zm.c rbsb.c
X
X.PRECIOUS:rz sz
X
xenix:
X	cc -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 -M0 -Ox -K -i -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X
x386:
X	cc -Ox -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	cc -Ox -DTXBSIZE=32768 -DNFGVMIN -DREADCHECK sz.c -lx -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
sysv:
X	cc -O -DMD rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	cc -DSV -O -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
sysvr3:
X	cc -O -DMD=2 rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	cc -DSV -O -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
bsd:
X	cc -DMD=2 -Dstrchr=index -DV7 -O rz.c -o rz
X	size rz
X	-ln rz rb
X	-ln rz rx
X	cc -DV7 -O -DTXBSIZE=32768 -DNFGVMIN sz.c -o sz
X	size sz
X	-ln sz sb
X	-ln sz sx
X
X
sz: nothing
sb: nothing
rz: nothing
rb: nothing
END_OF_FILE
if test 2128 -ne `wc -c <'Makefile.old'`; then
    echo shar: \"'Makefile.old'\" unpacked with wrong size!
fi
# end of 'Makefile.old'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1235 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X      README for Zmodem file transfer programs, Minix versions
X
Included with this readme file, you will find all the source necessary
to compile rz and sz for Minix. (This has only been tested on an Atari ST,
they might require minor modifications for PC's.)  This is basically
the zmodem distribution posted to comp.sources.unix a while back, with
a few modifications to get it running under Minix.  They should still
compile under Unix without changes. (Use Makefile.old) 
X
The source mentions several VAX/VMS specific source files.  
These are (obviously) not included in this comp.os.minix posting.  
If you need them, they can be found on any comp.sources.unix archive site.
X
One change is needed to /usr/include/stdio.h to define the clearerr macro.
To make the change copy stdio.h.cdiff to /usr/include, cd /usr/include,
and patch <stdio.h.cdiff. After that, just 'make install' and cross
your fingers.
X
These programs have only been tested by calling them from cu with
X ~%local rz 
X   or
X ~%local sz [files...]
X
but they should be usable for a user logged in over a remote terminal
line.  You may want to install them in /usr/bin instead of /usr/lib
for this purpose.
X
Have fun,
X
Joe M. Doss, Jr.
jdoss@killer.Dallas.TX.US
X
X
END_OF_FILE
if test 1235 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'README.caf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README.caf'\"
else
echo shar: Extracting \"'README.caf'\" \(2333 characters\)
sed "s/^X//" >'README.caf' <<'END_OF_FILE'
New for April 1988:  VMS C flavors of rz and sz especially for tired
frog 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
The contents of RZSZ.ARC can be uploaded to a VAX/XMS system by ZCOMM or
Professional-YAM using the supplied vupl.t script.  Connect to your VMS
system, 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
the files to it.  If the script can't fire up a Kermit server, the
script will use the VMS DCL "create" command to upload the files
directly.  In the latter case, use a clean line for best results.
X
The contents of RZSZ.ARC can be uploaded to a Unix or Xenix system by
ZCOMM or Professional-YAM using the supplied zupl.t script.  Connect to
your Unix/Xenix system, select an empty directory, and then give the
YAM/ZCOMM command: "source zupl.t".  This will upload minirb.c, compile
it, and then use minirb to upload the rz/sz files.
X
Once these files are on your Unix system, you can type "make".
The Makefile will list the various systems it knows how to
compile the programs for, and the command to do so (e.g., "make bsd").
X
The Makefile is self explanatory; just say "make".
X
Naturally, rz and sz work best with comm programs that seamlessly
support ZMODEM command and file AutoDownload (Pro-YAM and ZCOMM).
X
The "DSZ" shareware program allows ZMODEM file transfers with
traditional DOS comm programs, but it must be called manually.
X(The computer should do that for you!)  DSZ provides a "mini term
function" that supports ZMODEM AutoDownload.  DSZ (part of DSZ.ARC) and
the ZMODEM protocol description (YZMODEM.ARC) are on TeleGodzilla and
other fine bulletin boards.
X
Chuck 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
TeleGodzilla 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 2333 -ne `wc -c <'README.caf'`; then
    echo shar: \"'README.caf'\" unpacked with wrong size!
fi
# end of 'README.caf'
fi
if test -f 'crctab.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'crctab.c'\"
else
echo shar: Extracting \"'crctab.c'\" \(8737 characters\)
sed "s/^X//" >'crctab.c' <<'END_OF_FILE'
X/*
X *  Crc calculation stuff
X */
X
X/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
static unsigned short crctab[256] = {
X    0x0000,  0x1021,  0x2042,  0x3063,  0x4084,  0x50a5,  0x60c6,  0x70e7,
X    0x8108,  0x9129,  0xa14a,  0xb16b,  0xc18c,  0xd1ad,  0xe1ce,  0xf1ef,
X    0x1231,  0x0210,  0x3273,  0x2252,  0x52b5,  0x4294,  0x72f7,  0x62d6,
X    0x9339,  0x8318,  0xb37b,  0xa35a,  0xd3bd,  0xc39c,  0xf3ff,  0xe3de,
X    0x2462,  0x3443,  0x0420,  0x1401,  0x64e6,  0x74c7,  0x44a4,  0x5485,
X    0xa56a,  0xb54b,  0x8528,  0x9509,  0xe5ee,  0xf5cf,  0xc5ac,  0xd58d,
X    0x3653,  0x2672,  0x1611,  0x0630,  0x76d7,  0x66f6,  0x5695,  0x46b4,
X    0xb75b,  0xa77a,  0x9719,  0x8738,  0xf7df,  0xe7fe,  0xd79d,  0xc7bc,
X    0x48c4,  0x58e5,  0x6886,  0x78a7,  0x0840,  0x1861,  0x2802,  0x3823,
X    0xc9cc,  0xd9ed,  0xe98e,  0xf9af,  0x8948,  0x9969,  0xa90a,  0xb92b,
X    0x5af5,  0x4ad4,  0x7ab7,  0x6a96,  0x1a71,  0x0a50,  0x3a33,  0x2a12,
X    0xdbfd,  0xcbdc,  0xfbbf,  0xeb9e,  0x9b79,  0x8b58,  0xbb3b,  0xab1a,
X    0x6ca6,  0x7c87,  0x4ce4,  0x5cc5,  0x2c22,  0x3c03,  0x0c60,  0x1c41,
X    0xedae,  0xfd8f,  0xcdec,  0xddcd,  0xad2a,  0xbd0b,  0x8d68,  0x9d49,
X    0x7e97,  0x6eb6,  0x5ed5,  0x4ef4,  0x3e13,  0x2e32,  0x1e51,  0x0e70,
X    0xff9f,  0xefbe,  0xdfdd,  0xcffc,  0xbf1b,  0xaf3a,  0x9f59,  0x8f78,
X    0x9188,  0x81a9,  0xb1ca,  0xa1eb,  0xd10c,  0xc12d,  0xf14e,  0xe16f,
X    0x1080,  0x00a1,  0x30c2,  0x20e3,  0x5004,  0x4025,  0x7046,  0x6067,
X    0x83b9,  0x9398,  0xa3fb,  0xb3da,  0xc33d,  0xd31c,  0xe37f,  0xf35e,
X    0x02b1,  0x1290,  0x22f3,  0x32d2,  0x4235,  0x5214,  0x6277,  0x7256,
X    0xb5ea,  0xa5cb,  0x95a8,  0x8589,  0xf56e,  0xe54f,  0xd52c,  0xc50d,
X    0x34e2,  0x24c3,  0x14a0,  0x0481,  0x7466,  0x6447,  0x5424,  0x4405,
X    0xa7db,  0xb7fa,  0x8799,  0x97b8,  0xe75f,  0xf77e,  0xc71d,  0xd73c,
X    0x26d3,  0x36f2,  0x0691,  0x16b0,  0x6657,  0x7676,  0x4615,  0x5634,
X    0xd94c,  0xc96d,  0xf90e,  0xe92f,  0x99c8,  0x89e9,  0xb98a,  0xa9ab,
X    0x5844,  0x4865,  0x7806,  0x6827,  0x18c0,  0x08e1,  0x3882,  0x28a3,
X    0xcb7d,  0xdb5c,  0xeb3f,  0xfb1e,  0x8bf9,  0x9bd8,  0xabbb,  0xbb9a,
X    0x4a75,  0x5a54,  0x6a37,  0x7a16,  0x0af1,  0x1ad0,  0x2ab3,  0x3a92,
X    0xfd2e,  0xed0f,  0xdd6c,  0xcd4d,  0xbdaa,  0xad8b,  0x9de8,  0x8dc9,
X    0x7c26,  0x6c07,  0x5c64,  0x4c45,  0x3ca2,  0x2c83,  0x1ce0,  0x0cc1,
X    0xef1f,  0xff3e,  0xcf5d,  0xdf7c,  0xaf9b,  0xbfba,  0x8fd9,  0x9ff8,
X    0x6e17,  0x7e36,  0x4e55,  0x5e74,  0x2e93,  0x3eb2,  0x0ed1,  0x1ef0
X};
X
X/*
X * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. 
X *  NOTE: First srgument must be in range 0 to 255.
X *        Second argument is referenced twice.
X * 
X * Programmers may incorporate any or all code into their programs, 
X * giving proper credit within the source. Publication of the 
X * source routines is permitted so long as proper credit is given 
X * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, 
X * Omen Technology.
X */
X
X#define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp)
X
X/*
X * Copyright (C) 1986 Gary S. Brown.  You may use this program, or
X * code or tables extracted from it, as desired without restriction.
X */
X
X/* First, the polynomial itself and its table of feedback terms.  The  */
X/* polynomial is                                                       */
X/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
X/* Note that we take it "backwards" and put the highest-order term in  */
X/* the lowest-order bit.  The X^32 term is "implied"; the LSB is the   */
X/* X^31 term, etc.  The X^0 term (usually shown as "+1") results in    */
X/* the MSB being 1.                                                    */
X
X/* Note that the usual hardware shift register implementation, which   */
X/* is what we're using (we're merely optimizing it by doing eight-bit  */
X/* chunks at a time) shifts bits into the lowest-order term.  In our   */
X/* implementation, that means shifting towards the right.  Why do we   */
X/* do it this way?  Because the calculated CRC must be transmitted in  */
X/* order from highest-order term to lowest-order term.  UARTs transmit */
X/* characters in order from LSB to MSB.  By storing the CRC this way,  */
X/* we hand it to the UART in the order low-byte to high-byte; the UART */
X/* sends each low-bit to hight-bit; and the result is transmission bit */
X/* by bit from highest- to lowest-order term without requiring any bit */
X/* shuffling on our part.  Reception works similarly.                  */
X
X/* The feedback terms table consists of 256, 32-bit entries.  Notes:   */
X/*                                                                     */
X/*     The table can be generated at runtime if desired; code to do so */
X/*     is shown later.  It might not be obvious, but the feedback      */
X/*     terms simply represent the results of eight shift/xor opera-    */
X/*     tions for all combinations of data and CRC register values.     */
X/*                                                                     */
X/*     The values must be right-shifted by eight bits by the "updcrc"  */
X/*     logic; the shift must be unsigned (bring in zeroes).  On some   */
X/*     hardware you could probably optimize the shift in assembler by  */
X/*     using byte-swap instructions.                                   */
X
static long cr3tab[] = { /* CRC polynomial 0xedb88320 */
X0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
X0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
X0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
X0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
X0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
X0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
X0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
X0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
X0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
X0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
X0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
X0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
X0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
X0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
X0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
X0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
X0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
X0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
X0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
X0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
X0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
X0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
X0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
X0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
X0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
X0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
X0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
X0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
X0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
X0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
X0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
X0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
X};
X
X#ifdef NFGM
long
UPDC32(b, c)
long c;
X{
X	return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF));
X}
X
X#else
X
X#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF))
X#endif
X
X/* End of crctab.c */
END_OF_FILE
if test 8737 -ne `wc -c <'crctab.c'`; then
    echo shar: \"'crctab.c'\" unpacked with wrong size!
fi
# end of 'crctab.c'
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'\" \(6797 characters\)
sed "s/^X//" >'rbsb.c' <<'END_OF_FILE'
X/*
X *
X *  Rev 05-05-1988
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#include <sgtty.h>
X#define OS "V7/BSD"
X#ifdef LLITOUT
long Locmode;		/* Saved "local mode" for 4.x BSD "new driver" */
long 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#include <termio.h>
X#include <sys/ioctl.h>
X#define OS "SYS III/V"
X#define MODE2OK
X#include <string.h>
X#endif
X
X#if HOWMANY  > 255
Howmany 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 */
int Fromcu;		/* Were called from cu or yam */
from_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}
cucheck()
X{
X	if (Fromcu)
X		fprintf(stderr,"Please read the manual page BUGS chapter!\r\n");
X}
X
X
struct {
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#ifdef EXTA
X	19200,	EXTA,
X	38400,	EXTB,
X#endif
X	0,
X};
X
int Twostop;		/* Use two stop bits */
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 */
rdchk(f)
X{
X	static long lf;
X
X	ioctl(f, FIONREAD, &lf);
X	return ((int) lf);
X}
X#endif
X#ifdef SV
X#define READCHECK
X#include <fcntl.h>
X
char checked = '\0' ;
X/*
X * Nonblocking I/O is a bit different in System V, Release 2
X */
rdchk(f)
X{
X	int lf, savestat;
X
X	savestat = fcntl(f, F_GETFL) ;
X	fcntl(f, F_SETFL, savestat | O_NDELAY) ;
X	lf = read(f, &checked, 1) ;
X	fcntl(f, F_SETFL, savestat) ;
X	return(lf) ;
X}
X#endif
X#endif
X
X
static unsigned
getspeed(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
struct termio oldtty, tty;
X#else
struct sgttyb oldtty, tty;
struct tchars oldtch, tch;
X#endif
X
int iofd = 0;		/* File descriptor for ioctls & reads */
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 */
mode(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(iofd, 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(iofd, TCSETAW, &tty);
X		did0 = TRUE;
X		return OK;
X	case 1:
X	case 3:
X		if(!did0)
X			(void) ioctl(iofd, 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(iofd, TCSETAW, &tty);
X		did0 = TRUE;
X		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	 *   READCHECK 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#ifdef TIOCEXCL
X			ioctl(iofd, TIOCEXCL, 0);
X#endif
X			ioctl(iofd, TIOCGETP, &oldtty);
X			ioctl(iofd, TIOCGETC, &oldtch);
X#ifdef LLITOUT
X			ioctl(iofd, 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#ifdef ODDP
X		tty.sg_flags |= (ODDP|EVENP|CBREAK);
X		tty.sg_flags &= ~(ALLDELAY|CRMOD|ECHO|LCASE);
X#else
X		tty.sg_flags |= CBREAK;
X		tty.sg_flags &= ~(CRMOD|ECHO);
X#endif
X		ioctl(iofd, TIOCSETP, &tty);
X		ioctl(iofd, TIOCSETC, &tch);
X#ifdef LLITOUT
X		ioctl(iofd, 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#ifdef TIOCEXCL
X			ioctl(iofd, TIOCEXCL, 0);
X#endif
X			ioctl(iofd, TIOCGETP, &oldtty);
X			ioctl(iofd, TIOCGETC, &oldtch);
X#ifdef LLITOUT
X			ioctl(iofd, TIOCLGET, &Locmode);
X#endif
X		}
X		tty = oldtty;
X		tty.sg_flags |= RAW;
X		tty.sg_flags &= ~ECHO;
X		ioctl(iofd, TIOCSETP, &tty);
X		did0 = TRUE;
X		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(iofd, TCSBRK, 1);	/* Wait for output to drain */
X		(void) ioctl(iofd, TCFLSH, 1);	/* Flush input queue */
X		(void) ioctl(iofd, TCSETAW, &oldtty);	/* Restore modes */
X		(void) ioctl(iofd, TCXONC,1);	/* Restart output */
X#endif
X#ifdef V7
X		ioctl(iofd, TIOCSETP, &oldtty);
X		ioctl(iofd, TIOCSETC, &oldtch);
X#ifdef TIOCNXCL
X		ioctl(iofd, TIOCNXCL, 0);
X#endif
X#ifdef LLITOUT
X		ioctl(iofd, TIOCLSET, &Locmode);
X#endif
X#endif
X
X		return OK;
X	default:
X		return ERROR;
X	}
X}
X
sendbrk()
X{
X#ifdef V7
X#ifdef TIOCSBRK
X#define CANBREAK
X	sleep(1);
X	ioctl(iofd, TIOCSBRK, 0);
X	sleep(1);
X	ioctl(iofd, TIOCCBRK, 0);
X#endif
X#endif
X#ifdef USG
X#define CANBREAK
X	ioctl(iofd, TCSBRK, 0);
X#endif
X}
X
X/* End of rbsb.c */
END_OF_FILE
if test 6797 -ne `wc -c <'rbsb.c'`; then
    echo shar: \"'rbsb.c'\" unpacked with wrong size!
fi
# end of 'rbsb.c'
fi
if test -f 'rz.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rz.1'\"
else
echo shar: Extracting \"'rz.1'\" \(8454 characters\)
sed "s/^X//" >'rz.1' <<'END_OF_FILE'
X'\" Revision Level 
X'\" Last Delta     04-22-88
X.TH RZ 1 OMEN
X.SH NAME
rx, rb, rz \- XMODEM, YMODEM, ZMODEM (Batch) file receive
X.SH SYNOPSIS
X.B rz
X.RB [\- "\ +abepqtuvy" ]
X.br
X.B rb
X.RB [\- "\ +abqtuvy" ]
X.br
X.B rx
X.RB [\- "\ abceqtuv" ]
X.I file
X.br
X.B gz
X.I "file ..."
X.br
X.RB [ \- ][ v ] rzCOMMAND
X.SH DESCRIPTION
This program uses error correcting protocols to receive
files over a dial-in serial port from a variety of programs running under
PC-DOS, CP/M,
X.SM Unix,
and other operating systems.
It is invoked from a shell prompt
manually, or automatically as a result of an
X"sz file ..." command given to the calling program.
X
While
X.I rz
is smart enough to be called from
X.I cu(1),
very few versions of
X.I cu(1)
are smart enough to allow
X.I rz
to work properly.
Unix flavors of Professional-YAM are available for such dial-out application.
X
X
X.B Rz
X(Receive ZMODEM)
receives files with the ZMODEM batch protocol.
Pathnames are supplied by the sending program,
and directories are made if necessary (and possible).
Normally, the
X"rz" command is automatically issued by the calling ZMODEM program,
but some defective ZMODEM implementations may require starting
X.I rz
the old fashioned way.
X
X
X.B Rb
receives file(s) with YMODEM,
accepting either standard 128 byte sectors or
X1024 byte sectors
X(YAM sb
X.B -k
option).
The user should determine when
the 1024 byte block length
actually improves throughput without causing lost data
or even system crashes.
X
If True YMODEM (Omen Technology trademark) file information (file length, etc.)
is received,
the file length controls the number of bytes written to
the output dataset,
and the modify time and file mode
X(iff non zero)
are set accordingly.
X
If no True YMODEM file information is received,
slashes in the pathname are changed to underscore,
and any trailing period in the pathname is eliminated.
This conversion is useful for files received from CP/M systems.
With YMODEM, each file name is converted to lower case
unless it contains one or more lower case letters.
X
X
X.B Rx
receives a single
X.I file
with XMODEM or XMODEM-1k protocol.
The user should determine when
the 1024 byte block length
actually improves throughput without causing problems.
The user must supply the file name to both sending and receiving programs.
Up to 1023 garbage characters may be added to the received file.
X
X.B Gz
is a shell script which calls
X.I sz
to command Pro-YAM or ZCOMM to transmit the specified files.
Pathnames used with
X.I gz
must be escaped if they have special significance to the Unix shell.
X.br
XEXAMPLE:
gz "-a C:*.c D:*.h"
X
X
X.B Rz
may be invoked as
X.B rzCOMMAND
X(with an optional leading \- as generated by login(1)).
XFor each received file,
X.I rz
will pipe the file to ``COMMAND filename''
where filename is the name of the transmitted file
with the file contents as standard input.
X
XEach file transfer is acknowledged when COMMAND exits with 0 status.
A non zero exit status terminates transfers.
X
A typical use for this form is
X.I rzrmail
which calls rmail(1)
to post mail to the user specified by the transmitted file name.
XFor example, sending the file "caf" from a PC-DOS system to
X.I rzrmail
on a
X.SM Unix
system
would result in the contents of the DOS file "caf" being mailed to user "caf".
X
On some
X.SM Unix
systems, the login directory must contain a link to
COMMAND as login sets SHELL=rsh which disallows absolute
pathnames.
If invoked with a leading ``v'',
X.I rz
will report progress to /tmp/rzlog.
The following entry works for
X.SM Unix
SYS III/V:
X.ce
rzrmail::5:1::/bin:/usr/local/rzrmail
If the SHELL environment variable includes
X.I "rsh"
or
X.I "rksh"
X(restricted shell),
X.I rz
will not accept absolute pathnames
or references to a parent directory,
will not modify an existing file, and
removes any files received in error.
X
If
X.B rz
is invoked with stdout and stderr to different datasets,
Verbose is set to 2, causing frame by frame progress reports
to stderr.
This may be disabled with the
X.B q
option.
X
X.PP
The meanings of the available options are:
X.PP
X.PD 0
X.TP
X.B a
Convert files to
X.SM Unix
conventions by stripping carriage returns and all characters
beginning with the first Control Z (CP/M end of file).
X.TP
X.B b
Binary
X(tell it like it is)
file transfer override.
X.TP
X.B c
Request 16 bit CRC.
XXMODEM file transfers default to 8 bit checksum.
YMODEM and ZMODEM normally use 16 bit CRC.
X.TP
X.B D
Output file data to /dev/null; for testing.
X(Unix only)
X.TP
X.B e
XForce sender to escape all control characters;
normally XON, XOFF, DLE, CR-@-CR, and Ctrl-X are escaped.
X.TP
X.B p
X(ZMODEM) Protect: skip file if destination file exists.
X.TP
X.B q
Quiet suppresses verbosity.
X.TP
X.B "t tim"
Change timeout to
X.I tim
tenths of seconds.
X.TP
X.B v
Verbose
causes a list of file
names to be appended to
X/tmp/rzlog .
More v's generate more output.
X.TP
X.B y
Yes, clobber any existing files with the same name.
X.PD
X.ne 6
X.SH EXAMPLES
X.RE
X(Pro-YAM command)
X.RS
X.I <ALT-2>
X.br
Pro-YAM Command:
X.I "sz *.h *.c"
X.br
X(This automatically invokes
X.I rz
on the connected system.)
X.RE
X.SH SEE ALSO
ZMODEM.DOC,
YMODEM.DOC,
Professional-YAM,
crc(omen),
sz(omen),
usq(omen),
undos(omen)
X
Compile time options required
for various operating systems are described in the
source file.
X.SH NOTES
Sending serial data to timesharing minicomputers
at sustained high speeds
has been known to cause lockups, system halts, kernel panics,
and occasional antisocial behaviour.
When experimenting with high speed input to a
system, consider rebooting the system
if the file transfers are not successful,
especially if the personality of the system appears altered.
X
The Unix "ulimit" parameter must be set high enough
to permit large file transfers.
X
The TTY input buffering on some systems may not allow long blocks
or streaming input at high speed.
You should suspect this problem when you
can't send data to the Unix system at high speeds using ZMODEM,
YMODEM-1k or XMODEM-1k,
when YMODEM with 128 byte blocks works properly.
If the system's tty line handling is really broken, the serial port
or the entire system may not survive the onslaught of long bursts
of high speed data.
X
The DSZ or Pro-YAM
X.B "zmodem l"
numeric parameter may be set to a value between 64 and 1024 to limit the
burst length ("zmodem pl128").
X
X32 bit CRC code courtesy Gary S. Brown.
Directory creation code from John Gilmore's PD TAR program.
X.SH BUGS
Calling
X.I rz
from most versions of cu(1) doesn't work because cu's receive process
fights
X.I rz
for characters from the modem.
X
Programs that do not properly implement the specified file transfer protocol
may cause
X.I sz
to "hang" the port for a minute or two.
XEvery reported instance of this problem has been corrected by using
ZCOMM, Pro-YAM, or other program with a correct implementation
of the specified protocol.
X
Many programs claiming to support YMODEM only support XMODEM with 1k blocks,
and they often don't get that quite right.
X
Pathnames are restricted to 127 characters.
In XMODEM single file mode, the pathname given on the command line
is still processed as described above.
The ASCII option\'s CR/LF to NL translation merely deletes CR\'s;
undos(omen) performs a more intelligent translation.
X.SH "VMS VERSION"
The VMS version does not set the file time.
X
VMS C Standard I/O and RMS may interact to modify
file contents unexpectedly.
X
The VMS version does not support invocation as
X.B rzCOMMAND .
The current VMS version does not support XMODEM, XMODEM-1k, or YMODEM.
X
According to the VMS documentation,
the buffered input routine used on the VMS version of
X.I rz
introduces a delay
of up to one second for each protocol transaction.
This delay may be significant for very short files.
Removing the "#define BUFREAD" line from rz.c will
eliminate this delay at the expense of increased
CPU utilization.
X
The VMS version causes DCL to generate a random off the wall
error message under some error conditions; this is a result of
the incompatibility of the VMS "exit" function with the
Unix/MSDOS standard.
X.SH "ZMODEM CAPABILITIES"
X.I Rz
supports incoming ZMODEM binary (-b), ASCII (-a),
protect (-p),
clobber (-y),
and append (-+)
requests.
The default is protect (-p) and binary (-b).
X
The Unix versions support ZMODEM command execution.
X.SH FILES
rz.c, crctab.c, rbsb.c, zm.c, zmodem.h Unix source files.
X
rz.c, crctab.c, vrzsz.c, zm.c, zmodem.h, vmodem.h, vvmodem.c,
VMS source files.
X
X/tmp/rzlog stores debugging output generated with -vv option
X(rzlog on VMS).
END_OF_FILE
if test 8454 -ne `wc -c <'rz.1'`; then
    echo shar: \"'rz.1'\" unpacked with wrong size!
fi
# end of 'rz.1'
fi
if test -f 'stdio.h.cdiff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stdio.h.cdiff'\"
else
echo shar: Extracting \"'stdio.h.cdiff'\" \(415 characters\)
sed "s/^X//" >'stdio.h.cdiff' <<'END_OF_FILE'
X*** ostdio.h	Thu Mar 24 14:45:56 1989
X--- stdio.h	Thu Mar 24 14:41:29 1989
X***************
X*** 39,44 ****
X--- 39,45 ----
X  #define putc(c,f)		fputc(c,f)
X  #define feof(p) 		(((p)->_flags & _EOF) != 0)
X  #define ferror(p) 		(((p)->_flags & _ERR) != 0)
X+ #define clearerr(p) 		((p)->_flags &= ~(_ERR))
X  #define fileno(p) 		((p)->_fd)
X  #define rewind(f)		fseek(f, 0L, 0)
X  #define testflag(p,x)		((p)->_flags & (x))
END_OF_FILE
if test 415 -ne `wc -c <'stdio.h.cdiff'`; then
    echo shar: \"'stdio.h.cdiff'\" unpacked with wrong size!
fi
# end of 'stdio.h.cdiff'
fi
if test -f 'sz.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sz.1'\"
else
echo shar: Extracting \"'sz.1'\" \(12531 characters\)
sed "s/^X//" >'sz.1' <<'END_OF_FILE'
X'\" Revision Level 
X'\" Last Delta     04-21-88
X.TH SZ 1 OMEN
X.SH NAME
sx, sb, sz \- XMODEM, YMODEM, ZMODEM file send
X.SH SYNOPSIS
sz
X.RB [\- +abdefkLlNnopqTtuvyY ]
X.I file ...
X.br
sb
X.RB [\- adfkqtuv ]
X.I file ...
X.br
sx
X.RB [\- akqtuv ]
X.I file
X.br
sz
X.RB [\- oqtv ]
X.B "-c COMMAND"
X.br
sz
X.RB [\- oqtv ]
X.B "-i COMMAND"
X.br
sz -TT
X.SH DESCRIPTION
X.B Sz
uses the ZMODEM, YMODEM or XMODEM error correcting protocol to send
one or more files over a dial-in serial port to a variety of programs running under
PC-DOS, CP/M, Unix, VMS, and other operating systems.
X
While
X.I rz
is smart enough to be called from
X.I cu(1),
very few versions of
X.I cu(1)
are smart enough to allow
X.I sz
to work properly.
Unix flavors of Professional-YAM are available for such dial-out application.
X
X
X.B Sz
sends one or more files with ZMODEM protocol.
X
ZMODEM
greatly simplifies file transfers compared to XMODEM.
In addition to a friendly user interface, ZMODEM
provides Personal Computer and other users
an efficient, accurate, and robust file transfer method.
X
ZMODEM provides complete
X.B "END-TO-END"
data integrity between application programs.
ZMODEM's 32 bit CRC catches errors
that sneak into even the most advanced networks.
X
Advanced file management features include
AutoDownload (Automatic file Download initiated without user intervention),
Display of individual and total file lengths and transmission time estimates,
Crash Recovery,
selective file transfers,
and preservation of
exact file date and length.
X
Output from another program may be piped to
X.B sz
for transmission by denoting standard input with "-":
X.ce
ls -l | sz -
The program output is transmitted with the filename sPID.sz
where PID is the process ID of the
X.B sz
program.
If the environment variable
X.B ONAME
is set, that is used instead.
In this case, the Unix command:
X.ce
ls -l | ONAME=con sz -ay -
will send a "file" to the PC-DOS console display.
The
X.B -y
option instructs the receiver to open the file for writing unconditionally.
The
X.B -a
option
causes the receiver to convert Unix newlines to PC-DOS carriage returns
and linefeeds.
X
X
X.B Sb
batch sends one or more files with YMODEM or ZMODEM protocol.
The initial ZMODEM initialization is not sent.
When requested by the receiver,
X.B sb
supports
X.B YMODEM-g
with "cbreak" tty mode, XON/XOFF flow control,
and interrupt character set to CAN (^X).
X.B YMODEM-g
X(Professional-YAM
X.B g
option)
increases throughput over error free channels
X(direct connection, X.PC, etc.)
by not acknowledging each transmitted sector.
X
On
X.SM Unix
systems, additional information about the file is transmitted.
If the receiving program uses this information,
the transmitted file length controls the exact number of bytes written to
the output dataset,
and the modify time and file mode
are set accordingly.
X
X
X.B Sx
sends a single
X.I file
with
X.B XMODEM
or
X.B XMODEM-1k
protocol
X(sometimes incorrectly called "ymodem").
The user must supply the file name to both sending and receiving programs.
X
Iff
X.B sz
is invoked with $SHELL set and iff that variable contains the
string
X.I "rsh"
or
X.I "rksh"
X(restricted shell),
X.B sz
operates in restricted mode.
Restricted mode restricts pathnames to the current directory and
PUBDIR (usually /usr/spool/uucppublic) and/or subdirectories
thereof.
X
X
The fourth form sends a single COMMAND to a ZMODEM receiver for execution.
X.B Sz
exits with the COMMAND return value.
If COMMAND includes spaces or characters special to the shell,
it must be quoted.
X
X
The fifth form sends a single COMMAND to a ZMODEM receiver for execution.
X.B Sz
exits as soon as the receiver has correctly received the command,
before it is executed.
X
X
The sixth form (sz -TT)
attempts to output all 256 code combinations to the terminal.
In you are having difficulty sending files,
this command lets you see which character codes are being
eaten by the operating system.
X
X
If
X.B sz
is invoked with stdout and stderr to different datasets,
Verbose is set to 2, causing frame by frame progress reports
to stderr.
This may be disabled with the
X.B q
option.
X.PP
The meanings of the available options are:
X.PP
X.PD 0
X.TP
X\\
X(backslash) (VMS) Force the next option letter to upper case.
X.TP
X.B +
Instruct the receiver to append transmitted data to an existing file
X(ZMODEM only).
X.TP
X.B a
Convert NL characters in the transmitted file to CR/LF.
This is done by the sender for XMODEM and YMODEM, by the receiver
for ZMODEM.
X.TP
X.B b
X(ZMODEM) Binary override: transfer file without any translation.
X.TP
X.B "c COMMAND"
Send COMMAND to the receiver for execution, return with COMMAND\'s exit status.
X.TP
X.B d
Change all instances of "." to "/" in the transmitted pathname.
Thus, C.omenB0000 (which is unacceptable to MSDOS or CP/M)
is transmitted as C/omenB0000.
If the resultant filename has more than 8 characters in the stem,
a "." is inserted to allow a total of eleven.
X.TP
X.B e
XEscape all control characters;
normally XON, XOFF, DLE, CR-@-CR, and Ctrl-X are escaped.
X.TP
X.B f
Send Full pathname.
Normally directory prefixes are stripped from the transmitted
filename.
X.TP
X.B "i COMMAND"
Send COMMAND to the receiver for execution, return Immediately
upon the receiving program's successful recption of the command.
X.TP
X.B k
X(XMODEM/YMODEM) Send files using 1024 byte blocks
rather than the default 128 byte blocks.
X1024 byte packets speed file transfers at high bit rates.
X(ZMODEM streams the data for the best possible throughput.)
X.TP
X.B "L N"
Use ZMODEM sub-packets of length N.
A larger N (32 <= N <= 1024) gives slightly higher throughput,
a smaller N speeds error recovery.
The default is 128 below 300 baud, 256 above 300 baud, or 1024 above 2400 baud.
X.TP
X.B "l N"
Wait for the receiver to acknowledge correct data every
X.B N
X(32 <= N <= 1024)
characters.
This may be used to avoid network overrun when XOFF flow control is lacking.
X.TP
X.B n
X(ZMODEM) Send each file if
destination file does not exist.
Overwrite destination file if
source file is newer than the destination file.
X.TP
X.B N
X(ZMODEM) Send each file if
destination file does not exist.
Overwrite destination file if
source file is newer or longer than the destination file.
X.TP
X.B o
X(ZMODEM) Disable automatic selection of 32 bit CRC.
X.TP
X.B p
X(ZMODEM) Protect existing destination files by skipping transfer if the
destination file exists.
X.TP
X.B q
Quiet suppresses verbosity.
X.TP
X.B r
X(ZMODEM) Resume interrupted file transfer.
If the source file is longer than the destination file,
the transfer commences at the offset in the source file that equals
the length of the destination file.
X.TP
X.B "t tim"
Change timeout to
X.I tim
tenths of seconds.
X.TP
X.B u
Unlink the file after successful transmission.
X.TP
X.B "w N"
Limit the transmit window size to N bytes (ZMODEM).
X.TP
X.B v
Verbose
causes a list of file
names to be appended to
X/tmp/szlog .
More v's generate more output.
X.TP
X.B y
Instruct a ZMODEM receiving program to overwrite any existing file
with the same name.
X.TP
X.B Y
Instruct a ZMODEM receiving program to overwrite any existing file
with the same name,
and to skip any source files that do have a file with the same
pathname on the destination system.
X.PD
X.SH EXAMPLES
X.ne 7
X.B "ZMODEM File Transfer"
X(Unix to DSZ/ZCOMM/Professional-YAM)
X.br
X.B "% sz \-a *.c"
X.br
This single command transfers all .c files in the current Unix directory
with conversion
X.RB ( \-a )
to end of line conventions appropriate to the receiving environment.
With ZMODEM AutoDownload enabled, Professional-YAM  and ZCOMM
will automatically recieve
the files after performing a security check.
X
X.br
X.B "% sz \-Yan *.c *.h"
X.br
Send only the .c and .h files that exist on both systems,
and are newer on the sending system than the
corresponding version on the receiving system, converting Unix to
DOS text format.
X.br
X.B
X$ sz -\\Yan file1.c file2.c file3.c foo.h baz.h
X.R
X(for VMS)
X.br
X
X.B "ZMODEM Command Download"
X(Unix to Professional-YAM)
X.br
X cpszall:all
X    sz \-c "c:;cd /yam/dist"
X    sz \-ya $(YD)/*.me
X    sz \-yqb y*.exe
X    sz \-c "cd /yam"
X    sz \-i "!insms"
X.br
This Makefile fragment uses
X.B sz
to issue commands to Professional-YAM to change current disk and directory.
Next,
X.B sz
transfers the
X.I .me
files from the $YD directory, commanding the receiver to overwrite the old files
and to convert from Unix end of line conventions to PC-DOS conventions.
The third line transfers some
X.I .exe
files.
The fourth and fifth lines command Pro-YAM to
change directory and execute a PC-DOS batch file
X.I insms .
Since the batch file takes considerable time, the
X.B "\-i"
form is used to allow
X.B sz
to exit immediately.
X
X.B "XMODEM File Transfer"
X(Unix to Crosstalk)
X.br
X%
X.B "sx \-a foo.c"
X.br
X.B "ESC"
X.br
X.B "rx foo.c"
X.br
The above three commands transfer a single file
from Unix to a PC and Crosstalk with
X.I sz
translating Unix newlines to DOS CR/LF.
This combination is much slower and far less reliable than ZMODEM.
X.SH ERROR MESSAGES
X"Caught signal 99"
indicates the program was not properly compiled,
refer to "bibi(99)" in rbsb.c for details.
X.SH SEE ALSO
rz(omen),
ZMODEM.DOC,
YMODEM.DOC,
Professional-YAM,
crc(omen),
sq(omen),
todos(omen),
tocpm(omen),
tomac(omen),
yam(omen)
X
Compile time options required for various operating systems are described in
the source file.
X.SH "VMS VERSION"
The VMS version does not support wild cards.
Because of VMS DCL, upper case option letters muse be represented
by \\ proceding the letter.
X
The current VMS version does not support XMODEM, XMODEM-1k, or YMODEM.
X
VMS C Standard I/O and RMS may interact to modify the file contents.
X.SH FILES
X32 bit CRC code courtesy Gary S. Brown.
X
sz.c, crctab.c, rbsb.c, zm.c, zmodem.h Unix source files
X
sz.c, crctab.c, vrzsz.c, zm.c, zmodem.h, vmodem.h, vvmodem.c,
VMS source files.
X
X/tmp/szlog stores debugging output (sz -vv)
X(szlog on VMS).
X.SH "TESTING FEATURE"
The command "sz -T file"
exercises the
X.B Attn
sequence error recovery by commanding
errors with unterminated packets.
The receiving program should complain five times about
binary data packets being too long.
XEach time
X.B sz
is interrupted,
it should send a ZDATA header followed by another defective packet.
If the receiver does not detect five long data packets,
the
X.B Attn
sequence is not interrupting the sender, and the
X.B Myattn
string in
X.B sz.c
must be modified.
X
After 5 packets,
X.B sz
stops the "transfer" and
prints the total number of characters "sent" (Tcount).
The difference between Tcount and 5120 represents the number of characters
stored in various buffers when the Attn sequence is generated.
X.SH BUGS
Calling
X.I sz
from most versions of cu(1) doesn't work because cu's receive process
fights
X.I sz
for characters from the modem.
X
On at least one BSD system, sz would hang or exit when it got within
a few kilobytes of the end of file.
Using the "-w 8192" flag fixed the problem.
The real cause is unknown, perhaps a bug in the kernel TTY output routines.
X
Programs that do not properly implement the specified file transfer protocol
may cause
X.I sz
to "hang" the port for a minute or two.
This problem is corrected by using
ZCOMM, Pro-YAM, or other program with a correct implementation
of the specified protocol.
X
Many programs claiming to support YMODEM only support XMODEM with 1k blocks,
and they often don't get that quite right.
X
XXMODEM transfers add up to 127 garbage bytes per file.
XXMODEM-1k and YMODEM-1k transfers use 128 byte blocks
to avoid extra padding.
X
YMODEM programs use the file length transmitted at the beginning of the
transfer to prune the file to the correct length; this may cause problems with
source files that grow during the course of the transfer.
This problem does not pertain to ZMODEM transfers, which preserve the exact
file length unconditionally.
X
Most ZMODEM options are merely passed to the receiving program;
some do not implement all these options.
X
Circular buffering and a ZMODEM sliding window should be used
when input is from pipes instead of acknowledging frames each 1024 bytes.
If no files can be opened,
X.B sz
sends a ZMODEM command to echo a suitable complaint;
perhaps it should check for the presence of at least one accessible file before
getting hot and bothered.
The test mode leaves a zero length file on the receiving system.
X
A few high speed modems have a firmware bug that drops characters when the
direction of high speed transmissson is reversed.
The environment variable ZNULLS may be used to specify the number of nulls to
send before a ZDATA frame.
Values of 101 for a 4.77 mHz PC and 124 for an AT are typical.
END_OF_FILE
if test 12531 -ne `wc -c <'sz.1'`; then
    echo shar: \"'sz.1'\" unpacked with wrong size!
fi
# end of 'sz.1'
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'\" \(5487 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 *    05-23-87  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 */
X#define ZHEX 'B'	/* HEX frame indicator */
X#define ZBIN32 'C'	/* Binary frame with 32 bit FCS */
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 CANCRY	010	/* Receiver can decrypt */
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/* Parameters for ZSINIT frame */
X#define ZATTNLEN 32	/* Max length of attention string */
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 ZTCRYPT	2	/* Encryption */
X#define ZTRLE	3	/* Run Length encoding */
X/* Extended options for ZF3, bit encoded */
X#define ZXSPARS	64	/* Encoding for sparse file operations */
X
X/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
X#define ZCACK1	1	/* Acknowledge, then do command */
X
long rclhdr();
X
X/* Globals used by ZMODEM functions */
extern Rxframeind;	/* ZBIN ZBIN32, or ZHEX type of frame received */
extern Rxtype;		/* Type of header received */
extern Rxcount;		/* Count of data bytes received */
extern Zrwindow;	/* RX window size (controls garbage count) */
extern Rxtimeout;	/* Tenths of seconds to wait for something */
extern char Rxhdr[4];	/* Received header */
extern char Txhdr[4];	/* Transmitted header */
extern long Rxpos;	/* Received file position */
extern long Txpos;	/* Transmitted file position */
extern Txfcs32;		/* TURE means send binary frames with 32 bit FCS */
extern Crc32t;		/* Display flag indicating 32 bit CRC being sent */
extern Crc32;		/* Display flag indicating 32 bit CRC being received */
extern Znulls;		/* Number of nulls to send at beginning of ZDATA hdr */
extern char Attn[ZATTNLEN+1];	/* Attention string rx sends to tx on err */
X
X/* End of ZMODEM.H */
END_OF_FILE
if test 5487 -ne `wc -c <'zmodem.h'`; then
    echo shar: \"'zmodem.h'\" unpacked with wrong size!
fi
# end of 'zmodem.h'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 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