Update first part of zmodem sources

This commit is contained in:
Michiel Broek 2004-11-07 13:35:34 +00:00
parent cb2d964597
commit 706d0fcfe7
3 changed files with 208 additions and 230 deletions

View File

@ -62,6 +62,7 @@ static int zgethex(void);
static int zgeth1(void);
static void garbitch(void);
#include "../config.h"
#include "../lib/mbselib.h"
#include "../lib/nodelist.h"
@ -196,17 +197,15 @@ void zsbhdr(int len, int type, register char *shdr)
BUFFER_BYTE(ZPAD); BUFFER_BYTE(ZDLE);
switch (Crc32t=Txfcs32) {
case 2:
zsbh32(len, shdr, type, Usevhdrs?ZVBINR32:ZBINR32);
BUFFER_FLUSH(); break;
case 1:
zsbh32(len, shdr, type, Usevhdrs?ZVBIN32:ZBIN32); break;
default:
if (Usevhdrs) {
case 2: zsbh32(len, shdr, type, Usevhdrs?ZVBINR32:ZBINR32);
BUFFER_FLUSH();
break;
case 1: zsbh32(len, shdr, type, Usevhdrs?ZVBIN32:ZBIN32);
break;
default: if (Usevhdrs) {
BUFFER_BYTE(ZVBIN);
zsendline(len);
}
else
} else
BUFFER_BYTE(ZBIN);
zsendline(type);
crc = updcrc16(type, 0);
@ -270,8 +269,7 @@ void zshhdr(int len, int type, register char *shdr)
if (Usevhdrs) {
BUFFER_BYTE(ZVHEX);
zputhex(len);
}
else
} else
BUFFER_BYTE(ZHEX);
zputhex(type);
Crc32t = 0;
@ -313,16 +311,16 @@ void zsdata(register char *buf, int length, int frameend)
BUFFER_CLEAR();
switch (Crc32t) {
case 1:
zsda32(buf, length, frameend); break;
case 2:
zsdar32(buf, length, frameend); break;
default:
crc = 0;
case 1: zsda32(buf, length, frameend);
break;
case 2: zsdar32(buf, length, frameend);
break;
default: crc = 0;
for (;--length >= 0; ++buf) {
zsendline(*buf); crc = updcrc16((0377 & *buf), crc);
}
BUFFER_BYTE(ZDLE); BUFFER_BYTE(frameend);
BUFFER_BYTE(ZDLE);
BUFFER_BYTE(frameend);
crc = updcrc16(frameend, crc);
crc = updcrc16(0,updcrc16(0,crc));

View File

@ -6,23 +6,14 @@
void get_frame_buffer(void);
void free_frame_buffer(void);
void zsbhdr(int, int, register char *);
void zsbh32(int, register char *, int, int);
void zshhdr(int, int, register char *);
void zsdata(register char *, int, int);
void zsda32(register char *, int, int);
int zrdata(register char *, int);
int zrdat32(register char *, int);
void garbitch(void);
int zgethdr(char *);
int zrbhdr(register char *);
int zrbhd32(register char *);
int zrhhdr(char *);
void zputhex(register int);
void zsendline(int);
int zgethex(void);
int zgeth1(void);
int zdlread(void);
int noxrd7(void);
void stohdr(long);
long rclhdr(register char *);

View File

@ -66,28 +66,24 @@ void zsdar32(char *buf, int length, int frameend)
++n; continue;
}
switch (n) {
case 0:
zsendline(l);
case 0: zsendline(l);
crc = updcrc32(l, crc);
if (l == ZRESC) {
zsendline(0100); crc = updcrc32(0100, crc);
}
l = c; break;
case 1:
if (l != ZRESC) {
case 1: if (l != ZRESC) {
zsendline(l); zsendline(l);
crc = updcrc32(l, crc);
crc = updcrc32(l, crc);
n = 0; l = c; break;
}
/* **** FALL THRU TO **** */
default:
zsendline(ZRESC); crc = updcrc32(ZRESC, crc);
default: zsendline(ZRESC); crc = updcrc32(ZRESC, crc);
if (l == 040 && n < 34) {
n += 036;
zsendline(n); crc = updcrc32(n, crc);
}
else {
} else {
n += 0101;
zsendline(n); crc = updcrc32(n, crc);
zsendline(l); crc = updcrc32(l, crc);
@ -125,8 +121,7 @@ crcfoo:
case GOTCRCE:
case GOTCRCG:
case GOTCRCQ:
case GOTCRCW:
d = c; c &= 0377;
case GOTCRCW: d = c; c &= 0377;
crc = updcrc32(c, crc);
if ((c = zdlread()) & ~0377)
goto crcfoo;
@ -146,30 +141,24 @@ crcfoo:
}
Rxcount = length - (end - buf);
Syslog('z', "zrdatr32: %d %s", Rxcount,
Zendnames[(d-GOTCRCE)&3]);
Syslog('z', "zrdatr32: %d %s", Rxcount, Zendnames[(d-GOTCRCE)&3]);
return d;
case GOTCAN:
Syslog('+', "Zmodem: Sender Canceled");
case GOTCAN: Syslog('+', "Zmodem: Sender Canceled");
return ZCAN;
case TIMEOUT:
Syslog('+', "Zmodem: TIMEOUT");
case TIMEOUT: Syslog('+', "Zmodem: TIMEOUT");
return c;
default:
Syslog('+', "Zmodem: Bad data subpacket");
default: Syslog('+', "Zmodem: Bad data subpacket");
return c;
}
}
crc = updcrc32(c, crc);
switch (d) {
case 0:
if (c == ZRESC) {
case 0: if (c == ZRESC) {
d = -1; continue;
}
*buf++ = c; continue;
case -1:
if (c >= 040 && c < 0100) {
case -1: if (c >= 040 && c < 0100) {
d = c - 035; c = 040; goto spaces;
}
if (c == 0100) {
@ -177,8 +166,7 @@ crcfoo:
*buf++ = ZRESC; continue;
}
d = c; continue;
default:
d -= 0100;
default: d -= 0100;
if (d < 1)
goto badpkt;
spaces:
@ -189,6 +177,7 @@ spaces:
d = 0; continue;
}
}
badpkt:
Syslog('+', "Zmodem: Data subpacket too long");
return TERROR;