jpage@rruxa.UUCP (J Page) (08/26/87)
ioctl experts(are they any???): Any help/advice/suggestions on the following 4.2BSD/System V questions: 1. how in System V can CBREAK / ~ECHO, be emulated ???? 2. are there (stty and gtty)-like calls available in System V. Any literature on the ioctl/tty differences would be most appreciated. Thanks in advance, Jim Page Bellcore ST&S Laboratory ihnp4!bellcore!rruxe!jpage
gwyn@brl-smoke.ARPA (Doug Gwyn ) (08/27/87)
In article <299@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: > 1. how in System V can CBREAK / ~ECHO, be emulated ???? Refer to TERMIO(7) (annoyingly in the Adminstrator's Reference Manual instead of the PRM in many UNIX System V documentation sets). You need to figure out what CBREAK mode is supposed to be. Typically, disable ICANON, keep ISIG enabled, and set c_cc[VMIN] to 1 and c_cc[VTIME] to 0. To disable echo, clear all four ECHO* flags. > 2. are there (stty and gtty)-like calls available in System V. The above operations are done via ioctl() using the TCSETA or TCSETAW command codes as described in TERMIO(7). Many older UNIX System V implementations also support old-style gtty()/stty(), which are similar to those on 4BSD, but different in detail (in particular, there is no CBREAK bit). You should avoid using gtty()/stty().
davy@ea.ecn.purdue.edu.UUCP (08/28/87)
In article <299@rruxa.UUCP> jpage@rruxa.UUCP (J Page) writes: > 1. how in System V can CBREAK / ~ECHO, be emulated ???? The System V ioctl is a gross hack. (Who in their right mind would hard-code ^S/^Q into the kernel?) Anyway, to do this, turn off canonical input processing and then set the minimum number of characters to return from reads on to 1, and the timeout to zero: struct terminfo tinfo; ioctl(0, TIOCGETA, &tinfo); tinfo.c_lflag &= ~(ICANON | ECHO); tinfo.c_cc[EOF] = 1; /* min chars to read */ tinfo.c_cc[EOL] = 0; /* timeout */ ioctl(0, TCSETA, &tinfo); > 2. are there (stty and gtty)-like calls available in System V. Nope. They're actually gone from 4.3BSD too; they're implemented as library routines. --Dave Curry Purdue University Engineering Computer Network
Karl.Kleinpaste@cbstr1.att.com (08/28/87)
davy@ea.ecn.purdue.edu writes: > The System V ioctl is a gross hack. The SysV termio ioctl() is wonderfully orthogonal, as compared to the random cruft stuffed into the tchars structure, the "local mode word" crap, and ltchars structures of BSD. The cc[] array is just begging for organized extensions; just change NCC and add new #definitions for the new slots, and you can do with it what you will. Phooey on BSD. > tinfo.c_cc[EOF] = 1; /* min chars to read */ > tinfo.c_cc[EOL] = 0; /* timeout */ Forpetesake, if you're going to use the "min" and "time" fields, kindly call them by their right names: VMIN and VTIME. Use the names as appropriate to the use of the fields. Furthermore, you neglected the leading V on the names you did use. (Yes, overloading VEOF/VEOL with VMIN/VTIME was not too bright.) > > 2. are there (stty and gtty)-like calls available in System V. > > Nope. They're actually gone from 4.3BSD too; they're implemented as library > routines. False. There are stty/gtty compatibility routines in the kernel; you can issue an actual stty() system call, which will take a V7-style ioctl() package and perform some standardized conversions into the SysV termio scheme. There is still an <sgtty.h> file. Karl
bzs@bu-cs.bu.edu (Barry Shein) (08/28/87)
I sent him a copy of my ttyset() stuff which conditionally compiles under 4.x or SysV and gives a simple abstracted call interface to the common terminal modes. It's also available via anonymous FTP from BU-CS.BU.EDU. It's no panacea but for typical applications (like writing games or full screen editors) it should save a novice a couple of hours. There's an example program and some doc in there. It needs to be tested and possibly modified on SVR3, I don't have access to such a system. It's already been tested on 4.2, 4.3, SVR1, PC7300 and few releases of SVR2. -Barry Shein, Boston University