commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1097394 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.msc.in os/win32/exec.c os/win32/platform.c
Date Thu, 28 Apr 2011 10:11:16 GMT
Author: mturk
Date: Thu Apr 28 10:11:15 2011
New Revision: 1097394

URL: http://svn.apache.org/viewvc?rev=1097394&view=rev
Log:
win32 exec stubs

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=1097394&r1=1097393&r2=1097394&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Thu Apr 28 10:11:15 2011
@@ -76,6 +76,7 @@ ASMSOURCES=
 
 WIN32_SOURCES=\
 	$(TOPDIR)\os\win32\dso.c \
+	$(TOPDIR)\os\win32\exec.c \
 	$(TOPDIR)\os\win32\execmem.c \
 	$(TOPDIR)\os\win32\init.c \
 	$(TOPDIR)\os\win32\os.c \
@@ -98,6 +99,7 @@ LIBSOURCES=\
 	$(TOPDIR)\port\bsdstring.c \
 	$(TOPDIR)\port\bsdsys.c \
 	$(TOPDIR)\shared\array.c \
+	$(TOPDIR)\shared\baos.c \
 	$(TOPDIR)\shared\bzip2.c \
 	$(TOPDIR)\shared\callback.c \
 	$(TOPDIR)\shared\clazz.c \

Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c?rev=1097394&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c Thu Apr 28 10:11:15 2011
@@ -0,0 +1,144 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr/error.h"
+#include "acr/clazz.h"
+#include "acr/baos.h"
+#include "acr/iodefs.h"
+#include "acr/port.h"
+#include "acr/sbuf.h"
+#include "acr/string.h"
+#include "acr/time.h"
+#include "arch_opts.h"
+
+#define PROC_TIMEOUT_STEP   100
+#define PROC_BUFFER_SIZE    512
+
+#define PIPE_STDINP         0
+#define PIPE_STDINP_RDS     0
+#define PIPE_STDINP_WRS     1
+#define PIPE_STDOUT         2
+#define PIPE_STDOUT_RDS     2
+#define PIPE_STDOUT_WRS     3
+#define PIPE_STDERR         4
+#define PIPE_STDERR_RDS     4
+#define PIPE_STDERR_WRS     5
+#define PIPE_SIGERR         6
+#define PIPE_SIGERR_RDS     6
+#define PIPE_SIGERR_WRS     7
+#define PIPE_SIGPID         8
+#define PIPE_SIGPID_RDS     8
+#define PIPE_SIGPID_WRS     9
+#define PIPE_COUNT         10
+
+J_DECLARE_CLAZZ = {
+    INVALID_FIELD_OFFSET,
+    0,
+    0,
+    0,
+   ACR_WIN_CP "WindowsExecImpl"
+};
+
+J_DECLARE_M_ID(0000) = {
+    0,
+    "<init>",
+    "()V"
+};
+
+
+static int _run_exec(const wchar_t *executable,
+                     const wchar_t *cmdline,
+                     const wchar_t *envb,
+                     const wchar_t *workdir,
+                     acr_buf_t *out,
+                     acr_buf_t *err,
+                     acr_buf_t *inp,
+                     int timeout,
+                     int *retval)
+{
+    return ACR_PARENT_ERROR;
+}
+
+ACR_JNI_EXPORT(jobject, ExecImpl, init0)(JNI_STDARGS)
+{
+    if (_clazzn.u == 1)
+        return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
+    if (AcrLoadClass(env, &_clazzn, 0) != 0)
+        return 0;
+    R_LOAD_METHOD(0000, 0);
+    _clazzn.u = 1;
+    return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
+}
+
+ACR_UNX_EXPORT(jlong, PosixExec, run0)(JNI_STDARGS, jstring executable,
+                                       jstring args, jstring envb,
+                                       jstring cwd, jbyteArray inp,
+                                       jobject out, jobject err,
+                                       jint timeout)
+{
+    int rv = 0;
+    int rc = 0;
+    acr_buf_t bb[3];
+    acr_buf_t *ib = 0;
+    acr_buf_t *ob = 0;
+    acr_buf_t *eb = 0;
+    
+    WITH_WSTR(executable) {
+    WITH_WSTR(cwd) {
+        if (inp != 0) {
+            ib = &bb[0];
+            ib->len = (*env)->GetArrayLength(env, inp);
+            ib->buf = (*env)->GetPrimitiveArrayCritical(env, inp, 0);
+        }
+        if (out != 0)
+            ob = &bb[1];
+        if (err != 0 && err != out)
+            eb = &bb[2];
+        /* Call actual execute
+         */
+        rv = _run_exec(J2S(executable), 0, 0, J2S(cwd),
+                       ob, eb, ib, timeout, &rc);
+        if (ib != 0 && inp != 0)
+            (*env)->ReleasePrimitiveArrayCritical(env, inp, ib->buf, 0);
+        if (rv != ACR_PARENT_ERROR) {
+            if (out != 0) {
+                /* Write to the output stream */
+                int r = AcrWriteToOutputStream(env, out, ob->buf, ob->len);
+                if (r != 0) {
+                    rv = r;
+                    goto cleanup;
+                }
+            }
+            if (err != 0 && err != out) {
+                /* Write to the error stream */
+                int r = AcrWriteToOutputStream(env, err, eb->buf, eb->len);
+                if (r != 0) {
+                    rv = r;
+                    goto cleanup;
+                }
+            }
+        }
+
+cleanup:
+        if (ob != 0)
+            AcrFree(ob->buf);
+        if (eb != 0)
+            AcrFree(ob->buf);
+    } DONE_WITH_STR(cwd);
+    } DONE_WITH_STR(executable);
+
+    return ((jlong)rv << 32) | ((jlong)rc & ACR_I64_C(0xFFFFFFFF));
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=1097394&r1=1097393&r2=1097394&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Thu Apr 28 10:11:15
2011
@@ -112,3 +112,19 @@ finally:
     AcrLibLockRelease();
     return ppid;
 }
+
+ACR_JNI_EXPORT(jstring, Vm, self)(JNI_STDARGS)
+{
+    wchar_t ipath[PATH_MAX];
+    wchar_t lpath[ACR_PATH_MAX];
+    DWORD   sz;
+
+    sz = GetModuleFileName(0, ipath, PATH_MAX);
+    if (sz == 0 || sz >= PATH_MAX)
+        return 0;
+
+    sz = GetLongPathName(ipath, lpath, ACR_PATH_MAX);
+    if (sz == 0 || sz >= ACR_PATH_MAX)
+        return 0;
+    return WSTR_TO_JSTRING(lpath);
+}



Mime
View raw message