]> andersk Git - openssh.git/blobdiff - sshtty.c
- dtucker@cvs.openbsd.org 2010/01/09 11:13:02
[openssh.git] / sshtty.c
index 7cb848d2cddafeb84ea0a3ac272ff23ed90f20c8..d214ce3bb1a2e0a1f6cc36891b8a0518177dbf87 100644 (file)
--- a/sshtty.c
+++ b/sshtty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshtty.c,v 1.10 2006/03/25 13:17:03 djm Exp $ */
+/* $OpenBSD: sshtty.c,v 1.14 2010/01/09 05:04:24 djm 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 <stdio.h>
 #include <termios.h>
+#include <pwd.h>
 
 #include "sshpty.h"
 
 static struct termios _saved_tio;
 static int _in_raw_mode = 0;
 
-struct termios
+struct termios *
 get_saved_tio(void)
 {
-       return _saved_tio;
+       return _in_raw_mode ? &_saved_tio : NULL;
 }
 
 void
-leave_raw_mode(void)
+leave_raw_mode(int quiet)
 {
        if (!_in_raw_mode)
                return;
-       if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1)
-               perror("tcsetattr");
-       else
+       if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) {
+               if (!quiet)
+                       perror("tcsetattr");
+       } else
                _in_raw_mode = 0;
 }
 
 void
-enter_raw_mode(void)
+enter_raw_mode(int quiet)
 {
        struct termios tio;
 
        if (tcgetattr(fileno(stdin), &tio) == -1) {
-               perror("tcgetattr");
+               if (!quiet)
+                       perror("tcgetattr");
                return;
        }
        _saved_tio = tio;
@@ -83,8 +88,9 @@ enter_raw_mode(void)
        tio.c_oflag &= ~OPOST;
        tio.c_cc[VMIN] = 1;
        tio.c_cc[VTIME] = 0;
-       if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1)
-               perror("tcsetattr");
-       else
+       if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1) {
+               if (!quiet)
+                       perror("tcsetattr");
+       } else
                _in_raw_mode = 1;
 }
This page took 1.787859 seconds and 4 git commands to generate.