| 72 | } |
| 73 | |
| 74 | static void term_init(BOOL allow_ctrlc) |
| 75 | { |
| 76 | struct termios tty; |
| 77 | |
| 78 | memset(&tty, 0, sizeof(tty)); |
| 79 | tcgetattr (0, &tty); |
| 80 | oldtty = tty; |
| 81 | old_fd0_flags = fcntl(0, F_GETFL); |
| 82 | |
| 83 | tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |
| 84 | |INLCR|IGNCR|ICRNL|IXON); |
| 85 | tty.c_oflag |= OPOST; |
| 86 | tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); |
| 87 | if (!allow_ctrlc) |
| 88 | tty.c_lflag &= ~ISIG; |
| 89 | tty.c_cflag &= ~(CSIZE|PARENB); |
| 90 | tty.c_cflag |= CS8; |
| 91 | tty.c_cc[VMIN] = 1; |
| 92 | tty.c_cc[VTIME] = 0; |
| 93 | |
| 94 | tcsetattr (0, TCSANOW, &tty); |
| 95 | |
| 96 | atexit(term_exit); |
| 97 | } |
| 98 | |
| 99 | static void console_write(void *opaque, const uint8_t *buf, int len) |
| 100 | { |