static int cached_stty(int fd,Sgttyb *buf){ int xfd = (0 <= fd && fd < MAXFD) ? fd: MAXFD-1; int rcode; if( cur_sgttyb[xfd].SG_flags != buf->SG_flags || cur_sgttyb[xfd].SG_lflag != buf->SG_lflag ){ cur_sgttyb[xfd] = *buf; #ifdef hpux tcdrain(fd); usleep(100*1000); #endif rcode = TCsetattr(fd,buf); #ifdef hpux set_cbreak(fd,!(buf->SG_lflag&ICANON)); #endif return rcode; }else return 0; }
int pause(void) { int ch; struct termios save_termios; set_cbreak(&save_termios); fflush(stdout); ch = getchar(); if( ch == 27 ) { ch = getchar(); if( ch == 91 ) { ch = getchar(); ch = ch + 2000; } ch = ch + 1000; } if( ch == 195 ) { ch = getchar(); ch = ch + 10000; } unset_cbreak(&save_termios); return ch; }