harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r382065 [3/10] - in /incubator/harmony/enhanced/classlib/trunk: modules/security/make/ modules/security/make/native/linux/ modules/security/make/native/windows/ native-src/ native-src/linux.IA32/ native-src/linux.IA32/archive/ native-src/li...
Date Wed, 01 Mar 2006 15:43:11 GMT
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/hyexelibnls.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/hyexelibnls.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/hyexelibnls.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/hyexelibnls.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,62 @@
+/* Copyright 1991, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(hyexelibnls_h)
+#define hyexelibnls_h
+
+#include "hyport.h"
+/* 0x4558454c = EXEL */
+
+#define HYNLS_EXELIB_VERSION__MODULE 0x4558454c
+#define HYNLS_EXELIB_VERSION__ID 50
+#define HYNLS_EXELIB_VERSION HYNLS_EXELIB_VERSION__MODULE, HYNLS_EXELIB_VERSION__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY__ID 51
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_TO_FIND_JLS__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_TO_FIND_JLS__ID 52
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_TO_FIND_JLS HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_TO_FIND_JLS__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_TO_FIND_JLS__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BA__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BA__ID 53
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BA HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BA__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BA__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_CLASSNAME__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_CLASSNAME__ID 54
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_CLASSNAME HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_CLASSNAME__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_CLASSNAME__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY_CONVERTING__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY_CONVERTING__ID 55
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY_CONVERTING HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY_CONVERTING__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_OUT_OF_MEMORY_CONVERTING__ID
+#define HYNLS_EXELIB_CLASS_DOES_NOT_IMPL_MAIN__MODULE 0x4558454c
+#define HYNLS_EXELIB_CLASS_DOES_NOT_IMPL_MAIN__ID 56
+#define HYNLS_EXELIB_CLASS_DOES_NOT_IMPL_MAIN HYNLS_EXELIB_CLASS_DOES_NOT_IMPL_MAIN__MODULE, HYNLS_EXELIB_CLASS_DOES_NOT_IMPL_MAIN__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_ARG_ARRAY__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_ARG_ARRAY__ID 57
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_ARG_ARRAY HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_ARG_ARRAY__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_ARG_ARRAY__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BYTE_ARRAY__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BYTE_ARRAY__ID 58
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BYTE_ARRAY HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BYTE_ARRAY__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_BYTE_ARRAY__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_ARG__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_ARG__ID 59
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_ARG HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_ARG__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JLS_FOR_ARG__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_SET_ARRAY_ELEM__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_SET_ARRAY_ELEM__ID 60
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_SET_ARRAY_ELEM HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_SET_ARRAY_ELEM__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_SET_ARRAY_ELEM__ID
+#define HYNLS_EXELIB_VM_STARTUP_ERR_OUT_OF_MEMORY__MODULE 0x4558454c
+#define HYNLS_EXELIB_VM_STARTUP_ERR_OUT_OF_MEMORY__ID 61
+#define HYNLS_EXELIB_VM_STARTUP_ERR_OUT_OF_MEMORY HYNLS_EXELIB_VM_STARTUP_ERR_OUT_OF_MEMORY__MODULE, HYNLS_EXELIB_VM_STARTUP_ERR_OUT_OF_MEMORY__ID
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM__MODULE 0x4558454c
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM__ID 62
+#define HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM__MODULE, HYNLS_EXELIB_INTERNAL_VM_ERR_FAILED_CREATE_JAVA_VM__ID
+
+#endif // hyexelibnls_h

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/launcher_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/launcher_copyright.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/launcher_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/launcher_copyright.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,19 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,309 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "hyport.h"
+#include "libhlp.h"
+
+#define HY_PATH_SLASH DIR_SEPARATOR
+
+I_32
+main_appendToClassPath (HyPortLibrary * portLib, U_16 sep,
+                        HyStringBuffer ** classPath, char *toAppend)
+{
+
+  /* append a separator, first */
+  if (*classPath && (*classPath)->data[strlen ((*classPath)->data)] != sep)
+    {
+      char separator[2];
+      separator[0] = (char) sep;
+      separator[1] = '\0';
+      *classPath = strBufferCat (portLib, *classPath, separator);
+      if (*classPath == NULL)
+        return -1;
+    }
+
+  *classPath = strBufferCat (portLib, *classPath, toAppend);
+  if (*classPath == NULL)
+    return -1;
+
+  return 0;
+}
+
+/* Allocates and retrieves initial value of the classPath. */
+
+I_32
+main_initializeClassPath (HyPortLibrary * portLib,
+                          HyStringBuffer ** classPath)
+{
+  PORT_ACCESS_FROM_PORT (portLib);
+  I_32 rc;
+  char *envvars = "CLASSPATH\0classpath\0";
+  char *envvar;
+
+  for (envvar = envvars; *envvar; envvar += strlen (envvar) + 1)
+    {
+      rc = hysysinfo_get_env (envvar, NULL, 0);
+      if (rc > 0)
+        {
+          *classPath = strBufferEnsure (portLib, *classPath, rc);
+          if (*classPath == NULL)
+            return -1;
+          hysysinfo_get_env (envvar,
+                             (*classPath)->data + strlen ((*classPath)->data),
+                             rc);
+          (*classPath)->remaining -= rc;
+          break;
+        }
+    }
+
+  return 0;
+}
+
+IDATA
+main_initializeJavaHome (HyPortLibrary * portLib,
+                         HyStringBuffer ** finalJavaHome, int argc,
+                         char **argv)
+{
+  char *javaHome = NULL;
+  char *javaHomeModifiablePart = NULL;
+  char *p;
+  IDATA retval = -1;
+  I_32 rc;
+  UDATA isUpper = TRUE;
+  char *envvars = "JAVA_HOME\0java_home\0";
+  char *envvar;
+
+  PORT_ACCESS_FROM_PORT (portLib);
+
+  for (envvar = envvars; *envvar; envvar += strlen (envvar) + 1)
+    {
+      rc = hysysinfo_get_env (envvar, NULL, 0);
+      if (rc > 0)
+        {
+          *finalJavaHome = strBufferEnsure (portLib, *finalJavaHome, rc);
+          if (*finalJavaHome == NULL)
+            return -1;
+          hysysinfo_get_env (envvar,
+                             (*finalJavaHome)->data +
+                             strlen ((*finalJavaHome)->data), rc);
+          (*finalJavaHome)->remaining -= rc;
+          return 0;
+        }
+    }
+
+  /* Compute the proper value for the var. */
+
+  if ((argc < 1) || !argv)
+    return -1;
+
+  retval = hysysinfo_get_executable_name (argv[0], &javaHome);
+  if (retval)
+    {
+      /* guess.  How about ".."? */
+      *finalJavaHome = strBufferCat (portLib, *finalJavaHome, "..");
+      return 0;
+    }
+
+  javaHomeModifiablePart = javaHome;
+#if defined(WIN32)
+  /* Make sure we don't modify a drive specifier in a pathname. */
+  if ((strlen (javaHome) > 2) && (javaHome[1] == ':'))
+    {
+      javaHomeModifiablePart = javaHome + 2;
+      if (javaHome[2] == HY_PATH_SLASH)
+        javaHomeModifiablePart++;
+    }
+#endif
+
+#if defined(WIN32)
+  /* Make sure we don't modify the root of a UNC pathname. */
+  if ((strlen (javaHome) > 2) && (javaHome[0] == HY_PATH_SLASH)
+      && (javaHome[1] == HY_PATH_SLASH))
+    {
+      javaHomeModifiablePart = javaHome + 2;
+      /* skip over the machine name */
+      while (*javaHomeModifiablePart
+             && (*javaHomeModifiablePart != HY_PATH_SLASH))
+        {
+          javaHomeModifiablePart++;
+        }
+      if (*javaHomeModifiablePart)
+        javaHomeModifiablePart++;
+      /* skip over the share name */
+      while (*javaHomeModifiablePart
+             && (*javaHomeModifiablePart != HY_PATH_SLASH))
+        {
+          javaHomeModifiablePart++;
+        }
+    }
+#endif
+
+  if ((javaHomeModifiablePart == javaHome) && javaHome[0] == HY_PATH_SLASH)
+    {
+      /* make sure we don't modify a root slash. */
+      javaHomeModifiablePart++;
+    }
+
+  /* Note: if sysinfo_get_executable_name claims we were invoked from a root directory, */
+  /* then this code will return that root directory for java.home also. */
+  p = strrchr (javaHomeModifiablePart, HY_PATH_SLASH);
+  if (!p)
+    {
+      javaHomeModifiablePart[0] = '\0'; /* chop off whole thing! */
+    }
+  else
+    {
+      p[0] = '\0';              /* chop off trailing slash and executable name. */
+      p = strrchr (javaHomeModifiablePart, HY_PATH_SLASH);
+      if (!p)
+        {
+          javaHomeModifiablePart[0] = '\0';     /* chop off the rest */
+        }
+      else
+        {
+          p[0] = '\0';          /* chop off trailing slash and deepest subdirectory. */
+        }
+    }
+
+  *finalJavaHome = strBufferCat (portLib, *finalJavaHome, javaHome);
+
+  hymem_free_memory (javaHome);
+
+  return 0;
+}
+
+IDATA
+main_initializeJavaLibraryPath (HyPortLibrary * portLib,
+                                HyStringBuffer ** finalJavaLibraryPath,
+                                char *argv0)
+{
+#if defined(WIN32)
+#define ENV_PATH "PATH"
+#else
+#define ENV_PATH "LD_LIBRARY_PATH"
+#endif
+
+  HyStringBuffer *javaLibraryPath = NULL;
+  char *exeName = NULL;
+  IDATA rc = -1;
+  char *p;
+  char *envResult;
+  int envSize;
+#define ENV_BUFFER_SIZE 80
+  char envBuffer[ENV_BUFFER_SIZE];
+  char sep[2];
+  PORT_ACCESS_FROM_PORT (portLib);
+
+  sep[0] = (char) hysysinfo_get_classpathSeparator ();
+  sep[1] = '\0';
+
+  if (hysysinfo_get_executable_name (argv0, &exeName))
+    {
+      goto done;
+    }
+  p = strrchr (exeName, HY_PATH_SLASH);
+  if (p)
+    {
+      p[1] = '\0';
+    }
+  else
+    {
+      hymem_free_memory (exeName);
+      exeName = NULL;
+    }
+
+  envSize = hysysinfo_get_env (ENV_PATH, NULL, 0);
+  if (envSize > 0)
+    {
+      if (envSize >= ENV_BUFFER_SIZE)
+        {
+          envResult = hymem_allocate_memory (envSize + 1);
+          if (!envResult)
+            goto done;
+          hysysinfo_get_env (ENV_PATH, envResult, envSize);
+        }
+      else
+        {
+          envSize = -1;         /* make it -1 so we don't free the buffer */
+          hysysinfo_get_env (ENV_PATH, envBuffer, ENV_BUFFER_SIZE);
+          envResult = envBuffer;
+        }
+    }
+  else
+    {
+      envResult = NULL;
+    }
+
+  /* Add one to each length to account for the separator character.  Add 2 at the end for the "." and NULL terminator */
+
+  if (exeName)
+    {
+      javaLibraryPath = strBufferCat (portLib, javaLibraryPath, exeName);
+      javaLibraryPath = strBufferCat (portLib, javaLibraryPath, sep);
+    }
+  javaLibraryPath = strBufferCat (portLib, javaLibraryPath, ".");
+  if (envResult)
+    {
+      javaLibraryPath = strBufferCat (portLib, javaLibraryPath, sep);
+      javaLibraryPath = strBufferCat (portLib, javaLibraryPath, envResult);
+      if (envSize != -1)
+        {
+          hymem_free_memory (envResult);
+        }
+    }
+
+  rc = 0;
+
+done:
+  if (exeName)
+    {
+      hymem_free_memory (exeName);
+    }
+  *finalJavaLibraryPath = javaLibraryPath;
+  return rc;
+
+}
+
+IDATA
+convertString (JNIEnv * env, HyPortLibrary * hyportLibrary,
+               jclass stringClass, jmethodID stringMid, char *chars,
+               jstring * str)
+{
+  UDATA strLength;
+  jarray bytearray;
+  jstring string;
+
+  strLength = strlen (chars);
+  bytearray = (*env)->NewByteArray (env, strLength);
+  if (((*env)->ExceptionCheck (env)))
+    return 1;
+
+  (*env)->SetByteArrayRegion (env, bytearray, (UDATA) 0, strLength, chars);
+
+  string =
+    (*env)->NewObject (env, stringClass, stringMid, bytearray, (UDATA) 0,
+                       strLength);
+  if (!string)
+    return 2;
+
+  (*env)->DeleteLocalRef (env, bytearray);
+
+  *str = string;
+  return 0;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/libhlp.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,68 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(LIBHLP_H)
+#define LIBHLP_H
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+#include "hycomp.h"
+#include "hyport.h"
+#include "jni.h"
+
+  typedef struct HyStringBuffer
+  {
+    UDATA remaining;
+    U_8 data[4];
+  } HyStringBuffer;
+#define HYSIZEOF_HyStringBuffer 8
+  struct haCmdlineOptions
+  {
+    int argc;
+    char **argv;
+    char **envp;
+    HyPortLibrary *portLibrary;
+  };
+  struct HyPortLibrary;
+  extern HY_CFUNC HyStringBuffer *strBufferCat
+    PROTOTYPE ((struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+                const char *string));
+  extern HY_CFUNC char *strBufferData PROTOTYPE ((HyStringBuffer * buffer));
+  struct HyPortLibrary;
+  extern HY_CFUNC HyStringBuffer *strBufferPrepend
+    PROTOTYPE ((struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+                char *string));
+  struct HyPortLibrary;
+  extern HY_CFUNC HyStringBuffer *strBufferEnsure
+    PROTOTYPE ((struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+                UDATA len));
+  extern HY_CFUNC void dumpVersionInfo PROTOTYPE ((HyPortLibrary * portLib));
+  extern HY_CFUNC int main_runJavaMain
+    PROTOTYPE ((JNIEnv * env, char *mainClassName, int nameIsUTF,
+                int java_argc, char **java_argv,
+                HyPortLibrary * hyportLibrary));
+  extern HY_CFUNC IDATA main_initializeJavaLibraryPath
+    PROTOTYPE ((HyPortLibrary * portLib,
+                HyStringBuffer ** finalJavaLibraryPath, char *argv0));
+  extern HY_CFUNC I_32 main_initializeClassPath
+    PROTOTYPE ((HyPortLibrary * portLib, HyStringBuffer ** classPath));
+  extern HY_CFUNC IDATA main_initializeJavaHome
+    PROTOTYPE ((HyPortLibrary * portLib, HyStringBuffer ** finalJavaHome,
+                int argc, char **argv));
+#if defined(__cplusplus)
+}
+#endif
+#endif                          /* LIBHLP_H */

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/strbuf.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/strbuf.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/strbuf.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/launcher/strbuf.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,96 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <string.h>
+
+#include "libhlp.h"
+
+#define MIN_GROWTH 128
+
+HyStringBuffer *
+strBufferCat (struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+              const char *string)
+{
+  UDATA len = strlen (string);
+
+  buffer = strBufferEnsure (portLibrary, buffer, len);
+  if (buffer)
+    {
+      strcat (buffer->data, string);
+      buffer->remaining -= len;
+    }
+
+  return buffer;
+}
+
+HyStringBuffer *
+strBufferEnsure (struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+                 UDATA len)
+{
+
+  if (buffer == NULL)
+    {
+      PORT_ACCESS_FROM_PORT (portLibrary);
+      UDATA newSize = len > MIN_GROWTH ? len : MIN_GROWTH;
+      buffer = hymem_allocate_memory (newSize + 1 + sizeof (UDATA));    /* 1 for null terminator */
+      if (buffer != NULL)
+        {
+          buffer->remaining = newSize;
+          buffer->data[0] = '\0';
+        }
+      return buffer;
+    }
+
+  if (len > buffer->remaining)
+    {
+      PORT_ACCESS_FROM_PORT (portLibrary);
+      UDATA newSize = len > MIN_GROWTH ? len : MIN_GROWTH;
+      HyStringBuffer *new =
+        hymem_allocate_memory (strlen (buffer->data) + newSize +
+                               sizeof (UDATA) + 1);
+      if (new)
+        {
+          new->remaining = newSize;
+          strcpy (new->data, buffer->data);
+        }
+      hymem_free_memory (buffer);
+      return new;
+    }
+
+  return buffer;
+}
+
+HyStringBuffer *
+strBufferPrepend (struct HyPortLibrary * portLibrary, HyStringBuffer * buffer,
+                  char *string)
+{
+  UDATA len = strlen (string);
+
+  buffer = strBufferEnsure (portLibrary, buffer, len);
+  if (buffer)
+    {
+      memmove (buffer->data + len, buffer->data, strlen (buffer->data) + 1);
+      strncpy (buffer->data, string, len);
+      buffer->remaining -= len;
+    }
+
+  return buffer;
+}
+
+char *
+strBufferData (HyStringBuffer * buffer)
+{
+  return buffer ? buffer->data : NULL;
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar  1 07:42:53 2006
@@ -0,0 +1 @@
+*.obj

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/bigint.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/bigint.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/bigint.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/bigint.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,36 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(bigint_h)
+#define bigint_h
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_subImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src1, jlongArray src2));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_divImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray topObject,
+            jlongArray bottomObject));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_mulImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src1, jlongArray src2));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_negImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_addImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src1, jlongArray src2));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_remImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray topObject,
+            jlongArray bottomObject));
+jlongArray JNICALL Java_com_ibm_oti_util_math_BigInteger_shlImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src, jint shiftval));
+jint JNICALL Java_com_ibm_oti_util_math_BigInteger_compImpl
+PROTOTYPE ((JNIEnv * env, jclass cls, jlongArray src1, jlongArray src2));
+#endif /* bigint_h */

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/file.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/file.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/file.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/file.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,517 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <string.h>
+#include <ctype.h>
+#include "iohelp.h"
+#include "jclglob.h"
+#include "helpers.h"
+#include "jclprots.h"
+
+jboolean JNICALL
+Java_java_io_File_deleteFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_unlink (pathCopy);
+  return result == 0;
+}
+
+jboolean JNICALL
+Java_java_io_File_deleteDirImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_unlinkdir (pathCopy);
+  return result == 0;
+}
+
+jobject JNICALL
+Java_java_io_File_listImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  struct dirEntry
+  {
+    char pathEntry[HyMaxPath];
+    struct dirEntry *next;
+  } *dirList, *currentEntry;
+
+  PORT_ACCESS_FROM_ENV (env);
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  char filename[HyMaxPath];
+  I_32 result = 0, index;
+  I_32 numEntries = 0;
+  UDATA findhandle;
+  jarray answer = NULL;
+
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  if (length >= 1 && pathCopy[length - 1] != '\\'
+      && pathCopy[length - 1] != '/')
+    {
+      pathCopy[length] = jclSeparator;
+      length++;
+    }
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  findhandle = hyfile_findfirst (pathCopy, filename);
+  if (findhandle == (UDATA) - 1)
+    return NULL;
+
+  while (result > -1)
+    {
+      if (strcmp (".", filename) != 0 && (strcmp ("..", filename) != 0))
+        {
+          if (numEntries > 0)
+            {
+              currentEntry->next =
+                (struct dirEntry *) jclmem_allocate_memory (env,
+                                                            sizeof (struct
+                                                                    dirEntry));
+              currentEntry = currentEntry->next;
+            }
+          else
+            {
+              dirList =
+                (struct dirEntry *) jclmem_allocate_memory (env,
+                                                            sizeof (struct
+                                                                    dirEntry));
+              currentEntry = dirList;
+            }
+          if (currentEntry == NULL)
+            {
+              hyfile_findclose (findhandle);
+              throwNewOutOfMemoryError (env, "");
+              goto cleanup;
+            }
+          strcpy (currentEntry->pathEntry, filename);
+          numEntries++;
+        }
+      result = hyfile_findnext (findhandle, filename);
+    }
+  hyfile_findclose (findhandle);
+
+  if (numEntries == 0)
+    return NULL;
+
+  answer =
+    (*env)->NewObjectArray (env, numEntries,
+                            JCL_CACHE_GET (env, CLS_array_of_byte), NULL);
+cleanup:
+  for (index = 0; index < numEntries; index++)
+    {
+      jbyteArray entrypath;
+      jsize entrylen = strlen (dirList->pathEntry);
+      currentEntry = dirList;
+      if (answer)
+        {
+          entrypath = (*env)->NewByteArray (env, entrylen);
+          (*env)->SetByteArrayRegion (env, entrypath, 0, entrylen,
+                                      (jbyte *) dirList->pathEntry);
+          (*env)->SetObjectArrayElement (env, answer, index, entrypath);
+          (*env)->DeleteLocalRef (env, entrypath);
+        }
+      dirList = dirList->next;
+      jclmem_free_memory (env, currentEntry);
+    }
+  return answer;
+}
+
+jboolean JNICALL
+Java_java_io_File_isDirectoryImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_attr (pathCopy);
+  return result == HyIsDir;
+}
+
+jboolean JNICALL
+Java_java_io_File_existsImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_attr (pathCopy);
+  return result >= 0;
+}
+
+jboolean JNICALL
+Java_java_io_File_isFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_attr (pathCopy);
+  return result == HyIsFile;
+}
+
+jlong JNICALL
+Java_java_io_File_lastModifiedImpl (JNIEnv * env, jobject recv,
+                                    jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_64 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_lastmod (pathCopy);
+  return result;
+}
+
+jlong JNICALL
+Java_java_io_File_lengthImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_64 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_length (pathCopy);
+  if (result < 0)
+    {
+      return 0L;
+    }
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_isAbsoluteImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result = 0;
+  jsize length = (*env)->GetArrayLength (env, path);
+  jbyte *lpath = (jbyte *) ((*env)->GetPrimitiveArrayCritical (env, path, 0));
+
+  if (jclSeparator == '/' && length > 0)
+    {
+      result = (lpath[0] == jclSeparator);
+      goto release;
+    }
+  if (length > 1 && lpath[0] == '\\' && lpath[1] == '\\')
+    {
+      result = 1;
+      goto release;
+    }
+  if (length > 2)
+    {
+      if (isalpha (lpath[0]) && lpath[1] == ':'
+          && (lpath[2] == '\\' || lpath[2] == '/'))
+        result = 1;
+    }
+
+release:
+  /* Easier to release in one area than copy the code around */
+  (*env)->ReleasePrimitiveArrayCritical (env, path, lpath, JNI_ABORT);
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_mkdirImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = hyfile_mkdir (pathCopy);
+  return result == 0;
+}
+
+jboolean JNICALL
+Java_java_io_File_renameToImpl (JNIEnv * env, jobject recv,
+                                jbyteArray pathExist, jbyteArray pathNew)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length;
+  char pathExistCopy[HyMaxPath], pathNewCopy[HyMaxPath];
+  length = (*env)->GetArrayLength (env, pathExist);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, pathExist, 0, length, pathExistCopy));
+  pathExistCopy[length] = '\0';
+  length = (*env)->GetArrayLength (env, pathNew);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, pathNew, 0, length, pathNewCopy));
+  pathNewCopy[length] = '\0';
+  ioh_convertToPlatform (pathExistCopy);
+  ioh_convertToPlatform (pathNewCopy);
+  result = hyfile_move (pathExistCopy, pathNewCopy);
+  return result == 0;
+}
+
+jobject JNICALL
+Java_java_io_File_getCanonImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  /* This needs work.  Currently is does no more or less than VAJ-20 ST implementation
+   * but really should figure out '..', '.', and really resolve references.
+   */
+  jbyteArray answer;
+  jsize answerlen;
+  char pathCopy[HyMaxPath];
+  U_32 length = (U_32) (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  (*env)->GetByteArrayRegion (env, path, 0, length, pathCopy);
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+#if defined(WIN32)
+  platformCanonicalPath (pathCopy);
+#endif
+
+  answerlen = strlen (pathCopy);
+  answer = (*env)->NewByteArray (env, answerlen);
+  (*env)->SetByteArrayRegion (env, answer, 0, answerlen, (jbyte *) pathCopy);
+  return answer;
+}
+
+jint JNICALL
+Java_java_io_File_newFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  IDATA portFD;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+
+  /* First check to see if file already exists */
+  result = hyfile_attr (pathCopy);
+  if (result == HyIsDir)
+    return 3;
+  if (result >= 0)
+    return 1;
+
+  /* Now create the file and close it */
+  portFD =
+    hyfile_open (pathCopy, HyOpenCreate | HyOpenWrite | HyOpenTruncate, 0666);
+  if (portFD == -1)
+    return 2;
+  hyfile_close (portFD);
+  return 0;
+}
+
+jobject JNICALL
+Java_java_io_File_rootsImpl (JNIEnv * env, jclass clazz)
+{
+  char rootStrings[HyMaxPath], *rootCopy;
+  I_32 numRoots;
+  I_32 index = 0;
+  jarray answer;
+
+   /**
+	 * It is the responsibility of #getPlatformRoots to return a char array
+	 * with volume names separated by null with a trailing extra null, so for
+	 * Unix it should be '\<null><null>' .
+	 */
+  numRoots = getPlatformRoots (rootStrings);
+  if (numRoots == 0)
+    return NULL;
+  rootCopy = rootStrings;
+
+  answer =
+    (*env)->NewObjectArray (env, numRoots,
+                            JCL_CACHE_GET (env, CLS_array_of_byte), NULL);
+  if (!answer)
+    {
+      return NULL;
+    }
+  while (TRUE)
+    {
+      jbyteArray rootname;
+      jsize entrylen = strlen (rootCopy);
+      /* Have we hit the second null? */
+      if (entrylen == 0)
+        break;
+      rootname = (*env)->NewByteArray (env, entrylen);
+      (*env)->SetByteArrayRegion (env, rootname, 0, entrylen,
+                                  (jbyte *) rootCopy);
+      (*env)->SetObjectArrayElement (env, answer, index++, rootname);
+      (*env)->DeleteLocalRef (env, rootname);
+      rootCopy = rootCopy + entrylen + 1;
+    }
+  return answer;
+}
+
+jboolean JNICALL
+Java_java_io_File_isHiddenImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = getPlatformIsHidden (env, pathCopy);
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_setLastModifiedImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray path, jlong time)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  I_32 result;
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+
+  result = setPlatformLastModified (env, pathCopy, (I_64) time);
+
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_setReadOnlyImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  jsize length = (*env)->GetArrayLength (env, path);
+  char pathCopy[HyMaxPath];
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  return setPlatformReadOnly (env, pathCopy);
+}
+
+void JNICALL
+Java_java_io_File_oneTimeInitialization (JNIEnv * env, jclass clazz)
+{
+  jclass arrayClass = (*env)->FindClass (env, "[B");
+  if (arrayClass)
+    {
+      jobject globalRef = (*env)->NewWeakGlobalRef (env, arrayClass);
+      if (globalRef)
+        JCL_CACHE_SET (env, CLS_array_of_byte, globalRef);
+    }
+  return;
+}
+
+jbyteArray JNICALL
+Java_java_io_File_properPathImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  return getPlatformPath (env, path);
+}
+
+jboolean JNICALL
+Java_java_io_File_isReadOnlyImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = getPlatformIsReadOnly (env, pathCopy);
+  return result;
+}
+
+jboolean JNICALL
+Java_java_io_File_isWriteOnlyImpl (JNIEnv * env, jobject recv,
+                                   jbyteArray path)
+{
+  I_32 result;
+  char pathCopy[HyMaxPath];
+  jsize length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  result = getPlatformIsWriteOnly (env, pathCopy);
+  return result;
+}
+
+jobject JNICALL
+Java_java_io_File_getLinkImpl (JNIEnv * env, jobject recv, jbyteArray path)
+{
+  jbyteArray answer;
+  jsize answerlen;
+  char pathCopy[HyMaxPath];
+  U_32 length = (U_32) (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  (*env)->GetByteArrayRegion (env, path, 0, length, pathCopy);
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+  if (platformReadLink (pathCopy))
+    {
+      answerlen = strlen (pathCopy);
+      answer = (*env)->NewByteArray (env, answerlen);
+      (*env)->SetByteArrayRegion (env, answer, 0, answerlen,
+                                  (jbyte *) pathCopy);
+    }
+  else
+    {
+      answer = path;
+    }
+  return answer;
+}
+
+jboolean JNICALL
+Java_java_io_File_isCaseSensitiveImpl (JNIEnv * env, jclass clazz)
+{
+/* Assume all other platforms ARE case sensitive and add to this list when they prove otherwise */
+#if (defined(WIN32))
+  return FALSE;
+#else
+  return TRUE;
+#endif
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/filedesc.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/filedesc.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/filedesc.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/filedesc.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,70 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 "iohelp.h"
+#include "jclglob.h"
+
+jboolean JNICALL
+Java_java_io_FileDescriptor_valid (JNIEnv * env, jobject recv)
+{
+  /**
+    * Currently only answer false if the descriptor is -1.  Possibly there 
+    * could be an OS check to see if the handle has been invalidated 
+    */
+  void *descriptor = getJavaIoFileDescriptorContentsAsPointer (env, recv);
+  return (IDATA) descriptor != -1;
+}
+
+void JNICALL
+Java_java_io_FileDescriptor_sync (JNIEnv * env, jobject recv)
+{
+  /* Cause all unwritten data to be written out to the OS */
+  IDATA descriptor;
+  I_32 syncfailed = 0;
+  PORT_ACCESS_FROM_ENV (env);
+
+  descriptor = (IDATA) getJavaIoFileDescriptorContentsAsPointer (env, recv);
+  if (descriptor == -1)
+    {
+      syncfailed = 1;
+    }
+  if (!syncfailed && (descriptor > 2))
+    {
+      /* Don't attempt to sync stdin, out, or err */
+      syncfailed = hyfile_sync (descriptor) != 0;
+    }
+  if (syncfailed)
+    {
+      /* Find and throw SyncFailedException */
+      jclass exceptionClass = (*env)->FindClass(env, "java/io/SyncFailedException");
+      if (0 == exceptionClass) { 
+        /* Just return if we can't load the exception class. */
+        return;
+        }
+      (*env)->ThrowNew(env, exceptionClass, "Failed to Sync File");
+      return;
+    }
+}
+
+void JNICALL
+Java_java_io_FileDescriptor_oneTimeInitialization (JNIEnv * env,
+                                                   jclass fdClazz)
+{
+  jfieldID descriptorFID =
+    (*env)->GetFieldID (env, fdClazz, "descriptor", "J");
+  if (!descriptorFID)
+    return;
+  JCL_CACHE_SET (env, FID_java_io_FileDescriptor_descriptor, descriptorFID);
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileis.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileis.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileis.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileis.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,137 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 "iohelp.h"
+#include "jclglob.h"
+
+jlong JNICALL
+Java_java_io_FileInputStream_skip (JNIEnv * env, jobject recv, jlong count)
+{
+  jobject fd;
+  IDATA descriptor;
+  I_64 currentPosition, endOfFile, charsToSkip;
+  PORT_ACCESS_FROM_ENV (env);
+  if (count <= 0)
+    return 0;
+
+  fd =
+    (*env)->GetObjectField (env, recv,
+                            JCL_CACHE_GET (env,
+                                           FID_java_io_FileInputStream_fd));
+  descriptor = (IDATA) getJavaIoFileDescriptorContentsAsPointer (env, fd);
+
+  if (descriptor == -1)
+    {
+      throwJavaIoIOExceptionClosed (env);
+      return 0;
+    }
+
+  currentPosition = hyfile_seek (descriptor, 0, HySeekCur);
+  endOfFile = hyfile_seek (descriptor, 0, HySeekEnd);
+  charsToSkip = (I_64) count > endOfFile
+    || (endOfFile - (I_64) count <
+        currentPosition) ? endOfFile - currentPosition : (I_64) count;
+  hyfile_seek (descriptor, charsToSkip + currentPosition, HySeekSet);
+  return (jlong) charsToSkip;
+}
+
+jint JNICALL
+Java_java_io_FileInputStream_openImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray path)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  IDATA portFD;
+  jobject fd;
+  jsize length;
+  char pathCopy[HyMaxPath];
+  if (path == NULL)
+    {
+      throwNPException (env, "path is null");
+      return 0;
+    }
+  length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+
+  /* Now have the filename, open the file using a portlib call */
+  portFD = hyfile_open (pathCopy, (I_32) HyOpenRead, (I_32) 0);
+
+  if (portFD == -1)
+    return 1;
+
+  fd =
+    (*env)->GetObjectField (env, recv,
+                            JCL_CACHE_GET (env,
+                                           FID_java_io_FileInputStream_fd));
+  setJavaIoFileDescriptorContentsAsPointer (env, fd, (void *) portFD);
+  return 0;
+}
+
+jint JNICALL
+Java_java_io_FileInputStream_available (JNIEnv * env, jobject recv)
+{
+  /**
+   * Call the helper. The helper may throw an exception so either 
+   * check for -1 or return immediately 
+   */
+  return new_ioh_available (env, recv,
+                            JCL_CACHE_GET (env,
+                                           FID_java_io_FileInputStream_fd));
+}
+
+jint JNICALL
+Java_java_io_FileInputStream_readImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray buffer, jint offset,
+                                       jint count, jlong descriptor)
+{
+  /**
+   * Call the helper. The helper may throw an exception so this
+   * must return immediately.
+   */
+  return ioh_readbytesImpl (env, recv, buffer, offset, count,
+                            (IDATA) descriptor);
+}
+
+jint JNICALL
+Java_java_io_FileInputStream_readByteImpl (JNIEnv * env, jobject recv,
+                                           jlong descriptor)
+{
+  /**
+   * Call the helper. The helper may throw an exception so this
+   * must return immediately.
+   */
+  return ioh_readcharImpl (env, recv, (IDATA) descriptor);
+}
+
+void JNICALL
+Java_java_io_FileInputStream_oneTimeInitialization (JNIEnv * env,
+                                                    jclass clazz)
+{
+  jfieldID fdFID =
+    (*env)->GetFieldID (env, clazz, "fd", "Ljava/io/FileDescriptor;");
+  if (!fdFID)
+    return;
+  JCL_CACHE_SET (env, FID_java_io_FileInputStream_fd, fdFID);
+}
+
+void JNICALL
+Java_java_io_FileInputStream_closeImpl (JNIEnv * env, jobject recv)
+{
+  /* Call the helper */
+  new_ioh_close (env, recv,
+                 JCL_CACHE_GET (env, FID_java_io_FileInputStream_fd));
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileos.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileos.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileos.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/fileos.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,106 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <string.h>
+#include "iohelp.h"
+#include "jclglob.h"
+
+jint JNICALL
+Java_java_io_FileOutputStream_openImpl (JNIEnv * env, jobject recv,
+                                        jbyteArray path, jboolean append)
+{
+  jobject fd;
+  I_32 flags =
+    append ==
+    0 ? HyOpenCreate | HyOpenWrite | HyOpenTruncate : HyOpenWrite |
+    HyOpenCreate;
+  IDATA portFD;
+  PORT_ACCESS_FROM_ENV (env);
+  jsize length;
+  char pathCopy[HyMaxPath];
+
+  if (path == NULL)
+    {
+      throwNPException (env, "path is null");
+      return 0;
+    }
+  length = (*env)->GetArrayLength (env, path);
+  length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+  ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+  pathCopy[length] = '\0';
+  ioh_convertToPlatform (pathCopy);
+
+  /* Now have the filename, open the file using a portlib call */
+  portFD = hyfile_open (pathCopy, flags, 0666);
+
+  if (portFD == -1)
+    {
+      return 1;
+    }
+
+  if (append != 0)
+    {
+      hyfile_seek (portFD, 0, HySeekEnd);
+    }
+
+  fd =
+    (*env)->GetObjectField (env, recv,
+                            JCL_CACHE_GET (env,
+                                           FID_java_io_FileOutputStream_fd));
+  setJavaIoFileDescriptorContentsAsPointer (env, fd, (void *) portFD);
+  return 0;
+}
+
+void JNICALL
+Java_java_io_FileOutputStream_writeImpl (JNIEnv * env, jobject recv,
+                                         jbyteArray buffer, jint offset,
+                                         jint count, jlong descriptor)
+{
+  /**
+   * Call the helper. The helper may throw an exception so this
+   * must return immediately.
+   */
+  ioh_writebytesImpl (env, recv, buffer, offset, count, (IDATA) descriptor);
+}
+
+void JNICALL
+Java_java_io_FileOutputStream_writeByteImpl (JNIEnv * env, jobject recv,
+                                             jint c, jlong descriptor)
+{
+  /**
+   * Call the helper. The helper may throw an exception so this
+   * must return immediately.
+   */
+  ioh_writecharImpl (env, recv, c, (IDATA) descriptor);
+}
+
+void JNICALL
+Java_java_io_FileOutputStream_oneTimeInitialization (JNIEnv * env,
+                                                     jclass clazz)
+{
+  jfieldID fdFID =
+    (*env)->GetFieldID (env, clazz, "fd", "Ljava/io/FileDescriptor;");
+  if (!fdFID)
+    return;
+  JCL_CACHE_SET (env, FID_java_io_FileOutputStream_fd, fdFID);
+}
+
+void JNICALL
+Java_java_io_FileOutputStream_closeImpl (JNIEnv * env, jobject recv)
+{
+  /* Call the helper */
+  new_ioh_close (env, recv,
+                 JCL_CACHE_GET (env, FID_java_io_FileOutputStream_fd));
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/floatbits.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/floatbits.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/floatbits.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/floatbits.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,81 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <string.h>
+#include <math.h>
+#include "jcl.h"
+#include "fltconst.h"
+
+#define DOUBLE_SIGN_MASK				HYCONST64(0x8000000000000000)
+#define DOUBLE_EXPONENT_MASK		HYCONST64(0x7FF0000000000000)
+#define DOUBLE_MANTISSA_MASK		HYCONST64(0x000FFFFFFFFFFFFF)
+#define DOUBLE_NAN_BITS					(DOUBLE_EXPONENT_MASK | HYCONST64(0x0008000000000000))
+
+JNIEXPORT jlong JNICALL
+Java_java_lang_Double_doubleToLongBits (JNIEnv * env, jclass cls,
+                                        jdouble doubleValue)
+{
+  jlong longValue = *(jlong *) & doubleValue;
+  if ((longValue & DOUBLE_EXPONENT_MASK) == DOUBLE_EXPONENT_MASK)
+    {
+      if (longValue & DOUBLE_MANTISSA_MASK)
+        {
+          return DOUBLE_NAN_BITS;
+        }
+    }
+  return longValue;
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_lang_Double_doubleToRawLongBits (JNIEnv * env, jclass cls,
+                                           jdouble doubleValue)
+{
+  return *(jlong *) & doubleValue;
+}
+
+JNIEXPORT jdouble JNICALL
+Java_java_lang_Double_longBitsToDouble (JNIEnv * env, jclass cls,
+                                        jlong longValue)
+{
+  return *(jdouble *) & longValue;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_lang_Float_floatToIntBits (JNIEnv * env, jclass cls,
+                                     jfloat floatValue)
+{
+  jint intValue = *(jint *) & floatValue;
+  if ((intValue & SINGLE_EXPONENT_MASK) == SINGLE_EXPONENT_MASK)
+    {
+      if (intValue & SINGLE_MANTISSA_MASK)
+        {
+          return SINGLE_NAN_BITS;
+        }
+    }
+  return intValue;
+}
+
+JNIEXPORT jint JNICALL
+Java_java_lang_Float_floatToRawIntBits (JNIEnv * env, jclass cls,
+                                        jfloat floatValue)
+{
+  return *(jint *) & floatValue;
+}
+
+JNIEXPORT jfloat JNICALL
+Java_java_lang_Float_intBitsToFloat (JNIEnv * env, jclass cls, jint intValue)
+{
+  return *(jfloat *) & intValue;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/jclglob.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/jclglob.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/jclglob.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/jclglob.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,81 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(jclglob_h)
+#define jclglob_h
+#include "jcl.h"
+extern void *LUNI_JCL_ID_CACHE;
+#define JCL_ID_CACHE LUNI_JCL_ID_CACHE
+typedef struct LUNIJniIDCache
+{
+
+  jfieldID FID_java_io_RandomAccessFile_fd;
+  jfieldID FID_java_io_FileDescriptor_descriptor;
+  jfieldID FID_java_io_FileInputStream_fd;
+  jfieldID FID_java_io_FileOutputStream_fd;
+  jfieldID FID_com_ibm_oti_lang_ProcessInputStream_handle;
+  jfieldID FID_com_ibm_oti_lang_ProcessInputStream_fd;
+  jfieldID FID_com_ibm_oti_lang_ProcessOutputStream_handle;
+  jfieldID FID_com_ibm_oti_lang_ProcessOutputStream_fd;
+  jfieldID FID_com_ibm_oti_lang_SystemProcess_handle;
+  jfieldID FID_java_net_SocketImpl_address;
+  jfieldID FID_java_net_SocketImpl_port;
+  jfieldID FID_java_net_DatagramPacket_length;
+  jfieldID FID_java_net_DatagramPacket_address;
+  jfieldID FID_java_net_DatagramPacket_port;
+  jfieldID FID_java_lang_ClassLoader_vmRef;
+  jfieldID FID_com_ibm_oti_vm_MemorySpace;
+  /* Used by ObjectStreamClass */
+  jmethodID MID_java_lang_reflect_Field_getSignature;
+  jmethodID MID_java_lang_reflect_Method_getSignature;
+  jmethodID MID_java_lang_reflect_Constructor_getSignature;
+  /* Used by shared net helpers */
+  jmethodID MID_java_lang_Boolean_init;
+  jmethodID MID_java_lang_Byte_init;
+  jmethodID MID_java_lang_Integer_init;
+  jmethodID MID_java_net_InetAddress_init_byteArray;
+  jmethodID MID_java_net_InetAddress_init_byteArrayLjava_lang_String;
+  jmethodID MID_java_lang_Thread_yield;
+  jmethodID MID_java_net_InetAddress_getByAddress_Ljava_lang_String_byteArray;
+  jmethodID MID_java_net_InetAddress_getByAddress_byteArray;
+  jmethodID MID_java_net_InetAddress_preferIPv6Addresses;
+  jmethodID MID_java_net_Socket_preferIPv4Stack;
+  jclass CLS_java_lang_Boolean;
+  jclass CLS_java_lang_Byte;
+  jclass CLS_java_lang_Integer;
+  jclass CLS_java_lang_Thread;
+  jclass CLS_java_net_InetAddress;
+  jclass CLS_java_net_Socket;
+  jfieldID FID_java_lang_Boolean_value;
+  jfieldID FID_java_lang_Byte_value;
+  jfieldID FID_java_lang_Integer_value;
+  jfieldID FID_java_net_InetAddress_address;
+  jclass CLS_array_of_byte;
+  /* comm connection port lists */
+  char **realPortArray;
+  char **synthPortArray;
+  int portListLen;
+
+  /* JCL support for IPv6 */
+  jboolean jcl_supports_ipv6;
+} LUNIJniIDCache;
+#define JniIDCache LUNIJniIDCache
+/* Now that the module-specific defines are in place, include the shared file */
+#include "libglob.h"
+/* all UNIX platforms */
+#if defined(LINUX)
+#include "hysignal.h"
+#endif /* UNIX */
+#endif /* jclglob_h */

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/luni_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/luni_copyright.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/luni_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/luni_copyright.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,19 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/nethelp.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,40 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(nethelp_h)
+#define nethelp_h
+#include "iohelp.h"
+#include "hysocket.h"
+#define JAVASOCKOPT_TCP_NODELAY 1
+#define JAVASOCKOPT_SO_REUSEADDR 4
+#define JAVASOCKOPT_MCAST_ADD_MEMBERSHIP 19
+#define JAVASOCKOPT_MCAST_DROP_MEMBERSHIP 20
+#define JAVASOCKOPT_MCAST_TTL 17
+#define JAVASOCKOPT_SO_KEEPALIVE 8
+#define JAVASOCKOPT_MCAST_TIME_TO_LIVE 10       /* Currently unused */
+#define JAVASOCKOPT_SO_BROADCAST 32
+#define JAVASOCKOPT_SO_BINDADDR 15
+#define JAVASOCKOPT_MCAST_INTERFACE 16
+#define JAVASOCKOPT_SO_LINGER 128
+#define JAVASOCKOPT_SO_REUSEPORT 512
+#define JAVASOCKOPT_SO_SNDBUF 4097
+#define JAVASOCKOPT_SO_RCVBUF 4098
+#define JAVASOCKOPT_SO_RCVTIMEOUT  4102
+#define JAVASOCKOPT_IP_TOS 3
+#define JAVASOCKOPT_IP_MULTICAST_LOOP 18
+#define JAVASOCKOPT_IP_MULTICAST_IF2 31
+#define JAVASOCKOPT_SO_OOBINLINE  4099
+#define JAVASOCKOPT_REUSEADDR_AND_REUSEPORT  10001
+#endif /* nethelp_h */

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/netif.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/netif.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/netif.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/netif.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,214 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 "nethelp.h"
+#include "jclprots.h"
+#include "helpers.h"
+#include "jclglob.h"
+#include "portsock.h"
+
+/**
+ * Answer an array of NetworkInterface objects.  One for each network interface within the system
+ *
+ * @param	env	pointer to the JNI library
+ * @param	clazz	the class of the object invoking the JNI function
+ *
+ * @return			an array of NetworkInterface objects of length 0 or more
+ */
+
+jobjectArray JNICALL
+Java_java_net_NetworkInterface_getNetworkInterfacesImpl (JNIEnv * env,
+                                                         jclass clazz)
+{
+  /* variables to store network interfac edata returned by call to port library */
+  struct hyNetworkInterfaceArray_struct networkInterfaceArray;
+  I_32 result = 0;
+
+  /* variables for class and method objects needed to create bridge to java */
+  jclass networkInterfaceClass = NULL;
+  jclass inetAddressClass = NULL;
+  jclass utilClass = NULL;
+  jmethodID methodID = NULL;
+  jmethodID utilMid = NULL;
+
+  /* JNI objects used to return values from native call */
+  jstring name = NULL;
+  jstring displayName = NULL;
+  jobjectArray addresses = NULL;
+  jobjectArray networkInterfaces = NULL;
+  jbyteArray bytearray = NULL;
+
+  /* jobjects used to build the object arrays returned */
+  jobject currentInterface = NULL;
+  jobject element = NULL;
+
+  /* misc variables needed for looping and determining inetAddress info */
+  U_32 length = 0;
+  I_32 family = 0;
+  U_32 i = 0;
+  U_32 j = 0;
+  U_32 nameLength = 0;
+
+  /* required call if we are going to call port library methods */
+  PORT_ACCESS_FROM_ENV (env);
+
+  /* get the classes and methods that we need for later calls */
+  networkInterfaceClass =
+    (*env)->FindClass (env, "java/net/NetworkInterface");
+  if (networkInterfaceClass == NULL)
+    {
+      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_NORECOVERY);
+      return NULL;
+    }
+
+  inetAddressClass = (*env)->FindClass (env, "java/net/InetAddress");
+  if (inetAddressClass == NULL)
+    {
+      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_NORECOVERY);
+      return NULL;
+    }
+
+  methodID =
+    (*env)->GetMethodID (env, networkInterfaceClass, "<init>",
+                         "(Ljava/lang/String;Ljava/lang/String;[Ljava/net/InetAddress;I)V");
+  if (methodID == NULL)
+    {
+      throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_NORECOVERY);
+      return NULL;
+    }
+
+  utilClass = (*env)->FindClass (env, "com/ibm/oti/util/Util");
+  if (!utilClass)
+    {
+      return NULL;
+    }
+
+  utilMid =
+    ((*env)->
+     GetStaticMethodID (env, utilClass, "toString",
+                        "([BII)Ljava/lang/String;"));
+  if (!utilMid)
+    return NULL;
+
+  result =
+    hysock_get_network_interfaces (&networkInterfaceArray,
+                                   preferIPv4Stack (env));
+
+  if (result < 0)
+    {
+      /* this means an error occured.  The value returned is the socket error that should be returned */
+      throwJavaNetSocketException (env, result);
+      return NULL;
+    }
+
+  /* now loop through the interfaces and extract the information to be returned */
+  for (j = 0; j < networkInterfaceArray.length; j++)
+    {
+      /* set the name and display name and reset the addresses object array */
+      addresses = NULL;
+      name = NULL;
+      displayName = NULL;
+
+      if (networkInterfaceArray.elements[j].name != NULL)
+        {
+          nameLength = strlen (networkInterfaceArray.elements[j].name);
+          bytearray = (*env)->NewByteArray (env, nameLength);
+          if (bytearray == NULL)
+            {
+              /* NewByteArray should have thrown an exception */
+              return NULL;
+            }
+          (*env)->SetByteArrayRegion (env, bytearray, (jint) 0, nameLength,
+                                      networkInterfaceArray.elements[j].name);
+          name =
+            (*env)->CallStaticObjectMethod (env, utilClass, utilMid,
+                                            bytearray, (jint) 0, nameLength);
+          if ((*env)->ExceptionCheck (env))
+            {
+              return NULL;
+            }
+        }
+
+      if (networkInterfaceArray.elements[j].displayName != NULL)
+        {
+          nameLength = strlen (networkInterfaceArray.elements[j].displayName);
+          bytearray = (*env)->NewByteArray (env, nameLength);
+          if (bytearray == NULL)
+            {
+              /* NewByteArray should have thrown an exception */
+              return NULL;
+            }
+          (*env)->SetByteArrayRegion (env, bytearray, (jint) 0, nameLength,
+                                      networkInterfaceArray.elements[j].
+                                      displayName);
+          displayName =
+            (*env)->CallStaticObjectMethod (env, utilClass, utilMid,
+                                            bytearray, (jint) 0, nameLength);
+          if ((*env)->ExceptionCheck (env))
+            {
+              return NULL;
+            }
+        }
+
+      /* generate the object with the inet addresses for the itnerface       */
+      for (i = 0; i < networkInterfaceArray.elements[j].numberAddresses; i++)
+        {
+          element = newJavaNetInetAddressGenericB (env,
+                                                   networkInterfaceArray.
+                                                   elements[j].addresses[i].
+                                                   addr.bytes,
+                                                   networkInterfaceArray.
+                                                   elements[j].addresses[i].
+                                                   length,
+                                                   networkInterfaceArray.
+                                                   elements[j].addresses[i].
+                                                   scope);
+          if (i == 0)
+            {
+              addresses =
+                (*env)->NewObjectArray (env,
+                                        networkInterfaceArray.elements[j].
+                                        numberAddresses, inetAddressClass,
+                                        element);
+            }
+          else
+            {
+              (*env)->SetObjectArrayElement (env, addresses, i, element);
+            }
+        }
+
+      /* now  create the NetworkInterface object for this interface and then add it it ot the arrary that will be returned */
+      currentInterface =
+        (*env)->NewObject (env, networkInterfaceClass, methodID, name,
+                           displayName, addresses,
+                           networkInterfaceArray.elements[j].index);
+
+      if (j == 0)
+        {
+          networkInterfaces =
+            (*env)->NewObjectArray (env, networkInterfaceArray.length,
+                                    networkInterfaceClass, currentInterface);
+        }
+      else
+        {
+          (*env)->SetObjectArrayElement (env, networkInterfaces, j,
+                                         currentInterface);
+        }
+    }
+
+  /* free the memory for the interfaces struct and return the new NetworkInterface List */
+  hysock_free_network_interface_struct (&networkInterfaceArray);
+  return networkInterfaces;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/ois.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/ois.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/ois.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/luni/ois.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,217 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 "jni.h"
+
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2Z
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jboolean newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "Z");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetBooleanField (env, targetObject, fid, newValue);
+    }
+}
+
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2C
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jchar newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "C");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetCharField (env, targetObject, fid, newValue);
+    }
+}
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2I
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jint newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "I");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetIntField (env, targetObject, fid, newValue);
+    }
+}
+
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2F
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jfloat newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "F");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetFloatField (env, targetObject, fid, newValue);
+    }
+}
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2D
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jdouble newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "D");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetDoubleField (env, targetObject, fid, newValue);
+    }
+
+}
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2S
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jshort newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "S");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetShortField (env, targetObject, fid, newValue);
+    }
+
+}
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2J
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jlong newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "J");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetLongField (env, targetObject, fid, newValue);
+    }
+}
+jobject JNICALL
+Java_java_io_ObjectInputStream_newInstance (JNIEnv * env, jclass clazz,
+                                            jobject instantiationClass,
+                                            jobject constructorClass)
+{
+  jmethodID mid =
+    (*env)->GetMethodID (env, constructorClass, "<init>", "()V");
+
+  if (mid == 0)
+    {
+      /* Cant newInstance,No empty constructor... */
+      return (jobject) 0;
+    }
+  else
+    {
+      return (jobject) (*env)->NewObject (env, instantiationClass, mid);        /* Instantiate an object of a given class */
+    }
+
+}
+void JNICALL
+  Java_java_io_ObjectInputStream_setField__Ljava_lang_Object_2Ljava_lang_Class_2Ljava_lang_String_2B
+  (JNIEnv * env, jclass clazz, jobject targetObject, jobject declaringClass,
+   jobject fieldName, jbyte newValue)
+{
+  const char *fieldNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fid = (*env)->GetFieldID (env, declaringClass, fieldNameInC, "B");
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetByteField (env, targetObject, fid, newValue);
+    }
+}
+void JNICALL
+Java_java_io_ObjectInputStream_objSetField (JNIEnv * env, jclass clazz,
+                                            jobject targetObject,
+                                            jobject declaringClass,
+                                            jobject fieldName,
+                                            jobject fieldTypeName,
+                                            jobject newValue)
+{
+  const char *fieldNameInC, *fieldTypeNameInC;
+  jfieldID fid;
+  if (targetObject == NULL)
+    return;
+  fieldNameInC = (*env)->GetStringUTFChars (env, fieldName, NULL);
+  fieldTypeNameInC = (*env)->GetStringUTFChars (env, fieldTypeName, NULL);
+  fid =
+    (*env)->GetFieldID (env, declaringClass, fieldNameInC, fieldTypeNameInC);
+  (*env)->ReleaseStringUTFChars (env, fieldName, fieldNameInC);
+  (*env)->ReleaseStringUTFChars (env, fieldTypeName, fieldTypeNameInC);
+
+  /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */
+  if (fid != 0)
+    {
+      (*env)->SetObjectField (env, targetObject, fid, newValue);
+    }
+}



Mime
View raw message