openbsd-ports/comms/rzsz/patches/patch-ac
kevlo bc862a5c36 Mark it unbroken and update to 3.54.
Change the MAINTAINER to kevlo@
1999-11-30 07:57:48 +00:00

212 lines
5.8 KiB
Plaintext
Executable File

--- rz.c.orig Tue Nov 30 14:44:57 1999
+++ rz.c Tue Nov 30 15:48:37 1999
@@ -132,9 +132,8 @@
static char canistr[] = {
24,24,24,24,24,24,24,24,24,24,0
};
-
+ purgeline(); /* Do read next time ... */
zmputs(canistr);
- Lleft=0; /* Do read next time ... */
}
/*
@@ -185,6 +184,7 @@
char ztrans; /* ZMODEM file transport request */
int Zctlesc; /* Encode control characters */
int Zrwindow = 1400; /* RX window size (controls garbage count) */
+int log_to_screen = 0; /* Don't make log file */
/*
* Log an error
@@ -195,9 +195,9 @@
{
if (Verbose <= 0)
return;
- fprintf(stderr, "Retry %d: ", errors);
- fprintf(stderr, s);
- fprintf(stderr, "\n");
+ fprintf(Logstream, "Retry %d: ", errors);
+ fprintf(Logstream, s);
+ fprintf(Logstream, "\n");
}
void
@@ -234,7 +234,7 @@
if (Zmodem)
zmputs(Attn);
canit(); mode(0);
- fprintf(stderr, "rz: caught signal %d; exiting", n);
+ fprintf(Logstream, "rz: caught signal %d; exiting\n", n);
exit(3);
}
@@ -297,6 +297,9 @@
Zrwindow = atoi(*++argv);
}
break;
+ case 'V':
+ log_to_screen = 1;
+ /* fall */
case 'v':
++Verbose; break;
case 'y':
@@ -318,14 +321,14 @@
usage();
if (Batch && npats)
usage();
- if (Verbose) {
- if (freopen(LOGFILE, "a", stderr)==NULL)
- if (freopen(LOGFILE2, "a", stderr)==NULL) {
- fprintf(stderr, "Can't open log file!\n");
+ if (Verbose && !log_to_screen) {
+ if ((Logstream = fopen(LOGFILE, "a"))==NULL)
+ if ((Logstream = fopen(LOGFILE2, "a"))==NULL) {
+ fprintf(stderr, "Can't open log file!\n");
exit(2);
}
- setbuf(stderr, NULL);
- fprintf(stderr, "argv[0]=%s Progname=%s\n", virgin, Progname);
+ setbuf(Logstream, NULL);
+ fprintf(Logstream, "argv[0]=%s Progname=%s\n", virgin, Progname);
}
vfile("%s %s for %s tty=%s\n", Progname, VERSION, OS, Nametty);
mode(1);
@@ -342,8 +345,11 @@
}
if (exitcode && !Zmodem) /* bellow again with all thy might. */
canit();
- if (endmsg[0])
+ if (endmsg[0]) {
fprintf(stderr, " %s: %s\r\n", Progname, endmsg);
+ if (Verbose)
+ fprintf(Logstream, "%s\r\n", endmsg);
+ }
fprintf(stderr, "%s %s finished.\r\n", Progname, VERSION);
fflush(stderr);
if(exitcode) {
@@ -374,10 +380,10 @@
{
fprintf(stderr,
"Receive Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\n\n");
- fprintf(stderr,"Usage: rz [-v] [-wN] [-tT] (ZMODEM)\n");
- fprintf(stderr,"or rb [-avy] [-tT] (YMODEM)\n");
- fprintf(stderr,"or rc [-avy] [-tT] file (XMODEM-CRC)\n");
- fprintf(stderr,"or rx [-avy] [-tT] file (XMODEM)\n\n");
+ fprintf(stderr,"Usage: rz [-vV] [-wN] [-tT] (ZMODEM)\n");
+ fprintf(stderr,"or rb [-avVy] [-tT] (YMODEM)\n");
+ fprintf(stderr,"or rc [-avVy] [-tT] file (XMODEM-CRC)\n");
+ fprintf(stderr,"or rx [-avVy] [-tT] file (XMODEM)\n\n");
fprintf(stderr,
"Supports the following incoming ZMODEM options given to the sending program:\n\
compression (-Z), binary (-b), ASCII CR/LF>NL (-a), newer(-n),\n\
@@ -471,13 +477,13 @@
et_tu:
Firstsec=TRUE; Eofseen=FALSE;
+ purgeline(); /* Do read next time ... */
sendline(Crcflg?WANTCRC:NAK); flushmo();
- Lleft=0; /* Do read next time ... */
switch (c = wcgetsec(rpn, 100)) {
case WCEOT:
zperr2( "Pathname fetch returned %d", c);
+ purgeline(); /* Do read next time ... */
sendline(ACK); flushmo();
- Lleft=0; /* Do read next time ... */
readline(1);
goto et_tu;
case 0:
@@ -502,9 +508,9 @@
sendchar=Crcflg?WANTCRC:NAK;
for (;;) {
+ purgeline(); /* Do read next time ... */
sendline(sendchar); /* send it now, we're ready! */
flushmo();
- Lleft=0; /* Do read next time ... */
sectcurr=wcgetsec(secbuf, (sectnum&0177)?50:130);
if (sectcurr==(sectnum+1 &0377)) {
sectnum++;
@@ -523,8 +529,8 @@
else if (sectcurr==WCEOT) {
if (closeit())
return ERROR;
+ purgeline(); /* Do read next time ... */
sendline(ACK); flushmo();
- Lleft=0; /* Do read next time ... */
++Totfiles;
return OK;
}
@@ -624,11 +630,11 @@
while(readline(1)!=TIMEOUT)
;
if (Firstsec) {
+ purgeline(); /* Do read next time ... */
sendline(Crcflg?WANTCRC:NAK); flushmo();
- Lleft=0; /* Do read next time ... */
} else {
+ purgeline(); /* Do read next time ... */
maxtime=40; sendline(NAK); flushmo();
- Lleft=0; /* Do read next time ... */
}
}
/* try to stop the bubble machine. */
@@ -683,9 +689,9 @@
++Thisbinary;
++Totfiles; Totbytes += Bytesleft;
if (Verbose) {
- fprintf(stderr, "Incoming: %s %ld %lo %o\n",
+ fprintf(Logstream, "Incoming: %s %ld %lo %o\n",
name, Bytesleft, Modtime, Filemode);
- fprintf(stderr, "YMODEM header: %s\n", p);
+ fprintf(Logstream, "YMODEM header: %s\n", p);
}
}
@@ -706,7 +712,7 @@
zmanag &= ZMMASK;
if (zmanag==ZMPROT)
goto skipfile;
- vfile("Current %s is %ld %lo", name, f.st_size, f.st_mtime);
+ vfile("Current %s is %ld %lo", name, (long)f.st_size, f.st_mtime);
if (Thisbinary && zconv==ZCRESUM) {
rxbytes = f.st_size & ~511;
if (Bytesleft < rxbytes) {
@@ -953,7 +959,7 @@
if (Restricted) {
if (fopen(name, "r") != NULL) {
canit();
- fprintf(stderr, "\r\nrz: %s exists\n", name);
+ fprintf(stderr, "\r\nrz: %s exists\r\n", name);
bibi(-1);
}
/* restrict pathnames to current tree or uucppublic */
@@ -1072,6 +1078,10 @@
return ERROR;
}
#endif
+#ifndef BIG_SECURITY_HOLE
+ sprintf(endmsg, "ZCOMMAND Denied.");
+ return ERROR;
+#else
cmdzack1flg = Rxhdr[ZF0];
if (zrdata(secbuf, 1024) == GOTCRCW) {
void exec2();
@@ -1091,6 +1101,7 @@
return ZCOMPL;
}
zshhdr(4,ZNAK, Txhdr); goto again;
+#endif
case ZCOMPL:
goto again;
default:
@@ -1245,7 +1256,7 @@
}
moredata:
if (Verbose>1)
- fprintf(stderr, "%7ld ZMODEM%s\n",
+ fprintf(Logstream, "%7ld ZMODEM%s\n",
rxbytes, Crc32r?" CRC-32":"");
#ifdef SEGMENTS
if (chinseg >= (1024 * SEGMENTS)) {