diff options
Diffstat (limited to 'libjava/java/net')
68 files changed, 4729 insertions, 0 deletions
diff --git a/libjava/java/net/Authenticator.h b/libjava/java/net/Authenticator.h new file mode 100644 index 000000000..b8e26606b --- /dev/null +++ b/libjava/java/net/Authenticator.h @@ -0,0 +1,51 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Authenticator__ +#define __java_net_Authenticator__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class Authenticator; + class InetAddress; + class PasswordAuthentication; + } + } +} + +class java::net::Authenticator : public ::java::lang::Object +{ + +public: + static void setDefault(::java::net::Authenticator *); + static ::java::net::PasswordAuthentication * requestPasswordAuthentication(::java::net::InetAddress *, jint, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + static ::java::net::PasswordAuthentication * requestPasswordAuthentication(::java::lang::String *, ::java::net::InetAddress *, jint, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + Authenticator(); +public: // actually protected + virtual ::java::net::InetAddress * getRequestingSite(); + virtual ::java::lang::String * getRequestingHost(); + virtual jint getRequestingPort(); + virtual ::java::lang::String * getRequestingProtocol(); + virtual ::java::lang::String * getRequestingPrompt(); + virtual ::java::lang::String * getRequestingScheme(); + virtual ::java::net::PasswordAuthentication * getPasswordAuthentication(); +private: + static ::java::net::Authenticator * defaultAuthenticator; + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) host; + ::java::net::InetAddress * addr; + jint port; + ::java::lang::String * protocol; + ::java::lang::String * prompt; + ::java::lang::String * scheme; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Authenticator__ diff --git a/libjava/java/net/BindException.h b/libjava/java/net/BindException.h new file mode 100644 index 000000000..6056f55f7 --- /dev/null +++ b/libjava/java/net/BindException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_BindException__ +#define __java_net_BindException__ + +#pragma interface + +#include <java/net/SocketException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class BindException; + } + } +} + +class java::net::BindException : public ::java::net::SocketException +{ + +public: + BindException(); + BindException(::java::lang::String *); +private: + static const jlong serialVersionUID = -5945005768251722951LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_BindException__ diff --git a/libjava/java/net/ConnectException.h b/libjava/java/net/ConnectException.h new file mode 100644 index 000000000..324ff1fe7 --- /dev/null +++ b/libjava/java/net/ConnectException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ConnectException__ +#define __java_net_ConnectException__ + +#pragma interface + +#include <java/net/SocketException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class ConnectException; + } + } +} + +class java::net::ConnectException : public ::java::net::SocketException +{ + +public: + ConnectException(); + ConnectException(::java::lang::String *); +private: + static const jlong serialVersionUID = 3831404271622369215LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_ConnectException__ diff --git a/libjava/java/net/ContentHandler.h b/libjava/java/net/ContentHandler.h new file mode 100644 index 000000000..62aecff06 --- /dev/null +++ b/libjava/java/net/ContentHandler.h @@ -0,0 +1,34 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ContentHandler__ +#define __java_net_ContentHandler__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class ContentHandler; + class URLConnection; + } + } +} + +class java::net::ContentHandler : public ::java::lang::Object +{ + +public: + ContentHandler(); + virtual ::java::lang::Object * getContent(::java::net::URLConnection *) = 0; + virtual ::java::lang::Object * getContent(::java::net::URLConnection *, JArray< ::java::lang::Class * > *); + static ::java::lang::Class class$; +}; + +#endif // __java_net_ContentHandler__ diff --git a/libjava/java/net/ContentHandlerFactory.h b/libjava/java/net/ContentHandlerFactory.h new file mode 100644 index 000000000..ca1533104 --- /dev/null +++ b/libjava/java/net/ContentHandlerFactory.h @@ -0,0 +1,30 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ContentHandlerFactory__ +#define __java_net_ContentHandlerFactory__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class ContentHandler; + class ContentHandlerFactory; + } + } +} + +class java::net::ContentHandlerFactory : public ::java::lang::Object +{ + +public: + virtual ::java::net::ContentHandler * createContentHandler(::java::lang::String *) = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_ContentHandlerFactory__ diff --git a/libjava/java/net/DatagramPacket.h b/libjava/java/net/DatagramPacket.h new file mode 100644 index 000000000..068329e05 --- /dev/null +++ b/libjava/java/net/DatagramPacket.h @@ -0,0 +1,60 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_DatagramPacket__ +#define __java_net_DatagramPacket__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class DatagramPacket; + class InetAddress; + class SocketAddress; + } + } +} + +class java::net::DatagramPacket : public ::java::lang::Object +{ + +public: + DatagramPacket(JArray< jbyte > *, jint, jint); + DatagramPacket(JArray< jbyte > *, jint); + DatagramPacket(JArray< jbyte > *, jint, jint, ::java::net::InetAddress *, jint); + DatagramPacket(JArray< jbyte > *, jint, ::java::net::InetAddress *, jint); + DatagramPacket(JArray< jbyte > *, jint, jint, ::java::net::SocketAddress *); + DatagramPacket(JArray< jbyte > *, jint, ::java::net::SocketAddress *); + ::java::net::InetAddress * getAddress(); + jint getPort(); + JArray< jbyte > * getData(); + jint getOffset(); + jint getLength(); + void setAddress(::java::net::InetAddress *); + void setPort(jint); + void setSocketAddress(::java::net::SocketAddress *); + ::java::net::SocketAddress * getSocketAddress(); + void setData(JArray< jbyte > *); + void setData(JArray< jbyte > *, jint, jint); + void setLength(jint); +private: + JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::lang::Object)))) buffer; + jint offset; +public: // actually package-private + jint length; + jint maxlen; +private: + ::java::net::InetAddress * address; + jint port; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_DatagramPacket__ diff --git a/libjava/java/net/DatagramSocket.h b/libjava/java/net/DatagramSocket.h new file mode 100644 index 000000000..a1761e115 --- /dev/null +++ b/libjava/java/net/DatagramSocket.h @@ -0,0 +1,87 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_DatagramSocket__ +#define __java_net_DatagramSocket__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class DatagramPacket; + class DatagramSocket; + class DatagramSocketImpl; + class DatagramSocketImplFactory; + class InetAddress; + class SocketAddress; + } + namespace nio + { + namespace channels + { + class DatagramChannel; + } + } + } +} + +class java::net::DatagramSocket : public ::java::lang::Object +{ + +public: // actually protected + DatagramSocket(::java::net::DatagramSocketImpl *); +public: + DatagramSocket(); + DatagramSocket(jint); + DatagramSocket(jint, ::java::net::InetAddress *); + DatagramSocket(::java::net::SocketAddress *); +public: // actually package-private + virtual ::java::net::DatagramSocketImpl * getImpl(); +public: + virtual void close(); + virtual ::java::net::InetAddress * getInetAddress(); + virtual jint getPort(); + virtual ::java::net::InetAddress * getLocalAddress(); + virtual jint getLocalPort(); + virtual jint getSoTimeout(); + virtual void setSoTimeout(jint); + virtual jint getSendBufferSize(); + virtual void setSendBufferSize(jint); + virtual jint getReceiveBufferSize(); + virtual void setReceiveBufferSize(jint); + virtual void connect(::java::net::InetAddress *, jint); + virtual void disconnect(); + virtual void receive(::java::net::DatagramPacket *); + virtual void send(::java::net::DatagramPacket *); + virtual void bind(::java::net::SocketAddress *); + virtual jboolean isClosed(); + virtual ::java::nio::channels::DatagramChannel * getChannel(); + virtual void connect(::java::net::SocketAddress *); + virtual jboolean isBound(); + virtual jboolean isConnected(); + virtual ::java::net::SocketAddress * getRemoteSocketAddress(); + virtual ::java::net::SocketAddress * getLocalSocketAddress(); + virtual void setReuseAddress(jboolean); + virtual jboolean getReuseAddress(); + virtual void setBroadcast(jboolean); + virtual jboolean getBroadcast(); + virtual void setTrafficClass(jint); + virtual jint getTrafficClass(); + static void setDatagramSocketImplFactory(::java::net::DatagramSocketImplFactory *); +private: + static ::java::net::DatagramSocketImplFactory * factory; + ::java::net::DatagramSocketImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) impl; + jboolean implCreated; + ::java::net::InetAddress * remoteAddress; + jint remotePort; + jboolean bound; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_DatagramSocket__ diff --git a/libjava/java/net/DatagramSocketImpl.h b/libjava/java/net/DatagramSocketImpl.h new file mode 100644 index 000000000..e29991b42 --- /dev/null +++ b/libjava/java/net/DatagramSocketImpl.h @@ -0,0 +1,60 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_DatagramSocketImpl__ +#define __java_net_DatagramSocketImpl__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class DatagramPacket; + class DatagramSocketImpl; + class InetAddress; + class NetworkInterface; + class SocketAddress; + } + } +} + +class java::net::DatagramSocketImpl : public ::java::lang::Object +{ + +public: + DatagramSocketImpl(); +public: // actually protected + virtual void bind(jint, ::java::net::InetAddress *) = 0; + virtual void close() = 0; + virtual void create() = 0; + virtual jint peek(::java::net::InetAddress *) = 0; + virtual jint peekData(::java::net::DatagramPacket *) = 0; + virtual void send(::java::net::DatagramPacket *) = 0; + virtual void receive(::java::net::DatagramPacket *) = 0; + virtual void connect(::java::net::InetAddress *, jint); + virtual void disconnect(); + virtual void setTTL(jbyte) = 0; + virtual jbyte getTTL() = 0; + virtual void setTimeToLive(jint) = 0; + virtual jint getTimeToLive() = 0; + virtual void join(::java::net::InetAddress *) = 0; + virtual void leave(::java::net::InetAddress *) = 0; + virtual void joinGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *) = 0; + virtual void leaveGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *) = 0; + virtual ::java::io::FileDescriptor * getFileDescriptor(); + virtual jint getLocalPort(); +public: + virtual void setOption(jint, ::java::lang::Object *) = 0; + virtual ::java::lang::Object * getOption(jint) = 0; +public: // actually protected + jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) localPort; + ::java::io::FileDescriptor * fd; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_DatagramSocketImpl__ diff --git a/libjava/java/net/DatagramSocketImplFactory.h b/libjava/java/net/DatagramSocketImplFactory.h new file mode 100644 index 000000000..15e1780ec --- /dev/null +++ b/libjava/java/net/DatagramSocketImplFactory.h @@ -0,0 +1,30 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_DatagramSocketImplFactory__ +#define __java_net_DatagramSocketImplFactory__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class DatagramSocketImpl; + class DatagramSocketImplFactory; + } + } +} + +class java::net::DatagramSocketImplFactory : public ::java::lang::Object +{ + +public: + virtual ::java::net::DatagramSocketImpl * createDatagramSocketImpl() = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_DatagramSocketImplFactory__ diff --git a/libjava/java/net/FileNameMap.h b/libjava/java/net/FileNameMap.h new file mode 100644 index 000000000..916f14023 --- /dev/null +++ b/libjava/java/net/FileNameMap.h @@ -0,0 +1,29 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_FileNameMap__ +#define __java_net_FileNameMap__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class FileNameMap; + } + } +} + +class java::net::FileNameMap : public ::java::lang::Object +{ + +public: + virtual ::java::lang::String * getContentTypeFor(::java::lang::String *) = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_FileNameMap__ diff --git a/libjava/java/net/HttpURLConnection.h b/libjava/java/net/HttpURLConnection.h new file mode 100644 index 000000000..d192e33ad --- /dev/null +++ b/libjava/java/net/HttpURLConnection.h @@ -0,0 +1,101 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_HttpURLConnection__ +#define __java_net_HttpURLConnection__ + +#pragma interface + +#include <java/net/URLConnection.h> +extern "Java" +{ + namespace java + { + namespace net + { + class HttpURLConnection; + class URL; + } + namespace security + { + class Permission; + } + } +} + +class java::net::HttpURLConnection : public ::java::net::URLConnection +{ + +public: // actually protected + HttpURLConnection(::java::net::URL *); +public: + virtual void disconnect() = 0; + virtual jboolean usingProxy() = 0; + static void setFollowRedirects(jboolean); + static jboolean getFollowRedirects(); + virtual jboolean getInstanceFollowRedirects(); + virtual void setInstanceFollowRedirects(jboolean); + virtual void setRequestMethod(::java::lang::String *); + virtual ::java::lang::String * getRequestMethod(); + virtual jint getResponseCode(); + virtual ::java::lang::String * getResponseMessage(); +private: + void getResponseVals(); +public: + virtual ::java::security::Permission * getPermission(); + virtual ::java::io::InputStream * getErrorStream(); + virtual jlong getHeaderFieldDate(::java::lang::String *, jlong); +public: // actually package-private + static const jint HTTP_CONTINUE = 100; +public: + static const jint HTTP_OK = 200; + static const jint HTTP_CREATED = 201; + static const jint HTTP_ACCEPTED = 202; + static const jint HTTP_NOT_AUTHORITATIVE = 203; + static const jint HTTP_NO_CONTENT = 204; + static const jint HTTP_RESET = 205; + static const jint HTTP_PARTIAL = 206; + static const jint HTTP_MULT_CHOICE = 300; + static const jint HTTP_MOVED_PERM = 301; + static const jint HTTP_MOVED_TEMP = 302; + static const jint HTTP_SEE_OTHER = 303; + static const jint HTTP_NOT_MODIFIED = 304; + static const jint HTTP_USE_PROXY = 305; + static const jint HTTP_BAD_REQUEST = 400; + static const jint HTTP_UNAUTHORIZED = 401; + static const jint HTTP_PAYMENT_REQUIRED = 402; + static const jint HTTP_FORBIDDEN = 403; + static const jint HTTP_NOT_FOUND = 404; + static const jint HTTP_BAD_METHOD = 405; + static const jint HTTP_NOT_ACCEPTABLE = 406; + static const jint HTTP_PROXY_AUTH = 407; + static const jint HTTP_CLIENT_TIMEOUT = 408; + static const jint HTTP_CONFLICT = 409; + static const jint HTTP_GONE = 410; + static const jint HTTP_LENGTH_REQUIRED = 411; + static const jint HTTP_PRECON_FAILED = 412; + static const jint HTTP_ENTITY_TOO_LARGE = 413; + static const jint HTTP_REQ_TOO_LONG = 414; + static const jint HTTP_UNSUPPORTED_TYPE = 415; + static const jint HTTP_SERVER_ERROR = 500; + static const jint HTTP_INTERNAL_ERROR = 500; + static const jint HTTP_NOT_IMPLEMENTED = 501; + static const jint HTTP_BAD_GATEWAY = 502; + static const jint HTTP_UNAVAILABLE = 503; + static const jint HTTP_GATEWAY_TIMEOUT = 504; + static const jint HTTP_VERSION = 505; +private: + static jboolean followRedirects; + static ::java::lang::String * valid_methods; +public: // actually protected + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) method; + jint responseCode; + ::java::lang::String * responseMessage; + jboolean instanceFollowRedirects; +private: + jboolean gotResponseVals; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_HttpURLConnection__ diff --git a/libjava/java/net/Inet4Address.h b/libjava/java/net/Inet4Address.h new file mode 100644 index 000000000..5ff131546 --- /dev/null +++ b/libjava/java/net/Inet4Address.h @@ -0,0 +1,52 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Inet4Address__ +#define __java_net_Inet4Address__ + +#pragma interface + +#include <java/net/InetAddress.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class Inet4Address; + } + } +} + +class java::net::Inet4Address : public ::java::net::InetAddress +{ + + ::java::lang::Object * writeReplace(); +public: // actually package-private + Inet4Address(JArray< jbyte > *, ::java::lang::String *); +public: + jboolean isMulticastAddress(); + jboolean isLoopbackAddress(); + jboolean isAnyLocalAddress(); + jboolean isLinkLocalAddress(); + jboolean isSiteLocalAddress(); + jboolean isMCGlobal(); + jboolean isMCNodeLocal(); + jboolean isMCLinkLocal(); + jboolean isMCSiteLocal(); + jboolean isMCOrgLocal(); + JArray< jbyte > * getAddress(); + ::java::lang::String * getHostAddress(); + jint hashCode(); + jboolean equals(::java::lang::Object *); +public: // actually package-private + static const jlong serialVersionUID = 3286316764910316507LL; +private: + static const jint AF_INET = 2; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Inet4Address__ diff --git a/libjava/java/net/Inet6Address.h b/libjava/java/net/Inet6Address.h new file mode 100644 index 000000000..933a4780a --- /dev/null +++ b/libjava/java/net/Inet6Address.h @@ -0,0 +1,66 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Inet6Address__ +#define __java_net_Inet6Address__ + +#pragma interface + +#include <java/net/InetAddress.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class Inet6Address; + class NetworkInterface; + } + } +} + +class java::net::Inet6Address : public ::java::net::InetAddress +{ + +public: // actually package-private + Inet6Address(JArray< jbyte > *, ::java::lang::String *); +public: + jboolean isMulticastAddress(); + jboolean isAnyLocalAddress(); + jboolean isLoopbackAddress(); + jboolean isLinkLocalAddress(); + jboolean isSiteLocalAddress(); + jboolean isMCGlobal(); + jboolean isMCNodeLocal(); + jboolean isMCLinkLocal(); + jboolean isMCSiteLocal(); + jboolean isMCOrgLocal(); + JArray< jbyte > * getAddress(); + static ::java::net::Inet6Address * getByAddress(::java::lang::String *, JArray< jbyte > *, jint); + static ::java::net::Inet6Address * getByAddress(::java::lang::String *, JArray< jbyte > *, ::java::net::NetworkInterface *); + ::java::net::NetworkInterface * getScopedInterface(); + jint getScopeId(); + ::java::lang::String * getHostAddress(); + jint hashCode(); + jboolean equals(::java::lang::Object *); + jboolean isIPv4CompatibleAddress(); +private: + void readObject(::java::io::ObjectInputStream *); + void writeObject(::java::io::ObjectOutputStream *); +public: // actually package-private + static const jlong serialVersionUID = 6880410070516793377LL; + JArray< jbyte > * __attribute__((aligned(__alignof__( ::java::net::InetAddress)))) ipaddress; +private: + jint scope_id; + jboolean scope_id_set; + jboolean scope_ifname_set; + ::java::lang::String * ifname; + ::java::net::NetworkInterface * nif; + static const jint AF_INET6 = 10; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Inet6Address__ diff --git a/libjava/java/net/InetAddress.h b/libjava/java/net/InetAddress.h new file mode 100644 index 000000000..8cde4fb5d --- /dev/null +++ b/libjava/java/net/InetAddress.h @@ -0,0 +1,76 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_InetAddress__ +#define __java_net_InetAddress__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + } + } +} + +class java::net::InetAddress : public ::java::lang::Object +{ + +public: // actually package-private + InetAddress(JArray< jbyte > *, ::java::lang::String *, jint); +public: + virtual jboolean isMulticastAddress(); + virtual jboolean isAnyLocalAddress(); + virtual jboolean isLoopbackAddress(); + virtual jboolean isLinkLocalAddress(); + virtual jboolean isSiteLocalAddress(); + virtual jboolean isMCGlobal(); + virtual jboolean isMCNodeLocal(); + virtual jboolean isMCLinkLocal(); + virtual jboolean isMCSiteLocal(); + virtual jboolean isMCOrgLocal(); + virtual ::java::lang::String * getHostName(); +public: // actually package-private + virtual ::java::lang::String * internalGetCanonicalHostName(); +public: + virtual ::java::lang::String * getCanonicalHostName(); + virtual JArray< jbyte > * getAddress(); + virtual ::java::lang::String * getHostAddress(); + virtual jint hashCode(); + virtual jboolean equals(::java::lang::Object *); + virtual ::java::lang::String * toString(); + static ::java::net::InetAddress * getByAddress(JArray< jbyte > *); + static ::java::net::InetAddress * getByAddress(::java::lang::String *, JArray< jbyte > *); +public: // actually package-private + static ::java::net::InetAddress * getByLiteral(::java::lang::String *); +public: + static ::java::net::InetAddress * getByName(::java::lang::String *); + static JArray< ::java::net::InetAddress * > * getAllByName(::java::lang::String *); + static ::java::net::InetAddress * getLocalHost(); +private: + ::java::lang::Object * readResolve(); + void readObject(::java::io::ObjectInputStream *); + void writeObject(::java::io::ObjectOutputStream *); + static const jlong serialVersionUID = 3286316764910316507LL; +public: // actually package-private + static ::java::net::InetAddress * ANY_IF; + static ::java::net::InetAddress * LOCALHOST; +private: + jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) address; +public: // actually package-private + JArray< jbyte > * addr; + ::java::lang::String * hostName; +private: + jint family; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_InetAddress__ diff --git a/libjava/java/net/InetSocketAddress.h b/libjava/java/net/InetSocketAddress.h new file mode 100644 index 000000000..b4f14d41c --- /dev/null +++ b/libjava/java/net/InetSocketAddress.h @@ -0,0 +1,49 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_InetSocketAddress__ +#define __java_net_InetSocketAddress__ + +#pragma interface + +#include <java/net/SocketAddress.h> +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class InetSocketAddress; + } + } +} + +class java::net::InetSocketAddress : public ::java::net::SocketAddress +{ + +public: + InetSocketAddress(::java::net::InetAddress *, jint); + InetSocketAddress(jint); + InetSocketAddress(::java::lang::String *, jint); +private: + InetSocketAddress(::java::lang::String *, jint, jboolean); +public: + static ::java::net::InetSocketAddress * createUnresolved(::java::lang::String *, jint); + virtual jboolean equals(::java::lang::Object *); + virtual ::java::net::InetAddress * getAddress(); + virtual ::java::lang::String * getHostName(); + virtual jint getPort(); + virtual jint hashCode(); + virtual jboolean isUnresolved(); + virtual ::java::lang::String * toString(); +private: + static const jlong serialVersionUID = 5076001401234631237LL; + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::net::SocketAddress)))) hostname; + ::java::net::InetAddress * addr; + jint port; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_InetSocketAddress__ diff --git a/libjava/java/net/JarURLConnection.h b/libjava/java/net/JarURLConnection.h new file mode 100644 index 000000000..6c89e6e4d --- /dev/null +++ b/libjava/java/net/JarURLConnection.h @@ -0,0 +1,56 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_JarURLConnection__ +#define __java_net_JarURLConnection__ + +#pragma interface + +#include <java/net/URLConnection.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class JarURLConnection; + class URL; + class URLConnection; + } + namespace security + { + namespace cert + { + class Certificate; + } + } + } +} + +class java::net::JarURLConnection : public ::java::net::URLConnection +{ + +public: // actually protected + JarURLConnection(::java::net::URL *); +public: + virtual ::java::net::URL * getJarFileURL(); + virtual ::java::lang::String * getEntryName(); + virtual ::java::util::jar::JarEntry * getJarEntry(); + virtual ::java::util::jar::JarFile * getJarFile() = 0; + virtual JArray< ::java::security::cert::Certificate * > * getCertificates(); + virtual ::java::util::jar::Attributes * getMainAttributes(); + virtual ::java::util::jar::Attributes * getAttributes(); + virtual ::java::util::jar::Manifest * getManifest(); +private: + ::java::net::URL * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) jarFileURL; +public: // actually protected + ::java::net::URLConnection * jarFileURLConnection; +private: + ::java::lang::String * entryName; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_JarURLConnection__ diff --git a/libjava/java/net/MalformedURLException.h b/libjava/java/net/MalformedURLException.h new file mode 100644 index 000000000..713bf5e7d --- /dev/null +++ b/libjava/java/net/MalformedURLException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_MalformedURLException__ +#define __java_net_MalformedURLException__ + +#pragma interface + +#include <java/io/IOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class MalformedURLException; + } + } +} + +class java::net::MalformedURLException : public ::java::io::IOException +{ + +public: + MalformedURLException(); + MalformedURLException(::java::lang::String *); +private: + static const jlong serialVersionUID = -182787522200415866LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_MalformedURLException__ diff --git a/libjava/java/net/MimeTypeMapper.h b/libjava/java/net/MimeTypeMapper.h new file mode 100644 index 000000000..06fb2679e --- /dev/null +++ b/libjava/java/net/MimeTypeMapper.h @@ -0,0 +1,39 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_MimeTypeMapper__ +#define __java_net_MimeTypeMapper__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class MimeTypeMapper; + } + } +} + +class java::net::MimeTypeMapper : public ::java::lang::Object +{ + +public: + MimeTypeMapper(); + static void fillFromFile(::java::util::Map *, ::java::lang::String *); + virtual ::java::lang::String * getContentTypeFor(::java::lang::String *); + static void main(JArray< ::java::lang::String * > *); +public: // actually protected + static JArray< JArray< ::java::lang::String * > * > * mime_strings; +private: + ::java::util::Hashtable * __attribute__((aligned(__alignof__( ::java::lang::Object)))) mime_types; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_MimeTypeMapper__ diff --git a/libjava/java/net/MulticastSocket.h b/libjava/java/net/MulticastSocket.h new file mode 100644 index 000000000..2faac45e3 --- /dev/null +++ b/libjava/java/net/MulticastSocket.h @@ -0,0 +1,50 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_MulticastSocket__ +#define __java_net_MulticastSocket__ + +#pragma interface + +#include <java/net/DatagramSocket.h> +extern "Java" +{ + namespace java + { + namespace net + { + class DatagramPacket; + class InetAddress; + class MulticastSocket; + class NetworkInterface; + class SocketAddress; + } + } +} + +class java::net::MulticastSocket : public ::java::net::DatagramSocket +{ + +public: + MulticastSocket(); + MulticastSocket(jint); + MulticastSocket(::java::net::SocketAddress *); + virtual ::java::net::InetAddress * getInterface(); + virtual jbyte getTTL(); + virtual jint getTimeToLive(); + virtual void setInterface(::java::net::InetAddress *); + virtual void setNetworkInterface(::java::net::NetworkInterface *); + virtual ::java::net::NetworkInterface * getNetworkInterface(); + virtual void setLoopbackMode(jboolean); + virtual jboolean getLoopbackMode(); + virtual void setTTL(jbyte); + virtual void setTimeToLive(jint); + virtual void joinGroup(::java::net::InetAddress *); + virtual void leaveGroup(::java::net::InetAddress *); + virtual void joinGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *); + virtual void leaveGroup(::java::net::SocketAddress *, ::java::net::NetworkInterface *); + virtual void send(::java::net::DatagramPacket *, jbyte); + static ::java::lang::Class class$; +}; + +#endif // __java_net_MulticastSocket__ diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java new file mode 100644 index 000000000..efd66b3d5 --- /dev/null +++ b/libjava/java/net/MulticastSocket.java @@ -0,0 +1,519 @@ +/* MulticastSocket.java -- Class for using multicast sockets + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 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 java.net; + +import java.io.IOException; +import java.util.Enumeration; + + +/** + * 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 class models a multicast UDP socket. A multicast address is a + * class D internet address (one whose most significant bits are 1110). + * A multicast group consists of a multicast address and a well known + * port number. All members of the group listening on that address and + * port will receive all the broadcasts to the group. + * <p> + * Please note that applets are not allowed to use multicast sockets + * + * 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. + * + * @author Warren Levy (warrenl@cygnus.com) + * @author Aaron M. Renn (arenn@urbanophile.com) (Documentation comments) + * @since 1.1 + * @date May 18, 1999. + */ +public class MulticastSocket extends DatagramSocket +{ + /** + * Create a MulticastSocket that this not bound to any address + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation + */ + public MulticastSocket() throws IOException + { + this(new InetSocketAddress(0)); + } + + /** + * Create a multicast socket bound to the specified port + * + * @param port The port to bind to + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation + */ + public MulticastSocket(int port) throws IOException + { + this(new InetSocketAddress(port)); + } + + /** + * Create a multicast socket bound to the specified SocketAddress. + * + * @param address The SocketAddress the multicast socket will be bound to + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation + * + * @since 1.4 + */ + public MulticastSocket(SocketAddress address) throws IOException + { + super((SocketAddress) null); + setReuseAddress(true); + if (address != null) + bind(address); + } + + /** + * Returns the interface being used for multicast packets + * + * @return The multicast interface + * + * @exception SocketException If an error occurs + */ + public InetAddress getInterface() throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); + } + + /** + * Returns the current value of the "Time to Live" option. This is the + * number of hops a packet can make before it "expires". This method id + * deprecated. Use <code>getTimeToLive</code> instead. + * + * @return The TTL value + * + * @exception IOException If an error occurs + * + * @deprecated 1.2 Replaced by getTimeToLive() + * + * @see MulticastSocket#getTimeToLive() + */ + public byte getTTL() throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + // Use getTTL here rather than getTimeToLive in case we're using an impl + // other than the default PlainDatagramSocketImpl and it doesn't have + // getTimeToLive yet. + return getImpl().getTTL(); + } + + /** + * Returns the current value of the "Time to Live" option. This is the + * number of hops a packet can make before it "expires". + * + * @return The TTL value + * + * @exception IOException If an error occurs + * + * @since 1.2 + */ + public int getTimeToLive() throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + return getImpl().getTimeToLive(); + } + + /** + * Sets the interface to use for sending multicast packets. + * + * @param addr The new interface to use. + * + * @exception SocketException If an error occurs. + * + * @since 1.4 + */ + public void setInterface(InetAddress addr) throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr); + } + + /** + * Sets the local network interface used to send multicast messages + * + * @param netIf The local network interface used to send multicast messages + * + * @exception SocketException If an error occurs + * + * @see MulticastSocket#getNetworkInterface() + * + * @since 1.4 + */ + public void setNetworkInterface(NetworkInterface netIf) + throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + InetAddress address; + if (netIf != null) + out: + { + Enumeration e = netIf.getInetAddresses(); + if (getLocalAddress() instanceof Inet4Address) + { + // Search for a IPv4 address. + while (e.hasMoreElements()) + { + address = (InetAddress) e.nextElement(); + if (address instanceof Inet4Address) + break out; + } + throw new SocketException("interface " + netIf.getName() + " has no IPv6 address"); + } + else if (getLocalAddress() instanceof Inet6Address) + { + // Search for a IPv6 address. + while (e.hasMoreElements()) + { + address = (InetAddress) e.nextElement(); + if (address instanceof Inet6Address) + break out; + } + throw new SocketException("interface " + netIf.getName() + " has no IPv6 address"); + } + else + throw new SocketException("interface " + netIf.getName() + " has no suitable IP address"); + } + else + address = InetAddress.ANY_IF; + + + getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address); + } + + /** + * Gets the local network interface which is used to send multicast messages + * + * @return The local network interface to send multicast messages + * + * @exception SocketException If an error occurs + * + * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) + * + * @since 1.4 + */ + public NetworkInterface getNetworkInterface() throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + InetAddress address = + (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); + + // FIXME: libgcj doesn't have createAnyInterface. +// if (address.isAnyLocalAddress()) +// return NetworkInterface.createAnyInterface(); + + NetworkInterface netIf = NetworkInterface.getByInetAddress(address); + + return netIf; + } + + /** + * Disable/Enable local loopback of multicast packets. The option is used by + * the platform's networking code as a hint for setting whether multicast + * data will be looped back to the local socket. + * + * Because this option is a hint, applications that want to verify what + * loopback mode is set to should call #getLoopbackMode + * + * @param disable True to disable loopback mode + * + * @exception SocketException If an error occurs + * + * @since 1.4 + */ + public void setLoopbackMode(boolean disable) throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP, + Boolean.valueOf(disable)); + } + + /** + * Checks if local loopback mode is enabled + * + * @return true if loopback mode is enabled, false otherwise + * + * @exception SocketException If an error occurs + * + * @since 1.4 + */ + public boolean getLoopbackMode() throws SocketException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + Object buf = getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP); + + if (buf instanceof Boolean) + return ((Boolean) buf).booleanValue(); + + throw new SocketException("unexpected type"); + } + + /** + * Sets the "Time to Live" value for a socket. The value must be between + * 1 and 255. + * + * @param ttl The new TTL value + * + * @exception IOException If an error occurs + * + * @deprecated 1.2 Replaced by <code>setTimeToLive</code> + * + * @see MulticastSocket#setTimeToLive(int ttl) + */ + public void setTTL(byte ttl) throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + // Use setTTL here rather than setTimeToLive in case we're using an impl + // other than the default PlainDatagramSocketImpl and it doesn't have + // setTimeToLive yet. + getImpl().setTTL(ttl); + } + + /** + * Sets the "Time to Live" value for a socket. The value must be between + * 0 and 255, inclusive. + * + * @param ttl The new TTL value + * + * @exception IOException If an error occurs + * + * @since 1.2 + */ + public void setTimeToLive(int ttl) throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + if (ttl < 0 || ttl > 255) + throw new IllegalArgumentException("Invalid ttl: " + ttl); + + getImpl().setTimeToLive(ttl); + } + + /** + * Joins the specified multicast group. + * + * @param mcastaddr The address of the group to join + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkMulticast method doesn't allow the operation + */ + public void joinGroup(InetAddress mcastaddr) throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + if (! mcastaddr.isMulticastAddress()) + throw new IOException("Not a Multicast address"); + + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkMulticast(mcastaddr); + + getImpl().join(mcastaddr); + } + + /** + * Leaves the specified multicast group + * + * @param mcastaddr The address of the group to leave + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkMulticast method doesn't allow the operation + */ + public void leaveGroup(InetAddress mcastaddr) throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + if (! mcastaddr.isMulticastAddress()) + throw new IOException("Not a Multicast address"); + + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkMulticast(mcastaddr); + + getImpl().leave(mcastaddr); + } + + /** + * Joins the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to join + * @param netIf The local network interface to receive the multicast + * messages on or null to defer the interface set by #setInterface or + * #setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException If a security manager exists and its + * checkMulticast method doesn't allow the operation + * + * @see MulticastSocket#setInterface(InetAddress addr) + * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) + * + * @since 1.4 + */ + public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + if (! (mcastaddr instanceof InetSocketAddress)) + throw new IllegalArgumentException("SocketAddress type not supported"); + + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress().isMulticastAddress()) + throw new IOException("Not a Multicast address"); + + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkMulticast(tmp.getAddress()); + + getImpl().joinGroup(mcastaddr, netIf); + } + + /** + * Leaves the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to leave + * @param netIf The local networki interface or null to defer to the + * interface set by setInterface or setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException If a security manager exists and its + * checkMulticast method doesn't allow the operation + * + * @see MulticastSocket#setInterface(InetAddress addr) + * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf) + * + * @since 1.4 + */ + public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress().isMulticastAddress()) + throw new IOException("Not a Multicast address"); + + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkMulticast(tmp.getAddress()); + + getImpl().leaveGroup(mcastaddr, netIf); + } + + /** + * Sends a packet of data to a multicast address with a TTL that is + * different from the default TTL on this socket. The default TTL for + * the socket is not changed. + * + * @param packet The packet of data to send + * @param ttl The TTL for this packet + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkConnect or checkMulticast method doesn't allow the operation + * + * @deprecated + */ + public synchronized void send(DatagramPacket packet, byte ttl) + throws IOException + { + if (isClosed()) + throw new SocketException("socket is closed"); + + SecurityManager s = System.getSecurityManager(); + if (s != null) + { + InetAddress addr = packet.getAddress(); + if (addr.isMulticastAddress()) + s.checkPermission(new SocketPermission(addr.getHostName() + + packet.getPort(), + "accept,connect")); + else + s.checkConnect(addr.getHostAddress(), packet.getPort()); + } + + int oldttl = getImpl().getTimeToLive(); + getImpl().setTimeToLive(((int) ttl) & 0xFF); + getImpl().send(packet); + getImpl().setTimeToLive(oldttl); + } +} diff --git a/libjava/java/net/NetPermission.h b/libjava/java/net/NetPermission.h new file mode 100644 index 000000000..a6c88555b --- /dev/null +++ b/libjava/java/net/NetPermission.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_NetPermission__ +#define __java_net_NetPermission__ + +#pragma interface + +#include <java/security/BasicPermission.h> +extern "Java" +{ + namespace java + { + namespace net + { + class NetPermission; + } + } +} + +class java::net::NetPermission : public ::java::security::BasicPermission +{ + +public: + NetPermission(::java::lang::String *); + NetPermission(::java::lang::String *, ::java::lang::String *); +public: // actually package-private + static const jlong serialVersionUID = -8343910153355041693LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_NetPermission__ diff --git a/libjava/java/net/NetworkInterface.h b/libjava/java/net/NetworkInterface.h new file mode 100644 index 000000000..66898a212 --- /dev/null +++ b/libjava/java/net/NetworkInterface.h @@ -0,0 +1,50 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_NetworkInterface__ +#define __java_net_NetworkInterface__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class NetworkInterface; + } + } +} + +class java::net::NetworkInterface : public ::java::lang::Object +{ + +public: // actually package-private + NetworkInterface(::java::lang::String *, ::java::net::InetAddress *); + NetworkInterface(::java::lang::String *, JArray< ::java::net::InetAddress * > *); +public: + ::java::lang::String * getName(); + ::java::util::Enumeration * getInetAddresses(); + ::java::lang::String * getDisplayName(); + static ::java::net::NetworkInterface * getByName(::java::lang::String *); + static ::java::net::NetworkInterface * getByInetAddress(::java::net::InetAddress *); +private: + static ::java::util::Collection * condense(::java::util::Collection *); +public: + static ::java::util::Enumeration * getNetworkInterfaces(); + jboolean equals(::java::lang::Object *); + jint hashCode(); + ::java::lang::String * toString(); +private: + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) name; + ::java::util::Vector * inetAddresses; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_NetworkInterface__ diff --git a/libjava/java/net/NetworkInterface.java b/libjava/java/net/NetworkInterface.java new file mode 100644 index 000000000..7ad62a713 --- /dev/null +++ b/libjava/java/net/NetworkInterface.java @@ -0,0 +1,299 @@ +/* NetworkInterface.java -- + Copyright (C) 2002, 2003, 2004, 2005 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 java.net; + +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +/** + * This class models a network interface on the host computer. A network + * interface contains a name (typically associated with a specific + * hardware adapter) and a list of addresses that are bound to it. + * For example, an ethernet interface may be named "eth0" and have the + * address 192.168.1.101 assigned to it. + * + * @author Michael Koch (konqueror@gmx.de) + * @since 1.4 + */ +public final class NetworkInterface +{ + private String name; + private Vector<InetAddress> inetAddresses; + + NetworkInterface(String name, InetAddress address) + { + this.name = name; + this.inetAddresses = new Vector(1, 1); + this.inetAddresses.add(address); + } + + NetworkInterface(String name, InetAddress[] addresses) + { + this.name = name; + this.inetAddresses = new Vector(addresses.length, 1); + + for (int i = 0; i < addresses.length; i++) + this.inetAddresses.add(addresses[i]); + } + + /** + * Returns the name of the network interface + * + * @return The name of the interface. + */ + public String getName() + { + return name; + } + + /** + * Returns all available addresses of the network interface + * + * If a @see SecurityManager is available all addresses are checked + * with @see SecurityManager::checkConnect() if they are available. + * Only <code>InetAddresses</code> are returned where the security manager + * doesn't throw an exception. + * + * @return An enumeration of all addresses. + */ + public Enumeration<InetAddress> getInetAddresses() + { + SecurityManager s = System.getSecurityManager(); + + if (s == null) + return inetAddresses.elements(); + + Vector<InetAddress> tmpInetAddresses = new Vector<InetAddress>(1, 1); + + for (Enumeration<InetAddress> addresses = inetAddresses.elements(); + addresses.hasMoreElements();) + { + InetAddress addr = addresses.nextElement(); + try + { + s.checkConnect(addr.getHostAddress(), 58000); + tmpInetAddresses.add(addr); + } + catch (SecurityException e) + { + // Ignore. + } + } + + return tmpInetAddresses.elements(); + } + + /** + * Returns the display name of the interface + * + * @return The display name of the interface + */ + public String getDisplayName() + { + return name; + } + + /** + * Returns an network interface by name + * + * @param name The name of the interface to return + * + * @return a <code>NetworkInterface</code> object representing the interface, + * or null if there is no interface with that name. + * + * @exception SocketException If an error occurs + * @exception NullPointerException If the specified name is null + */ + public static NetworkInterface getByName(String name) + throws SocketException + { + for (Enumeration e = getNetworkInterfaces(); e.hasMoreElements();) + { + NetworkInterface tmp = (NetworkInterface) e.nextElement(); + + if (name.equals(tmp.getName())) + return tmp; + } + + // No interface with the given name found. + return null; + } + + /** + * Return a network interface by its address + * + * @param addr The address of the interface to return + * + * @return the interface, or <code>null</code> if none found + * + * @exception SocketException If an error occurs + * @exception NullPointerException If the specified addess is null + */ + public static NetworkInterface getByInetAddress(InetAddress addr) + throws SocketException + { + for (Enumeration interfaces = getNetworkInterfaces(); + interfaces.hasMoreElements();) + { + NetworkInterface tmp = (NetworkInterface) interfaces.nextElement(); + + for (Enumeration addresses = tmp.inetAddresses.elements(); + addresses.hasMoreElements();) + { + if (addr.equals((InetAddress) addresses.nextElement())) + return tmp; + } + } + + throw new SocketException("no network interface is bound to such an IP address"); + } + + static private Collection condense(Collection interfaces) + { + final Map condensed = new HashMap(); + + final Iterator interfs = interfaces.iterator(); + while (interfs.hasNext()) { + + final NetworkInterface face = (NetworkInterface) interfs.next(); + final String name = face.getName(); + + if (condensed.containsKey(name)) + { + final NetworkInterface conface = (NetworkInterface) condensed.get(name); + if (!conface.inetAddresses.containsAll(face.inetAddresses)) + { + final Iterator faceAddresses = face.inetAddresses.iterator(); + while (faceAddresses.hasNext()) + { + final InetAddress faceAddress = (InetAddress) faceAddresses.next(); + if (!conface.inetAddresses.contains(faceAddress)) + { + conface.inetAddresses.add(faceAddress); + } + } + } + } + else + { + condensed.put(name, face); + } + } + + return condensed.values(); + } + + /** + * Return an <code>Enumeration</code> of all available network interfaces + * + * @return all interfaces + * + * @exception SocketException If an error occurs + */ + public static Enumeration<NetworkInterface> getNetworkInterfaces() + throws SocketException + { + Vector<NetworkInterface> networkInterfaces = + VMNetworkInterface.getInterfaces(); + + if (networkInterfaces.isEmpty()) + return null; + + Collection condensed = condense(networkInterfaces); + + return Collections.enumeration(condensed); + } + + /** + * Checks if the current instance is equal to obj + * + * @param obj The object to compare with + * + * @return <code>true</code> if equal, <code>false</code> otherwise + */ + public boolean equals(Object obj) + { + if (! (obj instanceof NetworkInterface)) + return false; + + NetworkInterface tmp = (NetworkInterface) obj; + + return (name.equals(tmp.name) && inetAddresses.equals(tmp.inetAddresses)); + } + + /** + * Returns the hashcode of the current instance + * + * @return the hashcode + */ + public int hashCode() + { + // FIXME: hash correctly + return name.hashCode() + inetAddresses.hashCode(); + } + + /** + * Returns a string representation of the interface + * + * @return the string + */ + public String toString() + { + // FIXME: check if this is correct + String result; + String separator = System.getProperty("line.separator"); + + result = + "name: " + getDisplayName() + " (" + getName() + ") addresses:" + + separator; + + for (Enumeration e = inetAddresses.elements(); e.hasMoreElements();) + { + InetAddress address = (InetAddress) e.nextElement(); + result += address.toString() + ";" + separator; + } + + return result; + } +} diff --git a/libjava/java/net/NoRouteToHostException.h b/libjava/java/net/NoRouteToHostException.h new file mode 100644 index 000000000..7a639eaa7 --- /dev/null +++ b/libjava/java/net/NoRouteToHostException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_NoRouteToHostException__ +#define __java_net_NoRouteToHostException__ + +#pragma interface + +#include <java/net/SocketException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class NoRouteToHostException; + } + } +} + +class java::net::NoRouteToHostException : public ::java::net::SocketException +{ + +public: + NoRouteToHostException(); + NoRouteToHostException(::java::lang::String *); +private: + static const jlong serialVersionUID = -1897550894873493790LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_NoRouteToHostException__ diff --git a/libjava/java/net/PasswordAuthentication.h b/libjava/java/net/PasswordAuthentication.h new file mode 100644 index 000000000..2567fd0e5 --- /dev/null +++ b/libjava/java/net/PasswordAuthentication.h @@ -0,0 +1,37 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_PasswordAuthentication__ +#define __java_net_PasswordAuthentication__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class PasswordAuthentication; + } + } +} + +class java::net::PasswordAuthentication : public ::java::lang::Object +{ + +public: + PasswordAuthentication(::java::lang::String *, JArray< jchar > *); + ::java::lang::String * getUserName(); + JArray< jchar > * getPassword(); +private: + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) username; + JArray< jchar > * password; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_PasswordAuthentication__ diff --git a/libjava/java/net/PortUnreachableException.h b/libjava/java/net/PortUnreachableException.h new file mode 100644 index 000000000..5e0fff249 --- /dev/null +++ b/libjava/java/net/PortUnreachableException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_PortUnreachableException__ +#define __java_net_PortUnreachableException__ + +#pragma interface + +#include <java/net/SocketException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class PortUnreachableException; + } + } +} + +class java::net::PortUnreachableException : public ::java::net::SocketException +{ + +public: + PortUnreachableException(); + PortUnreachableException(::java::lang::String *); +private: + static const jlong serialVersionUID = 8462541992376507323LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_PortUnreachableException__ diff --git a/libjava/java/net/ProtocolException.h b/libjava/java/net/ProtocolException.h new file mode 100644 index 000000000..39e7b7b1e --- /dev/null +++ b/libjava/java/net/ProtocolException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ProtocolException__ +#define __java_net_ProtocolException__ + +#pragma interface + +#include <java/io/IOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class ProtocolException; + } + } +} + +class java::net::ProtocolException : public ::java::io::IOException +{ + +public: + ProtocolException(); + ProtocolException(::java::lang::String *); +private: + static const jlong serialVersionUID = -6098449442062388080LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_ProtocolException__ diff --git a/libjava/java/net/Proxy$Type.h b/libjava/java/net/Proxy$Type.h new file mode 100644 index 000000000..288bd8c51 --- /dev/null +++ b/libjava/java/net/Proxy$Type.h @@ -0,0 +1,40 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Proxy$Type__ +#define __java_net_Proxy$Type__ + +#pragma interface + +#include <java/lang/Enum.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class Proxy$Type; + } + } +} + +class java::net::Proxy$Type : public ::java::lang::Enum +{ + + Proxy$Type(::java::lang::String *, jint); +public: + static JArray< ::java::net::Proxy$Type * > * values(); + static ::java::net::Proxy$Type * valueOf(::java::lang::String *); + static ::java::net::Proxy$Type * DIRECT; + static ::java::net::Proxy$Type * HTTP; + static ::java::net::Proxy$Type * SOCKS; +private: + static const jlong serialVersionUID = -2231209257930100533LL; + static JArray< ::java::net::Proxy$Type * > * ENUM$VALUES; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Proxy$Type__ diff --git a/libjava/java/net/Proxy.h b/libjava/java/net/Proxy.h new file mode 100644 index 000000000..b6b44e3a6 --- /dev/null +++ b/libjava/java/net/Proxy.h @@ -0,0 +1,41 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Proxy__ +#define __java_net_Proxy__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class Proxy; + class Proxy$Type; + class SocketAddress; + } + } +} + +class java::net::Proxy : public ::java::lang::Object +{ + +public: + Proxy(::java::net::Proxy$Type *, ::java::net::SocketAddress *); + virtual ::java::net::SocketAddress * address(); + virtual ::java::net::Proxy$Type * type(); + virtual jboolean equals(::java::lang::Object *); + virtual jint hashCode(); + virtual ::java::lang::String * toString(); + static ::java::net::Proxy * NO_PROXY; +private: + ::java::net::Proxy$Type * __attribute__((aligned(__alignof__( ::java::lang::Object)))) type__; + ::java::net::SocketAddress * address__; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Proxy__ diff --git a/libjava/java/net/ProxySelector.h b/libjava/java/net/ProxySelector.h new file mode 100644 index 000000000..62382ee58 --- /dev/null +++ b/libjava/java/net/ProxySelector.h @@ -0,0 +1,38 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ProxySelector__ +#define __java_net_ProxySelector__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class ProxySelector; + class SocketAddress; + class URI; + } + } +} + +class java::net::ProxySelector : public ::java::lang::Object +{ + +public: + ProxySelector(); + static ::java::net::ProxySelector * getDefault(); + static void setDefault(::java::net::ProxySelector *); + virtual void connectFailed(::java::net::URI *, ::java::net::SocketAddress *, ::java::io::IOException *) = 0; + virtual ::java::util::List * select(::java::net::URI *) = 0; +private: + static ::java::net::ProxySelector * defaultSelector; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_ProxySelector__ diff --git a/libjava/java/net/ResolverCache$Entry.h b/libjava/java/net/ResolverCache$Entry.h new file mode 100644 index 000000000..22b5da83f --- /dev/null +++ b/libjava/java/net/ResolverCache$Entry.h @@ -0,0 +1,32 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ResolverCache$Entry__ +#define __java_net_ResolverCache$Entry__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class ResolverCache$Entry; + } + } +} + +class java::net::ResolverCache$Entry : public ::java::lang::Object +{ + +public: + ResolverCache$Entry(::java::lang::Object *, ::java::lang::Object *); + ::java::lang::Object * __attribute__((aligned(__alignof__( ::java::lang::Object)))) key; + ::java::lang::Object * value; + jlong expires; + static ::java::lang::Class class$; +}; + +#endif // __java_net_ResolverCache$Entry__ diff --git a/libjava/java/net/ResolverCache.h b/libjava/java/net/ResolverCache.h new file mode 100644 index 000000000..d274d235c --- /dev/null +++ b/libjava/java/net/ResolverCache.h @@ -0,0 +1,51 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ResolverCache__ +#define __java_net_ResolverCache__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class ResolverCache; + class ResolverCache$Entry; + } + } +} + +class java::net::ResolverCache : public ::java::lang::Object +{ + +public: // actually package-private + ResolverCache(); +private: + static jint getTTL(::java::lang::String *, jint); +public: + static ::java::lang::String * getHostByAddr(JArray< jbyte > *); + static JArray< JArray< jbyte > * > * getHostByName(::java::lang::String *); +private: + static ::java::lang::Object * makeHashableAddress(JArray< jbyte > *); + static ::java::net::ResolverCache$Entry * get(::java::lang::Object *); + static void put(::java::net::ResolverCache$Entry *); + static void reap(); +public: // actually package-private + static jint access$0(); + static jint access$1(); +private: + static jint POSITIVE_TTL; + static jint NEGATIVE_TTL; + static ::java::util::HashMap * cache; + static ::java::util::LinkedList * killqueue; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_ResolverCache__ diff --git a/libjava/java/net/ServerSocket.h b/libjava/java/net/ServerSocket.h new file mode 100644 index 000000000..98c77c61b --- /dev/null +++ b/libjava/java/net/ServerSocket.h @@ -0,0 +1,85 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_ServerSocket__ +#define __java_net_ServerSocket__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace gnu + { + namespace java + { + namespace net + { + class PlainSocketImpl; + } + } + } + namespace java + { + namespace net + { + class InetAddress; + class InetSocketAddress; + class ServerSocket; + class Socket; + class SocketAddress; + class SocketImpl; + class SocketImplFactory; + } + namespace nio + { + namespace channels + { + class ServerSocketChannel; + } + } + } +} + +class java::net::ServerSocket : public ::java::lang::Object +{ + +public: // actually package-private + ServerSocket(::gnu::java::net::PlainSocketImpl *); + virtual ::java::net::SocketImpl * getImpl(); +public: + ServerSocket(); + ServerSocket(jint); + ServerSocket(jint, jint); + ServerSocket(jint, jint, ::java::net::InetAddress *); + virtual void bind(::java::net::SocketAddress *); + virtual void bind(::java::net::SocketAddress *, jint); + virtual ::java::net::InetAddress * getInetAddress(); + virtual jint getLocalPort(); + virtual ::java::net::SocketAddress * getLocalSocketAddress(); + virtual ::java::net::Socket * accept(); +public: // actually protected + virtual void implAccept(::java::net::Socket *); +public: + virtual void close(); + virtual ::java::nio::channels::ServerSocketChannel * getChannel(); + virtual jboolean isBound(); + virtual jboolean isClosed(); + virtual void setSoTimeout(jint); + virtual jint getSoTimeout(); + virtual void setReuseAddress(jboolean); + virtual jboolean getReuseAddress(); + virtual void setReceiveBufferSize(jint); + virtual jint getReceiveBufferSize(); + virtual ::java::lang::String * toString(); + static void setSocketFactory(::java::net::SocketImplFactory *); +private: + static ::java::net::SocketImplFactory * factory; + ::java::net::SocketImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) impl; + ::java::net::InetSocketAddress * local; + jint port; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_ServerSocket__ diff --git a/libjava/java/net/Socket.h b/libjava/java/net/Socket.h new file mode 100644 index 000000000..776d6fc47 --- /dev/null +++ b/libjava/java/net/Socket.h @@ -0,0 +1,103 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_Socket__ +#define __java_net_Socket__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class Socket; + class SocketAddress; + class SocketImpl; + class SocketImplFactory; + } + namespace nio + { + namespace channels + { + class SocketChannel; + } + } + } +} + +class java::net::Socket : public ::java::lang::Object +{ + +public: + Socket(); +public: // actually protected + Socket(::java::net::SocketImpl *); +public: + Socket(::java::lang::String *, jint); + Socket(::java::net::InetAddress *, jint); + Socket(::java::lang::String *, jint, ::java::net::InetAddress *, jint); + Socket(::java::net::InetAddress *, jint, ::java::net::InetAddress *, jint); + Socket(::java::lang::String *, jint, jboolean); + Socket(::java::net::InetAddress *, jint, jboolean); +private: + Socket(::java::net::InetAddress *, jint, ::java::net::InetAddress *, jint, jboolean); + ::java::net::SocketImpl * getImpl(); +public: + virtual void bind(::java::net::SocketAddress *); + virtual void connect(::java::net::SocketAddress *); + virtual void connect(::java::net::SocketAddress *, jint); + virtual ::java::net::InetAddress * getInetAddress(); + virtual ::java::net::InetAddress * getLocalAddress(); + virtual jint getPort(); + virtual jint getLocalPort(); + virtual ::java::net::SocketAddress * getLocalSocketAddress(); + virtual ::java::net::SocketAddress * getRemoteSocketAddress(); + virtual ::java::io::InputStream * getInputStream(); + virtual ::java::io::OutputStream * getOutputStream(); + virtual void setTcpNoDelay(jboolean); + virtual jboolean getTcpNoDelay(); + virtual void setSoLinger(jboolean, jint); + virtual jint getSoLinger(); + virtual void sendUrgentData(jint); + virtual void setOOBInline(jboolean); + virtual jboolean getOOBInline(); + virtual void setSoTimeout(jint); + virtual jint getSoTimeout(); + virtual void setSendBufferSize(jint); + virtual jint getSendBufferSize(); + virtual void setReceiveBufferSize(jint); + virtual jint getReceiveBufferSize(); + virtual void setKeepAlive(jboolean); + virtual jboolean getKeepAlive(); + virtual void close(); + virtual ::java::lang::String * toString(); + static void setSocketImplFactory(::java::net::SocketImplFactory *); + virtual void shutdownInput(); + virtual void shutdownOutput(); + virtual ::java::nio::channels::SocketChannel * getChannel(); + virtual jboolean getReuseAddress(); + virtual void setReuseAddress(jboolean); + virtual jint getTrafficClass(); + virtual void setTrafficClass(jint); + virtual jboolean isConnected(); + virtual jboolean isBound(); + virtual jboolean isClosed(); + virtual jboolean isInputShutdown(); + virtual jboolean isOutputShutdown(); +public: // actually package-private + static ::java::net::SocketImplFactory * factory; + ::java::net::SocketImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) impl; + jboolean implCreated; + jboolean bound; +private: + jboolean inputShutdown; + jboolean outputShutdown; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_Socket__ diff --git a/libjava/java/net/SocketAddress.h b/libjava/java/net/SocketAddress.h new file mode 100644 index 000000000..42f0f21b1 --- /dev/null +++ b/libjava/java/net/SocketAddress.h @@ -0,0 +1,32 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketAddress__ +#define __java_net_SocketAddress__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class SocketAddress; + } + } +} + +class java::net::SocketAddress : public ::java::lang::Object +{ + +public: + SocketAddress(); +public: // actually package-private + static const jlong serialVersionUID = 5215720748342549866LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_SocketAddress__ diff --git a/libjava/java/net/SocketException.h b/libjava/java/net/SocketException.h new file mode 100644 index 000000000..563e7f13b --- /dev/null +++ b/libjava/java/net/SocketException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketException__ +#define __java_net_SocketException__ + +#pragma interface + +#include <java/io/IOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class SocketException; + } + } +} + +class java::net::SocketException : public ::java::io::IOException +{ + +public: + SocketException(); + SocketException(::java::lang::String *); +private: + static const jlong serialVersionUID = -5935874303556886934LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_SocketException__ diff --git a/libjava/java/net/SocketImpl.h b/libjava/java/net/SocketImpl.h new file mode 100644 index 000000000..0daf5146d --- /dev/null +++ b/libjava/java/net/SocketImpl.h @@ -0,0 +1,63 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketImpl__ +#define __java_net_SocketImpl__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class SocketAddress; + class SocketImpl; + } + } +} + +class java::net::SocketImpl : public ::java::lang::Object +{ + +public: + SocketImpl(); +public: // actually protected + virtual void create(jboolean) = 0; + virtual void connect(::java::lang::String *, jint) = 0; + virtual void connect(::java::net::InetAddress *, jint) = 0; + virtual void connect(::java::net::SocketAddress *, jint) = 0; + virtual void bind(::java::net::InetAddress *, jint) = 0; + virtual void listen(jint) = 0; + virtual void accept(::java::net::SocketImpl *) = 0; + virtual ::java::io::InputStream * getInputStream() = 0; + virtual ::java::io::OutputStream * getOutputStream() = 0; + virtual jint available() = 0; + virtual void close() = 0; + virtual ::java::io::FileDescriptor * getFileDescriptor(); + virtual ::java::net::InetAddress * getInetAddress(); + virtual jint getPort(); + virtual jboolean supportsUrgentData(); + virtual void sendUrgentData(jint) = 0; + virtual jint getLocalPort(); +public: + virtual ::java::lang::String * toString(); +public: // actually protected + virtual void shutdownInput(); + virtual void shutdownOutput(); +public: + virtual void setOption(jint, ::java::lang::Object *) = 0; + virtual ::java::lang::Object * getOption(jint) = 0; +public: // actually protected + ::java::net::InetAddress * __attribute__((aligned(__alignof__( ::java::lang::Object)))) address; + ::java::io::FileDescriptor * fd; + jint localport; + jint port; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_SocketImpl__ diff --git a/libjava/java/net/SocketImplFactory.h b/libjava/java/net/SocketImplFactory.h new file mode 100644 index 000000000..2089846df --- /dev/null +++ b/libjava/java/net/SocketImplFactory.h @@ -0,0 +1,30 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketImplFactory__ +#define __java_net_SocketImplFactory__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class SocketImpl; + class SocketImplFactory; + } + } +} + +class java::net::SocketImplFactory : public ::java::lang::Object +{ + +public: + virtual ::java::net::SocketImpl * createSocketImpl() = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_SocketImplFactory__ diff --git a/libjava/java/net/SocketOptions.h b/libjava/java/net/SocketOptions.h new file mode 100644 index 000000000..6a56d1346 --- /dev/null +++ b/libjava/java/net/SocketOptions.h @@ -0,0 +1,44 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketOptions__ +#define __java_net_SocketOptions__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class SocketOptions; + } + } +} + +class java::net::SocketOptions : public ::java::lang::Object +{ + +public: + virtual void setOption(jint, ::java::lang::Object *) = 0; + virtual ::java::lang::Object * getOption(jint) = 0; + static const jint SO_KEEPALIVE = 8; + static const jint SO_LINGER = 128; + static const jint SO_TIMEOUT = 4102; + static const jint SO_BINDADDR = 15; + static const jint SO_SNDBUF = 4097; + static const jint SO_RCVBUF = 4098; + static const jint SO_REUSEADDR = 4; + static const jint SO_BROADCAST = 32; + static const jint SO_OOBINLINE = 4099; + static const jint TCP_NODELAY = 1; + static const jint IP_MULTICAST_IF = 16; + static const jint IP_MULTICAST_IF2 = 31; + static const jint IP_MULTICAST_LOOP = 18; + static const jint IP_TOS = 3; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_SocketOptions__ diff --git a/libjava/java/net/SocketPermission.h b/libjava/java/net/SocketPermission.h new file mode 100644 index 000000000..dae8e83af --- /dev/null +++ b/libjava/java/net/SocketPermission.h @@ -0,0 +1,68 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketPermission__ +#define __java_net_SocketPermission__ + +#pragma interface + +#include <java/security/Permission.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class SocketPermission; + } + namespace security + { + class Permission; + class PermissionCollection; + } + } +} + +class java::net::SocketPermission : public ::java::security::Permission +{ + +public: + SocketPermission(::java::lang::String *, ::java::lang::String *); +private: + static ::java::lang::String * processHostport(::java::lang::String *); + void setHostPort(::java::lang::String *); + void setActions(::java::lang::String *); + void setAction(::java::lang::String *); +public: + jboolean equals(::java::lang::Object *); + jint hashCode(); + ::java::lang::String * getActions(); + ::java::security::PermissionCollection * newPermissionCollection(); +private: + JArray< ::java::net::InetAddress * > * getAddresses(); + ::java::lang::String * getCanonicalHostName(); +public: + jboolean implies(::java::security::Permission *); +private: + void readObject(::java::io::ObjectInputStream *); + void writeObject(::java::io::ObjectOutputStream *); +public: // actually package-private + static const jlong serialVersionUID = -7204263841984476862LL; +private: + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::security::Permission)))) hostname; + ::java::net::InetAddress * address; + jint minport; + jint maxport; + static const jint MIN_PORT = 0; + static const jint MAX_PORT = 2147483647; + ::java::lang::String * actions; + jint actionmask; + static JArray< ::java::lang::String * > * ACTIONS; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_SocketPermission__ diff --git a/libjava/java/net/SocketTimeoutException.h b/libjava/java/net/SocketTimeoutException.h new file mode 100644 index 000000000..a32424b91 --- /dev/null +++ b/libjava/java/net/SocketTimeoutException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_SocketTimeoutException__ +#define __java_net_SocketTimeoutException__ + +#pragma interface + +#include <java/io/InterruptedIOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class SocketTimeoutException; + } + } +} + +class java::net::SocketTimeoutException : public ::java::io::InterruptedIOException +{ + +public: + SocketTimeoutException(); + SocketTimeoutException(::java::lang::String *); +private: + static const jlong serialVersionUID = -8846654841826352300LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_SocketTimeoutException__ diff --git a/libjava/java/net/URI.h b/libjava/java/net/URI.h new file mode 100644 index 000000000..143b35a74 --- /dev/null +++ b/libjava/java/net/URI.h @@ -0,0 +1,144 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URI__ +#define __java_net_URI__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace gnu + { + namespace java + { + namespace lang + { + class CPStringBuilder; + } + } + } + namespace java + { + namespace net + { + class URI; + class URL; + } + } +} + +class java::net::URI : public ::java::lang::Object +{ + + void readObject(::java::io::ObjectInputStream *); + void writeObject(::java::io::ObjectOutputStream *); + static ::java::lang::String * getURIGroup(::java::util::regex::Matcher *, jint); + void parseURI(::java::lang::String *); + static ::java::lang::String * unquote(::java::lang::String *); + static ::java::lang::String * quote(::java::lang::String *); + static ::java::lang::String * quoteAuthority(::java::lang::String *); + static ::java::lang::String * quote(::java::lang::String *, ::java::lang::String *); + static ::java::lang::String * quoteHost(::java::lang::String *); + static ::java::lang::String * quotePath(::java::lang::String *); + static ::java::lang::String * quoteUserInfo(::java::lang::String *); +public: + URI(::java::lang::String *); + URI(::java::lang::String *, ::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + URI(::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + URI(::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + URI(::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + static ::java::net::URI * create(::java::lang::String *); + ::java::net::URI * parseServerAuthority(); + ::java::net::URI * normalize(); +private: + ::java::lang::String * normalizePath(::java::lang::String *); + void removeLastSegment(::gnu::java::lang::CPStringBuilder *); +public: + ::java::net::URI * resolve(::java::net::URI *); + ::java::net::URI * resolve(::java::lang::String *); + ::java::net::URI * relativize(::java::net::URI *); + ::java::net::URL * toURL(); + ::java::lang::String * getScheme(); + jboolean isAbsolute(); + jboolean isOpaque(); + ::java::lang::String * getRawSchemeSpecificPart(); + ::java::lang::String * getSchemeSpecificPart(); + ::java::lang::String * getRawAuthority(); + ::java::lang::String * getAuthority(); + ::java::lang::String * getRawUserInfo(); + ::java::lang::String * getUserInfo(); + ::java::lang::String * getHost(); + jint getPort(); + ::java::lang::String * getRawPath(); + ::java::lang::String * getPath(); + ::java::lang::String * getRawQuery(); + ::java::lang::String * getQuery(); + ::java::lang::String * getRawFragment(); + ::java::lang::String * getFragment(); + jboolean equals(::java::lang::Object *); + jint hashCode(); + jint URI$compareTo(::java::net::URI *); +private: + jint compareFragments(::java::net::URI *); +public: + ::java::lang::String * toString(); + ::java::lang::String * toASCIIString(); +private: + static ::java::lang::String * escapeCharacters(::java::lang::String *); +public: + jint compareTo(::java::lang::Object *); +public: // actually package-private + static const jlong serialVersionUID = -6052424284110960213LL; +private: + static ::java::lang::String * URI_REGEXP; + static ::java::lang::String * AUTHORITY_REGEXP; + static ::java::lang::String * RFC2396_DIGIT; + static ::java::lang::String * RFC2396_LOWALPHA; + static ::java::lang::String * RFC2396_UPALPHA; + static ::java::lang::String * RFC2396_ALPHA; + static ::java::lang::String * RFC2396_ALPHANUM; + static ::java::lang::String * RFC3986_UNRESERVED; + static ::java::lang::String * RFC3986_SUBDELIMS; + static ::java::lang::String * RFC3986_REG_NAME; + static ::java::lang::String * RFC3986_PCHAR; + static ::java::lang::String * RFC3986_SEGMENT; + static ::java::lang::String * RFC3986_PATH_SEGMENTS; + static ::java::lang::String * RFC3986_SSP; + static ::java::lang::String * RFC3986_HOST; + static ::java::lang::String * RFC3986_USERINFO; + static const jint SCHEME_GROUP = 2; + static const jint SCHEME_SPEC_PART_GROUP = 3; + static const jint AUTHORITY_GROUP = 5; + static const jint PATH_GROUP = 6; + static const jint QUERY_GROUP = 8; + static const jint FRAGMENT_GROUP = 10; + static const jint AUTHORITY_USERINFO_GROUP = 2; + static const jint AUTHORITY_HOST_GROUP = 3; + static const jint AUTHORITY_PORT_GROUP = 5; + static ::java::util::regex::Pattern * URI_PATTERN; + static ::java::util::regex::Pattern * AUTHORITY_PATTERN; + static ::java::lang::String * HEX; + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) scheme; + ::java::lang::String * rawSchemeSpecificPart; + ::java::lang::String * schemeSpecificPart; + ::java::lang::String * rawAuthority; + ::java::lang::String * authority; + ::java::lang::String * rawUserInfo; + ::java::lang::String * userInfo; + ::java::lang::String * rawHost; + ::java::lang::String * host; + jint port; + ::java::lang::String * rawPath; + ::java::lang::String * path; + ::java::lang::String * rawQuery; + ::java::lang::String * query; + ::java::lang::String * rawFragment; + ::java::lang::String * fragment; + ::java::lang::String * string; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URI__ diff --git a/libjava/java/net/URISyntaxException.h b/libjava/java/net/URISyntaxException.h new file mode 100644 index 000000000..93f1a4e66 --- /dev/null +++ b/libjava/java/net/URISyntaxException.h @@ -0,0 +1,39 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URISyntaxException__ +#define __java_net_URISyntaxException__ + +#pragma interface + +#include <java/lang/Exception.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URISyntaxException; + } + } +} + +class java::net::URISyntaxException : public ::java::lang::Exception +{ + +public: + URISyntaxException(::java::lang::String *, ::java::lang::String *); + URISyntaxException(::java::lang::String *, ::java::lang::String *, jint); + virtual ::java::lang::String * getInput(); + virtual ::java::lang::String * getReason(); + virtual jint getIndex(); + virtual ::java::lang::String * getMessage(); +private: + static const jlong serialVersionUID = 2137979680897488891LL; + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Exception)))) input; + jint index; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URISyntaxException__ diff --git a/libjava/java/net/URL$1.h b/libjava/java/net/URL$1.h new file mode 100644 index 000000000..c2867dc07 --- /dev/null +++ b/libjava/java/net/URL$1.h @@ -0,0 +1,32 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URL$1__ +#define __java_net_URL$1__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URL$1; + } + } +} + +class java::net::URL$1 : public ::java::lang::Object +{ + +public: // actually package-private + URL$1(); +public: + virtual ::java::lang::ClassLoader * URL$1$run(); + virtual ::java::lang::Object * run(); + static ::java::lang::Class class$; +}; + +#endif // __java_net_URL$1__ diff --git a/libjava/java/net/URL.h b/libjava/java/net/URL.h new file mode 100644 index 000000000..f0553c968 --- /dev/null +++ b/libjava/java/net/URL.h @@ -0,0 +1,92 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URL__ +#define __java_net_URL__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class URI; + class URL; + class URLConnection; + class URLStreamHandler; + class URLStreamHandlerFactory; + } + } +} + +class java::net::URL : public ::java::lang::Object +{ + +public: + URL(::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *); + URL(::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + URL(::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::net::URLStreamHandler *); + URL(::java::lang::String *); + URL(::java::net::URL *, ::java::lang::String *); + URL(::java::net::URL *, ::java::lang::String *, ::java::net::URLStreamHandler *); +private: + URL(::java::net::URL *, ::java::lang::String *, ::java::net::URLStreamHandler *, jboolean); +public: + jboolean equals(::java::lang::Object *); + ::java::lang::Object * getContent(); + ::java::lang::Object * getContent(JArray< ::java::lang::Class * > *); + ::java::lang::String * getFile(); + ::java::lang::String * getPath(); + ::java::lang::String * getAuthority(); + ::java::lang::String * getHost(); + jint getPort(); + jint getDefaultPort(); + ::java::lang::String * getProtocol(); + ::java::lang::String * getRef(); + ::java::lang::String * getUserInfo(); + ::java::lang::String * getQuery(); + jint hashCode(); + ::java::net::URLConnection * openConnection(); + ::java::io::InputStream * openStream(); + jboolean sameFile(::java::net::URL *); +public: // actually protected + void set(::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::lang::String *); + void set(::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); +public: + static void setURLStreamHandlerFactory(::java::net::URLStreamHandlerFactory *); + ::java::lang::String * toExternalForm(); + ::java::lang::String * toString(); +private: + static ::java::net::URLStreamHandler * getURLStreamHandler(::java::lang::String *); + void readObject(::java::io::ObjectInputStream *); + void writeObject(::java::io::ObjectOutputStream *); +public: + ::java::net::URI * toURI(); +private: + static ::java::lang::String * DEFAULT_SEARCH_PATH; + static ::java::lang::ClassLoader * systemClassLoader; + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) protocol; + ::java::lang::String * authority; + ::java::lang::String * host; + ::java::lang::String * userInfo; + jint port; + ::java::lang::String * file; + ::java::lang::String * ref; + jint hashCode__; +public: // actually package-private + ::java::net::URLStreamHandler * ph; +private: + static ::java::net::URLStreamHandlerFactory * factory; + static const jlong serialVersionUID = -7627629688361524110LL; + static ::java::util::HashMap * ph_cache; + static jboolean cache_handlers; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URL__ diff --git a/libjava/java/net/URLClassLoader$1.h b/libjava/java/net/URLClassLoader$1.h new file mode 100644 index 000000000..5eb7da2dc --- /dev/null +++ b/libjava/java/net/URLClassLoader$1.h @@ -0,0 +1,46 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLClassLoader$1__ +#define __java_net_URLClassLoader$1__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class URLClassLoader; + class URLClassLoader$1; + } + namespace security + { + class CodeSource; + } + } +} + +class java::net::URLClassLoader$1 : public ::java::lang::Object +{ + +public: // actually package-private + URLClassLoader$1(::java::net::URLClassLoader *, ::java::lang::String *, JArray< jbyte > *, ::java::security::CodeSource *); +public: + virtual ::java::lang::Class * URLClassLoader$1$run(); + virtual ::java::lang::Object * run(); +public: // actually package-private + ::java::net::URLClassLoader * __attribute__((aligned(__alignof__( ::java::lang::Object)))) this$0; +private: + ::java::lang::String * val$className; + JArray< jbyte > * val$classData; + ::java::security::CodeSource * val$source; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLClassLoader$1__ diff --git a/libjava/java/net/URLClassLoader$2.h b/libjava/java/net/URLClassLoader$2.h new file mode 100644 index 000000000..165bfd77d --- /dev/null +++ b/libjava/java/net/URLClassLoader$2.h @@ -0,0 +1,37 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLClassLoader$2__ +#define __java_net_URLClassLoader$2__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URLClassLoader; + class URLClassLoader$2; + } + } +} + +class java::net::URLClassLoader$2 : public ::java::lang::Object +{ + +public: // actually package-private + URLClassLoader$2(::java::lang::ClassLoader *, ::java::lang::Object *); +public: + virtual ::java::net::URLClassLoader * URLClassLoader$2$run(); + virtual ::java::lang::Object * run(); +private: + ::java::lang::ClassLoader * __attribute__((aligned(__alignof__( ::java::lang::Object)))) val$parent; + ::java::lang::Object * val$securityContext; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLClassLoader$2__ diff --git a/libjava/java/net/URLClassLoader.h b/libjava/java/net/URLClassLoader.h new file mode 100644 index 000000000..2e5f15c9b --- /dev/null +++ b/libjava/java/net/URLClassLoader.h @@ -0,0 +1,91 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLClassLoader__ +#define __java_net_URLClassLoader__ + +#pragma interface + +#include <java/security/SecureClassLoader.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace gnu + { + namespace java + { + namespace net + { + namespace loader + { + class Resource; + class URLStreamHandlerCache; + } + } + } + } + namespace java + { + namespace net + { + class URL; + class URLClassLoader; + class URLStreamHandlerFactory; + } + namespace security + { + class AccessControlContext; + class CodeSource; + class PermissionCollection; + } + } +} + +class java::net::URLClassLoader : public ::java::security::SecureClassLoader +{ + +public: + URLClassLoader(JArray< ::java::net::URL * > *); + URLClassLoader(JArray< ::java::net::URL * > *, ::java::lang::ClassLoader *); +public: // actually package-private + URLClassLoader(::java::lang::ClassLoader *, ::java::security::AccessControlContext *); +public: + URLClassLoader(JArray< ::java::net::URL * > *, ::java::lang::ClassLoader *, ::java::net::URLStreamHandlerFactory *); +public: // actually protected + virtual void addURL(::java::net::URL *); +private: + void addURLImpl(::java::net::URL *); + void addURLs(JArray< ::java::net::URL * > *); + ::java::lang::String * getAttributeValue(::java::util::jar::Attributes$Name *, ::java::util::jar::Attributes *, ::java::util::jar::Attributes *); +public: // actually protected + virtual ::java::lang::Package * definePackage(::java::lang::String *, ::java::util::jar::Manifest *, ::java::net::URL *); + virtual ::java::lang::Class * findClass(::java::lang::String *); +public: + virtual ::java::lang::String * toString(); +private: + ::gnu::java::net::loader::Resource * findURLResource(::java::lang::String *); +public: + virtual ::java::net::URL * findResource(::java::lang::String *); + virtual ::java::util::Enumeration * findResources(::java::lang::String *); +public: // actually protected + virtual ::java::security::PermissionCollection * getPermissions(::java::security::CodeSource *); +public: + virtual JArray< ::java::net::URL * > * getURLs(); + static ::java::net::URLClassLoader * newInstance(JArray< ::java::net::URL * > *); + static ::java::net::URLClassLoader * newInstance(JArray< ::java::net::URL * > *, ::java::lang::ClassLoader *); +public: // actually package-private + static ::java::lang::Class * access$0(::java::net::URLClassLoader *, ::java::lang::String *, JArray< jbyte > *, jint, jint, ::java::security::CodeSource *); +private: + static ::gnu::java::net::loader::URLStreamHandlerCache * factoryCache; + static ::java::lang::String * URL_LOADER_PREFIX; + ::java::util::Vector * __attribute__((aligned(__alignof__( ::java::security::SecureClassLoader)))) urls; + ::java::util::Vector * urlinfos; + ::java::net::URLStreamHandlerFactory * factory; + ::java::security::AccessControlContext * securityContext; + ::java::lang::String * thisString; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLClassLoader__ diff --git a/libjava/java/net/URLConnection.h b/libjava/java/net/URLConnection.h new file mode 100644 index 000000000..c40d9598b --- /dev/null +++ b/libjava/java/net/URLConnection.h @@ -0,0 +1,117 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLConnection__ +#define __java_net_URLConnection__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class ContentHandler; + class ContentHandlerFactory; + class FileNameMap; + class URL; + class URLConnection; + } + namespace security + { + class Permission; + } + namespace text + { + class ParsePosition; + class SimpleDateFormat; + } + } +} + +class java::net::URLConnection : public ::java::lang::Object +{ + +public: // actually protected + URLConnection(::java::net::URL *); +public: + virtual void connect() = 0; + virtual ::java::net::URL * getURL(); + virtual jint getConnectTimeout(); + virtual void setConnectTimeout(jint); + virtual jint getReadTimeout(); + virtual void setReadTimeout(jint); + virtual jint getContentLength(); + virtual ::java::lang::String * getContentType(); + virtual ::java::lang::String * getContentEncoding(); + virtual jlong getExpiration(); + virtual jlong getDate(); + virtual jlong getLastModified(); + virtual ::java::lang::String * getHeaderField(jint); + virtual ::java::lang::String * getHeaderField(::java::lang::String *); + virtual ::java::util::Map * getHeaderFields(); + virtual jint getHeaderFieldInt(::java::lang::String *, jint); + virtual jlong getHeaderFieldDate(::java::lang::String *, jlong); + virtual ::java::lang::String * getHeaderFieldKey(jint); + virtual ::java::lang::Object * getContent(); + virtual ::java::lang::Object * getContent(JArray< ::java::lang::Class * > *); + virtual ::java::security::Permission * getPermission(); + virtual ::java::io::InputStream * getInputStream(); + virtual ::java::io::OutputStream * getOutputStream(); + virtual ::java::lang::String * toString(); + virtual void setDoInput(jboolean); + virtual jboolean getDoInput(); + virtual void setDoOutput(jboolean); + virtual jboolean getDoOutput(); + virtual void setAllowUserInteraction(jboolean); + virtual jboolean getAllowUserInteraction(); + static void setDefaultAllowUserInteraction(jboolean); + static jboolean getDefaultAllowUserInteraction(); + virtual void setUseCaches(jboolean); + virtual jboolean getUseCaches(); + virtual void setIfModifiedSince(jlong); + virtual jlong getIfModifiedSince(); + virtual jboolean getDefaultUseCaches(); + virtual void setDefaultUseCaches(jboolean); + virtual void setRequestProperty(::java::lang::String *, ::java::lang::String *); + virtual void addRequestProperty(::java::lang::String *, ::java::lang::String *); + virtual ::java::lang::String * getRequestProperty(::java::lang::String *); + virtual ::java::util::Map * getRequestProperties(); + static void setDefaultRequestProperty(::java::lang::String *, ::java::lang::String *); + static ::java::lang::String * getDefaultRequestProperty(::java::lang::String *); + static void setContentHandlerFactory(::java::net::ContentHandlerFactory *); + static ::java::lang::String * guessContentTypeFromName(::java::lang::String *); + static ::java::lang::String * guessContentTypeFromStream(::java::io::InputStream *); + static ::java::net::FileNameMap * getFileNameMap(); + static void setFileNameMap(::java::net::FileNameMap *); +private: + ::java::net::ContentHandler * getContentHandler(::java::lang::String *); + static void initializeDateFormats(); + static ::java::net::FileNameMap * fileNameMap; + static ::java::net::ContentHandlerFactory * factory; + static jboolean defaultAllowUserInteraction; + static jboolean defaultUseCaches; + static ::java::net::ContentHandlerFactory * defaultFactory; +public: // actually protected + jboolean __attribute__((aligned(__alignof__( ::java::lang::Object)))) allowUserInteraction; + jboolean connected; + jboolean doInput; + jboolean doOutput; + jboolean useCaches; + jlong ifModifiedSince; + ::java::net::URL * url; +private: + static JArray< ::java::text::SimpleDateFormat * > * dateFormats; + static jboolean dateformats_initialized; + jint connectTimeout; + jint readTimeout; + ::java::text::ParsePosition * position; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLConnection__ diff --git a/libjava/java/net/URLDecoder.h b/libjava/java/net/URLDecoder.h new file mode 100644 index 000000000..a6586cf74 --- /dev/null +++ b/libjava/java/net/URLDecoder.h @@ -0,0 +1,31 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLDecoder__ +#define __java_net_URLDecoder__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URLDecoder; + } + } +} + +class java::net::URLDecoder : public ::java::lang::Object +{ + +public: + URLDecoder(); + static ::java::lang::String * decode(::java::lang::String *); + static ::java::lang::String * decode(::java::lang::String *, ::java::lang::String *); + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLDecoder__ diff --git a/libjava/java/net/URLEncoder.h b/libjava/java/net/URLEncoder.h new file mode 100644 index 000000000..87b3c574f --- /dev/null +++ b/libjava/java/net/URLEncoder.h @@ -0,0 +1,35 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLEncoder__ +#define __java_net_URLEncoder__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URLEncoder; + } + } +} + +class java::net::URLEncoder : public ::java::lang::Object +{ + +public: + static ::java::lang::String * encode(::java::lang::String *); + static ::java::lang::String * encode(::java::lang::String *, ::java::lang::String *); +private: + static jboolean isSafe(jchar); + URLEncoder(); + static ::java::lang::String * hex; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLEncoder__ diff --git a/libjava/java/net/URLStreamHandler.h b/libjava/java/net/URLStreamHandler.h new file mode 100644 index 000000000..ebcd44159 --- /dev/null +++ b/libjava/java/net/URLStreamHandler.h @@ -0,0 +1,48 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLStreamHandler__ +#define __java_net_URLStreamHandler__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class InetAddress; + class URL; + class URLConnection; + class URLStreamHandler; + } + } +} + +class java::net::URLStreamHandler : public ::java::lang::Object +{ + +public: + URLStreamHandler(); +public: // actually protected + virtual ::java::net::URLConnection * openConnection(::java::net::URL *) = 0; + virtual void parseURL(::java::net::URL *, ::java::lang::String *, jint, jint); +private: + static ::java::lang::String * canonicalizeFilename(::java::lang::String *); +public: // actually protected + virtual jboolean sameFile(::java::net::URL *, ::java::net::URL *); + virtual void setURL(::java::net::URL *, ::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::lang::String *); + virtual void setURL(::java::net::URL *, ::java::lang::String *, ::java::lang::String *, jint, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *, ::java::lang::String *); + virtual jboolean equals(::java::net::URL *, ::java::net::URL *); + virtual jboolean hostsEqual(::java::net::URL *, ::java::net::URL *); + virtual ::java::net::InetAddress * getHostAddress(::java::net::URL *); + virtual jint getDefaultPort(); + virtual jint hashCode(::java::net::URL *); + virtual ::java::lang::String * toExternalForm(::java::net::URL *); +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_URLStreamHandler__ diff --git a/libjava/java/net/URLStreamHandlerFactory.h b/libjava/java/net/URLStreamHandlerFactory.h new file mode 100644 index 000000000..dde45e239 --- /dev/null +++ b/libjava/java/net/URLStreamHandlerFactory.h @@ -0,0 +1,30 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_URLStreamHandlerFactory__ +#define __java_net_URLStreamHandlerFactory__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class URLStreamHandler; + class URLStreamHandlerFactory; + } + } +} + +class java::net::URLStreamHandlerFactory : public ::java::lang::Object +{ + +public: + virtual ::java::net::URLStreamHandler * createURLStreamHandler(::java::lang::String *) = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __java_net_URLStreamHandlerFactory__ diff --git a/libjava/java/net/UnknownHostException.h b/libjava/java/net/UnknownHostException.h new file mode 100644 index 000000000..965d439f3 --- /dev/null +++ b/libjava/java/net/UnknownHostException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_UnknownHostException__ +#define __java_net_UnknownHostException__ + +#pragma interface + +#include <java/io/IOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class UnknownHostException; + } + } +} + +class java::net::UnknownHostException : public ::java::io::IOException +{ + +public: + UnknownHostException(); + UnknownHostException(::java::lang::String *); +private: + static const jlong serialVersionUID = -4639126076052875403LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_UnknownHostException__ diff --git a/libjava/java/net/UnknownServiceException.h b/libjava/java/net/UnknownServiceException.h new file mode 100644 index 000000000..1bdc8021c --- /dev/null +++ b/libjava/java/net/UnknownServiceException.h @@ -0,0 +1,33 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_UnknownServiceException__ +#define __java_net_UnknownServiceException__ + +#pragma interface + +#include <java/io/IOException.h> +extern "Java" +{ + namespace java + { + namespace net + { + class UnknownServiceException; + } + } +} + +class java::net::UnknownServiceException : public ::java::io::IOException +{ + +public: + UnknownServiceException(); + UnknownServiceException(::java::lang::String *); +private: + static const jlong serialVersionUID = -4169033248853639508LL; +public: + static ::java::lang::Class class$; +}; + +#endif // __java_net_UnknownServiceException__ diff --git a/libjava/java/net/VMInetAddress.h b/libjava/java/net/VMInetAddress.h new file mode 100644 index 000000000..e093e2c2e --- /dev/null +++ b/libjava/java/net/VMInetAddress.h @@ -0,0 +1,37 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_VMInetAddress__ +#define __java_net_VMInetAddress__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class VMInetAddress; + } + } +} + +class java::net::VMInetAddress : public ::java::lang::Object +{ + +public: // actually package-private + VMInetAddress(); +public: + static ::java::lang::String * getLocalHostname(); + static JArray< jbyte > * lookupInaddrAny(); + static ::java::lang::String * getHostByAddr(JArray< jbyte > *); + static JArray< JArray< jbyte > * > * getHostByName(::java::lang::String *); + static JArray< jbyte > * aton(::java::lang::String *); + static ::java::lang::Class class$; +}; + +#endif // __java_net_VMInetAddress__ diff --git a/libjava/java/net/VMInetAddress.java b/libjava/java/net/VMInetAddress.java new file mode 100644 index 000000000..a99c216b9 --- /dev/null +++ b/libjava/java/net/VMInetAddress.java @@ -0,0 +1,97 @@ +/* VMInetAddress.java -- Class to model an Internet address + Copyright (C) 2005 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 java.net; + +import gnu.classpath.Configuration; + +import java.io.Serializable; + +class VMInetAddress implements Serializable +{ + static + { + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("javanet"); + } + + /** + * This method looks up the hostname of the local machine + * we are on. If the actual hostname cannot be determined, then the + * value "localhost" will be used. This native method wrappers the + * "gethostname" function. + * + * @return The local hostname. + */ + public static native String getLocalHostname(); + + /** + * Returns the value of the special address INADDR_ANY + */ + public static native byte[] lookupInaddrAny() throws UnknownHostException; + + /** + * This method returns the hostname for a given IP address. It will + * throw an UnknownHostException if the hostname cannot be determined. + * + * @param ip The IP address as a byte array + * + * @return The hostname + * + * @exception UnknownHostException If the reverse lookup fails + */ + public static native String getHostByAddr(byte[] ip) + throws UnknownHostException; + + /** + * Returns a list of all IP addresses for a given hostname. Will throw + * an UnknownHostException if the hostname cannot be resolved. + */ + public static native byte[][] getHostByName(String hostname) + throws UnknownHostException; + + /** + * Return the IP address represented by a literal address. + * Will return null if the literal address is not valid. + * + * @param address the name of the host + * + * @return The IP address as a byte array + */ + public static native byte[] aton(String address); +} diff --git a/libjava/java/net/VMNetworkInterface.h b/libjava/java/net/VMNetworkInterface.h new file mode 100644 index 000000000..792c5337a --- /dev/null +++ b/libjava/java/net/VMNetworkInterface.h @@ -0,0 +1,31 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_VMNetworkInterface__ +#define __java_net_VMNetworkInterface__ + +#pragma interface + +#include <java/lang/Object.h> +extern "Java" +{ + namespace java + { + namespace net + { + class VMNetworkInterface; + } + } +} + +class java::net::VMNetworkInterface : public ::java::lang::Object +{ + +public: // actually package-private + VMNetworkInterface(); +public: + static ::java::util::Vector * getInterfaces(); + static ::java::lang::Class class$; +}; + +#endif // __java_net_VMNetworkInterface__ diff --git a/libjava/java/net/VMNetworkInterface.java b/libjava/java/net/VMNetworkInterface.java new file mode 100644 index 000000000..af71ce294 --- /dev/null +++ b/libjava/java/net/VMNetworkInterface.java @@ -0,0 +1,66 @@ +/* VMNetworkInterface.java -- + Copyright (C) 2005 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 java.net; + +import gnu.classpath.Configuration; + +import java.util.Enumeration; +import java.util.Vector; + +/** + * This class models a network interface on the host computer. A network + * interface contains a name (typically associated with a specific + * hardware adapter) and a list of addresses that are bound to it. + * For example, an ethernet interface may be named "eth0" and have the + * address 192.168.1.101 assigned to it. + * + * @author Michael Koch (konqueror@gmx.de) + * @since 1.4 + */ +final class VMNetworkInterface +{ + static + { + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("javanet"); + } + + public static native Vector getInterfaces() + throws SocketException; +} diff --git a/libjava/java/net/VMURLConnection.h b/libjava/java/net/VMURLConnection.h new file mode 100644 index 000000000..0c0828ae4 --- /dev/null +++ b/libjava/java/net/VMURLConnection.h @@ -0,0 +1,38 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __java_net_VMURLConnection__ +#define __java_net_VMURLConnection__ + +#pragma interface + +#include <java/lang/Object.h> +#include <gcj/array.h> + +extern "Java" +{ + namespace java + { + namespace net + { + class VMURLConnection; + } + } +} + +class java::net::VMURLConnection : public ::java::lang::Object +{ + +public: // actually package-private + VMURLConnection(); +private: + static void init(); + static ::java::lang::String * guessContentTypeFromBuffer(JArray< jbyte > *, jint); +public: // actually package-private + static ::java::lang::String * guessContentTypeFromStream(::java::io::InputStream *); +public: + static const jint LENGTH = 1024; + static ::java::lang::Class class$; +}; + +#endif // __java_net_VMURLConnection__ diff --git a/libjava/java/net/VMURLConnection.java b/libjava/java/net/VMURLConnection.java new file mode 100644 index 000000000..19bf5814e --- /dev/null +++ b/libjava/java/net/VMURLConnection.java @@ -0,0 +1,79 @@ +/* VMURLConnection - VM code for URLConnection + Copyright (C) 2006 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 java.net; + +import gnu.classpath.Configuration; + +import java.io.IOException; +import java.io.InputStream; + +final class VMURLConnection +{ + public static final int LENGTH = 1024; + + static + { + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("javanet"); + init(); + } + + private static native void init(); + + private static native String guessContentTypeFromBuffer(byte[] b, int valid); + + /** + * This is called from URLConnection to guess the mime type of a + * stream. This method may return null to indicate that it could + * not guess a type. + */ + static String guessContentTypeFromStream(InputStream is) + throws IOException + { + if (! is.markSupported()) + return null; + is.mark(LENGTH); + byte[] bytes = new byte[LENGTH]; + int r = is.read(bytes); + if (r < 0) + return null; + is.reset(); + return guessContentTypeFromBuffer(bytes, r); + } +} diff --git a/libjava/java/net/natVMInetAddressNoNet.cc b/libjava/java/net/natVMInetAddressNoNet.cc new file mode 100644 index 000000000..fd8303bbe --- /dev/null +++ b/libjava/java/net/natVMInetAddressNoNet.cc @@ -0,0 +1,40 @@ +/* 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 <stddef.h> + +jstring +java::net::VMInetAddress::getLocalHostname () +{ + return NULL; +} + +jbyteArray +java::net::VMInetAddress::lookupInaddrAny () +{ + return NULL; +} + +jstring +java::net::VMInetAddress::getHostByAddr (jbyteArray addr) +{ + return NULL; +} + +JArray<jbyteArray> * +java::net::VMInetAddress::getHostByName (jstring host) +{ + return NULL; +} + +jbyteArray +java::net::VMInetAddress::aton (jstring host) +{ + return NULL; +} diff --git a/libjava/java/net/natVMInetAddressPosix.cc b/libjava/java/net/natVMInetAddressPosix.cc new file mode 100644 index 000000000..bc25f3654 --- /dev/null +++ b/libjava/java/net/natVMInetAddressPosix.cc @@ -0,0 +1,304 @@ +/* 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> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#include <string.h> +#include <errno.h> + +#include <sys/param.h> +#include <sys/types.h> +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif + +#include <gcj/cni.h> +#include <jvm.h> +#include <java/net/VMInetAddress.h> +#include <java/net/UnknownHostException.h> + +#if defined(HAVE_UNAME) && ! defined(HAVE_GETHOSTNAME) +#include <sys/utsname.h> +#endif + +#ifndef HAVE_GETHOSTNAME_DECL +extern "C" int gethostname (char *name, int namelen); +#endif + +jstring +java::net::VMInetAddress::getLocalHostname () +{ + char *chars; +#ifdef HAVE_GETHOSTNAME +#ifdef MAXHOSTNAMELEN + char buffer[MAXHOSTNAMELEN]; + if (gethostname (buffer, MAXHOSTNAMELEN)) + return NULL; + chars = buffer; +#else + size_t size = 256; + while (1) { + char buffer[size]; + if (!gethostname (buffer, size-1)) + { + buffer[size-1] = 0; + return JvNewStringUTF (buffer); + } + else if (errno != ENAMETOOLONG) + return NULL; + size *= 2; + } +#endif +#elif HAVE_UNAME + struct utsname stuff; + if (uname (&stuff) != 0) + return NULL; + chars = stuff.nodename; +#else + return NULL; +#endif + // It is admittedly non-optimal to convert the hostname to Unicode + // only to convert it back in getByName, but simplicity wins. + return JvNewStringUTF (chars); +} + +jbyteArray +java::net::VMInetAddress::lookupInaddrAny () +{ +#if ! HAVE_IN_ADDR_T + typedef jint in_addr_t; +#endif + in_addr_t laddr = INADDR_ANY; + char *bytes = (char *) &laddr; + int blen = sizeof (laddr); + jbyteArray result = JvNewByteArray (blen); + memcpy (elements (result), bytes, blen); + return result; +} + +jstring +java::net::VMInetAddress::getHostByAddr (jbyteArray addr) +{ + struct hostent *hptr = NULL; +#ifdef HAVE_GETHOSTBYADDR_R + struct hostent hent_r; +#if HAVE_STRUCT_HOSTENT_DATA + struct hostent_data fixed_buffer, *buffer_r = &fixed_buffer; +#else +#ifdef __GLIBC__ + // FIXME: in glibc, gethostbyname_r returns NETDB_INTERNAL to herr and + // ERANGE to errno if the buffer size is too small, rather than what is + // expected here. We work around this by setting a bigger buffer size and + // hoping that it is big enough. + char fixed_buffer[1024]; +#else + char fixed_buffer[200]; +#endif /* __GLIBC__ */ + char *buffer_r = fixed_buffer; + int size_r = sizeof (fixed_buffer); +#endif /* HAVE_STRUCT_HOSTENT_DATA */ +#endif /* HAVE_GETHOSTBYADDR_R */ + + char *bytes = (char*) elements (addr); + int len = addr->length; + int type; + char *val; + if (len == 4) + { + val = bytes; + type = AF_INET; + } +#ifdef HAVE_INET6 + else if (len == 16) + { + val = (char *) &bytes; + type = AF_INET6; + } +#endif /* HAVE_INET6 */ + else + JvFail ("unrecognized size"); + +#ifdef HAVE_GETHOSTBYADDR_R + while (true) + { + int ok; +#if HAVE_STRUCT_HOSTENT_DATA + ok = ! gethostbyaddr_r (val, len, type, &hent_r, buffer_r); +#else + int herr = 0; +#ifdef GETHOSTBYADDR_R_RETURNS_INT + ok = ! gethostbyaddr_r (val, len, type, &hent_r, + buffer_r, size_r, &hptr, &herr); +#else + hptr = gethostbyaddr_r (val, len, type, &hent_r, + buffer_r, size_r, &herr); + ok = hptr != NULL; +#endif /* GETHOSTBYADDR_R_RETURNS_INT */ + if (! ok && herr == ERANGE) + { + size_r *= 2; + buffer_r = (char *) _Jv_AllocBytes (size_r); + } + else +#endif /* HAVE_STRUCT_HOSTENT_DATA */ + break; + } +#else /* HAVE_GETHOSTBYADDR_R */ + // FIXME: this is insufficient if some other piece of code calls + // this gethostbyaddr. + JvSynchronize sync (&java::net::VMInetAddress::class$); + hptr = gethostbyaddr (val, len, type); +#endif /* HAVE_GETHOSTBYADDR_R */ + + if (hptr == NULL) + throw new java::net::UnknownHostException (); + + return JvNewStringUTF (hptr->h_name); +} + +JArray<jbyteArray> * +java::net::VMInetAddress::getHostByName (jstring host) +{ + struct hostent *hptr = NULL; +#ifdef HAVE_GETHOSTBYNAME_R + struct hostent hent_r; +#if HAVE_STRUCT_HOSTENT_DATA + struct hostent_data fixed_buffer, *buffer_r = &fixed_buffer; +#else +#ifdef __GLIBC__ + // FIXME: in glibc, gethostbyname_r returns NETDB_INTERNAL to herr and + // ERANGE to errno if the buffer size is too small, rather than what is + // expected here. We work around this by setting a bigger buffer size and + // hoping that it is big enough. + char fixed_buffer[1024]; +#else + char fixed_buffer[200]; +#endif /* __GLIBC__ */ + char *buffer_r = fixed_buffer; + int size_r = sizeof (fixed_buffer); +#endif /* HAVE_STRUCT_HOSTENT_DATA */ +#endif /* HAVE_GETHOSTBYNAME_R */ + + char *hostname; + char buf[100]; + int len = JvGetStringUTFLength(host); + if (len < 100) + hostname = buf; + else + hostname = (char *) _Jv_AllocBytes (len + 1); + JvGetStringUTFRegion (host, 0, host->length(), hostname); + buf[len] = '\0'; +#ifdef HAVE_GETHOSTBYNAME_R + while (true) + { + int ok; +#if HAVE_STRUCT_HOSTENT_DATA + ok = ! gethostbyname_r (hostname, &hent_r, buffer_r); +#else + int herr = 0; +#ifdef GETHOSTBYNAME_R_RETURNS_INT + ok = ! gethostbyname_r (hostname, &hent_r, buffer_r, size_r, + &hptr, &herr); +#else + hptr = gethostbyname_r (hostname, &hent_r, buffer_r, size_r, &herr); + ok = hptr != NULL; +#endif /* GETHOSTNAME_R_RETURNS_INT */ + if (! ok && herr == ERANGE) + { + size_r *= 2; + buffer_r = (char *) _Jv_AllocBytes (size_r); + } + else +#endif /* HAVE_STRUCT_HOSTENT_DATA */ + break; + } +#else /* HAVE_GETHOSTBYNAME_R */ + // FIXME: this is insufficient if some other piece of code calls + // this gethostbyname. + JvSynchronize sync (&java::net::VMInetAddress::class$); + hptr = gethostbyname (hostname); +#endif /* HAVE_GETHOSTBYNAME_R */ + + if (hptr == NULL) + throw new java::net::UnknownHostException (host); + + int count = 0; + char ** ptr = hptr->h_addr_list; + while (*ptr++) count++; + + JArray<jbyteArray> *result = + (JArray<jbyteArray> *) _Jv_NewObjectArray ( + count, _Jv_GetArrayClass(JvPrimClass(byte), NULL), NULL); + jbyteArray* addrs = elements (result); + + for (int i = 0; i < count; i++) + { + addrs[i] = JvNewByteArray (hptr->h_length); + memcpy (elements (addrs[i]), hptr->h_addr_list[i], hptr->h_length); + } + return result; +} + +jbyteArray +java::net::VMInetAddress::aton (jstring host) +{ + char *hostname; + char buf[100]; + int len = JvGetStringUTFLength(host); + if (len < 100) + hostname = buf; + else + hostname = (char *) _Jv_AllocBytes (len+1); + JvGetStringUTFRegion (host, 0, host->length(), hostname); + buf[len] = '\0'; + char *bytes = NULL; + int blen = 0; +#ifdef HAVE_INET_ATON + struct in_addr laddr; + if (inet_aton (hostname, &laddr)) + { + bytes = (char *) &laddr; + blen = 4; + } +#elif defined(HAVE_INET_ADDR) +#if ! HAVE_IN_ADDR_T + typedef jint in_addr_t; +#endif + in_addr_t laddr = inet_addr (hostname); + if (laddr != (in_addr_t)(-1)) + { + bytes = (char *) &laddr; + blen = 4; + } +#endif +#if defined (HAVE_INET_PTON) && defined (HAVE_INET6) + char inet6_addr[16]; + if (len != 0 && inet_pton (AF_INET6, hostname, inet6_addr) > 0) + { + bytes = inet6_addr; + blen = 16; + } +#endif + if (blen == 0) + return NULL; + jbyteArray result = JvNewByteArray (blen); + memcpy (elements (result), bytes, blen); + return result; +} diff --git a/libjava/java/net/natVMInetAddressWin32.cc b/libjava/java/net/natVMInetAddressWin32.cc new file mode 100644 index 000000000..259480faa --- /dev/null +++ b/libjava/java/net/natVMInetAddressWin32.cc @@ -0,0 +1,121 @@ +/* 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> + +#undef STRICT + +#include <java/net/VMInetAddress.h> +#include <java/net/UnknownHostException.h> + +jstring +java::net::VMInetAddress::getLocalHostname () +{ + char buffer[400]; + if (gethostname (buffer, sizeof(buffer))) + return NULL; + // It is admittedly non-optimal to convert the hostname to Unicode + // only to convert it back in getByName, but simplicity wins. + return JvNewStringUTF (buffer); +} + +jbyteArray +java::net::VMInetAddress::lookupInaddrAny () +{ + unsigned long laddr = INADDR_ANY; + char *bytes = (char *) &laddr; + int blen = sizeof (laddr); + jbyteArray result = JvNewByteArray (blen); + memcpy (elements (result), bytes, blen); + return result; +} + +jstring +java::net::VMInetAddress::getHostByAddr (jbyteArray addr) +{ + struct hostent *hptr = NULL; + char *bytes = (char*) elements (addr); + int len = addr->length; + int type; + char *val; + if (len == 4) + { + val = bytes; + type = AF_INET; + } +#ifdef HAVE_INET6 + else if (len == 16) + { + val = (char *) &bytes; + type = AF_INET6; + } +#endif /* HAVE_INET6 */ + else + JvFail ("unrecognized size"); + + // FIXME: this is insufficient if some other piece of code calls + // this gethostbyaddr. + JvSynchronize sync (&java::net::VMInetAddress::class$); + hptr = gethostbyaddr (val, len, type); + + if (hptr == NULL) + throw new java::net::UnknownHostException (); + + return JvNewStringUTF (hptr->h_name); +} + +JArray<jbyteArray> * +java::net::VMInetAddress::getHostByName (jstring host) +{ + struct hostent *hptr = NULL; + JV_TEMP_UTF_STRING (hostname, host); + + // FIXME: this is insufficient if some other piece of code calls + // this gethostbyname. + JvSynchronize sync (&java::net::VMInetAddress::class$); + hptr = gethostbyname (hostname); + + if (hptr == NULL) + throw new java::net::UnknownHostException (host); + + int count = 0; + char ** ptr = hptr->h_addr_list; + while (*ptr++) count++; + + JArray<jbyteArray> *result = + (JArray<jbyteArray> *) _Jv_NewObjectArray ( + count, _Jv_GetArrayClass(JvPrimClass(byte), NULL), NULL); + jbyteArray* addrs = elements (result); + + for (int i = 0; i < count; i++) + { + addrs[i] = JvNewByteArray (hptr->h_length); + memcpy (elements (addrs[i]), hptr->h_addr_list[i], hptr->h_length); + } + return result; +} + +jbyteArray +java::net::VMInetAddress::aton (jstring host) +{ + JV_TEMP_UTF_STRING (hostname, host); + char* bytes = NULL; + int blen = 0; + unsigned long laddr = inet_addr (hostname); + if (laddr != INADDR_NONE) + { + bytes = (char *) &laddr; + blen = 4; + } + if (blen == 0) + return NULL; + jbyteArray result = JvNewByteArray (blen); + memcpy (elements (result), bytes, blen); + return result; +} diff --git a/libjava/java/net/natVMNetworkInterfaceNoNet.cc b/libjava/java/net/natVMNetworkInterfaceNoNet.cc new file mode 100644 index 000000000..eda7f99f0 --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfaceNoNet.cc @@ -0,0 +1,21 @@ +/* Copyright (C) 2003, 2005 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 <java/net/SocketException.h> +#include <java/net/VMNetworkInterface.h> +#include <java/util/Vector.h> + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + throw new SocketException ( + JvNewStringLatin1 ("VMNetworkInterface.getInterfaces: unimplemented")); +} diff --git a/libjava/java/net/natVMNetworkInterfacePosix.cc b/libjava/java/net/natVMNetworkInterfacePosix.cc new file mode 100644 index 000000000..bfb11d21c --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfacePosix.cc @@ -0,0 +1,163 @@ +/* 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_UNISTD_H +#include <unistd.h> +#endif +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include <sys/param.h> +#include <sys/types.h> +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif +#ifdef HAVE_SYS_IOCTL_H +#define BSD_COMP /* Get FIONREAD on Solaris2. */ +#include <sys/ioctl.h> +#endif +#ifdef HAVE_NET_IF_H +#include <net/if.h> +#endif +#ifdef HAVE_IFADDRS_H +#include <ifaddrs.h> +#endif + +#include <gcj/cni.h> +#include <jvm.h> +#include <java/net/InetAddress.h> +#include <java/net/NetworkInterface.h> +#include <java/net/SocketException.h> +#include <java/net/VMNetworkInterface.h> +#include <java/util/Vector.h> + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + ::java::util::Vector* ht = new ::java::util::Vector (); + +#ifdef HAVE_GETIFADDRS + + struct ifaddrs *addrs; + if (::getifaddrs (&addrs) == -1) + throw new ::java::net::SocketException(JvNewStringUTF (strerror (errno))); + + for (struct ifaddrs *work = addrs; work != NULL; work = work->ifa_next) + { + // Sometimes the address can be NULL; I don't know why but + // there's nothing we can do with this. + if (! work->ifa_addr) + continue; + // We only return Inet4 or Inet6 addresses. + jbyteArray laddr; + if (work->ifa_addr->sa_family == AF_INET) + { + sockaddr_in *real = reinterpret_cast<sockaddr_in *> (work->ifa_addr); + laddr = JvNewByteArray(4); + memcpy (elements (laddr), &real->sin_addr, 4); + } +#ifdef HAVE_INET6 + else if (work->ifa_addr->sa_family == AF_INET6) + { + sockaddr_in6 *real + = reinterpret_cast<sockaddr_in6 *> (work->ifa_addr); + laddr = JvNewByteArray(16); + memcpy (elements (laddr), &real->sin6_addr, 16); + } +#endif + else + continue; + + ::java::net::InetAddress *inaddr + = ::java::net::InetAddress::getByAddress(laddr); + + // It is ok to make a new NetworkInterface for each struct; the + // java code will unify these as necessary; see + // NetworkInterface.condense(). + jstring name = JvNewStringUTF (work->ifa_name); + + ht->add (new NetworkInterface (name, inaddr)); + } + + freeifaddrs (addrs); + +#else /* ! HAVE_GETIFADDRS */ + + int fd; + int num_interfaces = 0; + struct ifconf if_data; + struct ifreq* if_record; + + if_data.ifc_len = 0; + if_data.ifc_buf = NULL; + + // Open a (random) socket to have a file descriptor for the ioctl calls. + fd = _Jv_socket (PF_INET, SOCK_DGRAM, htons (IPPROTO_IP)); + + if (fd < 0) + throw new ::java::net::SocketException; + + // Get all interfaces. If not enough buffers are available try it + // with a bigger buffer size. + do + { + num_interfaces += 16; + + if_data.ifc_len = sizeof (struct ifreq) * num_interfaces; + if_data.ifc_buf = + (char*) _Jv_Realloc (if_data.ifc_buf, if_data.ifc_len); + + // Try to get all local interfaces. + if (::ioctl (fd, SIOCGIFCONF, &if_data) < 0) + throw new java::net::SocketException; + } + while (if_data.ifc_len >= (int) (sizeof (struct ifreq) * num_interfaces)); + + // Get addresses of all interfaces. + if_record = if_data.ifc_req; + + for (int n = 0; n < if_data.ifc_len; n += sizeof (struct ifreq)) + { + struct ifreq ifr; + + memset (&ifr, 0, sizeof (ifr)); + strcpy (ifr.ifr_name, if_record->ifr_name); + + // Try to get the IPv4-address of the local interface + if (::ioctl (fd, SIOCGIFADDR, &ifr) < 0) + throw new java::net::SocketException; + + int len = 4; + struct sockaddr_in sa = *((sockaddr_in*) &(ifr.ifr_addr)); + + jbyteArray baddr = JvNewByteArray (len); + memcpy (elements (baddr), &(sa.sin_addr), len); + jstring if_name = JvNewStringLatin1 (if_record->ifr_name); + InetAddress* address = java::net::InetAddress::getByAddress (baddr); + ht->add (new NetworkInterface (if_name, address)); + if_record++; + } + + _Jv_Free (if_data.ifc_buf); + + if (fd >= 0) + _Jv_close (fd); +#endif /* HAVE_GETIFADDRS */ + + return ht; +} diff --git a/libjava/java/net/natVMNetworkInterfaceWin32.cc b/libjava/java/net/natVMNetworkInterfaceWin32.cc new file mode 100644 index 000000000..c9b14d57d --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfaceWin32.cc @@ -0,0 +1,144 @@ +/* Copyright (C) 2003, 2005 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 + +#include <java/net/NetworkInterface.h> +#include <java/net/InetAddress.h> +#include <java/net/SocketException.h> +#include <java/net/VMNetworkInterface.h> +#include <java/util/Vector.h> + +/* As of this writing, NetworkInterface.java has + getName() == getDisplayName() and only one IP address + per interface. If this changes, we'll need to use + iphlpapi (not supported on Win95) to retrieve richer + adapter information via GetAdaptersInfo(). In this + module, we provide the necessary hooks to detect the + presence of iphlpapi and use it if necessary, but + comment things out for now to avoid compiler warnings. */ + +enum {MAX_INTERFACES = 50}; + +typedef int +(*PfnGetRealNetworkInterfaces) (jstring* pjstrName, + java::net::InetAddress** ppAddress); + +static int +winsock2GetRealNetworkInterfaces (jstring* pjstrName, + java::net::InetAddress** ppAddress) +{ + // FIXME: Add IPv6 support. + + INTERFACE_INFO arInterfaceInfo[MAX_INTERFACES]; + + // Open a (random) socket to have a file descriptor for the WSAIoctl call. + SOCKET skt = ::socket (AF_INET, SOCK_DGRAM, 0); + if (skt == INVALID_SOCKET) + _Jv_ThrowSocketException (); + + DWORD dwOutBufSize; + int nRetCode = ::WSAIoctl (skt, SIO_GET_INTERFACE_LIST, + NULL, 0, &arInterfaceInfo, sizeof(arInterfaceInfo), + &dwOutBufSize, NULL, NULL); + + if (nRetCode == SOCKET_ERROR) + { + DWORD dwLastErrorCode = WSAGetLastError (); + ::closesocket (skt); + _Jv_ThrowSocketException (dwLastErrorCode); + } + + // Get addresses of all interfaces. + int nNbInterfaces = dwOutBufSize / sizeof(INTERFACE_INFO); + int nCurETHInterface = 0; + for (int i=0; i < nNbInterfaces; ++i) + { + int len = 4; + jbyteArray baddr = JvNewByteArray (len); + SOCKADDR_IN* pAddr = (SOCKADDR_IN*) &arInterfaceInfo[i].iiAddress; + memcpy (elements (baddr), &(pAddr->sin_addr), len); + + // Concoct a name for this interface. Since we don't + // have access to the real name under Winsock 2, we use + // "lo" for the loopback interface and ethX for the + // real ones. + TCHAR szName[30]; + u_long lFlags = arInterfaceInfo[i].iiFlags; + + if (lFlags & IFF_LOOPBACK) + _tcscpy (szName, _T("lo")); + else + { + _tcscpy (szName, _T("eth")); + wsprintf(szName+3, _T("%d"), nCurETHInterface++); + } + + jstring if_name = _Jv_Win32NewString (szName); + java::net::InetAddress* address = + java::net::InetAddress::getByAddress (baddr); + pjstrName[i] = if_name; + ppAddress[i] = address; + } + + ::closesocket (skt); + + return nNbInterfaces; +} + +/* +static int +iphlpapiGetRealNetworkInterfaces (jstring* pjstrName, + java::net::InetAddress** ppAddress) +{ + return 0; +} +*/ + +static PfnGetRealNetworkInterfaces +determineGetRealNetworkInterfacesFN () +{ + /* FIXME: Try to dynamically load iphlpapi.dll and + detect the presence of GetAdaptersInfo() using + GetProcAddress(). If successful, return + iphlpapiGetRealNetworkInterfaces; if not, + return winsock2GetRealNetworkInterfaces */ + return &winsock2GetRealNetworkInterfaces; +} + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + // This next declaration used to be a static local, + // but this introduced a dependency on libsupc++ due + // to _cxa_guard_acquire and _cxa_guard_release. + // When Win95 is gone and we eventually get rid of + // winsock2GetRealNetworkInterfaces, we can rework + // all of this. Alternatively, we could move this all + // to win32.cc and initialize this at startup time, + // but that seems more trouble than it's worth at + // the moment. + PfnGetRealNetworkInterfaces pfn = + determineGetRealNetworkInterfacesFN (); + + jstring arIFName[MAX_INTERFACES]; + InetAddress* arpInetAddress[MAX_INTERFACES]; + ::java::util::Vector* ht = new ::java::util::Vector (); + + int nNbInterfaces = (*pfn) (arIFName, arpInetAddress); + for (int i=0; i < nNbInterfaces; ++i) + { + ht->add (new java::net::NetworkInterface (arIFName[i], + arpInetAddress[i])); + } + + return ht; +} diff --git a/libjava/java/net/natVMURLConnection.cc b/libjava/java/net/natVMURLConnection.cc new file mode 100644 index 000000000..0a30a2197 --- /dev/null +++ b/libjava/java/net/natVMURLConnection.cc @@ -0,0 +1,81 @@ +/* Copyright (C) 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 <java/net/VMURLConnection.h> +#include <gcj/cni.h> +#include <java/lang/UnsupportedOperationException.h> +#include <stdio.h> + +#if defined (HAVE_MAGIC_T) && defined (HAVE_MAGIC_H) && defined (USE_LTDL) + +#include <magic.h> +#include <ltdl.h> + +static magic_t cookie; + +static magic_t (*p_magic_open)(int flags); +static int (*p_magic_load)(magic_t cookie, const char *filename); +static void (*p_magic_close)(magic_t cookie); +static const char * (*p_magic_buffer) (magic_t cookie, const void *buffer, + size_t length); + +#endif /* HAVE_MAGIC_T && HAVE_MAGIC_H && defined (USE_LTDL) */ + +void +java::net::VMURLConnection::init () +{ +#if defined (HAVE_MAGIC_T) && defined (HAVE_MAGIC_H) && defined (USE_LTDL) + lt_dlhandle handle = lt_dlopenext ("libmagic.so"); + if (!handle) + return; + + p_magic_open = (typeof (p_magic_open))lt_dlsym(handle, "magic_open"); + if (p_magic_open == NULL) + return; + p_magic_buffer = (typeof (p_magic_buffer))lt_dlsym(handle, "magic_buffer"); + if (p_magic_buffer == NULL) + return; + p_magic_close = (typeof (p_magic_close))lt_dlsym(handle, "magic_close"); + if (p_magic_close == NULL) + return; + p_magic_load = (typeof (p_magic_load))lt_dlsym(handle, "magic_load"); + if (p_magic_load == NULL) + return; + + cookie = p_magic_open (MAGIC_MIME); + if (cookie == (magic_t) NULL) + return; + if (p_magic_load (cookie, NULL) == -1) + { + p_magic_close (cookie); + cookie = (magic_t) NULL; + } +#endif /* HAVE_MAGIC_T && HAVE_MAGIC_H && defined (USE_LTDL) */ +} + +::java::lang::String * +java::net::VMURLConnection::guessContentTypeFromBuffer (jbyteArray bytes __attribute__ ((unused)), + jint valid __attribute__ ((unused))) +{ +#if defined (HAVE_MAGIC_T) && defined (HAVE_MAGIC_H) && defined (USE_LTDL) + const char *result; + + if (cookie == (magic_t) NULL) + return NULL; + + result = p_magic_buffer (cookie, elements(bytes), valid); + + if (result == NULL) + return NULL; + return _Jv_NewStringUTF (result); +#else + return NULL; +#endif /* HAVE_MAGIC_T && HAVE_MAGIC_H && defined (USE_LTDL) */ +} |