internal zmodem upload works

This commit is contained in:
Michiel Broek 2004-11-20 13:30:13 +00:00
parent 29a5f8f952
commit 9083842cbf
11 changed files with 319 additions and 229 deletions

View File

@ -35,7 +35,7 @@ v0.71.0 27-Oct-2004
from the users upload directory. from the users upload directory.
We don't reward upload time anymore, only bytes. It's more We don't reward upload time anymore, only bytes. It's more
troubles to implement right then it's worth these days. troubles to implement right then it's worth these days.
Added internal zmodem download protocol. Added internal zmodem download and upload protocol.
With user chat, the timeout timer wasn't refreshed. With user chat, the timeout timer wasn't refreshed.
mbnewusr: mbnewusr:

View File

@ -107,7 +107,7 @@ funcs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtex
mail.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h term.h ttyio.h openport.h mail.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h misc.h timeout.h oneline.h exitinfo.h lineedit.h fsedit.h filesub.h msgutil.h pop3.h email.h door.h whoson.h term.h ttyio.h openport.h
term.o: ../config.h ../lib/mbselib.h ../lib/users.h term.h ttyio.h term.o: ../config.h ../lib/mbselib.h ../lib/users.h term.h ttyio.h
ttyio.o: ../config.h ../lib/mbselib.h ttyio.h ttyio.o: ../config.h ../lib/mbselib.h ttyio.h
openport.o: ../config.h ../lib/mbselib.h ttyio.h openport.h openport.o: ../config.h ../lib/mbselib.h ttyio.h openport.h zmmisc.h
newuser.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h term.h ttyio.h openport.h newuser.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h newuser.h language.h timeout.h change.h dispfile.h term.h ttyio.h openport.h
pinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h pinfo.h input.h term.h ttyio.h pinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h pinfo.h input.h term.h ttyio.h
timecheck.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timecheck.h funcs.h bye.h exitinfo.h language.h input.h term.h ttyio.h timecheck.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timecheck.h funcs.h bye.h exitinfo.h language.h input.h term.h ttyio.h
@ -134,6 +134,6 @@ timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats
logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h
zmrle.o: ../config.h ../lib/mbselib.h ttyio.h zmrle.h zmmisc.h zmrle.o: ../config.h ../lib/mbselib.h ttyio.h zmrle.h zmmisc.h
zmmisc.o: ../config.h ../lib/mbselib.h ttyio.h zmrle.h zmmisc.h zmmisc.o: ../config.h ../lib/mbselib.h ttyio.h zmrle.h zmmisc.h
zmsend.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h zmrle.h transfer.h zmsend.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h zmrle.h transfer.h openport.h
zmrecv.o: ../config.h ../lib/mbselib.h ../lib/users.h ttyio.h transfer.h zmmisc.h zmrecv.h zmrecv.o: ../config.h ../lib/mbselib.h ../lib/users.h ttyio.h transfer.h zmmisc.h zmrecv.h openport.h
# End of generated dependencies # End of generated dependencies

View File

@ -328,7 +328,7 @@ void Download(void)
* Checking the successfull sent files, they are missing from * Checking the successfull sent files, they are missing from
* the ./tag directory. Failed files are still there. * the ./tag directory. Failed files are still there.
*/ */
Enter(1); PUTCHAR('\r');
/* Updating download counters, please wait ... */ /* Updating download counters, please wait ... */
pout(LIGHTCYAN, BLACK, (char *) Language(352)); pout(LIGHTCYAN, BLACK, (char *) Language(352));
Count = Size = 0; Count = Size = 0;

View File

