home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
stg_v4.lzh
/
get_key.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-11
|
662b
|
47 lines
/*
* get_key() - returns -1 if timeout or char
*/
#include "stglib.h"
#define TIME_RES 10
#define TIME_OUT _time_out
extern int _time_out;
get_key()
{
int to;
char c;
to=TIME_OUT*TIME_RES;
/* if (getuid()<=15)
to=-1;
*/
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
_ss_mode(2,3);
while (to--)
{
if (_gs_rdy(2)==ERR /* && errno==246 */ )
{
usleep(1000000/TIME_RES);
continue;
}
if (read(2,&c,1)==1)
{
_ss_mode(2,0);
signal(SIGINT,SIG_DFL);
signal(SIGQUIT,SIG_DFL);
return(c);
}
}
_ss_mode(2,0);
signal(SIGINT,SIG_DFL);
signal(SIGQUIT,SIG_DFL);
return(ERR);
}