2 * Copyright © 2009 Dan Nicholson <dbn.lists@gmail.com>
3 * Copyright © 2012 Intel Corporation
4 * Copyright © 2012 Ran Benita <ran234@gmail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Except as contained in this notice, the names of the authors or their
24 * institutions shall not be used in advertising or otherwise to promote the
25 * sale, use or other dealings in this Software without prior written
26 * authorization from the authors.
28 * Author: Dan Nicholson <dbn.lists@gmail.com>
29 * Daniel Stone <daniel@fooishbar.org>
30 * Ran Benita <ran234@gmail.com>
37 #include <sys/types.h>
47 #include "tools-common.h"
51 test_disable_stdin_echo(void)
53 HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
55 GetConsoleMode(stdin_handle, &mode);
56 SetConsoleMode(stdin_handle, mode & ~ENABLE_ECHO_INPUT);
60 test_enable_stdin_echo(void)
62 HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
64 GetConsoleMode(stdin_handle, &mode);
65 SetConsoleMode(stdin_handle, mode | ENABLE_ECHO_INPUT);
69 test_disable_stdin_echo(void)
71 /* Same as `stty -echo`. */
72 struct termios termios;
73 if (tcgetattr(STDIN_FILENO, &termios) == 0) {
74 termios.c_lflag &= ~ECHO;
75 (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &termios);
80 test_enable_stdin_echo(void)
82 /* Same as `stty echo`. */
83 struct termios termios;
84 if (tcgetattr(STDIN_FILENO, &termios) == 0) {
85 termios.c_lflag |= ECHO;
86 (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &termios);