mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-31 06:00:27 +08:00
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1305 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
40035dab65
commit
b495cb50fc
@ -1,24 +0,0 @@
|
|||||||
/* -rev 05-12-86
|
|
||||||
* mode function and most of the rest of the system dependent
|
|
||||||
* stuff for rb.c and sb.c This file is #included so the includer
|
|
||||||
* can set parameters such as HOWMANY.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int iofd = 0; /* File descriptor for ioctls & reads */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mode(n)
|
|
||||||
* 2: set a cbreak, XON/XOFF control mode if using Pro-YAM's -g option
|
|
||||||
* 1: save old tty stat, set raw mode
|
|
||||||
* 0: restore original tty mode
|
|
||||||
*/
|
|
||||||
int mode(int n)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendbrk()
|
|
||||||
{
|
|
||||||
//ioctl(iofd, TCSBRK, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,269 +0,0 @@
|
|||||||
'\" Revision Level
|
|
||||||
'\" Last Delta 05-19-86
|
|
||||||
.TH RZ 1 OMEN
|
|
||||||
.SH NAME
|
|
||||||
rb, rz \- XMODEM, YMODEM, ZMODEM (Batch) file receive
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B rz
|
|
||||||
.RB [\- "\ 1bquv" ]
|
|
||||||
.br
|
|
||||||
.B rb
|
|
||||||
.RB [\- "\ 1bquv" ]
|
|
||||||
.br
|
|
||||||
.B rz
|
|
||||||
.RB [\- "\ 1bcquv" ]
|
|
||||||
.I file
|
|
||||||
.br
|
|
||||||
.RB [ \- ][ v ] rzCOMMAND
|
|
||||||
.SH DESCRIPTION
|
|
||||||
This program uses error correcting protocol to receive
|
|
||||||
files over a serial port from a variety of programs running under
|
|
||||||
PC-DOS, CP/M,
|
|
||||||
.SM Unix,
|
|
||||||
and other operating systems.
|
|
||||||
|
|
||||||
The first form of
|
|
||||||
.B rz
|
|
||||||
(Receive Batch)
|
|
||||||
receives files with ZMODEM batch protocol.
|
|
||||||
If the sending program does not support ZMODEM,
|
|
||||||
.B rz
|
|
||||||
steps down to YMODEM protocol
|
|
||||||
after 50 seconds.
|
|
||||||
This delay can be eliminated by calling the program as
|
|
||||||
.I rb .
|
|
||||||
|
|
||||||
.B Rb
|
|
||||||
accepts either standard 128 byte sectors or
|
|
||||||
1024 byte sectors
|
|
||||||
(YAM
|
|
||||||
.B -k
|
|
||||||
option).
|
|
||||||
The user should determine experimentally
|
|
||||||
the conditions under which use of 1k blocks
|
|
||||||
actually improves throughput without causing
|
|
||||||
problems.
|
|
||||||
|
|
||||||
Normally, the file contents are converted to
|
|
||||||
.SM Unix
|
|
||||||
conventions by stripping carriage returns and all characters
|
|
||||||
beginning with Control Z (CP/M end of file).
|
|
||||||
If the raw pathname ends in
|
|
||||||
".A",
|
|
||||||
".ARC",
|
|
||||||
".CCC",
|
|
||||||
".CL",
|
|
||||||
".CMD",
|
|
||||||
".COM",
|
|
||||||
".CRL",
|
|
||||||
".DAT",
|
|
||||||
".DIR",
|
|
||||||
".EXE",
|
|
||||||
".O",
|
|
||||||
".OBJ",
|
|
||||||
".OVL",
|
|
||||||
".PAG",
|
|
||||||
".REL",
|
|
||||||
".SAV",
|
|
||||||
".SUB",
|
|
||||||
".SWP",
|
|
||||||
".SYS",
|
|
||||||
".TAR",
|
|
||||||
".UTL",
|
|
||||||
".a",
|
|
||||||
".o",
|
|
||||||
".tar",
|
|
||||||
or if the first packet contains
|
|
||||||
data that suggest a binary file
|
|
||||||
(parity bits or characters in the range 000 to 006 before the first ^Z),
|
|
||||||
or if the file mode is transmitted and the 0100000
|
|
||||||
bit is set, that file will be received in binary mode anyway.
|
|
||||||
Otherwise,
|
|
||||||
if the raw pathname ends in .MSG, or .TXT, an existing file will
|
|
||||||
be appended to rather than replaced.
|
|
||||||
|
|
||||||
If extended file information (file length, etc.)
|
|
||||||
is received,
|
|
||||||
the file length controls the number of bytes written to
|
|
||||||
the output dataset (YMODEM only),
|
|
||||||
and the modify time and file mode
|
|
||||||
(iff non zero)
|
|
||||||
are set accordingly.
|
|
||||||
|
|
||||||
If no extended file information is received,
|
|
||||||
slashes in the pathname are changed to underscore,
|
|
||||||
and any trailing period in the pathname is eliminated.
|
|
||||||
This conversion is useful for files received from CP/M systems.
|
|
||||||
Normally, each file name is converted to lower case
|
|
||||||
unless it contains one or more lower case letters.
|
|
||||||
|
|
||||||
|
|
||||||
The second form of
|
|
||||||
.B rz
|
|
||||||
receives a single
|
|
||||||
.I file
|
|
||||||
with XMODEM protocol.
|
|
||||||
The user must supply the file name to both sending and receiving programs.
|
|
||||||
|
|
||||||
|
|
||||||
The third form of
|
|
||||||
.B rz
|
|
||||||
is invoked as
|
|
||||||
.B rzCOMMAND
|
|
||||||
(with an optional leading \- as generated by login(1)).
|
|
||||||
For each received file,
|
|
||||||
rz will pipe the file to ``COMMAND filename''
|
|
||||||
where filename is the name of the transmitted file
|
|
||||||
with the file contents as standard input.
|
|
||||||
|
|
||||||
Each file transfer is acknowledged when COMMAND exits with 0 status.
|
|
||||||
A non zero exit status terminates transfers.
|
|
||||||
|
|
||||||
A typical use for this form is
|
|
||||||
.I rzrmail
|
|
||||||
which calls rmail(1)
|
|
||||||
to post mail to the user specified by the transmitted file name.
|
|
||||||
For example, sending the file "caf" from a PC-DOS system to
|
|
||||||
.I rzrmail
|
|
||||||
on a
|
|
||||||
.SM Unix
|
|
||||||
system
|
|
||||||
would result in the contents of the DOS file "caf" being mailed to user "caf".
|
|
||||||
|
|
||||||
On some
|
|
||||||
.SM Unix
|
|
||||||
systems, the login directory must contain a link to
|
|
||||||
COMMAND as login sets SHELL=rsh which disallows absolute
|
|
||||||
pathnames.
|
|
||||||
If invoked with a leading ``v'',
|
|
||||||
.B rz
|
|
||||||
will report progress to LOGFILE.
|
|
||||||
The following entry works for
|
|
||||||
.SM Unix
|
|
||||||
3.0:
|
|
||||||
.ce
|
|
||||||
rzrmail::5:1::/bin:/usr/local/rzrmail
|
|
||||||
If the SHELL environment variable includes
|
|
||||||
.I "rsh"
|
|
||||||
or
|
|
||||||
.I "rksh"
|
|
||||||
(restricted shell),
|
|
||||||
rz will not accept absolute pathnames
|
|
||||||
or references to a parent directory,
|
|
||||||
will not modify an existing file, and
|
|
||||||
removes any files received in error.
|
|
||||||
|
|
||||||
If
|
|
||||||
.B rz
|
|
||||||
is invoked with stdout and stderr to different datasets,
|
|
||||||
Verbose is set to 2, causing frame by frame progress reports
|
|
||||||
to stderr.
|
|
||||||
This may be disabled with the
|
|
||||||
.B q
|
|
||||||
option.
|
|
||||||
|
|
||||||
.PP
|
|
||||||
The meanings of the available options are:
|
|
||||||
.PP
|
|
||||||
.PD 0
|
|
||||||
.TP
|
|
||||||
.B 1
|
|
||||||
Use file descriptor 1 for ioctls and reads (Unix only).
|
|
||||||
By default, file descriptor 0 is used.
|
|
||||||
This option allows
|
|
||||||
.B rz
|
|
||||||
to be used with the
|
|
||||||
.I cu
|
|
||||||
~$
|
|
||||||
command.
|
|
||||||
.TP
|
|
||||||
.B b
|
|
||||||
Transfer all files in binary
|
|
||||||
(tell it like it is)
|
|
||||||
mode.
|
|
||||||
This option disables file append.
|
|
||||||
.TP
|
|
||||||
.B c
|
|
||||||
Request 16 bit CRC
|
|
||||||
(XMODEM file transfers default to 8 bit checksum).
|
|
||||||
Batch transfers use 16 bit CRC.
|
|
||||||
.TP
|
|
||||||
.B D
|
|
||||||
Output file data to /dev/null; for testing.
|
|
||||||
.TP
|
|
||||||
.B q
|
|
||||||
Quiet suppresses verbosity.
|
|
||||||
.TP
|
|
||||||
.B v
|
|
||||||
Verbose
|
|
||||||
causes a list of file
|
|
||||||
names to be appended to
|
|
||||||
/tmp/rzlog .
|
|
||||||
More v's generate more output.
|
|
||||||
.TP
|
|
||||||
.B u
|
|
||||||
Retain upper case letters in file names.
|
|
||||||
.PD
|
|
||||||
.SH EXAMPLES
|
|
||||||
.ne 6
|
|
||||||
.RE
|
|
||||||
(Pro-YAM command)
|
|
||||||
.RS
|
|
||||||
.I <ALT-2>
|
|
||||||
.br
|
|
||||||
YAM Command:
|
|
||||||
.I "sz *.h *.c"
|
|
||||||
.br
|
|
||||||
(This automatically invokes
|
|
||||||
.I rz
|
|
||||||
on the connected system.)
|
|
||||||
.RE
|
|
||||||
.SH SEE ALSO
|
|
||||||
ZMODEM.DOC,
|
|
||||||
YMODEM.DOC,
|
|
||||||
IMP(CP/M),
|
|
||||||
cu(1),
|
|
||||||
Professional-YAM manual,
|
|
||||||
sz(omen),
|
|
||||||
usq(omen),
|
|
||||||
undos(omen)
|
|
||||||
|
|
||||||
Compile time options required
|
|
||||||
for various operating systems are described in the
|
|
||||||
source file.
|
|
||||||
.SH BUGS
|
|
||||||
Pathnames are restricted to 127 characters.
|
|
||||||
In XMODEM single file mode, the pathname given on the command line
|
|
||||||
is still processed as described above.
|
|
||||||
The CR/LF to NL translation merely deletes CR\'s;
|
|
||||||
undos(omen) performs a more intelligent translation.
|
|
||||||
.SH "VMS VERSION"
|
|
||||||
Some of the #includes with file names enclosed with angle brackets <>
|
|
||||||
may need to have the angle brackets changed to "", or vice versa.
|
|
||||||
|
|
||||||
The VMS version does not set binary mode according to the incoming
|
|
||||||
file type.
|
|
||||||
Non binary file processing consists of stripping all characters beginning
|
|
||||||
with CPMEOF (^Z).
|
|
||||||
|
|
||||||
The VMS version does not set the file time.
|
|
||||||
|
|
||||||
At high speeds,
|
|
||||||
VMS sometimes loses incoming characters, resulting in retries
|
|
||||||
and degradation of throughput.
|
|
||||||
|
|
||||||
The mysterious
|
|
||||||
VMS C Standard I/O Package and RMS may interact to modify
|
|
||||||
file contents unexpectedly.
|
|
||||||
|
|
||||||
The VMS version does not support invocation as
|
|
||||||
.B rzCOMMAND .
|
|
||||||
ZMODEM has not yet been implemented on the VMS version.
|
|
||||||
.SH "ZMODEM CAPABILITIES"
|
|
||||||
.B Rz
|
|
||||||
supports incoming ZMODEM binary (-b), ASCII (-a), and append (-+)
|
|
||||||
requests, and ZMODEM command execution.
|
|
||||||
.SH FILES
|
|
||||||
rz.c, rbsb.c, zm.c, zmodem.h source files.
|
|
||||||
|
|
||||||
/tmp/rzlog stores debugging output generated with -vv option.
|
|
File diff suppressed because it is too large
Load Diff
@ -1,77 +0,0 @@
|
|||||||
#ifndef __RZ_H__
|
|
||||||
#define __RZ_H__
|
|
||||||
|
|
||||||
#include "zmodem.h"
|
|
||||||
|
|
||||||
|
|
||||||
unsigned short int updcrc(int c, unsigned int crc);
|
|
||||||
void zmputs(char *s);
|
|
||||||
int closeit(void);
|
|
||||||
int sys2(char *s);
|
|
||||||
int exec2(char *s);
|
|
||||||
int rzfile(void);
|
|
||||||
void ackbibi(void);
|
|
||||||
unsigned int IsAnyLower(char *s);
|
|
||||||
void usage(void);
|
|
||||||
static int wcrx(void);
|
|
||||||
char *substr(char *s, char *t);
|
|
||||||
|
|
||||||
void alrm(void);
|
|
||||||
void bibi(int n);
|
|
||||||
int zreceive_main(void);
|
|
||||||
void usage(void);
|
|
||||||
static int wcreceive(unsigned int argc, char **argp);
|
|
||||||
static int wcrxpn(char *rpn);
|
|
||||||
static int wcgetsec(char *rxbuf, int maxtime);
|
|
||||||
int readline(int timeout);
|
|
||||||
unsigned short int updcrc(int c, unsigned int crc);
|
|
||||||
int procheader(char *name);
|
|
||||||
int purgeline(void);
|
|
||||||
int putsec(char *buf, int n);
|
|
||||||
int readline(int timeout);
|
|
||||||
unsigned short int updcrc(int c, unsigned int crc);
|
|
||||||
|
|
||||||
int bttyout(int c);
|
|
||||||
int sys2(char *s);
|
|
||||||
int exec2(char *s);
|
|
||||||
void sendline(char c);
|
|
||||||
void xsendline(char c);
|
|
||||||
void canit(void);
|
|
||||||
int tryz(void);
|
|
||||||
int rzfiles(void);
|
|
||||||
|
|
||||||
|
|
||||||
extern int Verbose;
|
|
||||||
extern int iofd; /* File descriptor for ioctls & reads */
|
|
||||||
extern int Zmodem; /* ZMODEM protocol requested */
|
|
||||||
extern int Nozmodem; /* If invoked as "rb" */
|
|
||||||
/* Ward Christensen / CP/M parameters - Don't change these! */
|
|
||||||
#define ENQ 005
|
|
||||||
#define CAN ('X'&037)
|
|
||||||
//#define XOFF ('s'&037)
|
|
||||||
//#define XON ('q'&037)
|
|
||||||
#define SOH 1
|
|
||||||
#define STX 2
|
|
||||||
#define EOT 4
|
|
||||||
#define ACK 6
|
|
||||||
#define NAK 025
|
|
||||||
#define CPMEOF 032
|
|
||||||
#define WANTCRC 0103 /* send C not NAK to get crc not checksum */
|
|
||||||
#define TIMEOUT (-2)
|
|
||||||
#define ERRORMAX 5
|
|
||||||
#define RETRYMAX 5
|
|
||||||
#define WCEOT (-10)
|
|
||||||
#define SECSIZ 128 /* cp/m's Magic Number record size */
|
|
||||||
#define PATHLEN 257 /* ready for 4.2 bsd ? */
|
|
||||||
#define KSIZE 1024 /* record size with k option */
|
|
||||||
#define UNIXFILE 0x8000 /* happens to the the S_IFREG file mask bit for stat */
|
|
||||||
/**************************zm.c **************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,336 +0,0 @@
|
|||||||
'\" Revision Level
|
|
||||||
'\" Last Delta 5-19-86
|
|
||||||
.TH SZ 1 OMEN
|
|
||||||
.SH NAME
|
|
||||||
sz \- XMODEM, YMODEM, ZMODEM Batch file Send
|
|
||||||
.SH SYNOPSIS
|
|
||||||
sz
|
|
||||||
.RB [\- +1adfknqTuvy ]
|
|
||||||
.I file ...
|
|
||||||
.br
|
|
||||||
sz -X
|
|
||||||
.RB [\- 1kquv ]
|
|
||||||
.I file
|
|
||||||
.br
|
|
||||||
sz
|
|
||||||
.RB [\- 1qv ]
|
|
||||||
.B "-c COMMAND"
|
|
||||||
.br
|
|
||||||
sz
|
|
||||||
.RB [\- 1qv ]
|
|
||||||
.B "-i COMMAND"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B Sz
|
|
||||||
uses the ZMODEM, YMODEM or XMODEM error correcting protocol to send
|
|
||||||
one or more files over a serial port to a variety of programs running under
|
|
||||||
PC-DOS, CP/M, Unix, VMS, and other operating systems.
|
|
||||||
|
|
||||||
|
|
||||||
The first form of
|
|
||||||
.B sz
|
|
||||||
sends one or more files with ZMODEM or YMODEM batch protocol.
|
|
||||||
Normally, only the file name part of the pathname is transmitted.
|
|
||||||
On
|
|
||||||
.SM Unix
|
|
||||||
systems, additional information about the file is transmitted.
|
|
||||||
If the receiving program uses this information,
|
|
||||||
the transmitted file length controls the exact number of bytes written to
|
|
||||||
the output dataset,
|
|
||||||
and the modify time and file mode
|
|
||||||
are set accordingly.
|
|
||||||
|
|
||||||
Output from another program may be piped to
|
|
||||||
.B sz
|
|
||||||
for transmission by specifying the
|
|
||||||
.B -1
|
|
||||||
option and denoting standard input by "-":
|
|
||||||
.ce
|
|
||||||
ps -ef | sz -
|
|
||||||
The program output is transmitted with the filename sPID.sz
|
|
||||||
where PID is the process ID of the
|
|
||||||
.B sz
|
|
||||||
program.
|
|
||||||
If the environment variable
|
|
||||||
.B ONAME
|
|
||||||
is set, that is used instead.
|
|
||||||
In this case, the Unix command:
|
|
||||||
.ce
|
|
||||||
ONAME=con ps -ef|sz -ay -
|
|
||||||
will send a "file" to the PC-DOS console display.
|
|
||||||
The
|
|
||||||
.B -y
|
|
||||||
bypasses the receiver\'s checking of the output filename.
|
|
||||||
The
|
|
||||||
.B -a
|
|
||||||
causes the receiver to convert Unix newlines to PC-DOS carriage returns
|
|
||||||
and linefeeds.
|
|
||||||
|
|
||||||
Unix
|
|
||||||
.B sz
|
|
||||||
supports
|
|
||||||
.B YMODEM-g
|
|
||||||
with "cbreak" tty mode, XON/XOFF flow control,
|
|
||||||
and the interrupt character set to CAN.
|
|
||||||
.B YMODEM-g
|
|
||||||
(Professional-YAM
|
|
||||||
.B g
|
|
||||||
option)
|
|
||||||
increases throughput over error free channels
|
|
||||||
(direct connection, X.PC, etc.)
|
|
||||||
by not acknowledging each transmitted sector.
|
|
||||||
|
|
||||||
|
|
||||||
The second form of
|
|
||||||
.B sz
|
|
||||||
uses the
|
|
||||||
.B -X
|
|
||||||
flag to send a single
|
|
||||||
.I file
|
|
||||||
with
|
|
||||||
.B XMODEM
|
|
||||||
protocol.
|
|
||||||
The user must supply the file name to both sending and receiving programs.
|
|
||||||
|
|
||||||
Iff
|
|
||||||
.B sz
|
|
||||||
is invoked with $SHELL set and iff that variable contains the
|
|
||||||
string
|
|
||||||
.I "rsh"
|
|
||||||
or
|
|
||||||
.I "rksh"
|
|
||||||
(restricted shell), sz operates in restricted mode.
|
|
||||||
Restricted mode restricts pathnames to the current directory and
|
|
||||||
PUBDIR (usually /usr/spool/uucppublic) and/or subdirectories
|
|
||||||
thereof.
|
|
||||||
|
|
||||||
|
|
||||||
The third form sends a single COMMAND to the receiver for execution.
|
|
||||||
.B Sz
|
|
||||||
exits with the COMMAND return value.
|
|
||||||
If COMMAND includes spaces or characters special to the shell,
|
|
||||||
it must be quoted.
|
|
||||||
|
|
||||||
The fourth form sends a single COMMAND to the receiver for execution.
|
|
||||||
.B Sz
|
|
||||||
exits as soon as the receiver has received the command, before it is executed.
|
|
||||||
|
|
||||||
|
|
||||||
If sz is invoked with stdout and stderr to different datasets,
|
|
||||||
Verbose is set to 2, causing frame by frame progress reports
|
|
||||||
to stderr.
|
|
||||||
This may be disabled with the
|
|
||||||
.B q
|
|
||||||
option.
|
|
||||||
.PP
|
|
||||||
The meanings of the available options are:
|
|
||||||
.PP
|
|
||||||
.PD 0
|
|
||||||
.TP
|
|
||||||
.B +
|
|
||||||
Force the receiver to append transmitted data to an existing file
|
|
||||||
(ZMODEM only).
|
|
||||||
.TP
|
|
||||||
.B 1
|
|
||||||
Use file descriptor 1 for ioctls and reads (Unix only).
|
|
||||||
By default, file descriptor 0 is used.
|
|
||||||
This option allows
|
|
||||||
.B sz
|
|
||||||
to be used with the
|
|
||||||
.I cu
|
|
||||||
~$
|
|
||||||
command.
|
|
||||||
.TP
|
|
||||||
.B a
|
|
||||||
Convert NL characters in the transmitted file to CR/LF.
|
|
||||||
This is done by the sender for XMODEM and YMODEM, by the receiver
|
|
||||||
for ZMODEM.
|
|
||||||
.TP
|
|
||||||
.B "c COMMAND"
|
|
||||||
Send COMMAND to the receiver for execution, return with COMMAND\'s exit status.
|
|
||||||
.TP
|
|
||||||
.B "C N"
|
|
||||||
Make N attempts at ten second intervals
|
|
||||||
to read COMMAND\'s exit status before exiting.
|
|
||||||
.TP
|
|
||||||
.B d
|
|
||||||
Change all instances of "." to "/" in the transmitted pathname.
|
|
||||||
Thus, C.omenB0000 (which is unacceptable to MSDOS or CP/M)
|
|
||||||
is transmitted as C/omenB0000.
|
|
||||||
If the resultant filename has more than 8 characters in the stem,
|
|
||||||
a "." in inserted to allow a total of eleven.
|
|
||||||
.TP
|
|
||||||
.B f
|
|
||||||
Send Full pathname.
|
|
||||||
Normally directory prefixes are stripped from the transmitted
|
|
||||||
filename.
|
|
||||||
.TP
|
|
||||||
.B "i COMMAND"
|
|
||||||
Send COMMAND to the receiver for execution, return Immediately.
|
|
||||||
.TP
|
|
||||||
.B k
|
|
||||||
Send files using YMODEM 1024 byte blocks
|
|
||||||
rather than the default 128 byte blocks.
|
|
||||||
1024 byte packets speed file transfers at high bit rates.
|
|
||||||
(ZMODEM streams the data for the best possible throughput.)
|
|
||||||
.TP
|
|
||||||
.B n
|
|
||||||
Instruct ZMODEM receiver to skip files if the length and modification times
|
|
||||||
of the source file and the file on the destination system are equal.
|
|
||||||
.TP
|
|
||||||
.B N
|
|
||||||
Instruct ZMODEM receiver to skip files if the length and CRC\'s
|
|
||||||
of the source file and the file on the destination system are equal.
|
|
||||||
.TP
|
|
||||||
.B q
|
|
||||||
Quiet suppresses verbosity.
|
|
||||||
.TP
|
|
||||||
.B r
|
|
||||||
Resume interrupted file transfer.
|
|
||||||
If the source file is longer than the destination file,
|
|
||||||
the transfer commences at the offset in the source file that equals
|
|
||||||
the length of the destination file.
|
|
||||||
.TP
|
|
||||||
.B u
|
|
||||||
Unlink the file after successful transmission.
|
|
||||||
.TP
|
|
||||||
.B v
|
|
||||||
Verbose
|
|
||||||
causes a list of file
|
|
||||||
names to be appended to
|
|
||||||
/tmp/szlog .
|
|
||||||
More v's generate more output.
|
|
||||||
.TP
|
|
||||||
.B X
|
|
||||||
Send a single file with
|
|
||||||
.B XMODEM
|
|
||||||
protocol.
|
|
||||||
.TP
|
|
||||||
.B y
|
|
||||||
Force a ZMODEM receiving program to overwrite any existing file
|
|
||||||
with the same name.
|
|
||||||
.PD
|
|
||||||
.SH EXAMPLES
|
|
||||||
.ne 7
|
|
||||||
.B "ZMODEM File Transfer"
|
|
||||||
.br
|
|
||||||
.B "$ sz -a *.c"
|
|
||||||
.br
|
|
||||||
This single command transfers all .c files in the current Unix directory
|
|
||||||
with conversion
|
|
||||||
.RB ( -a )
|
|
||||||
to PC-DOS end of line conventions.
|
|
||||||
With ZMODEM AutoDownload enabled, Professional-YAM automatically recieves
|
|
||||||
the files after performing a security challenge.
|
|
||||||
|
|
||||||
.B "ZMODEM Command Download"
|
|
||||||
.br
|
|
||||||
cpszall:all
|
|
||||||
sz -c "c:;cd /yam/dist"
|
|
||||||
sz -ya $(YD)/*.me
|
|
||||||
sz -yqb y*.exe
|
|
||||||
sz -c "cd /yam"
|
|
||||||
sz -i "!insms"
|
|
||||||
.br
|
|
||||||
This Makefile fragment uses
|
|
||||||
.B sz
|
|
||||||
to issue commands to Professional-YAM to change current disk and directory.
|
|
||||||
Next,
|
|
||||||
.B sz
|
|
||||||
transfers the
|
|
||||||
.I .me
|
|
||||||
files from the $YD directory, commanding the receiver to overwrite the old files
|
|
||||||
and to convert from Unix end of line conventions to PC-DOS conventions.
|
|
||||||
The third line transfers some
|
|
||||||
.I .exe
|
|
||||||
files.
|
|
||||||
The fourth and fifth lines command Pro-YAM to
|
|
||||||
change directory and execute a PC-DOS batch file
|
|
||||||
.I insms .
|
|
||||||
Since the batch file takes considerable time, the
|
|
||||||
.B "-i"
|
|
||||||
form is used to allow
|
|
||||||
.B sz
|
|
||||||
to exit immediately.
|
|
||||||
|
|
||||||
.B "XMODEM File Transfer"
|
|
||||||
.br
|
|
||||||
$
|
|
||||||
.B "sz -Xa foo.c"
|
|
||||||
.br
|
|
||||||
.B "ESC"
|
|
||||||
.br
|
|
||||||
.B "rx foo.c"
|
|
||||||
.br
|
|
||||||
The above three commands transfer a single file
|
|
||||||
from Unix to a PC and Crosstalk XVI 3.6,
|
|
||||||
translating Unix newlines to DOS CR/LF.
|
|
||||||
|
|
||||||
.SH SEE ALSO
|
|
||||||
rz(omen),
|
|
||||||
ZMODEM.DOC,
|
|
||||||
YMODEM.DOC,
|
|
||||||
Professional-YAM manual,
|
|
||||||
IMP(CP/M),
|
|
||||||
cu(1),
|
|
||||||
sq(omen),
|
|
||||||
todos(omen),
|
|
||||||
tocpm(omen),
|
|
||||||
tomac(omen),
|
|
||||||
yam(omen)
|
|
||||||
|
|
||||||
Compile time options required for various operating systems are described in
|
|
||||||
the source file.
|
|
||||||
.SH "VMS VERSION"
|
|
||||||
The VMS version does not transmit the file date.
|
|
||||||
The VMS version calculates the file length by reading the file
|
|
||||||
and counting the bytes.
|
|
||||||
|
|
||||||
The VMS version does not support YMODEM-g or ZMODEM.
|
|
||||||
|
|
||||||
When VMS is lightly loaded, the response time may be too quick for MODEM7
|
|
||||||
unless the MODEM7
|
|
||||||
.B "q"
|
|
||||||
modifier is used.
|
|
||||||
|
|
||||||
The VMS C standard i/o package and RMS sometimes interact to modify
|
|
||||||
file contents unexpectedly.
|
|
||||||
.SH FILES
|
|
||||||
sz.c, rbsb.c, zm.c, zmodem.h source files
|
|
||||||
|
|
||||||
/tmp/szlog stores debugging output (sz -vv)
|
|
||||||
.SH "TESTING FEATURE"
|
|
||||||
The command "sz -T file"
|
|
||||||
exercises the
|
|
||||||
.B Attn
|
|
||||||
sequence error recovery by commanding
|
|
||||||
errors with unterminated packets.
|
|
||||||
The receiving program should complain five times about
|
|
||||||
binary data packets being too long.
|
|
||||||
Each time
|
|
||||||
.B sz
|
|
||||||
is interrupted,
|
|
||||||
it should send a ZDATA header followed by another defective packet.
|
|
||||||
If the receiver does not detect five long data packets,
|
|
||||||
the
|
|
||||||
.B Attn
|
|
||||||
sequence is not interrupting the sender, and the
|
|
||||||
.B Myattn
|
|
||||||
string in
|
|
||||||
.B sz.c
|
|
||||||
must be modified.
|
|
||||||
|
|
||||||
After 5 packets,
|
|
||||||
.B sz
|
|
||||||
stops the "transfer" and
|
|
||||||
prints the total number of characters "sent" (Tcount).
|
|
||||||
The difference between Tcount and 5120 represents the number of characters
|
|
||||||
stored in various buffers when the Attn sequence is generated.
|
|
||||||
.SH BUGS
|
|
||||||
XMODEM transfers add up to 127 spurious bytes per file.
|
|
||||||
|
|
||||||
Circular buffering and a ZMODEM sliding window should be used
|
|
||||||
when input is from pipes instead of acknowledging frames each 1024 bytes.
|
|
||||||
.B Sz
|
|
||||||
should check for the presence of at least one accessible file before
|
|
||||||
getting hot and bothered.
|
|
||||||
The test mode leaves a zero length file on the receiving system.
|
|
File diff suppressed because it is too large
Load Diff
@ -1,480 +0,0 @@
|
|||||||
/*
|
|
||||||
* Z M . C
|
|
||||||
* ZMODEM protocol primitives
|
|
||||||
* 5-18-86 Chuck Forsberg Omen Technology Inc
|
|
||||||
*
|
|
||||||
* Entry point Functions:
|
|
||||||
* zsbhdr(type, hdr) send binary header
|
|
||||||
* zshhdr(type, hdr) send hex header
|
|
||||||
* zgethdr(hdr, eflag) receive header - binary or hex
|
|
||||||
* zsbdata(buf, len, frameend) send binary data
|
|
||||||
* zrbdata(buf, len) receive binary data
|
|
||||||
* stohdr(pos) store position data in Txhdr
|
|
||||||
* long rclhdr(hdr) recover position offset from header
|
|
||||||
*/
|
|
||||||
|
|
||||||
//#ifndef CANFDX
|
|
||||||
#include "zmodem.h"
|
|
||||||
int Rxtimeout = 100; /* Tenths of seconds to wait for something */
|
|
||||||
//#endif
|
|
||||||
#define ERROR (-1)
|
|
||||||
static char *frametypes[] = {
|
|
||||||
"TIMEOUT",
|
|
||||||
"ERROR",
|
|
||||||
"ZRQINIT",
|
|
||||||
"ZRINIT",
|
|
||||||
"ZSINIT",
|
|
||||||
"ZACK",
|
|
||||||
"ZFILE",
|
|
||||||
"ZSKIP",
|
|
||||||
"ZNAK",
|
|
||||||
"ZABORT",
|
|
||||||
"ZFIN",
|
|
||||||
"ZRPOS",
|
|
||||||
"ZDATA",
|
|
||||||
"ZEOF",
|
|
||||||
"ZFERR",
|
|
||||||
"ZCRC",
|
|
||||||
"ZCHALLENGE",
|
|
||||||
"ZCOMPL",
|
|
||||||
"ZCAN",
|
|
||||||
"ZFREECNT",
|
|
||||||
"ZCOMMAND",
|
|
||||||
"ZCACK"
|
|
||||||
#define FRTYPES 21 /* Total number of frame types in this array */
|
|
||||||
};
|
|
||||||
|
|
||||||
long int rclhdr(char *hdr);
|
|
||||||
int zputhex(int c);
|
|
||||||
int zsendline(int c);
|
|
||||||
int zgethex(void);
|
|
||||||
int zgeth1(void);
|
|
||||||
int zrbhdr(char *hdr);
|
|
||||||
int zrhhdr(char *hdr);
|
|
||||||
int zdlread(void);
|
|
||||||
int noxread7(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* Send ZMODEM binary header hdr of type type */
|
|
||||||
int zsbhdr(int type, char *hdr)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
unsigned short oldcrc;
|
|
||||||
|
|
||||||
vfile("zsbhdr: %s %lx", frametypes[type+2], rclhdr(hdr));
|
|
||||||
xsendline(ZPAD); xsendline(ZDLE); xsendline(ZBIN);
|
|
||||||
|
|
||||||
zsendline(type); oldcrc = updcrc(type, 0);
|
|
||||||
|
|
||||||
for (n=4; --n >= 0;) {
|
|
||||||
zsendline(*hdr);
|
|
||||||
oldcrc = updcrc(*hdr++, oldcrc);
|
|
||||||
}
|
|
||||||
oldcrc = updcrc(0,updcrc(0,oldcrc));
|
|
||||||
zsendline(oldcrc>>8);
|
|
||||||
zsendline(oldcrc);
|
|
||||||
if (type != ZDATA)
|
|
||||||
flushmo();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send ZMODEM HEX header hdr of type type */
|
|
||||||
int zshhdr(int type, char *hdr)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
unsigned short oldcrc;
|
|
||||||
|
|
||||||
vfile("zshhdr: %s %lx", frametypes[type+2], rclhdr(hdr));
|
|
||||||
|
|
||||||
sendline(ZPAD); sendline(ZPAD); sendline(ZDLE); sendline(ZHEX);
|
|
||||||
zputhex(type);
|
|
||||||
|
|
||||||
oldcrc = updcrc(type, 0);
|
|
||||||
for (n=4; --n >= 0;) {
|
|
||||||
zputhex(*hdr); oldcrc = updcrc(*hdr++, oldcrc);
|
|
||||||
}
|
|
||||||
oldcrc = updcrc(0,updcrc(0,oldcrc));
|
|
||||||
zputhex(oldcrc>>8); zputhex(oldcrc);
|
|
||||||
|
|
||||||
/* Make it printable on remote machine */
|
|
||||||
sendline(015); sendline(0212); /*012*/
|
|
||||||
/*
|
|
||||||
* Uncork the remote in case a fake XOFF has stopped data flow
|
|
||||||
*/
|
|
||||||
if (type != ZFIN)
|
|
||||||
sendline(021);
|
|
||||||
flushmo();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Send binary array buf of length length, with ending ZDLE sequence frameend
|
|
||||||
*/
|
|
||||||
int zsbdata(char *buf, int length, int frameend)
|
|
||||||
{
|
|
||||||
register unsigned short oldcrc;
|
|
||||||
|
|
||||||
vfile("zsbdata: length=%d end=%x", length, frameend);
|
|
||||||
oldcrc = 0;
|
|
||||||
for (;--length >= 0;) {
|
|
||||||
zsendline(*buf);
|
|
||||||
oldcrc = updcrc(*buf++, oldcrc);
|
|
||||||
}
|
|
||||||
xsendline(ZDLE); xsendline(frameend);
|
|
||||||
oldcrc = updcrc(frameend, oldcrc);
|
|
||||||
|
|
||||||
oldcrc = updcrc(0,updcrc(0,oldcrc));
|
|
||||||
zsendline(oldcrc>>8);
|
|
||||||
zsendline(oldcrc);
|
|
||||||
if (frameend == ZCRCW)
|
|
||||||
flushmo();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Receive binary array buf of max length with ending ZDLE sequence
|
|
||||||
* and CRC. Returns the ending character or error code.
|
|
||||||
*/
|
|
||||||
int zrbdata(char *buf, int length)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
unsigned short oldcrc;
|
|
||||||
int d;
|
|
||||||
|
|
||||||
oldcrc = Rxcount = 0;
|
|
||||||
for (;;) {
|
|
||||||
if ((c = zdlread()) & ~0377) {
|
|
||||||
switch (c) {
|
|
||||||
case GOTCRCE:
|
|
||||||
case GOTCRCG:
|
|
||||||
case GOTCRCQ:
|
|
||||||
case GOTCRCW:
|
|
||||||
oldcrc = updcrc((d=c)&0377, oldcrc);
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
goto badcrc;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
goto badcrc;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if (oldcrc & 0xFFFF) {
|
|
||||||
badcrc:
|
|
||||||
zperr("Bad data packet CRC");
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
vfile("zrbdata: Rxcount = %d ret = %x",
|
|
||||||
Rxcount, d);
|
|
||||||
return d;
|
|
||||||
case GOTCAN:
|
|
||||||
zperr("ZMODEM: Sender Canceled");
|
|
||||||
return ZCAN;
|
|
||||||
case TIMEOUT:
|
|
||||||
zperr("ZMODEM data packet TIMEOUT");
|
|
||||||
return c;
|
|
||||||
default:
|
|
||||||
zperr("ZMODEM bad data packet ret=%x", c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (--length < 0) {
|
|
||||||
zperr("ZMODEM binary data packet too long");
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
++Rxcount;
|
|
||||||
*buf++ = c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read a ZMODEM header to hdr, either binary or hex.
|
|
||||||
* eflag controls local display of non zmodem characters:
|
|
||||||
* 0: no display
|
|
||||||
* 1: display printing characters only
|
|
||||||
* 2: display all non ZMODEM characters
|
|
||||||
* On success, set Zmodem to 1 and return type of header.
|
|
||||||
* Otherwise return negative on error
|
|
||||||
*/
|
|
||||||
int zgethdr(char *hdr, int eflag)
|
|
||||||
{
|
|
||||||
int c, n;
|
|
||||||
|
|
||||||
n = Baudrate; /* Max characters before start of frame */
|
|
||||||
again:
|
|
||||||
Rxframeind = Rxtype = 0;
|
|
||||||
switch (c = noxread7()) {
|
|
||||||
case TIMEOUT:
|
|
||||||
goto fifi;
|
|
||||||
case ZDLE:
|
|
||||||
if (noxread7() == ZDLE) {
|
|
||||||
c = ZCAN; goto fifi;
|
|
||||||
}
|
|
||||||
/* **** FALL THRU TO **** */
|
|
||||||
default:
|
|
||||||
if ( --n == 0) {
|
|
||||||
zperr("ZMODEM Garbage count exceeded");
|
|
||||||
return(ERROR);
|
|
||||||
}
|
|
||||||
if (eflag && ((c &= 0177) & 0140))
|
|
||||||
bttyout(c);
|
|
||||||
else if (eflag > 1)
|
|
||||||
bttyout(c);
|
|
||||||
goto again;
|
|
||||||
case ZPAD:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
splat:
|
|
||||||
switch (c = noxread7()) {
|
|
||||||
case ZPAD:
|
|
||||||
goto splat;
|
|
||||||
case TIMEOUT:
|
|
||||||
goto fifi;
|
|
||||||
default:
|
|
||||||
goto again;
|
|
||||||
case ZDLE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (c = noxread7()) {
|
|
||||||
case TIMEOUT:
|
|
||||||
goto fifi;
|
|
||||||
case ZBIN:
|
|
||||||
Rxframeind = ZBIN;
|
|
||||||
c = zrbhdr(hdr);
|
|
||||||
break;
|
|
||||||
case ZHEX:
|
|
||||||
Rxframeind = ZHEX;
|
|
||||||
c = zrhhdr(hdr);
|
|
||||||
break;
|
|
||||||
case ZDLE:
|
|
||||||
if (noxread7() == ZDLE) {
|
|
||||||
c = ZCAN; goto fifi;
|
|
||||||
}
|
|
||||||
/* **** FALL THRU TO **** */
|
|
||||||
default:
|
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
Rxpos = hdr[ZP3] & 0377;
|
|
||||||
Rxpos = (Rxpos<<8) + (hdr[ZP2] & 0377);
|
|
||||||
Rxpos = (Rxpos<<8) + (hdr[ZP1] & 0377);
|
|
||||||
Rxpos = (Rxpos<<8) + (hdr[ZP0] & 0377);
|
|
||||||
fifi:
|
|
||||||
switch (c) {
|
|
||||||
case GOTCAN:
|
|
||||||
c = ZCAN;
|
|
||||||
/* **** FALL THRU TO **** */
|
|
||||||
case ZNAK:
|
|
||||||
case ZCAN:
|
|
||||||
case ERROR:
|
|
||||||
case TIMEOUT:
|
|
||||||
zperr("ZMODEM: Got %s header", frametypes[c+2]);
|
|
||||||
default:
|
|
||||||
if (c >= -2 && c <= FRTYPES)
|
|
||||||
vfile("zgethdr: %s %lx", frametypes[c+2], Rxpos);
|
|
||||||
else
|
|
||||||
vfile("zgethdr: %d %lx", c, Rxpos);
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Receive a binary style header (type and position) */
|
|
||||||
int zrbhdr(char *hdr)
|
|
||||||
{
|
|
||||||
int c, n;
|
|
||||||
unsigned short oldcrc;
|
|
||||||
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
return c;
|
|
||||||
Rxtype = c;
|
|
||||||
oldcrc = updcrc(c, 0);
|
|
||||||
|
|
||||||
for (n=4; --n >= 0;) {
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
*hdr++ = c;
|
|
||||||
}
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if ((c = zdlread()) & ~0377)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if (oldcrc & 0xFFFF) {
|
|
||||||
zperr("Bad Header CRC"); return ERROR;
|
|
||||||
}
|
|
||||||
Zmodem = 1;
|
|
||||||
return Rxtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Receive a hex style header (type and position) */
|
|
||||||
int zrhhdr(char *hdr)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
unsigned short oldcrc;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
if ((c = zgethex()) < 0)
|
|
||||||
return c;
|
|
||||||
Rxtype = c;
|
|
||||||
oldcrc = updcrc(c, 0);
|
|
||||||
|
|
||||||
for (n=4; --n >= 0;) {
|
|
||||||
if ((c = zgethex()) < 0)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
*hdr++ = c;
|
|
||||||
}
|
|
||||||
if ((c = zgethex()) < 0)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if ((c = zgethex()) < 0)
|
|
||||||
return c;
|
|
||||||
oldcrc = updcrc(c, oldcrc);
|
|
||||||
if (oldcrc & 0xFFFF) {
|
|
||||||
zperr("Bad Header CRC"); return ERROR;
|
|
||||||
}
|
|
||||||
if (readline(1) == '\r') /* Throw away possible cr/lf */
|
|
||||||
readline(1);
|
|
||||||
Zmodem = 1; return Rxtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send a byte as two hex digits */
|
|
||||||
int zputhex(int c)
|
|
||||||
{
|
|
||||||
static char digits[] = "0123456789abcdef";
|
|
||||||
|
|
||||||
if (Verbose>4)
|
|
||||||
vfile("zputhex: %x", c);
|
|
||||||
sendline(digits[(c&0xF0)>>4]);
|
|
||||||
sendline(digits[(c)&0xF]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send character c with ZMODEM escape sequence encoding */
|
|
||||||
int zsendline(int c)
|
|
||||||
{
|
|
||||||
switch (c & 0377) {
|
|
||||||
case ZDLE:
|
|
||||||
case 021:
|
|
||||||
case 023:
|
|
||||||
case 0221:
|
|
||||||
case 0223:
|
|
||||||
xsendline(ZDLE);
|
|
||||||
c ^= 0100;
|
|
||||||
/* **** FALL THRU TO **** */
|
|
||||||
default:
|
|
||||||
xsendline(c);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Decode two lower case hex digits into an 8 bit byte value */
|
|
||||||
int zgethex(void)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
c = zgeth1();
|
|
||||||
if (Verbose>4)
|
|
||||||
vfile("zgethex: %x", c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
int zgeth1(void)
|
|
||||||
{
|
|
||||||
int c, n;
|
|
||||||
|
|
||||||
if ((c = noxread7()) < 0)
|
|
||||||
return c;
|
|
||||||
n = c - '0';
|
|
||||||
if (n > 9)
|
|
||||||
n -= ('a' - ':');
|
|
||||||
if (n & ~0xF)
|
|
||||||
return ERROR;
|
|
||||||
if ((c = noxread7()) < 0)
|
|
||||||
return c;
|
|
||||||
c -= '0';
|
|
||||||
if (c > 9)
|
|
||||||
c -= ('a' - ':');
|
|
||||||
if (c & ~0xF)
|
|
||||||
return ERROR;
|
|
||||||
c += (n<<4);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read a byte, checking for ZMODEM escape encoding
|
|
||||||
* including CAN-CAN which represents a quick abort
|
|
||||||
*/
|
|
||||||
int zdlread(void)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if ((c = readline(Rxtimeout)) != ZDLE)
|
|
||||||
return c;
|
|
||||||
if ((c = readline(Rxtimeout)) < 0)
|
|
||||||
return c;
|
|
||||||
switch (c) {
|
|
||||||
case ZDLE:
|
|
||||||
return GOTCAN;
|
|
||||||
case ZCRCE:
|
|
||||||
case ZCRCG:
|
|
||||||
case ZCRCQ:
|
|
||||||
case ZCRCW:
|
|
||||||
return (c | GOTOR);
|
|
||||||
case ZRUB0:
|
|
||||||
return 0177;
|
|
||||||
case ZRUB1:
|
|
||||||
return 0377;
|
|
||||||
default:
|
|
||||||
if ((c & 0140) == 0100)
|
|
||||||
return (c ^ 0100);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
zperr("Got bad ZMODEM escape sequence %x", c);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read a character from the modem line with timeout.
|
|
||||||
* Eat parity, XON and XOFF characters.
|
|
||||||
*/
|
|
||||||
int noxread7(void)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if ((c = readline(Rxtimeout)) < 0)
|
|
||||||
return c;
|
|
||||||
switch (c &= 0177) {
|
|
||||||
case XON:
|
|
||||||
case XOFF:
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Store long integer pos in Txhdr */
|
|
||||||
int stohdr(long int pos)
|
|
||||||
{
|
|
||||||
Txhdr[ZP0] = pos;
|
|
||||||
Txhdr[ZP1] = pos>>8;
|
|
||||||
Txhdr[ZP2] = pos>>16;
|
|
||||||
Txhdr[ZP3] = pos>>24;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Recover a long integer from a header */
|
|
||||||
long
|
|
||||||
int rclhdr(char *hdr)
|
|
||||||
{
|
|
||||||
long int l;
|
|
||||||
|
|
||||||
l = (hdr[ZP3] & 0377);
|
|
||||||
l = (l << 8) | (hdr[ZP2] & 0377);
|
|
||||||
l = (l << 8) | (hdr[ZP1] & 0377);
|
|
||||||
l = (l << 8) | (hdr[ZP0] & 0377);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* Z M O D E M . H Manifest constants for ZMODEM
|
|
||||||
* application to application file transfer protocol
|
|
||||||
* 5-16-86 Chuck Forsberg Omen Technology Inc
|
|
||||||
*/
|
|
||||||
#define ZPAD '*' /* 052 Padding character begins frames */
|
|
||||||
#define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
|
|
||||||
#define ZDLEE (ZDLE^0100) /* Escaped ZDLE as transmitted */
|
|
||||||
#define ZBIN 'A' /* Binary frame indicator */
|
|
||||||
#define ZHEX 'B' /* HEX frame indicator */
|
|
||||||
|
|
||||||
/* Frame types (see array "frametypes" in zm.c) */
|
|
||||||
#define ZRQINIT 0 /* Request receive init */
|
|
||||||
#define ZRINIT 1 /* Receive init */
|
|
||||||
#define ZSINIT 2 /* Send init sequence (optional) */
|
|
||||||
#define ZACK 3 /* ACK to above */
|
|
||||||
#define ZFILE 4 /* File name from sender */
|
|
||||||
#define ZSKIP 5 /* To sender: skip this file */
|
|
||||||
#define ZNAK 6 /* Last packet was garbled */
|
|
||||||
#define ZABORT 7 /* Abort batch transfers */
|
|
||||||
#define ZFIN 8 /* Finish session */
|
|
||||||
#define ZRPOS 9 /* Resume data trans at this position */
|
|
||||||
#define ZDATA 10 /* Data packet(s) follow */
|
|
||||||
#define ZEOF 11 /* End of file */
|
|
||||||
#define ZFERR 12 /* Fatal Read or Write error Detected */
|
|
||||||
#define ZCRC 13 /* Request for file CRC and response */
|
|
||||||
#define ZCHALLENGE 14 /* Receiver's Challenge */
|
|
||||||
#define ZCOMPL 15 /* Request is complete */
|
|
||||||
#define ZCAN 16 /* Other end canned session with CAN-CAN */
|
|
||||||
#define ZFREECNT 17 /* Request for free bytes on filesystem */
|
|
||||||
#define ZCOMMAND 18 /* Command from sending program */
|
|
||||||
|
|
||||||
/* ZDLE sequences */
|
|
||||||
#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */
|
|
||||||
#define ZCRCG 'i' /* CRC next, frame continues nonstop */
|
|
||||||
#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */
|
|
||||||
#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */
|
|
||||||
#define ZRUB0 'l' /* Translate to rubout 0177 */
|
|
||||||
#define ZRUB1 'm' /* Translate to rubout 0377 */
|
|
||||||
|
|
||||||
/* zdlread return values (internal) */
|
|
||||||
/* -1 is general error, -2 is timeout */
|
|
||||||
#define GOTOR 0400
|
|
||||||
#define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */
|
|
||||||
#define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */
|
|
||||||
#define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */
|
|
||||||
#define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */
|
|
||||||
#define GOTCAN (GOTOR|030) /* CAN-CAN seen */
|
|
||||||
|
|
||||||
/* Byte positions within header array */
|
|
||||||
#define ZF0 3 /* First flags byte */
|
|
||||||
#define ZF1 2
|
|
||||||
#define ZF2 1
|
|
||||||
#define ZF3 0
|
|
||||||
#define ZP0 0 /* Low order 8 bits of position */
|
|
||||||
#define ZP1 1
|
|
||||||
#define ZP2 2
|
|
||||||
#define ZP3 3 /* High order 8 bits of file position */
|
|
||||||
|
|
||||||
/* Bit Masks for ZRINIT flags byte ZF0 */
|
|
||||||
#define CANFDX 01 /* Rx can send and receive true FDX */
|
|
||||||
#define CANOVIO 02 /* Rx can receive data during disk I/O */
|
|
||||||
#define CANBRK 04 /* Rx can send a break signal */
|
|
||||||
#define CANCRY 010 /* Receiver can decrypt */
|
|
||||||
#define CANLZW 020 /* Receiver can uncompress */
|
|
||||||
|
|
||||||
/* Parameters for ZSINIT frame */
|
|
||||||
#define ZATTNLEN 32 /* Max length of attention string */
|
|
||||||
|
|
||||||
/* Parameters for ZFILE frame */
|
|
||||||
/* Conversion options one of these in ZF0 */
|
|
||||||
#define ZCBIN 1 /* Binary transfer - inhibit conversion */
|
|
||||||
#define ZCNL 2 /* Convert NL to local end of line convention */
|
|
||||||
#define ZCRESUM 3 /* Resume interrupted file transfer */
|
|
||||||
/* Management options, one of these in ZF1 */
|
|
||||||
#define ZMNEW 1 /* Transfer if source newer or different length */
|
|
||||||
#define ZMCRC 2 /* Transfer if different file CRC or length */
|
|
||||||
#define ZMAPND 3 /* Append contents to existing file (if any) */
|
|
||||||
#define ZMCLOB 4 /* Replace existing file */
|
|
||||||
#define ZMSPARS 5 /* Encoding for sparse file */
|
|
||||||
/* Transport options, one of these in ZF2 */
|
|
||||||
#define ZTLZW 1 /* Lempel-Ziv compression */
|
|
||||||
#define ZTCRYPT 2 /* Encryption */
|
|
||||||
#define ZTRLE 3 /* Run Length encoding */
|
|
||||||
|
|
||||||
/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
|
|
||||||
#define ZCACK1 1 /* Acknowledge, then do command */
|
|
||||||
|
|
||||||
long int rclhdr(char *hdr);
|
|
||||||
|
|
||||||
/* Globals used by ZMODEM functions */
|
|
||||||
int Rxframeind; /* ZBIN or ZHEX indicates type of frame received */
|
|
||||||
int Rxtype; /* Type of header received */
|
|
||||||
int Rxcount; /* Count of data bytes received */
|
|
||||||
extern int Rxtimeout; /* Tenths of seconds to wait for something */
|
|
||||||
char Rxhdr[4]; /* Received header */
|
|
||||||
char Txhdr[4]; /* Transmitted header */
|
|
||||||
long Rxpos; /* Received file position */
|
|
||||||
long Txpos; /* Transmitted file position */
|
|
||||||
char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
|
|
||||||
|
|
||||||
extern rt_device_t _console_device;
|
|
||||||
extern struct finsh_shell* shell;
|
|
||||||
#define zwrite(x1) rt_device_write(_console_device, 0, &x1, 1)
|
|
||||||
#define zread(x1,x2,x3,x4) rt_device_read (x1,x2,x3,x4)
|
|
||||||
|
|
||||||
extern void vfile(const char *fmt,...);
|
|
Loading…
x
Reference in New Issue
Block a user