v15i070: Xmodem release 3.6, Part01/05

Rich Salz rsalz at uunet.uu.net
Wed Jun 15 06:21:49 AEST 1988


Submitted-by: Steve Grandi <grandi at noao.arizona.edu>
Posting-number: Volume 15, Issue 70
Archive-name: xmodem3.6/part01


Here is version 3.6 of my Unix "full-featured" xmodem program.  It
incorporates fixes and enhancements from people who used it when it was
last posted in March.  Since that version was posted with missing pieces,
I'm submitting this version rather quickly so the "archives" will have a
complete version.

After unpacking, you should have the following files:

-rw-r--r--  1 grandi        933 Apr 14 15:01 Makefile
-rw-r--r--  1 grandi       4367 Apr 14 07:56 README
-rw-r--r--  1 grandi       4735 Mar 28 15:25 batch.c
-rw-r--r--  1 grandi      12045 Apr 14 06:57 getput.c
-rw-r--r--  1 grandi      10898 Apr 13 10:37 getput.sysv.c
-rw-r--r--  1 grandi       4076 Apr 11 08:59 misc.c
-rw-r--r--  1 grandi      12880 Apr 14 07:15 receive.c
-rw-r--r--  1 grandi       9886 Apr 14 10:07 send.c
-rw-r--r--  1 grandi      14301 Jan  7 14:30 tip.diffs
-rw-r--r--  1 grandi       9209 Apr 14 09:41 update.doc
-rw-r--r--  1 grandi       7948 Apr 14 07:53 xmodem.1
-rw-r--r--  1 grandi       6834 Apr 14 07:19 xmodem.c
-rw-r--r--  1 grandi       3240 Apr 11 07:39 xmodem.h

Steve Grandi, National Optical Astronomy Observatories, Tucson AZ, 602-325-9228
UUCP: {arizona,decvax,ncar,ihnp4}!noao!grandi or uunet!noao.arizona.edu!grandi
Internet: grandi at noao.arizona.edu    SPAN/HEPNET: 5355::GRANDI or NOAO::GRANDI


