2016-05-14 Fritz Reese <fritzoreese@gmail.com>
[official-gcc.git] / libjava / java / io / natVMConsole.cc
blob4007c86323023cb3c57b57ff0373ca0ce9833ed8
1 // natVMConsole.cc - Native part of VMConsole class.
3 /* Copyright (C) 2012
4 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
10 details. */
12 #include <config.h>
14 #include <termios.h>
15 #include <unistd.h>
17 #include <gcj/cni.h>
19 #include <java/io/Console.h>
20 #include <java/io/VMConsole.h>
22 #ifndef IUCLC
23 #define IUCLC 0
24 #endif
26 #define TERMIOS_ECHO_IFLAGS (IUCLC|IXON|IXOFF|IXANY)
27 #define TERMIOS_ECHO_LFLAGS (ECHO|ECHOE|ECHOK|ECHONL|TOSTOP)
29 jstring
30 java::io::VMConsole::readPassword(::java::io::Console *con)
32 struct termios oldt, newt;
33 jstring result;
35 tcgetattr (STDIN_FILENO, &oldt);
37 tcgetattr (STDIN_FILENO, &newt);
39 newt.c_iflag &= ~TERMIOS_ECHO_IFLAGS;
40 newt.c_lflag &= ~TERMIOS_ECHO_LFLAGS;
42 tcsetattr (STDIN_FILENO, TCSANOW, &newt);
44 result = con->readLine ();
46 tcsetattr (STDIN_FILENO, TCSANOW, &oldt);
48 return result;