@ -31,12 +31,77 @@
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "ttyio.h" #include "ttyio.h"
#include "openport.h" #include "openport.h"
#include "zmmisc.h"
int hanged_up = 0; int hanged_up = 0;
static int termios_saved = FALSE; /* Is termios saved */ static struct termios oldtty; /* Saved termios */
static struct termios savetios; /* Saved termios */ static struct termios tty;
static struct termios tios; unsigned Baudrate = 2400;
#define HOWMANY 255
static struct {
unsigned baudr;
speed_t speedcode;
} speeds[] = {
{110, B110},
{300, B300},
{600, B600},
{1200, B1200},
{2400, B2400},
{4800, B4800},
{9600, B9600},
#ifdef B12000
{12000, B12000},
#endif
#ifdef B14400
{14400, B14400},
#endif
#ifdef B19200
{19200, B19200},
#endif
#ifdef B38400
{38400, B38400},
#endif
#ifdef B57600
{57600, B57600},
#endif
#ifdef B115200
{115200, B115200},
#endif
#ifdef B230400
{230400, B230400},
#endif
#ifdef B460800
{460800, B460800},
#endif
#ifdef B500000
{500000, B500000},
#endif
#ifdef EXTA
{19200, EXTA},
#endif
#ifdef EXTB
{38400, EXTB},
#endif
{0, 0}
};
unsigned getspeed(speed_t);
unsigned getspeed(speed_t code)
{
int n;
for (n = 0; speeds[n].baudr; ++n)
if (speeds[n].speedcode == code)
return speeds[n].baudr;
return 38400; /* Assume fifo if ioctl failed */
}
@ -61,8 +126,8 @@ void hangup(void)
cflag = Tios.c_cflag | CLOCAL; cflag = Tios.c_cflag | CLOCAL;
ispeed = cfgetispeed(&tios); ispeed = cfgetispeed(&tty);
ospeed = cfgetospeed(&tios); ospeed = cfgetospeed(&tty);
cfsetispeed(&Tios,0); cfsetispeed(&Tios,0);
cfsetospeed(&Tios,0); cfsetospeed(&Tios,0);
if ((rc = tcsetattr(0,TCSADRAIN,&Tios))) if ((rc = tcsetattr(0,TCSADRAIN,&Tios)))
@ -85,59 +150,122 @@ void hangup(void)
/* /*
* Put the current opened tty in raw mode. * mode(n)
* 3: save old tty stat, set raw mode with flow control
* 2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
* 1: save old tty stat, set raw mode
* 0: restore original tty mode
*/ */
int io_mode(int fd, int n)
{
static int did0 = FALSE;
Syslog('t', "io_mode(%d, %d)", fd, n);
switch(n) {
case 2: /* Un-raw mode used by sz, sb when -g detected */
if(!did0) {
did0 = TRUE;
tcgetattr(fd,&oldtty);
}
tty = oldtty;
tty.c_iflag = BRKINT|IXON;
tty.c_oflag = 0; /* Transparent output */
tty.c_cflag &= ~PARENB; /* Disable parity */
tty.c_cflag |= CS8; /* Set character size = 8 */
// if (Twostop)
// tty.c_cflag |= CSTOPB; /* Set two stop bits */
#ifdef READCHECK
tty.c_lflag = protocol==ZM_ZMODEM ? 0 : ISIG;
tty.c_cc[VINTR] = protocol==ZM_ZMODEM ? -1 : 030; /* Interrupt char */
#else
tty.c_lflag = 0;
tty.c_cc[VINTR] = protocol==ZM_ZMODEM ? 03 : 030; /* Interrupt char */
#endif
#ifdef _POSIX_VDISABLE
if (((int) _POSIX_VDISABLE)!=(-1)) {
tty.c_cc[VQUIT] = _POSIX_VDISABLE; /* Quit char */
} else {
tty.c_cc[VQUIT] = -1; /* Quit char */
}
#else
tty.c_cc[VQUIT] = -1; /* Quit char */
#endif
#ifdef NFGVMIN
tty.c_cc[VMIN] = 1;
#else
tty.c_cc[VMIN] = 3; /* This many chars satisfies reads */
#endif
tty.c_cc[VTIME] = 1; /* or in this many tenths of seconds */
tcsetattr(fd,TCSADRAIN,&tty);
return 0;
case 1:
case 3:
if(!did0) {
did0 = TRUE;
tcgetattr(fd,&oldtty);
}
tty = oldtty;
tty.c_iflag = IGNBRK;
if (n==3) /* with flow control */
tty.c_iflag |= IXOFF;
/* Setup raw mode: no echo, noncanonical (no edit chars),
* no signal generating chars, and no extended chars (^V,
* ^O, ^R, ^W).
*/
tty.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
tty.c_oflag = 0; /* Transparent output */
tty.c_cflag &= ~(PARENB); /* Same baud rate, disable parity */
/* Set character size = 8 */
tty.c_cflag &= ~(CSIZE);
tty.c_cflag |= CS8;
// if (Twostop)
// tty.c_cflag |= CSTOPB; /* Set two stop bits */
#ifdef NFGVMIN
tty.c_cc[VMIN] = 1; /* This many chars satisfies reads */
#else
tty.c_cc[VMIN] = HOWMANY; /* This many chars satisfies reads */
#endif
tty.c_cc[VTIME] = 1; /* or in this many tenths of seconds */
tcsetattr(fd,TCSADRAIN,&tty);
Baudrate = getspeed(cfgetospeed(&tty));
Syslog('t', "Baudrate = %d", Baudrate);
return 0;
case 0:
if(!did0)
return ERROR;
tcdrain (fd); /* wait until everything is sent */
tcflush (fd,TCIOFLUSH); /* flush input queue */
tcsetattr (fd,TCSADRAIN,&oldtty);
tcflow (fd,TCOON); /* restart output */
return 0;
}
return -1;
}
int rawport(void) int rawport(void)
{ {
int rc = 0;
Syslog('t', "rawport()"); Syslog('t', "rawport()");
tty_status = 0; return io_mode(0, 1);
if (isatty(0)) {
if ((rc = tcgetattr(0,&savetios))) {
WriteError("$tcgetattr(0,save) return %d",rc);
return rc;
}
termios_saved = TRUE;
tios = savetios;
tios.c_iflag &= ~(INLCR | ICRNL | ISTRIP | IXON ); /* IUCLC removed for FreeBSD */
/*
* Map CRNL modes strip control characters and flow control
*/
tios.c_oflag &= ~OPOST; /* Don't do ouput character translation */
tios.c_lflag &= ~(ICANON | ECHO); /* No canonical input and no echo */
tios.c_cc[VMIN] = 1; /* Receive 1 character at a time */
tios.c_cc[VTIME] = 0; /* No time limit per character */
if ((rc = tcsetattr(0,TCSADRAIN,&tios)))
WriteError("$tcsetattr(0,TCSADRAIN,raw) return %d",rc);
} else {
Syslog('t', "not at a tty");
}
return rc;
} }
int cookedport(void) int cookedport(void)
{ {
int rc = 0;
Syslog('t', "cookedport()"); Syslog('t', "cookedport()");
return io_mode(0, 0);
if (termios_saved == FALSE) {
WriteError("Can't restore termios before it was saved");
return -1;
}
if (isatty(0)) {
if ((rc = tcsetattr(0,TCSAFLUSH,&savetios)))
WriteError("$tcsetattr(0,TCSAFLUSH,save) return %d", rc);
}
return rc;
} }

View File

@ -3,6 +3,7 @@
/* $Id$ */ /* $Id$ */
int io_mode(int, int);
void hangup(void); void hangup(void);
int rawport(void); int rawport(void);
int cookedport(void); int cookedport(void);

View File

