#include #include #include #include #ifdef HAS_G2C #include #else #define ftnlen int #define integer int #endif #ifndef TWO_UNDERSCORE #define check_key__ check_key_ #define in_key__ in_key_ #endif void check_key__(integer *kstat) { if (isatty(0)) { struct termios tios0,tios1; struct timeval to={0,0}; fd_set rfds; tcgetattr(0,&tios0); tios1 = tios0; tios1.c_lflag &= ~ICANON; tcsetattr(0,TCSANOW,&tios1); FD_ZERO(&rfds); FD_SET(0,&rfds); *kstat = select(1,&rfds,0,0,&to); tcsetattr(0,TCSANOW,&tios0); if (*kstat == -1) *kstat = 0; } else *kstat = 1; } void in_key__(char *key, ftnlen *key_len) { if (isatty(0)) { struct termios tios0,tios1; tcgetattr(0,&tios0); tios1 = tios0; tios1.c_lflag &= ~ICANON; tcsetattr(0,TCSANOW,&tios1); read(0,key,1); tcsetattr(0,TCSANOW,&tios0); } }