[comp.sources.atari.st] v01i048: zmdm -- terminal program with file transfer part08/08

koreth@ssyx.ucsc.edu (Steven Grimm) (05/30/88)

Submitted-by: bammi@mandrill.ces.cwru.edu (Jwahar R. Bammi)
Posting-number: Volume 1, Issue 48
Archive-name: zmdm/part08

#!/bin/sh
# this is part 8 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ZM.C continued
#
CurArch=8
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file ZM.C"
sed 's/^X//' << 'SHAR_EOF' >> ZM.C
X		return c;
X	if (c == CAN && (c = readline(Rxtimeout)) < 0)
X		return c;
X	if (c == CAN && (c = readline(Rxtimeout)) < 0)
X		return c;
X	switch (c) {
X	case CAN:
X		return GOTCAN;
X	case ZCRCE:
X	case ZCRCG:
X	case ZCRCQ:
X	case ZCRCW:
X		return (c | GOTOR);
X	case ZRUB0:
X		return 0177;
X	case ZRUB1:
X		return 0377;
X	default:
X		if ((c & 0140) ==  0100)
X			return (c ^ 0100);
X		break;
X	}
X	log2("Got bad ZMODEM escape sequence %x", c);
X	return ERROR;
X}
X
X/*
X * Read a character from the modem line with timeout.
X *  Eat parity, XON and XOFF characters.
X */
Xnoxread7()
X{
X	register int c;
X
X	for (;;) {
X		if ((c = readline(Rxtimeout)) < 0)
X			return c;
X		switch (c &= 0177) {
X		case XON:
X		case XOFF:
X			continue;
X		default:
X			return c;
X		}
X	}
X}
X
X/* Store long integer pos in Txhdr */
Xstohdr(pos)
Xregister long pos;
X{
X	Txhdr[ZP0] = pos;
X	Txhdr[ZP1] = pos>>8;
X	Txhdr[ZP2] = pos>>16;
X	Txhdr[ZP3] = pos>>24;
X}
X
X/* Recover a long integer from a header */
Xlong rclhdr(hdr)
Xregister char *hdr;
X{
X	register long l;
X
X	l = (hdr[ZP3] & 0377);
X	l = (l << 8) | (hdr[ZP2] & 0377);
X	l = (l << 8) | (hdr[ZP1] & 0377);
X	l = (l << 8) | (hdr[ZP0] & 0377);
X	return l;
X}
X
X/* -eof- */
SHAR_EOF
echo "File ZM.C is complete"
chmod 0600 ZM.C || echo "restore of ZM.C fails"
echo "x - extracting ZMDM.DOC (Text)"
sed 's/^X//' << 'SHAR_EOF' > ZMDM.DOC &&
X	zmdm.doc, v1.6 ++jrb
X
X			    ACKNOWLEDGEMENTS
X
X	ZMDM was derived from rz/sz for Unix  posted by 
X	Chuck Forsberg (...!tektronix!reed!omen!caf ). We
X	thank him for his excellent code, and for giving
X	us permission to use and distribute his code and
X	documentation.
X
X	The code for detecting baud rate at startup is courtesy
X	of Brian Katzung (katzung@laidbak.UUCP). Thanks very
X	much!
X
X	Andy Nicola did a lot of testing of the new features.
X	Thank You very much!
X
X	Thanks to the many users on the net who wrote in.
X	
X----------------------------------------------------------------------------
X	Enhancements since V1.2: (the last Usenet  release).
X	
X		o Some cleanup, moved common things around.
X		  Some cosmetic additions.
X
X		o MWC 3.0 compatible. The sample MW makefiles
X		  reflect the setup required for MWC  V 3.0.6.
X
X		o Manx Aztec C compatible. Tested with V 3.6a
X		  of the compiler. Produces the smallest code
X		  of all the compilers tested. See config.h,
X		  makefile.man and makefman.sta.
X		  CAUTION: for MegaST and 4Meg ST owners--
X		    The Manx Version will not work correctly
X		  for you due to a bug in the start up file
X		  -- we are still trying to figure out exactly
X		  what the problem is!
X
X		o Auto Baud Rate detection on startup:
X		  Previously ZMDM would set the baud rate
X		  to a compile time configurable rate on
X		  startup (it needed to know the baud rate
X		  to determine its default packet size). Thanks
X		  to code contributed by Brian Katzung, now it
X		  detects the baud rate on startup.
X		  Of course you can set the baud rate
X		  within ZMDM (by hitting '<HELP>'  'b' ).
X
X		o Compile time option to use all available memory
X		  as recv/send buffer. See DYNABUF, LEAVEALONE and
X		  MINACC preprocessor symbols in config.h. If you
X		  prefer to use a fixed size buffer, this is still
X		  possible by not #define'ing DYNABUF and setting
X		  BBUFSIZ. MegaST OK - thanks Andy Nicola.
X
X		o Stand Alone versions of RZ and SZ can be made
X		  by compiling the sources with the preprocessor
X		  symbols 'STANDALONE' #define'ed. See the makefile
X		  'MAKEFILE.STA' for more details.
X		  Stand Alone versions DO NOT do any command line
X		  argument expansions for wild cards or directories
X		  (unlike the integrated ZMDM).
X		  Stand Alone versions tested from within Gulam,
X		  Flash and Intersect. Thanks to Andy Nicola for
X		  testing these features.
X
X		o Remote versions of ZMDM, RZ and SZ can be made by
X		  compiling the sources with the preprocessor symbol
X		  'REMOTE' #define'ed. A remote version listens and
X		  does all its I/O thru the serial port. Of course
X		  it has to be fired up from console. One of our
X		  area BBS's provides this as a D/L option, where
X		  the BBS program execs a remote ZMDM, and one you exit
X		  you return back to the BBS program.
X
X	        o Added -B (note: uppercase B) option to both RZ and SZ.
X		  the -B function is a binary mode override, that disregards
X		  the extension when deciding the transfer mode. This is
X		  useful when say you are backing up your whole disk
X		  to say a Unix host. (backup the exact image of the files),
X		  or doing St-to-St type transfers.
X		
X		o Now compatible with the PD DLIB library. The
X		  pre-processor symbol DLIBS must be defined. Only
X		  tested with the Alcyon version of the library.
X
X		o Added the phone module (a simple dialer with a
X		  telephone numbers directory). This module is
X		  only compiled in if the preprocessor symbol
X		  'PHONES' is #define'ed. For those of you who
X		  are familiar with XMDM, this module was directly
X		  ripped out of there, with a small bug fix that
X		  prevented it from running under TurboSt.ACC.
X
X		o Long packet lengths now allowed at slower baud rates
X		  rather than insisting on using the default as the max
X		  packet length. For instance
X			sz -l 1024 files..
X		  will now send 1024 byte packets at low baud rates (<= 2400).
X		  The corresponding change has been made to the unix
X		  end of the software too.
X
X		o TurboSt.ACC note:
X			The high rez toggle (25/50 lines) on a
X		monochrome monitor will NOT work is TurboSt.ACC is
X		installed. The problem is on the TurboSt.ACC end. Using
X		the high rez toggle does'nt cause any ill-effect, it just
X		does not do anything.
X		  
X	Enhancements since V1.0:
X		o (This enhancement is only present when
X		   you compile with the pre-processor symbol
X		   `RECURSE' defined - see the makefile's)
X		  sz now takes a  directory as an argument.
X		  If the name of a directory is given as an
X		  argument, then the contents of that directory
X		  and all its subdirectories are sent. A new
X		  option to sz is '-P <dir or file>'
X		  (capital 'P' not 'p'), that
X		  'prunes' the expansion of a directory. For
X		  example if you wanted to send all the files
X		  in the 'C' partition of your hard disk, except
X		  the 'tmp', 'usr' and 'foo\bar' subdirectories, you would
X		  issue the following command in the transfer
X		  shell:
X
X		     sz -f -P c:\tmp -P c:\usr -P c:\foo\bar c:\
X
X		  Notice that you may specify multiple -P 'rune
X		  options. The argument to the -P option may also be
X		  the name of a file that you want to prune off.
X		  Also note that to send full path names
X		  to the remote end, the '-f' option is required,
X		  otherwise the remote end will create all the
X		  files in its current working directory. (Also
X		  see CWRU extension to Unix 'rz', where 'rz' when
X		  receiving full path names (ie. when you specify the
X		  '-f' option to sz on the ST end) will create all
X		  subdirectories required to receive the file). The
X		  ST 'rz' always creates all subdirectories required
X		  to receive a path when the other end is sz'ing with
X		  the '-f' option. Also note that in both the rz's
X		  all subdirectories are created relative to the 
X		  current working directory, even though the path may
X		  specify an absolute path.
X
X	        o File name mapping is slightly changed from V1.0.
X		  When receiving a filename that has multiple '.'s
X		  all but the last '.' is replace with an '_'. So
X		  'foo.bar.ext' becomes 'foo_bar.ext'. Similarly
X		  '123.456.789\aaa.bbb.ccc' becomes '123_456.789\aaa_bbb.ccc'.
X		  As in V1.0, the filename and extension (of each
X		  component of a path name) are truncated to 8 and 3
X		  characters respectively. So '123.456789.ext\foobarbaz'
X		  becomes '123_4567.ext\foobarba'. Also note that
X		  while sending, '\'s are sent as '/'s. The ST drive
X		  specifier part of a path name is never sent.
X		  So 'c:\file.ext' is sent as '/file.ext' (remember:
X		  that full pathnames are only sent when the '-f'
X		  option is specified to 'sz').
X
X		o Many bug fixes since V1.0!
X
X----------------------------------------------------------------------------
X
X
X	Zmdm consists of two main components:
X		o The terminal emulator
X		o The transfer shell
X
X	- The terminal emulator emulates a 80*25 terminal
X	(or optionally the 80*50 mode on Mono systems only).
X	It uses the escape codes of the bios built in enhanced
X	vt52 emulator. For UN*X users i have included the
X	termcap entry that we use.
X
X	- The transfer shell lets you send/receive files using
X	Xmodem/Xmodem-CRC/Xmodem-1K/Ymodem or Zmodem protocols.
X        In addition it provides UN*X csh like command for your
X	convenience, and does (TOS style) wild-card handling,
X        and (only single) quoting of arguments. Please note that
X	this is a convenience feature, and in no way does it
X	pretend to be compatible with csh or any other shell.
X	See the accompanying file YMODEM.DOC by Chuck Forsberg,
X	for details of the above transfer protocols.
X
X	This note describes the commands available from the
X	"transfer shell". The transfer shell is the built in command line
X	interface. In case you are wondering why we choose to
X	use a command line interface, the answer is quite simple.
X	The functions available have so many options and combinations
X	thereof, that it would be totally impractical if not impossible
X	to put them in menus/dialogues (each menu will have to be at least
X	3 levels deep). Of course it is much easier to type something
X	like 'sz -l 128 -L 128 *.c' than answering the at least three
X	dialogues required to pick up the same info. You enter the
X	transfer shell from the terminal emulator by hitting <HELP>
X	and choosing 'T' from the main menu. Once you are done using the
X	transfer shell, you simply hit <RETURN> to pop back into the terminal
X	emulator, exactly where you left off.
X
X	This program was written primarily for situations where you
X	are connected to remote hosts either directly or via modems.
X	The timing and error parameters are NOT suitable for hosts
X	such as CompuServe etc, where there may large delays or your
X	phone line is noisy. We distributed a program called XMDM earlier
X	that is very tolerant of delays/noisy lines and has been used
X	very successfully for BBS'ing around the country. XMDM has
X	conveniences such as dialing directories etc for that purpose.
X	If you have a old version of XMDM ( < V1.8) that does not have
X	dialing directories etc, please mail me for a new copy.
X
X	ZMDM has been tested in the following ways:
X	1) Between two ST's running ZMDM. 19200 Baud no problem!
X	2) With unix sz/rz running on a BSD4.3 on Vaxen.
X	3) With unix sz/rz running on Apollo Dn330/Dn300 under Aegis and
X	   Domain IX (over a siologin line).
X	4) With unix sz/rz running on a Sun under SunOS.
X	6) With an Ibm At running Procomm using Ymodem/Xmodem.
X	7) With ForemSt bbs, with the BBS sending in Ymodem batch
X	   mode. (note: ForemSt bbs's do not take batch uploads -
X	   Matt Singer are you listening??)
X
X	8) With a Mac running MicroPhone using Ymodem mode.
X	9) With an Intel 210 box running Xenix (yech!).
X		
X	UNIX users please note:
X		If the load on your system is high, the UNIX tty
X	driver drops characters when receiving at 9600 or higher baud rates.
X	There are two ways around this problem:
X	- use shorter packet and frame lengths using the `-l' and `-L' options
X	of SZ. For examples `sz -l 128 -L 128 files...' work most of
X	the time at 9600/19200 baud without any problem.
X
X	- reduce your baud rate to 4800 baud. Normally the first solution
X	works fine, but if you have an extraordinarily loaded machine
X	(or are running on a brain damaged 750 with DZ11's), then 4800 baud
X	works better.
X	
X	- Those who have 3b2 boat anchors, the tty driver (at least on
X	 the boxes we have) is totally useless over 1200 baud.
X
X	-----
X	
X
XNAME
X     rb, rz - XMODEM, YMODEM, ZMODEM (Batch) file receive
X
XSYNOPSIS
X     rz	[-Bpqtv]
X     rb	[-pqtv]
X     rz	[-cqtv] file
X
X
XDESCRIPTION
X     This program uses error correcting	protocol to receive files
X     over a serial port	from a variety of programs running under
X     TOS, PC-DOS, CP/M, Unix, and other operating systems.
X
X     The first form of rz (Receive ZMODEM) receives files with
X     the ZMODEM	batch protocol.	 If the	sending	program	does not
X     support ZMODEM, rz	steps down to YMODEM protocol after 50
X     seconds.  This delay can be eliminated by calling the pro-
X     gram as rb	.
X
X     When receiving with XMODEM	or YMODEM, Rz accepts either
X     standard 128 byte sectors or 1024 byte sectors (YAM -k
X     option).  The user	should determine when the longer block
X     length actually improves throughput without causing prob-
X     lems.
X
X     If	extended file information (file	length,	etc.) is
X     received, the file	length controls	the number of bytes writ-
X     ten to the	output dataset (YMODEM only), and the modify time
X     and file mode (iff	non zero) are set accordingly. A special feature
X     of the ST implementation is that if the remote end sends
X     full path names (-f option of sz) all required directories
X     will be automatically created on the ST end. The directories
X     will be rooted at the current directory and not at the root level.
X
X     The second	form of	rz receives a single file with XMODEM
X     protocol.	The user must supply the file name to both send-
X     ing and receiving programs.
X
X     When rz is invoked, Verbose is set to 2, causing frame by
X     frame progress reports to stderr.  This may be disabled with
X     the q option.
X
X
X     The meanings of the available options are:
X     
X     B	  (ZMODEM) force all files to be received in binary mode.
X	  Useful for ST-to-ST transfers (for Ascii files where
X	  you don't want LF to CRLF conversion). This is
X	  a local override, specifying `-B' overrides any mode
X	  the sender specifies (it however will still honor any `protect'
X	  or `append' requests from the sender)
X	  (Applicable to ZMODEM transfers only).
X
X     c	  Request 16 bit CRC.  XMODEM file transfers default to	8
X	  bit checksum.	 YMODEM	and ZMODEM normally use	16 bit
X	  CRC.
X
X     p	  (ZMODEM) Protect: skip file if destination file exists.
X
X     q	  Quiet	suppresses verbosity.
X
X     t tim
X	  Change timeout to tim	tenths of seconds.
X
X     v	  Verbose, more v's give more verbose. Info is also
X	  appended to logfile 'rzlog' .	More v's generate more output.
X
XZMODEM CAPABILITIES
X     Rz	supports incoming ZMODEM binary	(-b), ASCII (-a), protect
X     (-p), and append (-+) requests, and ZMODEM	command	execu-
X     tion. The incoming mode may be optionally overriden by specifying
X     the `-B' option to Rz, in which case all files will be received
X     in binary mode regardless of the incoming mode (protect and append will
X     still be obeyed). 
X
X     Rz also supports incoming pathnames, and will recursively
X     create all subdirectories as required. Rz preserve file mod
X     times, and file protection. The translation of Unix protection
X     bits to ST file attributes is based on the Unix owner (07XX)
X     protection bits.  Presently, only read and write bits are considered.
X     All received pathnames are considered to be rooted at the 
X     current working directory. Any leading '/' from unix systems
X     is discarded (ie. all incoming pathnames are considered unrooted,
X     and are locally 'planted' at the current working directory).
X     Ascii/Binary file modes are determined by examining the file
X     extension on the incoming path name. If the extension is one
X     of the following (case independent), then it is assumed to be
X     a binary file, ascii other wise. The ascii translation of 
X     '\n' to '\r\n' is done locally for ZMODEM (only).
X     For X or Y modem the sender determines the file type (see
X     the file 'common.c' for the latest list).
X
X	".PRG", ".TOS", ".TTP", ".ARC", ".ACC", ".IMG", ".RSC", ".O",
X        ".OBJ", ".NEO", ".PIC", ".PI1", ".PI2", ".PI3", ".PQ1", ".PQ2",
X        ".PQ3", ".BRD", ".ANI", ".STW", ".FNT", ".PRT", ".SNG", ".NEC",
X        ".CNF", ".Z"  , ".DFN", ".GEM", ".EZD", ".LNK", ".SYM",
X        ".PIX", ".X32", ".OUT", ".A",   ".CCC", ".CL",  ".CMD", ".COM",
X        ".CRL", ".DAT", ".DIR", ".EXE", ".OVL", ".PAG", ".REL", ".SAV",
X        ".SUB", ".SWP", ".SYS", ".TAR", ".UTL", ".IM",  ".PAK"
X
X
X
XRZ/SZ(1)		      ST Programmer's Manual		    RZ/SZ(1)
X
XNAME
X     sz
X
XSYNOPSIS
X     sz	[-+BdefkLlNnopqtuvy][-P <directory of file>]*  file ...
X     sz	-X [-kqtuv] file
X     sz	[-oqtv] -c COMMAND
X     sz	[-oqtv] -i COMMAND
X
XDESCRIPTION
X     Sz	uses the ZMODEM, YMODEM	or XMODEM error	correcting proto-
X     col to send one or	more files over	a serial port to a
X     variety of	programs running under PC-DOS, CP/M, Unix, VMS, TOS
X     and other operating systems.
X
X
X     The first form of sz sends	one or more files with ZMODEM or
X     YMODEM batch protocol.  Normally, only the	file name part of
X     the pathname is transmitted. Additional
X     information about the file	is transmitted.	 If the	receiving
X     program uses this information, the	transmitted file length
X     controls the exact	number of bytes	written	to the output
X     dataset, and the modify time and file mode	are set	accord-
X     ingly.
X
X     The second	form of	sz uses	the -X flag to send a single file
X     with XMODEM or XMODEM-1k protocol.	 The user must supply the
X     file name to both sending and receiving programs.
X
X
X     The third form sends a single COMMAND to the receiver for
X     execution.	 Sz exits with the COMMAND return value.
X
X
X     The fourth	form sends a single COMMAND to the receiver for
X     execution.	 Sz exits as soon as the receiver has correctly
X     received the command, before it is	executed.
X
X
X     In SZ Verbose is set to 2, causing frame by frame pro-
X     gress reports to stderr.  This may	be disabled with the q
X     option.
X
X     The meanings of the available options are:
X
X     +	  Instruct the receiver	to append transmitted data to an
X	  existing file	(ZMODEM	only).
X
X     B	  (ZMODEM) force all files to be sent in binary mode.
X	  Useful for ST-to-ST transfers (for Ascii files where
X	  you don't want LF to CRLF conversion).
X	  (Applicable to ZMODEM transfers only).
X
X     c COMMAND
X	  Send COMMAND to the receiver for execution, return with
X	  COMMAND's exit status.
X
X     d	  Change all instances of "." to "/" in	the transmitted
X	  pathname.  Thus, C.omenB0000 (which is unacceptable to
X	  MSDOS	or CP/M) is transmitted	as C/omenB0000.	 If the
X	  resultant filename has more than 8 characters	in the
X	  stem,	a "." is inserted to allow a total of eleven.
X
X     E	  Escape only Ctrl-X control characters; normally XON,
X	  XOFF,	CR-@-CR, and Ctrl-X are	escaped.
X
X     e	  Escape all control characters; normally XON, XOFF, CR-
X	  @-CR,	and Ctrl-X are escaped.
X
X     f	  Send Full pathname.  Normally	directory prefixes are
X	  stripped from	the transmitted	filename.
X
X     i COMMAND
X	  Send COMMAND to the receiver for execution, return
X	  Immediately upon the receiving program's successful
X	  reception of the command.
X
X     k	  (XMODEM/YMODEM) Send files using 1024	byte blocks
X	  rather than the default 128 byte blocks.  1024 byte
X	  packets speed	file transfers at high bit rates.  (ZMO-
X	  DEM streams the data for the best possible throughput.)
X
X     L N  Use ZMODEM sub-packets of length N.  A larger	N (32 <=
X	  N <= 1024) gives slightly higher throughput, a smaller
X	  N speeds error recovery.  The	default	is 128 below 300
X	  baud,	256 above 300 baud, or 1024 above 2400 baud.
X
X     l N  Wait for the receiver	to acknowledge correct data every
X	  N (32	<= N <=	1024) characters.  This	may be used to
X	  avoid	network	overrun	when XOFF flow control is lack-
X	  ing.
X
X     n	  (ZMODEM) Send	each file if destination file does not
X	  exist.  Overwrite destination	file if	source file is
X	  newer	or longer than the destination file.
X
X     N	  (ZMODEM) Send	each file if destination file does not
X	  exist.  Overwrite destination	file if	source file has
X	  different length or date.
X
X     o	  (ZMODEM) Disable automatic selection of 32 bit CRC.
X
X     p	  (ZMODEM) Protect existing destination	files by skipping
X	  transfer if the destination file exists.
X
X     q	  Quiet	suppresses verbosity.
X
X     r	  Resume interrupted file transfer.  If	the source file
X	  is longer than the destination file, the transfer com-
X	  mences at the	offset in the source file that equals the
X	  length of the	destination file.
X
X     t tim
X	  Change timeout to tim	tenths of seconds.
X
X     u	  Unlink the file after	successful transmission.
X
X     v	  Verbose causes a list	of file	names to be appended to
X	  szlog .	More v's generate more output.
X
X     X	  Send a single	file with XMODEM or XMODEM-1k protocol.
X
X     y	  Instruct a ZMODEM receiving program to overwrite any
X	  existing file	with the same name.
X
X     P <directory or file>
X	(ZMODEM) Sz may be given the name of
X	a directory, in which case it will send the contents
X	of the directory, and all the subdirectories thereof.
X	The -P 'Prune' option is used to prune out the named directory
X	or file while expanding the directory tree. Multiple
X	-P options may be specified. This option
X	is only present when the source is compiled with the
X	pre-processor symbol `RECURSE' defined.
X
X	SZ guesses the file mode by examining the filename extension as
X	discusses under RZ above. SZ -f send full pathnames with '\'
X	converted to '/'. The ST drive specifier is never sent.
X
XSEE ALSO
X     ZMODEM.DOC, YMODEM.DOC, IMP(CP/M),	cu(1), Professional-YAM
X     manual, sz(omen), usq(omen), undos(omen)
X
X     Compile time options required for various operating systems
X     are described in the source file.
X
XNOTES
X    Depending on your file structure, when using the recursively
X    descend a directory option of Sz, ZMDM can demand a lot of
X    dynamic memory. When the pre-processor symbol `RECURSE' is
X    defined, for Mark Williams C, `_stksize' is set to 16K. If
X    you are using Alcyon C, please use a decent version of
X    GEMSTART.S. We use the version from pratt@atari with
X    memory model (STACK=1), which gives quarter of available
X    memory to stack+heap. Note that all the dynamic memory is
X    taken off the program heap (for Alcyon, and off the Arena
X    above the stack for Mark Wiliams), ie. ZMDM uses `malloc' not
X    `Malloc'.
X
X    It is possible to run out of dynamic memory when descending
X    a file structure with a lot of files and/or deep-hierarchies.
X    The simplest way to work around this problem is to do the
X    sending in parts by using the -P rune option of Sz. For
X    instance if you run out of memory while trying to send your
X    C partition, you may want to prune out some directories and
X    send things in parts. In my case i backup my C partition to
X    our unix host in the following manner:
X
X	sz -f -P c:\bin -P c:\lib c:\  /* send eveything in the C
X				        partition except the 'bin'
X				        and 'lib' subdirectories */
X
X	sz -f c:\bin c:\lib	      /* then send the 'bin' and 'lib'
X				        directories */
X
X    The second solution depends on if you are using Mark Williams
X    or Alcyon C libraries. If you are running out of memory because
X    of deep hierarchies, you need to increase the stack. If you are
X    running out of memory because of a lot of files, then you
X    need to decrease the stack to allow for a larger arena in
X    the case of MWC (and trade-off for depth), or in the case of
X    Alcyon you need to increase stack+heap. On systems with a
X    large Ramdisk or many ACCs make sure you have enough space
X     before doing this.
X
X    The TTY input buffering on	some systems may not allow long
X    blocks or streaming input,	especially at high baud	rates.
X    The Pro-YAM zmodem	l numeric parameter may	be set to a value
X    between 64	and 1024 to limit the burst length.
X
XBUGS
X     THIS SOFTWARE IS STILL UNDER DEVELOPMENT AND ALMOST POSITIVELY
X     CONTAINS BUGS. PLEASE REPORT ALL SUCH CRITTERS TO mandrill!bammi.
X
X     Pathnames are restricted to 127 characters.  In XMODEM sin-
X     gle file mode, the	pathname given on the command line is
X     still processed as	described above.
X
XFILES
X
X     (rz|sz)log	stores debugging output	generated with -vvv[v]*
X	        option.
X
XOTHER COMMANDS
X	The following command are available in the
X	transfer shell:
X
X	<regular-expression> ::= <file name> | <wild card> |
X				 'quoted string'
X	NB: A quoted string cannot contain embedded single quotes. There
X	    is no escape character available in a quoted string.
X
X	rm,   remove files
X		rm [-i] <regular expression>
X		-i ::= interactive mode, you are prompted before
X		       file(s) are removed.
X
X	cp,   copy files
X		cp <many files> directory
X			copy all files into directory
X			cp *.c d:\foo - copy all C files into foo 
X				        directory on drive D:
X		cp <file> <directory>
X			copy file to directory\file.
X
X		cp <file> <file>
X			file to file copy
X			'cp file con:' to get the listing of a file.
X
X	ls,   list directory
X		ls [wild card]
X		ls without an argument will list all files in the
X		current directory. If an argument is given, then
X		only files matching the wild card will be listed.
X			ls *.c - list all C files in current directory
X			ls d:\foo - list all files in foo directory on D:
X			ls d:\foo\*.c - list all C files in foo directory
X
X	cd,   change working directory
X		cd directory
X
X	md,   make a directory
X		md directory
X
X	rd,   remove a directory
X		rd directory
X		Due to a Gemdos bug, you may have to say 'rd directory'
X		twice to get rid of directory. This happens when you
X		try to remove a directory that you have never visited.
X
X	pwd,  print  working directory
X		prints the current working directory
X
X	df,   check free space
X		df [device]
X		df without an argument will show free space on current drive.
X		df with an argument will show free space on specified drive.
X
XTERMCAP
X	Termcap entries that may be used for the terminal emulator.
X
Xst|520st|atariST|520 or 1040, bw, std sys font, 25 lines, 80 col:\
X	:ae=\Eba:al=\EL:am:as=\Ebc:\
X	:bl=^G:bs:\
X	:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:cr=^M:\
X	:dl=99\EM:do=\EB:\
X	:ho=\EH:\
X	:is=\Ev\Ee:\
X	:kd=\274:kh=\216:kl=\275:kr=\276:ku=\273:\
X	:le=^H:li#25:\
X	:nd=\EC:nl=^J:\
X	:pt:\
X	:se=\Eq:so=\Ep:sr=\EI:\
X	:ta=^I:\
X	:up=\EA:
X
X
XST|ST25|atariSTcolor|as above but with color for standout :\
X	:ae=\Eba:al=\EL:am:as=\Ebc:\
X	:bl=^G:bs:\
X	:cm=\EY%+ %+ :co#80:li#25:cr=^M:cd=\EJ:ce=\EK:cl=\EH\EJ:\
X	:dl=99\EM:do=^J:\
X	:ho=\EH:\
X	:is=\Ev\Ee:\
X	:kd=\274:kh=\216:kl=\275:kr=\276:ku=\273:\
X	:le=^H:\
X	:nd=\EC:nl=^J:\
X	:pt:\
X	:so=\Ec2\Eb3:se=\Ec0\Eb3:sr:\EI:\
X	:ta=^I:\
X	:up=\EA:
X
XsT|st50|AtariST emulating vt52, bw, 50 lines, 80 col:\
X	:ae=\Eba:al=\EL:am:as=\Ebc:\
X	:bl=^G:bs:\
X	:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:cr=^M:\
X	:dl=99\EM:do=^J:\
X	:ho=\EH:\
X	:is=\Ev\Ee:\
X	:kd=\274:kh=\216:kl=\275:kr=\276:ku=\273:\
X	:le=^H:li#50:\
X	:nd=\EC:nl=^J:\
X	:pt:\
X	:se=\Eq:so=\Ep:sr=\EI:\
X	:ta=^I:\
X	:up=\EA:
X
XCOMPILING
X
X	The source provided with this distribution will compile
X	with either ALCYON C V4.14 as distributed with the 
X	Atari Development System,  with Mark Williams C Version 2.00
X	or later and with MANX Aztec C (V3.6a tested).
X	(please note that the system will NOT compile with earlier
X	 versions of either compiler.)
X
X	Edit config.h.
X
X	If you are using Alcyon(and ALN for the linker), check paths in LNK
X
X	Define the preprocessor symbol `RECURSE' if you
X	want the sz to accept directory names(and send its
X	contents), and for the -P option.
X
X	To compile with Alcyon see the file `makefile.alc'
X	To compile with Mark Williams C see the file `makefile'
X	To compile with Manx Aztec C see the file `makefile.man'
X
X	Rename ZMDM.PRG to ZMDM.TOS if you so desire.
X
XMORE ALCYON NOTES:
X	-- Some people seem to have a bad version of as68 with Alcyon,
X	 that does'nt handle static variables too well (ie. symbols of the
X	 form "`name" in the assembler). Please make sure yours is not one of
X	 these.
X
X	-- Use a reasonable version of gemstart.s - ie. one which gives you
X	 a decent amount of stack+heap space. One of the nicer versions
X	 floating around is the one written by Alan Pratt @atari, that
X	 gives you the various memory model options, and corrects the
X	 bug with the bdos call as suggested by Robert Royar on this net.
X
X	-- Do NOT use the `fix' distributed on CompuServe developers forum
X	in the file WILDFI.ARC (in Dl7). This fix does'nt fix anything,
X	it breaks everything!
X
XKNOWN BUGS
X	-v's on the ST end don't do a thing!
X
X	If a receive is cancelled/aborted, the receive file
X	buffer is not flushed to the file. Personally, i
X	view this as a feature rather than a bug, so it is
X	unlikely to be `fixed'.
X
XDISCLAIMER
X	This code is in public domain, and you are encouraged
X	to distribute it further. You may however not sell the
X	code, or use it for any commercial gains. The code is
X	provided as is, and we are not responsible for any
X	omissions/errors, bugs, nor do we claim correctness or
X	its fitness for any purpose.
X
X	Please forward your comments and suggestions to
X
X				Jwahar Bammi
X			usenet: mandrill!bammi@{decvax,sun}.UUCP
X			csnet:  bammi@mandrill.ces.CWRU.edu
X			arpa:   bammi@mandrill.ces.CWRU.edu
X			CompuServe: 71515,155
X
X
X/* EOF */
SHAR_EOF
chmod 0600 ZMDM.DOC || echo "restore of ZMDM.DOC fails"
echo "x - extracting ZMDM.H (Text)"
sed 's/^X//' << 'SHAR_EOF' > ZMDM.H &&
X/*
X * 	Common include file
X *
X *		Jwahar Bammi
X *			usenet: mandrill!bammi@{decvax,sun}.UUCP
X *			csnet:  bammi@mandrill.ces.CWRU.edu
X *			arpa:   bammi@mandrill.ces.CWRU.edu
X *			CompuServe: 71515,155
X */
X
X#include <stdio.h>
X#include <ctype.h>
X#include <setjmp.h>
X#include <osbind.h>
X#include "decl.h"
X
X	/* See configurable parameters towards the end of the file */
X	/* Leave the rest alone					  */
X
X
X	
X 	/* Common defines */
X#ifndef FALSE
X#define	FALSE 		0
X#define TRUE 		1
X#endif
X
X
X#define EscSeq(x)	Bconout(2,(int)'\033'); Bconout(2,(int)x) /* Send Esc.
X							Seq. to	 console */
X#define CTRL(X)		(X & 037) /* CTRL-anything */
X
X#define STOS	  "GEMDOS/TOS"
X#define ZMDMVERSION	"1.62 -- 05/19/88"
X
X/* Ward Christensen / CP/M parameters - Don't change these! */
X#define ENQ 005
X#define CAN ('X'&037)
X#define XOFF ('s'&037)
X#define XON ('q'&037)
X#define SOH 1
X#define STX 2
X#define EOT 4
X#define ACK 6
X#define NAK 025
X#define CPMEOF 032
X#define WANTCRC 0103	/* send C not NAK to get crc not checksum */
X#define TIMEOUT (-2)
X#define RCDO (-3)
X#define ERRORMAX 5
X#define RETRYMAX 10	/* for dogs like compuserve */
X#define WCEOT (-10)
X#define SECSIZ 128	/* cp/m's Magic Number record size */
X#define PATHLEN 128	/* ready for 4.2 bsd ? noooooo */
X#define KSIZE 1024	/* record size with k option */
X#define UNIXFILE 0x8000	/* happens to the the S_IFREG file mask bit for stat */
X#define DEFBYTL 2000000000L	/* default rx file size */
X#define WANTG 0107	/* Send G not NAK to get nonstop batch xmsn */
X
X#define PURGELINE	while(Bconstat(1))Bconin(1);Lleft = 0
X
X#define Bauxws(X)	 wr_modem(X)
X
X#define RLOGFILE "rzlog"
X#define zperr vfile
X#define zperr2 vfile2
X
X#define OK 0
X
X#ifdef ERROR
X#undef ERROR
X#endif
X#define ERROR (-1)
X
X#define HOWMANY 133
X/* Parameters for ZSINIT frame */
X#define ZATTNLEN 32	/* Max length of attention string */
X
X 	
X 	/* Types */
X
X#ifdef LONG
X#undef LONG	/* Get rid of stupid portab.h definition */
X#endif
X
X#ifdef WORD
X#undef WORD
X#endif
X
X#ifdef UWORD
X#undef UWORD
X#endif
X
Xstruct	stat
X{
X	char	st_sp1[21];    /* Junk 	   */
X	char	st_mode;       /* File attributes */
X	int	st_time;       /* Mod Time	  */
X	int     st_date;       /* Mod date	  */
X	long	st_size;       /* File size	   */
X	char	st_name[14];   /* File name	   */
X};
X
X/* The structure returned by Iorec(), really ptr to this type */
Xtypedef struct {
X	char *ibuf;
X	int ibufsiz;
X	int ibufhd;
X	int ibuftl;
X	int ibuflow;
X	int ibufhi;
X} IOREC;
X
Xtypedef  struct {
X	char *sbaud;
X	int  ibaud;
X	int  jbaud;
X} BAUDS;
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#ifndef IN_COMMON
Xextern unsigned int crctab[]; /* see definition in common.c */
Xextern unsigned long int crc_32_tab[]; /* see definition in common.c */
X#endif
X
X#define updcrc(cp, crc) \
X( crctab[(((unsigned int)crc >> 8) & 255)] ^ ((unsigned int)crc << 8) ^ (unsigned int)cp)
X
X#define UPDC32(octet, crc) \
X(crc_32_tab[(((unsigned long)crc) ^ ((unsigned long)octet)) & 0xff] ^ (((unsigned long)crc) >> 8))
X
X
X#define BAUD_STRING(s)	((s < 0) ? "**UNKNOWN**" : vbauds[s].sbaud)
X#define BAUD_RATE(s)	((s < 0) ? 9600 : vbauds[s].jbaud)
X
X/* -eof- */
SHAR_EOF
chmod 0600 ZMDM.H || echo "restore of ZMDM.H fails"
echo "x - extracting ZMODEM.H (Text)"
sed 's/^X//' << 'SHAR_EOF' > ZMODEM.H &&
X/*
X *			    ACKNOWLEDGEMENTS
X *
X *	ZMDM was derived from rz/sz for Unix  posted by 
X *	Chuck Forsberg (...!tektronix!reed!omen!caf ). We
X *	thank him for his excellent code, and for giving
X *	us permission to use and distribute his code and
X *	documentation.
X *
X *	Atari St version by:
X *		Jwahar Bammi
X *			usenet: mandrill!bammi@{decvax,sun}.UUCP
X *			csnet:  bammi@mandrill.ces.CWRU.edu
X *			arpa:   bammi@mandrill.ces.CWRU.edu
X *			CompuServe: 71515,155
X */
X
X/*
X *   Z M O D E M . H     Manifest constants for ZMODEM
X *    application to application file transfer protocol
X *    01-15-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
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 options, one of these in ZF1 */
X#define ZMNEW	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 ZMSPARS	5	/* Encoding for sparse file */
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
X/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
X#define ZCACK1	1	/* Acknowledge, then do command */
X
Xextern long rclhdr();
X
X/* -eof- */
SHAR_EOF
chmod 0600 ZMODEM.H || echo "restore of ZMODEM.H fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0