2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #endif /* HAVE_TERMIO_H */
38 #ifdef HAVE_SYS_FILIO_H
39 #include <sys/filio.h>
42 static struct xlat tcxonc_options[] = {
50 static struct xlat tcflsh_options[] = {
51 { TCIFLUSH, "TCIFLUSH" },
52 { TCOFLUSH, "TCOFLUSH" },
53 { TCIOFLUSH, "TCIOFLUSH" },
57 static struct xlat baud_options[] = {
87 static struct xlat modem_flags[] = {
89 { TIOCM_LE, "TIOCM_LE", },
92 { TIOCM_DTR, "TIOCM_DTR", },
95 { TIOCM_RTS, "TIOCM_RTS", },
98 { TIOCM_ST, "TIOCM_ST", },
101 { TIOCM_SR, "TIOCM_SR", },
104 { TIOCM_CTS, "TIOCM_CTS", },
107 { TIOCM_CAR, "TIOCM_CAR", },
110 { TIOCM_CD, "TIOCM_CD", },
113 { TIOCM_RNG, "TIOCM_RNG", },
116 { TIOCM_RI, "TIOCM_RI", },
119 { TIOCM_DSR, "TIOCM_DSR", },
126 term_ioctl(tcp, code, arg)
143 /* ioctls with termios or termio args */
152 if (!verbose(tcp) || umove(tcp, arg, &tios) < 0)
156 printxval(baud_options, tios.c_cflag & CBAUD, "B???");
157 tprintf(" %sopost %sisig %sicanon %secho ...}",
158 (tios.c_oflag & OPOST) ? "" : "-",
159 (tios.c_lflag & ISIG) ? "" : "-",
160 (tios.c_lflag & ICANON) ? "" : "-",
161 (tios.c_lflag & ECHO) ? "" : "-");
164 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
165 (long) tios.c_iflag, (long) tios.c_oflag);
166 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
167 (long) tios.c_cflag, (long) tios.c_lflag);
169 tprintf("c_line=%u, ", tios.c_line);
171 if (!(tios.c_lflag & ICANON))
172 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
173 tios.c_cc[VMIN], tios.c_cc[VTIME]);
175 for (i = 0; i < NCCS; i++)
176 tprintf("\\x%02x", tios.c_cc[i]);
188 if (!verbose(tcp) || umove(tcp, arg, &tio) < 0)
192 printxval(baud_options, tio.c_cflag & CBAUD, "B???");
193 tprintf(" %sopost %sisig %sicanon %secho ...}",
194 (tio.c_oflag & OPOST) ? "" : "-",
195 (tio.c_lflag & ISIG) ? "" : "-",
196 (tio.c_lflag & ICANON) ? "" : "-",
197 (tio.c_lflag & ECHO) ? "" : "-");
200 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
201 (long) tio.c_iflag, (long) tio.c_oflag);
202 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
203 (long) tio.c_cflag, (long) tio.c_lflag);
204 tprintf("c_line=%u, ", tio.c_line);
206 if (!(tio.c_lflag & ICANON))
207 tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
208 tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
210 if (!(tio.c_lflag & ICANON))
211 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
212 tio.c_cc[VMIN], tio.c_cc[VTIME]);
215 for (i = 0; i < NCC; i++)
216 tprintf("\\x%02x", tio.c_cc[i]);
221 /* ioctls with winsize or ttysize args */
228 if (!verbose(tcp) || umove(tcp, arg, &ws) < 0)
230 tprintf(", {ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
231 ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
233 #endif /* TIOCGWINSZ */
240 if (!verbose(tcp) || umove(tcp, arg, &ts) < 0)
242 tprintf(", {ts_lines=%d, ts_cols=%d}",
243 ts.ts_lines, ts.ts_cols);
247 /* ioctls with a direct decodable arg */
251 printxval(tcxonc_options, arg, "TC???");
255 printxval(tcflsh_options, arg, "TC???");
258 /* ioctls with an indirect parameter displayed as modem flags */
265 if (umove(tcp, arg, &arg) < 0)
268 if (!printflags(modem_flags, arg))
272 #endif /* TIOCMGET */
274 /* ioctls with an indirect parameter displayed in decimal */
343 printnum(tcp, arg, "%d");
347 /* ioctls with an indirect parameter displayed in hex */
350 printnum(tcp, arg, "%#x");
354 /* ioctls with an indirect parameter displayed as a char */
360 printstr(tcp, arg, 1);
363 /* ioctls with no parameters */
382 /* ioctls which are unknown */