Fixed idle timer during chat
This commit is contained in:
parent
c1ae6ed787
commit
9eb6526fff
@ -33,6 +33,7 @@ v0.71.0 27-Oct-2004
|
|||||||
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 protocol.
|
||||||
|
With user chat, the timeout timer wasn't refreshed.
|
||||||
|
|
||||||
mbnewusr:
|
mbnewusr:
|
||||||
Rewrote terminal i/o.
|
Rewrote terminal i/o.
|
||||||
|
@ -112,14 +112,14 @@ newuser.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h inp
|
|||||||
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
|
||||||
change.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h change.h dispfile.h funcs.h input.h language.h misc.h timeout.h exitinfo.h bye.h term.h ttyio.h
|
change.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h change.h dispfile.h funcs.h input.h language.h misc.h timeout.h exitinfo.h bye.h term.h ttyio.h
|
||||||
transfer.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h transfer.h change.h whoson.h funcs.h term.h ttyio.h filesub.h language.h openport.h timeout.h zmsend.h
|
transfer.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h transfer.h change.h whoson.h funcs.h term.h ttyio.h filesub.h language.h openport.h timeout.h zmsend.h zmrecv.h
|
||||||
exitinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
|
exitinfo.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
|
||||||
mbsebbs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h mbsebbs.h user.h dispfile.h language.h menu.h misc.h bye.h timeout.h funcs.h term.h ttyio.h openport.h
|
mbsebbs.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h mbsebbs.h user.h dispfile.h language.h menu.h misc.h bye.h timeout.h funcs.h term.h ttyio.h openport.h
|
||||||
menu.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h mail.h bbslist.h change.h chat.h file.h funcs.h input.h misc.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h signature.h term.h ttyio.h
|
menu.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h oneline.h mail.h bbslist.h change.h chat.h file.h funcs.h input.h misc.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h signature.h term.h ttyio.h
|
||||||
pop3.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h term.h ttyio.h
|
pop3.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h term.h ttyio.h
|
||||||
lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h term.h ttyio.h
|
lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h term.h ttyio.h
|
||||||
timeout.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h term.h
|
timeout.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h term.h
|
||||||
chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h term.h ttyio.h
|
chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h term.h ttyio.h timeout.h
|
||||||
file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h term.h ttyio.h openport.h transfer.h
|
file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h term.h ttyio.h openport.h transfer.h
|
||||||
misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h funcs.h input.h language.h misc.h timeout.h exitinfo.h ttyio.h term.h
|
misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h funcs.h input.h language.h misc.h timeout.h exitinfo.h ttyio.h term.h
|
||||||
offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h term.h ttyio.h openport.h transfer.h
|
offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h term.h ttyio.h openport.h transfer.h
|
||||||
@ -133,7 +133,7 @@ userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h
|
|||||||
timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h
|
timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h
|
||||||
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 ../lib/nodelist.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
|
||||||
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
|
||||||
# End of generated dependencies
|
# End of generated dependencies
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "whoson.h"
|
#include "whoson.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include "ttyio.h"
|
#include "ttyio.h"
|
||||||
|
#include "timeout.h"
|
||||||
|
|
||||||
|
|
||||||
int chat_with_sysop = FALSE; /* Global sysop chat flag */
|
int chat_with_sysop = FALSE; /* Global sysop chat flag */
|
||||||
@ -278,6 +279,7 @@ void Chat(char *username, char *channel)
|
|||||||
*/
|
*/
|
||||||
ch = testkey(exitinfo.iScreenLen -1, curpos + 2);
|
ch = testkey(exitinfo.iScreenLen -1, curpos + 2);
|
||||||
if (isprint(ch)) {
|
if (isprint(ch)) {
|
||||||
|
alarm_on();
|
||||||
if (curpos < 77) {
|
if (curpos < 77) {
|
||||||
PUTCHAR(ch);
|
PUTCHAR(ch);
|
||||||
sbuf[curpos] = ch;
|
sbuf[curpos] = ch;
|
||||||
@ -286,6 +288,7 @@ void Chat(char *username, char *channel)
|
|||||||
PUTCHAR(7);
|
PUTCHAR(7);
|
||||||
}
|
}
|
||||||
} else if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
|
} else if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
|
||||||
|
alarm_on();
|
||||||
if (curpos) {
|
if (curpos) {
|
||||||
curpos--;
|
curpos--;
|
||||||
sbuf[curpos] = '\0';
|
sbuf[curpos] = '\0';
|
||||||
@ -294,6 +297,7 @@ void Chat(char *username, char *channel)
|
|||||||
PUTCHAR(7);
|
PUTCHAR(7);
|
||||||
}
|
}
|
||||||
} else if ((ch == '\r') && curpos) {
|
} else if ((ch == '\r') && curpos) {
|
||||||
|
alarm_on();
|
||||||
sprintf(buf, "CPUT:2,%d,%s;", mypid, sbuf);
|
sprintf(buf, "CPUT:2,%d,%s;", mypid, sbuf);
|
||||||
Syslog('c', "> %s", buf);
|
Syslog('c', "> %s", buf);
|
||||||
if (socket_send(buf) == 0) {
|
if (socket_send(buf) == 0) {
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "openport.h"
|
#include "openport.h"
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include "zmsend.h"
|
#include "zmsend.h"
|
||||||
|
#include "zmrecv.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -422,6 +423,51 @@ int upload(up_list **upload_list)
|
|||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
if (uProtInternal) {
|
if (uProtInternal) {
|
||||||
|
if (strncasecmp(sProtName, "zmodem", 6) == 0) {
|
||||||
|
rc = zmrcvfiles();
|
||||||
|
Syslog('b', "Begin dir processing");
|
||||||
|
if ((dirp = opendir(".")) == NULL) {
|
||||||
|
WriteError("$Upload: can't open ./upl");
|
||||||
|
Home();
|
||||||
|
rc = 1;
|
||||||
|
} else {
|
||||||
|
while ((dp = readdir(dirp)) != NULL) {
|
||||||
|
if (*(dp->d_name) != '.') {
|
||||||
|
if (rc == 0) {
|
||||||
|
stat(dp->d_name, &statfile);
|
||||||
|
Syslog('+', "Uploaded \"%s\", %ld bytes", dp->d_name, statfile.st_size);
|
||||||
|
sprintf(temp, "%s/%s/upl/%s", CFG.bbs_usersdir, exitinfo.Name, dp->d_name);
|
||||||
|
chmod(temp, 0660);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add uploaded file to the list
|
||||||
|
*/
|
||||||
|
tmp = (up_list *)malloc(sizeof(up_list));
|
||||||
|
tmp->next = NULL;
|
||||||
|
tmp->filename = xstrcpy(temp);
|
||||||
|
tmp->size = Size;
|
||||||
|
if (*upload_list == NULL) {
|
||||||
|
*upload_list = tmp;
|
||||||
|
} else {
|
||||||
|
for (ta = *upload_list; ta; ta = ta->next) {
|
||||||
|
if (ta->next == NULL) {
|
||||||
|
ta->next = (up_list *)tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Syslog('+', "Remove failed %s result %d", dp->d_name, unlink(dp->d_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dirp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Syslog('!', "Internal protocol %s not supported", sProtName);
|
||||||
|
free(temp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* External protocol
|
* External protocol
|
||||||
@ -487,6 +533,7 @@ int upload(up_list **upload_list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(temp);
|
free(temp);
|
||||||
|
Syslog('b', "Done, return rc=%d", rc);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
264
mbsebbs/zmmisc.c
264
mbsebbs/zmmisc.c
@ -65,7 +65,6 @@ static void garbitch(void);
|
|||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../lib/mbselib.h"
|
#include "../lib/mbselib.h"
|
||||||
#include "../lib/nodelist.h"
|
|
||||||
#include "ttyio.h"
|
#include "ttyio.h"
|
||||||
#include "zmrle.h"
|
#include "zmrle.h"
|
||||||
#include "zmmisc.h"
|
#include "zmmisc.h"
|
||||||
@ -75,33 +74,13 @@ static void garbitch(void);
|
|||||||
does timing in whole seconds.
|
does timing in whole seconds.
|
||||||
*/
|
*/
|
||||||
static int Rxtimeout = 10; /* Seconds to wait for something */
|
static int Rxtimeout = 10; /* Seconds to wait for something */
|
||||||
int Zctlesc;
|
|
||||||
|
|
||||||
/* 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 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; /* TRUE means send binary frames with 32 bit FCS */
|
|
||||||
int Crc32t; /* Controls 32 bit CRC being sent */
|
|
||||||
/* 1 == CRC32, 2 == CRC32 + RLE */
|
|
||||||
int Crc32r; /* Indicates/controls 32 bit CRC being received */
|
|
||||||
/* 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 */
|
|
||||||
|
|
||||||
char *txbuf=NULL;
|
char *txbuf=NULL;
|
||||||
char *rxbuf=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 */
|
||||||
|
|
||||||
|
|
||||||
char *frametypes[] = {
|
char *frametypes[] = {
|
||||||
(char *)"EMPTY", /* -16 */
|
(char *)"EMPTY", /* -16 */
|
||||||
(char *)"Can't be (-15)",
|
(char *)"Can't be (-15)",
|
||||||
@ -193,7 +172,8 @@ void zsbhdr(int len, int type, register char *shdr)
|
|||||||
for (n = Znulls; --n >=0; )
|
for (n = Znulls; --n >=0; )
|
||||||
BUFFER_BYTE(0);
|
BUFFER_BYTE(0);
|
||||||
|
|
||||||
BUFFER_BYTE(ZPAD); BUFFER_BYTE(ZDLE);
|
BUFFER_BYTE(ZPAD);
|
||||||
|
BUFFER_BYTE(ZDLE);
|
||||||
|
|
||||||
switch (Crc32t=Txfcs32) {
|
switch (Crc32t=Txfcs32) {
|
||||||
case 2: zsbh32(len, shdr, type, Usevhdrs?ZVBINR32:ZBINR32);
|
case 2: zsbh32(len, shdr, type, Usevhdrs?ZVBINR32:ZBINR32);
|
||||||
@ -235,7 +215,8 @@ void zsbh32(int len, register char *shdr, int type, int flavour)
|
|||||||
if (Usevhdrs)
|
if (Usevhdrs)
|
||||||
zsendline(len);
|
zsendline(len);
|
||||||
zsendline(type);
|
zsendline(type);
|
||||||
crc = 0xFFFFFFFFL; crc = updcrc32(type, crc);
|
crc = 0xFFFFFFFFL;
|
||||||
|
crc = updcrc32(type, crc);
|
||||||
|
|
||||||
for (n=len; --n >= 0; ++shdr) {
|
for (n=len; --n >= 0; ++shdr) {
|
||||||
crc = updcrc32((0377 & *shdr), crc);
|
crc = updcrc32((0377 & *shdr), crc);
|
||||||
@ -258,7 +239,7 @@ void zshhdr(int len, 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 %ld", Usevhdrs?'v':'f', len, frametypes[type+FTOFFSET], rclhdr(shdr));
|
Syslog('z', "zshhdr: %c %d %s %lx", Usevhdrs?'v':'f', len, frametypes[type+FTOFFSET], rclhdr(shdr));
|
||||||
|
|
||||||
BUFFER_CLEAR();
|
BUFFER_CLEAR();
|
||||||
|
|
||||||
@ -275,7 +256,8 @@ void zshhdr(int len, int type, register char *shdr)
|
|||||||
|
|
||||||
crc = updcrc16(type, 0);
|
crc = updcrc16(type, 0);
|
||||||
for (n=len; --n >= 0; ++shdr) {
|
for (n=len; --n >= 0; ++shdr) {
|
||||||
zputhex(*shdr); crc = updcrc16((0377 & *shdr), crc);
|
zputhex(*shdr);
|
||||||
|
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);
|
||||||
@ -316,14 +298,16 @@ void zsdata(register char *buf, int length, int frameend)
|
|||||||
break;
|
break;
|
||||||
default: crc = 0;
|
default: crc = 0;
|
||||||
for (;--length >= 0; ++buf) {
|
for (;--length >= 0; ++buf) {
|
||||||
zsendline(*buf); crc = updcrc16((0377 & *buf), crc);
|
zsendline(*buf);
|
||||||
|
crc = updcrc16((0377 & *buf), crc);
|
||||||
}
|
}
|
||||||
BUFFER_BYTE(ZDLE);
|
BUFFER_BYTE(ZDLE);
|
||||||
BUFFER_BYTE(frameend);
|
BUFFER_BYTE(frameend);
|
||||||
crc = updcrc16(frameend, crc);
|
crc = updcrc16(frameend, crc);
|
||||||
|
|
||||||
crc = updcrc16(0,updcrc16(0,crc));
|
crc = updcrc16(0,updcrc16(0,crc));
|
||||||
zsendline(((int)(crc>>8))); zsendline(crc);
|
zsendline(((int)(crc>>8)));
|
||||||
|
zsendline(crc);
|
||||||
}
|
}
|
||||||
if (frameend == ZCRCW)
|
if (frameend == ZCRCW)
|
||||||
BUFFER_BYTE(XON);
|
BUFFER_BYTE(XON);
|
||||||
@ -353,7 +337,8 @@ void zsda32(register char *buf, int length, int frameend)
|
|||||||
|
|
||||||
crc = ~crc;
|
crc = ~crc;
|
||||||
for (c=4; --c >= 0;) {
|
for (c=4; --c >= 0;) {
|
||||||
zsendline((int)crc); crc >>= 8;
|
zsendline((int)crc);
|
||||||
|
crc >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,6 +356,8 @@ 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);
|
||||||
|
|
||||||
switch (Crc32r) {
|
switch (Crc32r) {
|
||||||
case 1:
|
case 1:
|
||||||
return zrdat32(buf, length);
|
return zrdat32(buf, length);
|
||||||
@ -378,7 +365,9 @@ int zrdata(register char *buf, int length)
|
|||||||
return zrdatr32(buf, length);
|
return zrdatr32(buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = Rxcount = 0; end = buf + length;
|
crc = Rxcount = 0;
|
||||||
|
end = buf + length;
|
||||||
|
|
||||||
while (buf <= end) {
|
while (buf <= end) {
|
||||||
if ((c = zdlread()) & ~0377) {
|
if ((c = zdlread()) & ~0377) {
|
||||||
crcfoo:
|
crcfoo:
|
||||||
@ -426,7 +415,10 @@ int zrdat32(register char *buf, int length)
|
|||||||
register char *end;
|
register char *end;
|
||||||
register int d;
|
register int d;
|
||||||
|
|
||||||
crc = 0xFFFFFFFFL; Rxcount = 0; end = buf + length;
|
crc = 0xFFFFFFFFL;
|
||||||
|
Rxcount = 0;
|
||||||
|
end = buf + length;
|
||||||
|
|
||||||
while (buf <= end) {
|
while (buf <= end) {
|
||||||
if ((c = zdlread()) & ~0377) {
|
if ((c = zdlread()) & ~0377) {
|
||||||
crcfoo:
|
crcfoo:
|
||||||
@ -494,50 +486,49 @@ void garbitch(void)
|
|||||||
int zgethdr(char *shdr)
|
int zgethdr(char *shdr)
|
||||||
{
|
{
|
||||||
register int c, n, cancount;
|
register int c, n, cancount;
|
||||||
|
|
||||||
int Zrwindow = 1400;
|
int Zrwindow = 1400;
|
||||||
int Baudrate = 9600;
|
int Baudrate = 9600;
|
||||||
|
|
||||||
n = Zrwindow + Baudrate;
|
n = Zrwindow + Baudrate;
|
||||||
Rxframeind = Rxtype = 0;
|
Rxframeind = Rxtype = 0;
|
||||||
|
Syslog('z', "zgethdr(%lx)", rclhdr(shdr));
|
||||||
|
|
||||||
startover:
|
startover:
|
||||||
cancount = 5;
|
cancount = 5;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
/*
|
/*
|
||||||
* Return immediate ERROR if ZCRCW sequence seen
|
* Return immediate ERROR if ZCRCW sequence seen
|
||||||
*/
|
*/
|
||||||
if (((c = GETCHAR(Rxtimeout)) < 0) && (c != TIMEOUT))
|
if (((c = GETCHAR(Rxtimeout)) < 0) && (c != TIMEOUT))
|
||||||
goto fifi;
|
goto fifi;
|
||||||
else switch(c) {
|
else {
|
||||||
case 021: case 0221:
|
// Syslog('z', "Zmodem: Got %c %d", c, c);
|
||||||
goto again;
|
switch(c) {
|
||||||
|
case 021:
|
||||||
|
case 0221: goto again;
|
||||||
case HANGUP:
|
case HANGUP:
|
||||||
case TIMEOUT:
|
case TIMEOUT: goto fifi;
|
||||||
goto fifi;
|
|
||||||
case CAN:
|
case CAN:
|
||||||
gotcan:
|
gotcan:
|
||||||
|
Syslog('z', "zgethdr: got CAN");
|
||||||
if (--cancount <= 0) {
|
if (--cancount <= 0) {
|
||||||
c = ZCAN; goto fifi;
|
c = ZCAN;
|
||||||
|
goto fifi;
|
||||||
}
|
}
|
||||||
switch (c = GETCHAR(Rxtimeout)) {
|
switch (c = GETCHAR(Rxtimeout)) {
|
||||||
case TIMEOUT:
|
case TIMEOUT: goto again;
|
||||||
goto again;
|
case ZCRCW: switch (GETCHAR(Rxtimeout)) {
|
||||||
case ZCRCW:
|
case TIMEOUT: c = TERROR;
|
||||||
switch (GETCHAR(Rxtimeout)) {
|
|
||||||
case TIMEOUT:
|
|
||||||
c = TERROR; goto fifi;
|
|
||||||
case HANGUP:
|
|
||||||
goto fifi;
|
goto fifi;
|
||||||
default:
|
case HANGUP: goto fifi;
|
||||||
goto agn2;
|
default: goto agn2;
|
||||||
}
|
}
|
||||||
case HANGUP:
|
case HANGUP: goto fifi;
|
||||||
|
default: break;
|
||||||
|
case CAN: if (--cancount <= 0) {
|
||||||
|
c = ZCAN;
|
||||||
goto fifi;
|
goto fifi;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case CAN:
|
|
||||||
if (--cancount <= 0) {
|
|
||||||
c = ZCAN; goto fifi;
|
|
||||||
}
|
}
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -546,80 +537,89 @@ gotcan:
|
|||||||
agn2:
|
agn2:
|
||||||
#define GCOUNT (-4)
|
#define GCOUNT (-4)
|
||||||
if ( --n == 0) {
|
if ( --n == 0) {
|
||||||
c = GCOUNT; goto fifi;
|
c = GCOUNT;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cancount = 5;
|
cancount = 5;
|
||||||
|
|
||||||
splat:
|
splat:
|
||||||
switch (c = noxrd7()) {
|
switch (c = noxrd7()) {
|
||||||
case ZPAD:
|
case ZPAD: goto splat;
|
||||||
goto splat;
|
|
||||||
case HANGUP:
|
case HANGUP:
|
||||||
case TIMEOUT:
|
case TIMEOUT: goto fifi;
|
||||||
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 */
|
Rxhlen = 4; /* Set default length */
|
||||||
Rxframeind = c = noxrd7();
|
Rxframeind = c = noxrd7();
|
||||||
|
Syslog('z', "zgethdr: header type %d", c);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case ZVBIN32:
|
case ZVBIN32: if ((Rxhlen = c = zdlread()) < 0)
|
||||||
if ((Rxhlen = c = zdlread()) < 0)
|
|
||||||
goto fifi;
|
goto fifi;
|
||||||
if (c > ZMAXHLEN)
|
if (c > ZMAXHLEN)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 1; c = zrbhd32(shdr); break;
|
Crc32r = 1;
|
||||||
case ZBIN32:
|
c = zrbhd32(shdr);
|
||||||
if (Usevhdrs)
|
break;
|
||||||
|
case ZBIN32: if (Usevhdrs)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 1; c = zrbhd32(shdr); break;
|
Crc32r = 1;
|
||||||
case ZVBINR32:
|
c = zrbhd32(shdr);
|
||||||
if ((Rxhlen = c = zdlread()) < 0)
|
break;
|
||||||
|
case ZVBINR32: if ((Rxhlen = c = zdlread()) < 0)
|
||||||
goto fifi;
|
goto fifi;
|
||||||
if (c > ZMAXHLEN)
|
if (c > ZMAXHLEN)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 2; c = zrbhd32(shdr); break;
|
Crc32r = 2;
|
||||||
case ZBINR32:
|
c = zrbhd32(shdr);
|
||||||
if (Usevhdrs)
|
break;
|
||||||
|
case ZBINR32: if (Usevhdrs)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 2; c = zrbhd32(shdr); break;
|
Crc32r = 2;
|
||||||
|
c = zrbhd32(shdr);
|
||||||
|
break;
|
||||||
case HANGUP:
|
case HANGUP:
|
||||||
case TIMEOUT:
|
case TIMEOUT: goto fifi;
|
||||||
goto fifi;
|
case ZVBIN: if ((Rxhlen = c = zdlread()) < 0)
|
||||||
case ZVBIN:
|
|
||||||
if ((Rxhlen = c = zdlread()) < 0)
|
|
||||||
goto fifi;
|
goto fifi;
|
||||||
if (c > ZMAXHLEN)
|
if (c > ZMAXHLEN)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 0; c = zrbhdr(shdr); break;
|
Crc32r = 0;
|
||||||
case ZBIN:
|
c = zrbhdr(shdr);
|
||||||
if (Usevhdrs)
|
break;
|
||||||
|
case ZBIN: if (Usevhdrs)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 0; c = zrbhdr(shdr); break;
|
Crc32r = 0;
|
||||||
case ZVHEX:
|
c = zrbhdr(shdr);
|
||||||
if ((Rxhlen = c = zgethex()) < 0)
|
break;
|
||||||
|
case ZVHEX: if ((Rxhlen = c = zgethex()) < 0)
|
||||||
goto fifi;
|
goto fifi;
|
||||||
if (c > ZMAXHLEN)
|
if (c > ZMAXHLEN)
|
||||||
goto agn2;
|
goto agn2;
|
||||||
Crc32r = 0; c = zrhhdr(shdr); break;
|
Crc32r = 0;
|
||||||
case ZHEX:
|
c = zrhhdr(shdr);
|
||||||
if (Usevhdrs)
|
break;
|
||||||
goto agn2;
|
case ZHEX: if (Usevhdrs)
|
||||||
Crc32r = 0; c = zrhhdr(shdr); break;
|
|
||||||
case CAN:
|
|
||||||
goto gotcan;
|
|
||||||
default:
|
|
||||||
goto agn2;
|
goto agn2;
|
||||||
|
Crc32r = 0;
|
||||||
|
c = zrhhdr(shdr);
|
||||||
|
break;
|
||||||
|
case CAN: goto gotcan;
|
||||||
|
default: goto agn2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = Rxhlen; ++n < ZMAXHLEN; ) /* Clear unused hdr bytes */
|
for (n = Rxhlen; ++n < ZMAXHLEN; ) /* Clear unused hdr bytes */
|
||||||
shdr[n] = 0;
|
shdr[n] = 0;
|
||||||
Rxpos = shdr[ZP3] & 0377;
|
Rxpos = shdr[ZP3] & 0377;
|
||||||
@ -627,26 +627,27 @@ splat:
|
|||||||
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:
|
case GOTCAN: c = ZCAN;
|
||||||
c = ZCAN;
|
|
||||||
/* **** FALL THRU TO **** */
|
/* **** FALL THRU TO **** */
|
||||||
case ZNAK:
|
case ZNAK:
|
||||||
case ZCAN:
|
case ZCAN:
|
||||||
case TERROR:
|
case TERROR:
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
case HANGUP:
|
case HANGUP: Syslog('+', "Zmodem: Got %s", frametypes[c+FTOFFSET]);
|
||||||
Syslog('+', "Zmodem: Got %s", frametypes[c+FTOFFSET]);
|
|
||||||
/* **** FALL THRU TO **** */
|
/* **** FALL THRU TO **** */
|
||||||
default:
|
default: if (c >= -FTOFFSET && c <= FRTYPES)
|
||||||
if (c >= -FTOFFSET && c <= FRTYPES)
|
Syslog('z', "zgethdr: %c %d %s %lx", Rxframeind, Rxhlen, frametypes[c+FTOFFSET], Rxpos);
|
||||||
Syslog('z', "zgethdr: %c %d %s %ld", Rxframeind, Rxhlen, frametypes[c+FTOFFSET], Rxpos);
|
|
||||||
else
|
else
|
||||||
Syslog('z', "zgethdr: %c %d %ld", Rxframeind, c, Rxpos);
|
Syslog('z', "zgethdr: %d %d %ld", 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;
|
Usevhdrs = 1;
|
||||||
|
Syslog('z', "zgethdr: Usevhdrs");
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,15 +750,13 @@ int zrhhdr(char *shdr)
|
|||||||
Syslog('+', "Zmodem zrhhdr: Bad CRC");
|
Syslog('+', "Zmodem zrhhdr: Bad CRC");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c = GETCHAR(Rxtimeout)) {
|
switch (c = GETCHAR(Rxtimeout)) {
|
||||||
case 0215:
|
case 0215: Not8bit = c;
|
||||||
Not8bit = c;
|
|
||||||
/* **** FALL THRU TO **** */
|
/* **** FALL THRU TO **** */
|
||||||
case 015:
|
case 015: /* Throw away possible cr/lf */
|
||||||
/* Throw away possible cr/lf */
|
|
||||||
switch (c = GETCHAR(Rxtimeout)) {
|
switch (c = GETCHAR(Rxtimeout)) {
|
||||||
case 012:
|
case 012: Not8bit |= c;
|
||||||
Not8bit |= c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
@ -791,13 +790,11 @@ void zsendline(int c)
|
|||||||
BUFFER_BYTE(lastsent = c);
|
BUFFER_BYTE(lastsent = c);
|
||||||
else {
|
else {
|
||||||
switch (c &= 0377) {
|
switch (c &= 0377) {
|
||||||
case ZDLE:
|
case ZDLE: BUFFER_BYTE(ZDLE);
|
||||||
BUFFER_BYTE(ZDLE);
|
|
||||||
BUFFER_BYTE (lastsent = (c ^= 0100));
|
BUFFER_BYTE (lastsent = (c ^= 0100));
|
||||||
break;
|
break;
|
||||||
case 015:
|
case 015:
|
||||||
case 0215:
|
case 0215: if (!Zctlesc && (lastsent & 0177) != '@')
|
||||||
if (!Zctlesc && (lastsent & 0177) != '@')
|
|
||||||
goto sendit;
|
goto sendit;
|
||||||
/* **** FALL THRU TO **** */
|
/* **** FALL THRU TO **** */
|
||||||
case 020:
|
case 020:
|
||||||
@ -805,14 +802,12 @@ void zsendline(int c)
|
|||||||
case 023:
|
case 023:
|
||||||
case 0220:
|
case 0220:
|
||||||
case 0221:
|
case 0221:
|
||||||
case 0223:
|
case 0223: BUFFER_BYTE(ZDLE);
|
||||||
BUFFER_BYTE(ZDLE);
|
|
||||||
c ^= 0100;
|
c ^= 0100;
|
||||||
sendit:
|
sendit:
|
||||||
BUFFER_BYTE(lastsent = c);
|
BUFFER_BYTE(lastsent = c);
|
||||||
break;
|
break;
|
||||||
default:
|
default: if (Zctlesc && ! (c & 0140)) {
|
||||||
if (Zctlesc && ! (c & 0140)) {
|
|
||||||
BUFFER_BYTE(ZDLE);
|
BUFFER_BYTE(ZDLE);
|
||||||
c ^= 0100;
|
c ^= 0100;
|
||||||
}
|
}
|
||||||
@ -870,20 +865,19 @@ again:
|
|||||||
/* Quick check for non control characters */
|
/* Quick check for non control characters */
|
||||||
if ((c = GETCHAR(Rxtimeout)) & 0140)
|
if ((c = GETCHAR(Rxtimeout)) & 0140)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case ZDLE:
|
case ZDLE: break;
|
||||||
break;
|
|
||||||
case 023:
|
case 023:
|
||||||
case 0223:
|
case 0223:
|
||||||
case 021:
|
case 021:
|
||||||
case 0221:
|
case 0221: goto again;
|
||||||
goto again;
|
default: if (Zctlesc && !(c & 0140)) {
|
||||||
default:
|
|
||||||
if (Zctlesc && !(c & 0140)) {
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
again2:
|
again2:
|
||||||
if ((c = GETCHAR(Rxtimeout)) < 0)
|
if ((c = GETCHAR(Rxtimeout)) < 0)
|
||||||
return c;
|
return c;
|
||||||
@ -893,31 +887,27 @@ again2:
|
|||||||
return c;
|
return c;
|
||||||
if (c == CAN && (c = GETCHAR(Rxtimeout)) < 0)
|
if (c == CAN && (c = GETCHAR(Rxtimeout)) < 0)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case CAN:
|
case CAN: return GOTCAN;
|
||||||
return GOTCAN;
|
|
||||||
case ZCRCE:
|
case ZCRCE:
|
||||||
case ZCRCG:
|
case ZCRCG:
|
||||||
case ZCRCQ:
|
case ZCRCQ:
|
||||||
case ZCRCW:
|
case ZCRCW: return (c | GOTOR);
|
||||||
return (c | GOTOR);
|
case ZRUB0: return 0177;
|
||||||
case ZRUB0:
|
case ZRUB1: return 0377;
|
||||||
return 0177;
|
|
||||||
case ZRUB1:
|
|
||||||
return 0377;
|
|
||||||
case 023:
|
case 023:
|
||||||
case 0223:
|
case 0223:
|
||||||
case 021:
|
case 021:
|
||||||
case 0221:
|
case 0221: goto again2;
|
||||||
goto again2;
|
default: if (Zctlesc && ! (c & 0140)) {
|
||||||
default:
|
|
||||||
if (Zctlesc && ! (c & 0140)) {
|
|
||||||
goto again2;
|
goto again2;
|
||||||
}
|
}
|
||||||
if ((c & 0140) == 0100)
|
if ((c & 0140) == 0100)
|
||||||
return (c ^ 0100);
|
return (c ^ 0100);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Syslog('+', "Zmodem: Bad escape sequence 0x%x", c);
|
Syslog('+', "Zmodem: Bad escape sequence 0x%x", c);
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
@ -935,17 +925,15 @@ int noxrd7(void)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if ((c = GETCHAR(Rxtimeout)) < 0)
|
if ((c = GETCHAR(Rxtimeout)) < 0)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
switch (c &= 0177) {
|
switch (c &= 0177) {
|
||||||
case XON:
|
case XON:
|
||||||
case XOFF:
|
case XOFF: continue;
|
||||||
continue;
|
default: if (Zctlesc && !(c & 0140))
|
||||||
default:
|
|
||||||
if (Zctlesc && !(c & 0140))
|
|
||||||
continue;
|
continue;
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
case ZDLE:
|
case ZDLE: return c;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,31 +137,24 @@
|
|||||||
/* 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 */
|
||||||
|
|
||||||
long rclhdr(register char *);
|
|
||||||
|
|
||||||
/* Globals used by ZMODEM functions */
|
/* Globals used by ZMODEM functions */
|
||||||
extern int Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */
|
int Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */
|
||||||
extern int Rxtype; /* Type of header received */
|
int Rxtype; /* Type of header received */
|
||||||
extern int Rxcount; /* Count of data bytes received */
|
int Rxcount; /* Count of data bytes received */
|
||||||
extern int long Rxpos; /* Received file position */
|
int long Rxpos; /* Received file position */
|
||||||
extern int long Txpos; /* Transmitted file position */
|
int long Txpos; /* Transmitted file position */
|
||||||
extern int Txfcs32; /* TURE means send binary frames with 32 bit FCS */
|
int Txfcs32; /* TURE means send binary frames with 32 bit FCS */
|
||||||
extern int Crc32t; /* Display flag indicating 32 bit CRC being sent */
|
int Crc32t; /* Display flag indicating 32 bit CRC being sent */
|
||||||
extern int Crc32r; /* Display flag indicating 32 bit CRC being received */
|
int Crc32r; /* Display flag indicating 32 bit CRC being received */
|
||||||
extern int Crc32; /* Display flag indicating 32 bit CRC being received */
|
int Znulls; /* Number of nulls to send at beginning of ZDATA hdr */
|
||||||
extern int Znulls; /* Number of nulls to send at beginning of ZDATA hdr */
|
char Rxhdr[ZMAXHLEN]; /* Received header */
|
||||||
extern char Rxhdr[];
|
char Txhdr[ZMAXHLEN]; /* Transmitted header */
|
||||||
extern char Txhdr[];
|
char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
|
||||||
extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
|
char *Altcan; /* Alternate canit string */
|
||||||
extern char *Altcan; /* Alternate canit string */
|
|
||||||
extern char *Zendnames[];
|
|
||||||
extern char *txbuf;
|
|
||||||
extern char *rxbuf;
|
|
||||||
|
|
||||||
char Zsendmask[33]; /* Additional control characters to mask */
|
char Zsendmask[33]; /* Additional control characters to mask */
|
||||||
|
int Zctlesc;
|
||||||
extern int Zctlesc;
|
int Usevhdrs; /* Use variable length headers */
|
||||||
extern char *frametypes[];
|
|
||||||
|
|
||||||
|
|
||||||
void get_frame_buffer(void);
|
void get_frame_buffer(void);
|
||||||
|
214
mbsebbs/zmrecv.c
214
mbsebbs/zmrecv.c
@ -40,7 +40,6 @@
|
|||||||
static FILE *fout = NULL;
|
static FILE *fout = NULL;
|
||||||
char *curfile = NULL;
|
char *curfile = NULL;
|
||||||
|
|
||||||
static int Usevhdrs;
|
|
||||||
static off_t rxbytes;
|
static off_t rxbytes;
|
||||||
static int Eofseen; /* indicates cpm eof (^Z) has been received */
|
static int Eofseen; /* indicates cpm eof (^Z) has been received */
|
||||||
static int errors;
|
static int errors;
|
||||||
@ -52,13 +51,8 @@ struct timezone tz;
|
|||||||
static long Bytesleft; /* number of bytes of incoming file left */
|
static long Bytesleft; /* number of bytes of incoming file left */
|
||||||
static long Modtime; /* Unix style mod time for incoming file */
|
static long Modtime; /* Unix style mod time for incoming file */
|
||||||
static int Filemode; /* Unix style mode for incoming file */
|
static int Filemode; /* Unix style mode for incoming file */
|
||||||
|
static int Thisbinary = TRUE; /* current file is to be received in bin mode */
|
||||||
static int Thisbinary; /* current file is to be received in bin mode */
|
static char *secbuf=0; /* "sector" buffer */
|
||||||
char Lzconv; /* Local ZMODEM file conversion request */
|
|
||||||
char Lzmanag; /* Local file management request */
|
|
||||||
|
|
||||||
static char *secbuf=0;
|
|
||||||
|
|
||||||
static int tryzhdrtype;
|
static int tryzhdrtype;
|
||||||
static char zconv; /* ZMODEM file conversion request */
|
static char zconv; /* ZMODEM file conversion request */
|
||||||
static char zmanag; /* ZMODEM file management request */
|
static char zmanag; /* ZMODEM file management request */
|
||||||
@ -75,9 +69,6 @@ static int ackbibi(void);
|
|||||||
static long getfree(void);
|
static long getfree(void);
|
||||||
|
|
||||||
|
|
||||||
void get_frame_buffer(void);
|
|
||||||
void free_frame_buffer(void);
|
|
||||||
|
|
||||||
extern unsigned long rcvdbytes;
|
extern unsigned long rcvdbytes;
|
||||||
|
|
||||||
|
|
||||||
@ -97,8 +88,10 @@ int zmrcvfiles(void)
|
|||||||
Syslog('+', "Zmodem: could not initiate receive, rc=%d",rc);
|
Syslog('+', "Zmodem: could not initiate receive, rc=%d",rc);
|
||||||
} else
|
} else
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case ZCOMPL: rc = 0; break;
|
case ZCOMPL: rc = 0;
|
||||||
case ZFILE: rc = rzfiles(); break;
|
break;
|
||||||
|
case ZFILE: rc = rzfiles();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fout) {
|
if (fout) {
|
||||||
@ -135,39 +128,49 @@ 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;
|
||||||
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(4, 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:
|
case ZRQINIT: if (Rxhdr[ZF3] & 0x80)
|
||||||
if (Rxhdr[ZF3] & 0x80)
|
|
||||||
Usevhdrs = TRUE; /* we can var header */
|
Usevhdrs = TRUE; /* we can var header */
|
||||||
continue;
|
continue;
|
||||||
case ZEOF:
|
case ZEOF: continue;
|
||||||
|
case TIMEOUT: Syslog('+', "Zmodem: tryz() timeout attempt %d", n);
|
||||||
continue;
|
continue;
|
||||||
case TIMEOUT:
|
case ZFILE: zconv = Rxhdr[ZF0];
|
||||||
Syslog('+', "Zmodem: tryz() timeout attempt %d", n);
|
if (!zconv) {
|
||||||
continue;
|
Syslog('z', "*** !zconv %d", zconv);
|
||||||
case ZFILE:
|
}
|
||||||
zconv = Rxhdr[ZF0];
|
|
||||||
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);
|
||||||
if (c == GOTCRCW)
|
if (c == GOTCRCW) {
|
||||||
|
Syslog('z', "tryz return ZFILE");
|
||||||
return ZFILE;
|
return ZFILE;
|
||||||
|
}
|
||||||
zshhdr(4,ZNAK, Txhdr);
|
zshhdr(4,ZNAK, Txhdr);
|
||||||
goto again;
|
goto again;
|
||||||
case ZSINIT:
|
case ZSINIT: /* this once was:
|
||||||
Zctlesc = TESCCTL & Rxhdr[ZF0];
|
* Zctlesc = TESCCTL & Rxhdr[ZF0];
|
||||||
|
* trouble: if rz get --escape flag:
|
||||||
|
* - it sends TESCCTL to sz,
|
||||||
|
* get a ZSINIT _without_ TESCCTL (yeah - sender didn't know),
|
||||||
|
* overwrites Zctlesc flag ...
|
||||||
|
* - sender receives TESCCTL and uses "|=..."
|
||||||
|
* so: sz escapes, but rz doesn't unescape ... not good.
|
||||||
|
*/
|
||||||
|
Zctlesc |= TESCCTL & Rxhdr[ZF0];
|
||||||
if (zrdata(Attn, ZATTNLEN) == GOTCRCW) {
|
if (zrdata(Attn, ZATTNLEN) == GOTCRCW) {
|
||||||
stohdr(1L);
|
stohdr(1L);
|
||||||
zshhdr(4,ZACK, Txhdr);
|
zshhdr(4,ZACK, Txhdr);
|
||||||
@ -175,12 +178,10 @@ again:
|
|||||||
}
|
}
|
||||||
zshhdr(4,ZNAK, Txhdr);
|
zshhdr(4,ZNAK, Txhdr);
|
||||||
goto again;
|
goto again;
|
||||||
case ZFREECNT:
|
case ZFREECNT: stohdr(getfree());
|
||||||
stohdr(getfree());
|
|
||||||
zshhdr(4,ZACK, Txhdr);
|
zshhdr(4,ZACK, Txhdr);
|
||||||
goto again;
|
goto again;
|
||||||
case ZCOMMAND:
|
case ZCOMMAND: cmdzack1flg = Rxhdr[ZF0];
|
||||||
cmdzack1flg = Rxhdr[ZF0];
|
|
||||||
if (zrdata(secbuf, MAXBLOCK) == GOTCRCW) {
|
if (zrdata(secbuf, MAXBLOCK) == GOTCRCW) {
|
||||||
if (cmdzack1flg & ZCACK1)
|
if (cmdzack1flg & ZCACK1)
|
||||||
stohdr(0L);
|
stohdr(0L);
|
||||||
@ -192,20 +193,21 @@ again:
|
|||||||
} while (++errors<20 && zgethdr(Rxhdr) != ZFIN);
|
} while (++errors<20 && zgethdr(Rxhdr) != ZFIN);
|
||||||
return ackbibi();
|
return ackbibi();
|
||||||
}
|
}
|
||||||
zshhdr(4,ZNAK, Txhdr); goto again;
|
zshhdr(4,ZNAK, Txhdr);
|
||||||
case ZCOMPL:
|
|
||||||
goto again;
|
goto again;
|
||||||
case ZRINIT:
|
case ZCOMPL: goto again;
|
||||||
|
case ZRINIT: Syslog('z', "tryz: got ZRINIT");
|
||||||
|
return TERROR;
|
||||||
case ZFIN: /* do not beleive in first ZFIN */
|
case ZFIN: /* do not beleive in first ZFIN */
|
||||||
ackbibi(); return ZCOMPL;
|
ackbibi();
|
||||||
|
return ZCOMPL;
|
||||||
case TERROR:
|
case TERROR:
|
||||||
case HANGUP:
|
case HANGUP:
|
||||||
case ZCAN:
|
case ZCAN: return TERROR;
|
||||||
return TERROR;
|
default: continue;
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Syslog('z', "tryz return 0");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,20 +226,14 @@ int rzfiles(void)
|
|||||||
switch (c = rzfile()) {
|
switch (c = rzfile()) {
|
||||||
case ZEOF:
|
case ZEOF:
|
||||||
case ZSKIP:
|
case ZSKIP:
|
||||||
case ZFERR:
|
case ZFERR: switch (tryz()) {
|
||||||
switch (tryz()) {
|
case ZCOMPL: return OK;
|
||||||
case ZCOMPL:
|
default: return TERROR;
|
||||||
return OK;
|
case ZFILE: break;
|
||||||
default:
|
|
||||||
return TERROR;
|
|
||||||
case ZFILE:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
default:
|
default: return c;
|
||||||
return c;
|
case TERROR: return TERROR;
|
||||||
case TERROR:
|
|
||||||
return TERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
@ -264,37 +260,32 @@ int rzfile(void)
|
|||||||
n = 20;
|
n = 20;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
Syslog('z', "rxbytes %ld", rxbytes);
|
||||||
stohdr(rxbytes);
|
stohdr(rxbytes);
|
||||||
zshhdr(4,ZRPOS, Txhdr);
|
zshhdr(4,ZRPOS, Txhdr);
|
||||||
nxthdr:
|
nxthdr:
|
||||||
switch (c = zgethdr(Rxhdr)) {
|
switch (c = zgethdr(Rxhdr)) {
|
||||||
default:
|
default: Syslog('z', "rzfile: Wrong header %d", c);
|
||||||
Syslog('z', "rzfile: Wrong header %d", c);
|
|
||||||
if ( --n < 0) {
|
if ( --n < 0) {
|
||||||
Syslog('+', "Zmodem: wrong header %d", c);
|
Syslog('+', "Zmodem: wrong header %d", c);
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case ZCAN:
|
case ZCAN: Syslog('+', "Zmodem: sender CANcelled");
|
||||||
Syslog('+', "Zmodem: sender CANcelled");
|
|
||||||
return TERROR;
|
return TERROR;
|
||||||
case ZNAK:
|
case ZNAK: if ( --n < 0) {
|
||||||
if ( --n < 0) {
|
|
||||||
Syslog('+', "Zmodem: Got ZNAK");
|
Syslog('+', "Zmodem: Got ZNAK");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case TIMEOUT:
|
case TIMEOUT: if ( --n < 0) {
|
||||||
if ( --n < 0) {
|
|
||||||
Syslog('+', "Zmodem: TIMEOUT");
|
Syslog('+', "Zmodem: TIMEOUT");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case ZFILE:
|
case ZFILE: zrdata(secbuf, MAXBLOCK);
|
||||||
zrdata(secbuf, MAXBLOCK);
|
|
||||||
continue;
|
continue;
|
||||||
case ZEOF:
|
case ZEOF: if (rclhdr(Rxhdr) != rxbytes) {
|
||||||
if (rclhdr(Rxhdr) != rxbytes) {
|
|
||||||
/*
|
/*
|
||||||
* Ignore eof if it's at wrong place - force
|
* Ignore eof if it's at wrong place - force
|
||||||
* a timeout because the eof might have gone
|
* a timeout because the eof might have gone
|
||||||
@ -308,11 +299,10 @@ nxthdr:
|
|||||||
Syslog('+', "Zmodem: error closing file");
|
Syslog('+', "Zmodem: error closing file");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
fout=NULL;
|
fout = NULL;
|
||||||
Syslog('z', "rzfile: normal EOF");
|
Syslog('z', "rzfile: normal EOF");
|
||||||
return c;
|
return c;
|
||||||
case HANGUP:
|
case HANGUP: Syslog('+', "Zmodem: Lost Carrier");
|
||||||
Syslog('+', "Zmodem: Lost Carrier");
|
|
||||||
return TERROR;
|
return TERROR;
|
||||||
case TERROR: /* Too much garbage in header search error */
|
case TERROR: /* Too much garbage in header search error */
|
||||||
if (--n < 0) {
|
if (--n < 0) {
|
||||||
@ -321,29 +311,25 @@ nxthdr:
|
|||||||
}
|
}
|
||||||
zmputs(Attn);
|
zmputs(Attn);
|
||||||
continue;
|
continue;
|
||||||
case ZSKIP:
|
case ZSKIP: Modtime = 1;
|
||||||
Modtime = 1;
|
|
||||||
closeit(1);
|
closeit(1);
|
||||||
Syslog('+', "Zmodem: Sender SKIPPED file");
|
Syslog('+', "Zmodem: Sender SKIPPED file");
|
||||||
return c;
|
return c;
|
||||||
case ZDATA:
|
case ZDATA: if (rclhdr(Rxhdr) != rxbytes) {
|
||||||
if (rclhdr(Rxhdr) != rxbytes) {
|
|
||||||
if ( --n < 0) {
|
if ( --n < 0) {
|
||||||
Syslog('+', "Zmodem: Data has bad address");
|
Syslog('+', "Zmodem: Data has bad address");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
zmputs(Attn); continue;
|
zmputs(Attn);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
moredata:
|
moredata:
|
||||||
Syslog('z', "%7ld ZMODEM%s ",
|
Syslog('z', "%7ld ZMODEM%s ", rxbytes, Crc32r?" CRC-32":"");
|
||||||
rxbytes, Crc32r?" CRC-32":"");
|
|
||||||
Nopper();
|
Nopper();
|
||||||
switch (c = zrdata(secbuf, MAXBLOCK)) {
|
switch (c = zrdata(secbuf, MAXBLOCK)) {
|
||||||
case ZCAN:
|
case ZCAN: Syslog('+', "Zmodem: sender CANcelled");
|
||||||
Syslog('+', "Zmodem: sender CANcelled");
|
|
||||||
return TERROR;
|
return TERROR;
|
||||||
case HANGUP:
|
case HANGUP: Syslog('+', "Zmodem: Lost Carrier");
|
||||||
Syslog('+', "Zmodem: Lost Carrier");
|
|
||||||
return TERROR;
|
return TERROR;
|
||||||
case TERROR: /* CRC error */
|
case TERROR: /* CRC error */
|
||||||
if (--n < 0) {
|
if (--n < 0) {
|
||||||
@ -352,34 +338,30 @@ moredata:
|
|||||||
}
|
}
|
||||||
zmputs(Attn);
|
zmputs(Attn);
|
||||||
continue;
|
continue;
|
||||||
case TIMEOUT:
|
case TIMEOUT: if ( --n < 0) {
|
||||||
if ( --n < 0) {
|
|
||||||
Syslog('+', "Zmodem: TIMEOUT");
|
Syslog('+', "Zmodem: TIMEOUT");
|
||||||
return TERROR;
|
return TERROR;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case GOTCRCW:
|
case GOTCRCW: n = 20;
|
||||||
n = 20;
|
|
||||||
putsec(secbuf, Rxcount);
|
putsec(secbuf, Rxcount);
|
||||||
rxbytes += Rxcount;
|
rxbytes += Rxcount;
|
||||||
|
Syslog('z', "rxbytes %ld, will ACK", rxbytes);
|
||||||
stohdr(rxbytes);
|
stohdr(rxbytes);
|
||||||
PUTCHAR(XON);
|
PUTCHAR(XON);
|
||||||
zshhdr(4,ZACK, Txhdr);
|
zshhdr(4,ZACK, Txhdr);
|
||||||
goto nxthdr;
|
goto nxthdr;
|
||||||
case GOTCRCQ:
|
case GOTCRCQ: n = 20;
|
||||||
n = 20;
|
|
||||||
putsec(secbuf, Rxcount);
|
putsec(secbuf, Rxcount);
|
||||||
rxbytes += Rxcount;
|
rxbytes += Rxcount;
|
||||||
stohdr(rxbytes);
|
stohdr(rxbytes);
|
||||||
zshhdr(4,ZACK, Txhdr);
|
zshhdr(4,ZACK, Txhdr);
|
||||||
goto moredata;
|
goto moredata;
|
||||||
case GOTCRCG:
|
case GOTCRCG: n = 20;
|
||||||
n = 20;
|
|
||||||
putsec(secbuf, Rxcount);
|
putsec(secbuf, Rxcount);
|
||||||
rxbytes += Rxcount;
|
rxbytes += Rxcount;
|
||||||
goto moredata;
|
goto moredata;
|
||||||
case GOTCRCE:
|
case GOTCRCE: n = 20;
|
||||||
n = 20;
|
|
||||||
putsec(secbuf, Rxcount);
|
putsec(secbuf, Rxcount);
|
||||||
rxbytes += Rxcount;
|
rxbytes += Rxcount;
|
||||||
goto nxthdr;
|
goto nxthdr;
|
||||||
@ -402,14 +384,13 @@ void zmputs(char *s)
|
|||||||
|
|
||||||
while (*s) {
|
while (*s) {
|
||||||
switch (c = *s++) {
|
switch (c = *s++) {
|
||||||
case '\336':
|
case '\336': Syslog('z', "zmputs: sleep(1)");
|
||||||
Syslog('z', "zmputs: sleep(1)");
|
sleep(1);
|
||||||
sleep(1); continue;
|
continue;
|
||||||
case '\335':
|
case '\335': Syslog('z', "zmputs: send break");
|
||||||
Syslog('z', "zmputs: send break");
|
sendbrk();
|
||||||
sendbrk(); continue;
|
continue;
|
||||||
default:
|
default: PUTCHAR(c);
|
||||||
PUTCHAR(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,6 +402,13 @@ int closeit(int success)
|
|||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
Syslog('z', "closeit(%d)", success);
|
||||||
|
|
||||||
|
if ((fout == NULL) || (curfile == NULL)) {
|
||||||
|
Syslog('+', "closeit(), nothing to close");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
rc = fclose(fout);
|
rc = fclose(fout);
|
||||||
fout = NULL;
|
fout = NULL;
|
||||||
|
|
||||||
@ -455,20 +443,19 @@ int ackbibi(void)
|
|||||||
|
|
||||||
Syslog('z', "ackbibi:");
|
Syslog('z', "ackbibi:");
|
||||||
stohdr(0L);
|
stohdr(0L);
|
||||||
|
|
||||||
for (n=3; --n>=0; ) {
|
for (n=3; --n>=0; ) {
|
||||||
zshhdr(4,ZFIN, Txhdr);
|
zshhdr(4,ZFIN, Txhdr);
|
||||||
switch ((c=GETCHAR(10))) {
|
|
||||||
case 'O':
|
switch ((c = GETCHAR(10))) {
|
||||||
GETCHAR(1); /* Discard 2nd 'O' */
|
case 'O': GETCHAR(1); /* Discard 2nd 'O' */
|
||||||
Syslog('z', "Zmodem: ackbibi complete");
|
Syslog('z', "Zmodem: ackbibi complete");
|
||||||
return ZCOMPL;
|
return ZCOMPL;
|
||||||
case TERROR:
|
case TERROR:
|
||||||
case HANGUP:
|
case HANGUP: Syslog('z', "Zmodem: ackbibi got %d, ignore",c);
|
||||||
Syslog('z', "Zmodem: ackbibi got %d, ignore",c);
|
|
||||||
return 0;
|
return 0;
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
default:
|
default: Syslog('z', "Zmodem: ackbibi got '%s', continue", printablec(c));
|
||||||
Syslog('z', "Zmodem: ackbibi got '%s', continue", printablec(c));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,18 +477,29 @@ int procheader(char *Name)
|
|||||||
/* set default parameters and overrides */
|
/* set default parameters and overrides */
|
||||||
openmode = (char *)"w";
|
openmode = (char *)"w";
|
||||||
|
|
||||||
|
Syslog('z', "zmanag=%d", zmanag);
|
||||||
|
Syslog('z', "zconv=%d", zconv);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process ZMODEM remote file management requests
|
* Process ZMODEM remote file management requests
|
||||||
*/
|
*/
|
||||||
Thisbinary = (zconv != ZCNL); /* Remote ASCII override */
|
if (!Thisbinary && zconv == ZCNL) /* Remote ASCII override */
|
||||||
|
Thisbinary = FALSE;
|
||||||
|
if (zconv == ZCBIN) /* Remote Binary override */
|
||||||
|
Thisbinary = TRUE;
|
||||||
if (zmanag == ZMAPND)
|
if (zmanag == ZMAPND)
|
||||||
openmode = (char *)"a";
|
openmode = (char *)"a";
|
||||||
|
|
||||||
|
Syslog('z', "Thisbinary %s", Thisbinary ?"TRUE":"FALSE");
|
||||||
|
|
||||||
Bytesleft = DEFBYTL;
|
Bytesleft = DEFBYTL;
|
||||||
Filemode = 0;
|
Filemode = 0;
|
||||||
Modtime = 0L;
|
Modtime = 0L;
|
||||||
|
Eofseen = FALSE;
|
||||||
|
|
||||||
p = Name + 1 + strlen(Name);
|
p = Name + 1 + strlen(Name);
|
||||||
|
// FIXME: Here we must add code that checks the Name for slashes, spaces and other
|
||||||
|
// illegal characters in the filename.
|
||||||
sscanf(p, "%ld%lo%o%o%d%d%d%d", &Bytesleft, &Modtime, &Filemode, &dummy, &dummy, &dummy, &dummy, &dummy);
|
sscanf(p, "%ld%lo%o%o%d%d%d%d", &Bytesleft, &Modtime, &Filemode, &dummy, &dummy, &dummy, &dummy, &dummy);
|
||||||
strcpy(ctt, rfcdate(Modtime));
|
strcpy(ctt, rfcdate(Modtime));
|
||||||
Syslog('+', "Zmodem: \"%s\" %ld bytes, %s mode %o", Name, Bytesleft, ctt, Filemode);
|
Syslog('+', "Zmodem: \"%s\" %ld bytes, %s mode %o", Name, Bytesleft, ctt, Filemode);
|
||||||
@ -515,9 +513,15 @@ int procheader(char *Name)
|
|||||||
curfile = xstrcat(curfile, exitinfo.Name);
|
curfile = xstrcat(curfile, exitinfo.Name);
|
||||||
curfile = xstrcat(curfile, (char *)"/upl/");
|
curfile = xstrcat(curfile, (char *)"/upl/");
|
||||||
curfile = xstrcat(curfile, Name);
|
curfile = xstrcat(curfile, Name);
|
||||||
fout = fopen(curfile, openmode);
|
Syslog('z', "try open %s mode \"%s\"", curfile, openmode);
|
||||||
|
if ((fout = fopen(curfile, openmode)) == NULL) {
|
||||||
|
WriteError("$Can't open %s mode %s", curfile, openmode);
|
||||||
|
}
|
||||||
|
|
||||||
gettimeofday(&starttime, &tz);
|
gettimeofday(&starttime, &tz);
|
||||||
sbytes = rxbytes;
|
sbytes = rxbytes = 0;
|
||||||
|
|
||||||
|
Syslog('z', "result %s", fout ? "Ok":"Failed");
|
||||||
|
|
||||||
/* if (Bytesleft == rxbytes) { FIXME: if file already received, use this.
|
/* if (Bytesleft == rxbytes) { FIXME: if file already received, use this.
|
||||||
Syslog('+', "Zmodem: Skipping %s", Name);
|
Syslog('+', "Zmodem: Skipping %s", Name);
|
||||||
@ -540,6 +544,8 @@ int putsec(char *buf, int n)
|
|||||||
{
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
|
|
||||||
|
Syslog('z', "putsec %d characters %s mode", n, Thisbinary ? "binary":"ascii");
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
#include "zmmisc.h"
|
#include "zmmisc.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern char *Zendnames[];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send data subpacket RLE encoded with 32 bit FCS
|
* Send data subpacket RLE encoded with 32 bit FCS
|
||||||
*/
|
*/
|
||||||
@ -52,11 +55,15 @@ void zsdar32(char *buf, int length, int frameend)
|
|||||||
register int c, l, n;
|
register int c, l, n;
|
||||||
register unsigned long crc;
|
register unsigned long crc;
|
||||||
|
|
||||||
crc = 0xFFFFFFFFL; l = *buf++ & 0377;
|
crc = 0xFFFFFFFFL;
|
||||||
|
l = *buf++ & 0377;
|
||||||
|
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
zsendline(l); crc = updcrc32(l, crc);
|
zsendline(l);
|
||||||
|
crc = updcrc32(l, crc);
|
||||||
if (l == ZRESC) {
|
if (l == ZRESC) {
|
||||||
zsendline(1); crc = updcrc32(1, crc);
|
zsendline(1);
|
||||||
|
crc = updcrc32(1, crc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (n = 0; --length >= 0; ++buf) {
|
for (n = 0; --length >= 0; ++buf) {
|
||||||
@ -67,35 +74,46 @@ void zsdar32(char *buf, int length, int frameend)
|
|||||||
case 0: zsendline(l);
|
case 0: zsendline(l);
|
||||||
crc = updcrc32(l, crc);
|
crc = updcrc32(l, crc);
|
||||||
if (l == ZRESC) {
|
if (l == ZRESC) {
|
||||||
zsendline(0100); crc = updcrc32(0100, crc);
|
zsendline(0100);
|
||||||
|
crc = updcrc32(0100, crc);
|
||||||
}
|
}
|
||||||
l = c; break;
|
l = c; break;
|
||||||
case 1: if (l != ZRESC) {
|
case 1: if (l != ZRESC) {
|
||||||
zsendline(l); zsendline(l);
|
zsendline(l);
|
||||||
|
zsendline(l);
|
||||||
crc = updcrc32(l, crc);
|
crc = updcrc32(l, crc);
|
||||||
crc = updcrc32(l, crc);
|
crc = updcrc32(l, crc);
|
||||||
n = 0; l = c; break;
|
n = 0;
|
||||||
|
l = c;
|
||||||
|
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); crc = updcrc32(n, crc);
|
zsendline(n);
|
||||||
|
crc = updcrc32(n, crc);
|
||||||
} else {
|
} else {
|
||||||
n += 0101;
|
n += 0101;
|
||||||
zsendline(n); crc = updcrc32(n, crc);
|
zsendline(n);
|
||||||
zsendline(l); crc = updcrc32(l, crc);
|
crc = updcrc32(n, crc);
|
||||||
|
zsendline(l);
|
||||||
|
crc = updcrc32(l, crc);
|
||||||
}
|
}
|
||||||
n = 0; l = c; break;
|
n = 0;
|
||||||
|
l = c;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PUTCHAR(ZDLE); PUTCHAR(frameend);
|
PUTCHAR(ZDLE);
|
||||||
|
PUTCHAR(frameend);
|
||||||
crc = updcrc32(frameend, crc);
|
crc = updcrc32(frameend, crc);
|
||||||
|
|
||||||
crc = ~crc;
|
crc = ~crc;
|
||||||
for (length=4; --length >= 0;) {
|
for (length=4; --length >= 0;) {
|
||||||
zsendline((int)crc); crc >>= 8;
|
zsendline((int)crc);
|
||||||
|
crc >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +128,9 @@ int zrdatr32(register char *buf, int length)
|
|||||||
register char *end;
|
register char *end;
|
||||||
register int d;
|
register int d;
|
||||||
|
|
||||||
crc = 0xFFFFFFFFL; Rxcount = 0; end = buf + length;
|
crc = 0xFFFFFFFFL;
|
||||||
|
Rxcount = 0;
|
||||||
|
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) {
|
||||||
@ -119,7 +139,8 @@ crcfoo:
|
|||||||
case GOTCRCE:
|
case GOTCRCE:
|
||||||
case GOTCRCG:
|
case GOTCRCG:
|
||||||
case GOTCRCQ:
|
case GOTCRCQ:
|
||||||
case GOTCRCW: d = c; c &= 0377;
|
case GOTCRCW: d = c;
|
||||||
|
c &= 0377;
|
||||||
crc = updcrc32(c, crc);
|
crc = updcrc32(c, crc);
|
||||||
if ((c = zdlread()) & ~0377)
|
if ((c = zdlread()) & ~0377)
|
||||||
goto crcfoo;
|
goto crcfoo;
|
||||||
@ -153,17 +174,23 @@ crcfoo:
|
|||||||
crc = updcrc32(c, crc);
|
crc = updcrc32(c, crc);
|
||||||
switch (d) {
|
switch (d) {
|
||||||
case 0: if (c == ZRESC) {
|
case 0: if (c == ZRESC) {
|
||||||
d = -1; continue;
|
d = -1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
*buf++ = c; 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;
|
d = c - 035;
|
||||||
|
c = 040;
|
||||||
|
goto spaces;
|
||||||
}
|
}
|
||||||
if (c == 0100) {
|
if (c == 0100) {
|
||||||
d = 0;
|
d = 0;
|
||||||
*buf++ = ZRESC; continue;
|
*buf++ = ZRESC;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
d = c; continue;
|
d = c;
|
||||||
|
continue;
|
||||||
default: d -= 0100;
|
default: d -= 0100;
|
||||||
if (d < 1)
|
if (d < 1)
|
||||||
goto badpkt;
|
goto badpkt;
|
||||||
@ -172,7 +199,8 @@ spaces:
|
|||||||
goto badpkt;
|
goto badpkt;
|
||||||
while ( --d >= 0)
|
while ( --d >= 0)
|
||||||
*buf++ = c;
|
*buf++ = c;
|
||||||
d = 0; continue;
|
d = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,13 +50,11 @@ void initzsendmsk(char *);
|
|||||||
static FILE *in;
|
static FILE *in;
|
||||||
static int Eofseen; /* EOF seen on input set by zfilbuf */
|
static int Eofseen; /* EOF seen on input set by zfilbuf */
|
||||||
static int Rxflags = 0;
|
static int Rxflags = 0;
|
||||||
static int Usevhdrs;
|
|
||||||
static int Wantfcs32=TRUE; /* Want to send 32 bit FCS */
|
static int Wantfcs32=TRUE; /* Want to send 32 bit FCS */
|
||||||
static int Rxbuflen;
|
static int Rxbuflen;
|
||||||
static unsigned Txwindow; /* Control the size of the transmitted window */
|
static unsigned Txwindow; /* Control the size of the transmitted window */
|
||||||
static unsigned Txwspac; /* Spacing between zcrcq requests */
|
static unsigned Txwspac; /* Spacing between zcrcq requests */
|
||||||
static unsigned Txwcnt; /* Counter used to space ack requests */
|
static unsigned Txwcnt; /* Counter used to space ack requests */
|
||||||
//static long Tframlen = 0; /* Override for tx frame length */
|
|
||||||
static int blklen = 128; /* Length of transmitted records */
|
static int blklen = 128; /* Length of transmitted records */
|
||||||
static int blkopt; /* Override value for zmodem blklen */
|
static int blkopt; /* Override value for zmodem blklen */
|
||||||
static int errors;
|
static int errors;
|
||||||
@ -75,8 +73,9 @@ struct timezone tz;
|
|||||||
|
|
||||||
extern unsigned long sentbytes;
|
extern unsigned long sentbytes;
|
||||||
extern int Rxhlen;
|
extern int Rxhlen;
|
||||||
extern void get_frame_buffer(void);
|
|
||||||
extern void free_frame_buffer(void);
|
extern char *txbuf;
|
||||||
|
extern char *frametypes[];
|
||||||
|
|
||||||
|
|
||||||
int zmsndfiles(down_list *lst)
|
int zmsndfiles(down_list *lst)
|
||||||
|
Reference in New Issue
Block a user