login
Header Space

 
 

Re: help GCC, need sgtty.h

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
Date: Tuesday, August 4, 1992 - 3:31 pm

g0p2700@tamuts.tamu.edu (Pitono) asks:

There are now three styles of terminal handling.
The oldest, SGTTY, is compatible to V7 and 4BSD, and uses
  #include <sgtty.h>
  #include <sys/ioctl.h>
The newer ones are TERMIO
  #include <sys/termio.h>
and TERMIOS
  #include <termios.h>

Linux (as well as SunOS and SYSV, I think) uses TERMIOS.
So rewrite your program so that it uses TERMIOS. (It's worth it
if your want your program to be usable for the next five years.)

Example with SGTTY:
    #define raw()       (_tty.sg_flags|=RAW, stty(_tty_ch,&_tty))
    #define noraw()     (_tty.sg_flags&=~RAW,stty(_tty_ch,&_tty))
    #define crmode()    (_tty.sg_flags |= CBREAK, stty(_tty_ch,&_tty))
    #define nocrmode()  (_tty.sg_flags &= ~CBREAK,stty(_tty_ch,&_tty))
    #define echo()      (_tty.sg_flags |= ECHO, stty(_tty_ch, &_tty))
    #define noecho()    (_tty.sg_flags &= ~ECHO, stty(_tty_ch, &_tty))
    #define nl()        (_tty.sg_flags |= CRMOD,stty(_tty_ch, &_tty))
    #define nonl()      (_tty.sg_flags &= ~CRMOD, stty(_tty_ch, &_tty))
    #define savetty()   (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
    #define resetty()   (_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))

The same example with TERMIOS:
    #define crmode()    (_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN]=1,tcsetattr(_tty_ch, TCSAFLUSH, &_tty))
    #define nocrmode()  (_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch, TCSAFLUSH,&_tty))
    #define echo()      (_tty.c_lflag |= ECHO, tcsetattr(_tty_ch, TCSAFLUSH, &_tty))
    #define noecho()    (_tty.c_lflag &=~ECHO, tcsetattr(_tty_ch, TCSAFLUSH, &_tty))
    #define nl()        (_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,tcsetattr(_tty_ch, TCSAFLUSH, &_tty))
    #define nonl()      (_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,tcsetattr(_tty_ch, TCSAFLUSH, &_tty))
    #define savetty()   (tcgetattr(_tty_ch, &_oldtty),tcgetattr(_tty_ch, &_tty))
    #define resetty()   (tcsetattr(_tty_ch, TCSAFLUSH, &_oldtty))

The example with TERMIO is the same as with TERMIOS, but _tty is then of
type 'struct termio', not 'struct termios'.

Bruno Haible
haible@ma2s2.mathematik.uni-karlsruhe.de
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: help GCC, need sgtty.h, Bruno Haible, (Tue Aug 4, 3:31 pm)
speck-geostationary