home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume15 / xmodem3.6 / part01 next >
Text File  |  1988-06-13  |  28KB  |  680 lines

  1. Subject:  v15i070:  Xmodem release 3.6, Part01/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Steve Grandi <grandi@noao.arizona.edu>
  7. Posting-number: Volume 15, Issue 70
  8. Archive-name: xmodem3.6/part01
  9.  
  10.  
  11. Here is version 3.6 of my Unix "full-featured" xmodem program.  It
  12. incorporates fixes and enhancements from people who used it when it was
  13. last posted in March.  Since that version was posted with missing pieces,
  14. I'm submitting this version rather quickly so the "archives" will have a
  15. complete version.
  16.  
  17. After unpacking, you should have the following files:
  18.  
  19. -rw-r--r--  1 grandi        933 Apr 14 15:01 Makefile
  20. -rw-r--r--  1 grandi       4367 Apr 14 07:56 README
  21. -rw-r--r--  1 grandi       4735 Mar 28 15:25 batch.c
  22. -rw-r--r--  1 grandi      12045 Apr 14 06:57 getput.c
  23. -rw-r--r--  1 grandi      10898 Apr 13 10:37 getput.sysv.c
  24. -rw-r--r--  1 grandi       4076 Apr 11 08:59 misc.c
  25. -rw-r--r--  1 grandi      12880 Apr 14 07:15 receive.c
  26. -rw-r--r--  1 grandi       9886 Apr 14 10:07 send.c
  27. -rw-r--r--  1 grandi      14301 Jan  7 14:30 tip.diffs
  28. -rw-r--r--  1 grandi       9209 Apr 14 09:41 update.doc
  29. -rw-r--r--  1 grandi       7948 Apr 14 07:53 xmodem.1
  30. -rw-r--r--  1 grandi       6834 Apr 14 07:19 xmodem.c
  31. -rw-r--r--  1 grandi       3240 Apr 11 07:39 xmodem.h
  32.  
  33. Steve Grandi, National Optical Astronomy Observatories, Tucson AZ, 602-325-9228
  34. UUCP: {arizona,decvax,ncar,ihnp4}!noao!grandi or uunet!noao.arizona.edu!grandi
  35. Internet: grandi@noao.arizona.edu    SPAN/HEPNET: 5355::GRANDI or NOAO::GRANDI
  36.  
  37.  
  38. : This is a shar archive.  Extract with sh, not csh.
  39. echo x - README
  40. sed -e 's/^X//' > README << '!Funky!Stuff!'
  41. XThis is version 3.6 (finished 4/88) of the xmodem program which includes a
  42. Xfew bugfixes and some enhancements (requested by Macintosh users)
  43. Xstimulated by the xmodem release through comp.sources.unix.  See the file
  44. Xupdate.doc for details. 
  45. X
  46. X--------------------------------------------------------------------------------
  47. X
  48. XThis is version 3.4 (finished 10/87) of the xmodem program, a full-featured
  49. XXMODEM implementation for 4.3BSD.  Since the previous release (version
  50. X3.2, see volume 7 of the archives), substantial improvements have been
  51. Xmade. See the file update.doc for details.  Also, some attempt has been
  52. Xmade to support SysV Unix systems; see below.
  53. X
  54. XAs far as I am concerned, this program has reached the end of its evolution.
  55. XNewer protocols (such as ZMODEM) will not be incorporated into xmodem.  Check
  56. Xout Chuck Forsberg's rz/sz programs if you are interested in ZMODEM.
  57. X
  58. XTo answer one oft-asked question: No, I don't know how to tie this
  59. Xfull-featured xmodem program into tip or cu for file transfers when calling
  60. Xout from a 4.3BSD system.  4.3BSD tip does have some undocumented hooks
  61. Xfor tying into other programs through redirecting file descriptors, but my
  62. Xminimal attempts to utilize these hooks have failed.  However, several
  63. Xyears back, I built a VERY early version of xmodem (lacking XMODEM/CRC,
  64. XXMODEM-1K, MODEM7 batch or YMODEM) directly into 4.2BSD tip.  The changes
  65. Xworked unmodified in 4.3BSD; the diff files are contained in the file
  66. Xtip.diffs.
  67. X
  68. X--------------------------------------------------------------------------------
  69. X
  70. XThe xmodem program implements the Christensen (XMODEM) file transfer
  71. Xprotocol for moving files between 4.2/4.3BSD Unix systems and microcomputers.
  72. XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K
  73. Xblock protocol and the YMODEM batch protocol are all supported by xmodem.
  74. XFor details of the protocols, see the document edited by Chuck Forsberg titled
  75. XXMODEM/YMODEM Protocol Reference (the latest version is dated 8-4-87).
  76. X
  77. XThis program runs on 4.2/4.3BSD systems ONLY.  It has been tested on VAXes
  78. Xand Suns against the MEX-PC program from Niteowl Software and the ZCOMM and
  79. XDSZ programs from Omen Technology.
  80. X
  81. XI have tried to keep the 4.2isms (select system call, 4.2BSD/v7 tty structures,
  82. Xgettimeofday system call, etc.) confined to the source file getput.c; but I 
  83. Xmake no guarantees.  Also, I have made no attempt to keep variable names 
  84. Xunder 7 characters.  A version of getput.c that MAY work on Sys V Unix
  85. Xsystems is included.
  86. X
  87. X--------------------------------------------------------------------------------
  88. X
  89. XThanks to Emmet Gray (ihnp4!uiucuxc!fthood!egray) and John Rupley 
  90. X(arizona!rupley!root) for the following notes about converting xmodem to Sys V.
  91. XSince I don't have a Sys V system to test a Sys V version, I won't even try.
  92. X
  93. X1) Change the includes in xmodem.h from <sys/time.h> to <time.h>
  94. X   and from <sgtty.h> to <termio.h>
  95. X
  96. X2) Convert the occurrences of rindex to strrchr in batch.c
  97. X
  98. X3) Substitute getput.sysv.c for getput.c
  99. X
  100. X--------------------------------------------------------------------------------
  101. X
  102. XProgram history:
  103. X
  104. XDescended from UMODEM 3.5 by Lauren Weinstein, Richard Conn, and others.
  105. X
  106. XBased on XMODEM Version 1.0 by Brian Kantor, UCSD (3/84)  (Don't blame him 
  107. Xfor what follows....)
  108. X
  109. XVersion 2.0 (CRC-16 and Modem7 batch file transfer) (5/85)
  110. X
  111. XVersion 2.1 (1K packets) (7/85)
  112. X
  113. XVersion 2.2 (general clean-ups and multi-character read speed-ups) (9/85)
  114. X
  115. XVersion 2.3 (nap while reading packets; split into several source files) (1/86)
  116. X
  117. XVersion 3.0 (Ymodem batch receive; associated changes) (2/86)
  118. X
  119. XVersion 3.1 (Ymodem batch send; associated changes) (8/86)
  120. X
  121. XVersion 3.2 (general cleanups) (9/86) 
  122. X    (Released to the world 1/87)
  123. X
  124. XVersion 3.3 (general fixes and cleanups; see update.doc) (5/87)
  125. X
  126. XVersion 3.4 (general fixes and cleanups; see update.doc) (10/87) 
  127. X    (Released to the world 3/88)
  128. X
  129. XVersion 3.5 (general fixes and cleanups; see update.doc) (3/88)
  130. X
  131. XVersion 3.6 (general fixes and cleanups; text file translation for Mac; 
  132. X    see update.doc) (4/88) 
  133. X    (Released to the world 4/88)
  134. X
  135. X--------------------------------------------------------------------------------
  136. X
  137. XPlease send bug fixes, additions and comments to:
  138. XSteve Grandi, National Optical Astronomy Observatories (Tucson, Arizona)
  139. X    {ihnp4,ncar,arizona,...}!noao!grandi  grandi@noao.arizona.edu
  140. !Funky!Stuff!
  141. echo x - update.doc
  142. sed -e 's/^X//' > update.doc << '!Funky!Stuff!'
  143. XChanges leading to version 3.3
  144. X
  145. X1) "Better" handshaking for MODEM7 batch transfers (5/19/87).
  146. X
  147. X2) If reception of a file is aborted due to errors, delete incomplete file
  148. X(5/19/87).
  149. X
  150. X3) If an "impossible" tty speed is detected, assume 1200 bps (5/19/87).
  151. X
  152. X4) Disallow CAN-CAN abort during file send or receive except at beginning of
  153. Xfile transfer (during batch transfers, CAN-CAN abort is allowed at beginning
  154. Xof each file transfer) (5/19/87).
  155. X
  156. X5) Uncouple total allowed errors during the reception of a single packet 
  157. X(ERRORMAX, now made 10) and errors allowed when starting transfer (STERRORMAX, 
  158. Xset to 10) (5/19/87).
  159. X
  160. X6) Fix some bugs when receiving an empty file and when a phase error occurs
  161. Xduring a file reception (5/19/87).
  162. X
  163. X7) Portability fix in prtime and projtime; they also handle pathological
  164. Xcases better (5/19/87).
  165. X
  166. X8) During file reception an EOT is not believed unless it is sent again in
  167. Xresponse to a NAK (5/25/87).
  168. X
  169. X9) Modified cpm_unix and unixify so a filename without an extension will not
  170. Xhave a trailing dot in its filename after being received in a MODEM7 or
  171. XYMODEM batch transfer (5/25/87).
  172. X
  173. X10) Allowable errors during transmission of a single packet now set to
  174. XERRORMAX (5/27/87).
  175. X
  176. X11) When transferring a binary file, the YMODEM file length field is filled
  177. Xin on transmit and (if present) used to truncate the file on reception.
  178. XA new truncate function (truncfile) added to getput.c to do the deed (5/28/87).
  179. XThe file mode field is also set but is ignored on file reception.
  180. X
  181. X12) In a batch receive (xmodem -rt), program can be forced into checksum mode
  182. Xby specifying the "M" flag indicating a MODEM7 transfer (5/30/87).
  183. X
  184. X13) Changed the "B" option to "M" to indicate MODEM7 batch.  Made all option
  185. Xflags case insensitive.  Command line is now recorded in the log file
  186. X(5/30/87).
  187. X
  188. X14) The "KND/IMP" convention of using "CK" to invoke 1K packets during YMODEM
  189. Xbatch transfers was installed.  This code will be sent during a batch receive 
  190. Xif "K" is included on the command line unless "M" is also present.  This code
  191. Xwill be recognized when sending under all circumstances (5/30/87).
  192. X
  193. X------------------------------------------------------------------------------
  194. X
  195. XChanges leading to version 3.4
  196. X
  197. X1) Fix usage message (10/2/87).
  198. X
  199. X2) Sender will now try up to 10 times (EOTMAX) to send an EOT to terminate a
  200. Xtransmission.  Used to be 5 times, but Chuck Forsberg's "official" minimum
  201. Xrequirements for YMODEM mandate 10 (10/2/87).
  202. X
  203. X3) Handle YMODEM file modification times if present in header on reception of
  204. Xboth binary and text files (10/2/87).  Retracted when can't seem to get
  205. Xproper times whn playing with dsz (10/3/87).  Found bug and reinstalled
  206. Xfeature (10/16/87).  Found REAL bug (10/21/87).
  207. X
  208. X4) Null bytes are now stripped out of files when received as text files (MEX
  209. Xdoesn't seem to want to put in the terminating control-Z) (10/3/87).
  210. X
  211. X5) Slightly modified terminal parameter setting to explicitly turn of CRMOD
  212. Xand to flush read queue; ideas stolen from Kermit.  Will it fly on Pyramid?
  213. X(10/3/87).
  214. X
  215. X6) Decreased time between "startup" characters sent when starting a file
  216. Xreceive operation.  This should increase perceived response.  Now waits 
  217. XWAITFIRST seconds (set to 1) instead of 6 (waits for 5 seconds for 
  218. Xsubsequent packets.  STERRORMAX now 60, CRCSWMAX now 30.  
  219. XTimeouts on 1st sector no longer reported in log (10/5/87).
  220. X
  221. X7) Once again played with kernel sleeps in readbuf() (packet reading
  222. Xroutine).  On busy system could cause real problems.  Now supply flag (t) to
  223. Xsuppress sleeping on Too Busy systems.  No longer suppress sleep when speeds are
  224. Xover 4800 bps.  Sleep kludge DOES help: on an empty 750 running 4.3BSD, a
  225. Xfile reception at 2400 bps used 6% of the CPU with the sleep kludge and 24%
  226. Xwithout it (data transfer rates were the the same) (10/5/87).
  227. X
  228. X8) Actually count characters as they are being read for a file reception.
  229. XWhen YMODEM file length is set, stop writing characters when reach length.
  230. XThis will allow YMODEM file lengths to work for text files and the
  231. Xelimination of truncfile() in getput.c (which was impossible for SYS V)
  232. X(10/5/87).
  233. X
  234. X9) Another attempt at tty modes.  Now do nothing but set speeds, set mode to
  235. Xraw, and turn off echoing and tandem (10/6/87).
  236. X
  237. X------------------------------------------------------------------------------
  238. X
  239. XChanges leading to version 3.5
  240. X
  241. X1) Following the suggestion of Bill Carpenter (ho5cad!wjc), I changed every
  242. Xprintf("") to fprintf(stderr, "") so one can use xmodem on either end of unix
  243. Xto unix link. (3/24/88).
  244. X
  245. X2) Again, thanks to Bill Carpenter, corrected typo in stamptime() in
  246. Xgetput.sysv.c (3/24/88).
  247. X
  248. X3) Thanks to Steve Lebowitz (prcpto!pdvshl), fixed a && that should have been
  249. Xa & in getput.sysv.c (3/25/88).
  250. X
  251. X4) Thanks to Leo Pilachowski, who managed to fool xmodem by "preplacing" ACKS
  252. Xin the VAX's input queue (improves throughput by 20%, says Leo, but makes
  253. Xerror recovery a tad dicey...!).  Implemented a flushin() function in
  254. Xgetput.c to flush any pending characters.  flushin is called in send.c just
  255. Xafter sending a packet to make sure a proper ACK or NAK is received (I hope 
  256. Xfast machines don't beat me to it and get their ACKS flushed!).  In
  257. Xreceive.c, flushin is called prior to the "startup" characters, prior to
  258. Xsending the packet acknowledgment ACK and prior to the NAK prompting for
  259. Xconfirming EOT.  Now how does one implement flushin() on Sys V? (3/25/88).
  260. X
  261. X5) Fixed pair of bugs in send.c:  YMODEM test enforcing CRC was testing
  262. Xnumber of attempts against STERRORMAX instead of ERRORMAX (also shortened
  263. Xtimeout interval on this read) and a "timeout" during packet send was not
  264. Xnoticed (due to a > instead of a >=) thus program started sending EOTs which
  265. Xfurther delayed abort (3/28/88).
  266. X
  267. X6) Modified send.c and cpmify function in batch.c to strip path names on file
  268. Xnames transmitted as part of YMODEM batch (3/28/88).
  269. X
  270. X7) Hacked receive.c to make end of loop processing clearer and improve
  271. Xgarbage flushing when errors are detected (3/28/88).
  272. X
  273. X8) Pulled out of decision restricting YMODEM batch send to use CRC only.  Will 
  274. Xnow gladly use checksum if told to and will respond to NAK as well as the 
  275. Xproper C when starting up data transfer (3/28/88).  Turns out this patch fixes 
  276. Xproblem with Red Ryder (4/10/88).
  277. X
  278. X9) Tested MODEM7 batch against MEX-PC.  Confirmation of EOT during filename
  279. Xtransmission was not working, so xmodem wasn't shutting down a MODEM7 batch
  280. Xreceive.  Removed code to NAK first EOT and wait for second EOT (3/28/88).
  281. X
  282. X10) Added code to count number of newlines in a text file to get an accurate
  283. Xfile size.  I thought it would take too long; but seems to be quite nimble
  284. X(see countnl in getput.c).  We now transmit YMODEM file length and mode
  285. Xinformation for text as well as binary files (3/29/88).
  286. X
  287. X11) After a YMODEM file name packet was received, forgot to reset "wait" time
  288. Xfor receiving first character of data packet which definitely slowed
  289. Xperceived performance.  (See note 6 for v. 3.4).  Fixed (4/7/88).
  290. X
  291. X------------------------------------------------------------------------------
  292. X
  293. XChanges leading to version 3.6
  294. X
  295. X1) Added two new major commands (sa and ra) to send and receive text files
  296. Xfor Apple Macintoshs which use CR as EOL character instead of the MS/DOS CR
  297. XLF pair.  Thanks to Dave Nowak (djnowak@iseesun.DPL.SCG.HAC.COM) for the
  298. Xinspiration (4/11/88).
  299. X
  300. X2) Experiences with Red Ryder 10.3.  Fixed botch in receive.c that led to an
  301. Xinfinite loop when a checksum failed on YMODEM file name packet.  Now have
  302. Xseperate variables for packet errors and "startup" errors.  Prevent CRC to
  303. Xchecksum switch during receive startup if YMDMBAT flag is true.  This insures
  304. Xthat no such transition will ever take place on second or subsequent file
  305. Xtransfer; can be set on first file by including Y option on command line.  No
  306. Xlonger print "0" expected sectors if both YMODEM file length and KMD file
  307. Xlength are both 0 (4/12/88).
  308. X
  309. X3) Cleaned up ifs in readbuf.  Removed void declaration on flushin (will
  310. Xbreak 4.2BSD compiler?).  Corrected "number of sent sectors" on YMODEM
  311. Xtransfer (was counting filename packet) (4/12/88).
  312. X
  313. X4) More experiences with Red Ryder.  Removed line flush before every CRCCHR
  314. Xor NAK trying to start a receive (RR YMODEM batch send to the VAX now seems
  315. Xto work).  Fixed KMD "1K reception flag" to work properly on a receive. 
  316. XAdded a flushin just before program exits in a futile effort to eliminate
  317. XRR's nasty habit of sending a final EOT down the line.  Reaaranged
  318. Xvariables in send.c so longpackets requested by the KMD flag are not
  319. X"sticky" from file to file in a batch.  RR is a real DOG: ony gets about 133
  320. Xcps when downloading to a Mac over a 9600 bps line! (4/14/88). 
  321. X
  322. X------------------------------------------------------------------------------
  323. X
  324. XThanks to Keith Peterson (w8sdz@simtel20.arpa), John Rupley
  325. X(arizona!rupley!root), Emmet Gray (ihnp4!uiucuxc!fthood!egray), Bob Bickford
  326. X(lll-crg!well!rab), Doug Moore (moore@svax.cs.cornell.edu), David Brown
  327. X(jdb@ncsc.arpa), Bill Carpenter (ho5cad!wjc), Steve Lebowitz (prcpto!pdvshl),
  328. XLeo Pilachowski, Dave Nowak (djnowak@iseesun.DPL.SCG.HAC.COM) and Chuck
  329. XForsberg's documents and his ZCOMM/DSZ/rz/sz programs for ideas, suggestions
  330. Xand comments. 
  331. !Funky!Stuff!
  332. echo x - Makefile
  333. sed -e 's/^X//' > Makefile << '!Funky!Stuff!'
  334. XOBJECTS = xmodem.o getput.o misc.o send.o receive.o batch.o
  335. XCFLAGS = -O
  336. X
  337. Xxmodem: $(OBJECTS)
  338. X    cc $(CFLAGS) $(OBJECTS) -o xmodem
  339. X
  340. X$(OBJECTS): xmodem.h
  341. X
  342. Xprint: 
  343. X    lpr -p -Pvmslp xmodem.h xmodem.c getput.c receive.c send.c batch.c \
  344. X    misc.c Makefile update.doc README xmodem.1 getput.sysv.c
  345. X
  346. Xlint:
  347. X    lint xmodem.c getput.c receive.c send.c batch.c misc.c | imprint
  348. X
  349. Xshar:
  350. X    shar README update.doc Makefile xmodem.1 xmodem.h > xmodem.shar.1
  351. X    shar xmodem.c receive.c misc.c > xmodem.shar.2
  352. X    shar getput.c getput.sysv.c > xmodem.shar.3
  353. X    shar batch.c send.c > xmodem.shar.4
  354. X    shar tip.diffs > xmodem.shar.5
  355. X
  356. Xbigshar: 
  357. X    shar README update.doc Makefile xmodem.1 xmodem.h xmodem.c getput.c \
  358. X    getput.sysv.c receive.c misc.c batch.c send.c tip.diffs > xmodem.shar
  359. X
  360. Xtarz: 
  361. X    tar cvf xmodem.tar README update.doc Makefile xmodem.1 xmodem.h \
  362. X    xmodem.c getput.c getput.sysv.c receive.c misc.c batch.c send.c \
  363. X    tip.diffs ymodem.doc
  364. X    compress xmodem.tar
  365. !Funky!Stuff!
  366. echo x - xmodem.1
  367. sed -e 's/^X//' > xmodem.1 << '!Funky!Stuff!'
  368. X.TH XMODEM LOCAL "April 14, 1988"
  369. X.UC 4.2
  370. X.SH NAME
  371. Xxmodem \- Christensen protocol file transfer utility
  372. X.SH SYNOPSIS
  373. X.B xmodem
  374. X[\fBst|sb|sa|rt|rb|ra\fR][\fBymkctdlx\fR]
  375. X[file...]
  376. X.br
  377. X.SH DESCRIPTION
  378. XThe
  379. X.I xmodem
  380. Xprogram implements the Christensen (XMODEM) file transfer
  381. Xprotocol for moving files between 4.2/4.3BSD Unix systems and microcomputers.
  382. XThe XMODEM/CRC protocol, the MODEM7 batch protocol, the XMODEM-1K
  383. Xblock protocol and the YMODEM batch protocol are all supported by 
  384. X.IR xmodem .
  385. XFor details of the protocols,
  386. Xsee the document edited by Chuck Forsberg titled
  387. X.I
  388. XXMODEM/YMODEM Protocol Reference.
  389. X.sp
  390. XOption Flags are case insensitive; the cluster of flags 
  391. Xmay be preceded by an optional "-"
  392. Xcharacter.
  393. X.PP
  394. X.SH PARAMETERS
  395. XExactly one of the following must be selected:
  396. X.TP
  397. X.B rb  
  398. XReceive Binary - files are placed on the Unix disk without conversion.
  399. X.I Xmodem
  400. Xwill silently destroy existing files of the same name.
  401. X.TP
  402. X.B rt  
  403. XReceive Text - files are converted from the CP/M and MS-DOS
  404. Xformat of CR-LF pairs to the Unix convention of newline 
  405. Xcharacters only between lines.  
  406. XNull bytes are ignored and bit 8 of each character is stripped (which makes 
  407. XWordstar files much more readable).
  408. XA CTRL-Z character is deemed to indicate the EOF location in the incoming
  409. Xfile.
  410. XThe resulting file
  411. Xis acceptable to the Unix editors and compilers, and is usually slightly
  412. Xsmaller than the original file.
  413. X.I Xmodem
  414. Xwill silently destroy existing files of the same name.
  415. X.TP
  416. X.B ra
  417. XReceive Apple - same as rt save CR characters in the incoming file are 
  418. Xtranslated into Unix newline characters.
  419. X.TP
  420. X.B sb  
  421. XSend Binary - files are sent without conversion as they exist on the Unix disk.
  422. X.TP
  423. X.B st  
  424. XSend Text - newline characters in the file are converted to CR-LF pairs
  425. Xin accord with the CP/M and MS-DOS conventions for text files.  The file
  426. X"grows" in this process.
  427. X.TP
  428. X.B sa  
  429. XSend Apple - same as st save newline characters are converted into CR
  430. Xcharacters in accord with Apple Macintosh conventions for text files.
  431. X.PP
  432. X.SH OPTIONS
  433. X.TP
  434. X.B y
  435. XSelect the YMODEM batch protocol for sending files; a list of files specified
  436. Xon the command line will be sent in sequence.  The YMODEM batch protocol is 
  437. Xused automatically for file reception if the sending program requests it.
  438. XIf this flag is specified for a batch receive, (\fIxmodem rty\fR, for example),
  439. Xthe transfer will never attempt to switch from CRC to checksum mode.
  440. X.TP
  441. X.B m
  442. XSelect the MODEM7 batch protocol for sending files; a list of files specified
  443. Xon the command line will be sent in sequence.  The MODEM7 batch protocol is 
  444. Xused automatically for file reception if the sending program requests it.
  445. XIf this flag is specified for a batch receive, (\fIxmodem rbm\fR, for example),
  446. Xthe transfer starts in checksum mode rather than CRC mode.
  447. X.TP
  448. X.B k
  449. XSelect the XMODEM-1K file transfer mode for sending files. Use of 1K packets on
  450. Xlow-error lines increases throughput.  
  451. XHowever, over direct connections at 9600 bps to a busy host, 1K packets may
  452. Xcause data overflows generating excessive retries.
  453. X1K packets are automatically
  454. Xused for file reception if the sending program requests it.
  455. XIf this flag is specified with the YMODEM flag in a batch receive (\fIxmodem
  456. Xrbyk\fR, for example), the program will attempt to use the "KMD/IMP" convention
  457. Xto invoke 1K file transfers.
  458. X.TP
  459. X.B c   
  460. XSelect the CRC-16 error-checking protocol on receive.  CRC mode is better at catching
  461. Xtransmission errors that occur than the alternative checksum protocol.  
  462. XCRC mode is automatically selected for file
  463. Xtransmission if the receiving modem program requests it.
  464. X.TP
  465. X.B t
  466. XIndicates the Unix system is Too Busy and 
  467. X.I xmodem
  468. Xshould fall back to a simpler I/O strategy than normal.
  469. X.TP
  470. X.B d   
  471. XDelete the 
  472. X.I xmodem.log
  473. Xfile before file transfer is begun.
  474. X.TP
  475. X.B l   
  476. XDo NOT write to the log file.  If logging is selected, a file
  477. X.I xmodem.log 
  478. Xwill be created (or appended to), with entries for significant events, errors
  479. Xand retries.  This can be useful to see why things went wrong
  480. Xwhen they do.
  481. X.TP
  482. X.B x
  483. XToggle on debug mode.  If debug mode is selected, copious and possibly
  484. Xuseful debugging information will be placed in 
  485. X.IR xmodem.log .
  486. X.SH "FILE NAMES"
  487. XFiles transmitted using one of the batch modes
  488. Xwill be stored on the remote machine under a CP/M-ified name (path names
  489. Xstripped, limited
  490. Xto eight characters plus a three character extension; ":" characters will
  491. Xbe turned into "/" characters; all characters will be in monocase).  
  492. XFiles received using one of the batch modes
  493. Xwill be stored under their transmitted names (except that any "/" characters
  494. Xin the file name will be converted into ":" characters, all upper-case
  495. Xcharacters will be translated into lower case and trailing dots will be
  496. Xexpunged).
  497. X.PP
  498. XWhen a batch receive is requested,
  499. X.I xmodem
  500. Xtakes a wait and see attitude and can adapt to either batch protocol or even
  501. Xa classic XMODEM transfer (note that CRC-16 mode is automatically set under
  502. Xthese circumstances unless the b flag is specified).
  503. XIf a classic, "non-batch" XMODEM file reception takes place, 
  504. Xthe received file is stored as
  505. X.IR xmodem.in .
  506. XFile names present on the command line for a batch receive are ignored.
  507. X.SH NOTES
  508. XWhile waiting for the beginning of a file transfer, 
  509. X.I xmodem
  510. Xtreats two CAN (CTRL-X) characters that are received within 3 seconds
  511. Xas a request to abort.  CAN characters will not cause an abort if received
  512. Xduring a file transfer.
  513. X.PP
  514. XIf 10 or more errors are detected during the transmission or reception of any
  515. Xone packet, the transfer is aborted.
  516. X.PP
  517. XSqueezed, compressed or ARCed files must be transferred in binary mode, even if they
  518. Xcontain text.
  519. X.PP
  520. XIf you use 
  521. X.I xmodem
  522. Xover a 
  523. X.I rlogin
  524. Xlink, you may have to use the form
  525. X.IR "rlogin machine -8" .
  526. X.PP
  527. XIf an unexpected error occurs before a file is completely received, the
  528. Xincomplete file is deleted.
  529. X.PP
  530. XFiles received using both binary and text mode in a YMODEM batch transfer 
  531. Xwill be truncated
  532. Xto the file size specified in the YMODEM header (extra CR characters in the
  533. Xincoming file are correctly handled).  File sizes are included in
  534. Xthe YMODEM header when sending both binary and text files.  Thus files
  535. Xtransferred via YMODEM should preserve their exact length.
  536. XFile modification times are set for received files if present in the YMODEM
  537. Xheader; they are included in the headers for transmitted files.
  538. X.PP
  539. XThe "KMD/IMP" record count field in the YMODEM header is both set and read.
  540. X.SH EXAMPLES
  541. XTo receive a text file transmitted from a micro (using CRC-16
  542. Xerror-checking) and store it under the
  543. Xname 
  544. X.IR file.name ,
  545. Xuse the command line
  546. X.RS
  547. X.B "xmodem rtc file.name"
  548. X.RE
  549. XNote that if the transmitting program on the micro uses the 1K packet
  550. Xprotocol or either batch protocol,
  551. X.I xmodem
  552. Xdetects this automatically and takes appropriate action.  Further
  553. Xnote that if one of the batch protocols is used, the received file(s)
  554. Xwill be stored under their own names and the name on the command line
  555. X(if any) will be ignored.
  556. X.PP
  557. XTo send a set of text files to a microcomputer using 1K packets and the
  558. XYMODEM batch protocol, use the command line
  559. X.RS
  560. X.B "xmodem styk *.txt"
  561. X.RE
  562. X.SH FILES
  563. Xxmodem.log (if logging is enabled)
  564. X.SH BUGS
  565. XBatch mode could be smarter about bad file-names in the midst of a
  566. Xbatch transmit/receive.
  567. X.PP
  568. XBatch mode could allow a mixture of binary and text files.
  569. X.PP
  570. XBare Carriage Return characters (i.e., those not immediately followed by a
  571. XLine Feed character) are mishandled in a received file when using text mode.
  572. XA file with ``overstruck'' lines will thus come out looking funny.
  573. X.PP
  574. XYMODEM header packets are only sent as 128 byte packets.  Thus VERY long file
  575. Xnames will not be handled properly.
  576. X.SH SEE ALSO
  577. Xkermit(1)
  578. X.SH AUTHOR
  579. XSteve Grandi, National Optical Astronomy Observatories.  Based on
  580. X.I xmodem
  581. Xby Brian Kantor, University of California at San Diego.
  582. XThis, in turn, was based on
  583. X.I umodem
  584. Xby Lauren Weinstein, Richard Conn and others.
  585. !Funky!Stuff!
  586. echo x - xmodem.h
  587. sed -e 's/^X//' > xmodem.h << '!Funky!Stuff!'
  588. X#include <ctype.h>
  589. X#include <stdio.h>
  590. X#include <sys/types.h>
  591. X#include <sys/stat.h>
  592. X#include <sys/time.h>
  593. X#include <sgtty.h>
  594. X#include <signal.h>
  595. X
  596. X/* define macros to print messages in log file */
  597. X#define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
  598. X#define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
  599. X
  600. X#define         VERSION    36    /* Version Number */
  601. X#define      FALSE      0
  602. X#define      TRUE       1
  603. X
  604. X
  605. X/*  ASCII Constants  */
  606. X#define      SOH      001 
  607. X#define         STX    002
  608. X#define         ETX    003
  609. X#define      EOT    004
  610. X#define         ENQ    005
  611. X#define      ACK      006
  612. X#define         LF        012   /* Unix LF/NL */
  613. X#define         CR        015  
  614. X#define      NAK      025
  615. X#define         SYN    026
  616. X#define         CAN    030
  617. X#define         ESC    033
  618. X
  619. X/*  XMODEM Constants  */
  620. X#define      TIMEOUT      -1
  621. X#define      ERRORMAX      10    /* maximum errors tolerated while transferring a packet */
  622. X#define      WAITFIRST  1     /* seconds between startup characters in read */
  623. X#define      STERRORMAX    60    /* maximum "errors" tolerated in read startup */
  624. X#define      CRCSWMAX    30    /* maximum time to try CRC mode before switching */
  625. X#define      NAKMAX    120   /* maximum times to wait for initial NAK when sending */
  626. X#define      RETRYMAX      5     /* maximum retries to be made certain handshaking routines */
  627. X#define      KSWMAX    5     /* maximum errors before switching to 128 byte packets */
  628. X#define      EOTMAX    10    /* maximum times sender will send an EOT to end transfer */
  629. X#define      SLEEPNUM    100   /* target number of characters to collect during sleepy time */
  630. X#define         BBUFSIZ    1024  /* buffer size */
  631. X#define      NAMSIZ    11    /* length of a CP/M file name string */
  632. X#define         CTRLZ    032   /* CP/M EOF for text (usually!) */
  633. X#define      CRCCHR    'C'   /* CRC request character */
  634. X#define      KCHR    'K'   /* 1K block request character */
  635. X#define      BAD_NAME    'u'   /* Bad filename indicator */
  636. X
  637. X#define      CREATMODE    0644  /* mode for created files */
  638. X
  639. X/* GLOBAL VARIABLES */
  640. X
  641. Xint ttyspeed;        /* tty speed (bits per second) */
  642. Xunsigned char buff[BBUFSIZ];    /* buffer for data */
  643. Xint nbchr;        /* number of chars read so far for buffered read */
  644. Xlong filelength;    /* length specified in YMODEM header */
  645. Xlong fileread;        /* characters actually read so far in file */
  646. Xchar filename[256];    /* place to construct filenames */
  647. XFILE *LOGFP;        /* descriptor for LOG file */
  648. X
  649. X/* option flags and state variables */
  650. Xchar    XMITTYPE;    /* text or binary? */
  651. Xint    DEBUG;        /* keep debugging info in log? */
  652. Xint    RECVFLAG;    /* receive? */
  653. Xint    SENDFLAG;    /* send? */
  654. Xint    BATCH;        /* batch? (Now used as a state variable) */
  655. Xint    CRCMODE;    /* CRC or checksums? */
  656. Xint    DELFLAG;    /* don't delete old log file? */
  657. Xint    LOGFLAG;    /* keep log? */
  658. Xint    LONGPACK;     /* do not use long packets on transmit? */
  659. Xint    MDM7BAT;    /* MODEM7 batch protocol */
  660. Xint    YMDMBAT;    /* YMODEM batch protocol */
  661. Xint    TOOBUSY;    /* turn off sleeping in packet read routine */
  662. Xint    CHECKLENGTH;    /* Are we truncating a file to a YMODEM length? */
  663. X
  664. X
  665. X/*   CRC-16 constants.  From Usenet contribution by Mark G. Mendel, 
  666. X     Network Systems Corp.  (ihnp4!umn-cs!hyper!mark)
  667. X*/
  668. X
  669. X    /* the CRC polynomial. */
  670. X#define    P    0x1021
  671. X
  672. X    /* number of bits in CRC */
  673. X#define W    16
  674. X
  675. X    /* the number of bits per char */
  676. X#define B    8
  677. !Funky!Stuff!
  678. exit
  679.  
  680.