mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Do not throw any exception.
This commit is contained in:
parent
3f5312a66b
commit
90c216400b
1 changed files with 107 additions and 103 deletions
|
@ -1,103 +1,107 @@
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <PTYInputStream.h>
|
#include <PTYInputStream.h>
|
||||||
#include <PTYOutputStream.h>
|
#include <PTYOutputStream.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */
|
/* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */
|
||||||
/* Header for class _org_eclipse_cdt_utils_pty_PTYOutputStream */
|
/* Header for class _org_eclipse_cdt_utils_pty_PTYOutputStream */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||||
* Method: read0
|
* Method: read0
|
||||||
* Signature: (I)I
|
* Signature: (I)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env,
|
Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env,
|
||||||
jobject jobj,
|
jobject jobj,
|
||||||
jint jfd,
|
jint jfd,
|
||||||
jbyteArray buf,
|
jbyteArray buf,
|
||||||
jint buf_len)
|
jint buf_len)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int status;
|
int status;
|
||||||
jbyte *data;
|
jbyte *data;
|
||||||
int data_len;
|
int data_len;
|
||||||
|
|
||||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||||
data_len = buf_len;
|
data_len = buf_len;
|
||||||
fd = jfd;
|
fd = jfd;
|
||||||
|
|
||||||
status = read( fd, data, data_len );
|
status = read( fd, data, data_len );
|
||||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||||
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
/* EOF. */
|
/* EOF. */
|
||||||
status = -1;
|
status = -1;
|
||||||
} else if (status == -1) {
|
} else if (status == -1) {
|
||||||
/* Error, toss an exception */
|
/* Error, toss an exception */
|
||||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
/* Ignore the error for now, the debugger will attempt
|
||||||
if (exception == NULL) {
|
* to close this multiple time. */
|
||||||
/* Give up. */
|
#if 0
|
||||||
return -1;
|
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||||
}
|
if (exception == NULL) {
|
||||||
(*env)->ThrowNew(env, exception, "read error");
|
/* Give up. */
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
return status;
|
(*env)->ThrowNew(env, exception, "read error");
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
return status;
|
||||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
}
|
||||||
* Method: close0
|
|
||||||
* Signature: (I)I
|
|
||||||
*/
|
/*
|
||||||
JNIEXPORT jint JNICALL
|
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env,
|
* Method: close0
|
||||||
jobject jobj,
|
* Signature: (I)I
|
||||||
jint fd)
|
*/
|
||||||
{
|
JNIEXPORT jint JNICALL
|
||||||
return close(fd);
|
Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env,
|
||||||
}
|
jobject jobj,
|
||||||
|
jint fd)
|
||||||
/*
|
{
|
||||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
return close(fd);
|
||||||
* Method: write0
|
}
|
||||||
* Signature: (II)I
|
|
||||||
*/
|
/*
|
||||||
JNIEXPORT jint JNICALL
|
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env,
|
* Method: write0
|
||||||
jobject jobj,
|
* Signature: (II)I
|
||||||
jint jfd,
|
*/
|
||||||
jbyteArray buf,
|
JNIEXPORT jint JNICALL
|
||||||
jint buf_len)
|
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env,
|
||||||
{
|
jobject jobj,
|
||||||
int status;
|
jint jfd,
|
||||||
int fd;
|
jbyteArray buf,
|
||||||
jbyte *data;
|
jint buf_len)
|
||||||
int data_len;
|
{
|
||||||
|
int status;
|
||||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
int fd;
|
||||||
data_len = buf_len;
|
jbyte *data;
|
||||||
fd = jfd;
|
int data_len;
|
||||||
|
|
||||||
status = write(fd, data, data_len);
|
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
data_len = buf_len;
|
||||||
|
fd = jfd;
|
||||||
return status;
|
|
||||||
}
|
status = write(fd, data, data_len);
|
||||||
|
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||||
|
|
||||||
/*
|
return status;
|
||||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
}
|
||||||
* Method: close0
|
|
||||||
* Signature: (I)I
|
|
||||||
*/
|
/*
|
||||||
JNIEXPORT jint JNICALL
|
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env,
|
* Method: close0
|
||||||
jobject jobj,
|
* Signature: (I)I
|
||||||
jint fd)
|
*/
|
||||||
{
|
JNIEXPORT jint JNICALL
|
||||||
return close(fd);
|
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env,
|
||||||
}
|
jobject jobj,
|
||||||
|
jint fd)
|
||||||
|
{
|
||||||
|
return close(fd);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue