*** crc.c.orig	Sun May  2 19:14:18 1993
--- crc.c	Mon Oct 31 07:30:34 1994
***************
*** 117,122 ****
--- 117,126 ----
  {
  	register errors = 0;
  
+ 	if(argc	< 2) {
+ 		fprintf(stderr, "Usage: %s [-x] [-k] file ...\n", argv[0]);
+ 		exit(0);
+ 	}
  	if (! strcmp(argv[1], "-x")) {
  		Block = 128; --argc; ++argv;
  	}
*** rbsb.c.orig	Tue Apr 12 00:59:40 1994
--- rbsb.c	Mon Oct 31 07:30:34 1994
***************
*** 17,24 ****
  #ifdef LLITOUT
  long Locmode;		/* Saved "local mode" for 4.x BSD "new driver" */
  long Locbit = LLITOUT;	/* Bit SUPPOSED to disable output translations */
- #include <strings.h>
  #endif
  #endif
  
  #ifdef USG
--- 17,25 ----
  #ifdef LLITOUT
  long Locmode;		/* Saved "local mode" for 4.x BSD "new driver" */
  long Locbit = LLITOUT;	/* Bit SUPPOSED to disable output translations */
  #endif
+ #include <strings.h>
+ char *ttyname(), *getenv();
  #endif
  
  #ifdef USG
***************
*** 81,86 ****
--- 82,88 ----
  
  char *Nametty;
  FILE *Ttystream;
+ FILE *Logstream;
  int Tty;
  char linbuf[HOWMANY];
  char xXbuf[BUFSIZ];
***************
*** 358,364 ****
  		(void) tcflow(Tty, TCOON);	/* Restart output */
  #else
  		(void) ioctl(Tty, TCSBRK, 1);	/* Wait for output to drain */
! 		(void) ioctl(Tty, TCFLSH, 1);	/* Flush input queue */
  		(void) ioctl(Tty, TCSETAW, &oldtty);	/* Restore modes */
  		(void) ioctl(Tty, TCXONC,1);	/* Restart output */
  #endif
--- 360,366 ----
  		(void) tcflow(Tty, TCOON);	/* Restart output */
  #else
  		(void) ioctl(Tty, TCSBRK, 1);	/* Wait for output to drain */
! 		(void) ioctl(Tty, TCFLSH, 0);	/* Flush input queue */
  		(void) ioctl(Tty, TCSETAW, &oldtty);	/* Restore modes */
  		(void) ioctl(Tty, TCXONC,1);	/* Restart output */
  #endif
***************
*** 370,375 ****
--- 372,384 ----
  #ifdef LLITOUT
  		ioctl(Tty, TIOCLSET, &Locmode);
  #endif
+ #ifdef TIOCFLUSH
+ 		{ static int fread = 1;
+ 		ioctl(Tty, TIOCFLUSH, &fread);	 /* Flush input	queue */
+ 		}
+ #else
+ 		lseek(Tty, 0L, 2);
+ #endif
  #endif
  
  		return OK;
***************
*** 383,389 ****
  #ifdef V7
  #ifdef TIOCSBRK
  #define CANBREAK
- 	sleep(1);
  	ioctl(Tty, TIOCSBRK, 0);
  	sleep(1);
  	ioctl(Tty, TIOCCBRK, 0);
--- 392,397 ----
***************
*** 402,417 ****
  /* Initialize tty device for serial file xfer */
  inittty()
  {
! 	if ((Nametty = ttyname(2)) && *Nametty) {
! 		Tty = open(Nametty, 2);
! 	} else {
! 		Tty = open(Nametty = "/dev/tty", 2);
! 	}
! 
! 	if (Tty <= 0) {
! 		perror(Nametty);  exit(2);
! 	}
! 	Ttystream = fdopen(Tty, "w");
  }
  
  flushmoc()
--- 410,422 ----
  /* Initialize tty device for serial file xfer */
  inittty()
  {
! 	Tty = 0;
! 	Ttystream = stdout;
! 	Nametty	= ttyname(Tty);
! 	if (!Nametty ||	!*Nametty)
! 		Nametty	= "|pipe|";
! 	Logstream = stderr;
! 	setbuf(Ttystream, xXbuf);
  }
  
  flushmoc()
***************
*** 442,448 ****
  
  	if (--Lleft >= 0) {
  		if (Verbose > 8) {
! 			fprintf(stderr, "%02x ", *cdq&0377);
  		}
  		return (*cdq++ & 0377);
  	}
--- 447,453 ----
  
  	if (--Lleft >= 0) {
  		if (Verbose > 8) {
! 			fprintf(Logstream, "%02x ", *cdq&0377);
  		}
  		return (*cdq++ & 0377);
  	}
***************
*** 450,464 ****
  	if (n < 2)
  		n = 2;
  	if (Verbose > 5)
! 		fprintf(stderr, "Calling read: alarm=%d  Readnum=%d ",
  		  n, Readnum);
  	if (setjmp(tohere)) {
! #ifdef TIOCFLUSH
! /*		ioctl(Tty, TIOCFLUSH, 0); */
! #endif
! 		Lleft = 0;
  		if (Verbose>1)
! 			fprintf(stderr, "Readline:TIMEOUT\n");
  		return TIMEOUT;
  	}
  	signal(SIGALRM, alrm); alarm(n);
--- 455,466 ----
  	if (n < 2)
  		n = 2;
  	if (Verbose > 5)
! 		fprintf(Logstream, "Calling read: alarm=%d  Readnum=%d ",
  		  n, Readnum);
  	if (setjmp(tohere)) {
! 		purgeline();
  		if (Verbose>1)
! 			fprintf(Logstream, "Readline:TIMEOUT\n");
  		return TIMEOUT;
  	}
  	signal(SIGALRM, alrm); alarm(n);
***************
*** 466,481 ****
  	Lleft=read(Tty, cdq=linbuf, Readnum);
  	alarm(0);
  	if (Verbose > 5) {
! 		fprintf(stderr, "Read returned %d bytes errno=%d\n",
  		  Lleft, errno);
  	}
  	if (Lleft < 1)
  		return TIMEOUT;
  	if (Verbose > 8) {
  		for (n = Lleft; --n >= 0; ) {
! 			fprintf(stderr, "%02x ", *cdq&0377);
  		}
! 		fprintf(stderr, "\n");
  	}
  	--Lleft;
  	return (*cdq++ & 0377);
--- 468,483 ----
  	Lleft=read(Tty, cdq=linbuf, Readnum);
  	alarm(0);
  	if (Verbose > 5) {
! 		fprintf(Logstream, "Read returned %d bytes errno=%d\n",
  		  Lleft, errno);
  	}
  	if (Lleft < 1)
  		return TIMEOUT;
  	if (Verbose > 8) {
  		for (n = Lleft; --n >= 0; ) {
! 			fprintf(Logstream, "%02x ", *cdq&0377);
  		}
! 		fprintf(Logstream, "\n");
  	}
  	--Lleft;
  	return (*cdq++ & 0377);
***************
*** 491,505 ****
  	Lleft = 0;
  #ifdef USG
  #ifdef POSIX
! 	tcflush(Tty, 0);
  #else
  	ioctl(Tty, TCFLSH, 0);
  #endif
  #else
  	lseek(Tty, 0L, 2);
  #endif
  }
  
  
  /* send cancel string to get the other end to shut up */
  canit()
