summaryrefslogtreecommitdiff
path: root/ttymodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'ttymodes.c')
-rw-r--r--ttymodes.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ttymodes.c b/ttymodes.c
index d8e2c553a..e116b1999 100644
--- a/ttymodes.c
+++ b/ttymodes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ttymodes.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: ttymodes.c,v 1.28 2008/07/07 00:31:41 stevesk Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -298,6 +298,10 @@ tty_make_modes(int fd, struct termios *tiop)
298 } 298 }
299 299
300 if (tiop == NULL) { 300 if (tiop == NULL) {
301 if (fd == -1) {
302 debug("tty_make_modes: no fd or tio");
303 goto end;
304 }
301 if (tcgetattr(fd, &tio) == -1) { 305 if (tcgetattr(fd, &tio) == -1) {
302 logit("tcgetattr: %.100s", strerror(errno)); 306 logit("tcgetattr: %.100s", strerror(errno));
303 goto end; 307 goto end;
@@ -317,12 +321,10 @@ tty_make_modes(int fd, struct termios *tiop)
317 321
318 /* Store values of mode flags. */ 322 /* Store values of mode flags. */
319#define TTYCHAR(NAME, OP) \ 323#define TTYCHAR(NAME, OP) \
320 debug3("tty_make_modes: %d %d", OP, tio.c_cc[NAME]); \
321 buffer_put_char(&buf, OP); \ 324 buffer_put_char(&buf, OP); \
322 put_arg(&buf, special_char_encode(tio.c_cc[NAME])); 325 put_arg(&buf, special_char_encode(tio.c_cc[NAME]));
323 326
324#define TTYMODE(NAME, FIELD, OP) \ 327#define TTYMODE(NAME, FIELD, OP) \
325 debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \
326 buffer_put_char(&buf, OP); \ 328 buffer_put_char(&buf, OP); \
327 put_arg(&buf, ((tio.FIELD & NAME) != 0)); 329 put_arg(&buf, ((tio.FIELD & NAME) != 0));
328 330
@@ -353,7 +355,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
353 int n_bytes = 0; 355 int n_bytes = 0;
354 int failure = 0; 356 int failure = 0;
355 u_int (*get_arg)(void); 357 u_int (*get_arg)(void);
356 int arg, arg_size; 358 int arg_size;
357 359
358 if (compat20) { 360 if (compat20) {
359 *n_bytes_ptr = packet_get_int(); 361 *n_bytes_ptr = packet_get_int();
@@ -410,16 +412,14 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
410 case OP: \ 412 case OP: \
411 n_bytes += arg_size; \ 413 n_bytes += arg_size; \
412 tio.c_cc[NAME] = special_char_decode(get_arg()); \ 414 tio.c_cc[NAME] = special_char_decode(get_arg()); \
413 debug3("tty_parse_modes: %d %d", OP, tio.c_cc[NAME]); \
414 break; 415 break;
415#define TTYMODE(NAME, FIELD, OP) \ 416#define TTYMODE(NAME, FIELD, OP) \
416 case OP: \ 417 case OP: \
417 n_bytes += arg_size; \ 418 n_bytes += arg_size; \
418 if ((arg = get_arg())) \ 419 if (get_arg()) \
419 tio.FIELD |= NAME; \ 420 tio.FIELD |= NAME; \
420 else \ 421 else \
421 tio.FIELD &= ~NAME; \ 422 tio.FIELD &= ~NAME; \
422 debug3("tty_parse_modes: %d %d", OP, arg); \
423 break; 423 break;
424 424
425#include "ttymodes.h" 425#include "ttymodes.h"