: This is a shar archive.  Extract with sh, not csh.
echo x - README
sed -e 's/^X//' > README << '!Funky!Stuff!'
XThis is version 3.6 (finished 4/88) of the xmodem program which includes a
Xfew bugfixes and some enhancements (requested by Macintosh users)
Xstimulated by the xmodem release through comp.sources.unix.  See the file
Xupdate.doc for details. 
X
X--------------------------------------------------------------------------------
X
XThis is version 3.4 (finished 10/87) of the xmodem program, a full-featured
XXMODEM implementation for 4.3BSD.  Since the previous release (version
X3.2, see volume 7 of the archives), substantial improvements have been
Xmade. See the file update.doc for details.  Also, some attempt has been
Xmade to support SysV Unix systems; see below.
X
XAs far as I am concerned, this program has reached the end of its evolution.
XNewer protocols (such as ZMODEM) will not be incorporated into xmodem.  Check
Xout Chuck Forsberg's rz/sz programs if you are interested in ZMODEM.
X
XTo answer one oft-asked question: No, I don't know how to tie this
Xfull-featured xmodem program into tip or cu for file transfers when calling
Xout from a 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) 
X    (Released to the world 1/87)
X
XVersion 3.3 (general fixes and cleanups; see update.doc) (5/87)
X
XVersion 3.4 (general fixes and cleanups; see update.doc) (10/87) 
X    (Released to the world 3/88)
X
XVersion 3.5 (general fixes and cleanups; see update.doc) (3/88)
X
XVersion 3.6 (general fixes and cleanups; text file translation for Mac; 
X    see update.doc) (4/88) 
X    (Released to the world 4/88)
X
X--------------------------------------------------------------------------------
X
XPlease send bug fixes, additions and comments to:
XSteve Grandi, National Optical Astronomy Observatories (Tucson, Arizona)
X	{ihnp4,ncar,arizona,...}!noao!grandi  grandi at 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 receive 
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
XChanges leading to version 3.5
X
X1) Following the suggestion of Bill Carpenter (ho5cad!wjc), I changed every
Xprintf("") to fprintf(stderr, "") so one can use xmodem on either end of unix
Xto unix link. (3/24/88).
X
X2) Again, thanks to Bill Carpenter, corrected typo in stamptime() in
Xgetput.sysv.c (3/24/88).
X
X3) Thanks to Steve Lebowitz (prcpto!pdvshl), fixed a && that should have been
Xa & in getput.sysv.c (3/25/88).
X
X4) Thanks to Leo Pilachowski, who managed to fool xmodem by "preplacing" ACKS
Xin the VAX's input queue (improves throughput by 20%, says Leo, but makes
Xerror recovery a tad dicey...!).  Implemented a flushin() function in
Xgetput.c to flush any pending characters.  flushin is called in send.c just
Xafter sending a packet to make sure a proper ACK or NAK is received (I hope 
Xfast machines don't beat me to it and get their ACKS flushed!).  In
Xreceive.c, flushin is called prior to the "startup" characters, prior to
Xsending the packet acknowledgment ACK and prior to the NAK prompting for
Xconfirming EOT.  Now how does one implement flushin() on Sys V? (3/25/88).
X
X5) Fixed pair of bugs in send.c:  YMODEM test enforcing CRC was testing
Xnumber of attempts against STERRORMAX instead of ERRORMAX (also shortened
Xtimeout interval on this read) and a "timeout" during packet send was not
Xnoticed (due to a > instead of a >=) thus program started sending EOTs which
Xfurther delayed abort (3/28/88).
X
X6) Modified send.c and cpmify function in batch.c to strip path names on file
Xnames transmitted as part of YMODEM batch (3/28/88).
X
X7) Hacked receive.c to make end of loop processing clearer and improve
Xgarbage flushing when errors are detected (3/28/88).
X
X8) Pulled out of decision restricting YMODEM batch send to use CRC only.  Will 
Xnow gladly use checksum if told to and will respond to NAK as well as the 
Xproper C when starting up data transfer (3/28/88).  Turns out this patch fixes 
Xproblem with Red Ryder (4/10/88).
X
X9) Tested MODEM7 batch against MEX-PC.  Confirmation of EOT during filename
Xtransmission was not working, so xmodem wasn't shutting down a MODEM7 batch
Xreceive.  Removed code to NAK first EOT and wait for second EOT (3/28/88).
X
X10) Added code to count number of newlines in a text file to get an accurate
Xfile size.  I thought it would take too long; but seems to be quite nimble
X(see countnl in getput.c).  We now transmit YMODEM file length and mode
Xinformation for text as well as binary files (3/29/88).
X
X11) After a YMODEM file name packet was received, forgot to reset "wait" time
Xfor receiving first character of data packet which definitely slowed
Xperceived performance.  (See note 6 for v. 3.4).  Fixed (4/7/88).
X
X------------------------------------------------------------------------------
X
XChanges leading to version 3.6
X
X1) Added two new major commands (sa and ra) to send and receive text files
Xfor Apple Macintoshs which use CR as EOL character instead of the MS/DOS CR
XLF pair.  Thanks to Dave Nowak (djnowak at iseesun.DPL.SCG.HAC.COM) for the
Xinspiration (4/11/88).
X
X2) Experiences with Red Ryder 10.3.  Fixed botch in receive.c that led to an
Xinfinite loop when a checksum failed on YMODEM file name packet.  Now have
Xseperate variables for packet errors and "startup" errors.  Prevent CRC to
Xchecksum switch during receive startup if YMDMBAT flag is true.  This insures
Xthat no such transition will ever take place on second or subsequent file
Xtransfer; can be set on first file by including Y option on command line.  No
Xlonger print "0" expected sectors if both YMODEM file length and KMD file
Xlength are both 0 (4/12/88).
X
X3) Cleaned up ifs in readbuf.  Removed void declaration on flushin (will
Xbreak 4.2BSD compiler?).  Corrected "number of sent sectors" on YMODEM
Xtransfer (was counting filename packet) (4/12/88).
X
X4) More experiences with Red Ryder.  Removed line flush before every CRCCHR
Xor NAK trying to start a receive (RR YMODEM batch send to the VAX now seems
Xto work).  Fixed KMD "1K reception flag" to work properly on a receive. 
XAdded a flushin just before program exits in a futile effort to eliminate
XRR's nasty habit of sending a final EOT down the line.  Reaaranged
Xvariables in send.c so longpackets requested by the KMD flag are not
X"sticky" from file to file in a batch.  RR is a real DOG: ony gets about 133
Xcps when downloading to a Mac over a 9600 bps line! (4/14/88). 
X
X------------------------------------------------------------------------------
X
XThanks to Keith Peterson (w8sdz at simtel20.arpa), John Rupley
X(arizona!rupley!root), Emmet Gray (ihnp4!uiucuxc!fthood!egray), Bob Bickford
X(lll-crg!well!rab), Doug Moore (moore at svax.cs.cornell.edu), David Brown
X(jdb at ncsc.arpa), Bill Carpenter (ho5cad!wjc), Steve Lebowitz (prcpto!pdvshl),
XLeo Pilachowski, Dave Nowak (djnowak at iseesun.DPL.SCG.HAC.COM) and Chuck
XForsberg's documents and his ZCOMM/DSZ/rz/sz programs for ideas, suggestions
Xand 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
Xlint:
X	lint xmodem.c getput.c receive.c send.c batch.c misc.c | imprint
X
Xshar:
X	shar README update.doc Makefile xmodem.1 xmodem.h > xmodem.shar.1
X	shar xmodem.c receive.c misc.c > xmodem.shar.2
X	shar getput.c getput.sysv.c > xmodem.shar.3
X	shar batch.c send.c > xmodem.shar.4
X	shar tip.diffs > xmodem.shar.5
X
Xbigshar: 
X	shar README update.doc Makefile xmodem.1 xmodem.h xmodem.c getput.c \
X	getput.sysv.c receive.c misc.c batch.c send.c tip.diffs > xmodem.shar
X
Xtarz: 
X	tar cvf xmodem.tar README update.doc Makefile xmodem.1 xmodem.h \
X	xmodem.c getput.c getput.sysv.c receive.c misc.c batch.c send.c \
X	tip.diffs ymodem.doc
X	compress xmodem.tar
!Funky!Stuff!
echo x - xmodem.1
sed -e 's/^X//' > xmodem.1 << '!Funky!Stuff!'
X.TH XMODEM LOCAL "April 14, 1988"
X.UC 4.2
X.SH NAME
Xxmodem \- Christensen protocol file transfer utility
X.SH SYNOPSIS
X.B xmodem
X[\fBst|sb|sa|rt|rb|ra\fR][\fBymkctdlx\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; the cluster of flags 
Xmay 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 ra
XReceive Apple - same as rt save CR characters in the incoming file are 
Xtranslated into Unix newline characters.
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
X"grows" in this process.
X.TP
X.B sa  
XSend Apple - same as st save newline characters are converted into CR
Xcharacters in accord with Apple Macintosh conventions for text files.
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.
XIf this flag is specified for a batch receive, (\fIxmodem rty\fR, for example),
Xthe transfer will never attempt to switch from CRC to checksum mode.
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 checksum mode rather than 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 (path names
Xstripped, 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 may have to use the form
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 both binary and text files.  Thus files
Xtransferred via YMODEM should preserve their exact length.
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!
echo x - xmodem.h
sed -e 's/^X//' > xmodem.h << '!Funky!Stuff!'
X#include <ctype.h>
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/time.h>
X#include <sgtty.h>
X#include <signal.h>
X
X/* define macros to print messages in log file */
X#define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
X#define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
X
X#define	     VERSION	36	/* Version Number */
X#define      FALSE      0
X#define      TRUE       1
X
X
X/*  ASCII Constants  */
X#define      SOH  	001 
X#define	     STX	002
X#define	     ETX	003
X#define      EOT	004
X#define	     ENQ	005
X#define      ACK  	006
X#define	     LF		012   /* Unix LF/NL */
X#define	     CR		015  
X#define      NAK  	025
X#define	     SYN	026
X#define	     CAN	030
X#define	     ESC	033
X
X/*  XMODEM Constants  */
X#define      TIMEOUT  	-1
X#define      ERRORMAX  	10    /* maximum errors tolerated while transferring a packet */
X#define      WAITFIRST  1     /* seconds between startup characters in read */
X#define      STERRORMAX	60    /* maximum "errors" tolerated in read startup */
X#define      CRCSWMAX	30    /* maximum time to try CRC mode before switching */
X#define      NAKMAX	120   /* maximum times to wait for initial NAK when sending */
X#define      RETRYMAX  	5     /* maximum retries to be made certain handshaking routines */
X#define      KSWMAX	5     /* maximum errors before switching to 128 byte packets */
X#define      EOTMAX	10    /* maximum times sender will send an EOT to end transfer */
X#define      SLEEPNUM	100   /* target number of characters to collect during sleepy time */
X#define	     BBUFSIZ	1024  /* buffer size */
X#define      NAMSIZ	11    /* length of a CP/M file name string */
X#define	     CTRLZ	032   /* CP/M EOF for text (usually!) */
X#define      CRCCHR	'C'   /* CRC request character */
X#define      KCHR	'K'   /* 1K block request character */
X#define      BAD_NAME	'u'   /* Bad filename indicator */
X
X#define      CREATMODE	0644  /* mode for created files */
X
X/* GLOBAL VARIABLES */
X
Xint ttyspeed;		/* tty speed (bits per second) */
Xunsigned char buff[BBUFSIZ];	/* buffer for data */
Xint nbchr;		/* number of chars read so far for buffered read */
Xlong filelength;	/* length specified in YMODEM header */
Xlong fileread;		/* characters actually read so far in file */
Xchar filename[256];	/* place to construct filenames */
XFILE *LOGFP;		/* descriptor for LOG file */
X
X/* option flags and state variables */
Xchar	XMITTYPE;	/* text or binary? */
Xint	DEBUG;		/* keep debugging info in log? */
Xint	RECVFLAG;	/* receive? */
Xint	SENDFLAG;	/* send? */
Xint	BATCH;		/* batch? (Now used as a state variable) */
Xint	CRCMODE;	/* CRC or checksums? */
Xint	DELFLAG;	/* don't delete old log file? */
Xint	LOGFLAG;	/* keep log? */
Xint	LONGPACK; 	/* do not use long packets on transmit? */
Xint	MDM7BAT;	/* MODEM7 batch protocol */
Xint	YMDMBAT;	/* YMODEM batch protocol */
Xint	TOOBUSY;	/* turn off sleeping in packet read routine */
Xint	CHECKLENGTH;	/* Are we truncating a file to a YMODEM length? */
X
X
X/*   CRC-16 constants.  From Usenet contribution by Mark G. Mendel, 
X     Network Systems Corp.  (ihnp4!umn-cs!hyper!mark)
X*/
X
X    /* the CRC polynomial. */
X#define	P	0x1021
X
X    /* number of bits in CRC */
X#define W	16
X
X    /* the number of bits per char */
X#define B	8
!Funky!Stuff!
exit

-- 
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.



More information about the Comp.sources.unix mailing list