1 /* The <termios.h> header is used for controlling tty modes. */
6 typedef unsigned short tcflag_t
;
7 typedef unsigned char cc_t
;
8 typedef unsigned int speed_t
;
10 #define NCCS 20 /* size of cc_c array, some extra space
13 /* Primary terminal control structure. POSIX Table 7-1. */
15 tcflag_t c_iflag
; /* input modes */
16 tcflag_t c_oflag
; /* output modes */
17 tcflag_t c_cflag
; /* control modes */
18 tcflag_t c_lflag
; /* local modes */
19 speed_t c_ispeed
; /* input speed */
20 speed_t c_ospeed
; /* output speed */
21 cc_t c_cc
[NCCS
]; /* control characters */
24 /* Values for termios c_iflag bit map. POSIX Table 7-2. */
25 #define BRKINT 0x0001 /* signal interrupt on break */
26 #define ICRNL 0x0002 /* map CR to NL on input */
27 #define IGNBRK 0x0004 /* ignore break */
28 #define IGNCR 0x0008 /* ignore CR */
29 #define IGNPAR 0x0010 /* ignore characters with parity errors */
30 #define INLCR 0x0020 /* map NL to CR on input */
31 #define INPCK 0x0040 /* enable input parity check */
32 #define ISTRIP 0x0080 /* mask off 8th bit */
33 #define IXOFF 0x0100 /* enable start/stop input control */
34 #define IXON 0x0200 /* enable start/stop output control */
35 #define PARMRK 0x0400 /* mark parity errors in the input queue */
37 /* Values for termios c_oflag bit map. POSIX Sec. 7.1.2.3. */
38 #define OPOST 0x0001 /* perform output processing */
40 /* Values for termios c_cflag bit map. POSIX Table 7-3. */
41 #define CLOCAL 0x0001 /* ignore modem status lines */
42 #define CREAD 0x0002 /* enable receiver */
43 #define CSIZE 0x000C /* number of bits per character */
44 #define CS5 0x0000 /* if CSIZE is CS5, characters are 5 bits */
45 #define CS6 0x0004 /* if CSIZE is CS6, characters are 6 bits */
46 #define CS7 0x0008 /* if CSIZE is CS7, characters are 7 bits */
47 #define CS8 0x000C /* if CSIZE is CS8, characters are 8 bits */
48 #define CSTOPB 0x0010 /* send 2 stop bits if set, else 1 */
49 #define HUPCL 0x0020 /* hang up on last close */
50 #define PARENB 0x0040 /* enable parity on output */
51 #define PARODD 0x0080 /* use odd parity if set, else even */
53 /* Values for termios c_lflag bit map. POSIX Table 7-4. */
54 #define ECHO 0x0001 /* enable echoing of input characters */
55 #define ECHOE 0x0002 /* echo ERASE as backspace */
56 #define ECHOK 0x0004 /* echo KILL */
57 #define ECHONL 0x0008 /* echo NL */
58 #define ICANON 0x0010 /* canonical input (erase and kill enabled) */
59 #define IEXTEN 0x0020 /* enable extended functions */
60 #define ISIG 0x0040 /* enable signals */
61 #define NOFLSH 0x0080 /* disable flush after interrupt or quit */
62 #define TOSTOP 0x0100 /* send SIGTTOU (job control, not implemented*/
64 /* Indices into c_cc array. Default values in parentheses. POSIX Table 7-5. */
65 #define VEOF 0 /* cc_c[VEOF] = EOF char (^D) */
66 #define VEOL 1 /* cc_c[VEOL] = EOL char (undef) */
67 #define VERASE 2 /* cc_c[VERASE] = ERASE char (^H) */
68 #define VINTR 3 /* cc_c[VINTR] = INTR char (DEL) */
69 #define VKILL 4 /* cc_c[VKILL] = KILL char (^U) */
70 #define VMIN 5 /* cc_c[VMIN] = MIN value for timer */
71 #define VQUIT 6 /* cc_c[VQUIT] = QUIT char (^\) */
72 #define VTIME 7 /* cc_c[VTIME] = TIME value for timer */
73 #define VSUSP 8 /* cc_c[VSUSP] = SUSP (^Z, ignored) */
74 #define VSTART 9 /* cc_c[VSTART] = START char (^S) */
75 #define VSTOP 10 /* cc_c[VSTOP] = STOP char (^Q) */
78 /* This is defined in <unistd.h> in NetBSD headers. */
79 #else /* !__NBSD_LIBC */
80 #define _POSIX_VDISABLE (cc_t)0xFF /* You can't even generate this
81 * character with 'normal' keyboards.
82 * But some language specific keyboards
83 * can generate 0xFF. It seems that all
84 * 256 are used, so cc_t should be a
87 #endif /* !__NBSD_LIBC */
89 /* Values for the baud rate settings. POSIX Table 7-6. */
90 #define B0 0x0000 /* hang up the line */
91 #define B50 0x1000 /* 50 baud */
92 #define B75 0x2000 /* 75 baud */
93 #define B110 0x3000 /* 110 baud */
94 #define B134 0x4000 /* 134.5 baud */
95 #define B150 0x5000 /* 150 baud */
96 #define B200 0x6000 /* 200 baud */
97 #define B300 0x7000 /* 300 baud */
98 #define B600 0x8000 /* 600 baud */
99 #define B1200 0x9000 /* 1200 baud */
100 #define B1800 0xA000 /* 1800 baud */
101 #define B2400 0xB000 /* 2400 baud */
102 #define B4800 0xC000 /* 4800 baud */
103 #define B9600 0xD000 /* 9600 baud */
104 #define B19200 0xE000 /* 19200 baud */
105 #define B38400 0xF000 /* 38400 baud */
107 /* Optional actions for tcsetattr(). POSIX Sec. 7.2.1.2. */
108 #define TCSANOW 1 /* changes take effect immediately */
109 #define TCSADRAIN 2 /* changes take effect after output is done */
110 #define TCSAFLUSH 3 /* wait for output to finish and flush input */
112 /* Queue_selector values for tcflush(). POSIX Sec. 7.2.2.2. */
113 #define TCIFLUSH 1 /* flush accumulated input data */
114 #define TCOFLUSH 2 /* flush accumulated output data */
115 #define TCIOFLUSH 3 /* flush accumulated input and output data */
117 /* Action values for tcflow(). POSIX Sec. 7.2.2.2. */
118 #define TCOOFF 1 /* suspend output */
119 #define TCOON 2 /* restart suspended output */
120 #define TCIOFF 3 /* transmit a STOP character on the line */
121 #define TCION 4 /* transmit a START character on the line */
123 int tcsendbreak(int _fildes
, int _duration
);
124 int tcdrain(int _filedes
);
125 int tcflush(int _filedes
, int _queue_selector
);
126 int tcflow(int _filedes
, int _action
);
127 speed_t
cfgetispeed(const struct termios
*_termios_p
);
128 speed_t
cfgetospeed(const struct termios
*_termios_p
);
129 int cfsetispeed(struct termios
*_termios_p
, speed_t _speed
);
130 int cfsetospeed(struct termios
*_termios_p
, speed_t _speed
);
131 int tcgetattr(int _filedes
, struct termios
*_termios_p
);
132 int tcsetattr(int _filedes
, int _opt_actions
, const struct termios
136 #define cfgetispeed(termios_p) ((termios_p)->c_ispeed)
139 #define cfgetospeed(termios_p) ((termios_p)->c_ospeed)
142 #define cfsetispeed(termios_p, speed) ((termios_p)->c_ispeed = (speed), 0)
145 #define cfsetospeed(termios_p, speed) ((termios_p)->c_ospeed = (speed), 0)
148 /* Extensions to the termios c_iflag bit map. */
149 #define IXANY 0x0800 /* allow any key to continue ouptut */
150 #define SCANCODES 0x1000 /* send scancodes */
152 /* Extensions to the termios c_oflag bit map. They are only active iff
153 * OPOST is enabled. */
154 #define ONLCR 0x0002 /* Map NL to CR-NL on output */
155 #define XTABS 0x0004 /* Expand tabs to spaces */
156 #define ONOEOT 0x0008 /* discard EOT's (^D) on output) */
158 /* Extensions to the termios c_lflag bit map. */
159 #define LFLUSHO 0x0200 /* Flush output. */
161 /* Extensions to the c_cc array. */
162 #define VREPRINT 11 /* cc_c[VREPRINT] (^R) */
163 #define VLNEXT 12 /* cc_c[VLNEXT] (^V) */
164 #define VDISCARD 13 /* cc_c[VDISCARD] (^O) */
166 /* Extensions to baud rate settings. */
167 #define B57600 0x0100 /* 57600 baud */
168 #define B115200 0x0200 /* 115200 baud */
170 /* These are the default settings used by the kernel and by 'stty sane' */
172 #define TCTRL_DEF (CREAD | CS8 | HUPCL)
173 #define TINPUT_DEF (BRKINT | ICRNL | IXON | IXANY)
174 #define TOUTPUT_DEF (OPOST | ONLCR)
175 #define TLOCAL_DEF (ISIG | IEXTEN | ICANON | ECHO | ECHOE)
176 #define TSPEED_DEF B9600
178 #define TEOF_DEF '\4' /* ^D */
179 #define TEOL_DEF _POSIX_VDISABLE
180 #define TERASE_DEF '\10' /* ^H */
181 #define TINTR_DEF '\3' /* ^C */
182 #define TKILL_DEF '\25' /* ^U */
184 #define TQUIT_DEF '\34' /* ^\ */
185 #define TSTART_DEF '\21' /* ^Q */
186 #define TSTOP_DEF '\23' /* ^S */
187 #define TSUSP_DEF '\32' /* ^Z */
189 #define TREPRINT_DEF '\22' /* ^R */
190 #define TLNEXT_DEF '\26' /* ^V */
191 #define TDISCARD_DEF '\17' /* ^O */
193 /* Window size. This information is stored in the TTY driver but not used.
194 * This can be used for screen based applications in a window environment.
195 * The ioctls TIOCGWINSZ and TIOCSWINSZ can be used to get and set this
201 unsigned short ws_row
; /* rows, in characters */
202 unsigned short ws_col
; /* columns, in characters */
203 unsigned short ws_xpixel
; /* horizontal size, pixels */
204 unsigned short ws_ypixel
; /* vertical size, pixels */
207 #endif /* _TERMIOS_H */