[comp.unix.xenix] Patches to C Kermit 4E

chip@tct.uucp (Chip Salzenberg) (02/05/90)

I recently ported C Kermit 4E(070) to Xenix/386 2.3.  Changes included:

	Makefile entry for "sco386".
	Fix to modem init and dial strings for hayes modems.
	Fix to dial failure handling to send CR to hayes modems,
		which aborts a dial in progress.
	New command "$" which is like "!" but which connects the child
		process's stdin and stdout to the open comm line;
		this feature is useful for file transfer ("$ rz").

"Shar and enjoy."

======================================================================

Index: Makefile
***************
*** 273,276 ****
--- 274,283 ----
  	make wermit "CFLAGS= -DXENIX -DUXIII -DDEBUG -DTLOG -F 3000 -i" \
  		"LNKFLAGS = -F 3000 -i"
+ 
+ #SCO Xenix/386 2.3
+ sco386:
+ 	make wermit \
+ 		"CFLAGS= -O -DXENIX -DUXIII -DHDB -DDEBUG -DTLOG" \
+ 		"LNKFLAGS ="
  
  #SCO Xenix/286 2.2.1, e.g. for IBM PC/AT, PS/2 Model 50, etc.

Index: ckudia.c
***************
*** 293,297 ****
      ",",		/* pause_chars */
      2,			/* pause_time */
!     "AT\r",		/* wake_str */
      0,			/* wake_rate */
      "",			/* wake_prompt */
--- 293,297 ----
      ",",		/* pause_chars */
      2,			/* pause_time */
!     "AT E0 Q0 X4\r",	/* wake_str */
      0,			/* wake_rate */
      "",			/* wake_prompt */
***************
*** 298,302 ****
      "",			/* dmode_str */
      "",			/* dmode_prompt */
!     "AT D %s\r",	/* dial_str */
      0			/* dial_rate */
      };
--- 298,302 ----
      "",			/* dmode_str */
      "",			/* dmode_prompt */
!     "AT DT %s\r",	/* dial_str */
      0			/* dial_rate */
      };
***************
*** 643,646 ****
--- 643,654 ----
  		signal ( SIGINT, dialint );
  	    alarm ( 5 );		/* be sure to get out of this section */
+ 	    switch ( augmdmtyp )
+ 	    {
+ 	    case n_HAYES:
+ 	    case n_HAYESNV:
+ 		ttoc( '\r' );
+ 		break;
+ 	    }
+ 
  	    ttclos ();			/* hangup and close the line */
  	    }
***************
*** 720,725 ****
  			break;
  		    case '0':			/* numeric result code */
! 			augmdmtyp = n_HAYESNV;	/* nonverbal result codes */
! 			status = OKAY;
  			break;
  		    case 'O':			/* maybe English result code*/
--- 728,735 ----
  			break;
  		    case '0':			/* numeric result code */
! 			if (status == 0) {
! 			    augmdmtyp = n_HAYESNV; /* nonverbal result codes */
! 			    status = OKAY;
! 			}
  			break;
  		    case 'O':			/* maybe English result code*/
***************
*** 848,851 ****
--- 858,863 ----
  		    if (didWeGet(lbuf,"CONNECT")) status = CONNECTED;
  		    if (didWeGet(lbuf,"NO CARRIER")) status = FAILED;
+ 		    if (didWeGet(lbuf,"BUSY")) status = FAILED;
+ 		    if (didWeGet(lbuf,"NO DIAL")) status = FAILED;
  		    break;
  		  case n_PENRIL:

Index: ckufio.c
***************
*** 72,76 ****
--- 72,80 ----
  #ifdef UXIII
  #ifdef XENIX
+ #ifdef M_I386
+ char *ckzsys = " Xenix/386";
+ #else
  char *ckzsys = " Xenix/286";
+ #endif /* m_i386 */
  #else
  #ifdef PCIX

Index: ckutio.c
***************
*** 104,111 ****
--- 104,122 ----
  #endif /* tower1 */
  
+ /* AT&T System V implies HDB */
+ #ifdef ATT3BX
+ #ifndef HDB
+ #define HDB
+ #endif /* hdb */
+ #endif /* att3bx */
+ 
  /* Sys III/V, Xenix, PC/IX support by Herm Fischer, Encino, CA */
  #ifdef UXIII
  #ifdef XENIX
