[comp.windows.x] xterm diffs for a Sequent

mtr@mace.cc.purdue.edu (Miek Rowan) (10/17/88)

Appended are the diffs for xterm to make it use
the getpseudotty() library call (which uses a ioctl
to get the next availble tty)  I have tested it on
both a Balance and a Symmetry (both running 3.0)

The diffs are from the base distributed version plus 
fixes1-33.



*** /tmp/,RCSt1010276	Mon Oct 17 09:42:12 1988
--- main.c	Mon Oct 17 08:50:05 1988
***************
*** 1,5 ****
  #ifndef lint
! static char rcs_id[] = "$Header: /bob10/X11/clients/xterm/RCS/main.c,v 11.2.0.2 88/09/11 13:53:46 mtr Exp Locker: mtr $";
  #endif	/* lint */
  
  /*
--- 1,5 ----
  #ifndef lint
! static char rcs_id[] = "$Header: /userb/src/X11/clients/xterm/main.c,v 11.2.0.3 88/09/11 13:53:46 mtr Exp $";
  #endif	/* lint */
  
  /*
***************
*** 650,657 ****
   */
  int *pty, *tty;
  {
! 	int devindex, letter = 0;
  
  	while (letter < 11) {
  	    ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
  		    PTYCHAR1 [letter++];
--- 650,671 ----
   */
  int *pty, *tty;
  {
! #ifdef sequent
! 	char 	*pchSlave,
! 		*pchMaster;
  
+ 	if(0 > (*pty = getpseudotty(&pchSlave, &pchMaster))) {
+ 		fprintf (stderr,"%s: Not enough available pty's\n", xterm_name);
+ 		exit (ERROR_PTYS);
+ 	}
+ 	if (0 > (*tty = open (pchSlave, O_RDWR))) {
+ 		fprintf (stderr,"%s: Not enough available pty's\n", xterm_name);
+ 		exit (ERROR_PTYS);
+ 	}
+ 	return;
+ #else !sequent
+ 	int devindex, letter = 0;
+ 		
  	while (letter < 11) {
  	    ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
  		    PTYCHAR1 [letter++];
***************
*** 672,677 ****
--- 686,692 ----
  	
  	fprintf (stderr, "%s: Not enough available pty's\n", xterm_name);
  	exit (ERROR_PTYS);
+ #endif sequent
  }
  
  get_terminal ()

mtr@mace.cc.purdue.edu (Miek Rowan) (10/19/88)

In article <875@mace.cc.purdue.edu>, I write:
> Appended are the diffs for xterm to make it use
> the getpseudotty() library call (which uses a ioctl
> to get the next availble tty)  I have tested it on
> both a Balance and a Symmetry (both running 3.0)

This is the set of diff's I should have posted.  Sorry for the confusion.  This version
has a kludge that lets it work when there is no conrolling tty on startup (via rsh)
by swapping the filedes for the pty and tty.  Getpseudotty() messes up the order of the
tty file descriptors in the table (/dev/ptyxx and /dev/ttyxx) by opening an intermediate
file (/dev/getpty).  Sometimes this cause xterm to dup the pty file over the tty file
(which gives you two pointers to /dev/ptyxx and none to /dev/ttyxx) 

mtr


*** /tmp/,RCSt1007016	Tue Oct 18 16:54:30 1988
--- main.c	Tue Oct 18 16:54:01 1988
***************
*** 1,5 ****
  #ifndef lint
! static char rcs_id[] = "$Header: /usr/src/local/X11/clients/xterm/RCS/main.c,v 11.2.0.2 88/09/11 13:53:46 mtr Exp $";
  #endif	/* lint */
  
  /*
--- 1,5 ----
  #ifndef lint
! static char rcs_id[] = "$Header: /usr/src/local/X11/clients/xterm/RCS/main.c,v 11.2.0.4 88/10/18 10:32:06 mtr Exp $";
  #endif	/* lint */
  
  /*
***************
*** 650,657 ****
   */
  int *pty, *tty;
  {
! 	int devindex, letter = 0;
  
  	while (letter < 11) {
  	    ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
  		    PTYCHAR1 [letter++];
--- 650,694 ----
   */
  int *pty, *tty;
  {
! #ifdef sequent
! 	char 	*slave,
! 		*master;
! 	int	iFdes,
! 		iTemp;
  
+ 	if(0 > (*pty = getpseudotty(&slave, &master))) {
+ 		fprintf (stderr,"%s: Not enough available pty's\n", xterm_name);
+ 		exit (ERROR_PTYS);
+ 	}	
+ 	if (0 > (*tty = open (slave, O_RDWR,0))) {
+ 		fprintf (stderr,"%s: Not enough available pty's\n", xterm_name);
+ 		exit (ERROR_PTYS);
+ 	}
+ 	/*
+ 	 * finally - the filedes are swapped from what they
+ 	 * should be because of the call to getpseudotty()
+  	 * (it opens /dev/getpty, then opens /dev/ptyxx
+ 	 * then closes /dev/getpty SO..  *tty < *pty .. Trust me ;-)
+ 	 * ...This is so gross
+ 	 */
+ 	if(*pty > *tty) {
+ 		iFdes = dup(*tty);
+ 		dup2(*pty, *tty);
+ 		dup2(iFdes, *pty);
+ 		close(iFdes);
+ 		/*
+ 		 * now they are swapped in the filedes table, correct the
+ 		 * pass back values
+ 		 */
+ 		iFdes = *pty;
+ 		*pty = *tty;
+ 		*tty = iFdes;
+ 	}
+ 
+ 	return;
+ #else !sequent
+ 	int devindex, letter = 0;
+ 		
  	while (letter < 11) {
  	    ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
  		    PTYCHAR1 [letter++];
***************
*** 672,677 ****
--- 709,715 ----
  	
  	fprintf (stderr, "%s: Not enough available pty's\n", xterm_name);
  	exit (ERROR_PTYS);
+ #endif sequent
  }
  
  get_terminal ()