[BACK]Return to ttymodes.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ttymodes.c between version 1.3 and 1.4

version 1.3, 1999/11/23 22:25:56 version 1.4, 1999/11/24 00:26:04
Line 1 
Line 1 
 /*  /*
    * Author: Tatu Ylonen <ylo@cs.hut.fi>
    * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
    *                    All rights reserved
    * Created: Tue Mar 21 15:59:15 1995 ylo
    * Encoding and decoding of terminal modes in a portable way.
    * Much of the format is defined in ttymodes.h; it is included multiple times
    * into this file with the appropriate macro definitions to generate the
    * suitable code.
    */
   
 ttymodes.c  
   
 Author: Tatu Ylonen <ylo@cs.hut.fi>  
   
 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland  
                    All rights reserved  
   
 Created: Tue Mar 21 15:59:15 1995 ylo  
   
 Encoding and decoding of terminal modes in a portable way.  
 Much of the format is defined in ttymodes.h; it is included multiple times  
 into this file with the appropriate macro definitions to generate the  
 suitable code.  
   
 */  
   
 #include "includes.h"  #include "includes.h"
 RCSID("$Id$");  RCSID("$Id$");
   
Line 26 
Line 19 
 #define TTY_OP_ISPEED   192     /* int follows */  #define TTY_OP_ISPEED   192     /* int follows */
 #define TTY_OP_OSPEED   193     /* int follows */  #define TTY_OP_OSPEED   193     /* int follows */
   
 /* Converts POSIX speed_t to a baud rate.  The values of the constants  /*
    for speed_t are not themselves portable. */   * Converts POSIX speed_t to a baud rate.  The values of the
    * constants for speed_t are not themselves portable.
    */
 static int  static int
 speed_to_baud(speed_t speed)  speed_to_baud(speed_t speed)
 {  {
Line 115 
Line 109 
         }          }
 }  }
   
 /* Converts a numeric baud rate to a POSIX speed_t. */  /*
    * Converts a numeric baud rate to a POSIX speed_t.
    */
 static speed_t  static speed_t
 baud_to_speed(int baud)  baud_to_speed(int baud)
 {  {
Line 203 
Line 198 
         }          }
 }  }
   
 /* Encodes terminal modes for the terminal referenced by fd in a portable  /*
    manner, and appends the modes to a packet being constructed. */   * Encodes terminal modes for the terminal referenced by fd
    * in a portable manner, and appends the modes to a packet
    * being constructed.
    */
 void  void
 tty_make_modes(int fd)  tty_make_modes(int fd)
 {  {
Line 247 
Line 244 
         packet_put_char(TTY_OP_END);          packet_put_char(TTY_OP_END);
 }  }
   
 /* Decodes terminal modes for the terminal referenced by fd in a portable  /*
    manner from a packet being read. */   * Decodes terminal modes for the terminal referenced by fd in a portable
    * manner from a packet being read.
    */
 void  void
 tty_parse_modes(int fd, int *n_bytes_ptr)  tty_parse_modes(int fd, int *n_bytes_ptr)
 {  {
Line 258 
Line 256 
         int n_bytes = 0;          int n_bytes = 0;
         int failure = 0;          int failure = 0;
   
         /* Get old attributes for the terminal.  We will modify these          /*
            flags. I am hoping that if there are any machine-specific           * Get old attributes for the terminal.  We will modify these
            modes, they will initially have reasonable values. */           * flags. I am hoping that if there are any machine-specific
            * modes, they will initially have reasonable values.
            */
         if (tcgetattr(fd, &tio) < 0)          if (tcgetattr(fd, &tio) < 0)
                 failure = -1;                  failure = -1;
   
Line 313 
Line 313 
                 default:                  default:
                         debug("Ignoring unsupported tty mode opcode %d (0x%x)",                          debug("Ignoring unsupported tty mode opcode %d (0x%x)",
                               opcode, opcode);                                opcode, opcode);
                         /* Opcodes 0 to 127 are defined to have a one-byte argument. */                          /*
                            * Opcodes 0 to 127 are defined to have
                            * a one-byte argument.
                            */
                         if (opcode >= 0 && opcode < 128) {                          if (opcode >= 0 && opcode < 128) {
                                 n_bytes += 1;                                  n_bytes += 1;
                                 (void) packet_get_char();                                  (void) packet_get_char();
                                 break;                                  break;
                         } else {                          } else {
                                 /* Opcodes 128 to 159 are defined to have an integer argument. */                                  /*
                                    * Opcodes 128 to 159 are defined to have
                                    * an integer argument.
                                    */
                                 if (opcode >= 128 && opcode < 160) {                                  if (opcode >= 128 && opcode < 160) {
                                         n_bytes += 4;                                          n_bytes += 4;
                                         (void) packet_get_int();                                          (void) packet_get_int();
                                         break;                                          break;
                                 }                                  }
                         }                          }
                         /* It is a truly undefined opcode (160 to 255).                          /*
                            We have no idea about its arguments.  So we                           * It is a truly undefined opcode (160 to 255).
                            must stop parsing.  Note that some data may be                           * We have no idea about its arguments.  So we
                            left in the packet; hopefully there is nothing                           * must stop parsing.  Note that some data may be
                            more coming after the mode data. */                           * left in the packet; hopefully there is nothing
                            * more coming after the mode data.
                            */
                         log("parse_tty_modes: unknown opcode %d", opcode);                          log("parse_tty_modes: unknown opcode %d", opcode);
                         packet_integrity_check(0, 1, SSH_CMSG_REQUEST_PTY);                          packet_integrity_check(0, 1, SSH_CMSG_REQUEST_PTY);
                         goto set;                          goto set;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4