+ #ifdef M_I386
+ char *ckxsys = " Xenix/386";
+ #else
  char *ckxsys = " Xenix/286";
+ #endif /* m_i386 */
  #else
  #ifdef PCIX
***************
*** 645,648 ****
--- 656,665 ----
  }
  
+ /*  T T F D  --  Return the file descriptor open to the TTY.  */
+ ttfd() {
+     return ttyfd;
+ }
+ 
+ 
  /*  T T C L O S  --  Close the TTY, releasing any lock.  */
  
***************
*** 802,805 ****
--- 819,829 ----
  #else
      strcat( strcpy( lockfil, "LCK.." ), device );
+ #ifdef XENIX
+     {
+ 	int i;
+ 	for (i = strlen( lockfil ) - strlen( device ); lockfil[i]; ++i)
+ 	    lockfil[i] = tolower(lockfil[i]);
+     }
+ #endif /* xenix */
  #endif /* isiii */
  
***************
*** 832,838 ****
  ttlock(ttfd) char *ttfd; {		/* lock uucp if possible */
  #ifndef aegis
! #ifdef ATT3BX
      FILE *lck_fild;
! #endif /* att3bx */
      int lck_fil, l4l;
      int pid_buf = getpid();		/* pid to save in lock file */
--- 856,862 ----
  ttlock(ttfd) char *ttfd; {		/* lock uucp if possible */
  #ifndef aegis
! #ifdef HDB
      FILE *lck_fild;
! #endif /* hdb */
      int lck_fil, l4l;
      int pid_buf = getpid();		/* pid to save in lock file */
***************
*** 845,849 ****
      if (lck_fil < 0) return (-1);	/* create of lockfile failed */
  		/* creat leaves file handle open for writing -- hf */
! #ifdef ATT3BX
      fprintf((lck_fild = fdopen(lck_fil, "w")), "%10d\n", pid_buf);
      fflush(lck_fild);
--- 869,873 ----
      if (lck_fil < 0) return (-1);	/* create of lockfile failed */
  		/* creat leaves file handle open for writing -- hf */
! #ifdef HDB
      fprintf((lck_fild = fdopen(lck_fil, "w")), "%10d\n", pid_buf);
      fflush(lck_fild);
***************
*** 850,854 ****
  #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
! #endif /* att3bx */
      close (lck_fil);
      hasLock = 1;			/* now is locked */
--- 874,878 ----
  #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
! #endif /* hdb */
      close (lck_fil);
      hasLock = 1;			/* now is locked */

Index: ckuusr.c
***************
*** 400,403 ****
--- 400,404 ----
  struct keytab cmdtab[] = {
      "!",	   XXSHE, 0,
+     "$",	   XXSHC, 0,
      "%",    	   XXCOM, CM_INV,
      "bye",         XXBYE, 0,
***************
*** 1050,1053 ****
--- 1051,1055 ----
  */
  case XXSHE:				/* Local shell command */
+ case XXSHC:				/* Local shell command, connected */
      {
      int pid;
***************
*** 1108,1111 ****
--- 1110,1126 ----
  	seteuid(getuid());		/*  checks. */
  #endif
+ 
+ 	/* Connect shell to open comm port? */
+ 	if (cx == XXSHC && *s != NUL) {
+ 	    int tfd = ttfd();
+ 	    if (tfd >= 0) {
+ 		dup2(tfd, 0);
+ 		dup2(tfd, 1);
+ 	    }
+ 	    else {
+ 		fprintf(stderr, "not connected!\n");
+ 		exit(BAD_EXIT);
+ 	    }
+ 	}
  
  	if (*s == NUL)			/* Interactive shell requested? */

Index: ckuusr.h
***************
*** 70,73 ****
--- 70,74 ----
  #define XXLOGI 41	/* (Local) SCRIPT */
  #define XXCOM  42	/* Comment */
+ #define XXSHC  43	/* Command for SHELL, but connect to comm port */
  
  /* SET parameters */
-- 
Chip Salzenberg at ComDev/TCT   <chip%tct@ateng.com>, <uunet!ateng!tct!chip>
          "The Usenet, in a very real sense, does not exist."

-- 
Chip Salzenberg at ComDev/TCT   <chip%tct@ateng.com>, <uunet!ateng!tct!chip>
          "The Usenet, in a very real sense, does not exist."