Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1205/3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Rely on vt to supply geometry.
 [rsc] --rw-rw-r-- M 786594 glenda sys 7906 Dec  5 15:35 sys/src/cmd/ssh/cmsg.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/cmsg.c:252,303 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/cmsg.c:252,276
	  }
	  
	  /*
	-  * clumsy hack -- rather than open the font and fetch
	-  * the real character width and height, we assume that
	-  * LINES and COLS are initially correct and use them to 
	-  * derive cwidth, cheight.  this is definitely a mistake,
	-  * but i don't care.  if you do, fix it.
	+  * assumes that if you care, you're running under vt
	+  * and therefore these are set.
	   */
	  int
	  readgeom(int *nrow, int *ncol, int *width, int *height)
	  {
	- 	int ret;
	- 	static int first=1;
	  	static int fd = -1;
	- 	static int cwidth, cheight;
	  	char buf[64];
	- 	int n;
	  
	- 	ret = 0;
	- 	/* defaults */
	- 	*width = 640;
	- 	*height = 480;
	- 
	- 	if(fd < 0)
	- 		fd = open("/dev/wctl", OREAD);
	- 	if(fd >= 0){
	- 		n = read(fd, buf, sizeof(buf));
	- 		if(n < 48){
	- 			close(fd);
	- 			fd = -1;
	- 			ret = -1;
	- 			goto Out;
	- 		}
	- 	}
	- 	*width = atoi(&buf[2*12]) - atoi(&buf[0*12]);
	- 	*height = atoi(&buf[3*12]) - atoi(&buf[1*12]);
	- 
	- Out:
	- 	*nrow = intgetenv("LINES", 0);
	- 	*ncol = intgetenv("COLS", 0);
	- 	if(first){
	- 		first = 0;
	- 		if(*nrow)
	- 			cwidth = *width/(*nrow);
	- 		if(*ncol)
	- 			cheight = *height/(*ncol);
	- 	}
	- 	return ret;
	+ 	if(fd < 0 && (fd = open("/dev/wctl", OREAD)) < 0)
	+ 		return -1;
	+ 	/* wait for event, but don't care what it says */
	+ 	if(read(fd, buf, sizeof buf) < 0)
	+ 		return -1;
	+ 	*nrow = intgetenv("LINES", 24);
	+ 	*ncol = intgetenv("COLS", 80);
	+ 	*width = intgetenv("XPIXELS", 640);
	+ 	*height = intgetenv("YPIXELS", 480);
	+ 	return 0;
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 786594 glenda sys 9671 Dec  5 17:20 sys/src/cmd/ssh/ssh.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:59,65 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:59,65
	  void
	  usage(void)
	  {
	- 	fprint(2, "usage: ssh [-CiImPpRrw] [-A authlist] [-c cipherlist] [user@]hostname [cmd [args]]\n");
	+ 	fprint(2, "usage: ssh [-CiImPpRr] [-A authlist] [-c cipherlist] [user@]hostname [cmd [args]]\n");
	  	exits("usage");
	  }
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:78,83 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:78,85
	  	atexitkill(getpid());
	  
	  	dowinchange = 0;
	+ 	if(getenv("LINES"))
	+ 		dowinchange = 1;
	  	usepty = -1;
	  	user = nil;
	  	ARGBEGIN{
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:127,135 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:129,134
	  		break;
	  	case 'r':
	  		crstrip = 1;
	- 		break;
	- 	case 'w':
	- 		dowinchange = 1;
	  		break;
	  	default:
	  		usage();
 [rsc] --rw-rw-r-- M 786594 glenda sys 9671 Dec  5 17:20 sys/src/cmd/ssh/ssh.c


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].