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 /* __GLIBC__ */
36 #ifdef HAVE_SYS_FILIO_H
37 #include <sys/filio.h>
40 static struct xlat tcxonc_options[] = {
48 static struct xlat tcflsh_options[] = {
49 { TCIFLUSH, "TCIFLUSH" },
50 { TCOFLUSH, "TCOFLUSH" },
51 { TCIOFLUSH, "TCIOFLUSH" },
55 static struct xlat baud_options[] = {
85 static struct xlat modem_flags[] = {
87 { TIOCM_LE, "TIOCM_LE", },
90 { TIOCM_DTR, "TIOCM_DTR", },
93 { TIOCM_RTS, "TIOCM_RTS", },
96 { TIOCM_ST, "TIOCM_ST", },
99 { TIOCM_SR, "TIOCM_SR", },
102 { TIOCM_CTS, "TIOCM_CTS", },
105 { TIOCM_CAR, "TIOCM_CAR", },
108 { TIOCM_CD, "TIOCM_CD", },
111 { TIOCM_RNG, "TIOCM_RNG", },
114 { TIOCM_RI, "TIOCM_RI", },
117 { TIOCM_DSR, "TIOCM_DSR", },
124 term_ioctl(tcp, code, arg)
141 /* ioctls with termios or termio args */
150 if (!verbose(tcp) || umove(tcp, arg, &tios) < 0)
154 printxval(baud_options, tios.c_cflag & CBAUD, "B???");
155 tprintf(" %sopost %sisig %sicanon %secho ...}",
156 (tios.c_oflag & OPOST) ? "" : "-",
157 (tios.c_lflag & ISIG) ? "" : "-",
158 (tios.c_lflag & ICANON) ? "" : "-",
159 (tios.c_lflag & ECHO) ? "" : "-");
162 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
163 (long) tios.c_iflag, (long) tios.c_oflag);
164 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
165 (long) tios.c_cflag, (long) tios.c_lflag);
167 tprintf("c_line=%u, ", tios.c_line);
169 if (!(tios.c_lflag & ICANON))
170 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
171 tios.c_cc[VMIN], tios.c_cc[VTIME]);
173 for (i = 0; i < NCCS; i++)
174 tprintf("\\x%02x", tios.c_cc[i]);
186 if (!verbose(tcp) || umove(tcp, arg, &tio) < 0)
190 printxval(baud_options, tio.c_cflag & CBAUD, "B???");
191 tprintf(" %sopost %sisig %sicanon %secho ...}",
192 (tio.c_oflag & OPOST) ? "" : "-",
193 (tio.c_lflag & ISIG) ? "" : "-",
194 (tio.c_lflag & ICANON) ? "" : "-",
195 (tio.c_lflag & ECHO) ? "" : "-");
198 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
199 (long) tio.c_iflag, (long) tio.c_oflag);
200 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
201 (long) tio.c_cflag, (long) tio.c_lflag);
202 tprintf("c_line=%u, ", tio.c_line);
204 if (!(tio.c_lflag & ICANON))
205 tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
206 tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
208 if (!(tio.c_lflag & ICANON))
209 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
210 tio.c_cc[VMIN], tio.c_cc[VTIME]);
213 for (i = 0; i < NCC; i++)
214 tprintf("\\x%02x", tio.c_cc[i]);
219 /* ioctls with winsize or ttysize args */
226 if (!verbose(tcp) || umove(tcp, arg, &ws) < 0)
228 tprintf(", {ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
229 ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
231 #endif /* TIOCGWINSZ */
238 if (!verbose(tcp) || umove(tcp, arg, &ts) < 0)
240 tprintf(", {ts_lines=%d, ts_cols=%d}",
241 ts.ts_lines, ts.ts_cols);
245 /* ioctls with a direct decodable arg */
249 printxval(tcxonc_options, arg, "TC???");
253 printxval(tcflsh_options, arg, "TC???");
256 /* ioctls with an indirect parameter displayed as modem flags */
263 if (umove(tcp, arg, &arg) < 0)
266 if (!printflags(modem_flags, arg))
270 #endif /* TIOCMGET */
272 /* ioctls with an indirect parameter displayed in decimal */
335 printnum(tcp, arg, "%d");
339 /* ioctls with an indirect parameter displayed in hex */
342 printnum(tcp, arg, "%#x");
346 /* ioctls with an indirect parameter displayed as a char */
352 printstr(tcp, arg, 1);
355 /* ioctls with no parameters */
374 /* ioctls which are unknown */