@ -51,8 +51,8 @@
*/ */
static void zputhex(int); static void zputhex(int);
static void zsbh32(int,char*,int,int); static void zsbh32(char*, int);
static void zsda32(char*,int,int); static void zsda32(char*, int, int);
static int zrdat32(char*,int); static int zrdat32(char*,int);
static int noxrd7(void); static int noxrd7(void);
static int zrbhd32(char*); static int zrbhd32(char*);
@ -75,11 +75,13 @@ static void garbitch(void);
*/ */
static int Rxtimeout = 10; /* Seconds to wait for something */ static int Rxtimeout = 10; /* Seconds to wait for something */
int Rxhlen; /* Length of header received */ // int Rxhlen; /* Length of header received */
char *txbuf=NULL; char *txbuf=NULL;
static int lastsent; /* Last char we sent */ static int lastsent; /* Last char we sent */
static int Not8bit; /* Seven bits seen on header */ static int Not8bit; /* Seven bits seen on header */
extern unsigned Baudrate;
char *frametypes[] = { char *frametypes[] = {
(char *)"EMPTY", /* -16 */ (char *)"EMPTY", /* -16 */
@ -159,12 +161,12 @@ void free_frame_buffer(void)
/* /*
* Send ZMODEM binary header hdr of type type * Send ZMODEM binary header hdr of type type
*/ */
void zsbhdr(int len, int type, register char *shdr) void zsbhdr(int type, char *shdr)
{ {
register int n; register int n;
register unsigned short crc; register unsigned short crc;
Syslog('z', "zsbhdr: %c %d %s %lx", Usevhdrs?'v':'f', len, frametypes[type+FTOFFSET], rclhdr(shdr)); Syslog('z', "zsbhdr: %s %lx", frametypes[type+FTOFFSET], rclhdr(shdr));
BUFFER_CLEAR(); BUFFER_CLEAR();
@ -176,20 +178,16 @@ void zsbhdr(int len, int type, register char *shdr)
BUFFER_BYTE(ZDLE); BUFFER_BYTE(ZDLE);
switch (Crc32t=Txfcs32) { switch (Crc32t=Txfcs32) {
case 2: zsbh32(len, shdr, type, Usevhdrs?ZVBINR32:ZBINR32); case 2: zsbh32(shdr, type);
BUFFER_FLUSH(); BUFFER_FLUSH();
break; break;
case 1: zsbh32(len, shdr, type, Usevhdrs?ZVBIN32:ZBIN32); case 1: zsbh32(shdr, type);
break; break;
default: if (Usevhdrs) { default: BUFFER_BYTE(ZBIN);
BUFFER_BYTE(ZVBIN);
zsendline(len);
} else
BUFFER_BYTE(ZBIN);
zsendline(type); zsendline(type);
crc = updcrc16(type, 0); crc = updcrc16(type, 0);
for (n=len; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
zsendline(*shdr); zsendline(*shdr);
crc = updcrc16((0377& *shdr), crc); crc = updcrc16((0377& *shdr), crc);
} }
@ -206,19 +204,17 @@ void zsbhdr(int len, int type, register char *shdr)
/* /*
* Send ZMODEM binary header hdr of type type * Send ZMODEM binary header hdr of type type
*/ */
void zsbh32(int len, register char *shdr, int type, int flavour) void zsbh32(char *shdr, int type)
{ {
register int n; register int n;
register unsigned long crc; register unsigned long crc;
BUFFER_BYTE(flavour); BUFFER_BYTE(ZBIN32);
if (Usevhdrs)
zsendline(len);
zsendline(type); zsendline(type);
crc = 0xFFFFFFFFL; crc = 0xFFFFFFFFL;
crc = updcrc32(type, crc); crc = updcrc32(type, crc);
for (n=len; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
crc = updcrc32((0377 & *shdr), crc); crc = updcrc32((0377 & *shdr), crc);
zsendline(*shdr); zsendline(*shdr);
} }
@ -234,33 +230,30 @@ void zsbh32(int len, register char *shdr, int type, int flavour)
/* /*
* Send ZMODEM HEX header hdr of type type * Send ZMODEM HEX header hdr of type type
*/ */
void zshhdr(int len, int type, register char *shdr) void zshhdr(int type, register char *shdr)
{ {
register int n; register int n;
register unsigned short crc; register unsigned short crc;
Syslog('z', "zshhdr: %c %d %s %lx", Usevhdrs?'v':'f', len, frametypes[type+FTOFFSET], rclhdr(shdr)); Syslog('z', "zshhdr: %s %lx", frametypes[type+FTOFFSET], rclhdr(shdr));
BUFFER_CLEAR(); BUFFER_CLEAR();
BUFFER_BYTE(ZPAD); BUFFER_BYTE(ZPAD);
BUFFER_BYTE(ZPAD); BUFFER_BYTE(ZPAD);
BUFFER_BYTE(ZDLE); BUFFER_BYTE(ZDLE);
if (Usevhdrs) { BUFFER_BYTE(ZHEX);
BUFFER_BYTE(ZVHEX); zputhex(type & 0x7f);
zputhex(len);
} else
BUFFER_BYTE(ZHEX);
zputhex(type);
Crc32t = 0; Crc32t = 0;
crc = updcrc16(type, 0); crc = updcrc16((type & 0x7f), 0);
for (n=len; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
zputhex(*shdr); zputhex(*shdr);
crc = updcrc16((0377 & *shdr), crc); crc = updcrc16((0377 & *shdr), crc);
} }
crc = updcrc16(0,updcrc16(0,crc)); crc = updcrc16(0,updcrc16(0,crc));
zputhex(((int)(crc>>8))); zputhex(crc); zputhex(((int)(crc>>8)));
zputhex(crc);
/* /*
* Make it printable on remote machine * Make it printable on remote machine
@ -290,25 +283,24 @@ void zsdata(register char *buf, int length, int frameend)
Syslog('z', "zsdata: %d %s", length, Zendnames[(frameend-ZCRCE)&3]); Syslog('z', "zsdata: %d %s", length, Zendnames[(frameend-ZCRCE)&3]);
BUFFER_CLEAR(); BUFFER_CLEAR();
switch (Crc32t) { if (Crc32t)
case 1: zsda32(buf, length, frameend); zsda32(buf, length, frameend);
break; else {
case 2: zsdar32(buf, length, frameend); crc = 0;
break; for (;--length >= 0; ++buf) {
default: crc = 0; zsendline(*buf);
for (;--length >= 0; ++buf) { crc = updcrc16((0377 & *buf), crc);
zsendline(*buf); }
crc = updcrc16((0377 & *buf), crc); BUFFER_BYTE(ZDLE);
} BUFFER_BYTE(frameend);
BUFFER_BYTE(ZDLE); crc = updcrc16(frameend, crc);
BUFFER_BYTE(frameend);
crc = updcrc16(frameend, crc);
crc = updcrc16(0,updcrc16(0,crc)); crc = updcrc16(0,updcrc16(0,crc));
zsendline(((int)(crc>>8))); zsendline(((int)(crc>>8)));
zsendline(crc); zsendline(crc);
} }
if (frameend == ZCRCW) if (frameend == ZCRCW)
BUFFER_BYTE(XON); BUFFER_BYTE(XON);
@ -356,14 +348,10 @@ int zrdata(register char *buf, int length)
register char *end; register char *end;
register int d; register int d;
Syslog('z', "zrdata: len=%d, Crc32r=%d", length, Crc32r); Syslog('z', "zrdata: len=%d, Crc32r=%s", length, Crc32r ? "true":"false");
switch (Crc32r) { if (Crc32r)
case 1: return zrdat32(buf, length);
return zrdat32(buf, length);
case 2:
return zrdatr32(buf, length);
}
crc = Rxcount = 0; crc = Rxcount = 0;
end = buf + length; end = buf + length;
@ -487,11 +475,10 @@ int zgethdr(char *shdr)
{ {
register int c, n, cancount; register int c, n, cancount;
int Zrwindow = 1400; int Zrwindow = 1400;
int Baudrate = 9600;
n = Zrwindow + Baudrate; n = Zrwindow + Baudrate;
Rxframeind = Rxtype = 0; Rxframeind = Rxtype = 0;
Syslog('z', "zgethdr(%lx)", rclhdr(shdr)); // Syslog('z', "zgethdr(%lx)", rclhdr(shdr));
startover: startover:
cancount = 5; cancount = 5;
@ -503,7 +490,6 @@ again:
if (((c = GETCHAR(Rxtimeout)) < 0) && (c != TIMEOUT)) if (((c = GETCHAR(Rxtimeout)) < 0) && (c != TIMEOUT))
goto fifi; goto fifi;
else { else {
// Syslog('z', "Zmodem: Got %c %d", c, c);
switch(c) { switch(c) {
case 021: case 021:
case 0221: goto again; case 0221: goto again;
@ -538,13 +524,13 @@ agn2:
#define GCOUNT (-4) #define GCOUNT (-4)
if ( --n == 0) { if ( --n == 0) {
c = GCOUNT; c = GCOUNT;
Syslog('z', "zgethdr: garbage count exceeded");
goto fifi; goto fifi;
} }
goto startover; goto startover;
case ZPAD|0200: /* This is what we want. */ case ZPAD|0200: /* This is what we want. */
Not8bit = c; Not8bit = c;
case ZPAD: /* This is what we want. */ case ZPAD: /* This is what we want. */
// Syslog('z', "zgethdr: got ZPAD");
break; break;
} }
} }
@ -557,77 +543,33 @@ splat:
case TIMEOUT: goto fifi; case TIMEOUT: goto fifi;
default: goto agn2; default: goto agn2;
case ZDLE: /* This is what we want. */ case ZDLE: /* This is what we want. */
// Syslog('z', "zgethdr: got ZDLE");
break; break;
} }
Rxhlen = 4; /* Set default length */
Rxframeind = c = noxrd7(); Rxframeind = c = noxrd7();
Syslog('z', "zgethdr: header type %d", c);
switch (c) { switch (c) {
case ZVBIN32: if ((Rxhlen = c = zdlread()) < 0) case ZBIN32: Crc32r = 1;
goto fifi;
if (c > ZMAXHLEN)
goto agn2;
Crc32r = 1;
c = zrbhd32(shdr);
break;
case ZBIN32: if (Usevhdrs)
goto agn2;
Crc32r = 1;
c = zrbhd32(shdr);
break;
case ZVBINR32: if ((Rxhlen = c = zdlread()) < 0)
goto fifi;
if (c > ZMAXHLEN)
goto agn2;
Crc32r = 2;
c = zrbhd32(shdr);
break;
case ZBINR32: if (Usevhdrs)
goto agn2;
Crc32r = 2;
c = zrbhd32(shdr); c = zrbhd32(shdr);
break; break;
case HANGUP: case HANGUP:
case TIMEOUT: goto fifi; case TIMEOUT: goto fifi;
case ZVBIN: if ((Rxhlen = c = zdlread()) < 0) case ZBIN: Crc32r = 0;
goto fifi;
if (c > ZMAXHLEN)
goto agn2;
Crc32r = 0;
c = zrbhdr(shdr); c = zrbhdr(shdr);
break; break;
case ZBIN: if (Usevhdrs) case ZHEX: Crc32r = 0;
goto agn2;
Crc32r = 0;
c = zrbhdr(shdr);
break;
case ZVHEX: if ((Rxhlen = c = zgethex()) < 0)
goto fifi;
if (c > ZMAXHLEN)
goto agn2;
Crc32r = 0;
c = zrhhdr(shdr);
break;
case ZHEX: if (Usevhdrs)
goto agn2;
Crc32r = 0;
c = zrhhdr(shdr); c = zrhhdr(shdr);
break; break;
case CAN: goto gotcan; case CAN: goto gotcan;
default: goto agn2; default: goto agn2;
} }
for (n = Rxhlen; ++n < ZMAXHLEN; ) /* Clear unused hdr bytes */ for (n = 4; ++n < ZMAXHLEN; ) /* Clear unused hdr bytes */
shdr[n] = 0; shdr[n] = 0;
Rxpos = shdr[ZP3] & 0377; Rxpos = shdr[ZP3] & 0377;
Rxpos = (Rxpos<<8) + (shdr[ZP2] & 0377); Rxpos = (Rxpos<<8) + (shdr[ZP2] & 0377);
Rxpos = (Rxpos<<8) + (shdr[ZP1] & 0377); Rxpos = (Rxpos<<8) + (shdr[ZP1] & 0377);
Rxpos = (Rxpos<<8) + (shdr[ZP0] & 0377); Rxpos = (Rxpos<<8) + (shdr[ZP0] & 0377);
fifi: fifi:
Syslog('z', "Zmodem: at fifi Got %d", c);
switch (c) { switch (c) {
case GOTCAN: c = ZCAN; case GOTCAN: c = ZCAN;
/* **** FALL THRU TO **** */ /* **** FALL THRU TO **** */
@ -638,14 +580,13 @@ fifi:
case HANGUP: Syslog('+', "Zmodem: Got %s", frametypes[c+FTOFFSET]); case HANGUP: Syslog('+', "Zmodem: Got %s", frametypes[c+FTOFFSET]);
/* **** FALL THRU TO **** */ /* **** FALL THRU TO **** */
default: if (c >= -FTOFFSET && c <= FRTYPES) default: if (c >= -FTOFFSET && c <= FRTYPES)
Syslog('z', "zgethdr: %c %d %s %lx", Rxframeind, Rxhlen, frametypes[c+FTOFFSET], Rxpos); Syslog('z', "zgethdr: %c %s %lx", Rxframeind, frametypes[c+FTOFFSET], Rxpos);
else else
Syslog('z', "zgethdr: %d %d %ld", Rxframeind, c, Rxpos); Syslog('z', "zgethdr: %d %d %lx", Rxframeind, c, Rxpos);
} }
/* Use variable length headers if we got one */ /* Use variable length headers if we got one */
if (c >= 0 && c <= FRTYPES && Rxframeind & 040) { if (c >= 0 && c <= FRTYPES && Rxframeind & 040) {
Usevhdrs = 1;
Syslog('z', "zgethdr: Usevhdrs"); Syslog('z', "zgethdr: Usevhdrs");
} }
return c; return c;
@ -666,7 +607,7 @@ int zrbhdr(register char *shdr)
Rxtype = c; Rxtype = c;
crc = updcrc16(c, 0); crc = updcrc16(c, 0);
for (n=Rxhlen; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
if ((c = zdlread()) & ~0377) if ((c = zdlread()) & ~0377)
return c; return c;
crc = updcrc16(c, crc); crc = updcrc16(c, crc);
@ -700,7 +641,7 @@ int zrbhd32(register char *shdr)
Rxtype = c; Rxtype = c;
crc = 0xFFFFFFFFL; crc = updcrc32(c, crc); crc = 0xFFFFFFFFL; crc = updcrc32(c, crc);
for (n=Rxhlen; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
if ((c = zdlread()) & ~0377) if ((c = zdlread()) & ~0377)
return c; return c;
crc = updcrc32(c, crc); crc = updcrc32(c, crc);
@ -734,7 +675,7 @@ int zrhhdr(char *shdr)
Rxtype = c; Rxtype = c;
crc = updcrc16(c, 0); crc = updcrc16(c, 0);
for (n=Rxhlen; --n >= 0; ++shdr) { for (n=4; --n >= 0; ++shdr) {
if ((c = zgethex()) < 0) if ((c = zgethex()) < 0)
return c; return c;
crc = updcrc16(c, crc); crc = updcrc16(c, crc);
@ -868,10 +809,10 @@ again:
switch (c) { switch (c) {
case ZDLE: break; case ZDLE: break;
case 023: case XON:
case 0223: case XON|0200:
case 021: case XOFF:
case 0221: goto again; case XOFF|0200: goto again;
default: if (Zctlesc && !(c & 0140)) { default: if (Zctlesc && !(c & 0140)) {
goto again; goto again;
} }
@ -896,10 +837,10 @@ again2:
case ZCRCW: return (c | GOTOR); case ZCRCW: return (c | GOTOR);
case ZRUB0: return 0177; case ZRUB0: return 0177;
case ZRUB1: return 0377; case ZRUB1: return 0377;
case 023: case XON:
case 0223: case XON|0200:
case 021: case XOFF:
case 0221: goto again2; case XOFF|0200: goto again2;
default: if (Zctlesc && ! (c & 0140)) { default: if (Zctlesc && ! (c & 0140)) {
goto again2; goto again2;
} }

View File

@ -22,14 +22,14 @@
#define ZBIN 'A' /* Binary frame indicator (CRC-16) */ #define ZBIN 'A' /* Binary frame indicator (CRC-16) */
#define ZHEX 'B' /* HEX frame indicator */ #define ZHEX 'B' /* HEX frame indicator */
#define ZBIN32 'C' /* Binary frame with 32 bit FCS */ #define ZBIN32 'C' /* Binary frame with 32 bit FCS */
#define ZBINR32 'D' /* RLE packed 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 ZVBIN 'a' /* Binary frame indicator (CRC-16) */
#define ZVHEX 'b' /* HEX frame indicator */ // #define ZVHEX 'b' /* HEX frame indicator */
#define ZVBIN32 'c' /* Binary frame with 32 bit FCS */ // #define ZVBIN32 'c' /* Binary frame with 32 bit FCS */
#define ZVBINR32 'd' /* RLE packed 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 ZRESC 0176 /* RLE flag/escape character */
#define ZMAXHLEN 16 /* Max header information length NEVER CHANGE */ #define ZMAXHLEN 16 /* Max header information length NEVER CHANGE */
#define ZMAXSPLEN 1024 /* Max subpacket length NEVER CHANGE */ // #define ZMAXSPLEN 1024 /* Max subpacket length NEVER CHANGE */
/* Frame types (see array "frametypes" in zm.c) */ /* Frame types (see array "frametypes" in zm.c) */
@ -82,27 +82,27 @@
#define ZP3 3 /* High order 8 bits of file position */ #define ZP3 3 /* High order 8 bits of file position */
/* Parameters for ZRINIT header */ /* Parameters for ZRINIT header */
#define ZRPXWN 8 /* 9th byte in header contains window size/256 */ // #define ZRPXWN 8 /* 9th byte in header contains window size/256 */
#define ZRPXQQ 9 /* 10th to 14th bytes contain quote mask */ // #define ZRPXQQ 9 /* 10th to 14th bytes contain quote mask */
/* Bit Masks for ZRINIT flags byte ZF0 */ /* Bit Masks for ZRINIT flags byte ZF0 */
#define CANFDX 01 /* Rx can send and receive true FDX */ #define CANFDX 01 /* Rx can send and receive true FDX */
#define CANOVIO 02 /* Rx can receive data during disk I/O */ #define CANOVIO 02 /* Rx can receive data during disk I/O */
#define CANBRK 04 /* Rx can send a break signal */ #define CANBRK 04 /* Rx can send a break signal */
#define CANRLE 010 /* Receiver can decode RLE */ // #define CANRLE 010 /* Receiver can decode RLE */
#define CANLZW 020 /* Receiver can uncompress */ #define CANLZW 020 /* Receiver can uncompress */
#define CANFC32 040 /* Receiver can use 32 bit Frame Check */ #define CANFC32 040 /* Receiver can use 32 bit Frame Check */
#define ESCCTL 0100 /* Receiver expects ctl chars to be escaped */ #define ESCCTL 0100 /* Receiver expects ctl chars to be escaped */
#define ESC8 0200 /* Receiver expects 8th bit to be escaped */ #define ESC8 0200 /* Receiver expects 8th bit to be escaped */
/* Bit Masks for ZRINIT flags byte ZF1 */ /* Bit Masks for ZRINIT flags byte ZF1 */
#define CANVHDR 01 /* Variable headers OK */ // #define CANVHDR 01 /* Variable headers OK */
#define ZRRQWN 8 /* Receiver specified window size in ZRPXWN */ // #define ZRRQWN 8 /* Receiver specified window size in ZRPXWN */
#define ZRRQQQ 16 /* Additional control chars to quote in ZRPXQQ */ // #define ZRRQQQ 16 /* Additional control chars to quote in ZRPXQQ */
#define ZRQNVH (ZRRQWN|ZRRQQQ) /* Variable len hdr reqd to access info */ // #define ZRQNVH (ZRRQWN|ZRRQQQ) /* Variable len hdr reqd to access info */
/* Parameters for ZSINIT frame */ /* Parameters for ZSINIT frame */
#define ZATTNLEN 32 /* Max length of attention string */ #define ZATTNLEN 32 /* Max length of attention string */
#define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */ // #define ALTCOFF ZF1 /* Offset to alternate canit string, 0 if not used */
/* Bit Masks for ZSINIT flags byte ZF0 */ /* Bit Masks for ZSINIT flags byte ZF0 */
#define TESCCTL 0100 /* Transmitter expects ctl chars to be escaped */ #define TESCCTL 0100 /* Transmitter expects ctl chars to be escaped */
#define TESC8 0200 /* Transmitter expects 8th bit to be escaped */ #define TESC8 0200 /* Transmitter expects 8th bit to be escaped */
@ -130,9 +130,9 @@
#define ZTRLE 3 /* Run Length encoding */ #define ZTRLE 3 /* Run Length encoding */
/* Extended options for ZF3, bit encoded */ /* Extended options for ZF3, bit encoded */
#define ZXSPARS 64 /* Encoding for sparse file operations */ #define ZXSPARS 64 /* Encoding for sparse file operations */
#define ZCANVHDR 01 /* Variable headers OK */ // #define ZCANVHDR 01 /* Variable headers OK */
/* Receiver window size override */ /* Receiver window size override */
#define ZRWOVR 4 /* byte position for receive window override/256 */ // #define ZRWOVR 4 /* byte position for receive window override/256 */
/* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */ /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
#define ZCACK1 1 /* Acknowledge, then do command */ #define ZCACK1 1 /* Acknowledge, then do command */
@ -154,13 +154,20 @@ char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
char *Altcan; /* Alternate canit string */ char *Altcan; /* Alternate canit string */
char Zsendmask[33]; /* Additional control characters to mask */ char Zsendmask[33]; /* Additional control characters to mask */
int Zctlesc; int Zctlesc;
int Usevhdrs; /* Use variable length headers */ //int Usevhdrs; /* Use variable length headers */
enum zm_type_enum {
ZM_XMODEM,
ZM_YMODEM,
ZM_ZMODEM
};
enum zm_type_enum protocol;
void get_frame_buffer(void); void get_frame_buffer(void);
void free_frame_buffer(void); void free_frame_buffer(void);
void zsbhdr(int, int, register char *); void zsbhdr(int, char *);
void zshhdr(int, int, register char *); void zshhdr(int, char *);
void zsdata(register char *, int, int); void zsdata(register char *, int, int);
int zrdata(register char *, int); int zrdata(register char *, int);
int zrdat32(register char *, int); int zrdat32(register char *, int);

View File

@ -35,6 +35,7 @@
#include "transfer.h" #include "transfer.h"
#include "zmmisc.h" #include "zmmisc.h"
#include "zmrecv.h" #include "zmrecv.h"
#include "openport.h"
static FILE *fout = NULL; static FILE *fout = NULL;
@ -105,6 +106,7 @@ int zmrcvfiles(void)
secbuf = NULL; secbuf = NULL;
free_frame_buffer(); free_frame_buffer();
io_mode(0, 1);
Syslog('z', "Zmodem: receive rc=%d",rc); Syslog('z', "Zmodem: receive rc=%d",rc);
return abs(rc); return abs(rc);
} }
@ -128,19 +130,19 @@ int tryz(void)
*/ */
Syslog('z', "tryz attempt %d", n); Syslog('z', "tryz attempt %d", n);
stohdr(0L); stohdr(0L);
// Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO; Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO;
Txhdr[ZF0] = CANFC32; // Txhdr[ZF0] = CANFC32;
if (Zctlesc) if (Zctlesc)
Txhdr[ZF0] |= TESCCTL; Txhdr[ZF0] |= TESCCTL;
// Txhdr[ZF0] |= CANRLE; // Txhdr[ZF0] |= CANRLE;
Txhdr[ZF1] = CANVHDR; // Txhdr[ZF1] = CANVHDR;
zshhdr(4, tryzhdrtype, Txhdr); zshhdr(tryzhdrtype, Txhdr);
if (tryzhdrtype == ZSKIP) /* Don't skip too far */ if (tryzhdrtype == ZSKIP) /* Don't skip too far */
tryzhdrtype = ZRINIT; /* CAF 8-21-87 */ tryzhdrtype = ZRINIT; /* CAF 8-21-87 */
again: again:
switch (zgethdr(Rxhdr)) { switch (zgethdr(Rxhdr)) {
case ZRQINIT: if (Rxhdr[ZF3] & 0x80) case ZRQINIT: // if (Rxhdr[ZF3] & 0x80)
Usevhdrs = TRUE; /* we can var header */ // Usevhdrs = TRUE; /* we can var header */
continue; continue;
case ZEOF: continue; case ZEOF: continue;
case TIMEOUT: Syslog('+', "Zmodem: tryz() timeout attempt %d", n); case TIMEOUT: Syslog('+', "Zmodem: tryz() timeout attempt %d", n);
@ -148,18 +150,20 @@ again:
case ZFILE: zconv = Rxhdr[ZF0]; case ZFILE: zconv = Rxhdr[ZF0];
if (!zconv) { if (!zconv) {
Syslog('z', "*** !zconv %d", zconv); Syslog('z', "*** !zconv %d", zconv);
zconv = ZCBIN;
} }
zmanag = Rxhdr[ZF1]; zmanag = Rxhdr[ZF1];
ztrans = Rxhdr[ZF2]; ztrans = Rxhdr[ZF2];
if (Rxhdr[ZF3] & ZCANVHDR) // if (Rxhdr[ZF3] & ZCANVHDR)
Usevhdrs = TRUE; // Usevhdrs = TRUE;
tryzhdrtype = ZRINIT; tryzhdrtype = ZRINIT;
c = zrdata(secbuf, MAXBLOCK); c = zrdata(secbuf, MAXBLOCK);
io_mode(0, 3);
if (c == GOTCRCW) { if (c == GOTCRCW) {
Syslog('z', "tryz return ZFILE"); Syslog('z', "tryz return ZFILE");
return ZFILE; return ZFILE;
} }
zshhdr(4,ZNAK, Txhdr); zshhdr(ZNAK, Txhdr);
goto again; goto again;
case ZSINIT: /* this once was: case ZSINIT: /* this once was:
* Zctlesc = TESCCTL & Rxhdr[ZF0]; * Zctlesc = TESCCTL & Rxhdr[ZF0];
@ -173,13 +177,13 @@ again:
Zctlesc |= TESCCTL & Rxhdr[ZF0]; Zctlesc |= TESCCTL & Rxhdr[ZF0];
if (zrdata(Attn, ZATTNLEN) == GOTCRCW) { if (zrdata(Attn, ZATTNLEN) == GOTCRCW) {
stohdr(1L); stohdr(1L);
zshhdr(4,ZACK, Txhdr); zshhdr(ZACK, Txhdr);
goto again; goto again;
} }
zshhdr(4,ZNAK, Txhdr); zshhdr(ZNAK, Txhdr);
goto again; goto again;
case ZFREECNT: stohdr(getfree()); case ZFREECNT: stohdr(getfree());
zshhdr(4,ZACK, Txhdr); zshhdr(ZACK, Txhdr);
goto again; goto again;
case ZCOMMAND: cmdzack1flg = Rxhdr[ZF0]; case ZCOMMAND: cmdzack1flg = Rxhdr[ZF0];
if (zrdata(secbuf, MAXBLOCK) == GOTCRCW) { if (zrdata(secbuf, MAXBLOCK) == GOTCRCW) {
@ -189,11 +193,11 @@ again:
Syslog('+', "Zmodem: request for command \"%s\" ignored", printable(secbuf,-32)); Syslog('+', "Zmodem: request for command \"%s\" ignored", printable(secbuf,-32));
stohdr(0L); stohdr(0L);
do { do {
zshhdr(4,ZCOMPL, Txhdr); zshhdr(ZCOMPL, Txhdr);
} while (++errors<20 && zgethdr(Rxhdr) != ZFIN); } while (++errors<20 && zgethdr(Rxhdr) != ZFIN);
return ackbibi(); return ackbibi();
} }
zshhdr(4,ZNAK, Txhdr); zshhdr(ZNAK, Txhdr);
goto again; goto again;
case ZCOMPL: goto again; case ZCOMPL: goto again;
case ZRINIT: Syslog('z', "tryz: got ZRINIT"); case ZRINIT: Syslog('z', "tryz: got ZRINIT");
@ -262,7 +266,7 @@ int rzfile(void)
for (;;) { for (;;) {
Syslog('z', "rxbytes %ld", rxbytes); Syslog('z', "rxbytes %ld", rxbytes);
stohdr(rxbytes); stohdr(rxbytes);
zshhdr(4,ZRPOS, Txhdr); zshhdr(ZRPOS, Txhdr);
nxthdr: nxthdr:
switch (c = zgethdr(Rxhdr)) { switch (c = zgethdr(Rxhdr)) {
default: Syslog('z', "rzfile: Wrong header %d", c); default: Syslog('z', "rzfile: Wrong header %d", c);
@ -349,13 +353,13 @@ moredata:
Syslog('z', "rxbytes %ld, will ACK", rxbytes); Syslog('z', "rxbytes %ld, will ACK", rxbytes);
stohdr(rxbytes); stohdr(rxbytes);
PUTCHAR(XON); PUTCHAR(XON);
zshhdr(4,ZACK, Txhdr); zshhdr(ZACK, Txhdr);
goto nxthdr; goto nxthdr;
case GOTCRCQ: n = 20; case GOTCRCQ: n = 20;
putsec(secbuf, Rxcount); putsec(secbuf, Rxcount);
rxbytes += Rxcount; rxbytes += Rxcount;
stohdr(rxbytes); stohdr(rxbytes);
zshhdr(4,ZACK, Txhdr); zshhdr(ZACK, Txhdr);
goto moredata; goto moredata;
case GOTCRCG: n = 20; case GOTCRCG: n = 20;
putsec(secbuf, Rxcount); putsec(secbuf, Rxcount);
@ -445,7 +449,7 @@ int ackbibi(void)
stohdr(0L); stohdr(0L);
for (n=3; --n>=0; ) { for (n=3; --n>=0; ) {
zshhdr(4,ZFIN, Txhdr); zshhdr(ZFIN, Txhdr);
switch ((c = GETCHAR(10))) { switch ((c = GETCHAR(10))) {
case 'O': GETCHAR(1); /* Discard 2nd 'O' */ case 'O': GETCHAR(1); /* Discard 2nd 'O' */

View File

@ -50,6 +50,7 @@ extern char *Zendnames[];
/* /*
* Send data subpacket RLE encoded with 32 bit FCS * Send data subpacket RLE encoded with 32 bit FCS
*/ */
/*
void zsdar32(char *buf, int length, int frameend) void zsdar32(char *buf, int length, int frameend)
{ {
register int c, l, n; register int c, l, n;
@ -87,8 +88,8 @@ void zsdar32(char *buf, int length, int frameend)
l = c; l = c;
break; break;
} }
/* **** FALL THRU TO **** */ */ /* **** FALL THRU TO **** */
default: zsendline(ZRESC); crc = updcrc32(ZRESC, crc); /* default: zsendline(ZRESC); crc = updcrc32(ZRESC, crc);
if (l == 040 && n < 34) { if (l == 040 && n < 34) {
n += 036; n += 036;
zsendline(n); zsendline(n);
@ -116,11 +117,12 @@ void zsdar32(char *buf, int length, int frameend)
crc >>= 8; crc >>= 8;
} }
} }
*/
/* /*
* Receive data subpacket RLE encoded with 32 bit FCS * Receive data subpacket RLE encoded with 32 bit FCS
*/ */
/*
int zrdatr32(register char *buf, int length) int zrdatr32(register char *buf, int length)
{ {
register int c; register int c;
@ -131,7 +133,7 @@ int zrdatr32(register char *buf, int length)
crc = 0xFFFFFFFFL; crc = 0xFFFFFFFFL;
Rxcount = 0; Rxcount = 0;
end = buf + length; end = buf + length;
d = 0; /* Use for RLE decoder state */ d = 0; */ /* Use for RLE decoder state */ /*
while (buf <= end) { while (buf <= end) {
if ((c = zdlread()) & ~0377) { if ((c = zdlread()) & ~0377) {
crcfoo: crcfoo:
@ -208,4 +210,5 @@ badpkt:
Syslog('+', "Zmodem: Data subpacket too long"); Syslog('+', "Zmodem: Data subpacket too long");
return TERROR; return TERROR;
} }
*/

View File

@ -3,7 +3,9 @@
/* $Id$ */ /* $Id$ */
/*
void zsdar32(char *, int, int); void zsdar32(char *, int, int);
int zrdatr32(register char *, int); int zrdatr32(register char *, int);
*/
#endif #endif

View File

@ -34,6 +34,8 @@
#include "zmmisc.h" #include "zmmisc.h"
#include "zmrle.h" #include "zmrle.h"
#include "transfer.h" #include "transfer.h"
#include "openport.h"
static int initsend(void); static int initsend(void);
static int sendzfile(char*); static int sendzfile(char*);
@ -135,9 +137,10 @@ static int initsend(void)
{ {
Syslog('z', "Zmodem: initsend"); Syslog('z', "Zmodem: initsend");
io_mode(0, 1);
PUTSTR((char *)"rz\r"); PUTSTR((char *)"rz\r");
stohdr(0x80L); /* Show we can do var header */ stohdr(0x80L); /* Show we can do var header */
zshhdr(4, ZRQINIT, Txhdr); zshhdr(ZRQINIT, Txhdr);
if (getzrxinit()) { if (getzrxinit()) {
Syslog('+', "Zmodem: Unable to initiate send"); Syslog('+', "Zmodem: Unable to initiate send");
@ -160,7 +163,7 @@ static int finsend(void)
while (GETCHAR(1) >= 0) /*nothing*/; while (GETCHAR(1) >= 0) /*nothing*/;
for (i = 0; i < 30; i++) { for (i = 0; i < 30; i++) {
stohdr(0L); stohdr(0L);
zshhdr(4, ZFIN, Txhdr); zshhdr(ZFIN, Txhdr);
if ((rc = zgethdr(Rxhdr)) == ZFIN) if ((rc = zgethdr(Rxhdr)) == ZFIN)
PUTSTR((char *)"OO"); PUTSTR((char *)"OO");
if ((rc == ZFIN) || (rc == ZCAN) || (rc < 0)) if ((rc == ZFIN) || (rc == ZCAN) || (rc < 0))
@ -241,17 +244,18 @@ int getzrxinit(void) // CHECKED BUT NOT WELL TESTED
switch (zgethdr(Rxhdr)) { switch (zgethdr(Rxhdr)) {
case ZCHALLENGE: /* Echo receiver's challenge numbr */ case ZCHALLENGE: /* Echo receiver's challenge numbr */
stohdr(Rxpos); stohdr(Rxpos);
zshhdr(4, ZACK, Txhdr); zshhdr(ZACK, Txhdr);
continue; continue;
case ZCOMMAND: /* They didn't see out ZRQINIT */ case ZCOMMAND: /* They didn't see out ZRQINIT */
stohdr(0L); stohdr(0L);
zshhdr(4, ZRQINIT, Txhdr); zshhdr(ZRQINIT, Txhdr);
continue; continue;
case ZRINIT: case ZRINIT:
Rxflags = 0377 & Rxhdr[ZF0]; Rxflags = 0377 & Rxhdr[ZF0];
Usevhdrs = Rxhdr[ZF1] & CANVHDR; // Usevhdrs = Rxhdr[ZF1] & CANVHDR;
Txfcs32 = (Wantfcs32 && (Rxflags & CANFC32)); Txfcs32 = (Wantfcs32 && (Rxflags & CANFC32));
Zctlesc |= Rxflags & TESCCTL; Zctlesc |= Rxflags & TESCCTL;
Rxbuflen = (0377 & Rxhdr[ZP0])+((0377 & Rxhdr[ZP1])<<8); Rxbuflen = (0377 & Rxhdr[ZP0])+((0377 & Rxhdr[ZP1])<<8);
if ( !(Rxflags & CANFDX)) if ( !(Rxflags & CANFDX))
Txwindow = 0; Txwindow = 0;
@ -268,9 +272,9 @@ int getzrxinit(void) // CHECKED BUT NOT WELL TESTED
Syslog('z', "Rxbuflen=%d blklen=%d", Rxbuflen, blklen); Syslog('z', "Rxbuflen=%d blklen=%d", Rxbuflen, blklen);
Syslog('z', "Txwindow = %u Txwspac = %d", Txwindow, Txwspac); Syslog('z', "Txwindow = %u Txwspac = %d", Txwindow, Txwspac);
if (Lztrans == ZTRLE && (Rxflags & CANRLE)) // if (Lztrans == ZTRLE && (Rxflags & CANRLE))
Txfcs32 = 2; // Txfcs32 = 2;
else // else
Lztrans = 0; Lztrans = 0;
return (sendzsinit()); return (sendzsinit());
@ -283,7 +287,7 @@ int getzrxinit(void) // CHECKED BUT NOT WELL TESTED
if (Rxhdr[ZF0] == ZCOMMAND) if (Rxhdr[ZF0] == ZCOMMAND)
continue; continue;
default: default:
zshhdr(4, ZNAK, Txhdr); zshhdr(ZNAK, Txhdr);
continue; continue;
} }
} }
@ -305,9 +309,9 @@ int sendzsinit(void)
for (;;) { for (;;) {
stohdr(0L); stohdr(0L);
if (Zctlesc) { if (Zctlesc) {
Txhdr[ZF0] |= TESCCTL; zshhdr(4, ZSINIT, Txhdr); Txhdr[ZF0] |= TESCCTL; zshhdr(ZSINIT, Txhdr);
} else } else
zsbhdr(4, ZSINIT, Txhdr); zsbhdr(ZSINIT, Txhdr);
zsdata(Myattn, ZATTNLEN, ZCRCW); zsdata(Myattn, ZATTNLEN, ZCRCW);
c = zgethdr(Rxhdr); c = zgethdr(Rxhdr);
switch (c) { switch (c) {
@ -358,7 +362,7 @@ int zsendfile(char *buf, int blen)
Txhdr[ZF1] |= ZMSKNOLOC; Txhdr[ZF1] |= ZMSKNOLOC;
Txhdr[ZF2] = Lztrans; /* file transport request */ Txhdr[ZF2] = Lztrans; /* file transport request */
Txhdr[ZF3] = 0; Txhdr[ZF3] = 0;
zsbhdr(4, ZFILE, Txhdr); zsbhdr(ZFILE, Txhdr);
zsdata(buf, blen, ZCRCW); zsdata(buf, blen, ZCRCW);
again: again:
c = zgethdr(Rxhdr); c = zgethdr(Rxhdr);
@ -393,7 +397,7 @@ again:
lastcrcrq = Rxpos; lastcrcrq = Rxpos;
} }
stohdr(crc); stohdr(crc);
zsbhdr(4, ZCRC, Txhdr); zsbhdr(ZCRC, Txhdr);
goto again; goto again;
case ZFERR: case ZFERR:
case ZSKIP: case ZSKIP:
@ -486,7 +490,7 @@ to:
newcnt = Rxbuflen; newcnt = Rxbuflen;
Txwcnt = 0; Txwcnt = 0;
stohdr(Txpos); stohdr(Txpos);
zsbhdr(4, ZDATA, Txhdr); zsbhdr(ZDATA, Txhdr);
do { do {
n = zfilbuf(); n = zfilbuf();
@ -555,7 +559,7 @@ to:
for (;;) { for (;;) {
stohdr(Txpos); stohdr(Txpos);
zsbhdr(4, ZEOF, Txhdr); zsbhdr(ZEOF, Txhdr);
egotack: egotack:
switch (getinsync(0)) { switch (getinsync(0)) {
case ZACK: Syslog('z', "zsendfdata() ZACK"); case ZACK: Syslog('z', "zsendfdata() ZACK");
@ -628,7 +632,7 @@ int getinsync(int flag)
case ZRINIT: return c; case ZRINIT: return c;
case ZSKIP: Syslog('+', "Zmodem: File skipped by receiver request"); case ZSKIP: Syslog('+', "Zmodem: File skipped by receiver request");
return c; return c;
default: zsbhdr(4, ZNAK, Txhdr); default: zsbhdr(ZNAK, Txhdr);
continue; continue;
} }
} }