--- 493,537 ----
  	Lleft = 0;
  #ifdef USG
  #ifdef POSIX
! 	tcflush(Tty, TCIFLUSH);
  #else
  	ioctl(Tty, TCFLSH, 0);
  #endif
  #else
+ #ifdef TIOCFLUSH
+ 	{ static int fread = 1;
+ 	ioctl(Tty, TIOCFLUSH, &fread);
+ 	}
+ #else
  	lseek(Tty, 0L, 2);
  #endif
+ #endif
  }
  
+ /*
+  * Purge the modem output queue of all characters
+  */
+ purgeout()
+ {
+ #ifdef __386BSD__
+ 	fpurge(Ttystream);
+ #else
+ 	rewind(Ttystream);
+ #endif
+ #ifdef POSIX
+ 	tcflush(Tty, TCOFLUSH);
+ #else
+ #ifdef TCFLSH
+ 	ioctl(Tty, TCFLSH, 1);
+ #else
+ #ifdef TIOCFLUSH
+ 	{ static int fwrite = 2;
+ 	ioctl(Tty, TIOCFLUSH, &fwrite);
+ 	}
+ #endif
+ #endif
+ #endif
+ }
  
  /* send cancel string to get the other end to shut up */
  canit()
***************
*** 508,515 ****
  	 24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0
  	};
  
  	zmputs(canistr);
