This commit is contained in:
Matt Jenkins
2014-04-11 11:57:30 +01:00
4 changed files with 75 additions and 32 deletions

View File

@@ -4,11 +4,12 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=8192 -DNFGVMIN -DSEGMENTS=32
CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=4096 -DNFGVMIN -DSEGMENTS=2
#CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=1024 -DNFGVMIN -DSEGMENTS=8
SRCS = rz.c sz.c
OBJS = rz.o sz.o
MAN = rz.0 sz.0
MAN = rz.0 sz.0
MANSRC = rz.1 sz.1
all: rz sz $(MAN)

View File

@@ -117,6 +117,9 @@
#define HOWMANY 133
#endif
// PITO:
#define readline_timeout 1
/* Ward Christensen / CP/M parameters - Don't change these! */
#define ENQ 005
#define CAN ('X'&037)
@@ -209,6 +212,7 @@ char zconv; /* ZMODEM file conversion request */
char zmanag; /* ZMODEM file management request */
char ztrans; /* ZMODEM file transport request */
int Zctlesc; /* Encode control characters */
int Zrwindow = 1400; /* RX window size (controls garbage count) */
jmp_buf tohere; /* For the interrupt on RX timeout */
@@ -358,15 +362,22 @@ char *argv[];
usage()
{
cucheck();
fprintf(stderr,"Usage: rz [-abeuvy] (ZMODEM)\n");
fprintf(stderr,"Usage: rz [-+abDepqtuvy] (ZMODEM)\n");
fprintf(stderr,"or rb [-abuvy] (YMODEM)\n");
fprintf(stderr,"or rx [-abcv] file (XMODEM or XMODEM-1k)\n");
fprintf(stderr," -+ append transmitted data to an existing file\n");
fprintf(stderr," -a ASCII transfer (strip CR)\n");
fprintf(stderr," -b Binary transfer for all files\n");
#ifndef vax11c
fprintf(stderr," -c Use 16 bit CRC (XMODEM)\n");
#endif
fprintf(stderr," -D Output file to /dev/null\n");
fprintf(stderr," -e Escape control characters (ZMODEM)\n");
fprintf(stderr," -p Skip file if destination exists\n");
fprintf(stderr," -q Quiet suppresses verbosity\n");
fprintf(stderr," -t tim Change Rxtimeout to tim tenths of seconds (10-1000)\n");
fprintf(stderr," -u Do not make file pathnames lower case \n");
fprintf(stderr," -w n Rx window size to n bytes (ZMODEM)\n");
fprintf(stderr," -v Verbose more v's give more info\n");
fprintf(stderr," -y Yes, clobber existing file if any\n");
fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
@@ -466,7 +477,7 @@ char *rpn; /* receive a pathname */
register c;
#ifdef NFGVMIN
readline(1);
readline(readline_timeout);
#else
purgeline();
#endif
@@ -480,7 +491,7 @@ et_tu:
zperr( "Pathname fetch returned %d", c);
sendline(ACK);
Lleft=0; /* Do read next time ... */
readline(1);
readline(readline_timeout);
goto et_tu;
}
return ERROR;
@@ -565,20 +576,20 @@ int maxtime;
if (firstch==SOH) {
Blklen=128;
get2:
sectcurr=readline(1);
if ((sectcurr+(oldcrc=readline(1)))==0377) {
sectcurr=readline(readline_timeout);
if ((sectcurr+(oldcrc=readline(readline_timeout)))==0377) {
oldcrc=checksum=0;
for (p=rxbuf,wcj=Blklen; --wcj>=0; ) {
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
oldcrc=updcrc(firstch, oldcrc);
checksum += (*p++ = firstch);
}
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
if (Crcflg) {
oldcrc=updcrc(firstch, oldcrc);
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
oldcrc=updcrc(firstch, oldcrc);
if (oldcrc & 0xFFFF)
@@ -600,7 +611,7 @@ get2:
}
/* make sure eot really is eot and not just mixmash */
#ifdef NFGVMIN
else if (firstch==EOT && readline(1)==TIMEOUT)
else if (firstch==EOT && readline(readline_timeout)==TIMEOUT)
return WCEOT;
#else
else if (firstch==EOT && Lleft==0)
@@ -626,7 +637,7 @@ bilge:
humbug:
Lastrx=0;
while(readline(1)!=TIMEOUT)
while(readline(readline_timeout)!=TIMEOUT)
;
if (Firstsec) {
sendline(Crcflg?WANTCRC:NAK);
@@ -650,10 +661,12 @@ humbug:
* timeout is in tenths of seconds
*/
readline(timeout)
int timeout;
unsigned int timeout;
{
register n;
unsigned int n;
register char *p;
static char *cdq; /* pointer for removing chars from linbuf */
int c;
if (--Lleft >= 0) {
if (Verbose > 8) {
@@ -661,9 +674,11 @@ int timeout;
}
return (*cdq++ & 0377);
}
n = timeout/10;
if (n < 2)
n = 3;
n = timeout/10;
if (n < 2 && timeout!=1)
n = 3;
else if (n==0)
n=1;
if (Verbose > 5)
fprintf(stderr, "Calling read: alarm=%d Readnum=%d ",
n, Readnum);
@@ -677,6 +692,7 @@ int timeout;
return TIMEOUT;
}
signal(SIGALRM, alrm); alarm(n);
//errno=0;
Lleft=read(0, cdq=linbuf, Readnum);
alarm(0);
if (Verbose > 5) {
@@ -684,10 +700,22 @@ int timeout;
}
if (Lleft < 1)
return TIMEOUT;
--Lleft;
if (Verbose > 8) {
fprintf(stderr, "%02x ", *cdq&0377);
for (p=cdq, n = Lleft; --n >= 0; ) {
fprintf(stderr, "%02x ", *p++ &0377);
}
fprintf(stderr, "\n");
for (p=cdq, n = Lleft; --n >= 0; ) {
c = *p++ & 0177;
if (!isprint(c))
c = '.';
fprintf(stderr, " %c ", c);
}
fprintf(stderr, "\n");
}
--Lleft;
return (*cdq++ & 0377);
}
@@ -1483,7 +1511,7 @@ ackbibi()
zshhdr(4,ZFIN, Txhdr);
switch (readline(100)) {
case 'O':
readline(1); /* Discard 2nd 'O' */
readline(readline_timeout); /* Discard 2nd 'O' */
vfile("ackbibi complete");
return;
case RCDO: