added zsendline_tab

This commit is contained in:
Michiel Broek 2004-11-21 12:06:55 +00:00
parent efccc0441a
commit f0682afad5
6 changed files with 86 additions and 38 deletions

View File

@ -259,10 +259,15 @@ int download(down_list *download_list)
sleep(2);
if (uProtInternal) {
if (strncasecmp(sProtName, "zmodem", 6) == 0) {
if (strncasecmp(sProtName, "zmodem 8k", 9) == 0) {
sprintf(temp, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
chdir(temp);
maxrc = zmsndfiles(download_list);
maxrc = zmsndfiles(download_list, TRUE);
Home();
} else if (strncasecmp(sProtName, "zmodem", 6) == 0) {
sprintf(temp, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
chdir(temp);
maxrc = zmsndfiles(download_list, FALSE);
Home();
} else {
Syslog('!', "Warning internal protocol %s not supported", sProtName);

View File

@ -78,6 +78,8 @@ char *txbuf=NULL;
static int lastsent; /* Last char we sent */
static int Not8bit; /* Seven bits seen on header */
static char zsendline_tab[256];
extern unsigned Baudrate;
@ -688,33 +690,65 @@ void zputhex(register int c)
*/
void zsendline(int c)
{
/* Quick check for non control characters */
if (c & 0140)
PUTCHAR(lastsent = c);
else {
switch (c &= 0377) {
case ZDLE: PUTCHAR(ZDLE);
PUTCHAR(lastsent = (c ^= 0100));
break;
case 015:
case 0215: if (!Zctlesc && (lastsent & 0177) != '@')
goto sendit;
/* **** FALL THRU TO **** */
case 020:
case 021:
case 023:
case 0220:
case 0221:
case 0223: PUTCHAR(ZDLE);
c ^= 0100;
sendit:
PUTCHAR(lastsent = c);
break;
default: if (Zctlesc && ! (c & 0140)) {
PUTCHAR(ZDLE);
c ^= 0100;
}
PUTCHAR(lastsent = c);
switch(zsendline_tab[(unsigned) (c&=0377)]) {
case 0:
PUTCHAR(lastsent = c);
break;
case 1:
PUTCHAR(ZDLE);
c ^= 0100;
PUTCHAR(lastsent = c);
break;
case 2:
if ((lastsent & 0177) != '@') {
PUTCHAR(lastsent = c);
} else {
PUTCHAR(ZDLE);
c ^= 0100;
PUTCHAR(lastsent = c);
}
break;
}
}
void zsendline_init(void)
{
int i;
Syslog('z', "zsendline_init()");
for (i = 0; i < 256; i++) {
if (i & 0140)
zsendline_tab[i]=0;
else {
switch(i) {
case ZDLE:
case XOFF: /* ^Q */
case XON: /* ^S */
case (XOFF | 0200):
case (XON | 0200):
zsendline_tab[i]=1;
break;
case 020: /* ^P */
case 0220:
zsendline_tab[i]=1;
break;
case 015:
case 0215:
if (Zctlesc)
zsendline_tab[i]=1;
else
zsendline_tab[i]=2;
break;
default:
if (Zctlesc)
zsendline_tab[i]=1;
else
zsendline_tab[i]=0;
}
}
}
}

View File

@ -147,8 +147,6 @@ enum zm_type_enum {
enum zm_type_enum protocol;
//void get_frame_buffer(void);
//void free_frame_buffer(void);
void zsbhdr(int, char *);
void zshhdr(int, char *);
void zsdata(register char *, int, int);
@ -160,6 +158,7 @@ void zsendline(int);
int zdlread(void);
void stohdr(long);
long rclhdr(register char *);
void zsendline_init(void);
#define FTOFFSET 16

View File

@ -83,6 +83,7 @@ int zmrcvfiles(void)
Syslog('+', "Zmodem: start Zmodem receive");
zsendline_init();
if (secbuf == NULL)
secbuf = malloc(MAXBLOCK+1);
tryzhdrtype = ZRINIT;

View File

@ -72,7 +72,7 @@ static char Myattn[]={0};
static long skipsize;
struct timeval starttime, endtime;
struct timezone tz;
static int use8k = FALSE;
extern unsigned long sentbytes;
extern int Rxhlen;
@ -82,14 +82,16 @@ extern char *frametypes[];
extern unsigned Baudrate;
int zmsndfiles(down_list *lst)
int zmsndfiles(down_list *lst, int try8)
{
int rc, maxrc = 0;
down_list *tmpf;
Syslog('+', "Zmodem: start Zmodem send");
Syslog('+', "Zmodem: start Zmodem%s send", try8 ? "-8K":"");
use8k = try8;
protocol = ZM_ZMODEM;
zsendline_init();
if ((rc = initsend())) {
if (txbuf)
free(txbuf);
@ -187,7 +189,7 @@ static int sendzfile(char *rn)
fl.l_start = 0L;
fl.l_len = 0L;
if (txbuf == NULL)
txbuf = malloc(MAXBLOCK);
txbuf = malloc(MAXBLOCK + 1024);
skipsize = 0L;
if ((in = fopen(rn, "r")) == NULL) {
@ -252,7 +254,11 @@ int getzrxinit(void)
case ZRINIT:
Rxflags = 0377 & Rxhdr[ZF0];
Txfcs32 = (Wantfcs32 && (Rxflags & CANFC32));
int old = Zctlesc;
Zctlesc |= Rxflags & TESCCTL;
/* update table - was initialised to not escape */
if (Zctlesc && !old)
zsendline_init();
Rxbuflen = (0377 & Rxhdr[ZP0])+((0377 & Rxhdr[ZP1])<<8);
if ( !(Rxflags & CANFDX))
@ -437,7 +443,10 @@ int zsendfdata(void)
int junkcount; /* Counts garbage chars received by TX */
int maxblklen, goodblks = 0, goodneeded = 8;
maxblklen = 1024; // FIXME: 8K variant set this to 8K
if (use8k)
maxblklen = 8192;
else
maxblklen = 1024;
Syslog('z', "zsendfdata() maxblklen=%d", maxblklen);
junkcount = 0;

View File

@ -4,7 +4,7 @@
/* $Id$ */
int zmsndfiles(down_list *);
int zmsndfiles(down_list *, int);
#endif