rsalz@bbn.com (Rich Salz) (03/04/88)
Submitted-by: Steve Grandi <grandi@noao.arizona.edu> Posting-number: Volume 13, Issue 93 Archive-name: xmodem3.4/part01 This is version 3.4 (finished 10/87) of the xmodem program, a full-featured XMODEM implementation for 4.2/4/3BSD. Since the previous release (version 3.2, see volume 7 of the archives), substantial improvements have been made. See the file update.doc for details. Also, some attempt has been made to support SysV Unix systems; see below. As far as I am concerned, this program has reached the end of its evolution. Newer protocols (such as ZMODEM) will not be incorporated into xmodem. Check out Chuck Forsberg's rz/sz programs if you are interested in ZMODEM. : This is a shar archive. Extract with sh, not csh. echo x - README sed -e 's/^X//' > README << '!Funky!Stuff!' XThis is version 3.4 (finished 10/87) of the xmodem program, a full-featured XXMODEM implementation for 4.2/4/3BSD. Since the previous release (version X3.2, see volume 7 of the archives), substantial improvements have been Xmade. See the file update.doc for details. Also, some attempt has been Xmade to support SysV Unix systems; see below. X XAs far as I am concerned, this program has reached the end of its evolution. XNewer protocols (such as ZMODEM) will not be incorporated into xmodem. Check Xout Chuck Forsberg's rz/sz programs if you are interested in ZMODEM. X XTo answer one oft-asked question: No, I don't know how to tie the Xfull-featured xmodem program into tip or cu for file transfers when calling Xout from a 4.2/4.3BSD system. 4.3BSD tip does have some undocumented hooks Xfor tying into other programs through redirecting file descriptors, but my Xminimal attempts to utilize these hooks have failed. However, several Xyears back, I built a VERY early version of xmodem (lacking XMODEM/CRC, XXMODEM-1K, MODEM7 batch or YMODEM) directly into 4.2BSD tip. The changes Xworked unmodified in 4.3BSD; the diff files are contained in the file Xtip.diffs. X X-------------------------------------------------------------------------------- X XThe xmodem program implements the Christensen (XMODEM) file transfer Xprotocol for moving files between 4.2/4.3BSD Unix systems and microcomputers. XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K Xblock protocol and the YMODEM batch protocol are all supported by xmodem. XFor details of the protocols, see the document edited by Chuck Forsberg titled XXMODEM/YMODEM Protocol Reference (the latest version is dated 8-4-87). X XThis program runs on 4.2/4.3BSD systems ONLY. It has been tested on VAXes Xand Suns against the MEX-PC program from Niteowl Software and the ZCOMM and XDSZ programs from Omen Technology. X XI have tried to keep the 4.2isms (select system call, 4.2BSD/v7 tty structures, Xgettimeofday system call, etc.) confined to the source file getput.c; but I Xmake no guarantees. Also, I have made no attempt to keep variable names Xunder 7 characters. A version of getput.c that MAY work on Sys V Unix Xsystems is included. X X-------------------------------------------------------------------------------- X XThanks to Emmet Gray (ihnp4!uiucuxc!fthood!egray) and John Rupley X(arizona!rupley!root) for the following notes about converting xmodem to Sys V. XSince I don't have a Sys V system to test a Sys V version, I won't even try. X X1) Change the includes in xmodem.h from <sys/time.h> to <time.h> X and from <sgtty.h> to <termio.h> X X2) Convert the occurrences of rindex to strrchr in batch.c X X3) Substitute getput.sysv.c for getput.c X X-------------------------------------------------------------------------------- X XProgram history: X XDescended from UMODEM 3.5 by Lauren Weinstein, Richard Conn, and others. X XBased on XMODEM Version 1.0 by Brian Kantor, UCSD (3/84) (Don't blame him Xfor what follows....) X XVersion 2.0 (CRC-16 and Modem7 batch file transfer) (5/85) X XVersion 2.1 (1K packets) (7/85) X XVersion 2.2 (general clean-ups and multi-character read speed-ups) (9/85) X XVersion 2.3 (nap while reading packets; split into several source files) (1/86) X XVersion 3.0 (Ymodem batch receive; associated changes) (2/86) X XVersion 3.1 (Ymodem batch send; associated changes) (8/86) X XVersion 3.2 (general cleanups) (9/86) (Released to the world 1/87) X XVersion 3.3 (see update.doc) (5/87) X XVersion 3.4 (see update.doc) (10/87) X X-------------------------------------------------------------------------------- X XPlease send bug fixes, additions and comments to: XSteve Grandi, National Optical Astronomy Observatories (Tucson, Arizona) X {ihnp4,hao,arizona,...}!noao!grandi grandi@noao.arizona.edu !Funky!Stuff! echo x - update.doc sed -e 's/^X//' > update.doc << '!Funky!Stuff!' XChanges leading to version 3.3 X X1) "Better" handshaking for MODEM7 batch transfers (5/19/87). X X2) If reception of a file is aborted due to errors, delete incomplete file X(5/19/87). X X3) If an "impossible" tty speed is detected, assume 1200 bps (5/19/87). X X4) Disallow CAN-CAN abort during file send or receive except at beginning of Xfile transfer (during batch transfers, CAN-CAN abort is allowed at beginning Xof each file transfer) (5/19/87). X X5) Uncouple total allowed errors during the reception of a single packet X(ERRORMAX, now made 10) and errors allowed when starting transfer (STERRORMAX, Xset to 10) (5/19/87). X X6) Fix some bugs when receiving an empty file and when a phase error occurs Xduring a file reception (5/19/87). X X7) Portability fix in prtime and projtime; they also handle pathological Xcases better (5/19/87). X X8) During file reception an EOT is not believed unless it is sent again in Xresponse to a NAK (5/25/87). X X9) Modified cpm_unix and unixify so a filename without an extension will not Xhave a trailing dot in its filename after being received in a MODEM7 or XYMODEM batch transfer (5/25/87). X X10) Allowable errors during transmission of a single packet now set to XERRORMAX (5/27/87). X X11) When transferring a binary file, the YMODEM file length field is filled Xin on transmit and (if present) used to truncate the file on reception. XA new truncate function (truncfile) added to getput.c to do the deed (5/28/87). XThe file mode field is also set but is ignored on file reception. X X12) In a batch receive (xmodem -rt), program can be forced into checksum mode Xby specifying the "M" flag indicating a MODEM7 transfer (5/30/87). X X13) Changed the "B" option to "M" to indicate MODEM7 batch. Made all option Xflags case insensitive. Command line is now recorded in the log file X(5/30/87). X X14) The "KND/IMP" convention of using "CK" to invoke 1K packets during YMODEM Xbatch transfers was installed. This code will be sent during a batch recieve Xif "K" is included on the command line unless "M" is also present. This code Xwill be recognized when sending under all circumstances (5/30/87). X X------------------------------------------------------------------------------ X XChanges leading to version 3.4 X X1) Fix usage message (10/2/87). X X2) Sender will now try up to 10 times (EOTMAX) to send an EOT to terminate a Xtransmission. Used to be 5 times, but Chuck Forsberg's "official" minimum Xrequirements for YMODEM mandate 10 (10/2/87). X X3) Handle YMODEM file modification times if present in header on reception of Xboth binary and text files (10/2/87). Retracted when can't seem to get Xproper times whn playing with dsz (10/3/87). Found bug and reinstalled Xfeature (10/16/87). Found REAL bug (10/21/87). X X4) Null bytes are now stripped out of files when received as text files (MEX Xdoesn't seem to want to put in the terminating control-Z) (10/3/87). X X5) Slightly modified terminal parameter setting to explicitly turn of CRMOD Xand to flush read queue; ideas stolen from Kermit. Will it fly on Pyramid? X(10/3/87). X X6) Decreased time between "startup" characters sent when starting a file Xreceive operation. This should increase perceived response. Now waits XWAITFIRST seconds (set to 1) instead of 6 (waits for 5 seconds for Xsubsequent packets. STERRORMAX now 60, CRCSWMAX now 30. XTimeouts on 1st sector no longer reported in log (10/5/87). X X7) Once again played with kernel sleeps in readbuf() (packet reading Xroutine). On busy system could cause real problems. Now supply flag (t) to Xsuppress sleeping on Too Busy systems. No longer suppress sleep when speeds are Xover 4800 bps. Sleep kludge DOES help: on an empty 750 running 4.3BSD, a Xfile reception at 2400 bps used 6% of the CPU with the sleep kludge and 24% Xwithout it (data transfer rates were the the same) (10/5/87). X X8) Actually count characters as they are being read for a file reception. XWhen YMODEM file length is set, stop writing characters when reach length. XThis will allow YMODEM file lengths to work for text files and the Xelimination of truncfile() in getput.c (which was impossible for SYS V) X(10/5/87). X X9) Another attempt at tty modes. Now do nothing but set speeds, set mode to Xraw, and turn off echoing and tandem (10/6/87). X X------------------------------------------------------------------------------ X XThanks to Keith Peterson (w8sdz@simtel20.arpa), John Rupley X(arizona!rupley!root), Emmet Gray (ihnp4!uiucuxc!fthood!egray), Bob Bickford X(lll-crg!well!rab), Doug Moore (moore@svax.cs.cornell.edu), David Brown X(jdb@ncsc.arpa) and Chuck Forsberg's documents and his ZCOMM/DSZ programs Xfor ideas, suggestions and comments. !Funky!Stuff! echo x - Makefile sed -e 's/^X//' > Makefile << '!Funky!Stuff!' XOBJECTS = xmodem.o getput.o misc.o send.o receive.o batch.o XCFLAGS = -O X Xxmodem: $(OBJECTS) X cc $(CFLAGS) $(OBJECTS) -o xmodem X X$(OBJECTS): xmodem.h X Xprint: X lpr -p -Pvmslp xmodem.h xmodem.c getput.c receive.c send.c batch.c \ X misc.c Makefile update.doc README xmodem.1 getput.sysv.c X Xshar: X shar README update.doc Makefile xmodem.1 xmodem.h xmodem.c batch.c > xmodem.shar.1 X shar getput.c getput.sysv.c send.c > xmodem.shar.2 X shar receive.c misc.c tip.diffs > xmodem.shar.3 !Funky!Stuff! echo x - xmodem.1 sed -e 's/^X//' > xmodem.1 << '!Funky!Stuff!' X.TH XMODEM LOCAL "October 4, 1987" X.UC 4.2 X.SH NAME Xxmodem \- Christensen protocol file transfer utility X.SH SYNOPSIS X.B xmodem X[\fBst|sb|rt|rb\fR][\fBymkcdlx\fR] X[file...] X.br X.SH DESCRIPTION XThe X.I xmodem Xprogram implements the Christensen (XMODEM) file transfer Xprotocol for moving files between 4.2/4.3BSD Unix systems and microcomputers. XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K Xblock protocol and the YMODEM batch protocol are all supported by X.IR xmodem . XFor details of the protocols, Xsee the document edited by Chuck Forsberg titled X.I XXMODEM/YMODEM Protocol Reference. X.sp XOption Flags are case insensitive and may be preceded by an optional "-" Xcharacter. X.PP X.SH PARAMETERS XExactly one of the following must be selected: X.TP X.B rb XReceive Binary - files are placed on the Unix disk without conversion. X.I Xmodem Xwill silently destroy existing files of the same name. X.TP X.B rt XReceive Text - files are converted from the CP/M and MS-DOS Xformat of CR-LF pairs to the Unix convention of newline Xcharacters only between lines. XNull bytes are ignored and bit 8 of each character is stripped (which makes XWordstar files much more readable). XA CTRL-Z character is deemed to indicate the EOF location in the incoming Xfile. XThe resulting file Xis acceptable to the Unix editors and compilers, and is usually slightly Xsmaller than the original file. X.I Xmodem Xwill silently destroy existing files of the same name. X.TP X.B sb XSend Binary - files are sent without conversion as they exist on the Unix disk. X.TP X.B st XSend Text - newline characters in the file are converted to CR-LF pairs Xin accord with the CP/M and MS-DOS conventions for text files. The file grows Xslightly as this occurs so the estimate of file transmission size and Xtime are always optimistically low. X.PP X.SH OPTIONS X.TP X.B y XSelect the YMODEM batch protocol for sending files; a list of files specified Xon the command line will be sent in sequence. The YMODEM batch protocol is Xused automatically for file reception if the sending program requests it. X.TP X.B m XSelect the MODEM7 batch protocol for sending files; a list of files specified Xon the command line will be sent in sequence. The MODEM7 batch protocol is Xused automatically for file reception if the sending program requests it. XIf this flag is specified for a batch receive, (\fIxmodem rbm\fR, for example), Xthe transfer starts in the checksum rather mode rather than the CRC mode. X.TP X.B k XSelect the XMODEM-1K file transfer mode for sending files. Use of 1K packets on Xlow-error lines increases throughput. XHowever, over direct connections at 9600 bps to a busy host, 1K packets may Xcause data overflows generating excessive retries. X1K packets are automatically Xused for file reception if the sending program requests it. XIf this flag is specified with the YMODEM flag in a batch receive (\fIxmodem XrbYK\fR, for example), the program will attempt to use the "KMD/IMP" convention Xto invoke 1K file transfers. X.TP X.B c XSelect the CRC-16 error-checking protocol on receive. CRC mode is better at catching Xtransmission errors that occur than the alternative checksum protocol. XCRC mode is automatically selected for file Xtransmission if the receiving modem program requests it. X.TP X.B t XIndicates the Unix system is Too Busy and X.I xmodem Xshould fall back to a simpler I/O strategy than normal. X.TP X.B d XDelete the X.I xmodem.log Xfile before file transfer is begun. X.TP X.B l XDo NOT write to the log file. If logging is selected, a file X.I xmodem.log Xwill be created (or appended to), with entries for significant events, errors Xand retries. This can be useful to see why things went wrong Xwhen they do. X.TP X.B x XToggle on debug mode. If debug mode is selected, copious and possibly Xuseful debugging information will be placed in X.IR xmodem.log . X.SH "FILE NAMES" XFiles transmitted using one of the batch modes Xwill be stored on the remote machine under a CP/M-ified name (limited Xto eight characters plus a three character extension; ":" characters will Xbe turned into "/" characters; all characters will be in monocase). XFiles received using one of the batch modes Xwill be stored under their transmitted names (except that any "/" characters Xin the file name will be converted into ":" characters, all upper-case Xcharacters will be translated into lower case and trailing dots will be Xexpunged). X.PP XWhen a batch receive is requested, X.I xmodem Xtakes a wait and see attitude and can adapt to either batch protocol or even Xa classic XMODEM transfer (note that CRC-16 mode is automatically set under Xthese circumstances unless the b flag is specified). XIf a classic, "non-batch" XMODEM file reception takes place, Xthe received file is stored as X.IR xmodem.in . XFile names present on the command line for a batch receive are ignored. X.SH NOTES XWhile waiting for the beginning of a file transfer, X.I xmodem Xtreats two CAN (CTRL-X) characters that are received within 3 seconds Xas a request to abort. CAN characters will not cause an abort if received Xduring a file transfer. X.PP XIf 10 or more errors are detected during the transmission or reception of any Xone packet, the transfer is aborted. X.PP XSqueezed, compressed or ARCed files must be transferred in binary mode, even if they Xcontain text. X.PP XIf you use X.I xmodem Xover a X.I rlogin Xlink, you must use the flag X.IR "rlogin machine -8" . X.PP XIf an unexpected error occurs before a file is completely received, the Xincomplete file is deleted. X.PP XFiles received using both binary and text mode in a YMODEM batch transfer Xwill be truncated Xto the file size specified in the YMODEM header (extra CR characters in the Xincoming file are correctly handled). File sizes are included in Xthe YMODEM header when sending binary files, Xbut are zeroed on transmission of text files (since it would be too slow to Xremove CR characters in advance). XFile modification times are set for received files if present in the YMODEM Xheader; they are included in the headers for transmitted files. X.PP XThe "KMD/IMP" record count field in the YMODEM header is both set and read. X.SH EXAMPLES XTo receive a text file transmitted from a micro (using CRC-16 Xerror-checking) and store it under the Xname X.IR file.name , Xuse the command line X.RS X.B "xmodem rtc file.name" X.RE XNote that if the transmitting program on the micro uses the 1K packet Xprotocol or either batch protocol, X.I xmodem Xdetects this automatically and takes appropriate action. Further Xnote that if one of the batch protocols is used, the received file(s) Xwill be stored under their own names and the name on the command line X(if any) will be ignored. X.PP XTo send a set of text files to a microcomputer using 1K packets and the XYMODEM batch protocol, use the command line X.RS X.B "xmodem styk *.txt" X.RE X.SH FILES Xxmodem.log (if logging is enabled) X.SH BUGS XBatch mode could be smarter about bad file-names in the midst of a Xbatch transmit/receive. X.PP XBatch mode could allow a mixture of binary and text files. X.PP XBare Carriage Return characters (i.e., those not immediately followed by a XLine Feed character) are mishandled in a received file when using text mode. XA file with ``overstruck'' lines will thus come out looking funny. X.PP XYMODEM header packets are only sent as 128 byte packets. Thus VERY long file Xnames will not be handled properly. X.SH SEE ALSO Xkermit(1) X.SH AUTHOR XSteve Grandi, National Optical Astronomy Observatories. Based on X.I xmodem Xby Brian Kantor, University of California at San Diego. XThis, in turn, was based on X.I umodem Xby Lauren Weinstein, Richard Conn and others. !Funky!Stuff! exit -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.