]> granicus.if.org Git - strace/blobdiff - term.c
"Modernize" all old-style function parameter declarations
[strace] / term.c
diff --git a/term.c b/term.c
index 4cf10a925c3be890128d7ec7c1f155a1dfcb2c67..23d2317f5161246e265b1c47335555066783700b 100644 (file)
--- a/term.c
+++ b/term.c
 
 #include "defs.h"
 
+#ifdef LINUX
+/*
+ * The C library's definition of struct termios might differ from
+ * the kernel one, and we need to use the kernel layout.
+ */
+#include <linux/termios.h>
+#else
+
 #ifdef HAVE_TERMIO_H
 #include <termio.h>
 #endif /* HAVE_TERMIO_H */
 
 #include <termios.h>
+#endif
 
 #ifdef HAVE_SYS_FILIO_H
 #include <sys/filio.h>
 #endif
 
-static struct xlat tcxonc_options[] = {
+static const struct xlat tcxonc_options[] = {
        { TCOOFF,       "TCOOFF"        },
        { TCOON,        "TCOON"         },
        { TCIOFF,       "TCIOFF"        },
@@ -47,14 +56,16 @@ static struct xlat tcxonc_options[] = {
        { 0,            NULL            },
 };
 
-static struct xlat tcflsh_options[] = {
+#ifdef TCLFLSH
+static const struct xlat tcflsh_options[] = {
        { TCIFLUSH,     "TCIFLUSH"      },
        { TCOFLUSH,     "TCOFLUSH"      },
        { TCIOFLUSH,    "TCIOFLUSH"     },
        { 0,            NULL            },
 };
+#endif
 
-static struct xlat baud_options[] = {
+static const struct xlat baud_options[] = {
        { B0,           "B0"            },
        { B50,          "B50"           },
        { B75,          "B75"           },
@@ -129,7 +140,7 @@ static struct xlat baud_options[] = {
        { 0,            NULL            },
 };
 
-static struct xlat modem_flags[] = {
+static const struct xlat modem_flags[] = {
 #ifdef TIOCM_LE
        { TIOCM_LE,     "TIOCM_LE",     },
 #endif
@@ -167,13 +178,17 @@ static struct xlat modem_flags[] = {
 };
 
 
-int
-term_ioctl(tcp, code, arg)
-struct tcb *tcp;
-long code, arg;
+int term_ioctl(struct tcb *tcp, long code, long arg)
 {
        struct termios tios;
+#ifndef FREEBSD
        struct termio tio;
+#else
+       #define TCGETS  TIOCGETA
+       #define TCSETS  TIOCSETA
+       #define TCSETSW TIOCSETAW
+       #define TCSETSF TIOCSETAF
+#endif
        struct winsize ws;
 #ifdef TIOCGSIZE
        struct  ttysize ts;
@@ -198,7 +213,16 @@ long code, arg;
                        return 0;
                if (abbrev(tcp)) {
                        tprintf(", {");
+#ifndef FREEBSD
                        printxval(baud_options, tios.c_cflag & CBAUD, "B???");
+#else
+                       printxval(baud_options, tios.c_ispeed, "B???");
+                       if (tios.c_ispeed != tios.c_ospeed) {
+                               tprintf(" (in)");
+                               printxval(baud_options, tios.c_ospeed, "B???");
+                               tprintf(" (out)");
+                       }
+#endif
                        tprintf(" %sopost %sisig %sicanon %secho ...}",
                                (tios.c_oflag & OPOST) ? "" : "-",
                                (tios.c_lflag & ISIG) ? "" : "-",
@@ -210,7 +234,7 @@ long code, arg;
                        (long) tios.c_iflag, (long) tios.c_oflag);
                tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
                        (long) tios.c_cflag, (long) tios.c_lflag);
-#ifndef SVR4
+#if !defined(SVR4) && !defined(FREEBSD)
                tprintf("c_line=%u, ", tios.c_line);
 #endif
                if (!(tios.c_lflag & ICANON))
@@ -290,15 +314,18 @@ long code, arg;
 #endif
 
        /* ioctls with a direct decodable arg */
-
+#ifdef TCXONC
        case TCXONC:
                tprintf(", ");
                printxval(tcxonc_options, arg, "TC???");
                return 1;
+#endif
+#ifdef TCLFLSH
        case TCFLSH:
                tprintf(", ");
                printxval(tcflsh_options, arg, "TC???");
                return 1;
+#endif
 
        /* ioctls with an indirect parameter displayed as modem flags */
 
@@ -307,11 +334,10 @@ long code, arg;
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
-               if (umove(tcp, arg, &arg) < 0)
+               if (umove(tcp, arg, &i) < 0)
                        return 0;
                tprintf(", [");
-               if (!printflags(modem_flags, arg))
-                       tprintf("0");
+               printflags(modem_flags, i, "TIOCM_???");
                tprintf("]");
                return 1;
 #endif /* TIOCMGET */
@@ -385,16 +411,8 @@ long code, arg;
        case TIOCGPTN:
 #endif
                tprintf(", ");
-               printnum(tcp, arg, "%d");
-               return 1;
-
-#if 0
-       /* ioctls with an indirect parameter displayed in hex */
-
-               tprintf(", ");
-               printnum(tcp, arg, "%#x");
+               printnum_int(tcp, arg, "%d");
                return 1;
-#endif
 
        /* ioctls with an indirect parameter displayed as a char */
 
@@ -430,4 +448,3 @@ long code, arg;
                return 0;
        }
 }
-