/* setraw.c */ #include #include static struct termios ts, ots; /* ts is the new structure, ots is the old one */ setraw ( unit ) int unit; { tcgetattr(unit, &ts); ots = ts; ts.c_cflag |= CSTOPB; /* set 2 stop bits in control flags */ ts.c_iflag &= ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON /* | BRKINT */ ); /* c_iflag are input modes: INLCR translate NL to CR on input ICRNL tralate cr to newline in input IUCLC map uppercase to lowercase on input ISTRIP strip off eigth bit IXON enable XON/XOFF BRKINT if INBRK not set, generate SIGINT on BREAK, or ret \0 */ ts.c_oflag &= ~OPOST; /* output modes: OPOST enable implementation-defined output processing */ ts.c_lflag &= ~(ICANON | ISIG | ECHO); /* local modes: ICANON enables special charactres EOF, EOLF, EOL2, ERASE, etc. ISIG INRT QUIT SUSP DSUSP generate corresponding signal ECHO echo input characters */ cfsetospeed(&ts,B9600); cfsetispeed(&ts,B9600), tcsetattr(unit, TCSANOW, &ts); /* set the attributes of the terminal */ }