//------------------------------------------------------------------- // studytty.cpp // // This program shows current values of some fields within this // task's 'struct termios' data-structure for 'standard input'. // // compile using: $ g++ studytty.cpp -o studytty // // Reference: W. Ricard Stevens, "Advanced Programming in the // Unix Environment," Addison-Wesley (1993). [See Chapter 11 // on "Terminal I/O" for a full discussion of these 'termios' // terminal control-code entries and their various effects.] // // programmer: ALLAN CRUSE // written on: 18 APR 2006 //------------------------------------------------------------------- #include // for printf() #include // for open() #include // for read() #include // for tcgetattr() int main( int argc, char **argv ) { // get the current 'struct termios' data-structure struct termios tty; tcgetattr( STDIN_FILENO, &tty ); // show the control-code values stored in the c_cc[] array printf( "\n" ); printf( " c_cc[ VINTR ] = 0x%02X \n", tty.c_cc[ VINTR ] ); printf( " c_cc[ VQUIT ] = 0x%02X \n", tty.c_cc[ VQUIT ] ); printf( " c_cc[ VERASE ] = 0x%02X \n", tty.c_cc[ VERASE ] ); printf( " c_cc[ VKILL ] = 0x%02X \n", tty.c_cc[ VKILL ] ); printf( " c_cc[ VEOF ] = 0x%02X \n", tty.c_cc[ VEOF ] ); printf( " c_cc[ VTIME ] = 0x%02X \n", tty.c_cc[ VTIME ] ); printf( " c_cc[ VMIN ] = 0x%02X \n", tty.c_cc[ VMIN ] ); printf( " c_cc[ VSWTC ] = 0x%02X \n", tty.c_cc[ VSWTC ] ); printf( " c_cc[ VSTART ] = 0x%02X \n", tty.c_cc[ VSTART ] ); printf( " c_cc[ VSTOP ] = 0x%02X \n", tty.c_cc[ VSTOP ] ); printf( " c_cc[ VSUSP ] = 0x%02X \n", tty.c_cc[ VSUSP ] ); printf( " c_cc[ VEOL ] = 0x%02X \n", tty.c_cc[ VEOL ] ); printf( " c_cc[ VREPRINT ] = 0x%02X \n", tty.c_cc[ VREPRINT ] ); printf( " c_cc[ VDISCARD ] = 0x%02X \n", tty.c_cc[ VDISCARD ] ); printf( " c_cc[ VWERASE ] = 0x%02X \n", tty.c_cc[ VWERASE ] ); printf( " c_cc[ VLNEXT ] = 0x%02X \n", tty.c_cc[ VLNEXT ] ); printf( " c_cc[ VEOL2 ] = 0x%02X \n", tty.c_cc[ VEOL2 ] ); printf( "\n" ); }