- 	Lleft=0;	/* Do read next time ... */
  }
  
  /*
--- 540,547 ----
  	 24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0
  	};
  
+ 	purgeline();        /* Do read next time ... */
  	zmputs(canistr);
  }
  
  /*
***************
*** 541,548 ****
  long a, b, c, d;
  {
  	if (Verbose > 2) {
! 		fprintf(stderr, f, a, b, c, d);
! 		fprintf(stderr, "\n");
  	}
  }
  
--- 573,580 ----
  long a, b, c, d;
  {
  	if (Verbose > 2) {
! 		fprintf(Logstream, f, a, b, c, d);
! 		fprintf(Logstream, "\n");
  	}
  }
  
*** rz.c.orig	Sat Apr 23 17:53:28 1994
--- rz.c	Mon Oct 31 07:36:15 1994
***************
*** 1,5 ****
! #define VERSION "3.36 04-23-94"
  #define PUBDIR "/usr/spool/uucppublic"
  
  /*
   *
--- 1,9 ----
! #define VERSION "3.36/ache 04-23-94"
! #ifdef __FreeBSD__
! #define PUBDIR "/var/spool/uucppublic"
! #else
  #define PUBDIR "/usr/spool/uucppublic"
+ #endif
  
  /*
   *
***************
*** 174,179 ****
--- 178,185 ----
  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
   */
***************
*** 184,192 ****
  {
  	if (Verbose <= 0)
  		return;
! 	fprintf(stderr, "Retry %d: ", errors);
! 	fprintf(stderr, s, p, u);
! 	fprintf(stderr, "\n");
  }
  
  #include "zm.c"
--- 190,198 ----
  {
  	if (Verbose <= 0)
  		return;
! 	fprintf(Logstream, "Retry %d: ", errors);
! 	fprintf(Logstream, s, p, u);
! 	fprintf(Logstream, "\n");
  }
  
  #include "zm.c"
***************
*** 201,207 ****
  	if (Zmodem)
  		zmputs(Attn);
  	canit(); mode(0);
! 	fprintf(stderr, "rz: caught signal %d; exiting", n);
  	exit(3);
  }
  
--- 207,213 ----
  	if (Zmodem)
  		zmputs(Attn);
  	canit(); mode(0);
! 	fprintf(Logstream, "rz: caught signal %d; exiting\n", n);
  	exit(3);
  }
  
***************
*** 214,220 ****
  	int exitcode = 0;
  
  	Rxtimeout = 100;
- 	setbuf(stderr, NULL);
  	if ((cp=getenv("SHELL")) && (substr(cp, "rsh") || substr(cp, "rksh")))
  		Restricted=TRUE;
  
--- 220,225 ----
***************
*** 258,263 ****
--- 263,271 ----
  						Zrwindow = atoi(*++argv);
  					}
  					break;
+ 				case 'V':
+ 					log_to_screen = 1;
+ 					/* fall */
  				case 'v':
  					++Verbose; break;
  				default:
***************
*** 276,289 ****
  		usage();
  	if (Batch && npats)
  		usage();
! 	if (Verbose) {
! 		if (freopen(LOGFILE, "a", stderr)==NULL)
! 			if (freopen(LOGFILE2, "a", stderr)==NULL) {
! 				printf("Can't open log file!");
  				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);
--- 284,297 ----
  		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);
***************
*** 298,317 ****
  		exitcode=1;
  		canit();
  	}
- 	mode(0);
  	if (exitcode && !Zmodem)	/* bellow again with all thy might. */
  		canit();
