?? zmodem.h
字號:
/*--------------------------------------------------------------------------*/
/* FILE: zreceive.c (Opus zmodem receiver) */
/* */
/* */
/* The Opus Computer-Based Conversation System */
/* (c) Copyright 1986, Wynn Wagner III, All Rights Reserved */
/* */
/* This implementation of Chuck Forsberg's ZMODEM protocol was */
/* for Opus by Rick Huebner and Wynn Wagner III */
/* */
/* */
/* */
/* This module is similar to a header used by Opus-Cbcs (1.00). It is */
/* provided for your information only. You will find undefined items. */
/* */
/* There is absolutely no guarantee that anything here will work. If you */
/* break this material, you own both pieces. */
/* */
/* USAGE: You may use this material in any program with no obligation */
/* as long as there is no charge for your program. For more */
/* information about commercial use, contact the "OPUSinfo HERE" */
/* BBS (124/111). */
/* */
/* NOTE: There are a couple of things the Opus implementation does that */
/* aren't part of the original ZModem protocol. They all deal */
/* with WaZOO type ("ZedZap") netmail and should only show up when */
/* used under that condition. */
/* */
/* * The maximum packet size can grow larger than 1k. It is */
/* sensitive to the baud rate. (2400b=2048k; 9600b=8192k) */
/* * The sender must be able to send nothing. In other words, */
/* the sending system must be able to initiate and terminate */
/* a zmodem send session without having to actually send a */
/* file. Normally this kind of thing would never happen in */
/* zmodem. */
/* */
/* */
/*--------------------------------------------------------------------------*/
/* */
/* More than the three folks listed above were involved with this. Vince */
/* Perriello, for example, probably did some tweaking here and there. As */
/* to Who-Wrote-What, it's kinda hard to say at this point. Chuck Fors- */
/* berg did the hard part. He thought up the whole thing and wrote the */
/* original code (on which this is based). Rick took Chuck's code and */
/* scrubbed the Unix out of its nap. I took Rick's code and got as much */
/* of the "C" stinch out as I could. <ah-hem> Said another way... Chuck */
/* made it; Rick made it MsDOS; and I made it fast. So, if you have any */
/* kind of problem with this source code, your best best is to just figure */
/* it out yourself because everybody involved in writing the code can */
/* safely/legitimately disavow any knowledge of the particular section */
/* causing the trouble. */
/* --- Wynn Wagner III */
/* */
/*--------------------------------------------------------------------------*/
/* */
/* Naming convention: Z_??? a routine from ZModem.C */
/* _Z_??? a private routine in ZModem.C */
/* ZS_??? a routine in ZSend.C */
/* ZR_??? a routine in ZReceive.C */
/* */
/*--------------------------------------------------------------------------*/
#include <sys\types.h>
#include <sys\stat.h>
/*--------------------------------------------------------------------------*/
/* Routines from N_Zmodem.H ... */
/*--------------------------------------------------------------------------*/
byte * pascal zalloc();
void pascal z_message(byte *);
int pascal Z_GetByte(int);
void pascal Z_PutString(unsigned char *);
void pascal Z_SendHexHeader(unsigned short,unsigned char *);
int pascal Z_GetHeader(unsigned char *);
int pascal Z_GetZDL(void);
void pascal Z_PutLongIntoHeader(long);
unsigned short pascal Z_UpdateCRC(unsigned short,unsigned short);
#define ZPAD '*' /* 052 Pad character begins frames */
#define ZDLE 030 /* ^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 */
#define ZBIN32 'C' /* Binary frame with 32 bit FCS */
/*--------------------------------------------------------------------------*/
/* 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 transmit at this position */
#define ZDATA 10 /* Data packet(s) follow */
#define ZEOF 11 /* End of file */
#define ZFERR 12 /* Fatal Read/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 with CAN*5 */
#define ZFREECNT 17 /* Request for free bytes on disk */
#define ZCOMMAND 18 /* Command from sending program */
#define ZSTDERR 19 /* Send following to stderr */
/*--------------------------------------------------------------------------*/
/* ZDLE sequences */
/*--------------------------------------------------------------------------*/
#define ZCRCE 'h' /* CRC next/frame ends/hdr follows */
#define ZCRCG 'i' /* CRC next/frame continues nonstop */
#define ZCRCQ 'j' /* CRC next/frame continues/want ZACK*/
#define ZCRCW 'k' /* CRC next/ZACK expected/end of frame*/
#define ZRUB0 'l' /* Translate to rubout 0177 */
#define ZRUB1 'm' /* Translate to rubout 0377 */
/*--------------------------------------------------------------------------*/
/* Z_GetZDL return values (internal) */
/* -1 is general error, -2 is timeout */
/*--------------------------------------------------------------------------*/
#define GOTOR 0400 /* Octal alert! Octal alert! */
#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 */
/*--------------------------------------------------------------------------*/
/* 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 pos */
/*--------------------------------------------------------------------------*/
/* Bit Masks for ZRINIT flags byte ZF0 */
/*--------------------------------------------------------------------------*/
#define CANFDX 01 /* Can send and receive true FDX */
#define CANOVIO 02 /* Can receive data during disk I/O */
#define CANBRK 04 /* Can send a break signal */
#define CANCRY 010 /* Can decrypt */
#define CANLZW 020 /* Can uncompress */
#define CANFC32 040 /* Can use 32 bit Frame Check */
/*--------------------------------------------------------------------------*/
/* PARAMETERS FOR ZFILE FRAME... */
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* Conversion options one of these in ZF0 */
/*--------------------------------------------------------------------------*/
#define ZCBIN 1 /* Binary transfer - no conversion */
#define ZCNL 2 /* Convert NL to local EOLN */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -