[cp-patches] [NATIVE-LAYER] IO work & NET fix

Guilhem Lavaux guilhem at kaffe.org
Sat Jun 10 20:26:08 UTC 2006


Hi,

Here are some missing stuff that I have detected by running mauve on the
branch. cp*dir calls were not implemented (hmmm) . And there was a
little trouble with typecasting when building an IPV4 address.

Guilhem.

ChangeLog:
2006-06-10  Guilhem Lavaux  <guilhem at kaffe.org>

        * native/jni/native-lib/cpio.c
        (cpio_openDir, cpio_closeDir, cpio_readDir): Implemented.

        * native/jni/native-lib/cpnet.h:
        (cpnet_bytesToIPV4Address): Fixed type casting to avoid being
        messed by signs in jbyte.


-------------- next part --------------
Index: native/jni/native-lib/cpio.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpio.c,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 cpio.c
--- native/jni/native-lib/cpio.c	25 Mar 2006 17:08:50 -0000	1.1.2.3
+++ native/jni/native-lib/cpio.c	10 Jun 2006 20:23:09 -0000
@@ -43,6 +43,7 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/types.h>
+#include <dirent.h>
 
 #include <jni.h>
 
@@ -419,3 +420,30 @@
   return 0;
 }
 
+int cpio_openDir (const char *dirname, void **handle)
+{
+  *handle = (void *)opendir(dirname);
+  if (*handle == NULL)
+    return errno;
+  
+  return 0;
+}
+
+int cpio_closeDir (void *handle)
+{
+  closedir((DIR *)handle);
+  return 0;
+}
+
+
+int cpio_readDir (void *handle, const char **filename)
+{
+  struct dirent *dBuf;
+
+  dBuf = readdir((DIR *)handle);
+  if (dBuf == NULL)
+    return errno;
+
+  *filename = dBuf->d_name;
+  return 0;
+}
Index: native/jni/native-lib/cpnet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpnet.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 cpnet.c
--- native/jni/native-lib/cpnet.c	10 May 2006 07:08:25 -0000	1.1.2.4
+++ native/jni/native-lib/cpnet.c	10 Jun 2006 20:23:09 -0000
@@ -180,6 +180,8 @@
   int ret;
 
   /* TODO: implement socket time out */
+  struct sockaddr_in *theaddr = (struct sockaddr_in *)addr->data;
+
   ret = connect(fd, (struct sockaddr *)addr->data, addr->len);
   if (ret != 0)
     return errno;
Index: native/jni/native-lib/cpnet.h
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/native-lib/Attic/cpnet.h,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 cpnet.h
--- native/jni/native-lib/cpnet.h	19 Feb 2006 17:10:27 -0000	1.1.2.5
+++ native/jni/native-lib/cpnet.h	10 Jun 2006 20:23:09 -0000
@@ -189,10 +189,10 @@
   jint sysaddr;
   struct sockaddr_in *ipaddr = (struct sockaddr_in *)&(netaddr->data[0]);
 
-  sysaddr = ((jint)octets[0]) << 24;
-  sysaddr |= ((jint)octets[1]) << 16;
-  sysaddr |= ((jint)octets[2]) << 8;
-  sysaddr |= ((jint)octets[3]);
+  sysaddr = ((jint)(unsigned char)octets[0]) << 24;
+  sysaddr |= ((jint)(unsigned char)octets[1]) << 16;
+  sysaddr |= ((jint)(unsigned char)octets[2]) << 8;
+  sysaddr |= ((jint)(unsigned char)octets[3]);
 
   ipaddr->sin_addr.s_addr = htonl(sysaddr);
 }


More information about the Classpath-patches mailing list