summaryrefslogtreecommitdiff
path: root/libjava/gnu/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/java/net')
-rw-r--r--libjava/gnu/java/net/CRLFInputStream.h47
-rw-r--r--libjava/gnu/java/net/CRLFOutputStream.h48
-rw-r--r--libjava/gnu/java/net/DefaultContentHandlerFactory.h46
-rw-r--r--libjava/gnu/java/net/DefaultProxySelector.h45
-rw-r--r--libjava/gnu/java/net/EmptyX509TrustManager.h47
-rw-r--r--libjava/gnu/java/net/GetLocalHostAction.h41
-rw-r--r--libjava/gnu/java/net/HeaderFieldHelper.h43
-rw-r--r--libjava/gnu/java/net/ImageHandler.h44
-rw-r--r--libjava/gnu/java/net/IndexListParser.h51
-rw-r--r--libjava/gnu/java/net/LineInputStream.h49
-rw-r--r--libjava/gnu/java/net/PlainDatagramSocketImpl.h93
-rw-r--r--libjava/gnu/java/net/PlainDatagramSocketImpl.java310
-rw-r--r--libjava/gnu/java/net/PlainSocketImpl$SocketInputStream.h43
-rw-r--r--libjava/gnu/java/net/PlainSocketImpl$SocketOutputStream.h42
-rw-r--r--libjava/gnu/java/net/PlainSocketImpl.h95
-rw-r--r--libjava/gnu/java/net/PlainSocketImpl.java478
-rw-r--r--libjava/gnu/java/net/URLParseError.h32
-rw-r--r--libjava/gnu/java/net/loader/FileResource.h49
-rw-r--r--libjava/gnu/java/net/loader/FileURLLoader.h52
-rw-r--r--libjava/gnu/java/net/loader/JarURLLoader.h60
-rw-r--r--libjava/gnu/java/net/loader/JarURLResource.h60
-rw-r--r--libjava/gnu/java/net/loader/Load_gcjlib$SoResource.h50
-rw-r--r--libjava/gnu/java/net/loader/Load_gcjlib.h58
-rw-r--r--libjava/gnu/java/net/loader/Load_gcjlib.java77
-rw-r--r--libjava/gnu/java/net/loader/RemoteResource.h52
-rw-r--r--libjava/gnu/java/net/loader/RemoteURLLoader.h50
-rw-r--r--libjava/gnu/java/net/loader/Resource.h62
-rw-r--r--libjava/gnu/java/net/loader/URLLoader.h63
-rw-r--r--libjava/gnu/java/net/loader/URLStreamHandlerCache.h48
-rw-r--r--libjava/gnu/java/net/local/LocalServerSocket.h68
-rw-r--r--libjava/gnu/java/net/local/LocalSocket.h100
-rw-r--r--libjava/gnu/java/net/local/LocalSocketAddress.h42
-rw-r--r--libjava/gnu/java/net/local/LocalSocketImpl$LocalInputStream.h52
-rw-r--r--libjava/gnu/java/net/local/LocalSocketImpl$LocalOutputStream.h49
-rw-r--r--libjava/gnu/java/net/local/LocalSocketImpl.h86
-rw-r--r--libjava/gnu/java/net/local/LocalSocketImpl.java310
-rw-r--r--libjava/gnu/java/net/natPlainDatagramSocketImplNoNet.cc119
-rw-r--r--libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc858
-rw-r--r--libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc712
-rw-r--r--libjava/gnu/java/net/natPlainSocketImplNoNet.cc132
-rw-r--r--libjava/gnu/java/net/natPlainSocketImplPosix.cc868
-rw-r--r--libjava/gnu/java/net/natPlainSocketImplWin32.cc796
-rw-r--r--libjava/gnu/java/net/protocol/core/Connection.h64
-rw-r--r--libjava/gnu/java/net/protocol/core/Connection.java172
-rw-r--r--libjava/gnu/java/net/protocol/core/CoreInputStream.h60
-rw-r--r--libjava/gnu/java/net/protocol/core/CoreInputStream.java90
-rw-r--r--libjava/gnu/java/net/protocol/core/Handler.h49
-rw-r--r--libjava/gnu/java/net/protocol/core/Handler.java28
-rw-r--r--libjava/gnu/java/net/protocol/core/natCoreInputStream.cc51
-rw-r--r--libjava/gnu/java/net/protocol/file/Connection$StaticData.h48
-rw-r--r--libjava/gnu/java/net/protocol/file/Connection.h70
-rw-r--r--libjava/gnu/java/net/protocol/file/Handler.h49
-rw-r--r--libjava/gnu/java/net/protocol/ftp/ActiveModeDTP.h70
-rw-r--r--libjava/gnu/java/net/protocol/ftp/BlockInputStream.h52
-rw-r--r--libjava/gnu/java/net/protocol/ftp/BlockOutputStream.h50
-rw-r--r--libjava/gnu/java/net/protocol/ftp/CompressedInputStream.h59
-rw-r--r--libjava/gnu/java/net/protocol/ftp/CompressedOutputStream.h56
-rw-r--r--libjava/gnu/java/net/protocol/ftp/DTP.h43
-rw-r--r--libjava/gnu/java/net/protocol/ftp/DTPInputStream.h46
-rw-r--r--libjava/gnu/java/net/protocol/ftp/DTPOutputStream.h46
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPConnection.h165
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPException.h43
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPResponse.h47
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingInputStream.h44
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingOutputStream.h44
-rw-r--r--libjava/gnu/java/net/protocol/ftp/FTPURLConnection.h65
-rw-r--r--libjava/gnu/java/net/protocol/ftp/Handler.h50
-rw-r--r--libjava/gnu/java/net/protocol/ftp/PassiveModeDTP.h65
-rw-r--r--libjava/gnu/java/net/protocol/ftp/StreamInputStream.h45
-rw-r--r--libjava/gnu/java/net/protocol/ftp/StreamOutputStream.h45
-rw-r--r--libjava/gnu/java/net/protocol/gcjlib/Connection.h57
-rw-r--r--libjava/gnu/java/net/protocol/gcjlib/Connection.java83
-rw-r--r--libjava/gnu/java/net/protocol/gcjlib/Handler.h49
-rw-r--r--libjava/gnu/java/net/protocol/gcjlib/Handler.java24
-rw-r--r--libjava/gnu/java/net/protocol/http/Authenticator.h39
-rw-r--r--libjava/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.h47
-rw-r--r--libjava/gnu/java/net/protocol/http/ChunkedInputStream.h55
-rw-r--r--libjava/gnu/java/net/protocol/http/Cookie.h56
-rw-r--r--libjava/gnu/java/net/protocol/http/CookieManager.h42
-rw-r--r--libjava/gnu/java/net/protocol/http/Credentials.h44
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPConnection$Pool$Reaper.h44
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPConnection$Pool.h50
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPConnection.h128
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPDateFormat.h62
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPURLConnection$1.h47
-rw-r--r--libjava/gnu/java/net/protocol/http/HTTPURLConnection.h115
-rw-r--r--libjava/gnu/java/net/protocol/http/Handler.h50
-rw-r--r--libjava/gnu/java/net/protocol/http/Headers$HeaderElement.h41
-rw-r--r--libjava/gnu/java/net/protocol/http/Headers.h62
-rw-r--r--libjava/gnu/java/net/protocol/http/LimitedLengthInputStream.h57
-rw-r--r--libjava/gnu/java/net/protocol/http/Request.h87
-rw-r--r--libjava/gnu/java/net/protocol/http/RequestBodyWriter.h42
-rw-r--r--libjava/gnu/java/net/protocol/http/Response.h61
-rw-r--r--libjava/gnu/java/net/protocol/http/ResponseHeaderHandler.h38
-rw-r--r--libjava/gnu/java/net/protocol/http/SimpleCookieManager.h48
-rw-r--r--libjava/gnu/java/net/protocol/https/Handler.h50
-rw-r--r--libjava/gnu/java/net/protocol/jar/Connection$JarFileCache.h50
-rw-r--r--libjava/gnu/java/net/protocol/jar/Connection.h62
-rw-r--r--libjava/gnu/java/net/protocol/jar/Handler.h54
99 files changed, 9787 insertions, 0 deletions
diff --git a/libjava/gnu/java/net/CRLFInputStream.h b/libjava/gnu/java/net/CRLFInputStream.h
new file mode 100644
index 000000000..1c4df5ccc
--- /dev/null
+++ b/libjava/gnu/java/net/CRLFInputStream.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_CRLFInputStream__
+#define __gnu_java_net_CRLFInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class CRLFInputStream;
+ }
+ }
+ }
+}
+
+class gnu::java::net::CRLFInputStream : public ::java::io::InputStream
+{
+
+public:
+ CRLFInputStream(::java::io::InputStream *);
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+private:
+ jint indexOfCRLF(JArray< jbyte > *, jint, jint);
+public:
+ static const jint CR = 13;
+ static const jint LF = 10;
+public: // actually protected
+ ::java::io::InputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) in;
+private:
+ jboolean doReset;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_CRLFInputStream__
diff --git a/libjava/gnu/java/net/CRLFOutputStream.h b/libjava/gnu/java/net/CRLFOutputStream.h
new file mode 100644
index 000000000..594d7ae6f
--- /dev/null
+++ b/libjava/gnu/java/net/CRLFOutputStream.h
@@ -0,0 +1,48 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_CRLFOutputStream__
+#define __gnu_java_net_CRLFOutputStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class CRLFOutputStream;
+ }
+ }
+ }
+}
+
+class gnu::java::net::CRLFOutputStream : public ::java::io::FilterOutputStream
+{
+
+public:
+ CRLFOutputStream(::java::io::OutputStream *);
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void write(::java::lang::String *);
+ virtual void writeln();
+public: // actually package-private
+ static ::java::lang::String * US_ASCII;
+public:
+ static const jint CR = 13;
+ static const jint LF = 10;
+ static JArray< jbyte > * CRLF;
+public: // actually protected
+ jint __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) last;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_CRLFOutputStream__
diff --git a/libjava/gnu/java/net/DefaultContentHandlerFactory.h b/libjava/gnu/java/net/DefaultContentHandlerFactory.h
new file mode 100644
index 000000000..06c3f6f52
--- /dev/null
+++ b/libjava/gnu/java/net/DefaultContentHandlerFactory.h
@@ -0,0 +1,46 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_DefaultContentHandlerFactory__
+#define __gnu_java_net_DefaultContentHandlerFactory__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class DefaultContentHandlerFactory;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class ContentHandler;
+ }
+ }
+}
+
+class gnu::java::net::DefaultContentHandlerFactory : public ::java::lang::Object
+{
+
+public:
+ DefaultContentHandlerFactory();
+ virtual ::java::net::ContentHandler * createContentHandler(::java::lang::String *);
+private:
+ static JArray< ::java::lang::String * > * known_image_types;
+ static ::java::util::HashSet * imageTypes;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_DefaultContentHandlerFactory__
diff --git a/libjava/gnu/java/net/DefaultProxySelector.h b/libjava/gnu/java/net/DefaultProxySelector.h
new file mode 100644
index 000000000..11a4fce09
--- /dev/null
+++ b/libjava/gnu/java/net/DefaultProxySelector.h
@@ -0,0 +1,45 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_DefaultProxySelector__
+#define __gnu_java_net_DefaultProxySelector__
+
+#pragma interface
+
+#include <java/net/ProxySelector.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class DefaultProxySelector;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class SocketAddress;
+ class URI;
+ }
+ }
+}
+
+class gnu::java::net::DefaultProxySelector : public ::java::net::ProxySelector
+{
+
+public:
+ DefaultProxySelector();
+ void connectFailed(::java::net::URI *, ::java::net::SocketAddress *, ::java::io::IOException *);
+ ::java::util::List * select(::java::net::URI *);
+private:
+ static ::java::util::List * proxies;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_DefaultProxySelector__
diff --git a/libjava/gnu/java/net/EmptyX509TrustManager.h b/libjava/gnu/java/net/EmptyX509TrustManager.h
new file mode 100644
index 000000000..df08b8197
--- /dev/null
+++ b/libjava/gnu/java/net/EmptyX509TrustManager.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_EmptyX509TrustManager__
+#define __gnu_java_net_EmptyX509TrustManager__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class EmptyX509TrustManager;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace security
+ {
+ namespace cert
+ {
+ class X509Certificate;
+ }
+ }
+ }
+}
+
+class gnu::java::net::EmptyX509TrustManager : public ::java::lang::Object
+{
+
+public:
+ EmptyX509TrustManager();
+ virtual void checkClientTrusted(JArray< ::java::security::cert::X509Certificate * > *, ::java::lang::String *);
+ virtual void checkServerTrusted(JArray< ::java::security::cert::X509Certificate * > *, ::java::lang::String *);
+ virtual JArray< ::java::security::cert::X509Certificate * > * getAcceptedIssuers();
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_EmptyX509TrustManager__
diff --git a/libjava/gnu/java/net/GetLocalHostAction.h b/libjava/gnu/java/net/GetLocalHostAction.h
new file mode 100644
index 000000000..f0d088064
--- /dev/null
+++ b/libjava/gnu/java/net/GetLocalHostAction.h
@@ -0,0 +1,41 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_GetLocalHostAction__
+#define __gnu_java_net_GetLocalHostAction__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class GetLocalHostAction;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ }
+ }
+}
+
+class gnu::java::net::GetLocalHostAction : public ::java::lang::Object
+{
+
+public:
+ GetLocalHostAction();
+ virtual ::java::net::InetAddress * GetLocalHostAction$run();
+ virtual ::java::lang::Object * run();
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_GetLocalHostAction__
diff --git a/libjava/gnu/java/net/HeaderFieldHelper.h b/libjava/gnu/java/net/HeaderFieldHelper.h
new file mode 100644
index 000000000..ace66785d
--- /dev/null
+++ b/libjava/gnu/java/net/HeaderFieldHelper.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_HeaderFieldHelper__
+#define __gnu_java_net_HeaderFieldHelper__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class HeaderFieldHelper;
+ }
+ }
+ }
+}
+
+class gnu::java::net::HeaderFieldHelper : public ::java::lang::Object
+{
+
+public:
+ HeaderFieldHelper();
+ HeaderFieldHelper(jint);
+ virtual void addHeaderField(::java::lang::String *, ::java::lang::String *);
+ virtual ::java::lang::String * getHeaderFieldKeyByIndex(jint);
+ virtual ::java::lang::String * getHeaderFieldValueByIndex(jint);
+ virtual ::java::lang::String * getHeaderFieldValueByKey(::java::lang::String *);
+ virtual ::java::util::Map * getHeaderFields();
+ virtual jint getNumberOfEntries();
+private:
+ ::java::util::Vector * __attribute__((aligned(__alignof__( ::java::lang::Object)))) headerFieldKeys;
+ ::java::util::Vector * headerFieldValues;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_HeaderFieldHelper__
diff --git a/libjava/gnu/java/net/ImageHandler.h b/libjava/gnu/java/net/ImageHandler.h
new file mode 100644
index 000000000..41aba924a
--- /dev/null
+++ b/libjava/gnu/java/net/ImageHandler.h
@@ -0,0 +1,44 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_ImageHandler__
+#define __gnu_java_net_ImageHandler__
+
+#pragma interface
+
+#include <java/net/ContentHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class ImageHandler;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::ImageHandler : public ::java::net::ContentHandler
+{
+
+public: // actually package-private
+ ImageHandler();
+public:
+ virtual ::java::lang::Object * getContent(::java::net::URLConnection *);
+public: // actually package-private
+ static ::gnu::java::net::ImageHandler * instance;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_ImageHandler__
diff --git a/libjava/gnu/java/net/IndexListParser.h b/libjava/gnu/java/net/IndexListParser.h
new file mode 100644
index 000000000..2bbeec1b3
--- /dev/null
+++ b/libjava/gnu/java/net/IndexListParser.h
@@ -0,0 +1,51 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_IndexListParser__
+#define __gnu_java_net_IndexListParser__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class IndexListParser;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::IndexListParser : public ::java::lang::Object
+{
+
+public:
+ IndexListParser(::java::util::jar::JarFile *, ::java::net::URL *, ::java::net::URL *);
+public: // actually package-private
+ virtual void clearAll();
+public:
+ virtual ::java::lang::String * getVersionInfo();
+ virtual jdouble getVersionNumber();
+ virtual ::java::util::LinkedHashMap * getHeaders();
+ static ::java::lang::String * JAR_INDEX_FILE;
+ static ::java::lang::String * JAR_INDEX_VERSION_KEY;
+public: // actually package-private
+ jdouble __attribute__((aligned(__alignof__( ::java::lang::Object)))) versionNumber;
+ ::java::util::LinkedHashMap * prefixes;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_IndexListParser__
diff --git a/libjava/gnu/java/net/LineInputStream.h b/libjava/gnu/java/net/LineInputStream.h
new file mode 100644
index 000000000..194847efc
--- /dev/null
+++ b/libjava/gnu/java/net/LineInputStream.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_LineInputStream__
+#define __gnu_java_net_LineInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class LineInputStream;
+ }
+ }
+ }
+}
+
+class gnu::java::net::LineInputStream : public ::java::io::InputStream
+{
+
+public:
+ LineInputStream(::java::io::InputStream *);
+ LineInputStream(::java::io::InputStream *, ::java::lang::String *);
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual ::java::lang::String * readLine();
+private:
+ jint indexOf(JArray< jbyte > *, jint, jbyte);
+public: // actually protected
+ ::java::io::InputStream * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) in;
+private:
+ ::java::io::ByteArrayOutputStream * buf;
+ ::java::lang::String * encoding;
+ jboolean eof;
+ jboolean blockReads;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_LineInputStream__
diff --git a/libjava/gnu/java/net/PlainDatagramSocketImpl.h b/libjava/gnu/java/net/PlainDatagramSocketImpl.h
new file mode 100644
index 000000000..c57296faf
--- /dev/null
+++ b/libjava/gnu/java/net/PlainDatagramSocketImpl.h
@@ -0,0 +1,93 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_PlainDatagramSocketImpl__
+#define __gnu_java_net_PlainDatagramSocketImpl__
+
+#pragma interface
+
+#include <java/net/DatagramSocketImpl.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class PlainDatagramSocketImpl;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class DatagramPacket;
+ class InetAddress;
+ class NetworkInterface;
+ class SocketAddress;
+ }
+ }
+}
+
+class gnu::java::net::PlainDatagramSocketImpl : public ::java::net::DatagramSocketImpl
+{
+
+public:
+ PlainDatagramSocketImpl();
+public: // actually protected
+ void finalize();
+public:
+ jint getNativeFD();
+public: // actually protected
+ void bind(jint, ::java::net::InetAddress *);
+ void connect(::java::net::InetAddress *, jint);
+ void disconnect();
+ void create();
+ jint peek(::java::net::InetAddress *);
+ jint peekData(::java::net::DatagramPacket *);
+ void setTimeToLive(jint);
+ jint getTimeToLive();
+ void send(::java::net::DatagramPacket *);
+ void receive(::java::net::DatagramPacket *);
+public:
+ void setOption(jint, ::java::lang::Object *);
+ ::java::lang::Object * getOption(jint);
+private:
+ void mcastGrp(::java::net::InetAddress *, ::java::net::NetworkInterface *, jboolean);
+public: // actually protected
+ void close();
+ jbyte getTTL();
+ void setTTL(jbyte);
+ void join(::java::net::InetAddress *);
+ void leave(::java::net::InetAddress *);
+ void joinGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *);
+ void leaveGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *);
+public: // actually package-private
+ static const jint _Jv_TCP_NODELAY_ = 1;
+ static const jint _Jv_SO_BINDADDR_ = 15;
+ static const jint _Jv_SO_REUSEADDR_ = 4;
+ static const jint _Jv_SO_BROADCAST_ = 32;
+ static const jint _Jv_SO_OOBINLINE_ = 4099;
+ static const jint _Jv_IP_MULTICAST_IF_ = 16;
+ static const jint _Jv_IP_MULTICAST_IF2_ = 31;
+ static const jint _Jv_IP_MULTICAST_LOOP_ = 18;
+ static const jint _Jv_IP_TOS_ = 3;
+ static const jint _Jv_SO_LINGER_ = 128;
+ static const jint _Jv_SO_TIMEOUT_ = 4102;
+ static const jint _Jv_SO_SNDBUF_ = 4097;
+ static const jint _Jv_SO_RCVBUF_ = 4098;
+ static const jint _Jv_SO_KEEPALIVE_ = 8;
+ jint __attribute__((aligned(__alignof__( ::java::net::DatagramSocketImpl)))) native_fd;
+private:
+ ::java::lang::Object * RECEIVE_LOCK;
+ ::java::lang::Object * SEND_LOCK;
+public: // actually package-private
+ ::java::net::InetAddress * localAddress;
+ jint timeout;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_PlainDatagramSocketImpl__
diff --git a/libjava/gnu/java/net/PlainDatagramSocketImpl.java b/libjava/gnu/java/net/PlainDatagramSocketImpl.java
new file mode 100644
index 000000000..08c1cb3f6
--- /dev/null
+++ b/libjava/gnu/java/net/PlainDatagramSocketImpl.java
@@ -0,0 +1,310 @@
+/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocketImpl;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketOptions;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This is the default socket implementation for datagram sockets.
+ * It makes native calls to C routines that implement BSD style
+ * SOCK_DGRAM sockets in the AF_INET family.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
+ */
+public final class PlainDatagramSocketImpl extends DatagramSocketImpl
+{
+ // Static initializer to load native library
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javanet");
+ }
+ }
+
+ // These fields are mirrored for use in native code to avoid cpp conflicts
+ // when the #defines in system header files are the same as the public fields.
+ static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
+ _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
+ _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
+ _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
+ _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
+ _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
+ _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
+ _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
+ _Jv_IP_TOS_ = SocketOptions.IP_TOS,
+ _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
+ _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
+ _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
+ _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
+ _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
+
+ /**
+ * This is the actual underlying file descriptor
+ */
+ int native_fd = -1;
+
+ /**
+ * Lock object to serialize threads wanting to receive
+ */
+ private final Object RECEIVE_LOCK = new Object();
+
+ /**
+ * Lock object to serialize threads wanting to send
+ */
+ private final Object SEND_LOCK = new Object();
+
+ // FIXME: Is this necessary? Could it help w/ DatagramSocket.getLocalAddress?
+ // InetAddress address;
+
+ // localAddress cache
+ InetAddress localAddress;
+
+ // 'timeout' is set/read by setOption/getOption.
+ int timeout = 0;
+
+ /**
+ * Default do nothing constructor
+ */
+ public PlainDatagramSocketImpl() throws IOException
+ {
+ }
+
+ protected void finalize() throws Throwable
+ {
+ synchronized (this)
+ {
+ if (native_fd != -1)
+ close();
+ }
+ super.finalize();
+ }
+
+ public int getNativeFD()
+ {
+ return native_fd;
+ }
+
+ /**
+ * Binds this socket to a particular port and interface
+ *
+ * @param port The port to bind to
+ * @param addr The address to bind to
+ *
+ * @exception SocketException If an error occurs
+ */
+ protected native void bind(int port, InetAddress addr)
+ throws SocketException;
+
+ protected native void connect(InetAddress addr, int port)
+ throws SocketException;
+
+ protected native void disconnect();
+
+ /**
+ * Creates a new datagram socket
+ *
+ * @exception SocketException If an error occurs
+ */
+ protected native void create() throws SocketException;
+
+ protected native int peek(InetAddress addr) throws IOException;
+
+ protected native int peekData(DatagramPacket packet) throws IOException;
+
+ /**
+ * Sets the Time to Live value for the socket
+ *
+ * @param ttl The new TTL value
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void setTimeToLive(int ttl) throws IOException;
+
+ /**
+ * Gets the Time to Live value for the socket
+ *
+ * @return The TTL value
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native int getTimeToLive() throws IOException;
+
+ /**
+ * Sends a packet of data to a remote host
+ *
+ * @param packet The packet to send
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void send(DatagramPacket packet) throws IOException;
+
+ /**
+ * Receives a UDP packet from the network
+ *
+ * @param packet The packet to fill in with the data received
+ *
+ * @exception IOException IOException If an error occurs
+ */
+ protected native void receive(DatagramPacket packet) throws IOException;
+
+ /**
+ * Sets the value of an option on the socket
+ *
+ * @param option_id The identifier of the option to set
+ * @param val The value of the option to set
+ *
+ * @exception SocketException If an error occurs
+ */
+ public native void setOption(int option_id, Object val)
+ throws SocketException;
+
+ /**
+ * Retrieves the value of an option on the socket
+ *
+ * @param option_id The identifier of the option to retrieve
+ *
+ * @return The value of the option
+ *
+ * @exception SocketException If an error occurs
+ */
+ public native Object getOption(int option_id)
+ throws SocketException;
+
+ /**
+ * Joins or leaves a broadcasting group on a given network interface.
+ * If the network interface is <code>null</code> the group is join/left on
+ * all locale network interfaces.
+ *
+ * @param inetAddr The broadcast address.
+ * @param netIf The network interface to join the group on.
+ * @param join True to join a broadcasting group, fals to leave it.
+ *
+ * @exception IOException If an error occurs.
+ */
+ private native void mcastGrp(InetAddress inetAddr, NetworkInterface netIf,
+ boolean join)
+ throws IOException;
+
+ /**
+ * Closes the socket
+ */
+ protected native void close();
+
+ /**
+ * Gets the Time to Live value for the socket
+ *
+ * @return The TTL value
+ *
+ * @exception IOException If an error occurs
+ *
+ * @deprecated 1.2
+ */
+ protected byte getTTL() throws IOException
+ {
+ return (byte) getTimeToLive();
+ }
+
+ /**
+ * Sets the Time to Live value for the socket
+ *
+ * @param ttl The new TTL value
+ *
+ * @exception IOException If an error occurs
+ *
+ * @deprecated 1.2
+ */
+ protected void setTTL(byte ttl) throws IOException
+ {
+ setTimeToLive(((int) ttl) & 0xFF);
+ }
+
+ /**
+ * Joins a multicast group
+ *
+ * @param addr The group to join
+ *
+ * @exception IOException If an error occurs
+ */
+ protected void join(InetAddress addr) throws IOException
+ {
+ mcastGrp(addr, null, true);
+ }
+
+ /**
+ * Leaves a multicast group
+ *
+ * @param addr The group to leave
+ *
+ * @exception IOException If an error occurs
+ */
+ protected void leave(InetAddress addr) throws IOException
+ {
+ mcastGrp(addr, null, false);
+ }
+
+ protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
+ throws IOException
+ {
+ mcastGrp(((InetSocketAddress) mcastaddr).getAddress(), netIf, true);
+ }
+
+ protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
+ throws IOException
+ {
+ mcastGrp(((InetSocketAddress) mcastaddr).getAddress(), netIf, false);
+ }
+}
diff --git a/libjava/gnu/java/net/PlainSocketImpl$SocketInputStream.h b/libjava/gnu/java/net/PlainSocketImpl$SocketInputStream.h
new file mode 100644
index 000000000..83ac40cf5
--- /dev/null
+++ b/libjava/gnu/java/net/PlainSocketImpl$SocketInputStream.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_PlainSocketImpl$SocketInputStream__
+#define __gnu_java_net_PlainSocketImpl$SocketInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class PlainSocketImpl;
+ class PlainSocketImpl$SocketInputStream;
+ }
+ }
+ }
+}
+
+class gnu::java::net::PlainSocketImpl$SocketInputStream : public ::java::io::InputStream
+{
+
+public: // actually package-private
+ PlainSocketImpl$SocketInputStream(::gnu::java::net::PlainSocketImpl *);
+public:
+ jint available();
+ void close();
+ jint read();
+ jint read(JArray< jbyte > *, jint, jint);
+public: // actually package-private
+ ::gnu::java::net::PlainSocketImpl * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_PlainSocketImpl$SocketInputStream__
diff --git a/libjava/gnu/java/net/PlainSocketImpl$SocketOutputStream.h b/libjava/gnu/java/net/PlainSocketImpl$SocketOutputStream.h
new file mode 100644
index 000000000..852e894f2
--- /dev/null
+++ b/libjava/gnu/java/net/PlainSocketImpl$SocketOutputStream.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_PlainSocketImpl$SocketOutputStream__
+#define __gnu_java_net_PlainSocketImpl$SocketOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class PlainSocketImpl;
+ class PlainSocketImpl$SocketOutputStream;
+ }
+ }
+ }
+}
+
+class gnu::java::net::PlainSocketImpl$SocketOutputStream : public ::java::io::OutputStream
+{
+
+public: // actually package-private
+ PlainSocketImpl$SocketOutputStream(::gnu::java::net::PlainSocketImpl *);
+public:
+ void close();
+ void write(jint);
+ void write(JArray< jbyte > *, jint, jint);
+public: // actually package-private
+ ::gnu::java::net::PlainSocketImpl * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_PlainSocketImpl$SocketOutputStream__
diff --git a/libjava/gnu/java/net/PlainSocketImpl.h b/libjava/gnu/java/net/PlainSocketImpl.h
new file mode 100644
index 000000000..d907871df
--- /dev/null
+++ b/libjava/gnu/java/net/PlainSocketImpl.h
@@ -0,0 +1,95 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_PlainSocketImpl__
+#define __gnu_java_net_PlainSocketImpl__
+
+#pragma interface
+
+#include <java/net/SocketImpl.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class PlainSocketImpl;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class InetSocketAddress;
+ class SocketAddress;
+ class SocketImpl;
+ }
+ }
+}
+
+class gnu::java::net::PlainSocketImpl : public ::java::net::SocketImpl
+{
+
+public:
+ jboolean isInChannelOperation();
+ void setInChannelOperation(jboolean);
+ PlainSocketImpl();
+public: // actually protected
+ void finalize();
+public:
+ jint getNativeFD();
+ void setOption(jint, ::java::lang::Object *);
+ ::java::lang::Object * getOption(jint);
+ void shutdownInput();
+ void shutdownOutput();
+ void create(jboolean);
+public: // actually protected
+ void connect(::java::lang::String *, jint);
+ void connect(::java::net::InetAddress *, jint);
+ void connect(::java::net::SocketAddress *, jint);
+ void bind(::java::net::InetAddress *, jint);
+ void listen(jint);
+ void accept(::java::net::SocketImpl *);
+private:
+ void accept(::gnu::java::net::PlainSocketImpl *);
+public: // actually protected
+ jint available();
+ void close();
+ void sendUrgentData(jint);
+public:
+ ::java::net::InetSocketAddress * getLocalAddress();
+public: // actually protected
+ ::java::io::InputStream * getInputStream();
+ ::java::io::OutputStream * getOutputStream();
+public: // actually package-private
+ static const jint _Jv_TCP_NODELAY_ = 1;
+ static const jint _Jv_SO_BINDADDR_ = 15;
+ static const jint _Jv_SO_REUSEADDR_ = 4;
+ static const jint _Jv_SO_BROADCAST_ = 32;
+ static const jint _Jv_SO_OOBINLINE_ = 4099;
+ static const jint _Jv_IP_MULTICAST_IF_ = 16;
+ static const jint _Jv_IP_MULTICAST_IF2_ = 31;
+ static const jint _Jv_IP_MULTICAST_LOOP_ = 18;
+ static const jint _Jv_IP_TOS_ = 3;
+ static const jint _Jv_SO_LINGER_ = 128;
+ static const jint _Jv_SO_TIMEOUT_ = 4102;
+ static const jint _Jv_SO_SNDBUF_ = 4097;
+ static const jint _Jv_SO_RCVBUF_ = 4098;
+ static const jint _Jv_SO_KEEPALIVE_ = 8;
+ jint __attribute__((aligned(__alignof__( ::java::net::SocketImpl)))) native_fd;
+ jint timeout;
+ ::java::net::InetAddress * localAddress;
+ ::java::net::InetSocketAddress * localSocketAddress;
+private:
+ ::java::io::InputStream * in;
+ ::java::io::OutputStream * out;
+ jboolean inChannelOperation;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_PlainSocketImpl__
diff --git a/libjava/gnu/java/net/PlainSocketImpl.java b/libjava/gnu/java/net/PlainSocketImpl.java
new file mode 100644
index 000000000..d2c8f02b6
--- /dev/null
+++ b/libjava/gnu/java/net/PlainSocketImpl.java
@@ -0,0 +1,478 @@
+/* PlainSocketImpl.java -- Default socket implementation
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.net.SocketOptions;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * Unless the application installs its own SocketImplFactory, this is the
+ * default socket implemetation that will be used. It simply uses a
+ * combination of Java and native routines to implement standard BSD
+ * style sockets of family AF_INET and types SOCK_STREAM and SOCK_DGRAM
+ *
+ * @author Per Bothner (bothner@cygnus.com)
+ * @author Nic Ferrier (nferrier@tapsellferrier.co.uk)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public final class PlainSocketImpl extends SocketImpl
+{
+ // Static initializer to load native library.
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javanet");
+ }
+ }
+
+ // These fields are mirrored for use in native code to avoid cpp conflicts
+ // when the #defines in system header files are the same as the public fields.
+ static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
+ _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
+ _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
+ _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
+ _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
+ _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
+ _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
+ _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
+ _Jv_IP_TOS_ = SocketOptions.IP_TOS,
+ _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
+ _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
+ _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
+ _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
+ _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
+
+ /**
+ * The OS file handle representing the socket.
+ * This is used for reads and writes to/from the socket and
+ * to close it.
+ *
+ * When the socket is closed this is reset to -1.
+ */
+ int native_fd = -1;
+
+ // This value is set/read by setOption/getOption.
+ int timeout = 0;
+
+ // localAddress cache
+ InetAddress localAddress;
+
+ // Local address as an InetSocketAddress.
+ InetSocketAddress localSocketAddress;
+
+ /**
+ * A cached copy of the in stream for reading from the socket.
+ */
+ private InputStream in;
+
+ /**
+ * A cached copy of the out stream for writing to the socket.
+ */
+ private OutputStream out;
+
+ /**
+ * Indicates whether a channel initiated whatever operation
+ * is being invoked on this socket.
+ */
+ private boolean inChannelOperation;
+
+ /**
+ * Indicates whether we should ignore whether any associated
+ * channel is set to non-blocking mode. Certain operations
+ * throw an <code>IllegalBlockingModeException</code> if the
+ * associated channel is in non-blocking mode, <i>except</i>
+ * if the operation is invoked by the channel itself.
+ */
+ public final boolean isInChannelOperation()
+ {
+ return inChannelOperation;
+ }
+
+ /**
+ * Sets our indicator of whether an I/O operation is being
+ * initiated by a channel.
+ */
+ public final void setInChannelOperation(boolean b)
+ {
+ inChannelOperation = b;
+ }
+
+ /**
+ * Default do nothing constructor
+ */
+ public PlainSocketImpl()
+ {
+ }
+
+ protected void finalize() throws Throwable
+ {
+ synchronized (this)
+ {
+ if (native_fd != -1)
+ try
+ {
+ close();
+ }
+ catch (IOException ex)
+ {
+ }
+ }
+ super.finalize();
+ }
+
+ public int getNativeFD()
+ {
+ return native_fd;
+ }
+
+ /**
+ * Sets the specified option on a socket to the passed in object. For
+ * options that take an integer argument, the passed in object is an
+ * Integer. The option_id parameter is one of the defined constants in
+ * this interface.
+ *
+ * @param option_id The identifier of the option
+ * @param val The value to set the option to
+ *
+ * @exception SocketException If an error occurs
+ */
+ public native void setOption(int optID, Object value) throws SocketException;
+
+ /**
+ * Returns the current setting of the specified option. The Object returned
+ * will be an Integer for options that have integer values. The option_id
+ * is one of the defined constants in this interface.
+ *
+ * @param option_id The option identifier
+ *
+ * @return The current value of the option
+ *
+ * @exception SocketException If an error occurs
+ */
+ public native Object getOption(int optID) throws SocketException;
+
+ /**
+ * Flushes the input stream and closes it. If you read from the input stream
+ * after calling this method a <code>IOException</code> will be thrown.
+ *
+ * @throws IOException if an error occurs
+ */
+ public native void shutdownInput() throws IOException;
+
+ /**
+ * Flushes the output stream and closes it. If you write to the output stream
+ * after calling this method a <code>IOException</code> will be thrown.
+ *
+ * @throws IOException if an error occurs
+ */
+ public native void shutdownOutput() throws IOException;
+
+ /**
+ * Creates a new socket that is not bound to any local address/port and
+ * is not connected to any remote address/port. This will be created as
+ * a stream socket if the stream parameter is true, or a datagram socket
+ * if the stream parameter is false.
+ *
+ * @param stream true for a stream socket, false for a datagram socket
+ */
+ // FIXME: this is public for nio ... but this is just a hack
+ // until we upgrade to Classpath's nio.
+ public native void create(boolean stream) throws IOException;
+
+ /**
+ * Connects to the remote hostname and port specified as arguments.
+ *
+ * @param hostname The remote hostname to connect to
+ * @param port The remote port to connect to
+ *
+ * @exception IOException If an error occurs
+ */
+ protected void connect(String host, int port) throws IOException
+ {
+ connect(InetAddress.getByName(host), port);
+ }
+
+ /**
+ * Connects to the remote address and port specified as arguments.
+ *
+ * @param addr The remote address to connect to
+ * @param port The remote port to connect to
+ *
+ * @exception IOException If an error occurs
+ */
+ protected void connect(InetAddress host, int port) throws IOException
+ {
+ connect (new InetSocketAddress (host, port), 0);
+ }
+
+ /**
+ * Connects to the remote socket address with a specified timeout.
+ *
+ * @param timeout The timeout to use for this connect, 0 means infinite.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void connect(SocketAddress addr, int timeout) throws IOException;
+
+ /**
+ * Binds to the specified port on the specified addr. Note that this addr
+ * must represent a local IP address. **** How bind to INADDR_ANY? ****
+ *
+ * @param addr The address to bind to
+ * @param port The port number to bind to
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void bind(InetAddress host, int port)
+ throws IOException;
+
+ /**
+ * Starts listening for connections on a socket. The queuelen parameter
+ * is how many pending connections will queue up waiting to be serviced
+ * before being accept'ed. If the queue of pending requests exceeds this
+ * number, additional connections will be refused.
+ *
+ * @param queuelen The length of the pending connection queue
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void listen(int queuelen)
+ throws IOException;
+
+ /**
+ * Accepts a new connection on this socket and returns in in the
+ * passed in SocketImpl.
+ *
+ * @param impl The SocketImpl object to accept this connection.
+ */
+ protected void accept(SocketImpl impl)
+ throws IOException
+ {
+ accept((PlainSocketImpl) impl);
+ }
+
+ private native void accept(PlainSocketImpl impl)
+ throws IOException;
+
+ /**
+ * Returns the number of bytes that the caller can read from this socket
+ * without blocking.
+ *
+ * @return The number of readable bytes before blocking
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native int available() throws IOException;
+
+ /**
+ * Closes the socket. This will cause any InputStream or OutputStream
+ * objects for this Socket to be closed as well.
+ * <p>
+ * Note that if the SO_LINGER option is set on this socket, then the
+ * operation could block.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected native void close() throws IOException;
+
+ protected native void sendUrgentData(int data) throws IOException;
+
+ public synchronized InetSocketAddress getLocalAddress()
+ {
+ if (localSocketAddress == null)
+ {
+ try
+ {
+ localSocketAddress
+ = new InetSocketAddress ((InetAddress) getOption(SocketOptions.SO_BINDADDR),
+ localport == -1 ? 0 : localport);
+ }
+ catch (SocketException _)
+ {
+ return null;
+ }
+ }
+ return localSocketAddress;
+ }
+
+ /**
+ * Returns an InputStream object for reading from this socket. This will
+ * be an instance of SocketInputStream.
+ *
+ * @return An input stream attached to the socket.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized InputStream getInputStream() throws IOException
+ {
+ if (in == null)
+ in = new SocketInputStream();
+
+ return in;
+ }
+
+ /**
+ * Returns an OutputStream object for writing to this socket. This will
+ * be an instance of SocketOutputStream.
+ *
+ * @return An output stream attached to the socket.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized OutputStream getOutputStream() throws IOException
+ {
+ if (out == null)
+ out = new SocketOutputStream();
+
+ return out;
+ }
+
+ /**
+ * This class contains an implementation of <code>InputStream</code> for
+ * sockets. It in an internal only class used by <code>PlainSocketImpl</code>.
+ *
+ * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
+ */
+ final class SocketInputStream
+ extends InputStream
+ {
+ /**
+ * Returns the number of bytes available to be read before blocking
+ */
+ public int available() throws IOException
+ {
+ return PlainSocketImpl.this.available();
+ }
+
+ /**
+ * 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
+ {
+ PlainSocketImpl.this.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 native int read() throws IOException;
+
+ /**
+ * Reads up to len bytes of data into the caller supplied buffer starting
+ * at offset bytes from the start of the buffer
+ *
+ * @param buf The buffer
+ * @param offset Offset into the buffer to start reading from
+ * @param len The number of bytes to read
+ *
+ * @return The number of bytes actually read or -1 if end of stream
+ *
+ * @exception IOException If an error occurs.
+ */
+ public native int read(byte[] buf, int offset, int len) throws IOException;
+ }
+
+ /**
+ * 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.
+ *
+ * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
+ */
+ final class SocketOutputStream
+ extends OutputStream
+ {
+ /**
+ * 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
+ {
+ PlainSocketImpl.this.close();
+ }
+
+ /**
+ * 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 native void write(int b) throws IOException;
+
+ /**
+ * 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
+ *
+ * @exception IOException If an error occurs.
+ */
+ public native void write(byte[] buf, int offset, int len) throws IOException;
+ }
+}
diff --git a/libjava/gnu/java/net/URLParseError.h b/libjava/gnu/java/net/URLParseError.h
new file mode 100644
index 000000000..c900dc000
--- /dev/null
+++ b/libjava/gnu/java/net/URLParseError.h
@@ -0,0 +1,32 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_URLParseError__
+#define __gnu_java_net_URLParseError__
+
+#pragma interface
+
+#include <java/lang/Error.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class URLParseError;
+ }
+ }
+ }
+}
+
+class gnu::java::net::URLParseError : public ::java::lang::Error
+{
+
+public:
+ URLParseError(::java::lang::String *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_URLParseError__
diff --git a/libjava/gnu/java/net/loader/FileResource.h b/libjava/gnu/java/net/loader/FileResource.h
new file mode 100644
index 000000000..37f1d12ca
--- /dev/null
+++ b/libjava/gnu/java/net/loader/FileResource.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_FileResource__
+#define __gnu_java_net_loader_FileResource__
+
+#pragma interface
+
+#include <gnu/java/net/loader/Resource.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class FileResource;
+ class FileURLLoader;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::loader::FileResource : public ::gnu::java::net::loader::Resource
+{
+
+public:
+ FileResource(::gnu::java::net::loader::FileURLLoader *, ::java::io::File *);
+ ::java::io::InputStream * getInputStream();
+ jint getLength();
+ ::java::net::URL * getURL();
+public: // actually package-private
+ ::java::io::File * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::Resource)))) file;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_FileResource__
diff --git a/libjava/gnu/java/net/loader/FileURLLoader.h b/libjava/gnu/java/net/loader/FileURLLoader.h
new file mode 100644
index 000000000..4592f7f9a
--- /dev/null
+++ b/libjava/gnu/java/net/loader/FileURLLoader.h
@@ -0,0 +1,52 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_FileURLLoader__
+#define __gnu_java_net_loader_FileURLLoader__
+
+#pragma interface
+
+#include <gnu/java/net/loader/URLLoader.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class FileURLLoader;
+ class Resource;
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLClassLoader;
+ class URLStreamHandlerFactory;
+ }
+ }
+}
+
+class gnu::java::net::loader::FileURLLoader : public ::gnu::java::net::loader::URLLoader
+{
+
+public:
+ FileURLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *, ::java::net::URL *);
+ ::gnu::java::net::loader::Resource * getResource(::java::lang::String *);
+private:
+ ::java::io::File * walkPathComponents(::java::lang::String *);
+public: // actually package-private
+ ::java::io::File * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::URLLoader)))) dir;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_FileURLLoader__
diff --git a/libjava/gnu/java/net/loader/JarURLLoader.h b/libjava/gnu/java/net/loader/JarURLLoader.h
new file mode 100644
index 000000000..68114ab36
--- /dev/null
+++ b/libjava/gnu/java/net/loader/JarURLLoader.h
@@ -0,0 +1,60 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_JarURLLoader__
+#define __gnu_java_net_loader_JarURLLoader__
+
+#pragma interface
+
+#include <gnu/java/net/loader/URLLoader.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class JarURLLoader;
+ class Resource;
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLClassLoader;
+ class URLStreamHandlerFactory;
+ }
+ }
+}
+
+class gnu::java::net::loader::JarURLLoader : public ::gnu::java::net::loader::URLLoader
+{
+
+ JarURLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *, ::java::net::URL *, ::java::util::Set *);
+public:
+ JarURLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *, ::java::net::URL *);
+private:
+ void initialize();
+public:
+ ::gnu::java::net::loader::Resource * getResource(::java::lang::String *);
+ ::java::util::jar::Manifest * getManifest();
+ ::java::util::ArrayList * getClassPath();
+public: // actually package-private
+ jboolean __attribute__((aligned(__alignof__( ::gnu::java::net::loader::URLLoader)))) initialized;
+ ::java::util::jar::JarFile * jarfile;
+ ::java::net::URL * baseJarURL;
+ ::java::util::ArrayList * classPath;
+ ::java::util::Set * indexSet;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_JarURLLoader__
diff --git a/libjava/gnu/java/net/loader/JarURLResource.h b/libjava/gnu/java/net/loader/JarURLResource.h
new file mode 100644
index 000000000..e9fe6a638
--- /dev/null
+++ b/libjava/gnu/java/net/loader/JarURLResource.h
@@ -0,0 +1,60 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_JarURLResource__
+#define __gnu_java_net_loader_JarURLResource__
+
+#pragma interface
+
+#include <gnu/java/net/loader/Resource.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class JarURLLoader;
+ class JarURLResource;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ namespace security
+ {
+ namespace cert
+ {
+ class Certificate;
+ }
+ }
+ }
+}
+
+class gnu::java::net::loader::JarURLResource : public ::gnu::java::net::loader::Resource
+{
+
+public:
+ JarURLResource(::gnu::java::net::loader::JarURLLoader *, ::java::lang::String *, ::java::util::jar::JarEntry *);
+ ::java::io::InputStream * getInputStream();
+ jint getLength();
+ JArray< ::java::security::cert::Certificate * > * getCertificates();
+ ::java::net::URL * getURL();
+private:
+ ::java::util::jar::JarEntry * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::Resource)))) entry;
+ ::java::lang::String * name;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_JarURLResource__
diff --git a/libjava/gnu/java/net/loader/Load_gcjlib$SoResource.h b/libjava/gnu/java/net/loader/Load_gcjlib$SoResource.h
new file mode 100644
index 000000000..da8a2aca1
--- /dev/null
+++ b/libjava/gnu/java/net/loader/Load_gcjlib$SoResource.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_Load_gcjlib$SoResource__
+#define __gnu_java_net_loader_Load_gcjlib$SoResource__
+
+#pragma interface
+
+#include <gnu/java/net/loader/Resource.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class Load_gcjlib;
+ class Load_gcjlib$SoResource;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::loader::Load_gcjlib$SoResource : public ::gnu::java::net::loader::Resource
+{
+
+public: // actually package-private
+ Load_gcjlib$SoResource(::gnu::java::net::loader::Load_gcjlib *, ::java::net::URL *);
+public:
+ ::java::io::InputStream * getInputStream();
+ jint getLength();
+ ::java::net::URL * getURL();
+private:
+ ::java::net::URL * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::Resource)))) url;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_Load_gcjlib$SoResource__
diff --git a/libjava/gnu/java/net/loader/Load_gcjlib.h b/libjava/gnu/java/net/loader/Load_gcjlib.h
new file mode 100644
index 000000000..69d2ef5ac
--- /dev/null
+++ b/libjava/gnu/java/net/loader/Load_gcjlib.h
@@ -0,0 +1,58 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_Load_gcjlib__
+#define __gnu_java_net_loader_Load_gcjlib__
+
+#pragma interface
+
+#include <gnu/java/net/loader/URLLoader.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ namespace runtime
+ {
+ class SharedLibHelper;
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class Load_gcjlib;
+ class Resource;
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLClassLoader;
+ class URLStreamHandlerFactory;
+ }
+ }
+}
+
+class gnu::java::net::loader::Load_gcjlib : public ::gnu::java::net::loader::URLLoader
+{
+
+public:
+ Load_gcjlib(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *, ::java::net::URL *);
+ ::java::lang::Class * getClass(::java::lang::String *);
+ ::gnu::java::net::loader::Resource * getResource(::java::lang::String *);
+private:
+ ::gnu::gcj::runtime::SharedLibHelper * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::URLLoader)))) helper;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_Load_gcjlib__
diff --git a/libjava/gnu/java/net/loader/Load_gcjlib.java b/libjava/gnu/java/net/loader/Load_gcjlib.java
new file mode 100644
index 000000000..ea392041f
--- /dev/null
+++ b/libjava/gnu/java/net/loader/Load_gcjlib.java
@@ -0,0 +1,77 @@
+/* Copyright (C) 2007 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.loader;
+
+import gnu.gcj.runtime.SharedLibHelper;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * A <code>Load_gcjlib</code> is a type of <code>URLLoader</code>
+ * that loads classes and resources from a shared library.
+ */
+public final class Load_gcjlib extends URLLoader
+{
+ private SharedLibHelper helper;
+
+ public Load_gcjlib(URLClassLoader classloader,
+ URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL url, URL absoluteUrl)
+ {
+ super(classloader, cache, factory, url, absoluteUrl);
+ helper = SharedLibHelper.findHelper(classloader, url.getFile(),
+ noCertCodeSource, true);
+ }
+
+ public Class getClass(String className)
+ {
+ return helper.findClass(className);
+ }
+
+ public Resource getResource(String name)
+ {
+ URL url = helper.findResource(name);
+ if (url == null)
+ return null;
+ return new SoResource(this, url);
+ }
+
+ final static class SoResource extends Resource
+ {
+ private final URL url;
+
+ SoResource(Load_gcjlib loader, URL url)
+ {
+ super(loader);
+ this.url = url;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ URLConnection conn = url.openConnection();
+ return conn.getInputStream();
+ }
+
+ public int getLength()
+ {
+ // FIXME we could find this by asking the core object.
+ return -1;
+ }
+
+ public URL getURL ()
+ {
+ return url;
+ }
+ }
+}
diff --git a/libjava/gnu/java/net/loader/RemoteResource.h b/libjava/gnu/java/net/loader/RemoteResource.h
new file mode 100644
index 000000000..29ccf16a6
--- /dev/null
+++ b/libjava/gnu/java/net/loader/RemoteResource.h
@@ -0,0 +1,52 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_RemoteResource__
+#define __gnu_java_net_loader_RemoteResource__
+
+#pragma interface
+
+#include <gnu/java/net/loader/Resource.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class RemoteResource;
+ class RemoteURLLoader;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::loader::RemoteResource : public ::gnu::java::net::loader::Resource
+{
+
+public:
+ RemoteResource(::gnu::java::net::loader::RemoteURLLoader *, ::java::lang::String *, ::java::net::URL *, ::java::io::InputStream *, jint);
+ ::java::io::InputStream * getInputStream();
+ jint getLength();
+ ::java::net::URL * getURL();
+private:
+ ::java::net::URL * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::Resource)))) url;
+ ::java::io::InputStream * stream;
+public: // actually package-private
+ jint length;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_RemoteResource__
diff --git a/libjava/gnu/java/net/loader/RemoteURLLoader.h b/libjava/gnu/java/net/loader/RemoteURLLoader.h
new file mode 100644
index 000000000..2c051651b
--- /dev/null
+++ b/libjava/gnu/java/net/loader/RemoteURLLoader.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_RemoteURLLoader__
+#define __gnu_java_net_loader_RemoteURLLoader__
+
+#pragma interface
+
+#include <gnu/java/net/loader/URLLoader.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class RemoteURLLoader;
+ class Resource;
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLClassLoader;
+ class URLStreamHandlerFactory;
+ }
+ }
+}
+
+class gnu::java::net::loader::RemoteURLLoader : public ::gnu::java::net::loader::URLLoader
+{
+
+public:
+ RemoteURLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *);
+ ::gnu::java::net::loader::Resource * getResource(::java::lang::String *);
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::gnu::java::net::loader::URLLoader)))) protocol;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_RemoteURLLoader__
diff --git a/libjava/gnu/java/net/loader/Resource.h b/libjava/gnu/java/net/loader/Resource.h
new file mode 100644
index 000000000..98b626f4a
--- /dev/null
+++ b/libjava/gnu/java/net/loader/Resource.h
@@ -0,0 +1,62 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_Resource__
+#define __gnu_java_net_loader_Resource__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class Resource;
+ class URLLoader;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ namespace security
+ {
+ class CodeSource;
+ namespace cert
+ {
+ class Certificate;
+ }
+ }
+ }
+}
+
+class gnu::java::net::loader::Resource : public ::java::lang::Object
+{
+
+public:
+ Resource(::gnu::java::net::loader::URLLoader *);
+ virtual ::java::security::CodeSource * getCodeSource();
+ virtual JArray< ::java::security::cert::Certificate * > * getCertificates();
+ virtual ::gnu::java::net::loader::URLLoader * getLoader();
+ virtual ::java::net::URL * getURL() = 0;
+ virtual jint getLength() = 0;
+ virtual ::java::io::InputStream * getInputStream() = 0;
+public: // actually package-private
+ ::gnu::java::net::loader::URLLoader * __attribute__((aligned(__alignof__( ::java::lang::Object)))) loader;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_Resource__
diff --git a/libjava/gnu/java/net/loader/URLLoader.h b/libjava/gnu/java/net/loader/URLLoader.h
new file mode 100644
index 000000000..76c294b1f
--- /dev/null
+++ b/libjava/gnu/java/net/loader/URLLoader.h
@@ -0,0 +1,63 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_URLLoader__
+#define __gnu_java_net_loader_URLLoader__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class Resource;
+ class URLLoader;
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLClassLoader;
+ class URLStreamHandlerFactory;
+ }
+ namespace security
+ {
+ class CodeSource;
+ }
+ }
+}
+
+class gnu::java::net::loader::URLLoader : public ::java::lang::Object
+{
+
+public:
+ URLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *);
+ URLLoader(::java::net::URLClassLoader *, ::gnu::java::net::loader::URLStreamHandlerCache *, ::java::net::URLStreamHandlerFactory *, ::java::net::URL *, ::java::net::URL *);
+ virtual ::java::net::URL * getBaseURL();
+ virtual ::java::lang::Class * getClass(::java::lang::String *);
+ virtual ::gnu::java::net::loader::Resource * getResource(::java::lang::String *) = 0;
+ virtual ::java::util::jar::Manifest * getManifest();
+ virtual ::java::util::ArrayList * getClassPath();
+public: // actually package-private
+ ::java::net::URLClassLoader * __attribute__((aligned(__alignof__( ::java::lang::Object)))) classloader;
+ ::java::net::URL * baseURL;
+ ::java::net::URLStreamHandlerFactory * factory;
+ ::gnu::java::net::loader::URLStreamHandlerCache * cache;
+ ::java::security::CodeSource * noCertCodeSource;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_URLLoader__
diff --git a/libjava/gnu/java/net/loader/URLStreamHandlerCache.h b/libjava/gnu/java/net/loader/URLStreamHandlerCache.h
new file mode 100644
index 000000000..a41d1d982
--- /dev/null
+++ b/libjava/gnu/java/net/loader/URLStreamHandlerCache.h
@@ -0,0 +1,48 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_loader_URLStreamHandlerCache__
+#define __gnu_java_net_loader_URLStreamHandlerCache__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace loader
+ {
+ class URLStreamHandlerCache;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URLStreamHandler;
+ class URLStreamHandlerFactory;
+ }
+ }
+}
+
+class gnu::java::net::loader::URLStreamHandlerCache : public ::java::lang::Object
+{
+
+public:
+ URLStreamHandlerCache();
+ virtual void add(::java::net::URLStreamHandlerFactory *);
+ virtual ::java::net::URLStreamHandler * get(::java::net::URLStreamHandlerFactory *, ::java::lang::String *);
+private:
+ ::java::util::HashMap * __attribute__((aligned(__alignof__( ::java::lang::Object)))) factoryCache;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_loader_URLStreamHandlerCache__
diff --git a/libjava/gnu/java/net/local/LocalServerSocket.h b/libjava/gnu/java/net/local/LocalServerSocket.h
new file mode 100644
index 000000000..35969bc65
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalServerSocket.h
@@ -0,0 +1,68 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalServerSocket__
+#define __gnu_java_net_local_LocalServerSocket__
+
+#pragma interface
+
+#include <java/net/ServerSocket.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalServerSocket;
+ class LocalSocketImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class Socket;
+ class SocketAddress;
+ }
+ }
+}
+
+class gnu::java::net::local::LocalServerSocket : public ::java::net::ServerSocket
+{
+
+public:
+ LocalServerSocket();
+ LocalServerSocket(::java::net::SocketAddress *);
+ void bind(::java::net::SocketAddress *);
+ void bind(::java::net::SocketAddress *, jint);
+ ::java::net::InetAddress * getInetAddress();
+ jint getLocalPort();
+ ::java::net::SocketAddress * getLocalSocketAddress();
+ ::java::net::Socket * accept();
+ void close();
+ jboolean isBound();
+ jboolean isClosed();
+ void setSoTimeout(jint);
+ jint getSoTimeout();
+ void setReuseAddress(jboolean);
+ jboolean getReuseAddress();
+ ::java::lang::String * toString();
+ void setReceiveBufferSize(jint);
+ jint getReceiveBufferSize();
+ void setSendBufferSize(jint);
+ jint getSendBufferSize();
+private:
+ ::gnu::java::net::local::LocalSocketImpl * __attribute__((aligned(__alignof__( ::java::net::ServerSocket)))) myImpl;
+ jboolean closed;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalServerSocket__
diff --git a/libjava/gnu/java/net/local/LocalSocket.h b/libjava/gnu/java/net/local/LocalSocket.h
new file mode 100644
index 000000000..c33f540a2
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocket.h
@@ -0,0 +1,100 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalSocket__
+#define __gnu_java_net_local_LocalSocket__
+
+#pragma interface
+
+#include <java/net/Socket.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalSocket;
+ class LocalSocketAddress;
+ class LocalSocketImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class SocketAddress;
+ }
+ namespace nio
+ {
+ namespace channels
+ {
+ class SocketChannel;
+ }
+ }
+ }
+}
+
+class gnu::java::net::local::LocalSocket : public ::java::net::Socket
+{
+
+public:
+ LocalSocket();
+ LocalSocket(::gnu::java::net::local::LocalSocketAddress *);
+public: // actually package-private
+ LocalSocket(jboolean);
+public:
+ void bind(::java::net::SocketAddress *);
+ void connect(::java::net::SocketAddress *, jint);
+ ::java::net::InetAddress * getInetAddress();
+ ::java::net::InetAddress * getLocalAddress();
+ jint getPort();
+ jint getLocalPort();
+ ::java::nio::channels::SocketChannel * getChannel();
+ ::java::net::SocketAddress * getLocalSocketAddress();
+ ::java::net::SocketAddress * getRemoteSocketAddress();
+ ::java::io::InputStream * getInputStream();
+ ::java::io::OutputStream * getOutputStream();
+ void sendUrgentData(jint);
+ void close();
+ void shutdownInput();
+ void shutdownOutput();
+ jboolean isClosed();
+ jboolean isBound();
+ jboolean isConnected();
+ void setTcpNoDelay(jboolean);
+ jboolean getTcpNoDelay();
+ void setSoLinger(jboolean, jint);
+ jint getSoLinger();
+ void setOOBInline(jboolean);
+ jboolean getOOBInline();
+ void setSoTimeout(jint);
+ jint getSoTimeout();
+ void setSendBufferSize(jint);
+ jint getSendBufferSize();
+ void setReceiveBufferSize(jint);
+ jint getReceiveBufferSize();
+ void setKeepAlive(jboolean);
+ jboolean getKeepAlive();
+ void setTrafficClass(jint);
+ jint getTrafficClass();
+ void setReuseAddress(jboolean);
+ jboolean getReuseAddress();
+public: // actually package-private
+ ::gnu::java::net::local::LocalSocketImpl * getLocalImpl();
+private:
+ ::gnu::java::net::local::LocalSocketImpl * __attribute__((aligned(__alignof__( ::java::net::Socket)))) localimpl;
+public: // actually package-private
+ jboolean localClosed;
+ jboolean localConnected;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalSocket__
diff --git a/libjava/gnu/java/net/local/LocalSocketAddress.h b/libjava/gnu/java/net/local/LocalSocketAddress.h
new file mode 100644
index 000000000..ef095f610
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocketAddress.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalSocketAddress__
+#define __gnu_java_net_local_LocalSocketAddress__
+
+#pragma interface
+
+#include <java/net/SocketAddress.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalSocketAddress;
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::local::LocalSocketAddress : public ::java::net::SocketAddress
+{
+
+public:
+ LocalSocketAddress(::java::lang::String *);
+ ::java::lang::String * getPath();
+ jboolean equals(::java::lang::Object *);
+ jint hashCode();
+ ::java::lang::String * toString();
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::net::SocketAddress)))) path;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalSocketAddress__
diff --git a/libjava/gnu/java/net/local/LocalSocketImpl$LocalInputStream.h b/libjava/gnu/java/net/local/LocalSocketImpl$LocalInputStream.h
new file mode 100644
index 000000000..8b1de3817
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocketImpl$LocalInputStream.h
@@ -0,0 +1,52 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalSocketImpl$LocalInputStream__
+#define __gnu_java_net_local_LocalSocketImpl$LocalInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalSocketImpl;
+ class LocalSocketImpl$LocalInputStream;
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::local::LocalSocketImpl$LocalInputStream : public ::java::io::InputStream
+{
+
+public: // actually package-private
+ LocalSocketImpl$LocalInputStream(::gnu::java::net::local::LocalSocketImpl *, ::gnu::java::net::local::LocalSocketImpl *);
+public:
+ virtual jint available();
+ virtual jboolean markSupported();
+ virtual void mark(jint);
+ virtual void reset();
+ virtual void close();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+private:
+ ::gnu::java::net::local::LocalSocketImpl * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) impl;
+public: // actually package-private
+ ::gnu::java::net::local::LocalSocketImpl * this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalSocketImpl$LocalInputStream__
diff --git a/libjava/gnu/java/net/local/LocalSocketImpl$LocalOutputStream.h b/libjava/gnu/java/net/local/LocalSocketImpl$LocalOutputStream.h
new file mode 100644
index 000000000..e45600120
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocketImpl$LocalOutputStream.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalSocketImpl$LocalOutputStream__
+#define __gnu_java_net_local_LocalSocketImpl$LocalOutputStream__
+
+#pragma interface
+
+#include <java/io/OutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalSocketImpl;
+ class LocalSocketImpl$LocalOutputStream;
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::local::LocalSocketImpl$LocalOutputStream : public ::java::io::OutputStream
+{
+
+public: // actually package-private
+ LocalSocketImpl$LocalOutputStream(::gnu::java::net::local::LocalSocketImpl *, ::gnu::java::net::local::LocalSocketImpl *);
+public:
+ virtual void close();
+ virtual void flush();
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+private:
+ ::gnu::java::net::local::LocalSocketImpl * __attribute__((aligned(__alignof__( ::java::io::OutputStream)))) impl;
+public: // actually package-private
+ ::gnu::java::net::local::LocalSocketImpl * this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalSocketImpl$LocalOutputStream__
diff --git a/libjava/gnu/java/net/local/LocalSocketImpl.h b/libjava/gnu/java/net/local/LocalSocketImpl.h
new file mode 100644
index 000000000..517d93027
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocketImpl.h
@@ -0,0 +1,86 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_local_LocalSocketImpl__
+#define __gnu_java_net_local_LocalSocketImpl__
+
+#pragma interface
+
+#include <java/net/SocketImpl.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace local
+ {
+ class LocalSocketAddress;
+ class LocalSocketImpl;
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class SocketAddress;
+ class SocketImpl;
+ }
+ }
+}
+
+class gnu::java::net::local::LocalSocketImpl : public ::java::net::SocketImpl
+{
+
+public: // actually package-private
+ LocalSocketImpl();
+ LocalSocketImpl(jboolean);
+public:
+ void setOption(jint, ::java::lang::Object *);
+ ::java::lang::Object * getOption(jint);
+public: // actually protected
+ void create(jboolean);
+ void listen(jint);
+ void accept(::gnu::java::net::local::LocalSocketImpl *);
+ jint available();
+ void close();
+ void sendUrgentData(jint);
+ void shutdownInput();
+ void shutdownOutput();
+public: // actually package-private
+ void unlink();
+ void localBind(::gnu::java::net::local::LocalSocketAddress *);
+ void localConnect(::gnu::java::net::local::LocalSocketAddress *);
+ jint read(JArray< jbyte > *, jint, jint);
+ void write(JArray< jbyte > *, jint, jint);
+ void doCreate();
+ ::gnu::java::net::local::LocalSocketAddress * getLocalAddress();
+ ::gnu::java::net::local::LocalSocketAddress * getRemoteAddress();
+public: // actually protected
+ ::java::io::InputStream * getInputStream();
+ ::java::io::OutputStream * getOutputStream();
+ void accept(::java::net::SocketImpl *);
+ void connect(::java::lang::String *, jint);
+ void connect(::java::net::InetAddress *, jint);
+ void connect(::java::net::SocketAddress *, jint);
+ void bind(::java::net::InetAddress *, jint);
+ void bind(::java::net::SocketAddress *);
+private:
+ jboolean __attribute__((aligned(__alignof__( ::java::net::SocketImpl)))) created;
+ ::java::io::InputStream * in;
+ ::java::io::OutputStream * out;
+ jint socket_fd;
+ ::gnu::java::net::local::LocalSocketAddress * local;
+ ::gnu::java::net::local::LocalSocketAddress * remote;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_local_LocalSocketImpl__
diff --git a/libjava/gnu/java/net/local/LocalSocketImpl.java b/libjava/gnu/java/net/local/LocalSocketImpl.java
new file mode 100644
index 000000000..35df29804
--- /dev/null
+++ b/libjava/gnu/java/net/local/LocalSocketImpl.java
@@ -0,0 +1,310 @@
+/* LocalSocketImpl.java -- a unix domain client socket implementation.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net.local;
+
+import java.io.FileDescriptor;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+
+final class LocalSocketImpl extends SocketImpl
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private boolean created;
+ private InputStream in;
+ private OutputStream out;
+ private int socket_fd;
+ private LocalSocketAddress local;
+ private LocalSocketAddress remote;
+
+ // Constructor.
+ // -------------------------------------------------------------------------
+
+ LocalSocketImpl ()
+ {
+ this (false);
+ }
+
+ LocalSocketImpl (boolean nocreate)
+ {
+ created = nocreate;
+ socket_fd = -1;
+ fd = new FileDescriptor ();
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ public void setOption (int opt, Object value) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ public Object getOption (int opt) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ protected void create (boolean stream) throws IOException { }
+ protected void listen (int timeout) throws IOException { }
+ protected void accept (LocalSocketImpl socket) throws IOException { }
+ protected int available () throws IOException { return -1; }
+ protected void close () throws IOException { }
+ protected void sendUrgentData (int data) throws IOException { }
+ protected void shutdownInput () throws IOException { }
+ protected void shutdownOutput () throws IOException { }
+
+ void unlink () throws IOException { }
+ void localBind (LocalSocketAddress addr) throws IOException { }
+ void localConnect (LocalSocketAddress addr) throws IOException { }
+ int read (byte[] buf, int off, int len) throws IOException { return -1; }
+ void write (byte[] buf, int off, int len) throws IOException { }
+
+ void doCreate () throws IOException
+ {
+ if (!created)
+ {
+ create (true);
+ }
+ }
+
+ LocalSocketAddress getLocalAddress ()
+ {
+ return local;
+ }
+
+ LocalSocketAddress getRemoteAddress ()
+ {
+ return remote;
+ }
+
+ protected InputStream getInputStream()
+ {
+ if (in == null)
+ {
+ in = new LocalInputStream (this);
+ }
+
+ return in;
+ }
+
+ protected OutputStream getOutputStream()
+ {
+ if (out == null)
+ {
+ out = new LocalOutputStream (this);
+ }
+
+ return out;
+ }
+
+ protected void accept (SocketImpl impl) throws IOException
+ {
+ if (! (impl instanceof LocalSocketImpl))
+ {
+ throw new IllegalArgumentException ("not a local socket");
+ }
+ accept ((LocalSocketImpl) impl);
+ }
+
+ protected void connect (String host, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect(SocketAddress addr, int timeout) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localConnect ((LocalSocketAddress) addr);
+ }
+
+ protected void bind (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void bind (SocketAddress addr) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localBind ((LocalSocketAddress) addr);
+ }
+
+ // Inner classes.
+ // -------------------------------------------------------------------------
+
+ class LocalInputStream extends InputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalInputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public int available () throws IOException
+ {
+ return impl.available();
+ }
+
+ public boolean markSupported ()
+ {
+ return false;
+ }
+
+ public void mark (int readLimit)
+ {
+ }
+
+ public void reset () throws IOException
+ {
+ throw new IOException ("mark/reset not supported");
+ }
+
+ public void close () throws IOException
+ {
+ impl.close();
+ }
+
+ public int read () throws IOException
+ {
+ byte[] buf = new byte[1];
+ int ret = read (buf);
+ if (ret != -1)
+ {
+ return buf[0] & 0xFF;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ public int read (byte[] buf) throws IOException
+ {
+ return read (buf, 0, buf.length);
+ }
+
+ public int read (byte[] buf, int off, int len) throws IOException
+ {
+ int ret = impl.read (buf, off, len);
+
+ if (ret == 0)
+ {
+ return -1;
+ }
+
+ return ret;
+ }
+ }
+
+ class LocalOutputStream extends OutputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalOutputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public void close () throws IOException
+ {
+ impl.close ();
+ }
+
+ public void flush () throws IOException
+ {
+ }
+
+ public void write (int b) throws IOException
+ {
+ byte[] buf = new byte [1];
+ buf[0] = (byte) b;
+ write (buf);
+ }
+
+ public void write (byte[] buf) throws IOException
+ {
+ write (buf, 0, buf.length);
+ }
+
+ public void write (byte[] buf, int off, int len) throws IOException
+ {
+ impl.write (buf, off, len);
+ }
+ }
+}
diff --git a/libjava/gnu/java/net/natPlainDatagramSocketImplNoNet.cc b/libjava/gnu/java/net/natPlainDatagramSocketImplNoNet.cc
new file mode 100644
index 000000000..7cb5a2e06
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainDatagramSocketImplNoNet.cc
@@ -0,0 +1,119 @@
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/lang/Object.h>
+#include <java/net/BindException.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/SocketException.h>
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("DatagramSocketImpl.create: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint, ::java::net::InetAddress *)
+{
+ throw new ::java::net::BindException (
+ JvNewStringLatin1 ("DatagramSocketImpl.bind: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *, jint)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("DatagramSocketImpl.connect: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("DatagramSocketImpl.disconnect: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.peekData: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.close: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.send: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.receive: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.setTimeToLive: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.getTimeToLive: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *,
+ ::java::net::NetworkInterface *,
+ jboolean)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("DatagramSocketImpl.mcastGrp: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint, ::java::lang::Object *)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("DatagramSocketImpl.setOption: unimplemented"));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("DatagramSocketImpl.getOption: unimplemented"));
+}
diff --git a/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc b/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
new file mode 100644
index 000000000..7cbf011ab
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
@@ -0,0 +1,858 @@
+/* Copyright (C) 2003, 2005, 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#include <errno.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
+#include <bstring.h>
+#endif
+
+#include <gcj/cni.h>
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/PortUnreachableException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Integer.h>
+#include <java/net/UnknownHostException.h>
+#include <java/net/ConnectException.h>
+#include <java/lang/NullPointerException.h>
+
+union SockAddr
+{
+ struct sockaddr_in address;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 address6;
+#endif
+};
+
+union McastReq
+{
+#if HAVE_STRUCT_IP_MREQ
+ struct ip_mreq mreq;
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+ struct ipv6_mreq mreq6;
+#endif
+};
+
+union InAddr
+{
+ struct in_addr addr;
+#ifdef HAVE_INET6
+ struct in6_addr addr6;
+#endif
+};
+
+
+// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
+// NoRouteToHostException; also consider UnknownHostException, ConnectException.
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+ int sock = _Jv_socket (AF_INET, SOCK_DGRAM, 0);
+
+ if (sock < 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+ }
+
+ // We use native_fd in place of fd here. From leaving fd null we avoid
+ // the double close problem in FileDescriptor.finalize.
+ native_fd = sock;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint lport,
+ ::java::net::InetAddress *host)
+{
+ union SockAddr u;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+
+ if (host != NULL)
+ memcpy (&u.address.sin_addr, bytes, len);
+ else
+ u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (lport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (lport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (_Jv_bind (native_fd, ptr, len) == 0)
+ {
+ socklen_t addrlen = sizeof(u);
+
+ if (lport != 0)
+ localPort = lport;
+ else if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) == 0)
+ localPort = ntohs (u.address.sin_port);
+ else
+ goto error;
+
+ /* Allow broadcast by default. */
+ int broadcast = 1;
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast,
+ sizeof (broadcast)) != 0)
+ goto error;
+
+ return;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::BindException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *host,
+ jint rport)
+{
+ if (! host)
+ throw new ::java::lang::NullPointerException;
+
+ union SockAddr u;
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (rport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (rport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (_Jv_connect (native_fd, ptr, len) == 0)
+ return;
+ char* strerr = strerror (errno);
+ throw new ::java::net::ConnectException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+ struct sockaddr addr;
+ addr.sa_family = AF_UNSPEC;
+ // Ignore errors. This is lame but apparently required.
+ _Jv_connect (native_fd, &addr, sizeof (addr));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *i)
+{
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ ssize_t retlen =
+ ::recvfrom (native_fd, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
+ &addrlen);
+ if (retlen < 0)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ i->addr = raddr;
+ return rport;
+ error:
+ char* strerr = strerror (errno);
+
+ if (errno == ECONNREFUSED)
+ throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *p)
+{
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ jint maxlen = p->maxlen - p->getOffset();
+ ssize_t retlen = 0;
+
+ // Do timeouts via select since SO_RCVTIMEO is not always available.
+ if (timeout > 0 && native_fd >= 0 && native_fd < FD_SETSIZE)
+ {
+ fd_set rset;
+ struct timeval tv;
+ FD_ZERO(&rset);
+ FD_SET(native_fd, &rset);
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ int retval;
+ if ((retval = _Jv_select (native_fd + 1, &rset, NULL, NULL, &tv)) < 0)
+ goto error;
+ else if (retval == 0)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("PeekData timed out") );
+ }
+
+ retlen =
+ ::recvfrom (native_fd, (char *) dbytes, maxlen, MSG_PEEK, (sockaddr*) &u,
+ &addrlen);
+ if (retlen < 0)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ p->setAddress (::java::net::InetAddress::getByAddress (raddr));
+ p->setPort (rport);
+ p->length = (int) retlen;
+ return rport;
+
+ error:
+ char* strerr = strerror (errno);
+
+ if (errno == ECONNREFUSED)
+ throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+ // Avoid races from asynchronous finalization.
+ JvSynchronize sync (this);
+
+ // The method isn't declared to throw anything, so we disregard
+ // the return value.
+ _Jv_close (native_fd);
+ native_fd = -1;
+ timeout = 0;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
+{
+ JvSynchronize lock (SEND_LOCK);
+
+ // FIXME: Deal with Multicast.
+
+ ::java::net::InetAddress *host = p->getAddress();
+ if (host == NULL)
+ {
+ // If there is no host, maybe this socket was connected, in
+ // which case we try a plain send().
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ if (::send (native_fd, (char *) dbytes, p->getLength(), 0) >= 0)
+ return;
+ }
+ else
+ {
+ jint rport = p->getPort();
+ union SockAddr u;
+
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (rport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (rport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::sendto (native_fd, (char *) dbytes, p->getLength(), 0, ptr, len)
+ >= 0)
+ return;
+ }
+
+ char* strerr = strerror (errno);
+
+ if (errno == ECONNREFUSED)
+ throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
+{
+ JvSynchronize lock (RECEIVE_LOCK);
+
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ jint maxlen = p->maxlen - p->getOffset();
+ ssize_t retlen = 0;
+
+ // Do timeouts via select since SO_RCVTIMEO is not always available.
+ if (timeout > 0 && native_fd >= 0 && native_fd < FD_SETSIZE)
+ {
+ fd_set rset;
+ struct timeval tv;
+ FD_ZERO(&rset);
+ FD_SET(native_fd, &rset);
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ int retval;
+ if ((retval = _Jv_select (native_fd + 1, &rset, NULL, NULL, &tv)) < 0)
+ goto error;
+ else if (retval == 0)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("Receive timed out") );
+ }
+
+ retlen =
+ ::recvfrom (native_fd, (char *) dbytes, maxlen, 0, (sockaddr*) &u,
+ &addrlen);
+ if (retlen < 0)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ p->setAddress (::java::net::InetAddress::getByAddress (raddr));
+ p->setPort (rport);
+ p->length = (jint) retlen;
+ return;
+
+ error:
+ char* strerr = strerror (errno);
+
+ if (errno == ECONNREFUSED)
+ throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
+{
+ // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+ char val = (char) ttl;
+ socklen_t val_len = sizeof(val);
+
+ if (::setsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
+ return;
+
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+ // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+ char val;
+ socklen_t val_len = sizeof(val);
+
+ if (::getsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
+ return ((int) val) & 0xFF;
+
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *inetaddr,
+ ::java::net::NetworkInterface *,
+ jboolean join)
+{
+ // FIXME: implement use of NetworkInterface
+
+ jbyteArray haddress = inetaddr->addr;
+#if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IPV6_MREQ
+ union McastReq u;
+ jbyte *bytes = elements (haddress);
+#endif
+
+ int len = haddress->length;
+ int level, opname;
+ const char *ptr;
+ if (0)
+ ;
+#if HAVE_STRUCT_IP_MREQ
+ else if (len == 4)
+ {
+ level = IPPROTO_IP;
+ opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
+ memcpy (&u.mreq.imr_multiaddr, bytes, len);
+ // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
+ // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+ u.mreq.imr_interface.s_addr = htonl (INADDR_ANY);
+ len = sizeof (struct ip_mreq);
+ ptr = (const char *) &u.mreq;
+ }
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+ else if (len == 16)
+ {
+ level = IPPROTO_IPV6;
+
+ /* Prefer new RFC 2553 names. */
+#ifndef IPV6_JOIN_GROUP
+#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
+#endif
+#ifndef IPV6_LEAVE_GROUP
+#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
+#endif
+
+ opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
+ memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
+ // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
+ // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+ u.mreq6.ipv6mr_interface = 0;
+ len = sizeof (struct ipv6_mreq);
+ ptr = (const char *) &u.mreq6;
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::setsockopt (native_fd, level, opname, ptr, len) == 0)
+ return;
+
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+// Helper function to get the InetAddress for a given socket (file
+// descriptor).
+static ::java::net::InetAddress *
+getLocalAddress (int native_fd)
+{
+ jbyteArray laddr;
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+
+ if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+ }
+ if (u.address.sin_family == AF_INET)
+ {
+ laddr = JvNewByteArray (4);
+ memcpy (elements (laddr), &u.address.sin_addr, 4);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ laddr = JvNewByteArray (16);
+ memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ return ::java::net::InetAddress::getByAddress (laddr);
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint optID,
+ ::java::lang::Object *value)
+{
+ int val;
+ socklen_t val_len = sizeof (val);
+
+ if (native_fd < 0)
+ throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+ if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+ {
+ ::java::lang::Boolean *boolobj =
+ static_cast< ::java::lang::Boolean *> (value);
+ val = boolobj->booleanValue() ? 1 : 0;
+ }
+ else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+ {
+ ::java::lang::Integer *intobj =
+ static_cast< ::java::lang::Integer *> (value);
+ val = (int) intobj->intValue();
+ }
+ // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+ return;
+ case _Jv_SO_LINGER_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_LINGER not valid for UDP"));
+ return;
+ case _Jv_SO_KEEPALIVE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+ return;
+
+ case _Jv_SO_BROADCAST_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_OOBINLINE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
+ return;
+
+ case _Jv_SO_SNDBUF_ :
+ case _Jv_SO_RCVBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::setsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif
+ return;
+ case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ val_len) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif
+ return;
+ case _Jv_SO_BINDADDR_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_BINDADDR: read only option"));
+ return;
+ case _Jv_IP_MULTICAST_IF_ :
+ union InAddr u;
+ jbyteArray haddress;
+ jbyte *bytes;
+ int len;
+ int level, opname;
+ const char *ptr;
+
+ haddress = ((::java::net::InetAddress *) value)->addr;
+ bytes = elements (haddress);
+ len = haddress->length;
+ if (len == 4)
+ {
+ level = IPPROTO_IP;
+ opname = IP_MULTICAST_IF;
+ memcpy (&u.addr, bytes, len);
+ len = sizeof (struct in_addr);
+ ptr = (const char *) &u.addr;
+ }
+// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
+ else if (len == 16)
+ {
+ level = IPPROTO_IPV6;
+ opname = IPV6_MULTICAST_IF;
+ memcpy (&u.addr6, bytes, len);
+ len = sizeof (struct in6_addr);
+ ptr = (const char *) &u.addr6;
+ }
+#endif
+ else
+ throw
+ new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::setsockopt (native_fd, level, opname, ptr, len) != 0)
+ goto error;
+ return;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+ return;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ // cache the local address
+ if (localAddress == NULL)
+ localAddress = getLocalAddress (native_fd);
+ len = localAddress->addr->length;
+ if (len == 4)
+ {
+ level = IPPROTO_IP;
+ opname = IP_MULTICAST_LOOP;
+ }
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_LOOP)
+ else if (len == 16)
+ {
+ level = IPPROTO_IPV6;
+ opname = IPV6_MULTICAST_LOOP;
+ }
+#endif
+ else
+ throw
+ new ::java::net::SocketException (JvNewStringUTF ("invalid address length"));
+ if (::setsockopt (native_fd, level, opname, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_IP_TOS_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_TIMEOUT_ :
+ timeout = val;
+ return;
+ default :
+ errno = ENOPROTOOPT;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint optID)
+{
+ int val;
+ socklen_t val_len = sizeof(val);
+ int level, opname;
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+ break;
+ case _Jv_SO_LINGER_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_LINGER not valid for UDP"));
+ break;
+ case _Jv_SO_KEEPALIVE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+ break;
+
+ case _Jv_SO_BROADCAST_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_SO_OOBINLINE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
+ break;
+
+ case _Jv_SO_RCVBUF_ :
+ case _Jv_SO_SNDBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::getsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+ goto error;
+ else
+ return new ::java::lang::Integer (val);
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif
+ break;
+ case _Jv_SO_BINDADDR_:
+ // cache the local address
+ if (localAddress == NULL)
+ localAddress = getLocalAddress (native_fd);
+ return localAddress;
+ break;
+ case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif
+ break;
+ case _Jv_IP_MULTICAST_IF_ :
+#ifdef HAVE_INET_NTOA
+ struct in_addr inaddr;
+ socklen_t inaddr_len;
+ char *bytes;
+
+ inaddr_len = sizeof(inaddr);
+ if (::getsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
+ &inaddr_len) != 0)
+ goto error;
+
+ bytes = inet_ntoa (inaddr);
+
+ return ::java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
+#else
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF: not available - no inet_ntoa()"));
+#endif
+ break;
+ case _Jv_SO_TIMEOUT_ :
+ return new ::java::lang::Integer (timeout);
+ break;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ // cache the local address
+ localAddress = getLocalAddress (native_fd);
+ if (localAddress->addr->length == 4)
+ {
+ level = IPPROTO_IP;
+ opname = IP_MULTICAST_LOOP;
+ }
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_LOOP)
+ else if (localAddress->addr->length == 16)
+ {
+ level = IPPROTO_IPV6;
+ opname = IPV6_MULTICAST_LOOP;
+ }
+#endif
+ else
+ throw
+ new ::java::net::SocketException (JvNewStringUTF ("invalid address length"));
+ if (::getsockopt (native_fd, level, opname, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_IP_TOS_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Integer (val);
+
+ default :
+ errno = ENOPROTOOPT;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
diff --git a/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc b/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc
new file mode 100644
index 000000000..e41019665
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc
@@ -0,0 +1,712 @@
+/* Copyright (C) 2003, 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
+#include <bstring.h>
+#endif
+
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/net/BindException.h>
+#include <java/net/SocketException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/PortUnreachableException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Integer.h>
+
+union SockAddr
+{
+ struct sockaddr_in address;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 address6;
+#endif
+};
+
+union McastReq
+{
+#if HAVE_STRUCT_IP_MREQ
+ struct ip_mreq mreq;
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+ struct ipv6_mreq mreq6;
+#endif
+};
+
+union InAddr
+{
+ struct in_addr addr;
+#ifdef HAVE_INET6
+ struct in6_addr addr6;
+#endif
+};
+
+// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
+// NoRouteToHostException; also consider UnknownHostException, ConnectException.
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+ SOCKET sock = ::socket (AF_INET, SOCK_DGRAM, 0);
+
+ if (sock == INVALID_SOCKET)
+ {
+ _Jv_ThrowSocketException ();
+ }
+
+ // Cast this to a HANDLE so we can make
+ // it non-inheritable via _Jv_platform_close_on_exec.
+ HANDLE hSocket = (HANDLE) sock;
+ _Jv_platform_close_on_exec (hSocket);
+
+ // We use native_fd in place of fd here. From leaving fd null we avoid
+ // the double close problem in FileDescriptor.finalize.
+ native_fd = (jint) hSocket;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint lport,
+ ::java::net::InetAddress *host)
+{
+ union SockAddr u;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+
+ if (host != NULL)
+ memcpy (&u.address.sin_addr, bytes, len);
+ else
+ u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (lport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (lport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::bind (native_fd, ptr, len) == 0)
+ {
+ socklen_t addrlen = sizeof(u);
+
+ if (lport != 0)
+ localPort = lport;
+ else if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) == 0)
+ localPort = ntohs (u.address.sin_port);
+ else
+ goto error;
+
+ /* Allow broadcast by default. */
+ int broadcast = 1;
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast,
+ sizeof (broadcast)) != 0)
+ goto error;
+
+ return;
+ }
+
+error:
+ DWORD dwErrorCode = WSAGetLastError ();
+ throw new ::java::net::BindException (_Jv_WinStrError (dwErrorCode));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *, jint)
+{
+ throw new ::java::lang::InternalError (JvNewStringLatin1 (
+ "PlainDatagramSocketImpl::connect: not implemented yet"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+ throw new ::java::lang::InternalError (JvNewStringLatin1 (
+ "PlainDatagramSocketImpl::disconnect: not implemented yet"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *i)
+{
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ ssize_t retlen =
+ ::recvfrom (native_fd, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
+ &addrlen);
+ if (retlen < 0)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ i->addr = raddr;
+ return rport;
+error:
+ DWORD dwErrorCode = WSAGetLastError ();
+ if (dwErrorCode == WSAECONNRESET)
+ throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+
+ _Jv_ThrowIOException ();
+ return -1;
+ // we should never get here
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData(::java::net::DatagramPacket *p)
+{
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ jint maxlen = p->maxlen - p->getOffset();
+ ssize_t retlen = 0;
+
+ if (timeout > 0)
+ {
+ int nRet= ::setsockopt(native_fd, SOL_SOCKET, SO_RCVTIMEO,
+ (char*)&timeout, sizeof(timeout));
+ if (nRet != NO_ERROR)
+ goto error;
+ }
+
+ retlen =
+ ::recvfrom (native_fd, (char *) dbytes, maxlen, MSG_PEEK, (sockaddr*) &u,
+ &addrlen);
+ if (retlen == SOCKET_ERROR)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ p->setAddress (::java::net::InetAddress::getByAddress (raddr));
+ p->setPort (rport);
+ p->length = (jint) retlen;
+ return rport;
+
+error:
+ DWORD dwErrorCode = WSAGetLastError ();
+ if (dwErrorCode == WSAECONNRESET)
+ throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+ else if (dwErrorCode == WSAETIMEDOUT)
+ throw new ::java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
+ else
+ _Jv_ThrowIOException ();
+
+ return -1;
+ // we should never get here
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+ // Avoid races from asynchronous finalization.
+ JvSynchronize sync (this);
+
+ // The method isn't declared to throw anything, so we disregard
+ // the return value.
+ ::closesocket (native_fd);
+ native_fd = -1;
+ timeout = 0;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
+{
+ JvSynchronize lock (SEND_LOCK);
+
+ // FIXME: Deal with Multicast and if the socket is connected.
+ jint rport = p->getPort();
+ union SockAddr u;
+ jbyteArray haddress = p->getAddress()->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (rport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (rport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::sendto (native_fd, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
+ return;
+
+ DWORD dwErrorCode = WSAGetLastError ();
+ if (dwErrorCode == WSAECONNRESET)
+ throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+
+ _Jv_ThrowIOException ();
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
+{
+ JvSynchronize lock (RECEIVE_LOCK);
+
+ // FIXME: Deal with Multicast and if the socket is connected.
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyte *dbytes = elements (p->getData()) + p->getOffset();
+ jint maxlen = p->maxlen - p->getOffset();
+ ssize_t retlen = 0;
+
+ if (timeout > 0)
+ {
+ // This implementation doesn't allow specifying an infinite
+ // timeout after specifying a finite one, but Sun's JDK 1.4.1
+ // didn't seem to allow this either....
+ int nRet= ::setsockopt(native_fd, SOL_SOCKET, SO_RCVTIMEO,
+ (char*)&timeout, sizeof(timeout));
+ if (nRet != NO_ERROR)
+ goto error;
+ }
+
+ retlen =
+ ::recvfrom (native_fd, (char *) dbytes, maxlen, 0, (sockaddr*) &u,
+ &addrlen);
+ if (retlen < 0)
+ goto error;
+ // FIXME: Deal with Multicast addressing and if the socket is connected.
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ p->setAddress (::java::net::InetAddress::getByAddress (raddr));
+ p->setPort (rport);
+ p->length = (jint) retlen;
+ return;
+
+ error:
+ DWORD dwErrorCode = WSAGetLastError();
+ if (dwErrorCode == WSAECONNRESET)
+ throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+ else if (dwErrorCode == WSAETIMEDOUT)
+ throw new ::java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
+ else
+ throw new ::java::io::IOException (_Jv_WinStrError (dwErrorCode));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
+{
+ // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+ char val = (char) ttl;
+ socklen_t val_len = sizeof(val);
+
+ if (::setsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
+ return;
+
+ _Jv_ThrowIOException ();
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+ // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+ char val;
+ socklen_t val_len = sizeof(val);
+
+ if (::getsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
+ return ((int) val) & 0xFF;
+
+ _Jv_ThrowIOException ();
+
+ return -1;
+ // we should never get here
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *inetaddr,
+ ::java::net::NetworkInterface *,
+ jboolean join)
+{
+ // FIXME: implement use of NetworkInterface
+ jbyteArray haddress = inetaddr->addr;
+ int len = haddress->length;
+ int level, opname;
+ const char *ptr;
+ if (0)
+ ;
+#if HAVE_STRUCT_IP_MREQ
+ else if (len == 4)
+ {
+ level = IPPROTO_IP;
+ opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
+ memcpy (&u.mreq.imr_multiaddr, bytes, len);
+ // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
+ // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+ u.mreq.imr_interface.s_addr = htonl (INADDR_ANY);
+ len = sizeof (struct ip_mreq);
+ ptr = (const char *) &u.mreq;
+ }
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+ else if (len == 16)
+ {
+ level = IPPROTO_IPV6;
+
+ /* Prefer new RFC 2553 names. */
+#ifndef IPV6_JOIN_GROUP
+#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
+#endif
+#ifndef IPV6_LEAVE_GROUP
+#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
+#endif
+
+ opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
+ memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
+ // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
+ // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+ u.mreq6.ipv6mr_interface = 0;
+ len = sizeof (struct ipv6_mreq);
+ ptr = (const char *) &u.mreq6;
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::setsockopt (native_fd, level, opname, ptr, len) == 0)
+ return;
+
+ _Jv_ThrowIOException ();
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint optID,
+ ::java::lang::Object *value)
+{
+ int val;
+ socklen_t val_len = sizeof (val);
+
+ if (native_fd < 0)
+ throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+ if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+ {
+ ::java::lang::Boolean *boolobj =
+ static_cast< ::java::lang::Boolean *> (value);
+ val = boolobj->booleanValue() ? 1 : 0;
+ }
+ else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+ {
+ ::java::lang::Integer *intobj =
+ static_cast< ::java::lang::Integer *> (value);
+ val = (int) intobj->intValue();
+ }
+ // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+ return;
+ case _Jv_SO_LINGER_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_LINGER not valid for UDP"));
+ return;
+ case _Jv_SO_KEEPALIVE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+ return;
+
+ case _Jv_SO_BROADCAST_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ val_len) != 0)
+ goto error;
+ break;
+
+ case _Jv_SO_OOBINLINE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
+ break;
+
+ case _Jv_SO_SNDBUF_ :
+ case _Jv_SO_RCVBUF_ :
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::setsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+ goto error;
+ return;
+ case _Jv_SO_REUSEADDR_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+ case _Jv_SO_BINDADDR_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_BINDADDR: read only option"));
+ return;
+ case _Jv_IP_MULTICAST_IF_ :
+ union InAddr u;
+ jbyteArray haddress;
+ jbyte *bytes;
+ int len;
+ int level, opname;
+ const char *ptr;
+
+ haddress = ((::java::net::InetAddress *) value)->addr;
+ bytes = elements (haddress);
+ len = haddress->length;
+ if (len == 4)
+ {
+ level = IPPROTO_IP;
+ opname = IP_MULTICAST_IF;
+ memcpy (&u.addr, bytes, len);
+ len = sizeof (struct in_addr);
+ ptr = (const char *) &u.addr;
+ }
+// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
+ else if (len == 16)
+ {
+ level = IPPROTO_IPV6;
+ opname = IPV6_MULTICAST_IF;
+ memcpy (&u.addr6, bytes, len);
+ len = sizeof (struct in6_addr);
+ ptr = (const char *) &u.addr6;
+ }
+#endif
+ else
+ throw
+ new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::setsockopt (native_fd, level, opname, ptr, len) != 0)
+ goto error;
+ return;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
+ break;
+
+ case _Jv_IP_TOS_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_TIMEOUT_ :
+ timeout = val;
+ return;
+ default :
+ WSASetLastError (WSAENOPROTOOPT);
+ }
+
+ error:
+ _Jv_ThrowSocketException ();
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint optID)
+{
+ int val;
+ socklen_t val_len = sizeof(val);
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+ break;
+ case _Jv_SO_LINGER_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_LINGER not valid for UDP"));
+ break;
+ case _Jv_SO_KEEPALIVE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+ break;
+
+ case _Jv_SO_BROADCAST_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_SO_OOBINLINE_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
+ break;
+
+ case _Jv_SO_RCVBUF_ :
+ case _Jv_SO_SNDBUF_ :
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::getsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+ goto error;
+ else
+ return new ::java::lang::Integer (val);
+ break;
+ case _Jv_SO_BINDADDR_:
+ // cache the local address
+ if (localAddress == NULL)
+ {
+ jbyteArray laddr;
+ if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != 0)
+ goto error;
+ if (u.address.sin_family == AF_INET)
+ {
+ laddr = JvNewByteArray (4);
+ memcpy (elements (laddr), &u.address.sin_addr, 4);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ laddr = JvNewByteArray (16);
+ memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("invalid family"));
+ localAddress = ::java::net::InetAddress::getByAddress (laddr);
+ }
+ return localAddress;
+ break;
+ case _Jv_SO_REUSEADDR_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+ break;
+ case _Jv_IP_MULTICAST_IF_ :
+ struct in_addr inaddr;
+ socklen_t inaddr_len;
+ char *bytes;
+
+ inaddr_len = sizeof(inaddr);
+ if (::getsockopt (native_fd, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
+ &inaddr_len) != 0)
+ goto error;
+
+ bytes = inet_ntoa (inaddr);
+
+ return ::java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
+ break;
+ case _Jv_SO_TIMEOUT_ :
+ return new ::java::lang::Integer (timeout);
+ break;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, IP_MULTICAST_LOOP, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_IP_TOS_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Integer (val);
+
+ default :
+ WSASetLastError (WSAENOPROTOOPT);
+ }
+
+error:
+ _Jv_ThrowSocketException ();
+ return 0;
+ // we should never get here
+}
diff --git a/libjava/gnu/java/net/natPlainSocketImplNoNet.cc b/libjava/gnu/java/net/natPlainSocketImplNoNet.cc
new file mode 100644
index 000000000..a9138aff4
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainSocketImplNoNet.cc
@@ -0,0 +1,132 @@
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <gnu/java/net/PlainSocketImpl$SocketInputStream.h>
+#include <gnu/java/net/PlainSocketImpl$SocketOutputStream.h>
+#include <java/io/IOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/SocketException.h>
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("SocketImpl.create: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *, jint)
+{
+ throw new ::java::net::BindException (
+ JvNewStringLatin1 ("SocketImpl.bind: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *, jint)
+{
+ throw new ::java::net::ConnectException (
+ JvNewStringLatin1 ("SocketImpl.connect: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("SocketImpl.listen: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *)
+{
+ throw new ::java::io::IOException (
+ JvNewStringLatin1 ("SocketImpl.accept: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint, ::java::lang::Object *)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.setOption: unimplemented"));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.getOption: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(void)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(jbyteArray buffer,
+ jint offset, jint count)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jint b)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jbyteArray b,
+ jint offset, jint len)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData(jint data)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.sendUrgentData: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.available: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::close(void)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.close: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.shutdownInput: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+ throw new ::java::net::SocketException (
+ JvNewStringLatin1 ("SocketImpl.shutdownOutput: unimplemented"));
+}
diff --git a/libjava/gnu/java/net/natPlainSocketImplPosix.cc b/libjava/gnu/java/net/natPlainSocketImplPosix.cc
new file mode 100644
index 000000000..e21013bf7
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainSocketImplPosix.cc
@@ -0,0 +1,868 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#ifdef HAVE_SYS_IOCTL_H
+#define BSD_COMP /* Get FIONREAD on Solaris2. */
+#include <sys/ioctl.h>
+#endif
+
+// Pick up FIONREAD on Solaris 2.5.
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <errno.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
+#include <bstring.h>
+#endif
+
+#include <gcj/cni.h>
+#include <gcj/javaprims.h>
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <gnu/java/net/PlainSocketImpl$SocketInputStream.h>
+#include <gnu/java/net/PlainSocketImpl$SocketOutputStream.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/InetSocketAddress.h>
+#include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Class.h>
+#include <java/lang/Integer.h>
+#include <java/lang/Thread.h>
+#include <java/lang/NullPointerException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/IllegalArgumentException.h>
+#include <java/net/UnknownHostException.h>
+
+union SockAddr
+{
+ struct sockaddr_in address;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 address6;
+#endif
+};
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean stream)
+{
+ // We might already have been create()d in the nio case.
+ if (native_fd != -1)
+ return;
+
+ int sock = _Jv_socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
+
+ if (sock < 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+ }
+
+ // We use native_fd in place of fd here. From leaving fd null we avoid
+ // the double close problem in FileDescriptor.finalize.
+ native_fd = sock;
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *host, jint lport)
+{
+ union SockAddr u;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ int i = 1;
+
+ // The following is needed for OS X/PPC, otherwise bind() fails with an
+ // error. I found the issue and following fix on some mailing list, but
+ // no explanation was given as to why this solved the problem.
+ memset (&u, 0, sizeof (u));
+
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (lport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (lport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
+ ::setsockopt(native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
+
+ if (_Jv_bind (native_fd, ptr, len) == 0)
+ {
+ socklen_t addrlen = sizeof(u);
+
+ if (lport != 0)
+ localport = lport;
+ else if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) == 0)
+ localport = ntohs (u.address.sin_port);
+ else
+ goto error;
+
+ return;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::BindException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
+ jint timeout)
+{
+ ::java::net::InetSocketAddress *tmp = (::java::net::InetSocketAddress*) addr;
+ ::java::net::InetAddress *host = tmp->getAddress();
+ if (! host)
+ throw new ::java::net::UnknownHostException(tmp->toString());
+
+ jint rport = tmp->getPort();
+
+ // Set the SocketImpl's address and port fields before we try to
+ // connect. Note that the fact that these are set doesn't imply
+ // that we're actually connected to anything. We need to record
+ // this data before we attempt the connect, since non-blocking
+ // SocketChannels will use this and almost certainly throw timeout
+ // exceptions.
+ address = host;
+ port = rport;
+
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (rport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (rport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (timeout > 0)
+ {
+ int flags = ::fcntl (native_fd, F_GETFL);
+ ::fcntl (native_fd, F_SETFL, flags | O_NONBLOCK);
+
+ if ((_Jv_connect (native_fd, ptr, len) != 0) && (errno != EINPROGRESS))
+ goto error;
+
+ fd_set fset;
+ struct timeval tv;
+ FD_ZERO(&fset);
+ FD_SET(native_fd, &fset);
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ int retval;
+
+ if ((retval = _Jv_select (native_fd + 1, &fset, &fset, NULL, &tv)) < 0)
+ goto error;
+ else if (retval == 0)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("Connect timed out"));
+ // Set the socket back into a blocking state.
+ ::fcntl (native_fd, F_SETFL, flags);
+ }
+ else
+ {
+ if (_Jv_connect (native_fd, ptr, len) != 0)
+ goto error;
+ }
+
+ // A bind may not have been done on this socket; if so, set localport now.
+ if (localport == 0)
+ {
+ if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) == 0)
+ localport = ntohs (u.address.sin_port);
+ else
+ goto error;
+ }
+
+ return;
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::ConnectException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint backlog)
+{
+ if (::listen (native_fd, backlog) != 0)
+ {
+ char* strerr = strerror (errno);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+ }
+}
+
+static void
+throw_on_sock_closed (gnu::java::net::PlainSocketImpl *soc_impl)
+{
+ // Avoid races from asynchronous close().
+ JvSynchronize sync (soc_impl);
+ if (soc_impl->native_fd == -1)
+ {
+ using namespace java::net;
+ // Socket was closed.
+ SocketException *se =
+ new SocketException (JvNewStringUTF ("Socket Closed"));
+ throw se;
+ }
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s)
+{
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ int new_socket = 0;
+
+ // Do timeouts via select since SO_RCVTIMEO is not always available.
+ if (timeout > 0 && native_fd >= 0 && native_fd < FD_SETSIZE)
+ {
+ fd_set fset;
+ struct timeval tv;
+ FD_ZERO(&fset);
+ FD_SET(native_fd, &fset);
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ int retval;
+ if ((retval = _Jv_select (native_fd + 1, &fset, &fset, NULL, &tv)) < 0)
+ goto error;
+ else if (retval == 0)
+ throw new ::java::net::SocketTimeoutException (
+ JvNewStringUTF("Accept timed out"));
+ }
+
+ new_socket = _Jv_accept (native_fd, (sockaddr*) &u, &addrlen);
+
+ if (new_socket < 0)
+ goto error;
+
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ s->native_fd = new_socket;
+ s->localport = localport;
+ s->address = ::java::net::InetAddress::getByAddress (raddr);
+ s->port = rport;
+ return;
+
+ error:
+ char* strerr = strerror (errno);
+ throw_on_sock_closed (this);
+ throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainSocketImpl::close()
+{
+ // Avoid races from asynchronous finalization.
+ JvSynchronize sync (this);
+
+ // Should we use shutdown here? Yes.
+ // How would that effect so_linger? Uncertain.
+ ::shutdown (native_fd, 2);
+ // Ignore errors in shutdown as we are closing and all the same
+ // errors are handled in the close.
+ int res = _Jv_close (native_fd);
+
+ if (res == -1)
+ {
+ // These three errors are not errors according to tests performed
+ // on the reference implementation.
+ if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+ }
+ // Safe place to reset the file pointer.
+ native_fd = -1;
+ timeout = 0;
+}
+
+static void
+write_helper (jint native_fd, jbyte *bytes, jint len);
+
+// Write a byte to the socket.
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jint b)
+{
+ jbyte data = (jbyte) b;
+ write_helper (this$0->native_fd, &data, 1);
+}
+
+// Write some bytes to the socket.
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jbyteArray b, jint offset, jint len)
+{
+ if (! b)
+ throw new ::java::lang::NullPointerException;
+ if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
+ throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+ write_helper (this$0->native_fd, elements (b) + offset, len);
+}
+
+static void
+write_helper(jint native_fd, jbyte *bytes, jint len)
+{
+ int written = 0;
+
+ while (len > 0)
+ {
+ int r = _Jv_write (native_fd, bytes, len);
+
+ if (r == -1)
+ {
+ if (::java::lang::Thread::interrupted())
+ {
+ ::java::io::InterruptedIOException *iioe
+ = new ::java::io::InterruptedIOException
+ (JvNewStringLatin1 (strerror (errno)));
+ iioe->bytesTransferred = written;
+ throw iioe;
+ }
+ // Some errors should not cause exceptions.
+ if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+ break;
+ }
+
+ written += r;
+ len -= r;
+ bytes += r;
+ }
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData (jint)
+{
+ throw new ::java::net::SocketException (JvNewStringLatin1 (
+ "PlainSocketImpl: sending of urgent data not supported by this socket"));
+}
+
+static jint
+read_helper (gnu::java::net::PlainSocketImpl *soc_impl,
+ jbyte *bytes, jint count);
+
+// Read a single byte from the socket.
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(void)
+{
+ jbyte data;
+
+ if (read_helper (this$0, &data, 1) == 1)
+ return data & 0xFF;
+
+ return -1;
+}
+
+// Read count bytes into the buffer, starting at offset.
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(jbyteArray buffer,
+ jint offset,
+ jint count)
+{
+ if (! buffer)
+ throw new ::java::lang::NullPointerException;
+
+ jsize bsize = JvGetArrayLength (buffer);
+
+ if (offset < 0 || count < 0 || offset + count > bsize)
+ throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+ return read_helper (this$0, elements (buffer) + offset, count);
+}
+
+static jint
+read_helper (gnu::java::net::PlainSocketImpl *soc_impl,
+ jbyte *bytes, jint count)
+{
+ // If zero bytes were requested, short circuit so that recv
+ // doesn't signal EOF.
+ if (count == 0)
+ return 0;
+
+ // Do timeouts via select.
+ if (soc_impl->timeout > 0
+ && soc_impl->native_fd >= 0
+ && soc_impl->native_fd < FD_SETSIZE)
+ {
+ // Create the file descriptor set.
+ fd_set read_fds;
+ FD_ZERO (&read_fds);
+ FD_SET (soc_impl->native_fd, &read_fds);
+ // Create the timeout struct based on our internal timeout value.
+ struct timeval timeout_value;
+ timeout_value.tv_sec = soc_impl->timeout / 1000;
+ timeout_value.tv_usec =(soc_impl->timeout % 1000) * 1000;
+ // Select on the fds.
+ int sel_retval =
+ _Jv_select (soc_impl->native_fd + 1,
+ &read_fds, NULL, NULL, &timeout_value);
+ // We're only interested in the 0 return.
+ // error returns still require us to try to read
+ // the socket to see what happened.
+ if (sel_retval == 0)
+ {
+ ::java::net::SocketTimeoutException *timeoutException =
+ new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("Read timed out"));
+ throw timeoutException;
+ }
+ }
+
+ // Read the socket.
+ int r = ::recv (soc_impl->native_fd, (char *) bytes, count, 0);
+
+ if (r == 0)
+ {
+ throw_on_sock_closed (soc_impl);
+ return -1;
+ }
+
+ if (::java::lang::Thread::interrupted())
+ {
+ ::java::io::InterruptedIOException *iioe =
+ new ::java::io::InterruptedIOException
+ (JvNewStringUTF ("Read interrupted"));
+ iioe->bytesTransferred = r == -1 ? 0 : r;
+ throw iioe;
+ }
+ else if (r == -1)
+ {
+ throw_on_sock_closed (soc_impl);
+ // Some errors cause us to return end of stream...
+ if (errno == ENOTCONN)
+ return -1;
+
+ // Other errors need to be signalled.
+ throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+ }
+
+ return r;
+}
+
+// How many bytes are available?
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+#if defined(FIONREAD) || defined(HAVE_SELECT)
+ int num = 0;
+ int r = 0;
+ bool num_set = false;
+
+#if defined(FIONREAD)
+ r = ::ioctl (native_fd, FIONREAD, &num);
+
+ if (r == -1 && errno == ENOTTY)
+ {
+ // If the ioctl doesn't work, we don't care.
+ r = 0;
+ num = 0;
+ }
+ else
+ num_set = true;
+#elif defined(HAVE_SELECT)
+ if (native_fd < 0)
+ {
+ errno = EBADF;
+ r = -1;
+ }
+#endif
+
+ if (r == -1)
+ {
+ posix_error:
+ throw new ::java::io::IOException(JvNewStringUTF(strerror(errno)));
+ }
+
+ // If we didn't get anything we can use select.
+
+#if defined(HAVE_SELECT)
+ if (! num_set)
+ if (! num_set && native_fd >= 0 && native_fd < FD_SETSIZE)
+ {
+ fd_set rd;
+ FD_ZERO (&rd);
+ FD_SET (native_fd, &rd);
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ r = _Jv_select (native_fd + 1, &rd, NULL, NULL, &tv);
+ if(r == -1)
+ goto posix_error;
+ num = r == 0 ? 0 : 1;
+ }
+#endif /* HAVE_SELECT */
+
+ return (jint) num;
+#else
+ throw new ::java::io::IOException (JvNewStringUTF ("unimplemented"));
+#endif
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *value)
+{
+ int val;
+ socklen_t val_len = sizeof (val);
+
+ if (native_fd < 0)
+ throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+ if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+ {
+ ::java::lang::Boolean *boolobj =
+ static_cast< ::java::lang::Boolean *> (value);
+ if (boolobj->booleanValue())
+ val = 1;
+ else
+ {
+ if (optID == _Jv_SO_LINGER_)
+ val = -1;
+ else
+ val = 0;
+ }
+ }
+ else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+ {
+ ::java::lang::Integer *intobj =
+ static_cast< ::java::lang::Integer *> (value);
+ val = (int) intobj->intValue();
+ }
+ else
+ {
+ throw new ::java::lang::IllegalArgumentException (
+ JvNewStringLatin1 ("`value' must be Boolean or Integer"));
+ }
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+#ifdef TCP_NODELAY
+ if (::setsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+ val_len) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError
+ (JvNewStringUTF ("TCP_NODELAY not supported"));
+#endif /* TCP_NODELAY */
+ return;
+
+ case _Jv_SO_KEEPALIVE_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_BROADCAST_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
+ return;
+
+ case _Jv_SO_OOBINLINE_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_LINGER_ :
+#ifdef SO_LINGER
+ struct linger l_val;
+ l_val.l_onoff = (val != -1);
+ l_val.l_linger = val;
+
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+ sizeof(l_val)) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_LINGER not supported"));
+#endif /* SO_LINGER */
+ return;
+
+ case _Jv_SO_SNDBUF_ :
+ case _Jv_SO_RCVBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::setsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif
+ return;
+
+ case _Jv_SO_BINDADDR_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_BINDADDR: read only option"));
+ return;
+
+ case _Jv_IP_MULTICAST_IF_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+ return;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+ return;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+ return;
+
+ case _Jv_IP_TOS_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+
+ case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ val_len) != 0)
+ goto error;
+ return;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif
+
+ case _Jv_SO_TIMEOUT_ :
+ timeout = val;
+ return;
+
+ default :
+ errno = ENOPROTOOPT;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint optID)
+{
+ int val;
+ socklen_t val_len = sizeof(val);
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ struct linger l_val;
+ socklen_t l_val_len = sizeof(l_val);
+
+ switch (optID)
+ {
+#ifdef TCP_NODELAY
+ case _Jv_TCP_NODELAY_ :
+ if (::getsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ else
+ return new ::java::lang::Boolean (val != 0);
+#else
+ throw new ::java::lang::InternalError
+ (JvNewStringUTF ("TCP_NODELAY not supported"));
+#endif
+ break;
+
+ case _Jv_SO_LINGER_ :
+#ifdef SO_LINGER
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+ &l_val_len) != 0)
+ goto error;
+
+ if (l_val.l_onoff)
+ return new ::java::lang::Integer (l_val.l_linger);
+ else
+ return new ::java::lang::Boolean ((jboolean)false);
+#else
+ throw new ::java::lang::InternalError
+ (JvNewStringUTF ("SO_LINGER not supported"));
+#endif
+ break;
+
+ case _Jv_SO_KEEPALIVE_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ else
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_SO_BROADCAST_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean ((jboolean)val);
+
+ case _Jv_SO_OOBINLINE_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Boolean ((jboolean)val);
+
+ case _Jv_SO_RCVBUF_ :
+ case _Jv_SO_SNDBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::getsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+ goto error;
+ else
+ return new ::java::lang::Integer (val);
+#else
+ throw new ::java::lang::InternalError
+ (JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif
+ break;
+ case _Jv_SO_BINDADDR_:
+ // cache the local address
+ if (localAddress == NULL)
+ {
+ jbyteArray laddr;
+
+ if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != 0)
+ goto error;
+
+ if (u.address.sin_family == AF_INET)
+ {
+ laddr = JvNewByteArray (4);
+ memcpy (elements (laddr), &u.address.sin_addr, 4);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ laddr = JvNewByteArray (16);
+ memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("invalid family"));
+ localAddress = ::java::net::InetAddress::getByAddress (laddr);
+ }
+
+ return localAddress;
+ break;
+ case _Jv_IP_MULTICAST_IF_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+ break;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+ break;
+
+ case _Jv_IP_TOS_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ &val_len) != 0)
+ goto error;
+ return new ::java::lang::Integer (val);
+ break;
+
+ case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+ &val_len) != 0)
+ goto error;
+#else
+ throw new ::java::lang::InternalError (
+ JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif
+ break;
+
+ case _Jv_SO_TIMEOUT_ :
+ return new ::java::lang::Integer (timeout);
+ break;
+
+ default :
+ errno = ENOPROTOOPT;
+ }
+
+ error:
+ char* strerr = strerror (errno);
+ throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+ if (::shutdown (native_fd, 0))
+ throw new ::java::net::SocketException (JvNewStringUTF (strerror (errno)));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+ if (::shutdown (native_fd, 1))
+ throw new ::java::net::SocketException (JvNewStringUTF (strerror (errno)));
+}
diff --git a/libjava/gnu/java/net/natPlainSocketImplWin32.cc b/libjava/gnu/java/net/natPlainSocketImplWin32.cc
new file mode 100644
index 000000000..9377998f5
--- /dev/null
+++ b/libjava/gnu/java/net/natPlainSocketImplWin32.cc
@@ -0,0 +1,796 @@
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+#include <platform.h>
+
+#undef STRICT
+#undef MAX_PRIORITY
+#undef MIN_PRIORITY
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <gnu/java/net/PlainSocketImpl$SocketInputStream.h>
+#include <gnu/java/net/PlainSocketImpl$SocketOutputStream.h>
+#include <java/io/IOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/InetSocketAddress.h>
+#include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Class.h>
+#include <java/lang/Integer.h>
+#include <java/lang/Thread.h>
+#include <java/lang/NullPointerException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/IllegalArgumentException.h>
+
+union SockAddr
+{
+ struct sockaddr_in address;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 address6;
+#endif
+};
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean stream)
+{
+ SOCKET sock = ::socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
+
+ if (sock == INVALID_SOCKET)
+ {
+ _Jv_ThrowIOException ();
+ }
+
+ // Cast this to a HANDLE so we can make
+ // it non-inheritable via _Jv_platform_close_on_exec.
+ HANDLE hSocket = (HANDLE) sock;
+ _Jv_platform_close_on_exec (hSocket);
+
+ // We use native_fd in place of fd here. From leaving fd null we avoid
+ // the double close problem in FileDescriptor.finalize.
+ native_fd = (jint) hSocket;
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *host, jint lport)
+{
+ union SockAddr u;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+
+ if (host != NULL)
+ memcpy (&u.address.sin_addr, bytes, len);
+ else
+ u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (lport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (lport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (::bind (native_fd, ptr, len) != SOCKET_ERROR)
+ {
+ socklen_t addrlen = sizeof(u);
+
+ if (lport != 0)
+ localport = lport;
+ else if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
+ localport = ntohs (u.address.sin_port);
+ else
+ goto error;
+
+ return;
+ }
+
+error:
+ DWORD dwErrorCode = WSAGetLastError ();
+ throw new ::java::net::BindException (_Jv_WinStrError (dwErrorCode));
+}
+
+static void
+throwConnectException (DWORD dwErrorCode)
+{
+ throw new ::java::net::ConnectException (_Jv_WinStrError (dwErrorCode));
+}
+
+static void
+throwConnectException ()
+{
+ throwConnectException (WSAGetLastError ());
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
+ jint timeout)
+{
+ ::java::net::InetSocketAddress *tmp = (::java::net::InetSocketAddress*) addr;
+ ::java::net::InetAddress *host = tmp->getAddress();
+ jint rport = tmp->getPort();
+
+ // Set the SocketImpl's address and port fields before we try to
+ // connect. Note that the fact that these are set doesn't imply
+ // that we're actually connected to anything. We need to record
+ // this data before we attempt the connect, since non-blocking
+ // SocketChannels will use this and almost certainly throw timeout
+ // exceptions.
+ address = host;
+ port = rport;
+
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ jbyteArray haddress = host->addr;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
+ struct sockaddr *ptr = (struct sockaddr *) &u.address;
+
+ if (len == 4)
+ {
+ u.address.sin_family = AF_INET;
+ memcpy (&u.address.sin_addr, bytes, len);
+ len = sizeof (struct sockaddr_in);
+ u.address.sin_port = htons (rport);
+ }
+#ifdef HAVE_INET6
+ else if (len == 16)
+ {
+ u.address6.sin6_family = AF_INET6;
+ memcpy (&u.address6.sin6_addr, bytes, len);
+ len = sizeof (struct sockaddr_in6);
+ u.address6.sin6_port = htons (rport);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+ if (timeout > 0)
+ {
+ // FIXME: we're creating a fresh WSAEVENT for each connect().
+ WSAEventWrapper aWSAEventWrapper(native_fd, FD_CONNECT);
+ WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
+
+ if (::connect (native_fd, ptr, len) == SOCKET_ERROR)
+ {
+ if (WSAGetLastError () != WSAEWOULDBLOCK)
+ throwConnectException ();
+
+ DWORD dwRet =
+ WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
+ // use true, false instead of TRUE, FALSE because the
+ // MS constants got undefined
+
+ // Reset and ignore our thread's interrupted flag.
+ // It's not possible to interrupt these sort of
+ // operations on Win32 anyway.
+ ::java::lang::Thread::interrupted();
+
+ if (dwRet == WSA_WAIT_FAILED)
+ throwConnectException ();
+ else if (dwRet == WSA_WAIT_TIMEOUT)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("connect timed out"));
+
+ // If we get here, we still need to check whether the actual
+ // connect() succeeded. Use any socket-specific error code
+ // instead of the thread-based one.
+ int nErrCode; int nErrLen=sizeof(nErrCode);
+ if (::getsockopt(native_fd, SOL_SOCKET, SO_ERROR, (char*) &nErrCode,
+ &nErrLen) == SOCKET_ERROR)
+ {
+ throwConnectException ();
+ }
+
+ if (nErrCode != NO_ERROR)
+ {
+ throwConnectException (nErrCode);
+ }
+ }
+ }
+ else
+ {
+ if (::connect (native_fd, ptr, len) == SOCKET_ERROR)
+ throwConnectException();
+ }
+
+ // A bind may not have been done on this socket; if so, set localport now.
+ if (localport == 0)
+ {
+ if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
+ localport = ntohs (u.address.sin_port);
+ else
+ throwConnectException();
+ }
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint backlog)
+{
+ if (::listen (native_fd, backlog) == SOCKET_ERROR)
+ {
+ _Jv_ThrowIOException ();
+ }
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s)
+{
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ HANDLE hSocket = 0;
+ SOCKET new_socket = 0;
+
+ if (timeout > 0)
+ {
+ // FIXME: we're creating a fresh WSAEVENT for each accept().
+ // One possible alternative would be that native_fd really points
+ // to an extended structure consisting of the SOCKET, its
+ // associated WSAEVENT, etc.
+ WSAEventWrapper aWSAEventWrapper(native_fd, FD_ACCEPT);
+ WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
+
+ for (;;)
+ {
+ new_socket = ::accept (native_fd, (sockaddr*) &u, &addrlen);
+
+ if (new_socket != INVALID_SOCKET)
+ {
+ // This new child socket is nonblocking because the parent
+ // socket became nonblocking via the WSAEventSelect() call,
+ // so we set its mode back to blocking.
+ WSAEventSelect (new_socket, hEvent, 0);
+ // undo the hEvent <-> FD_ACCEPT association inherited
+ // inherited from our parent socket
+
+ unsigned long lSockOpt = 0L;
+ // blocking mode
+ if (ioctlsocket(new_socket, FIONBIO, &lSockOpt) == SOCKET_ERROR)
+ {
+ goto error;
+ }
+ break;
+ }
+ else if (WSAGetLastError () != WSAEWOULDBLOCK)
+ {
+ goto error;
+ }
+
+ DWORD dwRet =
+ WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
+ // use true, false instead of TRUE, FALSE because the
+ // MS constants got undefined
+
+ // Reset and ignore our thread's interrupted flag.
+ ::java::lang::Thread::interrupted();
+
+ if (dwRet == WSA_WAIT_FAILED)
+ goto error;
+ else if (dwRet == WSA_WAIT_TIMEOUT)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("Accept timed out"));
+ }
+ }
+ else
+ {
+ new_socket = ::accept (native_fd, (sockaddr*) &u, &addrlen);
+ }
+
+ if (new_socket == INVALID_SOCKET)
+ goto error;
+
+ // Cast this to a HANDLE so we can make
+ // it non-inheritable via _Jv_platform_close_on_exec.
+ hSocket = (HANDLE) new_socket;
+ _Jv_platform_close_on_exec (hSocket);
+
+ jbyteArray raddr;
+ jint rport;
+ if (u.address.sin_family == AF_INET)
+ {
+ raddr = JvNewByteArray (4);
+ memcpy (elements (raddr), &u.address.sin_addr, 4);
+ rport = ntohs (u.address.sin_port);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ raddr = JvNewByteArray (16);
+ memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+ rport = ntohs (u.address6.sin6_port);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+ s->native_fd = (jint) hSocket;
+ s->localport = localport;
+ s->address = ::java::net::InetAddress::getByAddress (raddr);
+ s->port = rport;
+ return;
+
+ error:
+ _Jv_ThrowIOException ();
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainSocketImpl::close()
+{
+ // Avoid races from asynchronous finalization.
+ JvSynchronize sync (this);
+
+ // should we use shutdown here? how would that effect so_linger?
+ int res = ::closesocket (native_fd);
+
+ if (res == -1)
+ {
+ // These three errors are not errors according to tests performed
+ // on the reference implementation.
+ DWORD dwErr = WSAGetLastError();
+ if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+ && dwErr != WSAENOTSOCK)
+ _Jv_ThrowIOException ();
+ }
+ // Safe place to reset the file pointer.
+ native_fd = -1;
+ timeout = 0;
+}
+
+// Write a byte to the socket.
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jint b)
+{
+ jbyte d =(jbyte) b;
+ int r = 0;
+
+ while (r != 1)
+ {
+ r = ::send (this$0->native_fd, (char*) &d, 1, 0);
+ if (r == -1)
+ {
+ DWORD dwErr = WSAGetLastError();
+
+ // Reset and ignore our thread's interrupted flag.
+ // It's not possible to interrupt these sort of
+ // operations on Win32 anyway.
+ ::java::lang::Thread::interrupted();
+
+ // Some errors should not cause exceptions.
+ if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+ && dwErr != WSAENOTSOCK)
+ _Jv_ThrowIOException ();
+ break;
+ }
+ }
+}
+
+// Write some bytes to the socket.
+void
+gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jbyteArray b,
+ jint offset, jint len)
+{
+ if (! b)
+ throw new ::java::lang::NullPointerException;
+ if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
+ throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+ jbyte *bytes = elements (b) + offset;
+ int written = 0;
+ while (len > 0)
+ {
+ int r = ::send (this$0->native_fd, (char*) bytes, len, 0);
+
+ if (r == -1)
+ {
+ DWORD dwErr = WSAGetLastError();
+
+ // Reset and ignore our thread's interrupted flag.
+ ::java::lang::Thread::interrupted();
+
+ // Some errors should not cause exceptions.
+ if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+ && dwErr != WSAENOTSOCK)
+ _Jv_ThrowIOException ();
+ break;
+ }
+
+ written += r;
+ len -= r;
+ bytes += r;
+ }
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData (jint)
+{
+ throw new ::java::net::SocketException (JvNewStringLatin1 (
+ "PlainSocketImpl: sending of urgent data not supported by this socket"));
+}
+
+// read() helper
+static jint
+doRead(int native_fd, void* buf, int count, int timeout)
+{
+ int r = 0;
+ DWORD dwErrorCode = 0;
+ // we are forced to declare this here because
+ // a call to Thread::interrupted() blanks out
+ // WSAGetLastError().
+
+ // FIXME: we unconditionally set SO_RCVTIMEO here
+ // because we can't detect whether someone has
+ // gone from a non-zero to zero timeout. What we'd
+ // really need is a member state variable in addition
+ // to timeout
+ int nRet= ::setsockopt(native_fd, SOL_SOCKET, SO_RCVTIMEO,
+ (char*)&timeout, sizeof(timeout));
+ if (nRet != NO_ERROR)
+ {
+ dwErrorCode = WSAGetLastError ();
+ goto error;
+ }
+
+ r = ::recv (native_fd, (char*) buf, count, 0);
+
+ if (r == 0)
+ return -1;
+
+ dwErrorCode = WSAGetLastError ();
+ // save WSAGetLastError() before calling Thread.interrupted()
+
+ // Reset and ignore our thread's interrupted flag.
+ ::java::lang::Thread::interrupted();
+
+ if (r == -1)
+ {
+error:
+ // Some errors cause us to return end of stream...
+ if (dwErrorCode == WSAENOTCONN)
+ return -1;
+
+ // Other errors need to be signalled.
+ if (dwErrorCode == WSAETIMEDOUT)
+ throw new ::java::net::SocketTimeoutException
+ (JvNewStringUTF ("Read timed out") );
+ else
+ _Jv_ThrowIOException (dwErrorCode);
+ }
+
+ return r;
+}
+
+// Read a single byte from the socket.
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(void)
+{
+ jbyte b;
+ doRead(this$0->native_fd, &b, 1, this$0->timeout);
+ return b & 0xFF;
+}
+
+// Read count bytes into the buffer, starting at offset.
+jint
+gnu::java::net::PlainSocketImpl$SocketInputStream::read(jbyteArray buffer,
+ jint offset, jint count)
+{
+ // If zero bytes were requested, short circuit so that recv
+ // doesn't signal EOF.
+ if (count == 0)
+ return 0;
+
+ if (! buffer)
+ throw new ::java::lang::NullPointerException;
+
+ jsize bsize = JvGetArrayLength (buffer);
+
+ if (offset < 0 || count < 0 || offset + count > bsize)
+ throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+ jbyte *bytes = elements (buffer) + offset;
+
+ // Read the socket.
+ return doRead(this$0->native_fd, bytes, count, this$0->timeout);
+}
+
+// How many bytes are available?
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+ unsigned long num = 0;
+
+ if (::ioctlsocket (native_fd, FIONREAD, &num) == SOCKET_ERROR)
+ _Jv_ThrowIOException ();
+
+ return (jint) num;
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *value)
+{
+ int val;
+ socklen_t val_len = sizeof (val);
+
+ if (native_fd < 0)
+ throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+ if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+ {
+ ::java::lang::Boolean *boolobj =
+ static_cast< ::java::lang::Boolean *> (value);
+ if (boolobj->booleanValue())
+ val = 1;
+ else
+ {
+ if (optID == _Jv_SO_LINGER_)
+ val = -1;
+ else
+ val = 0;
+ }
+ }
+ else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+ {
+ ::java::lang::Integer *intobj =
+ static_cast< ::java::lang::Integer *> (value);
+ val = (int) intobj->intValue();
+ }
+ else
+ {
+ throw new ::java::lang::IllegalArgumentException (
+ JvNewStringLatin1 ("`value' must be Boolean or Integer"));
+ }
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ if (::setsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+ val_len) == SOCKET_ERROR)
+ goto error;
+ return;
+
+ case _Jv_SO_KEEPALIVE_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+ val_len) == SOCKET_ERROR)
+ goto error;
+ break;
+
+ case _Jv_SO_BROADCAST_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
+ break;
+
+ case _Jv_SO_OOBINLINE_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+ val_len) == SOCKET_ERROR)
+ goto error;
+ break;
+
+ case _Jv_SO_LINGER_ :
+ struct linger l_val;
+ l_val.l_onoff = (val != -1);
+ l_val.l_linger = val;
+
+ if (::setsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+ sizeof(l_val)) == SOCKET_ERROR)
+ goto error;
+ return;
+
+ case _Jv_SO_SNDBUF_ :
+ case _Jv_SO_RCVBUF_ :
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::setsockopt (native_fd, SOL_SOCKET, opt, (char *) &val,
+ val_len) == SOCKET_ERROR)
+ goto error;
+ return;
+
+ case _Jv_SO_BINDADDR_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_BINDADDR: read only option"));
+ return;
+
+ case _Jv_IP_MULTICAST_IF_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+ return;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+ break;
+
+ case _Jv_IP_TOS_ :
+ if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ val_len) == SOCKET_ERROR)
+ goto error;
+ break;
+
+ case _Jv_SO_REUSEADDR_ :
+ throw new ::java::net::SocketException (
+ JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+ return;
+
+ case _Jv_SO_TIMEOUT_ :
+ timeout = val;
+ return;
+
+ default :
+ WSASetLastError (WSAENOPROTOOPT);
+ }
+
+error:
+ _Jv_ThrowSocketException ();
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint optID)
+{
+ int val;
+ socklen_t val_len = sizeof(val);
+ union SockAddr u;
+ socklen_t addrlen = sizeof(u);
+ struct linger l_val;
+ socklen_t l_val_len = sizeof(l_val);
+
+ switch (optID)
+ {
+ case _Jv_TCP_NODELAY_ :
+ if (::getsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ else
+ return new ::java::lang::Boolean (val != 0);
+ break;
+
+ case _Jv_SO_LINGER_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+ &l_val_len) == SOCKET_ERROR)
+ goto error;
+
+ if (l_val.l_onoff)
+ return new ::java::lang::Integer (l_val.l_linger);
+ else
+ return new ::java::lang::Boolean ((jboolean)false);
+ break;
+
+ case _Jv_SO_KEEPALIVE_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ else
+ return new ::java::lang::Boolean (val != 0);
+
+ case _Jv_SO_BROADCAST_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ return new ::java::lang::Boolean ((jboolean)val);
+
+ case _Jv_SO_OOBINLINE_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ return new ::java::lang::Boolean ((jboolean)val);
+
+ case _Jv_SO_RCVBUF_ :
+ case _Jv_SO_SNDBUF_ :
+ int opt;
+ optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+ if (::getsockopt (native_fd, SOL_SOCKET, opt, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ else
+ return new ::java::lang::Integer (val);
+ break;
+ case _Jv_SO_BINDADDR_:
+ // cache the local address
+ if (localAddress == NULL)
+ {
+ jbyteArray laddr;
+
+ if (::getsockname (native_fd, (sockaddr*) &u,
+ &addrlen) == SOCKET_ERROR)
+ goto error;
+
+ if (u.address.sin_family == AF_INET)
+ {
+ laddr = JvNewByteArray (4);
+ memcpy (elements (laddr), &u.address.sin_addr, 4);
+ }
+#ifdef HAVE_INET6
+ else if (u.address.sin_family == AF_INET6)
+ {
+ laddr = JvNewByteArray (16);
+ memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+ }
+#endif
+ else
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("invalid family"));
+ localAddress = ::java::net::InetAddress::getByAddress (laddr);
+ }
+
+ return localAddress;
+ break;
+ case _Jv_IP_MULTICAST_IF_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+ break;
+
+ case _Jv_IP_MULTICAST_IF2_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+ break;
+
+ case _Jv_IP_MULTICAST_LOOP_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+ break;
+
+ case _Jv_IP_TOS_ :
+ if (::getsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val,
+ &val_len) == SOCKET_ERROR)
+ goto error;
+ return new ::java::lang::Integer (val);
+ break;
+
+ case _Jv_SO_REUSEADDR_ :
+ throw new ::java::net::SocketException
+ (JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+ break;
+
+ case _Jv_SO_TIMEOUT_ :
+ return new ::java::lang::Integer (timeout);
+ break;
+
+ default :
+ WSASetLastError (WSAENOPROTOOPT);
+ }
+
+error:
+ _Jv_ThrowSocketException ();
+ return 0;
+ // we should never get here
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+ if (::shutdown (native_fd, 0))
+ _Jv_ThrowSocketException ();
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+ if (::shutdown (native_fd, 1))
+ _Jv_ThrowSocketException ();
+}
diff --git a/libjava/gnu/java/net/protocol/core/Connection.h b/libjava/gnu/java/net/protocol/core/Connection.h
new file mode 100644
index 000000000..d09908b4c
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/Connection.h
@@ -0,0 +1,64 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_core_Connection__
+#define __gnu_java_net_protocol_core_Connection__
+
+#pragma interface
+
+#include <java/net/URLConnection.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ class Core;
+ }
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace core
+ {
+ class Connection;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::protocol::core::Connection : public ::java::net::URLConnection
+{
+
+public:
+ Connection(::java::net::URL *);
+ virtual void connect();
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::lang::String * getHeaderField(::java::lang::String *);
+ virtual ::java::util::Map * getHeaderFields();
+ virtual ::java::lang::String * getHeaderField(jint);
+ virtual ::java::lang::String * getHeaderFieldKey(jint);
+private:
+ ::java::lang::String * getKey(::java::lang::String *);
+ ::java::lang::String * getField(::java::lang::String *);
+ void getHeaders();
+ ::java::util::Hashtable * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) hdrHash;
+ ::java::util::Vector * hdrVec;
+ jboolean gotHeaders;
+ ::gnu::gcj::Core * core;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_core_Connection__
diff --git a/libjava/gnu/java/net/protocol/core/Connection.java b/libjava/gnu/java/net/protocol/core/Connection.java
new file mode 100644
index 000000000..2319c0be9
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/Connection.java
@@ -0,0 +1,172 @@
+// Connection.java - Implementation of URLConnection for core protocol.
+
+/* Copyright (C) 2001, 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.protocol.core;
+
+import gnu.gcj.Core;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+/**
+ * @author Anthony Green <green@redhat.com>
+ * @date August 13, 2001
+ */
+
+class Connection extends URLConnection
+{
+ private Hashtable hdrHash = new Hashtable();
+ private Vector hdrVec = new Vector();
+ private boolean gotHeaders = false;
+
+ private Core core;
+
+ public Connection (URL url)
+ {
+ super(url);
+ }
+
+ // Implementation of abstract method.
+ public void connect() throws IOException
+ {
+ // Call is ignored if already connected.
+ if (connected)
+ return;
+
+ // If not connected, then file needs to be opened.
+ core = Core.create (url.getFile());
+ connected = true;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ if (! doInput)
+ throw new ProtocolException("Can't open InputStream if doInput is false");
+ return new CoreInputStream (core);
+ }
+
+ // Override default method in URLConnection.
+ public String getHeaderField(String name)
+ {
+ try
+ {
+ getHeaders();
+ }
+ catch (IOException x)
+ {
+ return null;
+ }
+ return (String) hdrHash.get(name.toLowerCase());
+ }
+
+ // Override default method in URLConnection.
+ public Map getHeaderFields()
+ {
+ try
+ {
+ getHeaders();
+ }
+ catch (IOException x)
+ {
+ return null;
+ }
+ return hdrHash;
+ }
+
+ // Override default method in URLConnection.
+ public String getHeaderField(int n)
+ {
+ try
+ {
+ getHeaders();
+ }
+ catch (IOException x)
+ {
+ return null;
+ }
+ if (n < hdrVec.size())
+ return getField ((String) hdrVec.elementAt(n));
+
+ return null;
+ }
+
+ // Override default method in URLConnection.
+ public String getHeaderFieldKey(int n)
+ {
+ try
+ {
+ getHeaders();
+ }
+ catch (IOException x)
+ {
+ return null;
+ }
+ if (n < hdrVec.size())
+ return getKey ((String) hdrVec.elementAt(n));
+
+ return null;
+ }
+
+ private String getKey(String str)
+ {
+ if (str == null)
+ return null;
+ int index = str.indexOf(':');
+ if (index >= 0)
+ return str.substring(0, index);
+ else
+ return null;
+ }
+
+ private String getField(String str)
+ {
+ if (str == null)
+ return null;
+ int index = str.indexOf(':');
+ if (index >= 0)
+ return str.substring(index + 1).trim();
+ else
+ return str;
+ }
+
+ private void getHeaders() throws IOException
+ {
+ if (gotHeaders)
+ return;
+ gotHeaders = true;
+
+ connect();
+
+ // Yes, it is overkill to use the hash table and vector here since
+ // we're only putting one header in the file, but in case we need
+ // to add others later and for consistency, we'll implement it this way.
+
+ // Add the only header we know about right now: Content-length.
+ long len = core.length;
+ String line = "Content-length: " + len;
+ hdrVec.addElement(line);
+
+ // The key will never be null in this scenario since we build up the
+ // headers ourselves. If we ever rely on getting a header from somewhere
+ // else, then we may have to check if the result of getKey() is null.
+ String key = getKey(line);
+ hdrHash.put(key.toLowerCase(), Long.toString(len));
+ }
+}
+
diff --git a/libjava/gnu/java/net/protocol/core/CoreInputStream.h b/libjava/gnu/java/net/protocol/core/CoreInputStream.h
new file mode 100644
index 000000000..d6beb3965
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/CoreInputStream.h
@@ -0,0 +1,60 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_core_CoreInputStream__
+#define __gnu_java_net_protocol_core_CoreInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ class Core;
+ class RawData;
+ }
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace core
+ {
+ class CoreInputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::core::CoreInputStream : public ::java::io::InputStream
+{
+
+ jint unsafeGetByte(jlong);
+ jint copyIntoByteArray(JArray< jbyte > *, jint, jint);
+public:
+ CoreInputStream(::gnu::gcj::Core *);
+ virtual jint available();
+ virtual void mark(jint);
+ virtual jboolean markSupported();
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual void reset();
+ virtual jlong skip(jlong);
+public: // actually protected
+ ::gnu::gcj::RawData * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) ptr;
+ jint pos;
+ jint mark__;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_core_CoreInputStream__
diff --git a/libjava/gnu/java/net/protocol/core/CoreInputStream.java b/libjava/gnu/java/net/protocol/core/CoreInputStream.java
new file mode 100644
index 000000000..421bb1c47
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/CoreInputStream.java
@@ -0,0 +1,90 @@
+// Handler.java - URLStreamHandler for core protocol.
+
+/* Copyright (C) 2001 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.protocol.core;
+
+import gnu.gcj.Core;
+import gnu.gcj.RawData;
+import java.io.InputStream;
+import java.io.IOException;
+
+public class CoreInputStream extends InputStream
+{
+ /* A pointer to the object in memory. */
+ protected RawData ptr;
+
+ /* Position of the next byte in core to be read. */
+ protected int pos;
+
+ /* The currently marked position in the stream. */
+ protected int mark;
+
+ /* The index in core one greater than the last valid character. */
+ protected int count;
+
+ private native int unsafeGetByte (long offset);
+ private native int copyIntoByteArray (byte[] dest, int offset, int numBytes);
+
+ public CoreInputStream (Core core)
+ {
+ ptr = core.ptr;
+ count = core.length;
+ }
+
+ public synchronized int available()
+ {
+ return count - pos;
+ }
+
+ public synchronized void mark(int readAheadLimit)
+ {
+ // readAheadLimit is ignored per Java Class Lib. book, p.220.
+ mark = pos;
+ }
+
+ public boolean markSupported()
+ {
+ return true;
+ }
+
+ public synchronized int read()
+ {
+ if (pos < count)
+ return ((int) unsafeGetByte(pos++)) & 0xFF;
+ return -1;
+ }
+
+ public synchronized int read(byte[] b, int off, int len)
+ {
+ if (pos >= count)
+ return -1;
+
+ int numBytes = Math.min(count - pos, len);
+ copyIntoByteArray (b, off, numBytes);
+ pos += numBytes;
+ return numBytes;
+ }
+
+ public synchronized void reset()
+ {
+ pos = mark;
+ }
+
+ public synchronized long skip(long n)
+ {
+ // Even though the var numBytes is a long, in reality it can never
+ // be larger than an int since the result of subtracting 2 positive
+ // ints will always fit in an int. Since we have to return a long
+ // anyway, numBytes might as well just be a long.
+ long numBytes = Math.min ((long) (count - pos), n < 0 ? 0L : n);
+ pos += numBytes;
+ return numBytes;
+ }
+}
diff --git a/libjava/gnu/java/net/protocol/core/Handler.h b/libjava/gnu/java/net/protocol/core/Handler.h
new file mode 100644
index 000000000..364e21abb
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/Handler.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_core_Handler__
+#define __gnu_java_net_protocol_core_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace core
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::core::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_core_Handler__
diff --git a/libjava/gnu/java/net/protocol/core/Handler.java b/libjava/gnu/java/net/protocol/core/Handler.java
new file mode 100644
index 000000000..8726172d2
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/Handler.java
@@ -0,0 +1,28 @@
+// Handler.java - URLStreamHandler for core protocol.
+
+/* Copyright (C) 2001 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.protocol.core;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * @author Anthony Green <green@redhat.com>
+ * @date August 13, 2001.
+ */
+public class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ return new Connection(url);
+ }
+}
diff --git a/libjava/gnu/java/net/protocol/core/natCoreInputStream.cc b/libjava/gnu/java/net/protocol/core/natCoreInputStream.cc
new file mode 100644
index 000000000..4053efcd1
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/core/natCoreInputStream.cc
@@ -0,0 +1,51 @@
+// natCoreInputStream.cc -- C++ side of CoreInputStream
+
+/* Copyright (C) 2001 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+/* Author: Anthony Green <green@redhat.com>. */
+
+#include <config.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+#include <string.h>
+
+#include <java/lang/NullPointerException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <gnu/java/net/protocol/core/CoreInputStream.h>
+
+jint
+gnu::java::net::protocol::core::CoreInputStream::unsafeGetByte (jlong offset)
+{
+ return ((char*) ptr) [offset];
+}
+
+jint
+gnu::java::net::protocol::core::CoreInputStream::copyIntoByteArray (jbyteArray dest,
+ jint offset,
+ jint numBytes)
+{
+ if (!dest)
+ throw new ::java::lang::NullPointerException;
+
+ jsize destSize = JvGetArrayLength (dest);
+
+ if (offset < 0 || numBytes < 0 || offset + numBytes < 0
+ || offset + numBytes > destSize
+ || pos + numBytes > count)
+ throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+ void *pcore = (void *) &((char*) ptr) [pos];
+ void *pdest = (void *) (elements (dest) + offset);
+
+ memcpy (pdest, pcore, numBytes);
+
+ return 0;
+}
+
diff --git a/libjava/gnu/java/net/protocol/file/Connection$StaticData.h b/libjava/gnu/java/net/protocol/file/Connection$StaticData.h
new file mode 100644
index 000000000..46ed9ac95
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/file/Connection$StaticData.h
@@ -0,0 +1,48 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_file_Connection$StaticData__
+#define __gnu_java_net_protocol_file_Connection$StaticData__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace file
+ {
+ class Connection$StaticData;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace text
+ {
+ class SimpleDateFormat;
+ }
+ }
+}
+
+class gnu::java::net::protocol::file::Connection$StaticData : public ::java::lang::Object
+{
+
+ Connection$StaticData();
+public: // actually package-private
+ static ::java::text::SimpleDateFormat * dateFormat;
+ static ::java::lang::String * lineSeparator;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_file_Connection$StaticData__
diff --git a/libjava/gnu/java/net/protocol/file/Connection.h b/libjava/gnu/java/net/protocol/file/Connection.h
new file mode 100644
index 000000000..160f80834
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/file/Connection.h
@@ -0,0 +1,70 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_file_Connection__
+#define __gnu_java_net_protocol_file_Connection__
+
+#pragma interface
+
+#include <java/net/URLConnection.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace file
+ {
+ class Connection;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ namespace security
+ {
+ class Permission;
+ }
+ }
+}
+
+class gnu::java::net::protocol::file::Connection : public ::java::net::URLConnection
+{
+
+public:
+ Connection(::java::net::URL *);
+ static ::java::lang::String * unquote(::java::lang::String *);
+ virtual void connect();
+public: // actually package-private
+ virtual JArray< jbyte > * getDirectoryListing();
+public:
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::io::OutputStream * getOutputStream();
+ virtual jlong getLastModified();
+ virtual ::java::lang::String * getHeaderField(::java::lang::String *);
+ virtual jint getContentLength();
+ virtual ::java::security::Permission * getPermission();
+private:
+ static ::java::lang::String * DEFAULT_PERMISSION;
+ ::java::io::File * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) file;
+ JArray< jbyte > * directoryListing;
+ ::java::io::InputStream * inputStream;
+ ::java::io::OutputStream * outputStream;
+ ::java::io::FilePermission * permission;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_file_Connection__
diff --git a/libjava/gnu/java/net/protocol/file/Handler.h b/libjava/gnu/java/net/protocol/file/Handler.h
new file mode 100644
index 000000000..f3edf9a99
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/file/Handler.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_file_Handler__
+#define __gnu_java_net_protocol_file_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace file
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::file::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_file_Handler__
diff --git a/libjava/gnu/java/net/protocol/ftp/ActiveModeDTP.h b/libjava/gnu/java/net/protocol/ftp/ActiveModeDTP.h
new file mode 100644
index 000000000..4ea352a73
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/ActiveModeDTP.h
@@ -0,0 +1,70 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_ActiveModeDTP__
+#define __gnu_java_net_protocol_ftp_ActiveModeDTP__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class ActiveModeDTP;
+ class DTPInputStream;
+ class DTPOutputStream;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class ServerSocket;
+ class Socket;
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::ActiveModeDTP : public ::java::lang::Object
+{
+
+public: // actually package-private
+ ActiveModeDTP(::java::net::InetAddress *, jint, jint, jint);
+public:
+ void run();
+ void waitFor();
+ ::java::io::InputStream * getInputStream();
+ ::java::io::OutputStream * getOutputStream();
+ void setTransferMode(jint);
+ void complete();
+ jboolean abort();
+ void transferComplete();
+public: // actually package-private
+ ::java::net::ServerSocket * __attribute__((aligned(__alignof__( ::java::lang::Object)))) server;
+ ::java::net::Socket * socket;
+ ::gnu::java::net::protocol::ftp::DTPInputStream * in;
+ ::gnu::java::net::protocol::ftp::DTPOutputStream * out;
+ jboolean completed;
+ jboolean inProgress;
+ jint transferMode;
+ ::java::io::IOException * exception;
+ ::java::lang::Thread * acceptThread;
+ jint connectionTimeout;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_ActiveModeDTP__
diff --git a/libjava/gnu/java/net/protocol/ftp/BlockInputStream.h b/libjava/gnu/java/net/protocol/ftp/BlockInputStream.h
new file mode 100644
index 000000000..a6c0e18bf
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/BlockInputStream.h
@@ -0,0 +1,52 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_BlockInputStream__
+#define __gnu_java_net_protocol_ftp_BlockInputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPInputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class BlockInputStream;
+ class DTP;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::BlockInputStream : public ::gnu::java::net::protocol::ftp::DTPInputStream
+{
+
+public: // actually package-private
+ BlockInputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::InputStream *);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+public: // actually package-private
+ virtual void readHeader();
+ static const jint EOF = 64;
+ jint __attribute__((aligned(__alignof__( ::gnu::java::net::protocol::ftp::DTPInputStream)))) descriptor;
+ jint max;
+ jint count;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_BlockInputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/BlockOutputStream.h b/libjava/gnu/java/net/protocol/ftp/BlockOutputStream.h
new file mode 100644
index 000000000..dd712fd2a
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/BlockOutputStream.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_BlockOutputStream__
+#define __gnu_java_net_protocol_ftp_BlockOutputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPOutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class BlockOutputStream;
+ class DTP;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::BlockOutputStream : public ::gnu::java::net::protocol::ftp::DTPOutputStream
+{
+
+public: // actually package-private
+ BlockOutputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::OutputStream *);
+public:
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ virtual void close();
+public: // actually package-private
+ static const jbyte RECORD = -128;
+ static const jbyte EOF = 64;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_BlockOutputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/CompressedInputStream.h b/libjava/gnu/java/net/protocol/ftp/CompressedInputStream.h
new file mode 100644
index 000000000..75de07ded
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/CompressedInputStream.h
@@ -0,0 +1,59 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_CompressedInputStream__
+#define __gnu_java_net_protocol_ftp_CompressedInputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPInputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class CompressedInputStream;
+ class DTP;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::CompressedInputStream : public ::gnu::java::net::protocol::ftp::DTPInputStream
+{
+
+public: // actually package-private
+ CompressedInputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::InputStream *);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+public: // actually package-private
+ virtual void readHeader();
+ virtual void readCodeHeader();
+ static const jint EOF = 64;
+ static const jint RAW = 0;
+ static const jint COMPRESSED = 128;
+ static const jint FILLER = 192;
+ jint __attribute__((aligned(__alignof__( ::gnu::java::net::protocol::ftp::DTPInputStream)))) descriptor;
+ jint max;
+ jint count;
+ jint state;
+ jint rep;
+ jint n;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_CompressedInputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/CompressedOutputStream.h b/libjava/gnu/java/net/protocol/ftp/CompressedOutputStream.h
new file mode 100644
index 000000000..243ac7c7a
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/CompressedOutputStream.h
@@ -0,0 +1,56 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_CompressedOutputStream__
+#define __gnu_java_net_protocol_ftp_CompressedOutputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPOutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class CompressedOutputStream;
+ class DTP;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::CompressedOutputStream : public ::gnu::java::net::protocol::ftp::DTPOutputStream
+{
+
+public: // actually package-private
+ CompressedOutputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::OutputStream *);
+public:
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+public: // actually package-private
+ virtual JArray< jbyte > * compress(JArray< jbyte > *, jint, jint);
+ virtual jint flush_compressed(JArray< jbyte > *, jint, jint, jbyte);
+ virtual jint flush_raw(JArray< jbyte > *, jint, JArray< jbyte > *, jint, jint);
+ virtual JArray< jbyte > * realloc(JArray< jbyte > *, jint);
+public:
+ virtual void close();
+public: // actually package-private
+ static const jbyte RECORD = -128;
+ static const jbyte EOF = 64;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_CompressedOutputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/DTP.h b/libjava/gnu/java/net/protocol/ftp/DTP.h
new file mode 100644
index 000000000..132e9020a
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/DTP.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_DTP__
+#define __gnu_java_net_protocol_ftp_DTP__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::DTP : public ::java::lang::Object
+{
+
+public:
+ virtual ::java::io::InputStream * getInputStream() = 0;
+ virtual ::java::io::OutputStream * getOutputStream() = 0;
+ virtual void setTransferMode(jint) = 0;
+ virtual void complete() = 0;
+ virtual jboolean abort() = 0;
+ virtual void transferComplete() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_java_net_protocol_ftp_DTP__
diff --git a/libjava/gnu/java/net/protocol/ftp/DTPInputStream.h b/libjava/gnu/java/net/protocol/ftp/DTPInputStream.h
new file mode 100644
index 000000000..257479948
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/DTPInputStream.h
@@ -0,0 +1,46 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_DTPInputStream__
+#define __gnu_java_net_protocol_ftp_DTPInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ class DTPInputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::DTPInputStream : public ::java::io::FilterInputStream
+{
+
+public: // actually package-private
+ DTPInputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::InputStream *);
+ virtual void setTransferComplete(jboolean);
+public:
+ virtual void close();
+public: // actually package-private
+ ::gnu::java::net::protocol::ftp::DTP * __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) dtp;
+ jboolean transferComplete;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_DTPInputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/DTPOutputStream.h b/libjava/gnu/java/net/protocol/ftp/DTPOutputStream.h
new file mode 100644
index 000000000..1e59c7afb
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/DTPOutputStream.h
@@ -0,0 +1,46 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_DTPOutputStream__
+#define __gnu_java_net_protocol_ftp_DTPOutputStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ class DTPOutputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::DTPOutputStream : public ::java::io::FilterOutputStream
+{
+
+public: // actually package-private
+ DTPOutputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::OutputStream *);
+ virtual void setTransferComplete(jboolean);
+public:
+ virtual void close();
+public: // actually package-private
+ ::gnu::java::net::protocol::ftp::DTP * __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) dtp;
+ jboolean transferComplete;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_DTPOutputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPConnection.h b/libjava/gnu/java/net/protocol/ftp/FTPConnection.h
new file mode 100644
index 000000000..d0b1183f9
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPConnection.h
@@ -0,0 +1,165 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPConnection__
+#define __gnu_java_net_protocol_ftp_FTPConnection__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ class CRLFOutputStream;
+ class LineInputStream;
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ class FTPConnection;
+ class FTPResponse;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class Socket;
+ }
+ }
+ namespace javax
+ {
+ namespace net
+ {
+ namespace ssl
+ {
+ class TrustManager;
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPConnection : public ::java::lang::Object
+{
+
+public:
+ FTPConnection(::java::lang::String *);
+ FTPConnection(::java::lang::String *, jint);
+ FTPConnection(::java::lang::String *, jint, jint, jint, jboolean);
+ virtual jboolean authenticate(::java::lang::String *, ::java::lang::String *);
+ virtual jboolean starttls(jboolean);
+ virtual jboolean starttls(jboolean, ::javax::net::ssl::TrustManager *);
+ virtual jboolean changeWorkingDirectory(::java::lang::String *);
+ virtual jboolean changeToParentDirectory();
+ virtual void reinitialize();
+ virtual void logout();
+public: // actually protected
+ virtual void initialiseDTP();
+public:
+ virtual void setPassive(jboolean);
+ virtual jint getRepresentationType();
+ virtual void setRepresentationType(jint);
+ virtual jint getFileStructure();
+ virtual void setFileStructure(jint);
+ virtual jint getTransferMode();
+ virtual void setTransferMode(jint);
+ virtual ::java::io::InputStream * retrieve(::java::lang::String *);
+ virtual ::java::io::OutputStream * store(::java::lang::String *);
+ virtual ::java::io::OutputStream * append(::java::lang::String *);
+ virtual void allocate(jlong);
+ virtual jboolean rename(::java::lang::String *, ::java::lang::String *);
+ virtual jboolean abort();
+ virtual jboolean delete$(::java::lang::String *);
+ virtual jboolean removeDirectory(::java::lang::String *);
+ virtual jboolean makeDirectory(::java::lang::String *);
+ virtual ::java::lang::String * getWorkingDirectory();
+ virtual ::java::io::InputStream * list(::java::lang::String *);
+ virtual ::java::util::List * nameList(::java::lang::String *);
+ virtual ::java::lang::String * system();
+ virtual void noop();
+public: // actually protected
+ virtual void send(::java::lang::String *);
+ virtual ::gnu::java::net::protocol::ftp::FTPResponse * getResponse();
+ virtual ::gnu::java::net::protocol::ftp::FTPResponse * readResponse();
+public: // actually package-private
+ static jint parseCode(::java::lang::String *);
+public:
+ static const jint FTP_PORT = 21;
+ static const jint FTP_DATA_PORT = 20;
+public: // actually protected
+ static ::java::lang::String * USER;
+ static ::java::lang::String * PASS;
+ static ::java::lang::String * ACCT;
+ static ::java::lang::String * CWD;
+ static ::java::lang::String * CDUP;
+ static ::java::lang::String * SMNT;
+ static ::java::lang::String * REIN;
+ static ::java::lang::String * QUIT;
+ static ::java::lang::String * PORT;
+ static ::java::lang::String * PASV;
+ static ::java::lang::String * TYPE;
+ static ::java::lang::String * STRU;
+ static ::java::lang::String * MODE;
+ static ::java::lang::String * RETR;
+ static ::java::lang::String * STOR;
+ static ::java::lang::String * STOU;
+ static ::java::lang::String * APPE;
+ static ::java::lang::String * ALLO;
+ static ::java::lang::String * REST;
+ static ::java::lang::String * RNFR;
+ static ::java::lang::String * RNTO;
+ static ::java::lang::String * ABOR;
+ static ::java::lang::String * DELE;
+ static ::java::lang::String * RMD;
+ static ::java::lang::String * MKD;
+ static ::java::lang::String * PWD;
+ static ::java::lang::String * LIST;
+ static ::java::lang::String * NLST;
+ static ::java::lang::String * SITE;
+ static ::java::lang::String * SYST;
+ static ::java::lang::String * STAT;
+ static ::java::lang::String * HELP;
+ static ::java::lang::String * NOOP;
+ static ::java::lang::String * AUTH;
+ static ::java::lang::String * PBSZ;
+ static ::java::lang::String * PROT;
+ static ::java::lang::String * CCC;
+ static ::java::lang::String * TLS;
+public:
+ static const jint TYPE_ASCII = 1;
+ static const jint TYPE_EBCDIC = 2;
+ static const jint TYPE_BINARY = 3;
+ static const jint STRUCTURE_FILE = 1;
+ static const jint STRUCTURE_RECORD = 2;
+ static const jint STRUCTURE_PAGE = 3;
+ static const jint MODE_STREAM = 1;
+ static const jint MODE_BLOCK = 2;
+ static const jint MODE_COMPRESSED = 3;
+private:
+ static ::java::lang::String * US_ASCII;
+public: // actually protected
+ ::java::net::Socket * __attribute__((aligned(__alignof__( ::java::lang::Object)))) socket;
+ ::gnu::java::net::LineInputStream * in;
+ ::gnu::java::net::CRLFOutputStream * out;
+ jint connectionTimeout;
+ jint timeout;
+ jboolean debug;
+ ::gnu::java::net::protocol::ftp::DTP * dtp;
+ jint representationType;
+ jint fileStructure;
+ jint transferMode;
+ jboolean passive;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPConnection__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPException.h b/libjava/gnu/java/net/protocol/ftp/FTPException.h
new file mode 100644
index 000000000..b22c2f24a
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPException.h
@@ -0,0 +1,43 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPException__
+#define __gnu_java_net_protocol_ftp_FTPException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class FTPException;
+ class FTPResponse;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPException : public ::java::io::IOException
+{
+
+public:
+ FTPException(::gnu::java::net::protocol::ftp::FTPResponse *);
+ virtual ::gnu::java::net::protocol::ftp::FTPResponse * getResponse();
+public: // actually protected
+ ::gnu::java::net::protocol::ftp::FTPResponse * __attribute__((aligned(__alignof__( ::java::io::IOException)))) response;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPException__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPResponse.h b/libjava/gnu/java/net/protocol/ftp/FTPResponse.h
new file mode 100644
index 000000000..b7faeb997
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPResponse.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPResponse__
+#define __gnu_java_net_protocol_ftp_FTPResponse__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class FTPResponse;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPResponse : public ::java::lang::Object
+{
+
+public:
+ FTPResponse(jint, ::java::lang::String *);
+ FTPResponse(jint, ::java::lang::String *, ::java::lang::String *);
+ jint getCode();
+ ::java::lang::String * getMessage();
+ ::java::lang::String * getData();
+public: // actually protected
+ jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) code;
+ ::java::lang::String * message;
+ ::java::lang::String * data;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPResponse__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingInputStream.h b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingInputStream.h
new file mode 100644
index 000000000..ab8c4e0c8
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingInputStream.h
@@ -0,0 +1,44 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingInputStream__
+#define __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingInputStream__
+
+#pragma interface
+
+#include <java/io/FilterInputStream.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class FTPURLConnection;
+ class FTPURLConnection$ClosingInputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPURLConnection$ClosingInputStream : public ::java::io::FilterInputStream
+{
+
+public: // actually package-private
+ FTPURLConnection$ClosingInputStream(::gnu::java::net::protocol::ftp::FTPURLConnection *, ::java::io::InputStream *);
+public:
+ virtual void close();
+public: // actually package-private
+ ::gnu::java::net::protocol::ftp::FTPURLConnection * __attribute__((aligned(__alignof__( ::java::io::FilterInputStream)))) this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingInputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingOutputStream.h b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingOutputStream.h
new file mode 100644
index 000000000..7cdb24cf0
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection$ClosingOutputStream.h
@@ -0,0 +1,44 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingOutputStream__
+#define __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingOutputStream__
+
+#pragma interface
+
+#include <java/io/FilterOutputStream.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class FTPURLConnection;
+ class FTPURLConnection$ClosingOutputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPURLConnection$ClosingOutputStream : public ::java::io::FilterOutputStream
+{
+
+public: // actually package-private
+ FTPURLConnection$ClosingOutputStream(::gnu::java::net::protocol::ftp::FTPURLConnection *, ::java::io::OutputStream *);
+public:
+ virtual void close();
+public: // actually package-private
+ ::gnu::java::net::protocol::ftp::FTPURLConnection * __attribute__((aligned(__alignof__( ::java::io::FilterOutputStream)))) this$0;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPURLConnection$ClosingOutputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/FTPURLConnection.h b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection.h
new file mode 100644
index 000000000..a4139287e
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/FTPURLConnection.h
@@ -0,0 +1,65 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_FTPURLConnection__
+#define __gnu_java_net_protocol_ftp_FTPURLConnection__
+
+#pragma interface
+
+#include <java/net/URLConnection.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class FTPConnection;
+ class FTPURLConnection;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::FTPURLConnection : public ::java::net::URLConnection
+{
+
+public:
+ FTPURLConnection(::java::net::URL *);
+ virtual void connect();
+ virtual void setDoInput(jboolean);
+ virtual void setDoOutput(jboolean);
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::io::OutputStream * getOutputStream();
+ virtual ::java::lang::String * getRequestProperty(::java::lang::String *);
+ virtual ::java::util::Map * getRequestProperties();
+private:
+ void addRequestPropertyValue(::java::util::Map *, ::java::lang::String *);
+public:
+ virtual void setRequestProperty(::java::lang::String *, ::java::lang::String *);
+ virtual void addRequestProperty(::java::lang::String *, ::java::lang::String *);
+public: // actually protected
+ ::gnu::java::net::protocol::ftp::FTPConnection * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) connection;
+ jboolean passive;
+ jint representationType;
+ jint fileStructure;
+ jint transferMode;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_FTPURLConnection__
diff --git a/libjava/gnu/java/net/protocol/ftp/Handler.h b/libjava/gnu/java/net/protocol/ftp/Handler.h
new file mode 100644
index 000000000..05839d6ab
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/Handler.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_Handler__
+#define __gnu_java_net_protocol_ftp_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual jint getDefaultPort();
+public:
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_Handler__
diff --git a/libjava/gnu/java/net/protocol/ftp/PassiveModeDTP.h b/libjava/gnu/java/net/protocol/ftp/PassiveModeDTP.h
new file mode 100644
index 000000000..01a4a8a78
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/PassiveModeDTP.h
@@ -0,0 +1,65 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_PassiveModeDTP__
+#define __gnu_java_net_protocol_ftp_PassiveModeDTP__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTPInputStream;
+ class DTPOutputStream;
+ class PassiveModeDTP;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class InetAddress;
+ class Socket;
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::PassiveModeDTP : public ::java::lang::Object
+{
+
+public: // actually package-private
+ PassiveModeDTP(::java::lang::String *, jint, ::java::net::InetAddress *, jint, jint);
+public:
+ ::java::io::InputStream * getInputStream();
+ ::java::io::OutputStream * getOutputStream();
+ void setTransferMode(jint);
+ void complete();
+ jboolean abort();
+ void transferComplete();
+public: // actually package-private
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) address;
+ jint port;
+ ::java::net::Socket * socket;
+ ::gnu::java::net::protocol::ftp::DTPInputStream * in;
+ ::gnu::java::net::protocol::ftp::DTPOutputStream * out;
+ jboolean completed;
+ jboolean inProgress;
+ jint transferMode;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_PassiveModeDTP__
diff --git a/libjava/gnu/java/net/protocol/ftp/StreamInputStream.h b/libjava/gnu/java/net/protocol/ftp/StreamInputStream.h
new file mode 100644
index 000000000..2a344be90
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/StreamInputStream.h
@@ -0,0 +1,45 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_StreamInputStream__
+#define __gnu_java_net_protocol_ftp_StreamInputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPInputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ class StreamInputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::StreamInputStream : public ::gnu::java::net::protocol::ftp::DTPInputStream
+{
+
+public: // actually package-private
+ StreamInputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::InputStream *);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_StreamInputStream__
diff --git a/libjava/gnu/java/net/protocol/ftp/StreamOutputStream.h b/libjava/gnu/java/net/protocol/ftp/StreamOutputStream.h
new file mode 100644
index 000000000..7787c3b5e
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/ftp/StreamOutputStream.h
@@ -0,0 +1,45 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_ftp_StreamOutputStream__
+#define __gnu_java_net_protocol_ftp_StreamOutputStream__
+
+#pragma interface
+
+#include <gnu/java/net/protocol/ftp/DTPOutputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace ftp
+ {
+ class DTP;
+ class StreamOutputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::ftp::StreamOutputStream : public ::gnu::java::net::protocol::ftp::DTPOutputStream
+{
+
+public: // actually package-private
+ StreamOutputStream(::gnu::java::net::protocol::ftp::DTP *, ::java::io::OutputStream *);
+public:
+ virtual void write(jint);
+ virtual void write(JArray< jbyte > *);
+ virtual void write(JArray< jbyte > *, jint, jint);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_ftp_StreamOutputStream__
diff --git a/libjava/gnu/java/net/protocol/gcjlib/Connection.h b/libjava/gnu/java/net/protocol/gcjlib/Connection.h
new file mode 100644
index 000000000..9ecf032ef
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/gcjlib/Connection.h
@@ -0,0 +1,57 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_gcjlib_Connection__
+#define __gnu_java_net_protocol_gcjlib_Connection__
+
+#pragma interface
+
+#include <java/net/URLConnection.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace gcj
+ {
+ class Core;
+ }
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace gcjlib
+ {
+ class Connection;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::protocol::gcjlib::Connection : public ::java::net::URLConnection
+{
+
+public:
+ Connection(::java::net::URL *);
+ virtual void connect();
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::lang::String * getHeaderField(::java::lang::String *);
+public: // actually package-private
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) solib;
+ ::java::lang::String * name;
+ ::gnu::gcj::Core * core;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_gcjlib_Connection__
diff --git a/libjava/gnu/java/net/protocol/gcjlib/Connection.java b/libjava/gnu/java/net/protocol/gcjlib/Connection.java
new file mode 100644
index 000000000..4e6e462f2
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/gcjlib/Connection.java
@@ -0,0 +1,83 @@
+// Connection.java - Implementation of URLConnection for gcjlib
+// protocol.
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.protocol.gcjlib;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import gnu.gcj.Core;
+import gnu.gcj.runtime.SharedLibHelper;
+import gnu.java.net.protocol.core.CoreInputStream;
+
+/**
+ * @author Tom Tromey <tromey@redhat.com>
+ * @date January 10, 2003
+ */
+class Connection extends URLConnection
+{
+ String solib;
+ String name;
+ Core core;
+
+ public Connection (URL url) throws MalformedURLException
+ {
+ super (url);
+ int index = url.getFile().indexOf ("!/");
+
+ if (index == -1)
+ throw new MalformedURLException ("couldn't find !/ in gcjlib URL");
+
+ name = url.getFile().substring (index + 2);
+ solib = url.getFile().substring (0, index);
+ }
+
+ public void connect() throws IOException
+ {
+ if (core != null)
+ return;
+ // We can't create a new SharedLibHelper here, since we don't know
+ // what parent class loader to use.
+ SharedLibHelper helper = SharedLibHelper.findHelper(solib);
+ if (helper == null)
+ throw new IOException("library not loaded: " + solib);
+ core = helper.findCore(name);
+ if (core == null)
+ throw new IOException("couldn't find core object: " + name);
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ connect();
+ return new CoreInputStream(core);
+ }
+
+ public String getHeaderField(String field)
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (field.equals("content-type"))
+ return guessContentTypeFromName(name);
+ else if (field.equals("content-length"))
+ return Long.toString(core.length);
+ }
+ catch (IOException e)
+ {
+ // Fall through.
+ }
+ return null;
+ }
+}
diff --git a/libjava/gnu/java/net/protocol/gcjlib/Handler.h b/libjava/gnu/java/net/protocol/gcjlib/Handler.h
new file mode 100644
index 000000000..40813aeb5
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/gcjlib/Handler.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_gcjlib_Handler__
+#define __gnu_java_net_protocol_gcjlib_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace gcjlib
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::gcjlib::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_gcjlib_Handler__
diff --git a/libjava/gnu/java/net/protocol/gcjlib/Handler.java b/libjava/gnu/java/net/protocol/gcjlib/Handler.java
new file mode 100644
index 000000000..60f5bcc25
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/gcjlib/Handler.java
@@ -0,0 +1,24 @@
+// Handler.java - URLStreamHandler for gcjlib protocol.
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.java.net.protocol.gcjlib;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection (URL url) throws IOException
+ {
+ return new Connection (url);
+ }
+}
diff --git a/libjava/gnu/java/net/protocol/http/Authenticator.h b/libjava/gnu/java/net/protocol/http/Authenticator.h
new file mode 100644
index 000000000..c2390d2b3
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Authenticator.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Authenticator__
+#define __gnu_java_net_protocol_http_Authenticator__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Authenticator;
+ class Credentials;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Authenticator : public ::java::lang::Object
+{
+
+public:
+ virtual ::gnu::java::net::protocol::http::Credentials * getCredentials(::java::lang::String *, jint) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_java_net_protocol_http_Authenticator__
diff --git a/libjava/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.h b/libjava/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.h
new file mode 100644
index 000000000..2d9b51957
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_ByteArrayRequestBodyWriter__
+#define __gnu_java_net_protocol_http_ByteArrayRequestBodyWriter__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class ByteArrayRequestBodyWriter;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::ByteArrayRequestBodyWriter : public ::java::lang::Object
+{
+
+public:
+ ByteArrayRequestBodyWriter(JArray< jbyte > *);
+ virtual jint getContentLength();
+ virtual void reset();
+ virtual jint write(JArray< jbyte > *);
+public: // actually protected
+ JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::lang::Object)))) content;
+ jint pos;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_ByteArrayRequestBodyWriter__
diff --git a/libjava/gnu/java/net/protocol/http/ChunkedInputStream.h b/libjava/gnu/java/net/protocol/http/ChunkedInputStream.h
new file mode 100644
index 000000000..4a362e96b
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/ChunkedInputStream.h
@@ -0,0 +1,55 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_ChunkedInputStream__
+#define __gnu_java_net_protocol_http_ChunkedInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class ChunkedInputStream;
+ class Headers;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::ChunkedInputStream : public ::java::io::InputStream
+{
+
+public:
+ ChunkedInputStream(::java::io::InputStream *, ::gnu::java::net::protocol::http::Headers *);
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jint available();
+ virtual void close();
+public: // actually package-private
+ ::gnu::java::net::protocol::http::Headers * __attribute__((aligned(__alignof__( ::java::io::InputStream)))) headers;
+private:
+ ::java::io::InputStream * in;
+public: // actually package-private
+ jint size;
+ jint count;
+ jboolean meta;
+ jboolean eof;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_ChunkedInputStream__
diff --git a/libjava/gnu/java/net/protocol/http/Cookie.h b/libjava/gnu/java/net/protocol/http/Cookie.h
new file mode 100644
index 000000000..3c2364060
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Cookie.h
@@ -0,0 +1,56 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Cookie__
+#define __gnu_java_net_protocol_http_Cookie__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Cookie;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Cookie : public ::java::lang::Object
+{
+
+public:
+ Cookie(::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, jboolean, ::java::util::Date *);
+ virtual ::java::lang::String * getName();
+ virtual ::java::lang::String * getValue();
+ virtual ::java::lang::String * getComment();
+ virtual ::java::lang::String * getDomain();
+ virtual ::java::lang::String * getPath();
+ virtual jboolean isSecure();
+ virtual ::java::util::Date * getExpiryDate();
+ virtual ::java::lang::String * toString();
+ virtual ::java::lang::String * toString(jboolean, jboolean);
+public: // actually protected
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) name;
+ ::java::lang::String * value;
+ ::java::lang::String * comment;
+ ::java::lang::String * domain;
+ ::java::lang::String * path;
+ jboolean secure;
+ ::java::util::Date * expires;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Cookie__
diff --git a/libjava/gnu/java/net/protocol/http/CookieManager.h b/libjava/gnu/java/net/protocol/http/CookieManager.h
new file mode 100644
index 000000000..f06ac974b
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/CookieManager.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_CookieManager__
+#define __gnu_java_net_protocol_http_CookieManager__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Cookie;
+ class CookieManager;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::CookieManager : public ::java::lang::Object
+{
+
+public:
+ virtual void setCookie(::gnu::java::net::protocol::http::Cookie *) = 0;
+ virtual JArray< ::gnu::java::net::protocol::http::Cookie * > * getCookies(::java::lang::String *, jboolean, ::java::lang::String *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_java_net_protocol_http_CookieManager__
diff --git a/libjava/gnu/java/net/protocol/http/Credentials.h b/libjava/gnu/java/net/protocol/http/Credentials.h
new file mode 100644
index 000000000..e877d54d9
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Credentials.h
@@ -0,0 +1,44 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Credentials__
+#define __gnu_java_net_protocol_http_Credentials__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Credentials;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Credentials : public ::java::lang::Object
+{
+
+public:
+ Credentials(::java::lang::String *, ::java::lang::String *);
+ virtual ::java::lang::String * getUsername();
+ virtual ::java::lang::String * getPassword();
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) username;
+ ::java::lang::String * password;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Credentials__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool$Reaper.h b/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool$Reaper.h
new file mode 100644
index 000000000..727cb83ae
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool$Reaper.h
@@ -0,0 +1,44 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPConnection$Pool$Reaper__
+#define __gnu_java_net_protocol_http_HTTPConnection$Pool$Reaper__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class HTTPConnection$Pool;
+ class HTTPConnection$Pool$Reaper;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPConnection$Pool$Reaper : public ::java::lang::Object
+{
+
+public: // actually package-private
+ HTTPConnection$Pool$Reaper(::gnu::java::net::protocol::http::HTTPConnection$Pool *);
+public:
+ virtual void run();
+public: // actually package-private
+ ::gnu::java::net::protocol::http::HTTPConnection$Pool * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$1;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPConnection$Pool$Reaper__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool.h b/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool.h
new file mode 100644
index 000000000..62aaa265b
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPConnection$Pool.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPConnection$Pool__
+#define __gnu_java_net_protocol_http_HTTPConnection$Pool__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class HTTPConnection;
+ class HTTPConnection$Pool;
+ class HTTPConnection$Pool$Reaper;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPConnection$Pool : public ::java::lang::Object
+{
+
+ HTTPConnection$Pool();
+ static jboolean matches(::gnu::java::net::protocol::http::HTTPConnection *, ::java::lang::String *, jint, jboolean);
+public: // actually package-private
+ virtual ::gnu::java::net::protocol::http::HTTPConnection * get(::java::lang::String *, jint, jboolean, jint, jint);
+ virtual void put(::gnu::java::net::protocol::http::HTTPConnection *);
+ virtual void removeOldest();
+ static ::gnu::java::net::protocol::http::HTTPConnection$Pool * instance;
+ ::java::util::LinkedList * __attribute__((aligned(__alignof__( ::java::lang::Object)))) connectionPool;
+ jint maxConnections;
+ jint connectionTTL;
+ ::gnu::java::net::protocol::http::HTTPConnection$Pool$Reaper * reaper;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPConnection$Pool__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPConnection.h b/libjava/gnu/java/net/protocol/http/HTTPConnection.h
new file mode 100644
index 000000000..e0d1c4628
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPConnection.h
@@ -0,0 +1,128 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPConnection__
+#define __gnu_java_net_protocol_http_HTTPConnection__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class CookieManager;
+ class HTTPConnection;
+ class HTTPConnection$Pool;
+ class Request;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class Socket;
+ }
+ }
+ namespace javax
+ {
+ namespace net
+ {
+ namespace ssl
+ {
+ class HandshakeCompletedListener;
+ class SSLSocketFactory;
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPConnection : public ::java::lang::Object
+{
+
+public:
+ HTTPConnection(::java::lang::String *);
+ HTTPConnection(::java::lang::String *, jboolean);
+ HTTPConnection(::java::lang::String *, jboolean, jint, jint);
+ HTTPConnection(::java::lang::String *, jint);
+ HTTPConnection(::java::lang::String *, jint, jboolean);
+ HTTPConnection(::java::lang::String *, jint, jboolean, jint, jint);
+ virtual ::java::lang::String * getHostName();
+ virtual jint getPort();
+ virtual jboolean isSecure();
+ virtual ::java::lang::String * getVersion();
+ virtual void setVersion(jint, jint);
+ virtual void setProxy(::java::lang::String *, jint);
+ virtual jboolean isUsingProxy();
+ virtual void setCookieManager(::gnu::java::net::protocol::http::CookieManager *);
+ virtual ::gnu::java::net::protocol::http::CookieManager * getCookieManager();
+public: // actually package-private
+ virtual void setPool(::gnu::java::net::protocol::http::HTTPConnection$Pool *);
+ virtual void release();
+public:
+ virtual ::gnu::java::net::protocol::http::Request * newRequest(::java::lang::String *, ::java::lang::String *);
+ virtual void close();
+public: // actually protected
+ virtual ::java::net::Socket * getSocket();
+public: // actually package-private
+ virtual ::javax::net::ssl::SSLSocketFactory * getSSLSocketFactory();
+ virtual void setSSLSocketFactory(::javax::net::ssl::SSLSocketFactory *);
+public: // actually protected
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::io::OutputStream * getOutputStream();
+ virtual void closeConnection();
+ virtual ::java::lang::String * getURI();
+public: // actually package-private
+ virtual jint getNonceCount(::java::lang::String *);
+ virtual void incrementNonce(::java::lang::String *);
+ virtual void addHandshakeCompletedListener(::javax::net::ssl::HandshakeCompletedListener *);
+ virtual void removeHandshakeCompletedListener(::javax::net::ssl::HandshakeCompletedListener *);
+public:
+ static const jint HTTP_PORT = 80;
+ static const jint HTTPS_PORT = 443;
+private:
+ static ::java::lang::String * userAgent;
+public: // actually protected
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) hostname;
+ jint port;
+ jboolean secure;
+ jint connectionTimeout;
+ jint timeout;
+ ::java::lang::String * proxyHostname;
+ jint proxyPort;
+ jint majorVersion;
+ jint minorVersion;
+private:
+ ::java::util::List * handshakeCompletedListeners;
+public: // actually protected
+ ::java::net::Socket * socket;
+private:
+ ::javax::net::ssl::SSLSocketFactory * sslSocketFactory;
+public: // actually protected
+ ::java::io::InputStream * in;
+ ::java::io::OutputStream * out;
+private:
+ ::java::util::Map * nonceCounts;
+public: // actually protected
+ ::gnu::java::net::protocol::http::CookieManager * cookieManager;
+private:
+ ::gnu::java::net::protocol::http::HTTPConnection$Pool * pool;
+public: // actually package-private
+ jint useCount;
+ jlong timeLastUsed;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPConnection__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPDateFormat.h b/libjava/gnu/java/net/protocol/http/HTTPDateFormat.h
new file mode 100644
index 000000000..2a305bac8
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPDateFormat.h
@@ -0,0 +1,62 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPDateFormat__
+#define __gnu_java_net_protocol_http_HTTPDateFormat__
+
+#pragma interface
+
+#include <java/text/DateFormat.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class HTTPDateFormat;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace text
+ {
+ class FieldPosition;
+ class NumberFormat;
+ class ParsePosition;
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPDateFormat : public ::java::text::DateFormat
+{
+
+public:
+ HTTPDateFormat();
+ virtual ::java::lang::StringBuffer * format(::java::util::Date *, ::java::lang::StringBuffer *, ::java::text::FieldPosition *);
+ virtual ::java::util::Date * parse(::java::lang::String *, ::java::text::ParsePosition *);
+private:
+ jint skipWhitespace(::java::lang::String *, jint);
+ jint skipNonWhitespace(::java::lang::String *, jint);
+ jint skipTo(::java::lang::String *, jint, jchar);
+public:
+ virtual void setCalendar(::java::util::Calendar *);
+ virtual void setNumberFormat(::java::text::NumberFormat *);
+public: // actually package-private
+ static JArray< ::java::lang::String * > * DAYS_OF_WEEK;
+ static JArray< ::java::lang::String * > * MONTHS;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPDateFormat__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPURLConnection$1.h b/libjava/gnu/java/net/protocol/http/HTTPURLConnection$1.h
new file mode 100644
index 000000000..678a71ac4
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPURLConnection$1.h
@@ -0,0 +1,47 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPURLConnection$1__
+#define __gnu_java_net_protocol_http_HTTPURLConnection$1__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Credentials;
+ class HTTPURLConnection;
+ class HTTPURLConnection$1;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPURLConnection$1 : public ::java::lang::Object
+{
+
+public: // actually package-private
+ HTTPURLConnection$1(::gnu::java::net::protocol::http::HTTPURLConnection *, ::gnu::java::net::protocol::http::Credentials *);
+public:
+ virtual ::gnu::java::net::protocol::http::Credentials * getCredentials(::java::lang::String *, jint);
+public: // actually package-private
+ ::gnu::java::net::protocol::http::HTTPURLConnection * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0;
+private:
+ ::gnu::java::net::protocol::http::Credentials * val$creds;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPURLConnection$1__
diff --git a/libjava/gnu/java/net/protocol/http/HTTPURLConnection.h b/libjava/gnu/java/net/protocol/http/HTTPURLConnection.h
new file mode 100644
index 000000000..460928e6b
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/HTTPURLConnection.h
@@ -0,0 +1,115 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_HTTPURLConnection__
+#define __gnu_java_net_protocol_http_HTTPURLConnection__
+
+#pragma interface
+
+#include <javax/net/ssl/HttpsURLConnection.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class HTTPConnection;
+ class HTTPURLConnection;
+ class Headers;
+ class Request;
+ class Response;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ namespace security
+ {
+ namespace cert
+ {
+ class Certificate;
+ }
+ }
+ }
+ namespace javax
+ {
+ namespace net
+ {
+ namespace ssl
+ {
+ class HandshakeCompletedEvent;
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::HTTPURLConnection : public ::javax::net::ssl::HttpsURLConnection
+{
+
+public:
+ HTTPURLConnection(::java::net::URL *);
+ virtual void connect();
+public: // actually package-private
+ virtual ::gnu::java::net::protocol::http::HTTPConnection * getConnection(::java::lang::String *, jint, jboolean);
+public:
+ virtual void disconnect();
+ virtual jboolean usingProxy();
+ virtual void setRequestMethod(::java::lang::String *);
+ virtual ::java::lang::String * getRequestProperty(::java::lang::String *);
+ virtual ::java::util::Map * getRequestProperties();
+ virtual void setRequestProperty(::java::lang::String *, ::java::lang::String *);
+ virtual void addRequestProperty(::java::lang::String *, ::java::lang::String *);
+ virtual ::java::io::OutputStream * getOutputStream();
+ virtual ::java::io::InputStream * getInputStream();
+ virtual ::java::io::InputStream * getErrorStream();
+ virtual ::java::util::Map * getHeaderFields();
+public: // actually package-private
+ virtual ::java::lang::String * getStatusLine(::gnu::java::net::protocol::http::Response *);
+public:
+ virtual ::java::lang::String * getHeaderField(jint);
+ virtual ::java::lang::String * getHeaderFieldKey(jint);
+ virtual ::java::lang::String * getHeaderField(::java::lang::String *);
+ virtual jlong getHeaderFieldDate(::java::lang::String *, jlong);
+ virtual ::java::lang::String * getContentType();
+ virtual jint getResponseCode();
+ virtual ::java::lang::String * getResponseMessage();
+ virtual ::java::lang::String * getCipherSuite();
+ virtual JArray< ::java::security::cert::Certificate * > * getLocalCertificates();
+ virtual JArray< ::java::security::cert::Certificate * > * getServerCertificates();
+ virtual void handshakeCompleted(::javax::net::ssl::HandshakeCompletedEvent *);
+ virtual void setReadTimeout(jint);
+private:
+ ::gnu::java::net::protocol::http::HTTPConnection * __attribute__((aligned(__alignof__( ::javax::net::ssl::HttpsURLConnection)))) connection;
+public: // actually package-private
+ ::java::lang::String * proxyHostname;
+ jint proxyPort;
+ ::java::lang::String * agent;
+ jboolean keepAlive;
+private:
+ ::gnu::java::net::protocol::http::Request * request;
+ ::gnu::java::net::protocol::http::Headers * requestHeaders;
+ ::java::io::ByteArrayOutputStream * requestSink;
+ jboolean requestMethodSetExplicitly;
+ ::gnu::java::net::protocol::http::Response * response;
+ ::java::io::InputStream * responseSink;
+ ::java::io::InputStream * errorSink;
+ ::javax::net::ssl::HandshakeCompletedEvent * handshakeEvent;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_HTTPURLConnection__
diff --git a/libjava/gnu/java/net/protocol/http/Handler.h b/libjava/gnu/java/net/protocol/http/Handler.h
new file mode 100644
index 000000000..bd96f2d8b
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Handler.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Handler__
+#define __gnu_java_net_protocol_http_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual jint getDefaultPort();
+public:
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Handler__
diff --git a/libjava/gnu/java/net/protocol/http/Headers$HeaderElement.h b/libjava/gnu/java/net/protocol/http/Headers$HeaderElement.h
new file mode 100644
index 000000000..ecf4982f0
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Headers$HeaderElement.h
@@ -0,0 +1,41 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Headers$HeaderElement__
+#define __gnu_java_net_protocol_http_Headers$HeaderElement__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Headers$HeaderElement;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Headers$HeaderElement : public ::java::lang::Object
+{
+
+public: // actually package-private
+ Headers$HeaderElement(::java::lang::String *, ::java::lang::String *);
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) name;
+ ::java::lang::String * value;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Headers$HeaderElement__
diff --git a/libjava/gnu/java/net/protocol/http/Headers.h b/libjava/gnu/java/net/protocol/http/Headers.h
new file mode 100644
index 000000000..cad6e68a7
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Headers.h
@@ -0,0 +1,62 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Headers__
+#define __gnu_java_net_protocol_http_Headers__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Headers;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace text
+ {
+ class DateFormat;
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Headers : public ::java::lang::Object
+{
+
+public:
+ Headers();
+ virtual ::java::util::Iterator * iterator();
+ virtual ::java::lang::String * getValue(::java::lang::String *);
+ virtual jint getIntValue(::java::lang::String *);
+ virtual jlong getLongValue(::java::lang::String *);
+ virtual ::java::util::Date * getDateValue(::java::lang::String *);
+ virtual void put(::java::lang::String *, ::java::lang::String *);
+ virtual void putAll(::gnu::java::net::protocol::http::Headers *);
+ virtual void remove(::java::lang::String *);
+ virtual void parse(::java::io::InputStream *);
+ virtual void addValue(::java::lang::String *, ::java::lang::String *);
+ virtual ::java::util::Map * getAsMap();
+ virtual ::java::lang::String * getHeaderName(jint);
+ virtual ::java::lang::String * getHeaderValue(jint);
+private:
+ ::java::util::ArrayList * __attribute__((aligned(__alignof__( ::java::lang::Object)))) headers;
+ static ::java::text::DateFormat * dateFormat;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Headers__
diff --git a/libjava/gnu/java/net/protocol/http/LimitedLengthInputStream.h b/libjava/gnu/java/net/protocol/http/LimitedLengthInputStream.h
new file mode 100644
index 000000000..e70bbcc03
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/LimitedLengthInputStream.h
@@ -0,0 +1,57 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_LimitedLengthInputStream__
+#define __gnu_java_net_protocol_http_LimitedLengthInputStream__
+
+#pragma interface
+
+#include <java/io/InputStream.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class HTTPConnection;
+ class LimitedLengthInputStream;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::LimitedLengthInputStream : public ::java::io::InputStream
+{
+
+ void handleClose();
+public: // actually package-private
+ LimitedLengthInputStream(::java::io::InputStream *, jlong, jboolean, ::gnu::java::net::protocol::http::HTTPConnection *, jboolean);
+public:
+ virtual jint read();
+ virtual jint read(JArray< jbyte > *);
+ virtual jint read(JArray< jbyte > *, jint, jint);
+ virtual jlong skip(jlong);
+ virtual jint available();
+ virtual void close();
+private:
+ jlong __attribute__((aligned(__alignof__( ::java::io::InputStream)))) remainingLen;
+ jboolean restrictLen;
+ ::gnu::java::net::protocol::http::HTTPConnection * connection;
+ jboolean eof;
+ ::java::io::InputStream * in;
+ jboolean doClose;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_LimitedLengthInputStream__
diff --git a/libjava/gnu/java/net/protocol/http/Request.h b/libjava/gnu/java/net/protocol/http/Request.h
new file mode 100644
index 000000000..2cf4693cf
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Request.h
@@ -0,0 +1,87 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Request__
+#define __gnu_java_net_protocol_http_Request__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Authenticator;
+ class HTTPConnection;
+ class Headers;
+ class Request;
+ class RequestBodyWriter;
+ class Response;
+ class ResponseHeaderHandler;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Request : public ::java::lang::Object
+{
+
+public: // actually protected
+ Request(::gnu::java::net::protocol::http::HTTPConnection *, ::java::lang::String *, ::java::lang::String *);
+public:
+ virtual ::gnu::java::net::protocol::http::HTTPConnection * getConnection();
+ virtual ::java::lang::String * getMethod();
+ virtual ::java::lang::String * getPath();
+ virtual ::java::lang::String * getRequestURI();
+ virtual ::gnu::java::net::protocol::http::Headers * getHeaders();
+ virtual ::java::lang::String * getHeader(::java::lang::String *);
+ virtual jint getIntHeader(::java::lang::String *);
+ virtual ::java::util::Date * getDateHeader(::java::lang::String *);
+ virtual void setHeader(::java::lang::String *, ::java::lang::String *);
+ virtual void setRequestBody(JArray< jbyte > *);
+ virtual void setRequestBodyWriter(::gnu::java::net::protocol::http::RequestBodyWriter *);
+ virtual void setResponseHeaderHandler(::java::lang::String *, ::gnu::java::net::protocol::http::ResponseHeaderHandler *);
+ virtual void setAuthenticator(::gnu::java::net::protocol::http::Authenticator *);
+ virtual ::gnu::java::net::protocol::http::Response * dispatch();
+public: // actually package-private
+ virtual ::gnu::java::net::protocol::http::Response * readResponse(::java::io::InputStream *);
+ virtual void notifyHeaderHandlers(::gnu::java::net::protocol::http::Headers *);
+private:
+ ::java::io::InputStream * createResponseBodyStream(::gnu::java::net::protocol::http::Headers *, jint, jint, ::java::io::InputStream *, jboolean);
+public: // actually package-private
+ virtual jboolean authenticate(::gnu::java::net::protocol::http::Response *, jint);
+ virtual ::java::util::Properties * parseAuthParams(::java::lang::String *);
+ virtual ::java::lang::String * unquote(::java::lang::String *);
+ virtual ::java::lang::String * getNonceCount(::java::lang::String *);
+ virtual JArray< jbyte > * generateNonce();
+ virtual ::java::lang::String * toHexString(JArray< jbyte > *);
+ virtual void handleSetCookie(::java::lang::String *);
+public: // actually protected
+ ::gnu::java::net::protocol::http::HTTPConnection * __attribute__((aligned(__alignof__( ::java::lang::Object)))) connection;
+ ::java::lang::String * method;
+ ::java::lang::String * path;
+ ::gnu::java::net::protocol::http::Headers * requestHeaders;
+ ::gnu::java::net::protocol::http::RequestBodyWriter * requestBodyWriter;
+ ::java::util::Map * responseHeaderHandlers;
+ ::gnu::java::net::protocol::http::Authenticator * authenticator;
+private:
+ jboolean dispatched;
+public: // actually package-private
+ JArray< jbyte > * nonce;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Request__
diff --git a/libjava/gnu/java/net/protocol/http/RequestBodyWriter.h b/libjava/gnu/java/net/protocol/http/RequestBodyWriter.h
new file mode 100644
index 000000000..1bd32bc86
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/RequestBodyWriter.h
@@ -0,0 +1,42 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_RequestBodyWriter__
+#define __gnu_java_net_protocol_http_RequestBodyWriter__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class RequestBodyWriter;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::RequestBodyWriter : public ::java::lang::Object
+{
+
+public:
+ virtual jint getContentLength() = 0;
+ virtual void reset() = 0;
+ virtual jint write(JArray< jbyte > *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_java_net_protocol_http_RequestBodyWriter__
diff --git a/libjava/gnu/java/net/protocol/http/Response.h b/libjava/gnu/java/net/protocol/http/Response.h
new file mode 100644
index 000000000..928b21247
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/Response.h
@@ -0,0 +1,61 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_Response__
+#define __gnu_java_net_protocol_http_Response__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Headers;
+ class Response;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::Response : public ::java::lang::Object
+{
+
+public: // actually protected
+ Response(jint, jint, jint, ::java::lang::String *, ::gnu::java::net::protocol::http::Headers *, ::java::io::InputStream *);
+public:
+ virtual jint getMajorVersion();
+ virtual jint getMinorVersion();
+ virtual jint getCode();
+ virtual jint getCodeClass();
+ virtual ::java::lang::String * getMessage();
+ virtual ::gnu::java::net::protocol::http::Headers * getHeaders();
+ virtual ::java::lang::String * getHeader(::java::lang::String *);
+ virtual jint getIntHeader(::java::lang::String *);
+ virtual jlong getLongHeader(::java::lang::String *);
+ virtual ::java::util::Date * getDateHeader(::java::lang::String *);
+ virtual jboolean isRedirect();
+ virtual jboolean isError();
+ virtual ::java::io::InputStream * getBody();
+public: // actually protected
+ jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) majorVersion;
+ jint minorVersion;
+ jint code;
+ ::java::lang::String * message;
+ ::gnu::java::net::protocol::http::Headers * headers;
+ ::java::io::InputStream * body;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_Response__
diff --git a/libjava/gnu/java/net/protocol/http/ResponseHeaderHandler.h b/libjava/gnu/java/net/protocol/http/ResponseHeaderHandler.h
new file mode 100644
index 000000000..055c019a1
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/ResponseHeaderHandler.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_ResponseHeaderHandler__
+#define __gnu_java_net_protocol_http_ResponseHeaderHandler__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class ResponseHeaderHandler;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::ResponseHeaderHandler : public ::java::lang::Object
+{
+
+public:
+ virtual void setValue(::java::lang::String *) = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_java_net_protocol_http_ResponseHeaderHandler__
diff --git a/libjava/gnu/java/net/protocol/http/SimpleCookieManager.h b/libjava/gnu/java/net/protocol/http/SimpleCookieManager.h
new file mode 100644
index 000000000..fc0b0bf32
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/http/SimpleCookieManager.h
@@ -0,0 +1,48 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_http_SimpleCookieManager__
+#define __gnu_java_net_protocol_http_SimpleCookieManager__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace http
+ {
+ class Cookie;
+ class SimpleCookieManager;
+ }
+ }
+ }
+ }
+ }
+}
+
+class gnu::java::net::protocol::http::SimpleCookieManager : public ::java::lang::Object
+{
+
+public:
+ SimpleCookieManager();
+ virtual void setCookie(::gnu::java::net::protocol::http::Cookie *);
+ virtual JArray< ::gnu::java::net::protocol::http::Cookie * > * getCookies(::java::lang::String *, jboolean, ::java::lang::String *);
+private:
+ void addCookies(::java::util::ArrayList *, ::java::lang::String *, jboolean, ::java::lang::String *, ::java::util::Date *);
+public: // actually protected
+ ::java::util::Map * __attribute__((aligned(__alignof__( ::java::lang::Object)))) cookies;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_http_SimpleCookieManager__
diff --git a/libjava/gnu/java/net/protocol/https/Handler.h b/libjava/gnu/java/net/protocol/https/Handler.h
new file mode 100644
index 000000000..ce077f08f
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/https/Handler.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_https_Handler__
+#define __gnu_java_net_protocol_https_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace https
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::https::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual jint getDefaultPort();
+public:
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_https_Handler__
diff --git a/libjava/gnu/java/net/protocol/jar/Connection$JarFileCache.h b/libjava/gnu/java/net/protocol/jar/Connection$JarFileCache.h
new file mode 100644
index 000000000..03744bc67
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/jar/Connection$JarFileCache.h
@@ -0,0 +1,50 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_jar_Connection$JarFileCache__
+#define __gnu_java_net_protocol_jar_Connection$JarFileCache__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace jar
+ {
+ class Connection$JarFileCache;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ }
+}
+
+class gnu::java::net::protocol::jar::Connection$JarFileCache : public ::java::lang::Object
+{
+
+public:
+ Connection$JarFileCache();
+ static ::java::util::jar::JarFile * get(::java::net::URL *, jboolean);
+private:
+ static ::java::util::Hashtable * cache;
+ static const jint READBUFSIZE = 4096;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_jar_Connection$JarFileCache__
diff --git a/libjava/gnu/java/net/protocol/jar/Connection.h b/libjava/gnu/java/net/protocol/jar/Connection.h
new file mode 100644
index 000000000..5456919fb
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/jar/Connection.h
@@ -0,0 +1,62 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_jar_Connection__
+#define __gnu_java_net_protocol_jar_Connection__
+
+#pragma interface
+
+#include <java/net/JarURLConnection.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace jar
+ {
+ class Connection;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ }
+ namespace text
+ {
+ class SimpleDateFormat;
+ }
+ }
+}
+
+class gnu::java::net::protocol::jar::Connection : public ::java::net::JarURLConnection
+{
+
+public: // actually protected
+ Connection(::java::net::URL *);
+public:
+ void connect();
+ ::java::io::InputStream * getInputStream();
+ ::java::util::jar::JarFile * getJarFile();
+ ::java::lang::String * getHeaderField(::java::lang::String *);
+ jint getContentLength();
+ jlong getLastModified();
+private:
+ static ::java::text::SimpleDateFormat * dateFormat;
+ ::java::util::jar::JarFile * __attribute__((aligned(__alignof__( ::java::net::JarURLConnection)))) jar_file;
+ ::java::util::jar::JarEntry * jar_entry;
+ ::java::net::URL * jar_url;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_jar_Connection__
diff --git a/libjava/gnu/java/net/protocol/jar/Handler.h b/libjava/gnu/java/net/protocol/jar/Handler.h
new file mode 100644
index 000000000..b5fb6b66e
--- /dev/null
+++ b/libjava/gnu/java/net/protocol/jar/Handler.h
@@ -0,0 +1,54 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_java_net_protocol_jar_Handler__
+#define __gnu_java_net_protocol_jar_Handler__
+
+#pragma interface
+
+#include <java/net/URLStreamHandler.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace java
+ {
+ namespace net
+ {
+ namespace protocol
+ {
+ namespace jar
+ {
+ class Handler;
+ }
+ }
+ }
+ }
+ }
+ namespace java
+ {
+ namespace net
+ {
+ class URL;
+ class URLConnection;
+ }
+ }
+}
+
+class gnu::java::net::protocol::jar::Handler : public ::java::net::URLStreamHandler
+{
+
+public:
+ Handler();
+public: // actually protected
+ virtual ::java::net::URLConnection * openConnection(::java::net::URL *);
+ virtual void parseURL(::java::net::URL *, ::java::lang::String *, jint, jint);
+private:
+ static ::java::lang::String * flat(::java::lang::String *);
+public: // actually protected
+ virtual ::java::lang::String * toExternalForm(::java::net::URL *);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_java_net_protocol_jar_Handler__