Path: utzoo!utgpu!water!watmath!uunet!lll-winken!pacbell!att!mtune!ethos!pcid!gizzmo!fthood!egray From: egray@fthood.UUCP Newsgroups: unix-pc.sources Subject: xmodem v3.6 (3 of 3) Message-ID: <6800079@fthood> Date: 14 Jul 88 19:06:00 GMT Lines: 1037 Nf-ID: #N:fthood:6800079:000:34208 Nf-From: fthood.UUCP!egray Jul 14 14:06:00 1988 This part 3 of 3 to Steve Grandi's xmodem v3.6 package. Emmet P. Gray US Army, HQ III Corps & Fort Hood ...!uunet!uiucuxc!fthood!egray Attn: AFZF-DE-ENV Directorate of Engineering & Housing Environmental Management Office Fort Hood, TX 76544-5057 ------------------------------------------------------------------------------ #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # xmodem.l # tip.diffs # update.doc # This archive created: Thu Jul 14 13:12:51 1988 export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'xmodem.l'" '(8026 characters)' if test -f 'xmodem.l' then echo shar: "will not over-write existing file 'xmodem.l'" else sed 's/^X//' << \SHAR_EOF > 'xmodem.l' X.TH XMODEM 1 net X.SH NAME Xxmodem \- Christensen protocol file transfer utility X.SH SYNOPSIS X.B xmodem X[\fBr\fR|\fBrt\fR|\fBra\fR|\fBs\fR|\fBst\fR|\fBsa\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 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 r XReceive Binary - files are placed on the Unix disk without conversion. XIf a batch protocol is not specified X.I xmodem Xwill prompt the user before overwriting an existing file of the same name. XBatch protocols avoid file name collisions by prepending the letter 'X' to Xthe file 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.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 s 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 rmc\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 Xryk\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 checksum error-checking protocol on receive. Although the CRC Xmode is better at catching Xtransmission errors than the checksum method, older systems may not use CRC. 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 XUse logging feature. 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 c 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 rt 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. SHAR_EOF if test 8026 -ne "`wc -c < 'xmodem.l'`" then echo shar: "error transmitting 'xmodem.l'" '(should have been 8026 characters)' fi fi echo shar: "extracting 'tip.diffs'" '(14301 characters)' if test -f 'tip.diffs' then echo shar: "will not over-write existing file 'tip.diffs'" else sed 's/^X//' << \SHAR_EOF > 'tip.diffs' X X*** cmdtab.c.ORIG Mon May 5 11:01:59 1986 X--- cmdtab.c Thu Aug 21 10:08:50 1986 X*************** X*** 15,16 **** X--- 15,17 ---- X extern int cu_take(), cu_put(), dollar(), genbrk(), suspend(); X+ extern int rtfile(), stfile(), rbfile(), sbfile(); X X*************** X*** 35,36 **** X--- 36,41 ---- X { '#', NORM, "send break", genbrk }, X+ { '{', NORM, "receive xmodem text file", rtfile }, X+ { '}', NORM, "send xmodem text file", stfile }, X+ { '(', NORM, "receive xmodem binary file", rbfile }, X+ { ')', NORM, "send xmodem binary file", sbfile }, X { 0, 0, 0 } X X X X*** cmds.c.ORIG Mon May 5 11:01:56 1986 X--- cmds.c Tue Sep 30 10:17:11 1986 X*************** X*** 855,856 **** X--- 865,1412 ---- X return(0); X+ } X+ X+ X+ /* XMODEM stuff; sag sept 1984 - Feb 1985 X+ * Taken from Brian Kantor's (sdccsu3!brian) xmodem version 1.0 X+ * Note that this code will work on version 4.2 ONLY (uses select) X+ */ X+ X+ #include X+ #include 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+ #define CTRLZ 032 /* CP/M EOF for text (usually!) */ X+ X+ /* XMODEM Constants */ X+ #define TIMEOUT -1 X+ #define ERRORMAX 10 /* maximum errors tolerated */ X+ #define RETRYMAX 10 /* maximum retries to be made */ X+ #define BBUFSIZ 128 /* buffer size -- do not change! */ X+ #define DEBUG 0 /* 1 for debugging output */ X+ #define GETERR -10 /* error code for getbyte routine */ X+ X+ char buff[BBUFSIZ]; X+ X+ int nbchr; /* number of chars read so far for buffered read */ X+ X+ /* Receive a text file */ X+ rtfile(c) X+ char c; X+ { X+ putchar (c); X+ rfile ('t'); X+ } X+ X+ /* Receive a binary file */ X+ rbfile(c) X+ char c; X+ { X+ putchar (c); X+ rfile ('b'); X+ } X+ X+ /* Send a text file */ X+ stfile(c) X+ char c; X+ { X+ putchar (c); X+ sfile ('t'); X+ } X+ X+ /* Send a binary file */ X+ sbfile(c) X+ char c; X+ { X+ putchar (c); X+ sfile ('b'); X+ } X+ X+ /* print error message and cleanup for exit */ X+ error(msg) X+ char *msg; X+ { X+ printf("\r\nXMODEM: %s\n", msg); X+ ioctl (0, TIOCSETC, &tchars); X+ write (fildes[1], (char *)&ccc, 1); X+ signal (SIGINT, SIG_DFL); X+ } X+ X+ /* X+ * X+ * Get a byte from the specified file. Buffer the read so we don't X+ * have to use a system call for each character. X+ * X+ */ X+ getbyte(fildes, ch) /* Buffered disk read */ X+ int fildes; X+ char *ch; X+ X+ { X+ static char buf[BUFSIZ]; /* Remember buffer */ X+ static char *bufp = buf; /* Remember where we are in buffer */ X+ X+ if (nbchr == 0) /* Buffer exausted; read some more */ X+ { X+ if ((nbchr = read(fildes, buf, BUFSIZ)) < 0) X+ { X+ error("File Read Error"); X+ return (GETERR); X+ } X+ bufp = buf; /* Set pointer to start of array */ X+ } X+ if (--nbchr >= 0) X+ { X+ *ch = *bufp++; X+ return(0); X+ } X+ else X+ return(EOF); X+ } X+ X+ /** receive a file **/ X+ rfile(mode) X+ char mode; X+ { X+ register int bufctr, checksum; X+ register int c; X+ int j, firstchar, sectnum, sectcurr, tmode; X+ int sectcomp, errors, errorflag, recfin; X+ int fatalerror, inchecksum; X+ long recvsectcnt; X+ X+ int (*f) (); X+ char *cp, *expand(); X+ time_t start; X+ X+ if (prompt (" Receive local file name? ", copyname)) X+ return; X+ cp = expand (copyname); X+ if ((sfd = creat (cp, 0666)) < 0) X+ { X+ printf ("\r\n%s: Cannot creat\r\n", copyname); X+ return; X+ } X+ X+ kill (pid, SIGIOT); X+ read (repdes[0], (char *)&ccc, 1); /* wait until read process stops */ X+ ioctl (0, TIOCSETC, &defchars); /* set tty modes */ X+ f = signal (SIGINT, intcopy); /* intercept control-c */ X+ X+ start = time(0); X+ quit = 0; X+ (void) setjmp(intbuf); /* set control-c catcher */ X+ X+ if (quit) X+ { X+ error("Control-C; Reception canceled"); X+ close (sfd); X+ return; X+ } X+ X+ printf("XMODEM: Ready to RECEIVE File %s", cp); X+ puts("\r\nControl-C to cancel.\n"); X+ X+ recfin = FALSE; X+ sectnum = errors = 0; X+ fatalerror = FALSE; /* NO fatal errors */ X+ recvsectcnt = 0; /* number of received sectors */ X+ X+ if (mode == 't') X+ tmode = TRUE; X+ else X+ tmode = FALSE; X+ X+ sendbyte(NAK); /* Start up the sender's first block */ X+ X+ do X+ { X+ errorflag = FALSE; X+ do X+ { X+ firstchar = readbyte(6); X+ } X+ while ((firstchar != SOH) X+ && (firstchar != EOT) X+ && (firstchar != TIMEOUT) X+ && ((firstchar & 0x7f) != CAN)); X+ X+ if (firstchar == TIMEOUT) X+ { X+ printf("\r\nTimeout on Sector %d\n", sectnum+1); X+ errorflag = TRUE; X+ } X+ X+ if ((firstchar & 0x7f) == CAN) X+ { X+ error("Reception canceled at user's request"); X+ close (sfd); X+ return; X+ } X+ X+ if (firstchar == SOH) X+ { X+ sectcurr = readbyte(3); /* get sector numbers */ X+ sectcomp = readbyte(3); X+ if ((sectcurr + sectcomp) == 0xff) X+ { X+ if (sectcurr == ((sectnum+1) & 0xff)) X+ { X+ checksum = 0; X+ for (j = bufctr = 0; j < BBUFSIZ; j++) X+ { X+ buff[bufctr] = c = readbyte(3); X+ checksum = ((checksum+c) & 0xff); X+ if (!tmode) /* binary mode */ X+ { X+ bufctr++; X+ continue; X+ } X+ if (c == CR) X+ continue; /* skip CR's */ X+ if (c == CTRLZ) /* CP/M EOF char */ X+ { X+ recfin = TRUE; /* flag EOF */ X+ continue; X+ } X+ if (!recfin) X+ bufctr++; X+ } X+ inchecksum = readbyte(3); /* get checksum */ X+ if (checksum == inchecksum) /* good checksum */ X+ { X+ errors = 0; X+ recvsectcnt++; X+ sectnum = sectcurr; X+ if (DEBUG) printf ("\n"); X+ printf ("\rreceived sector %-4d", recvsectcnt); X+ if (write(sfd, buff, bufctr) < 0) X+ { X+ sendbyte(CAN); X+ error("File Write Error"); X+ close (sfd); X+ return; X+ } X+ else X+ sendbyte(ACK); X+ X+ } X+ else X+ { X+ printf("\r\nChecksum Error on Sector %d\n", sectnum+1); X+ errorflag = TRUE; X+ } X+ } X+ else X+ { X+ if (sectcurr == sectnum) X+ { X+ while(readbyte(3) != TIMEOUT) X+ ; X+ sendbyte(ACK); X+ } X+ else X+ { X+ printf("\r\nPhase Error - Received Sector is "); X+ printf("%d while Expected Sector is %d\n", X+ sectcurr, ((sectnum+1) & 0xff)); X+ errorflag = TRUE; X+ fatalerror = TRUE; X+ sendbyte(CAN); X+ } X+ } X+ } X+ else X+ { X+ printf("\r\nHeader Sector Number Error on Sector %d\n", X+ sectnum+1); X+ errorflag = TRUE; X+ } X+ } X+ X+ if (errorflag) X+ { X+ errors++; X+ while (readbyte(3) != TIMEOUT) X+ ; X+ sendbyte(NAK); X+ } X+ } X+ while ((firstchar != EOT) && (errors < ERRORMAX) && !fatalerror); X+ X+ if ((firstchar == EOT) && (errors < ERRORMAX) && !fatalerror) X+ { X+ close(sfd); X+ sendbyte(ACK); X+ printf("\n\rReceive Complete"); X+ printf("\n\r%ld CP/M Records ", recvsectcnt); X+ prtime(" transferred in ", time(0)-start); X+ X+ ioctl (0, TIOCSETC, &tchars); /* reset ttys */ X+ write (fildes[1], (char *)&ccc, 1); /* wakeup tip */ X+ signal (SIGINT, SIG_DFL); /* reset control-c catcher */ X+ } X+ else X+ { X+ sendbyte(CAN); X+ error("\r\nABORTED -- Too Many Errors"); X+ close (sfd); X+ return; X+ } X+ } X+ X+ /** send a file **/ X+ sfile(mode) X+ char mode; X+ { X+ register int bufctr, checksum, sectnum; X+ char blockbuf[134]; X+ int fd, attempts; X+ int nlflag, sendfin, tmode; X+ int bbufcnt; X+ int firstchar; X+ int getretrn; X+ char c; X+ int sendresp; /* response char to sent block */ X+ X+ int (*f) (); X+ char *cp, *expand(); X+ time_t start; X+ X+ if (prompt (" Send local file name? ", copyname)) X+ return; X+ cp = expand (copyname); X+ if ((fd = open(cp, 0)) < 0) X+ { X+ printf("Can't open file for send\n"); X+ return; X+ } X+ X+ kill (pid, SIGIOT); X+ read (repdes[0], (char *)&ccc, 1); /* wait until read process stops */ X+ ioctl (0, TIOCSETC, &defchars); /* setup tty */ X+ f = signal (SIGINT, intcopy); /* prepare to catch control-c */ X+ start = time(0); X+ quit = 0; X+ (void) setjmp(intbuf); /* setup control-c catcher */ X+ X+ nbchr = 0; /* clear buffered read char count */ X+ X+ if (quit) X+ { X+ sendbyte(CAN); X+ error("Control-C; Send canceled"); X+ close (fd); X+ return; X+ } X+ X+ printf("XMODEM: File %s Ready to SEND", cp); X+ prfilestat(cp); /* print file size statistics */ X+ puts("\r\nControl-C to cancel.\n"); X+ X+ if (mode == 't') X+ tmode = TRUE; X+ else X+ tmode = FALSE; X+ X+ sendfin = nlflag = FALSE; X+ attempts = 0; X+ X+ while (((firstchar=readbyte(30)) != NAK) && (firstchar != CAN)) X+ { X+ if (++attempts > RETRYMAX) { X+ error("Remote System Not Responding"); X+ close (fd); X+ return; X+ } X+ } X+ X+ if ((firstchar & 0x7f) == CAN) X+ { X+ error("Send cancelled at user's request."); X+ close (fd); X+ return; X+ } X+ X+ sectnum = 1; /* first sector number */ X+ attempts = 0; X+ X+ do X+ { X+ for (bufctr=0; bufctr < BBUFSIZ;) X+ { X+ if (nlflag) X+ { X+ buff[bufctr++] = LF; /* leftover newline */ X+ nlflag = FALSE; X+ } X+ getretrn = getbyte(fd, &c); X+ if (getretrn == GETERR) X+ { X+ sendbyte(CAN); X+ error ("Read error on local file"); X+ close (fd); X+ return; X+ } X+ if (getretrn == EOF) X+ { X+ sendfin = TRUE; /* this is the last sector */ X+ if (!bufctr) /* if EOF on sector boundary */ X+ break; /* avoid sending extra sector */ X+ if (tmode) X+ buff[bufctr++] = CTRLZ; /* Control-Z for CP/M EOF */ X+ else X+ bufctr++; X+ continue; X+ } X+ X+ if (tmode && c == LF) /* text mode & Unix newline? */ X+ { X+ buff[bufctr++] = CR; /* insert carriage return */ X+ if (bufctr < BBUFSIZ) X+ buff[bufctr++] = LF; /* insert LF */ X+ else X+ nlflag = TRUE; /* insert on next sector */ X+ } X+ else X+ buff[bufctr++] = c; /* copy the char without change */ X+ } X+ X+ attempts = 0; X+ X+ if (!bufctr) /* if EOF on sector boundary */ X+ break; /* avoid sending empty sector */ X+ X+ do X+ { X+ bbufcnt = 0; /* start building block to be sent */ X+ blockbuf[bbufcnt++] = SOH; /* start of packet char */ X+ blockbuf[bbufcnt++] = sectnum; /* current sector # */ X+ blockbuf[bbufcnt++] = -sectnum-1; /* and its complement */ X+ X+ checksum = 0; /* init checksum */ X+ for (bufctr=0; bufctr < BBUFSIZ; bufctr++) X+ { X+ blockbuf[bbufcnt++] = buff[bufctr]; X+ checksum = ((checksum+buff[bufctr]) & 0xff); X+ } X+ X+ blockbuf[bbufcnt++] = checksum; X+ write(FD, blockbuf, 132); /* write the block */ X+ ioctl(FD,TIOCFLUSH,0); X+ X+ attempts++; X+ sendresp = readbyte(10); /* get response */ X+ if (sendresp != ACK) X+ { X+ printf("\r\nNon-ACK Received on Sector %d\n",sectnum); X+ if (sendresp == TIMEOUT) X+ printf("\r\nThis Non-ACK was a TIMEOUT\n"); X+ } X+ } X+ while((sendresp != ACK) && (attempts < RETRYMAX)); X+ X+ sectnum++; /* increment to next sector number */ X+ if (DEBUG) printf ("\n"); X+ printf ("\rsent sector %-4d", sectnum-1); X+ } X+ while (!sendfin && (attempts < RETRYMAX)); X+ X+ if (attempts >= RETRYMAX) X+ { X+ error("Remote System Not Responding"); X+ close (fd); X+ return; X+ } X+ X+ attempts = 0; X+ sendbyte(EOT); /* send 1st EOT */ X+ X+ while ((readbyte(15) != ACK) && (attempts++ < RETRYMAX)) X+ sendbyte(EOT); X+ X+ if (attempts >= RETRYMAX) X+ error("Remote System Not Responding on Completion"); X+ X+ close(fd); X+ printf("\r\nSend Complete\r\n"); X+ prtime("Data transferred in ", time(0)-start); X+ X+ ioctl (0, TIOCSETC, &tchars); /* restore tty */ X+ write (fildes[1], (char *)&ccc, 1); /* wakeup tip */ X+ signal (SIGINT, SIG_DFL); /* reset control-c catcher */ X+ sleep(5); /* give other side time to return to terminal mode */ X+ X+ } X+ X+ /* print file size status information */ X+ prfilestat(name) X+ char *name; X+ { X+ struct stat filestatbuf; /* file status info */ X+ X+ stat(name, &filestatbuf); /* get file status bytes */ X+ printf("\r\nEstimated File Size %ldK, %ld Records, %ld Bytes", X+ (filestatbuf.st_size/1024)+1, (filestatbuf.st_size/128)+1, X+ filestatbuf.st_size); X+ return; X+ } X+ X+ /* get a byte from data stream -- timeout if "seconds" elapses */ X+ int readbyte(seconds) X+ int seconds; X+ { X+ int i, readfd; X+ char c; X+ struct timeval tmout; X+ X+ tmout.tv_sec = seconds; X+ tmout.tv_usec = 0; X+ X+ readfd = 1 << FD; X+ X+ if ((i=select(FD+1, &readfd, 0, 0, &tmout)) == 0) X+ { X+ return(TIMEOUT); X+ } X+ X+ read(FD, &c, 1); X+ X+ return(c & 0xff); /* return the char */ X+ } X+ X+ /* send a byte to data stream */ X+ sendbyte(data) X+ char data; X+ { X+ write(FD, &data, 1); /* write the byte */ X+ ioctl(FD,TIOCFLUSH,0); /* flush so it really happens now! */ X+ return; X+ } X+ X+ /* X+ * "nap" for specified time X+ */ X+ nap (milliseconds) X+ int milliseconds; X+ { X+ struct timeval timeout; X+ X+ if (milliseconds == 0) X+ return; X+ timeout.tv_sec = 0; X+ timeout.tv_usec = milliseconds * 1000; X+ X+ (void) select(1, 0, 0, 0, &timeout); X } SHAR_EOF if test 14301 -ne "`wc -c < 'tip.diffs'`" then echo shar: "error transmitting 'tip.diffs'" '(should have been 14301 characters)' fi fi echo shar: "extracting 'update.doc'" '(9209 characters)' if test -f 'update.doc' then echo shar: "will not over-write existing file 'update.doc'" else sed 's/^X//' << \SHAR_EOF > 'update.doc' 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@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@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), Bill Carpenter (ho5cad!wjc), Steve Lebowitz (prcpto!pdvshl), XLeo Pilachowski, Dave Nowak (djnowak@iseesun.DPL.SCG.HAC.COM) and Chuck XForsberg's documents and his ZCOMM/DSZ/rz/sz programs for ideas, suggestions Xand comments. SHAR_EOF if test 9209 -ne "`wc -c < 'update.doc'`" then echo shar: "error transmitting 'update.doc'" '(should have been 9209 characters)' fi fi exit 0 # End of shell archive