Zmodem changes
This commit is contained in:
parent
8b1194af26
commit
a179a29b53
@ -53,7 +53,6 @@ struct tchars oldtch, tch;
|
||||
|
||||
int hanged_up = 0;
|
||||
unsigned Baudrate = 9600; /* Default, set by first io_mode() call */
|
||||
int current_mode = -1;
|
||||
|
||||
|
||||
|
||||
@ -176,12 +175,6 @@ int io_mode(int fd, int n)
|
||||
static int did0 = FALSE;
|
||||
|
||||
Syslog('t', "io_mode(%d, %d) (%s)", fd, n, io_names[n]);
|
||||
if (n == current_mode) {
|
||||
Syslog('t', "io_mode already set");
|
||||
return 0;
|
||||
}
|
||||
|
||||
current_mode = n;
|
||||
|
||||
switch(n) {
|
||||
|
||||
@ -327,7 +320,6 @@ int io_mode(int fd, int n)
|
||||
* ^O, ^R, ^W).
|
||||
*/
|
||||
tty.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
|
||||
// tty.c_lflag = 0; /* Transparant input */
|
||||
tty.c_oflag = 0; /* Transparent output */
|
||||
|
||||
tty.c_cflag &= ~( CSIZE | PARENB ); /* Same baud rate, disable parity */
|
||||
@ -386,7 +378,7 @@ void sendbrk(void)
|
||||
|
||||
if (isatty(0)) {
|
||||
#ifdef USE_TERMIOS
|
||||
tcsendbreak(0, 200);
|
||||
tcsendbreak(0, 0);
|
||||
#endif
|
||||
#ifdef USE_TERMIO
|
||||
ioctl(0, TCSBRK, 0);
|
||||
|
@ -58,6 +58,7 @@ char *ttystat[]= {(char *)"Ok",
|
||||
/*
|
||||
* private r/w functions
|
||||
*/
|
||||
static int tty_read(char *, int, int);
|
||||
static int tty_read(char *buf, int size, int tot)
|
||||
{
|
||||
time_t now;
|
||||
@ -126,8 +127,8 @@ static int tty_read(char *buf, int size, int tot)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tty_put(char *buf, int size)
|
||||
int tty_write(char *, int);
|
||||
int tty_write(char *buf, int size)
|
||||
{
|
||||
int result;
|
||||
|
||||
@ -137,14 +138,14 @@ int tty_put(char *buf, int size)
|
||||
if (result != size) {
|
||||
if (hanged_up || (errno == EPIPE) || (errno == ECONNRESET)) {
|
||||
tty_status = STAT_HANGUP;
|
||||
WriteError("tty_put: hanged_up flag");
|
||||
WriteError("tty_write: hanged_up flag");
|
||||
} else {
|
||||
tty_status=STAT_ERROR;
|
||||
Syslog('!', "tty_put: error flag");
|
||||
Syslog('!', "tty_write: error flag");
|
||||
}
|
||||
}
|
||||
if (tty_status)
|
||||
Syslog('t', "tty_put: error %s", ttystat[tty_status]);
|
||||
Syslog('t', "tty_write: error %s", ttystat[tty_status]);
|
||||
|
||||
return -tty_status;
|
||||
}
|
||||
@ -184,6 +185,13 @@ void tty_flushin(void)
|
||||
}
|
||||
|
||||
|
||||
void tty_flushout(void)
|
||||
{
|
||||
tcdrain(1);
|
||||
// tcflush(1, TCOFLUSH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tty_getc(int tot)
|
||||
{
|
||||
@ -207,7 +215,41 @@ int tty_putc(int c)
|
||||
{
|
||||
char buf = c;
|
||||
|
||||
return tty_put(&buf, 1);
|
||||
return tty_write(&buf, 1);
|
||||
}
|
||||
|
||||
|
||||
int tty_get(char *buf, int size, int tot)
|
||||
{
|
||||
int result=0;
|
||||
|
||||
if (left >= size) {
|
||||
memcpy(buf,next,size);
|
||||
next += size;
|
||||
left -= size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (left > 0) {
|
||||
memcpy(buf,next,left);
|
||||
buf += left;
|
||||
next += left;
|
||||
size -= left;
|
||||
left=0;
|
||||
}
|
||||
|
||||
while ((result=tty_read(buf,size,tot)) > 0) {
|
||||
buf += result;
|
||||
size -= result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tty_put(char *buf, int size)
|
||||
{
|
||||
return tty_write(buf,size);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#define TCHECK() tty_check()
|
||||
#define FLUSHIN() tty_flushin()
|
||||
#define FLUSHOUT() tty_flushout()
|
||||
#define PUTCHAR(x) tty_putc(x)
|
||||
#define PUT(x,y) tty_put(x,y)
|
||||
#define PUTSTR(x) tty_put(x,strlen(x))
|
||||
@ -79,8 +80,9 @@ int tty_status;
|
||||
int tty_check(void);
|
||||
int tty_getc(int);
|
||||
int tty_putc(int);
|
||||
int tty_put(char*, int);
|
||||
int tty_put(char *, int);
|
||||
int tty_get(char *, int, int);
|
||||
void tty_flushin(void);
|
||||
|
||||
void tty_flushout(void);
|
||||
|
||||
#endif
|
||||
|
@ -201,7 +201,7 @@ void zsbhdr(int type, char *shdr)
|
||||
BUFFER_FLUSH();
|
||||
|
||||
if (type != ZDATA)
|
||||
fflush(stdout);
|
||||
FLUSHOUT();
|
||||
}
|
||||
|
||||
|
||||
@ -274,7 +274,7 @@ void zshhdr(int type, char *shdr)
|
||||
BUFFER_BYTE(021);
|
||||
|
||||
BUFFER_FLUSH();
|
||||
fflush(stdout);
|
||||
FLUSHOUT();
|
||||
}
|
||||
|
||||
|
||||
@ -313,7 +313,7 @@ void zsdata(register char *buf, int length, int frameend)
|
||||
BUFFER_FLUSH();
|
||||
|
||||
if (frameend != ZCRCG)
|
||||
fflush(stdout);
|
||||
FLUSHOUT();
|
||||
}
|
||||
|
||||
|
||||
@ -488,14 +488,7 @@ startover:
|
||||
cancount = 5;
|
||||
tmcount = 5;
|
||||
again:
|
||||
/*
|
||||
* Return immediate ERROR if ZCRCW sequence seen
|
||||
*/
|
||||
// if (((c = GETCHAR(Rxtimeout)) < 0) && (c != TIMEOUT))
|
||||
// goto fifi;
|
||||
// else {
|
||||
// switch(c) {
|
||||
switch (c = GETCHAR(Rxtimeout)) {
|
||||
switch (c = GETCHAR(Rxtimeout)) {
|
||||
case 021:
|
||||
case 0221: goto again;
|
||||
case HANGUP: goto fifi;
|
||||
@ -542,8 +535,7 @@ agn2:
|
||||
Not8bit = c;
|
||||
case ZPAD: /* This is what we want. */
|
||||
break;
|
||||
}
|
||||
// }
|
||||
}
|
||||
cancount = 5;
|
||||
|
||||
splat:
|
||||
@ -756,12 +748,19 @@ void zsendline(int c)
|
||||
BUFFER_BYTE(ZDLE);
|
||||
BUFFER_BYTE(lastsent = (c ^= 0100));
|
||||
break;
|
||||
case 015:
|
||||
case 0215:
|
||||
if (!Zctlesc && (lastsent & 0177) != '@')
|
||||
goto sendit;
|
||||
/* Fall thru */
|
||||
case 020:
|
||||
case 021:
|
||||
case 023:
|
||||
case 0221:
|
||||
case 0223:
|
||||
BUFFER_BYTE(ZDLE);
|
||||
c ^= 0100;
|
||||
sendit:
|
||||
BUFFER_BYTE(lastsent = c);
|
||||
break;
|
||||
default:
|
||||
|
@ -234,15 +234,13 @@ static int sendzfile(char *rn)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Syslog('+', "Zmodem: send \"%s\"", MBSE_SS(rn));
|
||||
Syslog('+', "Zmodem: size %lu bytes, dated %s", (unsigned int)st.st_size, rfcdate(st.st_mtime));
|
||||
Syslog('+', "Zmodem: send \"%s\", %lu bytes, dated %s", MBSE_SS(rn), (unsigned int)st.st_size, rfcdate(st.st_mtime));
|
||||
gettimeofday(&starttime, &tz);
|
||||
|
||||
snprintf(txbuf,MAXBLOCK + 1024,"%s %u %o %o 0 0 0", rn,
|
||||
(unsigned int)st.st_size, (int)st.st_mtime + (int)(st.st_mtime % 2), st.st_mode);
|
||||
bufl = strlen(txbuf);
|
||||
*(strchr(txbuf,' ')) = '\0'; /*hope no blanks in filename*/
|
||||
Syslog('z', "txbuf \"%s\"", printable(txbuf, 0));
|
||||
|
||||
Eofseen = 0;
|
||||
rc = zsendfile(txbuf,bufl);
|
||||
|
Reference in New Issue
Block a user