! 	if (endmsg[0])
! 		printf("  %s: %s\r\n", Progname, endmsg);
! 	printf("%s %s finished.\r\n", Progname, VERSION);
! 	fflush(stdout);
  	if(exitcode)
  		exit(1);
  #ifndef REGISTERED
  	/* Removing or disabling this code without registering is theft */
  	if (!Usevhdrs)  {
! 		printf( "\n\n\nPlease read the License Agreement in rz.doc\n");
! 		fflush(stdout);
  		sleep(10);
  	}
  #endif
--- 306,326 ----
  		exitcode=1;
  		canit();
  	}
  	if (exitcode && !Zmodem)	/* bellow again with all thy might. */
  		canit();
! 	mode(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);
  	if(exitcode)
  		exit(1);
  #ifndef REGISTERED
  	/* Removing or disabling this code without registering is theft */
  	if (!Usevhdrs)  {
! 		fprintf(stderr, "\n\n\nPlease read the License Agreement in rz.doc\n");
  		sleep(10);
  	}
  #endif
***************
*** 327,336 ****
  	fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
  	  Progname, VERSION, OS);
  	fprintf(stderr, "\t\t\042The High Reliability Software\042\n\n");
! 	fprintf(stderr,"Usage:	rz [-v]		(ZMODEM)\n");
! 	fprintf(stderr,"or	rb [-av]	(YMODEM)\n");
! 	fprintf(stderr,"or	rc [-av] file	(XMODEM-CRC)\n");
! 	fprintf(stderr,"or	rx [-av] 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\
--- 336,345 ----
  	fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
  	  Progname, VERSION, OS);
  	fprintf(stderr, "\t\t\042The High Reliability Software\042\n\n");
! 	fprintf(stderr,"Usage:  rz [-vV] [-w N] [-t N]  (ZMODEM)\n");
! 	fprintf(stderr,"or      rb [-avV] [-t N]        (YMODEM)\n");
! 	fprintf(stderr,"or      rc [-avV] [-t N] file   (XMODEM-CRC)\n");
! 	fprintf(stderr,"or      rx [-avV] [-t N] 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\
***************
*** 418,430 ****
  
  et_tu:
  	Firstsec=TRUE;  Eofseen=FALSE;
  	sendline(Crcflg?WANTCRC:NAK);  flushmo();
- 	Lleft=0;	/* Do read next time ... */
  	while ((c = wcgetsec(rpn, 100)) != 0) {
  		if (c == WCEOT) {
  			zperr( "Pathname fetch returned %d", c);
  			sendline(ACK);  flushmo();
- 			Lleft=0;	/* Do read next time ... */
  			readline(1);
  			goto et_tu;
  		}
--- 427,439 ----
  
  et_tu:
  	Firstsec=TRUE;  Eofseen=FALSE;
+ 	purgeline();    /* Do read next time ... */
  	sendline(Crcflg?WANTCRC:NAK);  flushmo();
  	while ((c = wcgetsec(rpn, 100)) != 0) {
  		if (c == WCEOT) {
  			zperr( "Pathname fetch returned %d", c);
+ 			purgeline();    /* Do read next time ... */
  			sendline(ACK);  flushmo();
  			readline(1);
  			goto et_tu;
  		}
***************
*** 449,457 ****
  	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++;
--- 458,466 ----
  	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++;
***************
*** 469,476 ****
  		else if (sectcurr==WCEOT) {
  			if (closeit())
  				return ERROR;
  			sendline(ACK); flushmo();
- 			Lleft=0;	/* Do read next time ... */
  			return OK;
  		}
  		else if (sectcurr==ERROR)
--- 478,485 ----
  		else if (sectcurr==WCEOT) {
  			if (closeit())
  				return ERROR;
+ 			purgeline();    /* Do read next time ... */
  			sendline(ACK); flushmo();
  			return OK;
  		}
  		else if (sectcurr==ERROR)
***************
*** 569,579 ****
  		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. */
--- 578,588 ----
  		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. */
***************
*** 625,633 ****
  		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);
  		}
  	}
  
