[unix-pc.sources] Patch to CKermit to automatically invoke Zmodem

darren@bacchus.UUCP (Darren Friedlein) (01/15/88)

I love Zmodem, and I got tired of the hastle to use it with kermit (the only
comm prog I use because of problems with cu and async_main is a joke).  There
was mention in the Zmodem doc about having the com prog search for "B00" to
start a file transfer, so I thought I'd modify kermit to be triggered by
"B00".  Well, it works, but it's the messiest hack I've ever done!  One
side-effect of installing this patch is that it doesn't do that choppy
input.  Instead, it scrolls accross like it should have in the first place.
To use the zmodem patch, define ZMODEM on the command line for cc (part of
the following patch does that to the Makefile).  Oh yeah - it places the
d/lded file into /usr/spool/uucppublic.  If you want it somewhere else,
change the #define of RZLINE in ckucon.c

What's the bottom line?  Well - if you have rz (receive Zmodem) and the
sources for CKermit 4E(067), apply the following context diff with patch
and tell me how it works.  I can't notice any change between the patched
and unpatched version, but I'm only running 1200bd on a reasonably fast
machine.  I'd be interested in what some other people's results look
like.

One note: I am using the version of CKermit patches for the UNIXpc internal
modem.  If you aren't using this, you'll have to change the Makefile patch
and maybe some of the ckucon.c patch (but I doubt it).

Again, I apologize for the messy code.  Have fun!

-Darren

/******                      /*****       {mcnc}            Darren G. Friedlein
 *     *      /******        *            {icus}  Rt 4 Box 416, Durham NC 27703
 *     *      *              *            {ethos}    data(bacchus):919/596-7746
 *     *urham \*****\        *     ompany {gladys}           voice:919/596-9492
\******             *oftware \*****       {bakerst}!bacchus!darren
              ******/
"I broke a mirror in hy house - I'm supposed to get seven years bad luck but
my lawyer thinks he can get me five."            -Steven Wright

----- Cut Here -----
*** orig/Makefile	Tue Jan 12 01:49:20 1988
--- new/Makefile	Wed Jan 13 23:32:10 1988
***************
*** 242,248
  #ATT UNIX PC 7300 and 3b1 (renames things for shared library)
  upc:
  	make wermit \
! 	"CFLAGS = -DDEBUG -DTLOG -DUNIXPC -Ddial=Dial -Dopeni=Openi -O" \
  	"LNKFLAGS ="
  
  

--- 242,248 -----
  #ATT UNIX PC 7300 and 3b1 (renames things for shared library)
  upc:
  	make wermit \
! 	"CFLAGS = -DDEBUG -DTLOG -DUNIXPC -DZMODEM -Ddial=Dial -Dopeni=Openi -O" \
  	"LNKFLAGS ="
  
  
*** orig/ckucon.c	Tue Jan 12 01:07:52 1988
--- new/ckucon.c	Wed Jan 13 23:32:10 1988
***************
*** 43,48
  int i, active;				/* Variables global to this module */
  char *chstr();
  char temp[50];
  
  #define LBUFL 200			/* Line buffer */
  char lbuf[LBUFL];

--- 43,52 -----
  int i, active;				/* Variables global to this module */
  char *chstr();
  char temp[50];
+ #ifdef ZMODEM
+ int confrez = 0;                        /* Used to lock console during FT */
+ int tempz = 0;                          /* Counts Bs and 0s... */
+ #endif
  
  #define LBUFL 200			/* Line buffer */
  char lbuf[LBUFL];
***************
*** 55,60
  conn_int() {				/* Modem read failure handler, */
      longjmp(env_con,1);			/* notifies parent process to stop */
  }
  
  /*  C O N E C T  --  Perform terminal connection  */
  

--- 59,78 -----
  conn_int() {				/* Modem read failure handler, */
      longjmp(env_con,1);			/* notifies parent process to stop */
  }
+ 
+ #ifdef ZMODEM
+ #define RZLINE	"cd /usr/spool/uucppublic; rz </dev/ph1 >/dev/ph1"
+ zfre() {
+     signal(SIGUSR2, zfre);
+     if (confrez == 0) {
+         confrez = 1;
+         wait();
+     }
+     confrez = 0;
+     return(1);
+ }
+ #endif
+ 
  
  /*  C O N E C T  --  Perform terminal connection  */
  
***************
*** 122,127
  	  active = 1;			/* This fork reads, sends keystrokes */
  	  if (!setjmp(env_con)) {	/* comm error in child process */
  	    signal(SIGUSR1,conn_int);	/* routine for child process exit */
  	    while (active) {
  		c = coninc(0) & cmask;	/* Get character from keyboard */
  		if ((c & 0177) == escape) { /* Look for escape char */

--- 140,148 -----
  	  active = 1;			/* This fork reads, sends keystrokes */
  	  if (!setjmp(env_con)) {	/* comm error in child process */
  	    signal(SIGUSR1,conn_int);	/* routine for child process exit */
+ #ifdef ZMODEM
+             signal(SIGUSR2,zfre);       /* Kdb Lock */
+ #endif
  	    while (active) {
  		c = coninc(0) & cmask;	/* Get character from keyboard */
  		if ((c & 0177) == escape) { /* Look for escape char */
***************
*** 159,165
  		    pause();		/* Wait to be killed by parent. */
                  }
  		c &= cmask;		/* Got a char, strip parity, etc */
! 		conoc(c);		/* Put it on the screen. */
  		if (seslog) zchout(ZSFILE,c);	/* If logging, log it. */
  		while ((n = ttchk()) > 0) {	/* Any more left in buffer? */
  		    if (n > LBUFL) n = LBUFL;   /* Get them all at once. */

--- 180,201 -----
  		    pause();		/* Wait to be killed by parent. */
                  }
  		c &= cmask;		/* Got a char, strip parity, etc */
! #ifdef ZMODEM
!                 if (c == 'B')
!                     tempz = 1;
!                 else if ((c == '0') && (tempz > 0))
!                     tempz++;
!                 else
!                     tempz = 0;
! 				                        	            
!                 if (tempz > 3) {
!                     kill(parent_id, SIGUSR2);
!                     system(RZLINE);
!                     kill(parent_id, SIGUSR2);
!                     tempz = 0;
! 	        }
! #endif  
! 		conoc(c);		/* Put it on the screen. 
  		if (seslog) zchout(ZSFILE,c);	/* If logging, log it. */
  	    }
      	}
***************
*** 161,174
  		c &= cmask;		/* Got a char, strip parity, etc */
  		conoc(c);		/* Put it on the screen. */
  		if (seslog) zchout(ZSFILE,c);	/* If logging, log it. */
- 		while ((n = ttchk()) > 0) {	/* Any more left in buffer? */
- 		    if (n > LBUFL) n = LBUFL;   /* Get them all at once. */
- 		    if ((n = ttxin(n,lbuf)) > 0) {
- 			for (i = 0; i < n; i++) lbuf[i] &= cmask;  /* Strip */
- 			conxo(n,lbuf);	    	    	    	   /* Output */
- 			if (seslog) zsoutx(ZSFILE,lbuf,n);  	   /* Log */
- 		    }
- 	    	}
  	    }
      	}
  }

--- 197,202 -----
  #endif  
  		conoc(c);		/* Put it on the screen. 
  		if (seslog) zchout(ZSFILE,c);	/* If logging, log it. */
  	    }
      	}
  }