openbsd-ports/comms/rzsz/patches/patch-ab
1998-04-25 23:25:24 +00:00

328 lines
8.6 KiB
Plaintext
Executable File

*** rz.c.orig Fri Nov 21 13:13:51 1997
--- rz.c Fri Nov 21 13:13:51 1997
***************
*** 174,179 ****
--- 174,181 ----
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
*/
***************
*** 205,213 ****
{
if (Verbose <= 0)
return;
! fprintf(stderr, "Retry %d: ", errors);
! fprintf(stderr, s, p, u);
! fprintf(stderr, "\n");
}
#include "zm.c"
--- 207,215 ----
{
if (Verbose <= 0)
return;
! fprintf(Logstream, "Retry %d: ", errors);
! fprintf(Logstream, s, p, u);
! fprintf(Logstream, "\n");
}
#include "zm.c"
***************
*** 222,228 ****
if (Zmodem)
zmputs(Attn);
canit(); mode(0);
! fprintf(stderr, "rz: caught signal %d; exiting", n);
exit(3);
}
--- 224,230 ----
if (Zmodem)
zmputs(Attn);
canit(); mode(0);
! fprintf(Logstream, "rz: caught signal %d; exiting\n", n);
exit(3);
}
***************
*** 281,286 ****
--- 283,291 ----
Zrwindow = atoi(*++argv);
}
break;
+ case 'V':
+ log_to_screen = 1;
+ /* fall */
case 'v':
++Verbose; break;
case 'y':
***************
*** 302,316 ****
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");
! exit(2);
! }
! setbuf(stderr, NULL);
! fprintf(stderr, "argv[0]=%s Progname=%s\n", virgin, Progname);
! }
vfile("%s %s for %s tty=%s\n", Progname, VERSION, OS, Nametty);
mode(1);
if (signal(SIGINT, bibi) == SIG_IGN) {
--- 307,321 ----
usage();
if (Batch && npats)
usage();
! 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(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);
if (signal(SIGINT, bibi) == SIG_IGN) {
***************
*** 326,333 ****
}
if (exitcode && !Zmodem) /* bellow again with all thy might. */
canit();
! if (endmsg[0])
fprintf(stderr, " %s: %s\r\n", Progname, endmsg);
fprintf(stderr, "%s %s finished.\r\n", Progname, VERSION);
fflush(stderr);
#ifndef REGISTERED
--- 331,341 ----
}
if (exitcode && !Zmodem) /* bellow again with all thy might. */
canit();
! 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);
#ifndef REGISTERED
***************
*** 351,360 ****
{
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,
"Supports the following incoming ZMODEM options given to the sending program:\n\
compression (-Z), binary (-b), ASCII CR/LF>NL (-a), newer(-n),\n\
--- 359,368 ----
{
fprintf(stderr,
"Receive Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\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\
***************
*** 449,459 ****
et_tu:
Firstsec=TRUE; Eofseen=FALSE;
sendline(Crcflg?WANTCRC:NAK); flushmo();
- Lleft=0; /* Do read next time ... */
switch (c = wcgetsec(rpn, 100)) {
case WCEOT:
zperr2( "Pathname fetch returned %d", c);
sendline(ACK); flushmo();
Lleft=0; /* Do read next time ... */
readline(1);
--- 457,468 ----
et_tu:
Firstsec=TRUE; Eofseen=FALSE;
+ purgeline(); /* Do a reading of the line ... */
sendline(Crcflg?WANTCRC:NAK); flushmo();
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);
***************
*** 480,488 ****
sendchar=Crcflg?WANTCRC:NAK;
for (;;) {
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++;
--- 489,497 ----
sendchar=Crcflg?WANTCRC:NAK;
for (;;) {
+ purgeline(); /* Do read next time ... */
sendline(sendchar); /* send it now, we're ready! */
flushmo();
sectcurr=wcgetsec(secbuf, (sectnum&0177)?50:130);
if (sectcurr==(sectnum+1 &0377)) {
sectnum++;
***************
*** 500,507 ****
else if (sectcurr==WCEOT) {
if (closeit())
return ERROR;
sendline(ACK); flushmo();
- Lleft=0; /* Do read next time ... */
return OK;
}
else if (sectcurr==ERROR)
--- 509,516 ----
else if (sectcurr==WCEOT) {
if (closeit())
return ERROR;
+ purgeline(); /* Do read next time ... */
sendline(ACK); flushmo();
return OK;
}
else if (sectcurr==ERROR)
***************
*** 600,610 ****
while(readline(1)!=TIMEOUT)
;
if (Firstsec) {
sendline(Crcflg?WANTCRC:NAK); flushmo();
- Lleft=0; /* Do read next time ... */
} else {
maxtime=40; sendline(NAK); flushmo();
- Lleft=0; /* Do read next time ... */
}
}
/* try to stop the bubble machine. */
--- 609,619 ----
while(readline(1)!=TIMEOUT)
;
if (Firstsec) {
+ purgeline(); /* Do read next time ... */
sendline(Crcflg?WANTCRC:NAK); flushmo();
} else {
+ purgeline(); /* Do read next time ... */
maxtime=40; sendline(NAK); flushmo();
}
}
/* try to stop the bubble machine. */
***************
*** 658,666 ****
if (Filemode & UNIXFILE)
++Thisbinary;
if (Verbose) {
! fprintf(stderr, "Incoming: %s %ld %lo %o\n",
name, Bytesleft, Modtime, Filemode);
! fprintf(stderr, "YMODEM header: %s\n", p);
}
}
--- 667,675 ----
if (Filemode & UNIXFILE)
++Thisbinary;
if (Verbose) {
! fprintf(Logstream, "Incoming: %s %ld %lo %o\n",
name, Bytesleft, Modtime, Filemode);
! fprintf(Logstream, "YMODEM header: %s\n", p);
}
}
***************
*** 681,687 ****
zmanag &= ZMMASK;
if (zmanag==ZMPROT)
goto skipfile;
! vfile("Current %s is %ld %lo", name, f.st_size, f.st_mtime);
if (Thisbinary && zconv==ZCRESUM) {
rxbytes = f.st_size & ~511;
if (Bytesleft < rxbytes) {
--- 690,696 ----
zmanag &= ZMMASK;
if (zmanag==ZMPROT)
goto skipfile;
! 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) {
***************
*** 928,934 ****
if (Restricted) {
if (fopen(name, "r") != NULL) {
canit();
! fprintf(stderr, "\r\nrz: %s exists\n", name);
bibi(-1);
}
/* restrict pathnames to current tree or uucppublic */
--- 937,943 ----
if (Restricted) {
if (fopen(name, "r") != NULL) {
canit();
! fprintf(stderr, "\r\nrz: %s exists\r\n", name);
bibi(-1);
}
/* restrict pathnames to current tree or uucppublic */
***************
*** 1047,1052 ****
--- 1056,1065 ----
return ERROR;
}
#endif
+ #ifndef BIG_SECURITY_HOLE
+ sprintf(endmsg, "ZCOMMAND Denied.");
+ return ERROR;
+ #else
cmdzack1flg = Rxhdr[ZF0];
if (zrdata(secbuf, 1024) == GOTCRCW) {
void exec2();
***************
*** 1066,1071 ****
--- 1079,1085 ----
return ZCOMPL;
}
zshhdr(4,ZNAK, Txhdr); goto again;
+ #endif
case ZCOMPL:
goto again;
default:
***************
*** 1220,1226 ****
}
moredata:
if (Verbose>1)
! fprintf(stderr, "%7ld ZMODEM%s\n",
rxbytes, Crc32r?" CRC-32":"");
#ifdef SEGMENTS
if (chinseg >= (1024 * SEGMENTS)) {
--- 1234,1240 ----
}
moredata:
if (Verbose>1)
! fprintf(Logstream, "%7ld ZMODEM%s\n",
rxbytes, Crc32r?" CRC-32":"");
#ifdef SEGMENTS
if (chinseg >= (1024 * SEGMENTS)) {