--- 634,642 ----
  		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);
  		}
  	}
  
***************
*** 888,894 ****
  	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 */
--- 897,903 ----
  	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 */
***************
*** 1172,1178 ****
  			}
  moredata:
  			if (Verbose>1)
! 				fprintf(stderr, "\r%7ld ZMODEM%s    ",
  				  rxbytes, Crc32r?" CRC-32":"");
  #ifdef SEGMENTS
  			if (chinseg >= (1024 * SEGMENTS)) {
--- 1181,1187 ----
  			}
  moredata:
  			if (Verbose>1)
! 				fprintf(Logstream, "\r%7ld ZMODEM%s    ",
  				  rxbytes, Crc32r?" CRC-32":"");
  #ifdef SEGMENTS
  			if (chinseg >= (1024 * SEGMENTS)) {
*** sz.c.orig	Sat Apr 23 19:14:28 1994
--- sz.c	Mon Oct 31 07:35:05 1994
***************
*** 1,5 ****
! #define VERSION "3.36 04-23-94"
  #define PUBDIR "/usr/spool/uucppublic"
  
  /*
   **************************************************************************
--- 1,9 ----
! #define VERSION "3.36/ache 04-23-94"
! #ifdef __FreeBSD__
! #define PUBDIR "/var/spool/uucppublic"
! #else
  #define PUBDIR "/usr/spool/uucppublic"
+ #endif
  
  /*
   **************************************************************************
***************
*** 184,200 ****
  STATIC jmp_buf tohere;		/* For the interrupt on RX timeout */
  STATIC jmp_buf intrjmp;	/* For the interrupt on RX CAN */
  
  
  /* called by signal interrupt or terminate to clean things up */
  void
  bibi(n)
  {
  	canit(); fflush(stdout); mode(0);
! 	fprintf(stderr, "sz: caught signal %d; exiting\n", n);
  	if (n == SIGQUIT)
  		abort();
  	if (n == 99)
! 		fprintf(stderr, "mode(2) in rbsb.c not implemented!!\n");
  	exit(3);
  }
  
--- 188,205 ----
  STATIC jmp_buf tohere;		/* For the interrupt on RX timeout */
  STATIC jmp_buf intrjmp;	/* For the interrupt on RX CAN */
  
+ int log_to_screen = 0;  /* Don't make log file */
  
  /* called by signal interrupt or terminate to clean things up */
  void
  bibi(n)
  {
  	canit(); fflush(stdout); mode(0);
! 	fprintf(Logstream, "sz: caught signal %d; exiting\n", n);
  	if (n == SIGQUIT)
  		abort();
  	if (n == 99)
! 		fprintf(Logstream, "mode(2) in rbsb.c not implemented!!\n");
  	exit(3);
  }
  
***************
*** 221,229 ****
  {
  	if (Verbose <= 0)
  		return;
! 	fprintf(stderr, "Retry %d: ", errors);
! 	fprintf(stderr, s, p, u);
! 	fprintf(stderr, "\n");
  }
  
  #include "zm.c"
--- 226,234 ----
  {
  	if (Verbose <= 0)
  		return;
! 	fprintf(Logstream, "Retry %d: ", errors);
! 	fprintf(Logstream, s, p, u);
! 	fprintf(Logstream, "\n");
  }
  
  #include "zm.c"
***************
*** 317,322 ****
--- 322,330 ----
  					mode(0);  exit(0);
  				case 'u':
  					++Unlinkafter; break;
+ 				case 'V':
+ 					log_to_screen = 1;
+ 					/* fall */
  				case 'v':
  					++Verbose; break;
  				case 'w':
***************
*** 363,375 ****
  	}
  	if (npats < 1 && !Command && !Test) 
  		usage();
! 	if (Verbose) {
! 		if (freopen(LOGFILE, "a", stderr)==NULL)
! 			if (freopen(LOGFILE2, "a", stderr)==NULL) {
! 				printf("Can't open log file!");
  				exit(2);
  			}
! 		setbuf(stderr, NULL);
  	}
  	vfile("%s %s for %s tty=%s\n", Progname, VERSION, OS, Nametty);
  
