summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/native/jni/java-io
diff options
context:
space:
mode:
authorgandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-23 15:19:26 +0000
committergandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-23 15:19:26 +0000
commit5c7411981584e487ac41794feb98a66df9fd6fcb (patch)
treefebe3d4d4c0c994db223fee8e819bde6582494c9 /libjava/classpath/native/jni/java-io
parent112dfe9f689af01c2dd00e0f153fc25d69095b6c (diff)
downloadppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.tar.gz
ppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.zip
Merge GNU Classpath 0.99 into libjava.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/native/jni/java-io')
-rw-r--r--libjava/classpath/native/jni/java-io/Makefile.am3
-rw-r--r--libjava/classpath/native/jni/java-io/Makefile.in6
-rw-r--r--libjava/classpath/native/jni/java-io/java_io_VMConsole.c90
3 files changed, 96 insertions, 3 deletions
diff --git a/libjava/classpath/native/jni/java-io/Makefile.am b/libjava/classpath/native/jni/java-io/Makefile.am
index 58bd973e2fb..80edb32fa38 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.am
+++ b/libjava/classpath/native/jni/java-io/Makefile.am
@@ -1,6 +1,7 @@
nativeexeclib_LTLIBRARIES = libjavaio.la
-libjavaio_la_SOURCES = java_io_VMFile.c \
+libjavaio_la_SOURCES = java_io_VMConsole.c \
+ java_io_VMFile.c \
java_io_VMObjectInputStream.c \
java_io_VMObjectStreamClass.c
diff --git a/libjava/classpath/native/jni/java-io/Makefile.in b/libjava/classpath/native/jni/java-io/Makefile.in
index 0052aeeb825..b9c68adc149 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.in
+++ b/libjava/classpath/native/jni/java-io/Makefile.in
@@ -94,7 +94,7 @@ LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
libjavaio_la_DEPENDENCIES = \
$(top_builddir)/native/jni/classpath/jcl.lo \
$(top_builddir)/native/jni/native-lib/libclasspathnative.la
-am_libjavaio_la_OBJECTS = java_io_VMFile.lo \
+am_libjavaio_la_OBJECTS = java_io_VMConsole.lo java_io_VMFile.lo \
java_io_VMObjectInputStream.lo java_io_VMObjectStreamClass.lo
libjavaio_la_OBJECTS = $(am_libjavaio_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
@@ -326,7 +326,8 @@ top_srcdir = @top_srcdir@
uudecode = @uudecode@
vm_classes = @vm_classes@
nativeexeclib_LTLIBRARIES = libjavaio.la
-libjavaio_la_SOURCES = java_io_VMFile.c \
+libjavaio_la_SOURCES = java_io_VMConsole.c \
+ java_io_VMFile.c \
java_io_VMObjectInputStream.c \
java_io_VMObjectStreamClass.c
@@ -412,6 +413,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMConsole.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMFile.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMObjectInputStream.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/java_io_VMObjectStreamClass.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/java-io/java_io_VMConsole.c b/libjava/classpath/native/jni/java-io/java_io_VMConsole.c
new file mode 100644
index 00000000000..2883f5f73eb
--- /dev/null
+++ b/libjava/classpath/native/jni/java-io/java_io_VMConsole.c
@@ -0,0 +1,90 @@
+/* java_io_VMConsole.c - Native methods for java.io.Console class
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+/* do not move; needed here because of some macro definitions */
+#include <config.h>
+
+#include <termios.h>
+#include <unistd.h>
+
+#include <jni.h>
+
+#include "java_io_VMConsole.h"
+
+/*************************************************************************/
+
+#define TERMIOS_ECHO_IFLAGS (IUCLC|IXON|IXOFF|IXANY)
+#define TERMIOS_ECHO_LFLAGS (ECHO|ECHOE|ECHOK|ECHONL|TOSTOP)
+
+/*
+ * Class: java_io_VMConsole
+ * Method: echo
+ * Signature: (Z)Z
+ */
+JNIEXPORT jstring JNICALL
+Java_java_io_VMConsole_readPassword (JNIEnv * env,
+ jclass clazz
+ __attribute__ ((__unused__)),
+ jobject con)
+{
+ struct termios old, new;
+ jmethodID readLineID;
+ jstring result;
+
+ readLineID =
+ (*env)->GetMethodID (env, (*env)->GetObjectClass (env, con), "readLine",
+ "()Ljava/lang/String;");
+ if (!readLineID)
+ {
+ return NULL;
+ }
+
+ tcgetattr (STDIN_FILENO, &old);
+
+ tcgetattr (STDIN_FILENO, &new);
+
+ new.c_iflag &= ~TERMIOS_ECHO_IFLAGS;
+ new.c_lflag &= ~TERMIOS_ECHO_LFLAGS;
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &new);
+
+ result = (*env)->CallObjectMethod (env, con, readLineID);
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &old);
+
+ return result;
+}
OpenPOWER on IntegriCloud