added zsendline_s function for buffered output

This commit is contained in:
Michiel Broek 2004-11-21 12:51:04 +00:00
parent f0682afad5
commit 5c14f4e833

View File

@ -61,7 +61,7 @@ static int zrhhdr(char*);
static int zgethex(void); static int zgethex(void);
static int zgeth1(void); static int zgeth1(void);
static void garbitch(void); static void garbitch(void);
static inline void zsendline_s(const char *, int);
#include "../config.h" #include "../config.h"
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
@ -278,12 +278,9 @@ void zsda32(register char *buf, int length, int frameend)
register unsigned long crc; register unsigned long crc;
crc = 0xFFFFFFFFL; crc = 0xFFFFFFFFL;
zsendline_s(buf, length);
for (;--length >= 0; ++buf) { for (;--length >= 0; ++buf) {
c = *buf & 0377; c = *buf & 0377;
if (c & 0140)
PUTCHAR(lastsent = c);
else
zsendline(c);
crc = updcrc32(c, crc); crc = updcrc32(c, crc);
} }
PUTCHAR(ZDLE); PUTCHAR(ZDLE);
@ -295,6 +292,11 @@ void zsda32(register char *buf, int length, int frameend)
zsendline((int)crc); zsendline((int)crc);
crc >>= 8; crc >>= 8;
} }
if (frameend == ZCRCW) {
PUTCHAR(XON);
fflush(stdout);
}
} }
@ -713,6 +715,53 @@ void zsendline(int c)
static inline void zsendline_s(const char *s, int count)
{
const char *end = s + count;
while (s != end) {
int last_esc = 0;
const char *t = s;
while (t != end) {
last_esc = zsendline_tab[(unsigned) ((*t) & 0377)];
if (last_esc)
break;
t++;
}
if (t != s) {
PUT((char *)s, (t-s));
lastsent = t[-1];
s = t;
}
if (last_esc) {
int c = *s;
switch (last_esc) {
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;
}
s++;
}
}
}
void zsendline_init(void) void zsendline_init(void)
{ {
int i; int i;