ttymodes.c (57429) | ttymodes.c (60573) |
---|---|
1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * Created: Tue Mar 21 15:59:15 1995 ylo 6 * Encoding and decoding of terminal modes in a portable way. 7 * Much of the format is defined in ttymodes.h; it is included multiple times 8 * into this file with the appropriate macro definitions to generate the 9 * suitable code. 10 */ 11 12#include "includes.h" | 1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * Created: Tue Mar 21 15:59:15 1995 ylo 6 * Encoding and decoding of terminal modes in a portable way. 7 * Much of the format is defined in ttymodes.h; it is included multiple times 8 * into this file with the appropriate macro definitions to generate the 9 * suitable code. 10 */ 11 12#include "includes.h" |
13RCSID("$Id: ttymodes.c,v 1.5 1999/11/24 19:53:54 markus Exp $"); | 13RCSID("$Id: ttymodes.c,v 1.6 2000/04/14 10:30:34 markus Exp $"); |
14 15#include "packet.h" 16#include "ssh.h" 17 18#define TTY_OP_END 0 19#define TTY_OP_ISPEED 192 /* int follows */ 20#define TTY_OP_OSPEED 193 /* int follows */ 21 22/* 23 * Converts POSIX speed_t to a baud rate. The values of the 24 * constants for speed_t are not themselves portable. 25 */ | 14 15#include "packet.h" 16#include "ssh.h" 17 18#define TTY_OP_END 0 19#define TTY_OP_ISPEED 192 /* int follows */ 20#define TTY_OP_OSPEED 193 /* int follows */ 21 22/* 23 * Converts POSIX speed_t to a baud rate. The values of the 24 * constants for speed_t are not themselves portable. 25 */ |
26static int | 26static int |
27speed_to_baud(speed_t speed) 28{ 29 switch (speed) { 30 case B0: 31 return 0; 32 case B50: 33 return 50; 34 case B75: --- 72 unchanged lines hidden (view full) --- 107 default: 108 return 9600; 109 } 110} 111 112/* 113 * Converts a numeric baud rate to a POSIX speed_t. 114 */ | 27speed_to_baud(speed_t speed) 28{ 29 switch (speed) { 30 case B0: 31 return 0; 32 case B50: 33 return 50; 34 case B75: --- 72 unchanged lines hidden (view full) --- 107 default: 108 return 9600; 109 } 110} 111 112/* 113 * Converts a numeric baud rate to a POSIX speed_t. 114 */ |
115static speed_t | 115static speed_t |
116baud_to_speed(int baud) 117{ 118 switch (baud) { 119 case 0: 120 return B0; 121 case 50: 122 return B50; 123 case 75: --- 74 unchanged lines hidden (view full) --- 198 } 199} 200 201/* 202 * Encodes terminal modes for the terminal referenced by fd 203 * in a portable manner, and appends the modes to a packet 204 * being constructed. 205 */ | 116baud_to_speed(int baud) 117{ 118 switch (baud) { 119 case 0: 120 return B0; 121 case 50: 122 return B50; 123 case 75: --- 74 unchanged lines hidden (view full) --- 198 } 199} 200 201/* 202 * Encodes terminal modes for the terminal referenced by fd 203 * in a portable manner, and appends the modes to a packet 204 * being constructed. 205 */ |
206void | 206void |
207tty_make_modes(int fd) 208{ 209 struct termios tio; 210 int baud; 211 212 if (tcgetattr(fd, &tio) < 0) { 213 packet_put_char(TTY_OP_END); 214 log("tcgetattr: %.100s", strerror(errno)); --- 27 unchanged lines hidden (view full) --- 242 /* Mark end of mode data. */ 243 packet_put_char(TTY_OP_END); 244} 245 246/* 247 * Decodes terminal modes for the terminal referenced by fd in a portable 248 * manner from a packet being read. 249 */ | 207tty_make_modes(int fd) 208{ 209 struct termios tio; 210 int baud; 211 212 if (tcgetattr(fd, &tio) < 0) { 213 packet_put_char(TTY_OP_END); 214 log("tcgetattr: %.100s", strerror(errno)); --- 27 unchanged lines hidden (view full) --- 242 /* Mark end of mode data. */ 243 packet_put_char(TTY_OP_END); 244} 245 246/* 247 * Decodes terminal modes for the terminal referenced by fd in a portable 248 * manner from a packet being read. 249 */ |
250void | 250void |
251tty_parse_modes(int fd, int *n_bytes_ptr) 252{ 253 struct termios tio; 254 int opcode, baud; 255 int n_bytes = 0; 256 int failure = 0; 257 258 /* --- 101 unchanged lines hidden --- | 251tty_parse_modes(int fd, int *n_bytes_ptr) 252{ 253 struct termios tio; 254 int opcode, baud; 255 int n_bytes = 0; 256 int failure = 0; 257 258 /* --- 101 unchanged lines hidden --- |