diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/java/net/natVMURLConnection.cc | |
parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
download | ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.zip |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net/natVMURLConnection.cc')
-rw-r--r-- | libjava/java/net/natVMURLConnection.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libjava/java/net/natVMURLConnection.cc b/libjava/java/net/natVMURLConnection.cc new file mode 100644 index 00000000000..3429bb63dba --- /dev/null +++ b/libjava/java/net/natVMURLConnection.cc @@ -0,0 +1,56 @@ +/* Copyright (C) 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 <java/net/VMURLConnection.h> +#include <gcj/cni.h> +#include <java/lang/UnsupportedOperationException.h> + +#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN) + +#include <magic.h> + +static magic_t cookie; + +#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */ + +void +java::net::VMURLConnection::init () +{ +#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN) + cookie = magic_open (MAGIC_MIME); + if (cookie == (magic_t) NULL) + return; + if (magic_load (cookie, NULL) == -1) + { + magic_close (cookie); + cookie = (magic_t) NULL; + } +#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */ +} + +::java::lang::String * +java::net::VMURLConnection::guessContentTypeFromBuffer (jbyteArray bytes, + jint valid) +{ +#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN) + const char *result; + + if (cookie == (magic_t) NULL) + return NULL; + + result = magic_buffer (cookie, elements(bytes), valid); + + if (result == NULL) + return NULL; + return _Jv_NewStringUTF (result); +#else + return NULL; +#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */ +} |