delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/12/13:16:41

From: Kevin Ashley <k DOT ashley AT ulcc DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Getch() in UNIX
Date: Tue, 12 May 1998 17:30:49 +0100
Organization: Posted via ULCC Internet Services
Lines: 30
Message-ID: <35587939.41C6@ulcc.ac.uk>
References: <354EE6B2 DOT 41C6 AT cc DOT hut DOT fi> <35517F12 DOT 2ECAC739 AT cais DOT kaist DOT ac DOT kr>
NNTP-Posting-Host: silver.ulcc.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Dan, Ho-Jin wrote:
> 
> #include <termio.h>
> #include <sys/ioctl.h>
> 
> int getch() {
>    struct termio o, n;
>    char c;
> 
>    ioctl(0, TCGETA, &o);
>    ioctl(0, TCGETA, &n);
....

A minor point, but one that helps portability - most systems that
support
the termio stuff indicate that the function-call interface is preferable
to the ioctl interface. Use tcgetattr, tcsetattr in preference to ioctl.
This has the obvious advantage that it is much easier to re-implement
a function like tcsetattr on another system that doesn't have termio
done
in the device driver than it is to hack ioctl to support extra
attributes.  

------------------------------------------------------------------------------
Kevin Ashley                                       K DOT Ashley AT Ulcc DOT ac DOT uk
Special Projects Manager            
http://www.ulcc.ac.uk/staff/Kevin+Ashley
ULCC                        ...ukc!ncdlab!K.Ashley (but probably not any
more)
                      This is not a signature

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019