--- 371,383 ----
  	}
  	if (npats < 1 && !Command && !Test) 
  		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);
  	}
  	vfile("%s %s for %s tty=%s\n", Progname, VERSION, OS, Nametty);
  
***************
*** 413,424 ****
  		canit();
  	}
  	if (endmsg[0]) {
! 		printf("\r\n%s: %s\r\n", Progname, endmsg);
  		if (Verbose)
! 			fprintf(stderr, "%s\r\n", endmsg);
  	}
! 	printf("%s %s finished.\r\n", Progname, VERSION);
! 	fflush(stdout);
  	mode(0);
  	if(errcnt || Exitcode)
  		exit(1);
--- 421,431 ----
  		canit();
  	}
    	if (endmsg[0]) {
! 		fprintf(stderr, "\r\n%s: %s\r\n", Progname, endmsg);
    		if (Verbose)
! 			fprintf(Logstream, "%s\r\n", endmsg);
    	}
! 	fprintf(stderr, "%s %s finished.\r\n", Progname, VERSION);
  	mode(0);
  	if(errcnt || Exitcode)
  		exit(1);
***************
*** 426,433 ****
  #ifndef REGISTERED
  	/* Removing or disabling this code without registering is theft */
  	if (!Usevhdrs)  {
! 		printf("\n\n\nPlease read the License Agreement in sz.doc\n");
! 		fflush(stdout);
  		sleep(10);
  	}
  #endif
--- 433,439 ----
  #ifndef REGISTERED
  	/* Removing or disabling this code without registering is theft */
  	if (!Usevhdrs)  {
! 		fprintf(stderr, "\n\n\nPlease read the License Agreement in sz.doc\n");
  		sleep(10);
  	}
  #endif
