]> andersk Git - openssh.git/blobdiff - ttymodes.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / ttymodes.c
index 40d536e2cd272c707e988d02a2b665d7cc9a8643..6f51b8a70836618782570d5680fc80b663f4d709 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenBSD: ttymodes.c,v 1.29 2008/11/02 00:16:16 stevesk Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
 
 #include "includes.h"
 
+#include <sys/types.h>
+
+#include <errno.h>
+#include <string.h>
 #include <termios.h>
+#include <stdarg.h>
 
 #include "packet.h"
 #include "log.h"
 #include "ssh1.h"
 #include "compat.h"
 #include "buffer.h"
-#include "bufaux.h"
 
 #define TTY_OP_END             0
 /*
@@ -293,6 +298,10 @@ tty_make_modes(int fd, struct termios *tiop)
        }
 
        if (tiop == NULL) {
+               if (fd == -1) {
+                       debug("tty_make_modes: no fd or tio");
+                       goto end;
+               }
                if (tcgetattr(fd, &tio) == -1) {
                        logit("tcgetattr: %.100s", strerror(errno));
                        goto end;
@@ -302,22 +311,18 @@ tty_make_modes(int fd, struct termios *tiop)
 
        /* Store input and output baud rates. */
        baud = speed_to_baud(cfgetospeed(&tio));
-       debug3("tty_make_modes: ospeed %d", baud);
        buffer_put_char(&buf, tty_op_ospeed);
        buffer_put_int(&buf, baud);
        baud = speed_to_baud(cfgetispeed(&tio));
-       debug3("tty_make_modes: ispeed %d", baud);
        buffer_put_char(&buf, tty_op_ispeed);
        buffer_put_int(&buf, baud);
 
        /* Store values of mode flags. */
 #define TTYCHAR(NAME, OP) \
-       debug3("tty_make_modes: %d %d", OP, tio.c_cc[NAME]); \
        buffer_put_char(&buf, OP); \
        put_arg(&buf, special_char_encode(tio.c_cc[NAME]));
 
 #define TTYMODE(NAME, FIELD, OP) \
-       debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \
        buffer_put_char(&buf, OP); \
        put_arg(&buf, ((tio.FIELD & NAME) != 0));
 
@@ -348,11 +353,10 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
        int n_bytes = 0;
        int failure = 0;
        u_int (*get_arg)(void);
-       int arg, arg_size;
+       int arg_size;
 
        if (compat20) {
                *n_bytes_ptr = packet_get_int();
-               debug3("tty_parse_modes: SSH2 n_bytes %d", *n_bytes_ptr);
                if (*n_bytes_ptr == 0)
                        return;
                get_arg = packet_get_int;
@@ -384,7 +388,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
                case TTY_OP_ISPEED_PROTO2:
                        n_bytes += 4;
                        baud = packet_get_int();
-                       debug3("tty_parse_modes: ispeed %d", baud);
                        if (failure != -1 &&
                            cfsetispeed(&tio, baud_to_speed(baud)) == -1)
                                error("cfsetispeed failed for %d", baud);
@@ -395,7 +398,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
                case TTY_OP_OSPEED_PROTO2:
                        n_bytes += 4;
                        baud = packet_get_int();
-                       debug3("tty_parse_modes: ospeed %d", baud);
                        if (failure != -1 &&
                            cfsetospeed(&tio, baud_to_speed(baud)) == -1)
                                error("cfsetospeed failed for %d", baud);
@@ -405,16 +407,14 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
        case OP: \
          n_bytes += arg_size; \
          tio.c_cc[NAME] = special_char_decode(get_arg()); \
-         debug3("tty_parse_modes: %d %d", OP, tio.c_cc[NAME]); \
          break;
 #define TTYMODE(NAME, FIELD, OP) \
        case OP: \
          n_bytes += arg_size; \
-         if ((arg = get_arg())) \
+         if (get_arg()) \
            tio.FIELD |= NAME; \
          else \
            tio.FIELD &= ~NAME; \
-         debug3("tty_parse_modes: %d %d", OP, arg); \
          break;
 
 #include "ttymodes.h"
This page took 0.045512 seconds and 4 git commands to generate.