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); sleep(2);
if (uProtInternal) { 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); sprintf(temp, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
chdir(temp); 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(); Home();
} else { } else {
Syslog('!', "Warning internal protocol %s not supported", sProtName); 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 lastsent; /* Last char we sent */
static int Not8bit; /* Seven bits seen on header */ static int Not8bit; /* Seven bits seen on header */
static char zsendline_tab[256];
extern unsigned Baudrate; extern unsigned Baudrate;
@ -688,33 +690,65 @@ void zputhex(register int c)
*/ */
void zsendline(int c) void zsendline(int c)
{ {
/* Quick check for non control characters */ switch(zsendline_tab[(unsigned) (c&=0377)]) {
if (c & 0140) case 0:
PUTCHAR(lastsent = c); PUTCHAR(lastsent = c);
else { break;
switch (c &= 0377) { case 1:
case ZDLE: PUTCHAR(ZDLE); PUTCHAR(ZDLE);
PUTCHAR(lastsent = (c ^= 0100)); c ^= 0100;
break; PUTCHAR(lastsent = c);
case 015: break;
case 0215: if (!Zctlesc && (lastsent & 0177) != '@') case 2:
goto sendit; if ((lastsent & 0177) != '@') {
/* **** FALL THRU TO **** */ PUTCHAR(lastsent = c);
case 020: } else {
case 021: PUTCHAR(ZDLE);
case 023: c ^= 0100;
case 0220: PUTCHAR(lastsent = c);
case 0221: }
case 0223: PUTCHAR(ZDLE); break;
c ^= 0100; }
sendit: }
PUTCHAR(lastsent = c);
break;
default: if (Zctlesc && ! (c & 0140)) {
PUTCHAR(ZDLE); void zsendline_init(void)
c ^= 0100; {
} int i;
PUTCHAR(lastsent = c);
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; enum zm_type_enum protocol;
//void get_frame_buffer(void);
//void free_frame_buffer(void);
void zsbhdr(int, char *); void zsbhdr(int, char *);
void zshhdr(int, char *); void zshhdr(int, char *);
void zsdata(register char *, int, int); void zsdata(register char *, int, int);
@ -160,6 +158,7 @@ void zsendline(int);
int zdlread(void); int zdlread(void);
void stohdr(long); void stohdr(long);
long rclhdr(register char *); long rclhdr(register char *);
void zsendline_init(void);
#define FTOFFSET 16 #define FTOFFSET 16

View File

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

View File

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

View File

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