Deleted Added
full compact
ttymodes.c (181110) ttymodes.c (181111)
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/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
6 *
7 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is

--- 283 unchanged lines hidden (view full) ---

293 put_arg = buffer_put_int;
294 } else {
295 tty_op_ospeed = TTY_OP_OSPEED_PROTO1;
296 tty_op_ispeed = TTY_OP_ISPEED_PROTO1;
297 put_arg = (void (*)(Buffer *, u_int)) buffer_put_char;
298 }
299
300 if (tiop == NULL) {
2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
6 *
7 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is

--- 283 unchanged lines hidden (view full) ---

293 put_arg = buffer_put_int;
294 } else {
295 tty_op_ospeed = TTY_OP_OSPEED_PROTO1;
296 tty_op_ispeed = TTY_OP_ISPEED_PROTO1;
297 put_arg = (void (*)(Buffer *, u_int)) buffer_put_char;
298 }
299
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) {
302 logit("tcgetattr: %.100s", strerror(errno));
303 goto end;
304 }
305 } else
306 tio = *tiop;
307
308 /* Store input and output baud rates. */
309 baud = speed_to_baud(cfgetospeed(&tio));
310 debug3("tty_make_modes: ospeed %d", baud);
311 buffer_put_char(&buf, tty_op_ospeed);
312 buffer_put_int(&buf, baud);
313 baud = speed_to_baud(cfgetispeed(&tio));
314 debug3("tty_make_modes: ispeed %d", baud);
315 buffer_put_char(&buf, tty_op_ispeed);
316 buffer_put_int(&buf, baud);
317
318 /* Store values of mode flags. */
319#define TTYCHAR(NAME, OP) \
305 if (tcgetattr(fd, &tio) == -1) {
306 logit("tcgetattr: %.100s", strerror(errno));
307 goto end;
308 }
309 } else
310 tio = *tiop;
311
312 /* Store input and output baud rates. */
313 baud = speed_to_baud(cfgetospeed(&tio));
314 debug3("tty_make_modes: ospeed %d", baud);
315 buffer_put_char(&buf, tty_op_ospeed);
316 buffer_put_int(&buf, baud);
317 baud = speed_to_baud(cfgetispeed(&tio));
318 debug3("tty_make_modes: ispeed %d", baud);
319 buffer_put_char(&buf, tty_op_ispeed);
320 buffer_put_int(&buf, baud);
321
322 /* Store values of mode flags. */
323#define TTYCHAR(NAME, OP) \
320 debug3("tty_make_modes: %d %d", OP, tio.c_cc[NAME]); \
321 buffer_put_char(&buf, OP); \
322 put_arg(&buf, special_char_encode(tio.c_cc[NAME]));
323
324#define TTYMODE(NAME, FIELD, OP) \
324 buffer_put_char(&buf, OP); \
325 put_arg(&buf, special_char_encode(tio.c_cc[NAME]));
326
327#define TTYMODE(NAME, FIELD, OP) \
325 debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \
326 buffer_put_char(&buf, OP); \
327 put_arg(&buf, ((tio.FIELD & NAME) != 0));
328
329#include "ttymodes.h"
330
331#undef TTYCHAR
332#undef TTYMODE
333

--- 14 unchanged lines hidden (view full) ---

348void
349tty_parse_modes(int fd, int *n_bytes_ptr)
350{
351 struct termios tio;
352 int opcode, baud;
353 int n_bytes = 0;
354 int failure = 0;
355 u_int (*get_arg)(void);
328 buffer_put_char(&buf, OP); \
329 put_arg(&buf, ((tio.FIELD & NAME) != 0));
330
331#include "ttymodes.h"
332
333#undef TTYCHAR
334#undef TTYMODE
335

--- 14 unchanged lines hidden (view full) ---

350void
351tty_parse_modes(int fd, int *n_bytes_ptr)
352{
353 struct termios tio;
354 int opcode, baud;
355 int n_bytes = 0;
356 int failure = 0;
357 u_int (*get_arg)(void);
356 int arg, arg_size;
358 int arg_size;
357
358 if (compat20) {
359 *n_bytes_ptr = packet_get_int();
360 debug3("tty_parse_modes: SSH2 n_bytes %d", *n_bytes_ptr);
361 if (*n_bytes_ptr == 0)
362 return;
363 get_arg = packet_get_int;
364 arg_size = 4;

--- 40 unchanged lines hidden (view full) ---

405 cfsetospeed(&tio, baud_to_speed(baud)) == -1)
406 error("cfsetospeed failed for %d", baud);
407 break;
408
409#define TTYCHAR(NAME, OP) \
410 case OP: \
411 n_bytes += arg_size; \
412 tio.c_cc[NAME] = special_char_decode(get_arg()); \
359
360 if (compat20) {
361 *n_bytes_ptr = packet_get_int();
362 debug3("tty_parse_modes: SSH2 n_bytes %d", *n_bytes_ptr);
363 if (*n_bytes_ptr == 0)
364 return;
365 get_arg = packet_get_int;
366 arg_size = 4;

--- 40 unchanged lines hidden (view full) ---

407 cfsetospeed(&tio, baud_to_speed(baud)) == -1)
408 error("cfsetospeed failed for %d", baud);
409 break;
410
411#define TTYCHAR(NAME, OP) \
412 case OP: \
413 n_bytes += arg_size; \
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#define TTYMODE(NAME, FIELD, OP) \
416 case OP: \
417 n_bytes += arg_size; \
415 break;
416#define TTYMODE(NAME, FIELD, OP) \
417 case OP: \
418 n_bytes += arg_size; \
418 if ((arg = get_arg())) \
419 if (get_arg()) \
419 tio.FIELD |= NAME; \
420 else \
421 tio.FIELD &= ~NAME; \
420 tio.FIELD |= NAME; \
421 else \
422 tio.FIELD &= ~NAME; \
422 debug3("tty_parse_modes: %d %d", OP, arg); \
423 break;
424
425#include "ttymodes.h"
426
427#undef TTYCHAR
428#undef TTYMODE
429
430 default:

--- 65 unchanged lines hidden ---
423 break;
424
425#include "ttymodes.h"
426
427#undef TTYCHAR
428#undef TTYMODE
429
430 default:

--- 65 unchanged lines hidden ---