1 /* zmodem.h - ZMODEM protocol constants
2 
3   Copyright (C) until 1998 Chuck Forsberg (OMEN Technology Inc)
4   Copyright (C) 1996, 1997 Uwe Ohse
5 
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10 
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15 
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 
21  *    05-23-87  Chuck Forsberg Omen Technology Inc
22 */
23 #define ZPAD '*'	/* 052 Padding character begins frames */
24 #define ZDLE 030	/* Ctrl-X Zmodem escape - `ala BISYNC DLE */
25 #define ZDLEE (ZDLE^0100)	/* Escaped ZDLE as transmitted */
26 #define ZBIN 'A'	/* Binary frame indicator */
27 #define ZHEX 'B'	/* HEX frame indicator */
28 #define ZBIN32 'C'	/* Binary frame with 32 bit FCS */
29 
30 /* Frame types (see array "frametypes" in zm.c) */
31 #define ZRQINIT	0	/* Request receive init */
32 #define ZRINIT	1	/* Receive init */
33 #define ZSINIT 2	/* Send init sequence (optional) */
34 #define ZACK 3		/* ACK to above */
35 #define ZFILE 4		/* File name from sender */
36 #define ZSKIP 5		/* To sender: skip this file */
37 #define ZNAK 6		/* Last packet was garbled */
38 #define ZABORT 7	/* Abort batch transfers */
39 #define ZFIN 8		/* Finish session */
40 #define ZRPOS 9		/* Resume data trans at this position */
41 #define ZDATA 10	/* Data packet(s) follow */
42 #define ZEOF 11		/* End of file */
43 #define ZFERR 12	/* Fatal Read or Write error Detected */
44 #define ZCRC 13		/* Request for file CRC and response */
45 #define ZCHALLENGE 14	/* Receiver's Challenge */
46 #define ZCOMPL 15	/* Request is complete */
47 #define ZCAN 16		/* Other end canned session with CAN*5 */
48 #define ZFREECNT 17	/* Request for free bytes on filesystem */
49 #define ZCOMMAND 18	/* Command from sending program */
50 #define ZSTDERR 19	/* Output to standard error, data follows */
51 
52 /* ZDLE sequences */
53 #define ZCRCE 'h'	/* CRC next, frame ends, header packet follows */
54 #define ZCRCG 'i'	/* CRC next, frame continues nonstop */
55 #define ZCRCQ 'j'	/* CRC next, frame continues, ZACK expected */
56 #define ZCRCW 'k'	/* CRC next, ZACK expected, end of frame */
57 #define ZRUB0 'l'	/* Translate to rubout 0177 */
58 #define ZRUB1 'm'	/* Translate to rubout 0377 */
59 
60 /* zdlread return values (internal) */
61 /* -1 is general error, -2 is timeout */
62 #define GOTOR 0400
63 #define GOTCRCE (ZCRCE|GOTOR)	/* ZDLE-ZCRCE received */
64 #define GOTCRCG (ZCRCG|GOTOR)	/* ZDLE-ZCRCG received */
65 #define GOTCRCQ (ZCRCQ|GOTOR)	/* ZDLE-ZCRCQ received */
66 #define GOTCRCW (ZCRCW|GOTOR)	/* ZDLE-ZCRCW received */
67 #define GOTCAN	(GOTOR|030)	/* CAN*5 seen */
68 
69 /* Byte positions within header array */
70 #define ZF0	3	/* First flags byte */
71 #define ZF1	2
72 #define ZF2	1
73 #define ZF3	0
74 #define ZP0	0	/* Low order 8 bits of position */
75 #define ZP1	1
76 #define ZP2	2
77 #define ZP3	3	/* High order 8 bits of file position */
78 
79 /* Bit Masks for ZRINIT flags byte ZF0 */
80 #define CANFDX	0x01	/* Rx can send and receive true FDX */
81 #define CANOVIO	0x02	/* Rx can receive data during disk I/O */
82 #define CANBRK	0x04	/* Rx can send a break signal */
83 #define CANCRY	0x08	/* Receiver can decrypt */
84 #define CANLZW	0x10	/* Receiver can uncompress */
85 #define CANFC32	0x20	/* Receiver can use 32 bit Frame Check */
86 #define ESCCTL  0x40	/* Receiver expects ctl chars to be escaped */
87 #define ESC8    0x80	/* Receiver expects 8th bit to be escaped */
88 /* Bit Masks for ZRINIT flags byze ZF1 */
89 #define ZF1_CANVHDR  0x01  /* Variable headers OK, unused in lrzsz */
90 #define ZF1_TIMESYNC 0x02 /* nonstandard, Receiver request timesync */
91 
92 /* Parameters for ZSINIT frame */
93 #define ZATTNLEN 32	/* Max length of attention string */
94 /* Bit Masks for ZSINIT flags byte ZF0 */
95 #define TESCCTL 0100	/* Transmitter expects ctl chars to be escaped */
96 #define TESC8   0200	/* Transmitter expects 8th bit to be escaped */
97 
98 /* Parameters for ZFILE frame */
99 /* Conversion options one of these in ZF0 */
100 #define ZCBIN	1	/* Binary transfer - inhibit conversion */
101 #define ZCNL	2	/* Convert NL to local end of line convention */
102 #define ZCRESUM	3	/* Resume interrupted file transfer */
103 /* Management include options, one of these ored in ZF1 */
104 #define ZF1_ZMSKNOLOC   0x80 /* Skip file if not present at rx */
105 /* Management options, one of these ored in ZF1 */
106 #define ZF1_ZMMASK	    0x1f /* Mask for the choices below */
107 #define ZF1_ZMNEWL         1 /* Transfer if source newer or longer */
108 #define ZF1_ZMCRC          2 /* Transfer if different file CRC or length */
109 #define ZF1_ZMAPND         3 /* Append contents to existing file (if any) */
110 #define ZF1_ZMCLOB         4 /* Replace existing file */
111 #define ZF1_ZMNEW          5 /* Transfer if source newer */
112 	/* Number 5 is alive ... */
113 #define ZF1_ZMDIFF         6 /* Transfer if dates or lengths different */
114 #define ZF1_ZMPROT         7 /* Protect destination file */
115 #define ZF1_ZMCHNG         8 /* Change filename if destination exists */
116 
117 /* Transport options, one of these in ZF2 */
118 #define ZTLZW	1	/* Lempel-Ziv compression */
119 #define ZTCRYPT	2	/* Encryption */
120 #define ZTRLE	3	/* Run Length encoding */
121 /* Extended options for ZF3, bit encoded */
122 #define ZXSPARS	64	/* Encoding for sparse file operations */
123 
124 /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
125 #define ZCACK1	1	/* Acknowledge, then do command */
126 
127 /* Globals used by ZMODEM functions */
128 #if 0
129 extern int Rxframeind;	/* ZBIN ZBIN32, or ZHEX type of frame received */
130 extern int Rxtype;		/* Type of header received */
131 extern int Zrwindow;	/* RX window size (controls garbage count) */
132 extern char Rxhdr[4];	/* Received header */
133 extern char Txhdr[4];	/* Transmitted header */
134 extern long Txpos;	/* Transmitted file position */
135 extern int Txfcs32;		/* TURE means send binary frames with 32 bit FCS */
136 extern int Crc32t;		/* Display flag indicating 32 bit CRC being sent */
137 extern int Crc32;		/* Display flag indicating 32 bit CRC being received */
138 extern int Znulls;		/* Number of nulls to send at beginning of ZDATA hdr */
139 extern char Attn[ZATTNLEN+1];	/* Attention string rx sends to tx on err */
140 #endif
141 
142 /* End of ZMODEM.H */
143