⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rzsz.sh

📁 Linux下基于Z-MODEM的串口通讯程序源码
💻 SH
📖 第 1 页 / 共 5 页
字号:
X	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXeverest:X	cc -b elf -w 3 -O3 $(RFLAGS) -DUSG -DMD=2 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	cc -b elf -w 3 $(RFLAGS) -O3 -DUSG -DREADCHECK sz.c -lx -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXposix:X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX -DMD=2 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXPOSIX:X	@echo "Well, stricter, as in *safer sex* ..."X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX -DMD=2 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DPOSIX sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXXbsd:X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DMD=2 -Dstrchr=index -DV7 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DV7 -DNFGVMIN sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXtandy:X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAGS) -n -DUSG -DMD -DT6K sz.c -lx -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAGS) -n -DUSG -DMD -DT6K rz.c -lx -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcXdnix:X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DSV -DUSG -DNFGVMIN -DREADCHECK sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXdnix5r3:X	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DMD=2 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(RFLAGS) $(OFLAG) -DUSG -DSV -DNFGVMIN -DREADCHECK sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXXamiga:X	$(CC) $(CFLAGS) $(OFLAG) -DUSG -DNFGVMIN -g rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) $(CFLAGS) $(OFLAG) -DUSG -DSV -DNFGVMIN -g sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXaix:X	@echo "As of July 26 1996, ..."X	@echo "IBM sez if you have the very latest PTFs, 'make posix' will work."X	@echo ""Xnext:X	LIBS=-lposixX	$(CC) -g -posix $(OFLAG) -DPOSIX -DMD=2 rz.c -o rzX	size rzX	-rm -f rb rx rcX	ln rz rbX	ln rz rxX	ln rz rcX	$(CC) -g -posix $(OFLAG) -DPOSIX sz.c -o szX	size szX	-rm -f sb sx zcommand zcommandiX	ln sz sbX	ln sz sxX	ln sz zcommandX	ln sz zcommandiXundos:	undos.cX	cc -O $(RFLAGS)  undos.c -o undosX	-rm -f tounix todos unmac tomac tocpm unparityX	ln undos tounixX	ln undos todosX	ln undos unmacX	ln undos tomacX	ln undos tocpmX	ln undos unparityXXlint:X	lint -DUSG -DSV sz.c >/tmp/sz.fluffX	lint -DUSG -DSV rz.c >/tmp/rz.fluffXXsz: nothingsb: nothingrz: nothingrb: nothingSHAR_EOF  (set 20 02 07 19 08 54 22 'Makefile'; eval "$shar_touch") &&  chmod 0644 'Makefile' ||  $echo 'restore of' 'Makefile' 'failed'  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then    md5sum -c << SHAR_EOF >/dev/null 2>&1 \    || $echo 'Makefile:' 'MD5 check failed'fdd5fc6417d75596b6c8f401ed072318  MakefileSHAR_EOF  else    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`"    test 8650 -eq "$shar_count" ||    $echo 'Makefile:' 'original size' '8650,' 'current size' "$shar_count!"  fifi# ============= zmodem.h ==============if test -f 'zmodem.h' && test "$first_param" != -c; then  $echo 'x -' SKIPPING 'zmodem.h' '(file already exists)'else  $echo 'x -' extracting 'zmodem.h' '(text)'  sed 's/^X//' << 'SHAR_EOF' > 'zmodem.h' &&/*X *   Z M O D E M . H     Manifest constants for ZMODEMX *    application to application file transfer protocolX *    Copyright 1993 Omen Technology Inc All Rights ReservedX */#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 (CRC-16) */#define ZHEX 'B'	/* HEX frame indicator */#define ZBIN32 'C'	/* Binary frame with 32 bit FCS */#define ZBINR32 'D'	/* RLE packed Binary frame with 32 bit FCS */#define ZVBIN 'a'	/* Binary frame indicator (CRC-16) */#define ZVHEX 'b'	/* HEX frame indicator */#define ZVBIN32 'c'	/* Binary frame with 32 bit FCS */#define ZVBINR32 'd'	/* RLE packed Binary frame with 32 bit FCS */#define ZRESC	0176	/* RLE flag/escape character */#define ZMAXHLEN 16	/* Max header information length  NEVER CHANGE */#define ZMAXSPLEN 1024	/* Max subpacket length  NEVER CHANGE */X/* 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*5 */#define ZFREECNT 17	/* Request for free bytes on filesystem */#define ZCOMMAND 18	/* Command from sending program */X/* 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 */X/* 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*5 seen */X/* 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 */X/* Parameters for ZRINIT header */#define ZRPXWN	8	/* 9th byte in header contains window size/256 */#define ZRPXQQ	9	/* 10th to 14th bytes contain quote mask *//* 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 CANRLE	010	/* Receiver can decode RLE */#define CANLZW	020	/* Receiver can uncompress */#define CANFC32	040	/* Receiver can use 32 bit Frame Check */#define ESCCTL 0100	/* Receiver expects ctl chars to be escaped */#define ESC8   0200	/* Receiver expects 8th bit to be escaped */X/* Bit Masks for ZRINIT flags byte ZF1 */#define CANVHDR	01	/* Variable headers OK */#define ZRRQWN	8	/* Receiver specified window size in ZRPXWN */#define ZRRQQQ	16	/* Additional control chars to quote in ZRPXQQ	*/#define ZRQNVH	(ZRRQWN|ZRRQQQ)	/* Variable len hdr reqd to access info */X/* Parameters for ZSINIT frame */#define ZATTNLEN 32	/* Max length of attention string */#define ALTCOFF ZF1	/* Offset to alternate canit string, 0 if not used *//* Bit Masks for ZSINIT flags byte ZF0 */#define TESCCTL 0100	/* Transmitter expects ctl chars to be escaped */#define TESC8   0200	/* Transmitter expects 8th bit to be escaped */X/* 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 include options, one of these ored in ZF1 */#define ZMSKNOLOC	0200	/* Skip file if not present at rx *//* Management options, one of these ored in ZF1 */#define ZMMASK	037	/* Mask for the choices below */#define ZMNEWL	1	/* Transfer if source newer or longer */#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 ZMNEW	5	/* Transfer if source newer */X	/* Number 5 is alive ... */#define ZMDIFF	6	/* Transfer if dates or lengths different */#define ZMPROT	7	/* Protect destination file */#define ZMCHNG	8	/* Change filename if destination exists *//* Transport options, one of these in ZF2 */#define ZTLZW	1	/* Lempel-Ziv compression */#define ZTRLE	3	/* Run Length encoding *//* Extended options for ZF3, bit encoded */#define ZXSPARS	64	/* Encoding for sparse file operations */#define ZCANVHDR	01	/* Variable headers OK *//* Receiver window size override */#define ZRWOVR 4	/* byte position for receive window override/256 */X/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */#define ZCACK1	1	/* Acknowledge, then do command */Xlong rclhdr();X/* Globals used by ZMODEM functions */extern Rxframeind;	/* ZBIN ZBIN32, or ZHEX type of frame */extern Rxtype;		/* Type of header received */extern Rxcount;		/* Count of data bytes received */extern Rxtimeout;	/* Tenths of seconds to wait for something */extern long Rxpos;	/* Received file position */extern long Txpos;	/* Transmitted file position */extern Txfcs32;		/* TURE means send binary frames with 32 bit FCS */extern Crc32t;		/* Display flag indicating 32 bit CRC being sent */extern Crc32;		/* Display flag indicating 32 bit CRC being received */extern Znulls;		/* Number of nulls to send at beginning of ZDATA hdr */extern char Attn[ZATTNLEN+1];	/* Attention string rx sends to tx on err */extern char *Altcan;	/* Alternate canit string */X/* End of zmodem.h */SHAR_EOF  (set 20 02 12 08 16 15 43 'zmodem.h'; eval "$shar_touch") &&  chmod 0644 'zmodem.h' ||  $echo 'restore of' 'zmodem.h' 'failed'  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then    md5sum -c << SHAR_EOF >/dev/null 2>&1 \    || $echo 'zmodem.h:' 'MD5 check failed'5efc9d31a118e1acc644949f1b004267  zmodem.hSHAR_EOF  else    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'zmodem.h'`"    test 6513 -eq "$shar_count" ||    $echo 'zmodem.h:' 'original size' '6513,' 'current size' "$shar_count!"  fifi# ============= zm.c ==============if test -f 'zm.c' && test "$first_param" != -c; then  $echo 'x -' SKIPPING 'zm.c' '(file already exists)'else  $echo 'x -' extracting 'zm.c' '(text)'  sed 's/^X//' << 'SHAR_EOF' > 'zm.c' &&/*X *   Z M . CX *    Copyright 1994 Omen Technology Inc All Rights ReservedX *    ZMODEM protocol primitivesX *X * Entry point Functions:X *	zsbhdr(type, hdr) send binary headerX *	zshhdr(type, hdr) send hex headerX *	zgethdr(hdr) receive header - binary or hexX *	zsdata(buf, len, frameend) send dataX *	zrdata(buf, len) receive dataX *	stohdr(pos) store position data in TxhdrX *	long rclhdr(hdr) recover position offset from headerX * X *X *	This version implements numerous enhancements including ZMODEMX *	Run Length Encoding and variable length headers.  TheseX *	features were not funded by the original Telenet developmentX *	contract.X * X *  This software may be freely used for educational (didacticX *  only) purposes.  This software may also be freely used toX *  support file transfer operations to or from licensed OmenX *  Technology products.  Use with other commercial or sharewareX *  programs (Crosstalk, Procomm, etc.) REQUIRES REGISTRATION.X *X *  Any programs which use part or all of this software must beX *  provided in source form with this notice intact except byX *  written permission from Omen Technology Incorporated.X * X * Use of this software for commercial or administrative purposesX * except when exclusively limited to interfacing Omen TechnologyX * products requires a per port license payment of $20.00 US perX * port (less in quantity).  Use of this code by inclusion,X * decompilation, reverse engineering or any other meansX * constitutes agreement to these conditions and acceptance ofX * liability to license the materials and payment of reasonableX * legal costs necessary to enforce this license agreement.X *X *X *		Omen Technology IncX *		Post Office Box 4681X *		Portland OR 97208X *X *	This code is made available in the hope it will be useful,X *	BUT WITHOUT ANY WARRANTY OF ANY KIND OR LIABILITY FOR ANYX *	DAMAGES OF ANY KIND.X *X */X#ifndef CANFDX#include "zmodem.h"int Rxtimeout = 100;		/* Tenths of seconds to wait for something */#endifX/* Globals used by ZMODEM functions */int Rxframeind;		/* ZBIN ZBIN32, or ZHEX type of frame */int Rxtype;		/* Type of header received */int Rxhlen;		/* Length of header received */int Rxcount;		/* Count of data bytes received */char Rxhdr[ZMAXHLEN];	/* Received header */char Txhdr[ZMAXHLEN];	/* Transmitted header */long Rxpos;		/* Received file position */long Txpos;		/* Transmitted file position */int Txfcs32;		/* TURE means send binary frames with 32 bit FCS */int Crc32t;		/* Controls 32 bit CRC being sent */X			/* 1 == CRC32,  2 == CRC32 + RLE */int Crc32r;		/* Indicates/controls 32 bit CRC being received */X			/* 0 == CRC16,  1 == CRC32,  2 == CRC32 + RLE */int Usevhdrs;		/* Use variable length headers */int Znulls;		/* Number of nulls to send at beginning of ZDATA hdr */char Attn[ZATTNLEN+1];	/* Attention string rx sends to tx on err */char *Altcan;		/* Alternate canit string */Xstatic lastsent;	/* Last char we sent */Xstatic char *frametypes[] = {X	"No Response to Error Correction Request",	/* -4 */X	"No Carrier Detect",		/* -3 */X	"TIMEOUT",		/* -2 */X	"ERROR",		/* -1 */#define FTOFFSET 4X	"ZRQINIT",X	"ZRINIT",X	"ZSINIT",X	"ZACK",X	"ZFILE",X	"ZSKIP",X	"ZNAK",X	"ZABORT",X	"ZFIN",X	"ZRPOS",X	"ZDATA",X	"ZEOF",X	"ZFERR",X	"ZCRC",X	"ZCHALLENGE",X	"ZCOMPL",X	"ZCAN",X	"ZFREECNT",X	"ZCOMMAND",#define FRTYPES 22	/* Total number of frame types in this array */X			/*  not including psuedo negative entries */};Xstatic char badcrc[] = "Bad CRC";X/* Send ZMODEM binary header hdr of type type */zsbhdr(len, type, hdr)register char *hdr;{X	register int n;X	register unsigned short crc;X#ifndef DSZX	vfile("zsbhdr: %c %d %s %lx", Usevhdrs?'v':'f', len,X	  frametypes[type+FTOFFSET], rclhdr(hdr));#endifX	if (type == ZDATA)X		for (n = Znulls; --n >=0; )X			xsendline(0);XX	xsendline(ZPAD); xsendline(ZDLE);XX	switch (Crc32t=Txfcs32) {X	case 2:X		zsbh32(len, hdr, type, Usevhdrs?ZVBINR32:ZBINR32);X		flushmo();  break;X	case 1:X		zsbh32(len, hdr, type, Usevhdrs?ZVBIN32:ZBIN32);  break;X	default:X		if (Usevhdrs) {X			xsendline(ZVBIN);X			zsendline(len);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -