39 }
40
41 JNIEXPORT jstring JNICALL
42 Java_java_io_Console_encoding(JNIEnv *env, jclass cls)
43 {
44 return NULL;
45 }
46
47 JNIEXPORT jboolean JNICALL
48 Java_java_io_Console_echo(JNIEnv *env,
49 jclass cls,
50 jboolean on)
51 {
52 struct termios tio;
53 jboolean old;
54 int tty = fileno(stdin);
55 if (tcgetattr(tty, &tio) == -1) {
56 JNU_ThrowIOExceptionWithLastError(env, "tcgetattr failed");
57 return !on;
58 }
59 old = (tio.c_lflag & ECHO);
60 if (on) {
61 tio.c_lflag |= ECHO;
62 } else {
63 tio.c_lflag &= ~ECHO;
64 }
65 if (tcsetattr(tty, TCSANOW, &tio) == -1) {
66 JNU_ThrowIOExceptionWithLastError(env, "tcsetattr failed");
67 }
68 return old;
69 }
|
39 }
40
41 JNIEXPORT jstring JNICALL
42 Java_java_io_Console_encoding(JNIEnv *env, jclass cls)
43 {
44 return NULL;
45 }
46
47 JNIEXPORT jboolean JNICALL
48 Java_java_io_Console_echo(JNIEnv *env,
49 jclass cls,
50 jboolean on)
51 {
52 struct termios tio;
53 jboolean old;
54 int tty = fileno(stdin);
55 if (tcgetattr(tty, &tio) == -1) {
56 JNU_ThrowIOExceptionWithLastError(env, "tcgetattr failed");
57 return !on;
58 }
59 old = (tio.c_lflag & ECHO) != 0;
60 if (on) {
61 tio.c_lflag |= ECHO;
62 } else {
63 tio.c_lflag &= ~ECHO;
64 }
65 if (tcsetattr(tty, TCSANOW, &tio) == -1) {
66 JNU_ThrowIOExceptionWithLastError(env, "tcsetattr failed");
67 }
68 return old;
69 }
|