[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Thu Jan 8 08:54:02 2004


PatchSet 4292 
Date: 2004/01/08 16:38:46
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath

2004-01-08  Dalibor Topic <robilad@kaffe.org>

        Resynced with GNU Classpath.

        2003-10-09  Michael Koch  <konqueror@gmx.de>

        * gnu/java/net/PlainSocketImpl.java: Added classes SocketInputStream
        and SocketOutputStream.

Members: 
	ChangeLog:1.1879->1.1880 
	libltdl/config-h.in:1.10->1.11 
	libraries/javalib/gnu/java/net/PlainSocketImpl.java:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1879 kaffe/ChangeLog:1.1880
--- kaffe/ChangeLog:1.1879	Thu Jan  8 10:33:49 2004
+++ kaffe/ChangeLog	Thu Jan  8 16:38:46 2004
@@ -1,5 +1,14 @@
 2004-01-08  Dalibor Topic <robilad@kaffe.org>
 
+	Resynced with GNU Classpath.
+
+	2003-10-09  Michael Koch  <konqueror@gmx.de>
+
+        * gnu/java/net/PlainSocketImpl.java: Added classes SocketInputStream
+        and SocketOutputStream.
+
+2004-01-08  Dalibor Topic <robilad@kaffe.org>
+
 	* libraries/javalib/Makefile.am,
 	libraries/javalib/Makefile.in:
 	Regenerated.
Index: kaffe/libltdl/config-h.in
diff -u kaffe/libltdl/config-h.in:1.10 kaffe/libltdl/config-h.in:1.11
--- kaffe/libltdl/config-h.in:1.10	Mon Dec  8 02:46:41 2003
+++ kaffe/libltdl/config-h.in	Thu Jan  8 16:38:47 2004
@@ -188,6 +188,8 @@
 /* Define to a type to use for `error_t' if it is not otherwise available. */
 #undef error_t
 
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
-   if it is not supported. */
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
 #undef inline
+#endif
Index: kaffe/libraries/javalib/gnu/java/net/PlainSocketImpl.java
diff -u kaffe/libraries/javalib/gnu/java/net/PlainSocketImpl.java:1.1 kaffe/libraries/javalib/gnu/java/net/PlainSocketImpl.java:1.2
--- kaffe/libraries/javalib/gnu/java/net/PlainSocketImpl.java:1.1	Sun Sep 28 19:54:09 2003
+++ kaffe/libraries/javalib/gnu/java/net/PlainSocketImpl.java	Thu Jan  8 16:38:48 2004
@@ -257,4 +257,209 @@
 protected native void waitForConnection() throws IOException;
 protected native void setBlocking(boolean blocking);
 
+/* Taken from GNU Classpath. */
+
+  /**
+   * This class contains an implementation of <code>InputStream</code> for
+   * sockets.  It in an internal only class used by <code>PlainSocketImpl</code>.
+   */
+  class SocketInputStream extends InputStream
+  {
+    /**
+     * The PlainSocketImpl object this stream is associated with
+     */
+    private PlainSocketImpl impl;
+
+    /**
+     * Builds an instance of this class from a PlainSocketImpl object
+     */
+    protected SocketInputStream (PlainSocketImpl impl)
+    {
+      this.impl = impl;
+    }
+
+    /**
+     * Returns the number of bytes available to be read before blocking
+     */
+    public int available() throws IOException
+    {
+      return impl.available();
+    }
+
+    /**
+     * Determines if "mark" functionality is supported on this stream.  For
+     * sockets, this is always false.  Note that the superclass default is
+     * false, but it is overridden out of safety concerns and/or paranoia.
+     */
+    public boolean markSupported()
+    {
+      return false;
+    }
+
+    /**
+     * Do nothing mark method since we don't support this functionality.  Again,
+     * overriding out of paranoia.
+     *
+     * @param readlimit In theory, the number of bytes we can read before the mark becomes invalid
+     */
+    public void mark (int readlimit)
+    {
+    }
+
+    /**
+     * Since we don't support mark, this method always throws an exception
+     *
+     * @exception IOException Everytime since we don't support this functionality
+     */
+    public void reset() throws IOException
+    {
+      throw new IOException ("Socket InputStreams do not support mark/reset");
+    }
+
+    /**
+     * This method not only closes the stream, it closes the underlying socket
+     * (and thus any connection) and invalidates any other Input/Output streams
+     * for the underlying impl object
+     */
+    public void close() throws IOException
+    {
+      impl.close();
+    }
+
+    /**
+     * Reads the next byte of data and returns it as an int.
+     *
+     * @return The byte read (as an int) or -1 if end of stream);
+     *
+     * @exception IOException If an error occurs.
+     */
+    public int read() throws IOException
+    {
+      byte buf[] = new byte [1];
+      int bytes_read = read (buf, 0, buf.length);
+
+      if (bytes_read != -1)
+        return buf[0] & 0xFF;
+      else
+        return -1;
+    }
+
+    /**
+     * Reads up to buf.length bytes of data into the caller supplied buffer.
+     *
+     * @return The actual number of bytes read or -1 if end of stream
+     *
+     * @exception IOException If an error occurs.
+     */
+    public int read (byte[] buf) throws IOException
+    {
+      return read (buf, 0, buf.length);
+    }
+
+    /**
+     * Reads up to len bytes of data into the caller supplied buffer starting
+     * at offset bytes from the start of the buffer
+     *
+     * @return The number of bytes actually read or -1 if end of stream
+     *
+     * @exception IOException If an error occurs.
+     */
+    public int read (byte[] buf, int offset, int len) throws IOException
+    {
+      int bytes_read = impl.read (buf, offset, len);
+
+      if (bytes_read == 0)
+        return -1;
+
+      return bytes_read;
+    }
+
+  } // class SocketInputStream
+
+  /**
+   * This class is used internally by <code>PlainSocketImpl</code> to be the
+   * <code>OutputStream</code> subclass returned by its
+   * <code>getOutputStream method</code>.  It expects only to  be used in that
+   * context.
+   */
+  class SocketOutputStream extends OutputStream
+  {
+    /**
+     * The PlainSocketImpl object this stream is associated with
+     */
+    private PlainSocketImpl impl;
+
+    /**
+     * Build an instance of this class from a PlainSocketImpl object
+     */
+    protected SocketOutputStream (PlainSocketImpl impl)
+    {
+      this.impl = impl;
+    }
+
+    /**
+     * This method closes the stream and the underlying socket connection. This
+     * action also effectively closes any other InputStream or OutputStream
+     * object associated with the connection.
+     *
+     * @exception IOException If an error occurs
+     */
+    public void close() throws IOException
+    {
+      impl.close();
+    }
+
+    /**
+     * Hmmm, we don't seem to have a flush() method in Socket impl, so just
+     * return for now, but this might need to be looked at later.
+     *
+     * @exception IOException Can't happen
+     */
+    public void flush() throws IOException
+    {
+    }
+
+    /**
+     * Writes a byte (passed in as an int) to the given output stream
+     *
+     * @param b The byte to write
+     *
+     * @exception IOException If an error occurs
+     */
+    public void write (int b) throws IOException
+    {
+      byte buf[] = new byte [1];
+      Integer i = new Integer (b);
+
+      buf [0] = i.byteValue();
+      write (buf, 0, buf.length);
+    }
+
+    /**
+     * Write an array of bytes to the output stream
+     *
+     * @param buf The array of bytes to write
+     *
+     * @exception IOException If an error occurs
+     */
+    public void write (byte[] buf) throws IOException
+    {
+      write (buf, 0, buf.length);
+    }
+
+    /**
+     * Writes len number of bytes from the array buf to the stream starting
+     * at offset bytes into the buffer.
+     *
+     * @param buf The buffer
+     * @param offset Offset into the buffer to start writing from
+     * @param len The number of bytes to write
+     */
+    public void write (byte[] buf, int offset, int len) throws IOException
+    {
+      impl.write (buf, offset, len);
+    }
+
+  } // class SocketOutputStream
+
 }