Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core.qnx/library/pty/pty.c')
-rw-r--r--core/org.eclipse.cdt.core.qnx/library/pty/pty.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.qnx/library/pty/pty.c b/core/org.eclipse.cdt.core.qnx/library/pty/pty.c
new file mode 100644
index 00000000000..4b9e682c3ee
--- /dev/null
+++ b/core/org.eclipse.cdt.core.qnx/library/pty/pty.c
@@ -0,0 +1,35 @@
+#include "PTY.h"
+#include "openpty.h"
+
+/*
+ * Class: org_eclipse_cdt_utils_pty_PTY
+ * Method: forkpty
+ * Signature: ()I
+ */
+JNIEXPORT jstring JNICALL
+Java_org_eclipse_cdt_utils_pty_PTY_forkpty (JNIEnv *env, jobject jobj) {
+ jfieldID fid; /* Store the field ID */
+ jstring jstr = NULL;
+ int master = -1;
+ char line[1024]; /* FIXME: Should be enough */
+ jclass cls;
+
+ line[0] = '\0';
+
+ master = ptym_open(line);
+ if (master >= 0) {
+ /* Get a reference to the obj's class */
+ cls = (*env)->GetObjectClass(env, jobj);
+
+ /* Set the master fd. */
+ fid = (*env)->GetFieldID(env, cls, "master", "I");
+ if (fid == NULL) {
+ return NULL;
+ }
+ (*env)->SetIntField(env, jobj, fid, (jint)master);
+
+ /* Create a new String for the slave. */
+ jstr = (*env)->NewStringUTF(env, line);
+ }
+ return jstr;
+}

Back to the top