Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 5/22/85; site cbosgd.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!cbosgd!mark From: mark@cbosgd.UUCP (Mark Horton) Newsgroups: net.micro.att,net.unix,net.unix-wizards Subject: Re: CBREAK in S5/~ICANON in V7/4.x Message-ID: <1334@cbosgd.UUCP> Date: Wed, 24-Jul-85 00:34:23 EDT Article-I.D.: cbosgd.1334 Posted: Wed Jul 24 00:34:23 1985 Date-Received: Thu, 25-Jul-85 08:00:57 EDT References: <746@wlcrjs.UUCP> <373@cuae2.UUCP> <2467@sun.uucp> Organization: AT&T Bell Laboratories, Columbus, Oh Lines: 42 Xref: watmath net.micro.att:296 net.unix:5120 net.unix-wizards:13986 This is all pretty confusing to most people, I'll bet. It's even more confusing if you do what I suspect the origional poster did: look up stty in their manual (and in /usr/include/sgtty.h) and notice that CBREAK and TANDEM just aren't there, and neither is TIOCSETN. Chances are that the program they are trying to port from V7/4BSD to SIII/SV uses these. What's going on here is this. sgtty is the interface to the tty driver used in V6 and V7. 4BSD is upward compatible with this interface, although CBERAK and TIOCSETN were in V7. System III changed the interface radically - it's now possible to get much more detailed control of the tty driver, although it's now at a lower level. (Instead of turning on CBREAK, you have to clear ICANON and set VMIN and VTIME, being sure to save the old values for when you come back.) SIII/SV have an upward compatibility package in sgtty, which is how SIII (called UNIX 3.0 at the time) could be upward compatible with the previous release, UNIX 2.0. However, UNIX 2.0 was not the same as V7, in particular it didn't hvae CBREAK or TIOCSETN. So to this day, the compatibility package doesn't have them either. The compatibility package has other problems. For example, when you use it, it clears your ECHOE bit, which will annoy most people. So it's strongly recommended that you don't use the compatibility package, instead ifdef the program to handle either the SV or V7 tty drivers. If you're hopelessly confused by all this, don't worry. There is a package that handles all this stuff for you. It's called curses. You can ask curses for CBREAK mode, for example, by calling crmode(); You can turn off echo by calling noecho(); These calls do the appropriate thing on either 4.2BSD or System V. There are a lot more portability features in the System V curses; these are not all present in the 4.2 curses, but SV curses will run on 4.2 if you have the appropriate licenses. In general, if you're writing a program that wants to turn off echo and get characters one at a time, chances are it's screen oriented. I encourage you to use curses, your application will be more portable. (There are curses implementions for 4.2BSD, System V, MS DOS, and QNX.)