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[] = {
51 static struct xlat tcflsh_options[] = {
52 { TCIFLUSH, "TCIFLUSH" },
53 { TCOFLUSH, "TCOFLUSH" },
54 { TCIOFLUSH, "TCIOFLUSH" },
59 static struct xlat baud_options[] = {
84 { B115200, "B115200" },
87 { B230400, "B230400" },
90 { B460800, "B460800" },
93 { B500000, "B500000" },
96 { B576000, "B576000" },
99 { B921600, "B921600" },
102 { B1000000, "B1000000" },
105 { B1152000, "B1152000" },
108 { B1500000, "B1500000" },
111 { B2000000, "B2000000" },
114 { B2500000, "B2500000" },
117 { B3000000, "B3000000" },
120 { B3500000, "B3500000" },
123 { B4000000, "B4000000" },
134 static struct xlat modem_flags[] = {
136 { TIOCM_LE, "TIOCM_LE", },
139 { TIOCM_DTR, "TIOCM_DTR", },
142 { TIOCM_RTS, "TIOCM_RTS", },
145 { TIOCM_ST, "TIOCM_ST", },
148 { TIOCM_SR, "TIOCM_SR", },
151 { TIOCM_CTS, "TIOCM_CTS", },
154 { TIOCM_CAR, "TIOCM_CAR", },
157 { TIOCM_CD, "TIOCM_CD", },
160 { TIOCM_RNG, "TIOCM_RNG", },
163 { TIOCM_RI, "TIOCM_RI", },
166 { TIOCM_DSR, "TIOCM_DSR", },
173 term_ioctl(tcp, code, arg)
181 #define TCGETS TIOCGETA
182 #define TCSETS TIOCSETA
183 #define TCSETSW TIOCSETAW
184 #define TCSETSF TIOCSETAF
197 /* ioctls with termios or termio args */
206 if (!verbose(tcp) || umove(tcp, arg, &tios) < 0)
211 printxval(baud_options, tios.c_cflag & CBAUD, "B???");
213 printxval(baud_options, tios.c_ispeed, "B???");
214 if (tios.c_ispeed != tios.c_ospeed) {
216 printxval(baud_options, tios.c_ospeed, "B???");
220 tprintf(" %sopost %sisig %sicanon %secho ...}",
221 (tios.c_oflag & OPOST) ? "" : "-",
222 (tios.c_lflag & ISIG) ? "" : "-",
223 (tios.c_lflag & ICANON) ? "" : "-",
224 (tios.c_lflag & ECHO) ? "" : "-");
227 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
228 (long) tios.c_iflag, (long) tios.c_oflag);
229 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
230 (long) tios.c_cflag, (long) tios.c_lflag);
231 #if !defined(SVR4) && !defined(FREEBSD)
232 tprintf("c_line=%u, ", tios.c_line);
234 if (!(tios.c_lflag & ICANON))
235 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
236 tios.c_cc[VMIN], tios.c_cc[VTIME]);
238 for (i = 0; i < NCCS; i++)
239 tprintf("\\x%02x", tios.c_cc[i]);
251 if (!verbose(tcp) || umove(tcp, arg, &tio) < 0)
255 printxval(baud_options, tio.c_cflag & CBAUD, "B???");
256 tprintf(" %sopost %sisig %sicanon %secho ...}",
257 (tio.c_oflag & OPOST) ? "" : "-",
258 (tio.c_lflag & ISIG) ? "" : "-",
259 (tio.c_lflag & ICANON) ? "" : "-",
260 (tio.c_lflag & ECHO) ? "" : "-");
263 tprintf(", {c_iflags=%#lx, c_oflags=%#lx, ",
264 (long) tio.c_iflag, (long) tio.c_oflag);
265 tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
266 (long) tio.c_cflag, (long) tio.c_lflag);
267 tprintf("c_line=%u, ", tio.c_line);
269 if (!(tio.c_lflag & ICANON))
270 tprintf("c_cc[_VMIN]=%d, c_cc[_VTIME]=%d, ",
271 tio.c_cc[_VMIN], tio.c_cc[_VTIME]);
273 if (!(tio.c_lflag & ICANON))
274 tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
275 tio.c_cc[VMIN], tio.c_cc[VTIME]);
278 for (i = 0; i < NCC; i++)
279 tprintf("\\x%02x", tio.c_cc[i]);
284 /* ioctls with winsize or ttysize args */
291 if (!verbose(tcp) || umove(tcp, arg, &ws) < 0)
293 tprintf(", {ws_row=%d, ws_col=%d, ws_xpixel=%d, ws_ypixel=%d}",
294 ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
296 #endif /* TIOCGWINSZ */
303 if (!verbose(tcp) || umove(tcp, arg, &ts) < 0)
305 tprintf(", {ts_lines=%d, ts_cols=%d}",
306 ts.ts_lines, ts.ts_cols);
310 /* ioctls with a direct decodable arg */
314 printxval(tcxonc_options, arg, "TC???");
320 printxval(tcflsh_options, arg, "TC???");
324 /* ioctls with an indirect parameter displayed as modem flags */
331 if (umove(tcp, arg, &arg) < 0)
334 if (!printflags(modem_flags, arg))
338 #endif /* TIOCMGET */
340 /* ioctls with an indirect parameter displayed in decimal */
409 printnum(tcp, arg, "%d");
413 /* ioctls with an indirect parameter displayed in hex */
416 printnum(tcp, arg, "%#x");
420 /* ioctls with an indirect parameter displayed as a char */
426 printstr(tcp, arg, 1);
429 /* ioctls with no parameters */
448 /* ioctls which are unknown */