***************
*** 461,468 ****
  	firstsec=TRUE;
  	bytcnt = -1;
  	if (Nozmodem) {
! 		printf("Start your local YMODEM receive.     ");
! 		fflush(stdout);
  	}
  	for (n=0; n<argc; ++n) {
  		Totsecs = 0;
--- 467,473 ----
  	firstsec=TRUE;
  	bytcnt = -1;
  	if (Nozmodem) {
! 		fprintf(stderr, "Start your local YMODEM receive.     ");
  	}
  	for (n=0; n<argc; ++n) {
  		Totsecs = 0;
***************
*** 569,579 ****
  
  	if (Modem2) {
  		if (*name && fstat(fileno(in), &f)!= -1) {
! 			fprintf(stderr, "Sending %s, %ld XMODEM blocks. ",
  			  name, (127+f.st_size)>>7);
  		}
! 		printf("Start your local XMODEM receive.     ");
! 		fflush(stdout);
  		return OK;
  	}
  	zperr("Awaiting pathname nak for %s", *name?name:"<END>");
--- 574,583 ----
  
  	if (Modem2) {
  		if (*name && fstat(fileno(in), &f)!= -1) {
! 			fprintf(Logstream, "Sending %s, %ld XMODEM blocks. ",
  			  name, (127+f.st_size)>>7);
  		}
! 		fprintf(stderr, "Start your local XMODEM receive.     ");
  		return OK;
  	}
  	zperr("Awaiting pathname nak for %s", *name?name:"<END>");
***************
*** 728,736 ****
  	firstch=0;	/* part of logic to detect CAN CAN */
  
  	if (Verbose>2)
! 		fprintf(stderr, "Sector %3d %2dk\n", Totsecs, Totsecs/8 );
  	else if (Verbose>1)
! 		fprintf(stderr, "\rSector %3d %2dk ", Totsecs, Totsecs/8 );
  	for (attempts=0; attempts <= RETRYMAX; attempts++) {
  		Lastrx= firstch;
  		sendline(cseclen==1024?STX:SOH);
--- 732,740 ----
  	firstch=0;	/* part of logic to detect CAN CAN */
  
  	if (Verbose>2)
! 		fprintf(Logstream, "Sector %3d %2dk\n", Totsecs, Totsecs/8 );
  	else if (Verbose>1)
! 		fprintf(Logstream, "\rSector %3d %2dk ", Totsecs, Totsecs/8 );
  	for (attempts=0; attempts <= RETRYMAX; attempts++) {
  		Lastrx= firstch;
  		sendline(cseclen==1024?STX:SOH);
***************
*** 848,854 ****
  {
  	long m, n;
  
! 	vfile("fooseek: pos =%lu vpos=%lu Canseek=%d", pos, vpos, Canseek);
  	/* Seek offset < current buffer */
  	if (pos < (vpos -TXBSIZE +1024)) {
  		BEofseen = 0;
--- 852,858 ----
  {
  	long m, n;
  
! 	vfile("fooseek: pos =%ld vpos=%ld Canseek=%d", pos, vpos, Canseek);
  	/* Seek offset < current buffer */
  	if (pos < (vpos -TXBSIZE +1024)) {
  		BEofseen = 0;
***************
*** 928,938 ****
  
  char *usinfo[] = {
  	"Send Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\n",
! 	"Usage:	sz [-+abcdefgklLnNuvwyYZ] [-] file ...",
! 	"\t	zcommand [-egv] COMMAND",
! 	"\t	zcommandi [-egv] COMMAND",
! 	"\t	sb [-adfkuv] [-] file ...",
! 	"\t	sx [-akuv] [-] file",
  	""
  };
  
--- 932,944 ----
  
  char *usinfo[] = {
  	"Send Files and Commands with ZMODEM/YMODEM/XMODEM Protocol\n",
! 	"Usage:",
! 	"    sz [-+abcdefgknNouvVyYZ] [-l N] [-L N] [-w N] [-r[r]] [-] file ...",
! 	"    sz -T",
! 	"    zcommand [-egvV] COMMAND",
! 	"    zcommandi [-egvV] COMMAND",
! 	"    sb [-adfkuvV] [-] file ...",
! 	"    sx [-akuvV] [-] file",
  	""
  };
  
***************
*** 1267,1275 ****
  			}
  		signal(SIGINT, SIG_IGN); canit();
  		sleep(3); purgeline(); mode(0);
! 		printf("\nsz: Tcount = %ld\n", tcount);
  		if (tleft) {
! 			printf("ERROR: Interrupts Not Caught\n");
  			exit(1);
  		}
  		exit(0);
--- 1273,1281 ----
  			}
  		signal(SIGINT, SIG_IGN); canit();
  		sleep(3); purgeline(); mode(0);
! 		fprintf(stderr, "\nsz: Tcount = %ld\n", tcount);
  		if (tleft) {
! 			fprintf(stderr, "ERROR: Interrupts Not Caught\n");
  			exit(1);
  		}
  		exit(0);
***************
*** 1290,1296 ****
  		} else
  			e = ZCRCG;
  		if (Verbose>1)
! 			fprintf(stderr, "\r%7ld ZMODEM%s    ",
  			  Txpos, Crc32t?" CRC-32":"");
  		zsdata(txbuf, n, e);
  		bytcnt = Txpos += n;
--- 1296,1302 ----
  		} else
  			e = ZCRCG;
  		if (Verbose>1)
! 			fprintf(Logstream, "\r%7ld ZMODEM%s    ",
  			  Txpos, Crc32t?" CRC-32":"");
  		zsdata(txbuf, n, e);
  		bytcnt = Txpos += n;
***************
*** 1378,1384 ****
  
  	for (;;) {
  		if (Test) {
! 			printf("\r\n\n\n***** Signal Caught *****\r\n");
  			Rxpos = 0; c = ZRPOS;
  		} else
  			c = zgethdr(Rxhdr);
--- 1384,1390 ----
  
  	for (;;) {
  		if (Test) {
! 			fprintf(stderr,"\r\n\n\n***** Signal Caught *****\r\n");
  			Rxpos = 0; c = ZRPOS;
  		} else
  			c = zgethdr(Rxhdr);
***************
*** 1414,1419 ****
--- 1420,1427 ----
  					if (blklen > 32)
  						blklen /= 2;
  			}
+ 			else
+ 				Beenhereb4 = 0;
  			Lastsync = Rxpos;
  			return c;
  		case ZACK:
***************
*** 1525,1541 ****
  	for (Totalleft = 0, Filesleft = 0; --argc >=0; ++argv) {
  		f.st_size = -1;
  		if (Verbose>2) {
! 			fprintf(stderr, "\nCountem: %03d %s ", argc, *argv);
! 			fflush(stderr);
  		}
  		if (access(*argv, 04) >= 0 && stat(*argv, &f) >= 0) {
  			++Filesleft;  Totalleft += f.st_size;
  		}
  		if (Verbose>2)
! 			fprintf(stderr, " %ld", f.st_size);
  	}
  	if (Verbose>2)
! 		fprintf(stderr, "\ncountem: Total %d %ld\n",
  		  Filesleft, Totalleft);
  }
  
--- 1533,1548 ----
  	for (Totalleft = 0, Filesleft = 0; --argc >=0; ++argv) {
  		f.st_size = -1;
  		if (Verbose>2) {
! 			fprintf(Logstream, "\nCountem: %03d %s ", argc, *argv);
  		}
  		if (access(*argv, 04) >= 0 && stat(*argv, &f) >= 0) {
  			++Filesleft;  Totalleft += f.st_size;
  		}
  		if (Verbose>2)
! 			fprintf(Logstream, " %ld", f.st_size);
  	}
  	if (Verbose>2)
! 		fprintf(Logstream, "\ncountem: Total %d %ld\n",
  		  Filesleft, Totalleft);
  }
  
***************
*** 1544,1576 ****
  	register n;
  
  	mode(m);
! 	printf("\r\n\nCharacter Transparency Test Mode %d\r\n", m);
! 	printf("If Pro-YAM/ZCOMM is not displaying ^M hit ALT-V NOW.\r\n");
! 	printf("Hit Enter.\021");  fflush(stdout);
  	readline(500);
  
  	for (n = 0; n < 256; ++n) {
  		if (!(n%8))
! 			printf("\r\n");
! 		printf("%02x ", n);  fflush(stdout);
  		sendline(n);	flushmo();
! 		printf("  ");  fflush(stdout);
  		if (n == 127) {
! 			printf("Hit Enter.\021");  fflush(stdout);
  			readline(500);
! 			printf("\r\n");  fflush(stdout);
  		}
  	}
! 	printf("\021\r\nEnter Characters, echo is in hex.\r\n");
! 	printf("Hit SPACE or pause 40 seconds for exit.\r\n");
  
  	while (n != TIMEOUT && n != ' ') {
  		n = readline(400);
! 		printf("%02x\r\n", n);
! 		fflush(stdout);
  	}
! 	printf("\r\nMode %d character transparency test ends.\r\n", m);
! 	fflush(stdout);
  }
  
  /* End of sz.c */
--- 1551,1581 ----
  	register n;
  
  	mode(m);
! 	fprintf(stderr, "\r\n\nCharacter Transparency Test Mode %d\r\n", m);
! 	fprintf(stderr, "If Pro-YAM/ZCOMM is not displaying ^M hit ALT-V NOW.\r\n");
! 	fprintf(stderr, "Hit Enter.\021");
  	readline(500);
  
  	for (n = 0; n < 256; ++n) {
  		if (!(n%8))
! 			fprintf(stderr, "\r\n");
! 		fprintf(stderr, "%02x ", n);
  		sendline(n);	flushmo();
! 		fprintf(stderr, "  ");
  		if (n == 127) {
! 			fprintf(stderr, "Hit Enter.\021");
  			readline(500);
! 			fprintf(stderr, "\r\n");
  		}
  	}
! 	fprintf(stderr, "\021\r\nEnter Characters, echo is in hex.\r\n");
! 	fprintf(stderr, "Hit SPACE or pause 40 seconds for exit.\r\n");
  
  	while (n != TIMEOUT && n != ' ') {
  		n = readline(400);
! 		fprintf(stderr, "%02x\r\n", n);
  	}
! 	fprintf(stderr, "\r\nMode %d character transparency test ends.\r\n", m);
  }
  
  /* End of sz.c */
