diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-02-29 02:43:00 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-02-29 02:43:00 (GMT) |
commit | 63249be0e10a8726acb5a7cf64491319eaa46227 (patch) | |
tree | ebb2b75ece8852e8a58804631c0004f06a9bba9f /java/src/jni | |
parent | a1617b7cdbe14173fcf690b4627059fa4528c19b (diff) | |
download | hdf5-63249be0e10a8726acb5a7cf64491319eaa46227.zip hdf5-63249be0e10a8726acb5a7cf64491319eaa46227.tar.gz hdf5-63249be0e10a8726acb5a7cf64491319eaa46227.tar.bz2 |
[svn-r29226] HDFFV-9552: merge in java code.
Diffstat (limited to 'java/src/jni')
38 files changed, 24147 insertions, 0 deletions
diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt new file mode 100644 index 0000000..6ee56c8 --- /dev/null +++ b/java/src/jni/CMakeLists.txt @@ -0,0 +1,84 @@ +cmake_minimum_required (VERSION 3.1.0) +PROJECT (HDF5_JAVA_JNI C CXX) + +set (HDF5_JAVA_JNI_CSRCS + ${HDF5_JAVA_JNI_SOURCE_DIR}/exceptionImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5aImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5Constants.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5dImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5eImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5fImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5gImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5iImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5Imp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5lImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5oImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5plImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5rImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.c +) + +set (HDF5_JAVA_JNI_CHDRS + ${HDF5_JAVA_JNI_SOURCE_DIR}/exceptionImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5aImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5dImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5eImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5fImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5gImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5iImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5jni.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5lImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5oImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5plImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5rImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.h +) + +INCLUDE_DIRECTORIES( ${HDF5_JAVA_JNI_SOURCE_DIR} ) + +set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) + +########### JNI libraries always must be built shared ############### +add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JAVA_JNI_CHDRS}) +TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED " " " ") +target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} ${HDF5_LIB_TARGET}) +set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni) +SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_JAVA_JNI_LIB_TARGET}") +H5_SET_LIB_OPTIONS (${HDF5_JAVA_JNI_LIB_TARGET} ${HDF5_JAVA_JNI_LIB_NAME} SHARED ${HDF5_JAVA_PACKAGE_SOVERSION}) +if (WIN32) + get_filename_component (HDF5_JAVA_JNI_DLL_NAME ${HDF5_JAVA_JNI_LIB_TARGET} NAME_WE) + # message (STATUS "HDF5_JAVA_JNI_DLL_NAME: ${HDF5_JAVA_JNI_DLL_NAME}") + if (BUILD_TESTING) + add_custom_target (HDF5_JAVA_JNI-Test-Copy ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${HDF5_JAVA_JNI_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${HDF5_JAVA_JNI_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMENT "Copying ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${HDF5_JAVA_JNI_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/" + ) + add_dependencies (HDF5_JAVA_JNI-Test-Copy ${HDF5_JAVA_JNI_LIB_TARGET}) + endif (BUILD_TESTING) +endif (WIN32) + +#----------------------------------------------------------------------------- +# Add Target(s) to CMake Install for import into other projects +#----------------------------------------------------------------------------- +if (HDF5_EXPORTED_TARGETS) + install ( + TARGETS + ${HDF5_JAVA_JNI_LIB_TARGET} + EXPORT + ${HDF5_JAVA_EXPORTED_TARGETS} + LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries + ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries + RUNTIME DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT libraries + ) +endif (HDF5_EXPORTED_TARGETS) diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am new file mode 100644 index 0000000..764fcdb --- /dev/null +++ b/java/src/jni/Makefile.am @@ -0,0 +1,44 @@ +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Java native interface (JNI) Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am + +# Mark this directory as part of the JNI API +JAVA_API=yes + +# Include src directory and JNI flags +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/java/src/jni $(JNIFLAGS) + +# This is our main target +lib_LTLIBRARIES=libhdf5_java.la + +# Add libtool numbers to the HDF5 Java (JNI) library (from config/lt_vers.am) +libhdf5_java_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) + +# Source files for the library +libhdf5_java_la_SOURCES=exceptionImp.c h5Constants.c nativeData.c h5util.c h5Imp.c \ + h5aImp.c h5dImp.c h5eImp.c h5fImp.c h5gImp.c h5iImp.c h5lImp.c h5oImp.c \ + h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5zImp.c + +# HDF5 Java (JNI) library depends on HDF5 Library. +libhdf5_java_la_LIBADD=$(LIBHDF5) + +include $(top_srcdir)/config/conclude.am diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c new file mode 100644 index 0000000..8623ca9 --- /dev/null +++ b/java/src/jni/exceptionImp.c @@ -0,0 +1,414 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/***********/ +/* Headers */ +/***********/ + +#include "hdf5.h" +#include <stdio.h> +#include <stdlib.h> +#include "jni.h" +#include "h5jni.h" +#include "exceptionImp.h" + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* These types are copied from H5Eprivate.h + * They should be moved to a public include file, and deleted from + * here. + */ + +#define H5E_NSLOTS 32 /*number of slots in an error stack */ + +/* + * The list of error messages in the system is kept as an array of + * error_code/message pairs, one for major error numbers and another for + * minor error numbers. + */ +typedef struct H5E_major_mesg_t { + hid_t error_code; + const char *str; +} H5E_major_mesg_t; + +typedef struct H5E_minor_mesg_t { + hid_t error_code; + const char *str; +} H5E_minor_mesg_t; + +/* major and minor error numbers */ +typedef struct H5E_num_t { + hid_t maj_num; + hid_t min_num; +} H5E_num_t; + +/********************/ +/* Local Macros */ +/********************/ + +#define THROWEXCEPTION(className,args) { \ + jclass jc; \ + jmethodID jm; \ + jobject ex; \ + jc = ENVPTR->FindClass(ENVPAR (className)); \ + if (jc == NULL) { \ + return JNI_FALSE; \ + } \ + jm = ENVPTR->GetMethodID(ENVPAR jc, "<init>", "(Ljava/lang/String;)V"); \ + if (jm == NULL) { \ + return JNI_FALSE; \ + } \ + ex = ENVPTR->NewObjectA (ENVPAR jc, jm, (jvalue*)(args)); \ + if (ENVPTR->Throw(ENVPAR (jthrowable)ex) < 0) { \ + printf("FATAL ERROR: %s: Throw failed\n", (className)); \ + return JNI_FALSE; \ + } \ + return JNI_TRUE; \ +} + +/********************/ +/* Local Prototypes */ +/********************/ + +static const char *defineHDF5LibraryException(hid_t maj_num); +static jboolean H5JNIErrorClass(JNIEnv *env, const char *message, const char *className); + +/* get the major and minor error numbers on the top of the error stack */ +static herr_t +walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void *_err_nums) +{ + H5E_num_t *err_nums = (H5E_num_t *)_err_nums; + + if(err_desc) { + err_nums->maj_num = err_desc->maj_num; + err_nums->min_num = err_desc->min_num; + } /* end if */ + + return 0; +} /* end walk_error_callback() */ + +/* + * Class: hdf_hdf5lib_exceptions_HDF5Library + * Method: H5error_off + * Signature: ()I + * + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5error_1off(JNIEnv *env, jclass clss) +{ + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + return 0; +} /* end Java_hdf_hdf5lib_H5_H5error_1off() */ + + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: printStackTrace0 + * Signature: (Ljava/lang/Object;)V + * + * Call the HDF-5 library to print the HDF-5 error stack to 'file_name'. + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0( + JNIEnv *env, jobject obj, jstring file_name) +{ + FILE *stream = NULL; + const char *file = NULL; + + if(file_name == NULL) { + H5Eprint2(H5E_DEFAULT, stderr); + } /* end if */ + else { + file = ENVPTR->GetStringUTFChars(ENVPAR file_name, 0); + stream = HDfopen(file, "a+"); + if(stream) { + H5Eprint2(H5E_DEFAULT, stream); + HDfclose(stream); + } /* end if */ + ENVPTR->ReleaseStringUTFChars(ENVPAR file_name, file); + } /* end else */ +} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0() */ + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: getMajorErrorNumber + * Signature: ()J + * + * Extract the HDF-5 major error number from the HDF-5 error stack. + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber( + JNIEnv *env, jobject obj) +{ + H5E_num_t err_nums; + err_nums.maj_num = 0; + err_nums.min_num = 0; + + H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums); + + return err_nums.maj_num; +} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber() */ + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: getMinorErrorNumber + * Signature: ()J + * + * Extract the HDF-5 minor error number from the HDF-5 error stack. + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber( + JNIEnv *env, jobject obj) +{ + H5E_num_t err_nums; + err_nums.maj_num = 0; + err_nums.min_num = 0; + + H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums); + + return err_nums.min_num; +} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber() */ + +/* + * Routine to raise particular Java exceptions from C + */ +static +jboolean +H5JNIErrorClass(JNIEnv *env, const char *message, const char *className) +{ + char *args[2]; + jstring str = ENVPTR->NewStringUTF(ENVPAR message); + args[0] = (char *)str; + args[1] = 0; + + THROWEXCEPTION(className, args); +} /* end H5JNIErrorClass() */ + +/* + * Create and throw an 'outOfMemoryException' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5outOfMemory(JNIEnv *env, const char *functName) +{ + return H5JNIErrorClass(env, functName, "java/lang/OutOfMemoryError"); +} /* end h5outOfMemory() */ + + +/* + * A fatal error in a JNI call + * Create and throw an 'InternalError' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5JNIFatalError(JNIEnv *env, const char *functName) +{ + return H5JNIErrorClass(env, functName, "java/lang/InternalError"); +} /* end h5JNIFatalError() */ + +/* + * A NULL argument in an HDF5 call + * Create and throw an 'NullPointerException' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5nullArgument(JNIEnv *env, const char *functName) +{ + return H5JNIErrorClass(env, functName, "java/lang/NullPointerException"); +} /* end h5nullArgument() */ + +/* + * A bad argument in an HDF5 call + * Create and throw an 'IllegalArgumentException' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5badArgument(JNIEnv *env, const char *functName) +{ + return H5JNIErrorClass(env, functName, "java/lang/IllegalArgumentException"); +} /* end h5badArgument() */ + +/* + * Some feature Not implemented yet + * Create and throw an 'UnsupportedOperationException' + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5unimplemented(JNIEnv *env, const char *functName) +{ + return H5JNIErrorClass(env, functName, "java/lang/UnsupportedOperationException"); +} /* end h5unimplemented() */ + +/* h5raiseException(). This routine is called to generate + * an arbitrary Java exception with a particular message. + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5raiseException(JNIEnv *env, const char *exception, const char *message) +{ + return H5JNIErrorClass(env, message, exception); +} /* end h5raiseException() */ + +/* + * h5libraryError() determines the HDF-5 major error code + * and creates and throws the appropriate sub-class of + * HDF5LibraryException(). This routine should be called + * whenever a call to the HDF-5 library fails, i.e., when + * the return is -1. + * + * Note: This routine never returns from the 'throw', + * and the Java native method immediately raises the + * exception. + */ +jboolean +h5libraryError(JNIEnv *env) +{ + char *args[2]; + const char *exception = NULL; + char *msg_str = NULL; + int num_errs = 0; + hid_t min_num; + hid_t maj_num; + ssize_t msg_size = 0; + H5E_type_t error_msg_type; + jstring str = NULL; + hid_t stk_id = -1; + H5E_num_t exceptionNumbers; + + exceptionNumbers.maj_num = 0; + exceptionNumbers.min_num = 0; + + /* Save current stack contents for future use */ + stk_id = H5Eget_current_stack(); /* This will clear current stack */ + if(stk_id >= 0) + H5Ewalk2(stk_id, H5E_WALK_DOWNWARD, walk_error_callback, &exceptionNumbers); + maj_num = exceptionNumbers.maj_num; + min_num = exceptionNumbers.min_num; + + exception = defineHDF5LibraryException(maj_num); + + /* get the length of the name */ + msg_size = H5Eget_msg(min_num, NULL, NULL, 0); + if(msg_size > 0) { + msg_size++; /* add extra space for the null terminator */ + msg_str = (char*)HDcalloc((size_t)msg_size, sizeof(char)); + if(msg_str) { + msg_size = H5Eget_msg(min_num, &error_msg_type, (char *)msg_str, (size_t)msg_size); + str = ENVPTR->NewStringUTF(ENVPAR msg_str); + HDfree(msg_str); + } /* end if */ + } /* end if */ + else + str = NULL; + if(stk_id >= 0) + H5Eset_current_stack(stk_id); + + args[0] = (char *)str; + args[1] = 0; + THROWEXCEPTION(exception, args); +} /* end h5libraryError() */ + + +/* + * defineHDF5LibraryException() returns the name of the sub-class + * which goes with an HDF-5 error code. + */ +static const char * +defineHDF5LibraryException(hid_t maj_num) +{ + hid_t err_num = maj_num; + + if (H5E_ARGS == err_num) + return "hdf/hdf5lib/exceptions/HDF5FunctionArgumentException"; + else if (H5E_RESOURCE == err_num) + return "hdf/hdf5lib/exceptions/HDF5ResourceUnavailableException"; + else if (H5E_INTERNAL == err_num) + return "hdf/hdf5lib/exceptions/HDF5InternalErrorException"; + else if (H5E_FILE == err_num) + return "hdf/hdf5lib/exceptions/HDF5FileInterfaceException"; + else if (H5E_IO == err_num) + return "hdf/hdf5lib/exceptions/HDF5LowLevelIOException"; + else if (H5E_FUNC == err_num) + return "hdf/hdf5lib/exceptions/HDF5FunctionEntryExitException"; + else if (H5E_ATOM == err_num) + return "hdf/hdf5lib/exceptions/HDF5AtomException"; + else if (H5E_CACHE == err_num) + return "hdf/hdf5lib/exceptions/HDF5MetaDataCacheException"; + else if (H5E_BTREE == err_num) + return "hdf/hdf5lib/exceptions/HDF5BtreeException"; + else if (H5E_SYM == err_num) + return "hdf/hdf5lib/exceptions/HDF5SymbolTableException"; + else if (H5E_HEAP == err_num) + return "hdf/hdf5lib/exceptions/HDF5HeapException"; + else if (H5E_OHDR == err_num) + return "hdf/hdf5lib/exceptions/HDF5ObjectHeaderException"; + else if (H5E_DATATYPE == err_num) + return "hdf/hdf5lib/exceptions/HDF5DatatypeInterfaceException"; + else if (H5E_DATASPACE == err_num) + return "hdf/hdf5lib/exceptions/HDF5DataspaceInterfaceException"; + else if (H5E_DATASET == err_num) + return "hdf/hdf5lib/exceptions/HDF5DatasetInterfaceException"; + else if (H5E_STORAGE == err_num) + return "hdf/hdf5lib/exceptions/HDF5DataStorageException"; + else if (H5E_PLIST == err_num) + return "hdf/hdf5lib/exceptions/HDF5PropertyListInterfaceException"; + else if (H5E_ATTR == err_num) + return "hdf/hdf5lib/exceptions/HDF5AttributeException"; + else if (H5E_PLINE == err_num) + return "hdf/hdf5lib/exceptions/HDF5DataFiltersException"; + else if (H5E_EFL == err_num) + return "hdf/hdf5lib/exceptions/HDF5ExternalFileListException"; + else if (H5E_REFERENCE == err_num) + return "hdf/hdf5lib/exceptions/HDF5ReferenceException"; + + return "hdf/hdf5lib/exceptions/HDF5LibraryException"; +} /* end defineHDF5LibraryException() */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + diff --git a/java/src/jni/exceptionImp.h b/java/src/jni/exceptionImp.h new file mode 100644 index 0000000..e238372 --- /dev/null +++ b/java/src/jni/exceptionImp.h @@ -0,0 +1,67 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_exception */ + +#ifndef _Included_hdf_hdf5lib_H5_exception +#define _Included_hdf_hdf5lib_H5_exception + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_exceptions_HDF5Library + * Method: H5error_off + * Signature: ()I + * + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5error_1off(JNIEnv *env, jclass clss ); + + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: printStackTrace0 + * Signature: (Ljava/lang/Object;)V + * + * Call the HDF-5 library to print the HDF-5 error stack to 'file_name'. + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0(JNIEnv *env, + jobject obj, jstring file_name); + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: getMajorErrorNumber + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber(JNIEnv *env, jobject obj); + +/* + * Class: hdf_hdf5lib_exceptions_HDFLibraryException + * Method: getMinorErrorNumber + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber(JNIEnv *env, jobject obj); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_exception */ diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c new file mode 100644 index 0000000..f1d49be --- /dev/null +++ b/java/src/jni/h5Constants.c @@ -0,0 +1,692 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include "hdf5.h" + +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1QUARTER_1HADDR_1MAX(JNIEnv *env, jclass cls) { return (hsize_t)HADDR_MAX/4; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1ALLOW_1K13_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_ALLOW_K13_OPTION_MASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1CHIP_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_CHIP_OPTION_MASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1EC_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_EC_OPTION_MASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1MAX_1PIXELS_1PER_1BLOCK(JNIEnv *env, jclass cls) { return H5_SZIP_MAX_PIXELS_PER_BLOCK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1NN_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_NN_OPTION_MASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1UNKNOWN(JNIEnv *env, jclass cls) { return H5_INDEX_UNKNOWN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1NAME(JNIEnv *env, jclass cls) { return H5_INDEX_NAME; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1CRT_1ORDER(JNIEnv *env, jclass cls) { return H5_INDEX_CRT_ORDER; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1N(JNIEnv *env, jclass cls) { return H5_INDEX_N; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1UNKNOWN(JNIEnv *env, jclass cls) { return H5_ITER_UNKNOWN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1INC(JNIEnv *env, jclass cls) { return H5_ITER_INC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1DEC(JNIEnv *env, jclass cls) { return H5_ITER_DEC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1NATIVE(JNIEnv *env, jclass cls) { return H5_ITER_NATIVE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1N(JNIEnv *env, jclass cls) { return H5_ITER_N; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5AC_1CURR_1CACHE_1CONFIG_1VERSION(JNIEnv *env, jclass cls) { return H5AC__CURR_CACHE_CONFIG_VERSION; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5AC_1MAX_1TRACE_1FILE_1NAME_1LEN(JNIEnv *env, jclass cls) { return H5AC__MAX_TRACE_FILE_NAME_LEN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1PROCESS_1ZERO_1ONLY(JNIEnv *env, jclass cls) { return H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1DISTRIBUTED(JNIEnv *env, jclass cls) { return H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1off(JNIEnv *env, jclass cls) { return H5C_incr__off; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1threshold(JNIEnv *env, jclass cls) { return H5C_incr__threshold; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1off(JNIEnv *env, jclass cls) { return H5C_flash_incr__off; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1add_1space(JNIEnv *env, jclass cls) { return H5C_flash_incr__add_space; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1off(JNIEnv *env, jclass cls) { return H5C_decr__off; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1threshold(JNIEnv *env, jclass cls) { return H5C_decr__threshold; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out(JNIEnv *env, jclass cls) { return H5C_decr__age_out; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out_1with_1threshold(JNIEnv *env, jclass cls) { return H5C_decr__age_out_with_threshold; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNK_1IDX_1BTREE(JNIEnv *env, jclass cls) { return H5D_CHUNK_IDX_BTREE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1DEFAULT(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1EARLY(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_EARLY; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1ERROR(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1INCR(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_INCR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1LATE(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_LATE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ERROR(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ALLOC(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_ALLOC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1NEVER(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_NEVER; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1IFSET(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_IFSET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1DEFAULT(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1ERROR(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1UNDEFINED(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_UNDEFINED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1USER_1DEFINED(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_USER_DEFINED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1LAYOUT_1ERROR(JNIEnv *env, jclass cls) { return H5D_LAYOUT_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNKED(JNIEnv *env, jclass cls) { return H5D_CHUNKED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1COMPACT(JNIEnv *env, jclass cls) { return H5D_COMPACT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1CONTIGUOUS(JNIEnv *env, jclass cls) { return H5D_CONTIGUOUS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1VIRTUAL(JNIEnv *env, jclass cls) { return H5D_VIRTUAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1NLAYOUTS(JNIEnv *env, jclass cls) { return H5D_NLAYOUTS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_ALLOCATED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ERROR(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1NOT_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_NOT_ALLOCATED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1PART_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_PART_ALLOCATED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1ERROR(JNIEnv *env, jclass cls) { return H5D_VDS_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1FIRST_1MISSING(JNIEnv *env, jclass cls) { return H5D_VDS_FIRST_MISSING; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1LAST_1AVAILABLE(JNIEnv *env, jclass cls) { return H5D_VDS_LAST_AVAILABLE; } + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ALIGNMENT(JNIEnv *env, jclass cls) { return H5E_ALIGNMENT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYEXISTS(JNIEnv *env, jclass cls) { return H5E_ALREADYEXISTS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYINIT(JNIEnv *env, jclass cls) { return H5E_ALREADYINIT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ARGS(JNIEnv *env, jclass cls) { return H5E_ARGS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ATOM(JNIEnv *env, jclass cls) { return H5E_ATOM; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1ATTR(JNIEnv *env, jclass cls) { return H5E_ATTR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADATOM(JNIEnv *env, jclass cls) { return H5E_BADATOM; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADFILE(JNIEnv *env, jclass cls) { return H5E_BADFILE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADGROUP(JNIEnv *env, jclass cls) { return H5E_BADGROUP; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADMESG(JNIEnv *env, jclass cls) { return H5E_BADMESG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADRANGE(JNIEnv *env, jclass cls) { return H5E_BADRANGE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSELECT(JNIEnv *env, jclass cls) { return H5E_BADSELECT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSIZE(JNIEnv *env, jclass cls) { return H5E_BADSIZE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADTYPE(JNIEnv *env, jclass cls) { return H5E_BADTYPE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BADVALUE(JNIEnv *env, jclass cls) { return H5E_BADVALUE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1BTREE(JNIEnv *env, jclass cls) { return H5E_BTREE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CACHE(JNIEnv *env, jclass cls) { return H5E_CACHE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CALLBACK(JNIEnv *env, jclass cls) { return H5E_CALLBACK; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANAPPLY(JNIEnv *env, jclass cls) { return H5E_CANAPPLY; } +/*JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTALLOC(JNIEnv *env, jclass cls) { return H5E_CANTALLOC; }*/ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLIP(JNIEnv *env, jclass cls) { return H5E_CANTCLIP; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLOSEFILE(JNIEnv *env, jclass cls) { return H5E_CANTCLOSEFILE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCONVERT(JNIEnv *env, jclass cls) { return H5E_CANTCONVERT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOPY(JNIEnv *env, jclass cls) { return H5E_CANTCOPY; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOUNT(JNIEnv *env, jclass cls) { return H5E_CANTCOUNT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCREATE(JNIEnv *env, jclass cls) { return H5E_CANTCREATE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDEC(JNIEnv *env, jclass cls) { return H5E_CANTDEC; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDECODE(JNIEnv *env, jclass cls) { return H5E_CANTDECODE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDELETE(JNIEnv *env, jclass cls) { return H5E_CANTDELETE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTENCODE(JNIEnv *env, jclass cls) { return H5E_CANTENCODE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFLUSH(JNIEnv *env, jclass cls) { return H5E_CANTFLUSH; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFREE(JNIEnv *env, jclass cls) { return H5E_CANTFREE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTGET(JNIEnv *env, jclass cls) { return H5E_CANTGET; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINC(JNIEnv *env, jclass cls) { return H5E_CANTINC; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINIT(JNIEnv *env, jclass cls) { return H5E_CANTINIT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINSERT(JNIEnv *env, jclass cls) { return H5E_CANTINSERT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLIST(JNIEnv *env, jclass cls) { return H5E_CANTLIST; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOAD(JNIEnv *env, jclass cls) { return H5E_CANTLOAD; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOCK(JNIEnv *env, jclass cls) { return H5E_CANTLOCK; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTNEXT(JNIEnv *env, jclass cls) { return H5E_CANTNEXT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENFILE(JNIEnv *env, jclass cls) { return H5E_CANTOPENFILE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENOBJ(JNIEnv *env, jclass cls) { return H5E_CANTOPENOBJ; } +/*JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTRECV(JNIEnv *env, jclass cls) { return H5E_CANTRECV; }*/ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTREGISTER(JNIEnv *env, jclass cls) { return H5E_CANTREGISTER; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTRELEASE(JNIEnv *env, jclass cls) { return H5E_CANTRELEASE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSELECT(JNIEnv *env, jclass cls) { return H5E_CANTSELECT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSET(JNIEnv *env, jclass cls) { return H5E_CANTSET; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSPLIT(JNIEnv *env, jclass cls) { return H5E_CANTSPLIT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTUNLOCK(JNIEnv *env, jclass cls) { return H5E_CANTUNLOCK; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CLOSEERROR(JNIEnv *env, jclass cls) { return H5E_CLOSEERROR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1COMPLEN(JNIEnv *env, jclass cls) { return H5E_COMPLEN; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASET(JNIEnv *env, jclass cls) { return H5E_DATASET; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASPACE(JNIEnv *env, jclass cls) { return H5E_DATASPACE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1DATATYPE(JNIEnv *env, jclass cls) { return H5E_DATATYPE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1DEFAULT(JNIEnv *env, jclass cls) { return H5E_DEFAULT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1DUPCLASS(JNIEnv *env, jclass cls) { return H5E_DUPCLASS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1EFL(JNIEnv *env, jclass cls) { return H5E_EFL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1EXISTS(JNIEnv *env, jclass cls) { return H5E_EXISTS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1FCNTL(JNIEnv *env, jclass cls) { return H5E_FCNTL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1FILE(JNIEnv *env, jclass cls) { return H5E_FILE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEEXISTS(JNIEnv *env, jclass cls) { return H5E_FILEEXISTS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEOPEN(JNIEnv *env, jclass cls) { return H5E_FILEOPEN; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1FUNC(JNIEnv *env, jclass cls) { return H5E_FUNC; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1HEAP(JNIEnv *env, jclass cls) { return H5E_HEAP; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1INTERNAL(JNIEnv *env, jclass cls) { return H5E_INTERNAL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1IO(JNIEnv *env, jclass cls) { return H5E_IO; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1LINK(JNIEnv *env, jclass cls) { return H5E_LINK; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1LINKCOUNT(JNIEnv *env, jclass cls) { return H5E_LINKCOUNT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1MAJOR(JNIEnv *env, jclass cls) { return H5E_MAJOR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1MINOR(JNIEnv *env, jclass cls) { return H5E_MINOR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1MOUNT(JNIEnv *env, jclass cls) { return H5E_MOUNT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1MPI(JNIEnv *env, jclass cls) { return H5E_MPI; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1MPIERRSTR(JNIEnv *env, jclass cls) { return H5E_MPIERRSTR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOFILTER(JNIEnv *env, jclass cls) { return H5E_NOFILTER; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOIDS(JNIEnv *env, jclass cls) { return H5E_NOIDS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MAJOR(JNIEnv *env, jclass cls) { return H5E_NONE_MAJOR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MINOR(JNIEnv *env, jclass cls) { return H5E_NONE_MINOR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOSPACE(JNIEnv *env, jclass cls) { return H5E_NOSPACE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTCACHED(JNIEnv *env, jclass cls) { return H5E_NOTCACHED; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTFOUND(JNIEnv *env, jclass cls) { return H5E_NOTFOUND; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTHDF5(JNIEnv *env, jclass cls) { return H5E_NOTHDF5; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1OHDR(JNIEnv *env, jclass cls) { return H5E_OHDR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1OVERFLOW(JNIEnv *env, jclass cls) { return H5E_OVERFLOW; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1PLINE(JNIEnv *env, jclass cls) { return H5E_PLINE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1PLIST(JNIEnv *env, jclass cls) { return H5E_PLIST; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1PROTECT(JNIEnv *env, jclass cls) { return H5E_PROTECT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1READERROR(JNIEnv *env, jclass cls) { return H5E_READERROR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1REFERENCE(JNIEnv *env, jclass cls) { return H5E_REFERENCE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1RESOURCE(JNIEnv *env, jclass cls) { return H5E_RESOURCE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1RS(JNIEnv *env, jclass cls) { return H5E_RS; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1SEEKERROR(JNIEnv *env, jclass cls) { return H5E_SEEKERROR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1SETLOCAL(JNIEnv *env, jclass cls) { return H5E_SETLOCAL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1STORAGE(JNIEnv *env, jclass cls) { return H5E_STORAGE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1SYM(JNIEnv *env, jclass cls) { return H5E_SYM; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1TRUNCATED(JNIEnv *env, jclass cls) { return H5E_TRUNCATED; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1TST(JNIEnv *env, jclass cls) { return H5E_TST; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1UNINITIALIZED(JNIEnv *env, jclass cls) { return H5E_UNINITIALIZED; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1UNSUPPORTED(JNIEnv *env, jclass cls) { return H5E_UNSUPPORTED; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1VERSION(JNIEnv *env, jclass cls) { return H5E_VERSION; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1VFL(JNIEnv *env, jclass cls) { return H5E_VFL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1DOWNWARD(JNIEnv *env, jclass cls) { return H5E_WALK_DOWNWARD; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) { return H5E_WALK_UPWARD; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) { return H5E_WRITEERROR; } + +/* Java does not have unsigned native types */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1CREAT(JNIEnv *env, jclass cls) { return H5F_ACC_CREAT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1EXCL(JNIEnv *env, jclass cls) { return H5F_ACC_EXCL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDONLY(JNIEnv *env, jclass cls) { return H5F_ACC_RDONLY; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDWR(JNIEnv *env, jclass cls) { return H5F_ACC_RDWR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1TRUNC(JNIEnv *env, jclass cls) { return H5F_ACC_TRUNC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_ACC_DEFAULT; } +#pragma GCC diagnostic pop + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_CLOSE_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1SEMI(JNIEnv *env, jclass cls) { return H5F_CLOSE_SEMI; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1STRONG(JNIEnv *env, jclass cls) { return H5F_CLOSE_STRONG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1WEAK(JNIEnv *env, jclass cls) { return H5F_CLOSE_WEAK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1EARLIEST(JNIEnv *env, jclass cls){return H5F_LIBVER_EARLIEST;} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1LATEST(JNIEnv *env, jclass cls){return H5F_LIBVER_LATEST;} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ALL(JNIEnv *env, jclass cls) { return H5F_OBJ_ALL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ATTR(JNIEnv *env, jclass cls) { return H5F_OBJ_ATTR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATASET(JNIEnv *env, jclass cls) { return H5F_OBJ_DATASET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATATYPE(JNIEnv *env, jclass cls) { return H5F_OBJ_DATATYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1FILE(JNIEnv *env, jclass cls) { return H5F_OBJ_FILE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1GROUP(JNIEnv *env, jclass cls) { return H5F_OBJ_GROUP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1LOCAL(JNIEnv *env, jclass cls) { return H5F_OBJ_LOCAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1GLOBAL(JNIEnv *env, jclass cls) { return H5F_SCOPE_GLOBAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1LOCAL(JNIEnv *env, jclass cls) { return H5F_SCOPE_LOCAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1UNLIMITED(JNIEnv *env, jclass cls) { return (jint)H5F_UNLIMITED; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1ALL_1PERSIST(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_ALL_PERSIST; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1ALL(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_ALL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1AGGR_1VFD(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_AGGR_VFD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1VFD(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_VFD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1FILE_1SPACE_1NTYPES(JNIEnv *env, jclass cls) { return H5F_FILE_SPACE_NTYPES; } + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1CORE(JNIEnv *env, jclass cls) { return H5FD_CORE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1DIRECT(JNIEnv *env, jclass cls) { +#ifdef H5_HAVE_DIRECT + return H5FD_DIRECT; +#else + return -1; +#endif +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1FAMILY(JNIEnv *env, jclass cls) { return H5FD_FAMILY; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG(JNIEnv *env, jclass cls) { return H5FD_LOG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MPIO(JNIEnv *env, jclass cls) { return H5FD_MPIO; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MULTI(JNIEnv *env, jclass cls) { return H5FD_MULTI; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1SEC2(JNIEnv *env, jclass cls) { return H5FD_SEC2; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1STDIO(JNIEnv *env, jclass cls) { return H5FD_STDIO; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1WINDOWS(JNIEnv *env, jclass cls) { +#ifdef H5_HAVE_WINDOWS + return H5FD_DIRECT; +#else + return -1; +#endif +} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_READ; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_WRITE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_SEEK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_IO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_READ; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_WRITE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_IO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FLAVOR(JNIEnv *env, jclass cls) { return H5FD_LOG_FLAVOR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_READ; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_WRITE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_SEEK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1TRUNCATE(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_TRUNCATE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_IO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1OPEN(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_OPEN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1STAT(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_STAT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_READ; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_WRITE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_SEEK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1CLOSE(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_CLOSE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_IO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALLOC(JNIEnv *env, jclass cls) { return H5FD_LOG_ALLOC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALL(JNIEnv *env, jclass cls) { return H5FD_LOG_ALL; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NOLIST(JNIEnv *env, jclass cls) { return H5FD_MEM_NOLIST; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT(JNIEnv *env, jclass cls) { return H5FD_MEM_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1SUPER(JNIEnv *env, jclass cls) { return H5FD_MEM_SUPER; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1BTREE(JNIEnv *env, jclass cls) { return H5FD_MEM_BTREE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DRAW(JNIEnv *env, jclass cls) { return H5FD_MEM_DRAW; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1GHEAP(JNIEnv *env, jclass cls) { return H5FD_MEM_GHEAP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1LHEAP(JNIEnv *env, jclass cls) { return H5FD_MEM_LHEAP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1OHDR(JNIEnv *env, jclass cls) { return H5FD_MEM_OHDR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NTYPES(JNIEnv *env, jclass cls) { return H5FD_MEM_NTYPES; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1DEFAULT_1HADDR_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(HADDR_MAX/H5FD_MEM_NTYPES); } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)0; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SUPER_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)0; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1BTREE_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(1 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1DRAW_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(2 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1GHEAP_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(3 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1LHEAP_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(4 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1OHDR_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(5 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } + + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1DATASET(JNIEnv *env, jclass cls) { return H5G_DATASET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1GROUP(JNIEnv *env, jclass cls) { return H5G_GROUP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK(JNIEnv *env, jclass cls) { return H5G_LINK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1UDLINK(JNIEnv *env, jclass cls) { return H5G_UDLINK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_15(JNIEnv *env, jclass cls) { return H5G_RESERVED_5; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_16(JNIEnv *env, jclass cls) { return H5G_RESERVED_6; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_17(JNIEnv *env, jclass cls) { return H5G_RESERVED_7; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1TYPE(JNIEnv *env, jclass cls) { return H5G_TYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1UNKNOWN(JNIEnv *env, jclass cls) { return H5G_UNKNOWN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1ERROR(JNIEnv *env, jclass cls) { return H5G_LINK_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1HARD(JNIEnv *env, jclass cls) { return H5G_LINK_HARD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1SOFT(JNIEnv *env, jclass cls) { return H5G_LINK_SOFT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1NLIBTYPES(JNIEnv *env, jclass cls) { return H5G_NLIBTYPES; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1NTYPES(JNIEnv *env, jclass cls) { return H5G_NTYPES; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1NUSERTYPES(JNIEnv *env, jclass cls) { return H5G_NUSERTYPES; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1SAME_1LOC(JNIEnv *env, jclass cls) { return H5G_SAME_LOC; } + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_UNKNOWN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1SYMBOL_1TABLE(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_SYMBOL_TABLE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1COMPACT(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_COMPACT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1DENSE(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_DENSE; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1UNINIT(JNIEnv *env, jclass cls) { return H5I_UNINIT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1BADID(JNIEnv *env, jclass cls) { return H5I_BADID; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1FILE(JNIEnv *env, jclass cls) { return H5I_FILE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1GROUP(JNIEnv *env, jclass cls) { return H5I_GROUP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1DATATYPE(JNIEnv *env, jclass cls) { return H5I_DATATYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASPACE(JNIEnv *env, jclass cls) { return H5I_DATASPACE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) { return H5I_DATASET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) { return H5I_ATTR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1REFERENCE(JNIEnv *env, jclass cls) { return H5I_REFERENCE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) { return H5I_VFL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1INVALID_1HID(JNIEnv *env, jclass cls) { return H5I_INVALID_HID; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1CLS(JNIEnv *env, jclass cls) { return H5I_GENPROP_CLS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1LST(JNIEnv *env, jclass cls) { return H5I_GENPROP_LST; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1CLASS(JNIEnv *env, jclass cls) { return H5I_ERROR_CLASS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1MSG(JNIEnv *env, jclass cls) { return H5I_ERROR_MSG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1STACK(JNIEnv *env, jclass cls) { return H5I_ERROR_STACK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1NTYPES(JNIEnv *env, jclass cls) { return H5I_NTYPES; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1ERROR(JNIEnv *env, jclass cls) { return H5L_TYPE_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1HARD(JNIEnv *env, jclass cls) { return H5L_TYPE_HARD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1SOFT(JNIEnv *env, jclass cls) { return H5L_TYPE_SOFT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1EXTERNAL(JNIEnv *env, jclass cls) { return H5L_TYPE_EXTERNAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1MAX(JNIEnv *env, jclass cls) { return H5L_TYPE_MAX; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1SHALLOW_1HIERARCHY_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_SHALLOW_HIERARCHY_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1SOFT_1LINK_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_SOFT_LINK_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1EXT_1LINK_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_EXT_LINK_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1REFERENCE_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_REFERENCE_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1WITHOUT_1ATTR_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_WITHOUT_ATTR_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1PRESERVE_1NULL_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_PRESERVE_NULL_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1NONE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_NONE_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1SDSPACE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_SDSPACE_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1DTYPE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_DTYPE_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1FILL_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_FILL_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1PLINE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_PLINE_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ATTR_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_ATTR_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ALL_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_ALL_FLAG; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls) { return H5O_TYPE_UNKNOWN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1GROUP(JNIEnv *env, jclass cls) { return H5O_TYPE_GROUP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1DATASET(JNIEnv *env, jclass cls) { return H5O_TYPE_DATASET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NAMED_1DATATYPE(JNIEnv *env, jclass cls) { return H5O_TYPE_NAMED_DATATYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NTYPES(JNIEnv *env, jclass cls) { return H5O_TYPE_NTYPES; } + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ROOT(JNIEnv *env, jclass cls){return H5P_ROOT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1CREATE(JNIEnv *env, jclass cls){return H5P_OBJECT_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE(JNIEnv *env, jclass cls){return H5P_FILE_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS(JNIEnv *env, jclass cls){return H5P_FILE_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE(JNIEnv *env, jclass cls){return H5P_DATASET_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS(JNIEnv *env, jclass cls){return H5P_DATASET_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER(JNIEnv *env, jclass cls){return H5P_DATASET_XFER;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT(JNIEnv *env, jclass cls){return H5P_FILE_MOUNT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE(JNIEnv *env, jclass cls){return H5P_GROUP_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS(JNIEnv *env, jclass cls){return H5P_GROUP_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1STRING_1CREATE(JNIEnv *env, jclass cls){return H5P_STRING_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE(JNIEnv *env, jclass cls){return H5P_LINK_CREATE;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_XFER_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_MOUNT_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_GROUP_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_GROUP_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY_1DEFAULT(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_CREATE_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS_DEFAULT;} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1TRACKED(JNIEnv *env, jclass cls){return H5P_CRT_ORDER_TRACKED;} +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1INDEXED(JNIEnv *env, jclass cls){return H5P_CRT_ORDER_INDEXED;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DEFAULT(JNIEnv *env, jclass cls) { return H5P_DEFAULT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5P_ROOT; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) { return H5PL_TYPE_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) { return H5PL_TYPE_FILTER; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_FILTER_PLUGIN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_ALL_PLUGIN; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1BADTYPE(JNIEnv *env, jclass cls) { return H5R_BADTYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1MAXTYPE(JNIEnv *env, jclass cls) { return H5R_MAXTYPE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJ_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_OBJ_REF_BUF_SIZE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1DSET_1REG_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_DSET_REG_REF_BUF_SIZE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT(JNIEnv *env, jclass cls) { return H5R_OBJECT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1ALL(JNIEnv *env, jclass cls) { return H5S_ALL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1MAX_1RANK(JNIEnv *env, jclass cls) { return H5S_MAX_RANK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5S_NO_CLASS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1NULL(JNIEnv *env, jclass cls) { return H5S_NULL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SCALAR(JNIEnv *env, jclass cls) { return H5S_SCALAR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ALL(JNIEnv *env, jclass cls) { return H5S_SEL_ALL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ERROR(JNIEnv *env, jclass cls) { return H5S_SEL_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1HYPERSLABS(JNIEnv *env, jclass cls) { return H5S_SEL_HYPERSLABS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1N(JNIEnv *env, jclass cls) { return H5S_SEL_N; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1NONE(JNIEnv *env, jclass cls) { return H5S_SEL_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1POINTS(JNIEnv *env, jclass cls) { return H5S_SEL_POINTS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1AND(JNIEnv *env, jclass cls) { return H5S_SELECT_AND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1APPEND(JNIEnv *env, jclass cls) { return H5S_SELECT_APPEND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1INVALID(JNIEnv *env, jclass cls) { return H5S_SELECT_INVALID; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOOP(JNIEnv *env, jclass cls) { return H5S_SELECT_NOOP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTA(JNIEnv *env, jclass cls) { return H5S_SELECT_NOTA; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTB(JNIEnv *env, jclass cls) { return H5S_SELECT_NOTB; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1OR(JNIEnv *env, jclass cls) { return H5S_SELECT_OR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1PREPEND(JNIEnv *env, jclass cls) { return H5S_SELECT_PREPEND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1SET(JNIEnv *env, jclass cls) { return H5S_SELECT_SET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1XOR(JNIEnv *env, jclass cls) { return H5S_SELECT_XOR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1SIMPLE(JNIEnv *env, jclass cls) { return H5S_SIMPLE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5S_1UNLIMITED(JNIEnv *env, jclass cls) { return (jint)H5S_UNLIMITED; } + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B16(JNIEnv *env, jclass cls) { return H5T_ALPHA_B16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B32(JNIEnv *env, jclass cls) { return H5T_ALPHA_B32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B64(JNIEnv *env, jclass cls) { return H5T_ALPHA_B64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B8(JNIEnv *env, jclass cls) { return H5T_ALPHA_B8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F32(JNIEnv *env, jclass cls) { return H5T_ALPHA_F32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F64(JNIEnv *env, jclass cls) { return H5T_ALPHA_F64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I16(JNIEnv *env, jclass cls) { return H5T_ALPHA_I16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I32(JNIEnv *env, jclass cls) { return H5T_ALPHA_I32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I64(JNIEnv *env, jclass cls) { return H5T_ALPHA_I64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I8(JNIEnv *env, jclass cls) { return H5T_ALPHA_I8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U16(JNIEnv *env, jclass cls) { return H5T_ALPHA_U16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U32(JNIEnv *env, jclass cls) { return H5T_ALPHA_U32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U64(JNIEnv *env, jclass cls) { return H5T_ALPHA_U64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U8(JNIEnv *env, jclass cls) { return H5T_ALPHA_U8; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ARRAY(JNIEnv *env, jclass cls) { return H5T_ARRAY; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1BITFIELD(JNIEnv *env, jclass cls) { return H5T_BITFIELD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1NO(JNIEnv *env, jclass cls) { return H5T_BKG_NO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1YES(JNIEnv *env, jclass cls) { return H5T_BKG_YES; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1C_1S1(JNIEnv *env, jclass cls) { return H5T_C_S1; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1COMPOUND(JNIEnv *env, jclass cls) { return H5T_COMPOUND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1CONV(JNIEnv *env, jclass cls) { return H5T_CONV_CONV; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1FREE(JNIEnv *env, jclass cls) { return H5T_CONV_FREE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1INIT(JNIEnv *env, jclass cls) { return H5T_CONV_INIT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ERROR(JNIEnv *env, jclass cls) { return H5T_CSET_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ASCII(JNIEnv *env, jclass cls) { return H5T_CSET_ASCII; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1UTF8(JNIEnv *env, jclass cls) { return H5T_CSET_UTF8; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_110(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_10; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_111(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_11; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_112(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_12; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_113(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_13; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_114(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_14; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_115(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_15; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_12(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_2; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_13(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_3; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_14(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_4; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_15(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_5; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_16(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_6; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_17(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_7; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_18(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_8; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_19(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_9; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1ASCEND(JNIEnv *env, jclass cls) { return H5T_DIR_ASCEND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DEFAULT(JNIEnv *env, jclass cls) { return H5T_DIR_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DESCEND(JNIEnv *env, jclass cls) { return H5T_DIR_DESCEND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ENUM(JNIEnv *env, jclass cls) { return H5T_ENUM; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT(JNIEnv *env, jclass cls) { return H5T_FLOAT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1FORTRAN_1S1(JNIEnv *env, jclass cls) { return H5T_FORTRAN_S1; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32BE(JNIEnv *env, jclass cls) { return H5T_IEEE_F32BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32LE(JNIEnv *env, jclass cls) { return H5T_IEEE_F32LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64BE(JNIEnv *env, jclass cls) { return H5T_IEEE_F64BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64LE(JNIEnv *env, jclass cls) { return H5T_IEEE_F64LE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEGER(JNIEnv *env, jclass cls) { return H5T_INTEGER; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B16(JNIEnv *env, jclass cls) { return H5T_INTEL_B16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B32(JNIEnv *env, jclass cls) { return H5T_INTEL_B32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B64(JNIEnv *env, jclass cls) { return H5T_INTEL_B64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B8(JNIEnv *env, jclass cls) { return H5T_INTEL_B8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F32(JNIEnv *env, jclass cls) { return H5T_INTEL_F32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F64(JNIEnv *env, jclass cls) { return H5T_INTEL_F64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I16(JNIEnv *env, jclass cls) { return H5T_INTEL_I16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I32(JNIEnv *env, jclass cls) { return H5T_INTEL_I32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I64(JNIEnv *env, jclass cls) { return H5T_INTEL_I64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I8(JNIEnv *env, jclass cls) { return H5T_INTEL_I8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U16(JNIEnv *env, jclass cls) { return H5T_INTEL_U16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U32(JNIEnv *env, jclass cls) { return H5T_INTEL_U32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U64(JNIEnv *env, jclass cls) { return H5T_INTEL_U64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U8(JNIEnv *env, jclass cls) { return H5T_INTEL_U8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B16(JNIEnv *env, jclass cls) { return H5T_MIPS_B16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B32(JNIEnv *env, jclass cls) { return H5T_MIPS_B32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B64(JNIEnv *env, jclass cls) { return H5T_MIPS_B64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B8(JNIEnv *env, jclass cls) { return H5T_MIPS_B8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F32(JNIEnv *env, jclass cls) { return H5T_MIPS_F32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F64(JNIEnv *env, jclass cls) { return H5T_MIPS_F64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I16(JNIEnv *env, jclass cls) { return H5T_MIPS_I16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I32(JNIEnv *env, jclass cls) { return H5T_MIPS_I32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I64(JNIEnv *env, jclass cls) { return H5T_MIPS_I64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I8(JNIEnv *env, jclass cls) { return H5T_MIPS_I8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U16(JNIEnv *env, jclass cls) { return H5T_MIPS_U16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U32(JNIEnv *env, jclass cls) { return H5T_MIPS_U32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U64(JNIEnv *env, jclass cls) { return H5T_MIPS_U64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U8(JNIEnv *env, jclass cls) { return H5T_MIPS_U8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B16(JNIEnv *env, jclass cls) { return H5T_NATIVE_B16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B32(JNIEnv *env, jclass cls) { return H5T_NATIVE_B32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B64(JNIEnv *env, jclass cls) { return H5T_NATIVE_B64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B8(JNIEnv *env, jclass cls) { return H5T_NATIVE_B8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1CHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_CHAR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1DOUBLE(JNIEnv *env, jclass cls) { return H5T_NATIVE_DOUBLE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT(JNIEnv *env, jclass cls) { return H5T_NATIVE_FLOAT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HADDR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HADDR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HBOOL(JNIEnv *env, jclass cls) { return H5T_NATIVE_HBOOL; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HERR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HERR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSIZE(JNIEnv *env, jclass cls) { return H5T_NATIVE_HSIZE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSSIZE(JNIEnv *env, jclass cls) { return H5T_NATIVE_HSSIZE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LDOUBLE(JNIEnv *env, jclass cls) { return H5T_NATIVE_LDOUBLE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LLONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_LLONG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_LONG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1OPAQUE(JNIEnv *env, jclass cls) { return H5T_NATIVE_OPAQUE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SCHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_SCHAR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SHORT(JNIEnv *env, jclass cls) { return H5T_NATIVE_SHORT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UCHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_UCHAR; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT16; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT32; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT64; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT8; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULLONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_ULLONG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_ULONG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1USHORT(JNIEnv *env, jclass cls) { return H5T_NATIVE_USHORT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NCLASSES(JNIEnv *env, jclass cls) { return H5T_NCLASSES; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5T_NO_CLASS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1ERROR(JNIEnv *env, jclass cls) { return H5T_NORM_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1IMPLIED(JNIEnv *env, jclass cls) { return H5T_NORM_IMPLIED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1MSBSET(JNIEnv *env, jclass cls) { return H5T_NORM_MSBSET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1NONE(JNIEnv *env, jclass cls) { return H5T_NORM_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NPAD(JNIEnv *env, jclass cls) { return H5T_NPAD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NSGN(JNIEnv *env, jclass cls) { return H5T_NSGN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE(JNIEnv *env, jclass cls) { return H5T_OPAQUE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE_1TAG_1MAX(JNIEnv *env, jclass cls) { return H5T_OPAQUE_TAG_MAX; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1BE(JNIEnv *env, jclass cls) { return H5T_ORDER_BE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1ERROR(JNIEnv *env, jclass cls) { return H5T_ORDER_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1LE(JNIEnv *env, jclass cls) { return H5T_ORDER_LE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1NONE(JNIEnv *env, jclass cls) { return H5T_ORDER_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1VAX(JNIEnv *env, jclass cls) { return H5T_ORDER_VAX; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1BACKGROUND(JNIEnv *env, jclass cls) { return H5T_PAD_BACKGROUND; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ERROR(JNIEnv *env, jclass cls) { return H5T_PAD_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ONE(JNIEnv *env, jclass cls) { return H5T_PAD_ONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ZERO(JNIEnv *env, jclass cls) { return H5T_PAD_ZERO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1DONTCARE(JNIEnv *env, jclass cls) { return H5T_PERS_DONTCARE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1HARD(JNIEnv *env, jclass cls) { return H5T_PERS_HARD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1SOFT(JNIEnv *env, jclass cls) { return H5T_PERS_SOFT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1REFERENCE(JNIEnv *env, jclass cls) { return H5T_REFERENCE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_12(JNIEnv *env, jclass cls) { return H5T_SGN_2; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1ERROR(JNIEnv *env, jclass cls) { return H5T_SGN_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1NONE(JNIEnv *env, jclass cls) { return H5T_SGN_NONE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16BE(JNIEnv *env, jclass cls) { return H5T_STD_B16BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16LE(JNIEnv *env, jclass cls) { return H5T_STD_B16LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32BE(JNIEnv *env, jclass cls) { return H5T_STD_B32BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32LE(JNIEnv *env, jclass cls) { return H5T_STD_B32LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64BE(JNIEnv *env, jclass cls) { return H5T_STD_B64BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64LE(JNIEnv *env, jclass cls) { return H5T_STD_B64LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8BE(JNIEnv *env, jclass cls) { return H5T_STD_B8BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8LE(JNIEnv *env, jclass cls) { return H5T_STD_B8LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16BE(JNIEnv *env, jclass cls) { return H5T_STD_I16BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16LE(JNIEnv *env, jclass cls) { return H5T_STD_I16LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32BE(JNIEnv *env, jclass cls) { return H5T_STD_I32BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32LE(JNIEnv *env, jclass cls) { return H5T_STD_I32LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64BE(JNIEnv *env, jclass cls) { return H5T_STD_I64BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64LE(JNIEnv *env, jclass cls) { return H5T_STD_I64LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8BE(JNIEnv *env, jclass cls) { return H5T_STD_I8BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8LE(JNIEnv *env, jclass cls) { return H5T_STD_I8LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1DSETREG(JNIEnv *env, jclass cls) { return H5T_STD_REF_DSETREG; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1OBJ(JNIEnv *env, jclass cls) { return H5T_STD_REF_OBJ; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16BE(JNIEnv *env, jclass cls) { return H5T_STD_U16BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16LE(JNIEnv *env, jclass cls) { return H5T_STD_U16LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32BE(JNIEnv *env, jclass cls) { return H5T_STD_U32BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32LE(JNIEnv *env, jclass cls) { return H5T_STD_U32LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64BE(JNIEnv *env, jclass cls) { return H5T_STD_U64BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64LE(JNIEnv *env, jclass cls) { return H5T_STD_U64LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8BE(JNIEnv *env, jclass cls) { return H5T_STD_U8BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8LE(JNIEnv *env, jclass cls) { return H5T_STD_U8LE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1ERROR(JNIEnv *env, jclass cls) { return H5T_STR_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLPAD(JNIEnv *env, jclass cls) { return H5T_STR_NULLPAD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLTERM(JNIEnv *env, jclass cls) { return H5T_STR_NULLTERM; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_110(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_10; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_111(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_11; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_112(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_12; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_113(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_13; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_114(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_14; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_115(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_15; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_13(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_3; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_14(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_4; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_15(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_5; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_16(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_6; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_17(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_7; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_18(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_8; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_19(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_9; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1SPACEPAD(JNIEnv *env, jclass cls) { return H5T_STR_SPACEPAD; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1STRING(JNIEnv *env, jclass cls) { return H5T_STRING; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1TIME(JNIEnv *env, jclass cls) { return H5T_TIME; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32BE(JNIEnv *env, jclass cls) { return H5T_UNIX_D32BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32LE(JNIEnv *env, jclass cls) { return H5T_UNIX_D32LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64BE(JNIEnv *env, jclass cls) { return H5T_UNIX_D64BE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64LE(JNIEnv *env, jclass cls) { return H5T_UNIX_D64LE; } +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) { return (int)H5T_VARIABLE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) { return H5T_VLEN; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) { return H5Z_CB_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1FAIL(JNIEnv *env, jclass cls) { return H5Z_CB_FAIL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1NO(JNIEnv *env, jclass cls) { return H5Z_CB_NO; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1DISABLE_1EDC(JNIEnv *env, jclass cls) { return H5Z_DISABLE_EDC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1ENABLE_1EDC(JNIEnv *env, jclass cls) { return H5Z_ENABLE_EDC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1ERROR_1EDC(JNIEnv *env, jclass cls) { return H5Z_ERROR_EDC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1DECODE_1ENABLED(JNIEnv *env, jclass cls) { return H5Z_FILTER_CONFIG_DECODE_ENABLED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1ENCODE_1ENABLED(JNIEnv *env, jclass cls) { return H5Z_FILTER_CONFIG_ENCODE_ENABLED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1DEFLATE(JNIEnv *env, jclass cls) { return H5Z_FILTER_DEFLATE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ERROR(JNIEnv *env, jclass cls) { return H5Z_FILTER_ERROR; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1FLETCHER32(JNIEnv *env, jclass cls) { return H5Z_FILTER_FLETCHER32; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1MAX(JNIEnv *env, jclass cls) { return H5Z_FILTER_MAX; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NBIT(JNIEnv *env, jclass cls) {return H5Z_FILTER_NBIT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NONE(JNIEnv *env, jclass cls) { return H5Z_FILTER_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1RESERVED(JNIEnv *env, jclass cls) { return H5Z_FILTER_RESERVED; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SCALEOFFSET(JNIEnv *env, jclass cls){ return H5Z_FILTER_SCALEOFFSET; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SHUFFLE(JNIEnv *env, jclass cls) { return H5Z_FILTER_SHUFFLE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SZIP(JNIEnv *env, jclass cls) { return H5Z_FILTER_SZIP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1DEFMASK(JNIEnv *env, jclass cls) { return H5Z_FLAG_DEFMASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1INVMASK(JNIEnv *env, jclass cls) { return H5Z_FLAG_INVMASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1MANDATORY(JNIEnv *env, jclass cls) { return H5Z_FLAG_MANDATORY; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1OPTIONAL(JNIEnv *env, jclass cls) { return H5Z_FLAG_OPTIONAL; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1REVERSE(JNIEnv *env, jclass cls) { return H5Z_FLAG_REVERSE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1SKIP_1EDC(JNIEnv *env, jclass cls) { return H5Z_FLAG_SKIP_EDC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1MAX_1NFILTERS(JNIEnv *env, jclass cls) { return H5Z_MAX_NFILTERS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1NO_1EDC(JNIEnv *env, jclass cls) { return H5Z_NO_EDC; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT_1MINBITS_1DEFAULT(JNIEnv *env, jclass cls) { return H5Z_SO_INT_MINBITS_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1DSCALE(JNIEnv *env, jclass cls){return H5Z_SO_FLOAT_DSCALE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1ESCALE(JNIEnv *env, jclass cls){return H5Z_SO_FLOAT_ESCALE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT(JNIEnv *env, jclass cls){return H5Z_SO_INT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SHUFFLE_USER_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SHUFFLE_TOTAL_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SZIP_USER_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SZIP_TOTAL_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1MASK(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_MASK; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPB(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_PPB; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1BPP(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_BPP; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPS(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_PPS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1NBIT_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_NBIT_USER_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1SCALEOFFSET_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SCALEOFFSET_USER_NPARMS; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ALL(JNIEnv *env, jclass cls) { return H5Z_FILTER_ALL; } + +#pragma GCC diagnostic pop + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + diff --git a/java/src/jni/h5Imp.c b/java/src/jni/h5Imp.c new file mode 100644 index 0000000..05d5d59 --- /dev/null +++ b/java/src/jni/h5Imp.c @@ -0,0 +1,181 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * This code is the C-interface called by Java programs to access the + * general library functions of the HDF5 library. + * + * Each routine wraps a single HDF entry point, generally with the + * analogous arguments and return codes. + * + */ + +#include "hdf5.h" +#include <jni.h> +#include "h5jni.h" +#include "h5Imp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5open + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5open(JNIEnv *env, jclass clss) +{ + herr_t retVal = H5open(); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5open */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5close + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5close(JNIEnv *env, jclass clss) +{ + herr_t retVal = H5close(); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5close */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5dont_atexit + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5dont_1atexit(JNIEnv *env, jclass clss) +{ + herr_t retVal = H5dont_atexit(); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5dont_1atexit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5get_libversion + * Signature: ([I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5get_1libversion(JNIEnv *env, jclass clss, jintArray libversion) +{ + unsigned *theArray = NULL; + herr_t status = -1; + jboolean isCopy; + + if (libversion == NULL) { + h5nullArgument(env, "H5get_version: libversion is NULL"); + } /* end if */ + else { + theArray = (unsigned*)ENVPTR->GetIntArrayElements(ENVPAR libversion, &isCopy); + if (theArray == NULL) { + h5JNIFatalError( env, "H5get_libversion: input not pinned"); + } /* end if */ + else { + status = H5get_libversion(&(theArray[0]), &(theArray[1]), &(theArray[2])); + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray,0); + } /* end else */ + } /* end else */ + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5get_1libversion */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5check_version + * Signature: (III)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5check_1version(JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum) +{ + return (jint)H5check_version((unsigned)majnum, (unsigned)minnum, (unsigned)relnum); +} /* end Java_hdf_hdf5lib_H5_H5check_1version */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5garbage_collect + * Signature: ()I + * + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5garbage_1collect(JNIEnv *env, jclass clss) +{ + herr_t retVal = H5garbage_collect(); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5garbage_1collect */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5set_free_list_limits + * Signature: (IIIIII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits(JNIEnv *env, jclass clss, jint reg_global_lim, jint reg_list_lim, + jint arr_global_lim, jint arr_list_lim, jint blk_global_lim, jint blk_list_lim ) +{ + herr_t retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim, + (int)arr_global_lim, (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5is_library_threadsafe + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe(JNIEnv *env, jclass clss) +{ + hbool_t is_ts = false; + H5is_library_threadsafe(&is_ts); + return (jboolean)is_ts; +} /* end Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5Imp.h b/java/src/jni/h5Imp.h new file mode 100644 index 0000000..6600378 --- /dev/null +++ b/java/src/jni/h5Imp.h @@ -0,0 +1,95 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5 */ + +#ifndef _Included_hdf_hdf5lib_H5_H5 +#define _Included_hdf_hdf5lib_H5_H5 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5open + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5open + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5close + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5close + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5dont_atexit + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5dont_1atexit + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5get_libversion + * Signature: ([I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5get_1libversion + (JNIEnv *, jclass, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5check_version + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5check_1version + (JNIEnv *, jclass, jint, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5garbage_collect + * Signature: ()I + * + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5garbage_1collect + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5set_free_list_limits + * Signature: (IIIIII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits + (JNIEnv *, jclass, jint, jint, jint, jint, jint, jint ); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5is_library_threadsafe + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe + (JNIEnv *, jclass); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5 */ diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c new file mode 100644 index 0000000..a081271 --- /dev/null +++ b/java/src/jni/h5aImp.c @@ -0,0 +1,879 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include "h5util.h" +#include <jni.h> +#include <stdlib.h> +#include <string.h> +#include "h5aImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +#ifdef __cplusplus +#define CBENVPTR (cbenv) +#define CBENVPAR +#define JVMPTR (jvm) +#define JVMPAR +#define JVMPAR2 +#else +#define CBENVPTR (*cbenv) +#define CBENVPAR cbenv, +#define JVMPTR (*jvm) +#define JVMPAR jvm +#define JVMPAR2 jvm, +#endif + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data); + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Acreate + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Acreate(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist) +{ + hid_t attr_id = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + attr_id = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT); + + UNPIN_JAVA_STRING(name, aName); + + if (attr_id < 0) + h5libraryError(env); + + return (jlong)attr_id; +} /* end Java_hdf_hdf5lib_H5__1H5Acreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aopen_name + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aopen_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name) +{ + hid_t attr_id = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + attr_id = H5Aopen_name((hid_t)loc_id, aName); + + UNPIN_JAVA_STRING(name,aName); + + if (attr_id < 0) + h5libraryError(env); + + return (jlong)attr_id; +} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aopen_idx + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aopen_1idx(JNIEnv *env, jclass clss, jlong loc_id, jint idx) +{ + hid_t attr_id = H5Aopen_idx((hid_t)loc_id, (unsigned int) idx); + + if (attr_id < 0) + h5libraryError(env); + + return (jlong)attr_id; +} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf) +{ + herr_t status = -1; + jbyte *byteP; + jboolean isCopy; + + if (buf == NULL) { + h5nullArgument( env,"H5Awrite: buf is NULL"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (byteP == NULL) { + h5JNIFatalError(env,"H5Awrite: buf is not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, byteP); + + /* free the buffer without copying back */ + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf) +{ + herr_t status = -1; + jbyte *byteP; + jboolean isCopy; + + if (buf == NULL) { + h5nullArgument( env,"H5Aread: buf is NULL"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (byteP == NULL) { + h5JNIFatalError( env,"H5Aread: buf is not pinned"); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, byteP); + + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_space + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aget_1space(JNIEnv *env, jclass clss, jlong attr_id) +{ + hid_t retVal = -1; + + retVal = H5Aget_space((hid_t)attr_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aget_1space */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_type + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aget_1type(JNIEnv *env, jclass clss, jlong attr_id) +{ + hid_t retVal = -1; + + retVal = H5Aget_type((hid_t)attr_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aget_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1name(JNIEnv *env, jclass clss, jlong attr_id) +{ + char *aName; + jstring str = NULL; + ssize_t buf_size; + + /* get the length of the name */ + buf_size = H5Aget_name((hid_t)attr_id, NULL, 0); + + if (buf_size <= 0) { + h5badArgument(env, "H5Aget_name: buf_size <= 0"); + } /* end if */ + else { + buf_size++; /* add extra space for the null terminator */ + aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); + if (aName == NULL) { + h5outOfMemory(env, "H5Aget_name: malloc failed"); + } /* end if */ + else { + buf_size = H5Aget_name((hid_t)attr_id, (size_t)buf_size, aName); + if (buf_size < 0) { + HDfree(aName); + h5libraryError(env); + } /* end if */ + else { + /* save the string; */ + str = ENVPTR->NewStringUTF(ENVPAR aName); + HDfree(aName); + } /* end else */ + } /* end else */ + } /* end else */ + return str; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_num_attrs + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs(JNIEnv *env, jclass clss, jlong loc_id) +{ + int retVal = -1; + + retVal = H5Aget_num_attrs((hid_t)loc_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Adelete(JNIEnv *env, jclass clss, jlong loc_id, jstring name) +{ + herr_t status = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + status = H5Adelete((hid_t)loc_id, aName); + + UNPIN_JAVA_STRING(name, aName); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Adelete */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Aclose(JNIEnv *env, jclass clss, jlong attr_id) +{ + herr_t retVal = -1; + + if (attr_id > 0) + retVal = H5Aclose((hid_t)attr_id); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Acreate2 + * Signature: (JLjava/lang/String;JJJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Acreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist, jlong access_plist) +{ + hid_t status = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + status = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, + (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist ); + + UNPIN_JAVA_STRING(name, aName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Acreate2 */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aopen(JNIEnv *env, jclass clss, jlong obj_id, jstring name, jlong access_plist) + +{ + hid_t retVal = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + retVal = H5Aopen((hid_t)obj_id, aName, (hid_t)access_plist); + + UNPIN_JAVA_STRING(name, aName); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aopen */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen_by_idx + * Signature: (JLjava/lang/String;IIJJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint idx_type, jint order, jlong n, jlong aapl_id, jlong lapl_id) +{ + hid_t retVal = -1; + const char *aName; + + PIN_JAVA_STRING(name, aName, -1); + + retVal = H5Aopen_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, + (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(name, aName); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx */ + +/* +* Class: hdf_hdf5lib_H5 +* Method: _H5Acreate_by_name +* Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J +*/ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong type_id, jlong space_id, jlong acpl_id, jlong aapl_id, jlong lapl_id) +{ + hid_t retVal = -1; + const char *aName; + const char *attrName; + + PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, -1); + + retVal = H5Acreate_by_name((hid_t)loc_id, aName, attrName, (hid_t)type_id, + (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aexists_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Aexists_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +{ + htri_t retVal = -1; + const char *aName; + const char *attrName; + + PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, JNI_FALSE); + + retVal = H5Aexists_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + + if (retVal < 0) + h5libraryError(env); + + return (jboolean)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Aexists_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Arename + * Signature: (JLjava/lang/String;Ljava/lang/String)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Arename(JNIEnv *env, jclass clss, jlong loc_id, jstring old_attr_name, jstring new_attr_name) +{ + herr_t retVal = -1; + const char *oName; + const char *nName; + + PIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName, -1); + + retVal = H5Arename((hid_t)loc_id, oName, nName); + + UNPIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Arename */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Arename_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Arename_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring old_attr_name, jstring new_attr_name, jlong lapl_id) +{ + herr_t retVal = -1; + const char *aName; + const char *oName; + const char *nName; + + PIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName, -1); + + retVal = H5Arename_by_name((hid_t)loc_id, aName, oName, nName, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Arename_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_name_by_idx + * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +{ + size_t buf_size; + char *aValue; + jlong status_size; + jstring str = NULL; + const char *aName; + + PIN_JAVA_STRING(obj_name, aName, NULL); + + /* get the length of the attribute name */ + status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, + (H5_iter_order_t) order, (hsize_t) n, (char*)NULL, (size_t)0, (hid_t)lapl_id); + + if(status_size < 0) { + UNPIN_JAVA_STRING(obj_name, aName); + h5libraryError(env); + } /* end if */ + else { + buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ + + aValue = (char*)HDmalloc(sizeof(char) * buf_size); + if (aValue == NULL) { + UNPIN_JAVA_STRING(obj_name, aName); + h5outOfMemory(env, "H5Aget_name_by_idx: malloc failed "); + } /* end if */ + else { + status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, + (H5_iter_order_t) order, (hsize_t) n, (char*)aValue, (size_t)buf_size, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(obj_name, aName); + + if (status_size < 0) { + HDfree(aValue); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR aValue); + HDfree(aValue); + if (str == NULL) { + /* exception -- fatal JNI error */ + h5JNIFatalError(env, "H5Aget_name_by_idx: return string not created"); + } /* end if */ + } /* end else */ + } /* end else */ + } /* end else */ + return str; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_storage_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1storage_1size(JNIEnv *env, jclass clss, jlong attr_id) +{ + hsize_t retVal = (hsize_t)-1; + + retVal = H5Aget_storage_size((hid_t)attr_id); +/* probably returns '0' if fails--don't do an exception */ + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1storage_1size */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1info(JNIEnv *env, jclass clss, jlong attr_id) +{ + herr_t status = -1; + H5A_info_t ainfo; + jvalue args[4]; + jobject ret_obj = NULL; + + status = H5Aget_info((hid_t)attr_id, &ainfo); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +{ + herr_t status; + H5A_info_t ainfo; + jvalue args[4]; + jobject ret_obj = NULL; + const char *aName; + + PIN_JAVA_STRING(obj_name, aName, NULL); + + status = H5Aget_info_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, + (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(obj_name, aName); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +{ + const char *aName; + const char *attrName; + herr_t status; + H5A_info_t ainfo; + jvalue args[4]; + jobject ret_obj = NULL; + + PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, NULL); + + status = H5Aget_info_by_name((hid_t)loc_id, aName, attrName, &ainfo, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Adelete_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +{ + herr_t retVal = -1; + const char *aName; + const char *attrName; + + PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName, -1); + + retVal = H5Adelete_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aexists + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Aexists(JNIEnv *env, jclass clss, jlong obj_id, jstring attr_name) +{ + htri_t bval = JNI_FALSE; + const char *aName; + + PIN_JAVA_STRING(attr_name, aName, JNI_FALSE); + + bval = H5Aexists((hid_t)obj_id, aName); + + UNPIN_JAVA_STRING(attr_name, aName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Aexists */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete_by_idx + * Signature: (JLjava/lang/String;IIJJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +{ + herr_t status = -1; + const char *aName; + + PIN_JAVA_STRING0(obj_name, aName); + + status = H5Adelete_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(obj_name, aName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong aapl_id, jlong lapl_id) + +{ + hid_t status = -1; + const char *aName; + const char *oName; + + PIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName, -1); + + status = H5Aopen_by_name((hid_t)loc_id, oName, aName, (hid_t)aapl_id, (hid_t)lapl_id); + + UNPIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist(JNIEnv *env, jclass clss, jlong attr_id) +{ + hid_t retVal = -1; + + retVal = H5Aget_create_plist((hid_t)attr_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist */ + +static herr_t +H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data) { + JNIEnv *cbenv; + jint status = -1; + jclass cls; + jmethodID mid; + jstring str; + jmethodID constructor; + jvalue args[4]; + jobject cb_info_t = NULL; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + + args[0].z = info->corder_valid; + args[1].j = info->corder; + args[2].i = info->cset; + args[3].j = (jlong)info->data_size; + /* get a reference to your class if you don't have it already */ + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5A_info_t"); + if (cls != 0) { + /* get a reference to the constructor; the name is <init> */ + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(ZJIJ)V"); + if (constructor != 0) { + cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); + } /* end if (constructor != 0) */ + } /* end if (cls != 0) */ + } /* end if (mid != 0) */ + } /* end if (cls != 0) */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + + return (herr_t)status; +} /* end H5A_iterate_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aiterate + * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aiterate(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jlong idx, jobject callback_op, jobject op_data) +{ + hsize_t start_idx = (hsize_t)idx; + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); + } /* end if */ + else { + status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)op_data); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aiterate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aiterate_by_name + * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, + jlong idx, jobject callback_op, jobject op_data, jlong access_id) +{ + const char *lName; + hsize_t start_idx = (hsize_t)idx; + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING(name, lName, -1); + + status = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)op_data, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h new file mode 100644 index 0000000..bbc61f5 --- /dev/null +++ b/java/src/jni/h5aImp.h @@ -0,0 +1,273 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5A */ + +#ifndef _Included_hdf_hdf5lib_H5_H5A +#define _Included_hdf_hdf5lib_H5_H5A + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Acreate + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aopen_name + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1name + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aopen_idx + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1idx + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread + (JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_space + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1space + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_type + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1type + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_num_attrs + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Aclose + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Acreate2 + * Signature: (JLjava/lang/String;JJJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate2 +(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen + (JNIEnv *, jclass, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen_by_idx + * Signature: (JLjava/lang/String;IIJJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx + (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong, jlong); + +/* +* Class: hdf_hdf5lib_H5 +* Method: _H5Acreate_by_name +* Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J +*/ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name +(JNIEnv *, jclass, jlong, jstring, jstring, jlong, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aexists_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists_1by_1name + (JNIEnv *, jclass, jlong, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Arename + * Signature: (JLjava/lang/String;Ljava/lang/String)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename + (JNIEnv *, jclass, jlong, jstring, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Arename_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename_1by_1name + (JNIEnv *, jclass, jlong, jstring, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_name_by_idx + * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx + (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_storage_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Aget_1storage_1size + (JNIEnv *, jclass, jlong); + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx + (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_info_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)Lhdf/hdf5lib/structs/H5A_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name + (JNIEnv *, jclass, jlong, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1name + (JNIEnv *, jclass, jlong, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aexists + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Adelete_by_idx + * Signature: (JLjava/lang/String;IIJJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx + (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Aopen_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;JJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name + (JNIEnv *, jclass, jlong, jstring, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aiterate + * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aiterate + (JNIEnv*, jclass, jlong, jint, jint, jlong, jobject, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aiterate_by_name + * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobject, jobject, jlong); + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5A */ diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c new file mode 100644 index 0000000..f70cb5e --- /dev/null +++ b/java/src/jni/h5dImp.c @@ -0,0 +1,1758 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "hdf5.h" +#include "h5util.h" +#include "h5dImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +#ifdef __cplusplus + #ifdef _WINDOWS + #include <direct.h> + #endif + #define CBENVPTR (cbenv) + #define CBENVPAR + #define JVMPTR (jvm) + #define JVMPAR + #define JVMPAR2 +#else + #define CBENVPTR (*cbenv) + #define CBENVPAR cbenv, + #define JVMPTR (*jvm) + #define JVMPAR jvm + #define JVMPAR2 jvm, +#endif + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DreadVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); + +/********************/ +/* Local Macros */ +/********************/ + +#define PIN_BYTE_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_BYTE_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_SHORT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_SHORT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_INT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_INT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_LONG_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \ +} + +#define UNPIN_LONG_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_FLOAT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_FLOAT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_DOUBLE_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_DOUBLE_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \ +} + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dcreate(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist_id) +{ + hid_t dset_id = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT); + + UNPIN_JAVA_STRING(name, fileName); + + if (dset_id < 0) + h5libraryError(env); + + return (jlong)dset_id; +} /* end Java_hdf_hdf5lib_H5__1H5Dcreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dopen + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dopen(JNIEnv *env, jclass clss, jlong loc_id, jstring name) +{ + hid_t dset_id = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + dset_id = H5Dopen2((hid_t)loc_id, fileName, H5P_DEFAULT); + + UNPIN_JAVA_STRING(name, fileName); + if (dset_id < 0) + h5libraryError(env); + + return (jlong)dset_id; +} /* end Java_hdf_hdf5lib_H5__1H5Dopen */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_space + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dget_1space(JNIEnv *env, jclass clss, jlong dataset_id) +{ + hid_t retVal = -1; + + retVal = H5Dget_space((hid_t)dataset_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Dget_1space */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_type + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dget_1type(JNIEnv *env, jclass clss, jlong dataset_id) +{ + hid_t retVal = -1; + + retVal = H5Dget_type((hid_t)dataset_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Dget_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist(JNIEnv *env, jclass clss, jlong dataset_id) +{ + hid_t retVal = -1; + + retVal = H5Dget_create_plist((hid_t)dataset_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist */ + +static htri_t +H5Tdetect_variable_str(hid_t tid) { + htri_t ret_val = 0; + + if (H5Tget_class(tid) == H5T_COMPOUND) { + unsigned i; + unsigned nm = (unsigned)H5Tget_nmembers(tid); + for(i = 0; i < nm; i++) { + htri_t status = 0; + hid_t mtid = 0; + if((mtid = H5Tget_member_type(tid, i)) < 0) + return -1; /* exit immediately on error */ + if((status = H5Tdetect_variable_str(mtid)) < 0) + return status; /* exit immediately on error */ + ret_val |= status; + H5Tclose (mtid); + } /* end for */ + } /* end if */ + else + ret_val = H5Tis_variable_str(tid); + + return ret_val; +} /* end H5Tdetect_variable_str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread + * Signature: (JJJJJ[BZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) +{ + herr_t status; + jbyte *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread: buf does not support variable length type"); + } /* end else if */ + else { + PIN_BYTE_ARRAY(); + + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_BYTE_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_BYTE_ARRAY(0); /* update java buffer for return */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite + * Signature: (JJJJJ[BZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) +{ + herr_t status; + jbyte *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite: buf does not support variable length type"); + } /* end else if */ + else { + PIN_BYTE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */ + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Dclose(JNIEnv *env, jclass clss, jlong dataset_id) +{ + herr_t retVal = -1; + + retVal = H5Dclose((hid_t)dataset_id); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Dclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_storage_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Dget_1storage_1size(JNIEnv *env, jclass clss, jlong dataset_id) +{ + hsize_t retVal = (hsize_t)-1; + + if (dataset_id < 0) { + h5badArgument(env, "H5Dget_storage_size: not a dataset"); + } /* end if */ + else { + retVal = H5Dget_storage_size((hid_t)dataset_id); + } /* end else */ + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Dget_1storage_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dvlen_reclaim + * Signature: (JJJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim(JNIEnv *env, jclass clss, jlong type_id, jlong space_id, + jlong xfer_plist_id, jbyteArray buf) +{ + herr_t status = -1; + jbyte *byteP; + jboolean isCopy; + + if (buf == NULL) { + h5nullArgument(env, "H5Dvlen_reclaim: buf is NULL"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (byteP == NULL) { + h5JNIFatalError(env, "H5Dvlen_reclaim: buf not pinned"); + } /* end if */ + else { + status = H5Dvlen_reclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, byteP); + + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim */ + +/* + //////////////////////////////////////////////////////////////////// + // // + // New APIs for read data from library // + // Using H5Dread(..., Object buf) requires function calls // + // theArray.emptyBytes() and theArray.arrayify(buf), which // + // triples the actual memory needed by the data set. // + // Using the following APIs solves the problem. // + // // + //////////////////////////////////////////////////////////////////// +*/ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_short + * Signature: (JJJJJ[SZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1short(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jshort *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_short: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_short: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread_short: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_short: buf does not support variable length type"); + } /* end else if */ + else { + PIN_SHORT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread_short: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_SHORT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_SHORT_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1short */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_short + * Signature: (JJJJJ[SZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1short(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jshort *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL ) { + h5nullArgument(env, "H5Dwrite_short: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_short: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_short: buf does not support variable length type"); + } /* end else if */ + else { + PIN_SHORT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite_short: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_SHORT_ARRAY(JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1short */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_int + * Signature: (JJJJJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1int(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jint *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_int: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread_int: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_int: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread_int: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_int: buf does not support variable length type"); + } /* end else if */ + else { + PIN_INT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread_int: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_INT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_INT_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_int + * Signature: (JJJJJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1int(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jint *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite_int: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_int: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_int: buf does not support variable length type"); + } /* end else if */ + else { + PIN_INT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite_int: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_INT_ARRAY(JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_long + * Signature: (JJJJJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1long(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jlong *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_long: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread_long: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_long: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread_long: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_long: buf does not support variable length type"); + } /* end else if */ + else { + PIN_LONG_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread_long: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_LONG_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_LONG_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_long + * Signature: (JJJJJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1long(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jlong *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite_long: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_long: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_long: buf does not support variable length type"); + } /* end else if */ + else { + PIN_LONG_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite_long: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_LONG_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_float + * Signature: (JJJJJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1float(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jfloat *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_float: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_float: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread_float: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_float: buf does not support variable length type"); + } /* end else if */ + else { + PIN_FLOAT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread_float: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_FLOAT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_FLOAT_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1float */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_float + * Signature: (JJJJJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1float(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jfloat *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite_float: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_float: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_float: buf does not support variable length type"); + } /* end else if */ + else { + PIN_FLOAT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite_float: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_FLOAT_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1float */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_double + * Signature: (JJJJJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1double(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jdouble *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_double: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread_double: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_double: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dread_double: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dread_double: buf does not support variable length type"); + } /* end else if */ + else { + PIN_DOUBLE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dread_double: buf not pinned"); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + if (status < 0) { + UNPIN_DOUBLE_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_DOUBLE_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1double */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_double + * Signature: (JJJJJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1double(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jdouble *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite_double: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_double: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Dwrite_double: buf does not support variable length type"); + } /* end else if */ + else { + PIN_DOUBLE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dwrite_double: buf not pinned"); + } /* end if */ + else { + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); + + UNPIN_DOUBLE_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1double */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_string + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1string(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) +{ + herr_t status = -1; + char *c_buf; + char *cstr; + size_t str_len; + jsize i; + jsize n; + size_t pos; + jstring jstr; + + c_buf = cstr = NULL; + if (j_buf == NULL) { + h5nullArgument(env, "H5Dread_string: buf is NULL"); + } /* end if */ + else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { + h5nullArgument(env, "H5Dread_string: buf length <= 0"); + } /* end else if */ + else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) { + h5libraryError(env); + } /* end else if */ + else { + if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) { + h5JNIFatalError(env, "H5Dread_string: memory allocation failed."); + } /* end if */ + else { + if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) { + if (cstr) + HDfree(cstr); + cstr = NULL; + h5JNIFatalError(env, "H5Dread_string: memory allocation failed."); + } /* end if */ + else { + status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf); + + if (status < 0) { + if (cstr) + HDfree(cstr); + cstr = NULL; + if (c_buf) + HDfree(c_buf); + c_buf = NULL; + h5libraryError(env); + } /* end if */ + else { + pos = 0; + for (i = 0; i < n; i++) { + HDmemcpy(cstr, c_buf+pos, str_len); + cstr[str_len] = '\0'; + jstr = ENVPTR->NewStringUTF(ENVPAR cstr); + ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr); + pos += str_len; + } /* end for */ + } /* end else */ + + if (c_buf) + HDfree(c_buf); + } /* end else cbuf allocation*/ + + if (cstr) + HDfree(cstr); + } /* end else cstr allocation*/ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1string */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_string + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1string(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) +{ + herr_t status = -1; + char *c_buf; + jsize str_len; + jsize i; + jsize n; + + if (j_buf == NULL) { + h5nullArgument(env, "H5Dwrite_string: buf is NULL"); + } /* end if */ + else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { + h5nullArgument(env, "H5Dwrite_string: buf length <= 0"); + } /* end else if */ + else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) { + h5libraryError(env); + } /* end else if */ + else { + if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) { + h5JNIFatalError(env, "H5Dwrite_string: memory allocation failed."); + } /* end if */ + else { + for (i = 0; i < n; i++) { + jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + strncpy(&c_buf[i * str_len], utf8, str_len); + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for */ + + status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf); + + if (c_buf) + HDfree(c_buf); + c_buf = NULL; + + if (status < 0) { + h5libraryError(env); + } /* end if */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1string */ + +/** + * Read VLEN data into array of arrays. + * Object[] buf contains VL arrays of data points + * Currently only deal with variable length of atomic data types + */ +/* old version */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_VLStrings + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +{ + herr_t status = -1; + htri_t isVlenStr=0; + + if (buf == NULL) { + h5nullArgument(env, "H5Dread_VLStrings: buf is NULL"); + } /* end if */ + else { + isVlenStr = H5Tis_variable_str((hid_t)mem_type_id); + + if (isVlenStr) { + status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, buf); + } /* end if */ + else + h5badArgument(env, "H5Dread_VLStrings: type is not variable length String"); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1VLStrings */ + +herr_t +H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t + file_sid, hid_t xfer_plist_id, jobjectArray buf) +{ + char **strs; + jstring jstr; + jint i; + jint n; + herr_t status = -1; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + strs =(char**)HDcalloc((size_t)n, sizeof(char*)); + + if (strs == NULL) { + h5JNIFatalError(env, "H5DreadVL_str: failed to allocate buff for read variable length strings"); + } /* end if */ + else { + status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs); + + if (status < 0) { + H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); + HDfree(strs); + h5JNIFatalError(env, "H5DreadVL_str: failed to read variable length strings"); + } /* end if */ + else { + for (i=0; i < n; i++) { + jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + H5free_memory (strs[i]); + } /* end for */ + + /* + for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, + H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings + after it is done. + H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); + */ + + HDfree(strs); + } /* end else */ + } /* end else */ + + return status; +} /* end H5DreadVL_str */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_VLStrings + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +{ + herr_t status = -1; + htri_t isVlenStr=0; + + if (buf == NULL) { + h5nullArgument(env, "H5Dwrite_VLStrings: buf is NULL"); + } /* end if */ + else { + isVlenStr = H5Tis_variable_str((hid_t)mem_type_id); + + if (isVlenStr) { + status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, buf); + } /* end if */ + else + h5badArgument(env, "H5Dwrite_VLStrings: type is not variable length String"); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings */ + +herr_t +H5DwriteVL_str(JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t xfer_plist_id, jobjectArray buf) +{ + herr_t status = -1; + char **wdata; + jsize size; + jsize i; + + size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + wdata = (char**)HDmalloc((size_t)size * sizeof (char*)); + + if (!wdata) { + h5JNIFatalError(env, "H5DwriteVL_string: cannot allocate buffer"); + } /* end if */ + else { + HDmemset(wdata, 0, (size_t)size * sizeof(char*)); + for (i = 0; i < size; ++i) { + jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + wdata[i] = (char*)HDmalloc((size_t)length + 1); + if (wdata[i]) { + HDmemset(wdata[i], 0, (size_t)length + 1); + HDstrncpy(wdata[i], utf8, (size_t)length + 1); + } /* end if */ + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for (i = 0; i < size; ++i) */ + + status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, wdata); + + /* now free memory*/ + for (i = 0; i < size; i++) { + if(wdata[i]) { + HDfree(wdata[i]); + } /* end if */ + } /* end for */ + HDfree(wdata); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end H5DwriteVL_str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_reg_ref + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref (JNIEnv *env, jclass clss, + jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +{ + herr_t status = -1; + h5str_t h5str; + size_t size; + hdset_reg_ref_t *ref_data; + jint i; + jint n; + jstring jstr; + + hid_t region = -1; + hid_t did = (hid_t) dataset_id; + hid_t tid = (hid_t) mem_type_id; + hid_t mem_sid = (hid_t) mem_space_id; + hid_t file_sid = (hid_t) file_space_id; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ + ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); + + if (ref_data == NULL) { + h5JNIFatalError(env, "H5Dread_reg_ref: failed to allocate buff for read"); + return -1; + } /* end if */ + + status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data); + + if (status < 0) { + HDfree(ref_data); + h5JNIFatalError(env, "H5Dread_reg_ref: failed to read data"); + return -1; + } /* end if */ + + HDmemset(&h5str, 0, sizeof(h5str_t)); + h5str_new(&h5str, 1024); + for (i=0; i<n; i++) { + h5str.s[0] = '\0'; + h5str_sprintf(&h5str, did, tid, ref_data[i], 0); + jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); + + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + } /* end for */ + + h5str_free(&h5str); + HDfree(ref_data); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_reg_ref_data + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data (JNIEnv *env, jclass clss, + jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +{ + herr_t status = -1; + h5str_t h5str; + size_t size; + hdset_reg_ref_t *ref_data; + jint i; + jint n; + jstring jstr; + + hid_t region_obj; + H5S_sel_type region_type; + + hid_t region = -1; + hid_t did = (hid_t) dataset_id; + hid_t tid = (hid_t) mem_type_id; + hid_t mem_sid = (hid_t) mem_space_id; + hid_t file_sid = (hid_t) file_space_id; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ + ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); + + if (ref_data == NULL) { + h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to allocate buff for read"); + return -1; + } /* end if */ + + status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data); + + if (status < 0) { + HDfree(ref_data); + h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to read data"); + return -1; + } /* end if */ + + HDmemset(&h5str, 0, sizeof(h5str_t)); + h5str_new(&h5str, 1024); + for (i=0; i<n; i++) { + h5str.s[0] = '\0'; + + /* get name of the dataset the region reference points to using H5Rget_name */ + region_obj = H5Rdereference2(did, H5P_DEFAULT, H5R_DATASET_REGION, ref_data[i]); + if (region_obj >= 0) { + region = H5Rget_region(did, H5R_DATASET_REGION, ref_data[i]); + if (region >= 0) { + region_type = H5Sget_select_type(region); + if(region_type==H5S_SEL_POINTS) { + h5str_dump_region_points_data(&h5str, region, region_obj); + } /* end if */ + else { + h5str_dump_region_blocks_data(&h5str, region, region_obj); + } /* end else */ + + H5Sclose(region); + } /* end if */ + H5Dclose(region_obj); + } /* end if */ + jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); + + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + } /* end for */ + + h5str_free(&h5str); + HDfree(ref_data); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate2 + * Signature: (JLjava/lang/String;JJJJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dcreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +{ + hid_t dset_id = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id); + + UNPIN_JAVA_STRING(name, fileName); + if (dset_id < 0) + h5libraryError(env); + + return (jlong)dset_id; +} /* end Java_hdf_hdf5lib_H5__1H5Dcreate2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dopen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dopen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) +{ + hid_t dset_id; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + dset_id = H5Dopen2((hid_t)loc_id, fileName, (hid_t)access_plist); + + UNPIN_JAVA_STRING(name, fileName); + if (dset_id < 0) + h5libraryError(env); + + return (jlong)dset_id; +} /* end Java_hdf_hdf5lib_H5__1H5Dopen2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate_anon + * Signature: (JJJJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Dcreate_1anon(JNIEnv *env, jclass clss, jlong loc_id, jlong type_id, jlong space_id, jlong dcpl_id, jlong dapl_id) +{ + hid_t dset_id = -1; + + dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, (hid_t)dapl_id); + if (dset_id < 0) + h5libraryError(env); + + return (jlong)dset_id; +} /* end Java_hdf_hdf5lib_H5__1H5Dcreate_1anon */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_space_status + * Signature: (J)I; + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dget_1space_1status(JNIEnv *env, jclass clss, jlong loc_id) +{ + H5D_space_status_t space_status = H5D_SPACE_STATUS_ERROR; + + if (H5Dget_space_status((hid_t)loc_id, &space_status) < 0) + h5libraryError(env); + + return (jint)space_status; +} /* end Java_hdf_hdf5lib_H5_H5Dget_1space_1status */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_access_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Dget_1access_1plist(JNIEnv *env, jclass clss, jlong loc_id) +{ + hid_t retVal = -1; + + retVal = H5Dget_access_plist((hid_t)loc_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Dget_1access_1plist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Dget_1offset(JNIEnv *env, jclass clss, jlong loc_id) +{ + haddr_t offset = HADDR_UNDEF; + + offset = H5Dget_offset((hid_t)loc_id); + if (offset == HADDR_UNDEF) + h5libraryError(env); + + return (jlong)offset; +} /* end Java_hdf_hdf5lib_H5_H5Dget_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dvlen_get_buf_size + * Signature: (JJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size(JNIEnv *env, jclass clss, jlong dataset_id, jlong type_id, jlong space_id) +{ + hsize_t sz = 0; + + if (H5Dvlen_get_buf_size((hid_t)dataset_id, (hid_t)type_id, (hid_t)space_id, &sz) < 0) + h5libraryError(env); + + return (jlong)sz; +} /* end Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dfill + * Signature: ([BJ[BJJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Dfill(JNIEnv *env, jclass clss, jbyteArray fill, jlong fill_type_id, jbyteArray buf, jlong buf_type_id, jlong space_id) +{ + herr_t status; + jbyte *fillP; + jbyte *buffP; + jboolean isCopy1; + jboolean isCopy2; + + + if (buf == NULL) { + h5nullArgument(env, "H5Dfill: buf is NULL"); + return; + } /* end if */ + buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy2); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Dfill: buf not pinned"); + return; + } /* end if */ + + if(fill) { + fillP = ENVPTR->GetByteArrayElements(ENVPAR fill, &isCopy1); + if (fillP == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); + h5JNIFatalError( env, "H5Dfill: fill not pinned"); + return; + } /* end if */ + } /* end if */ + else + fillP = NULL; + + status = H5Dfill((const void*)fillP, (hid_t)fill_type_id, (void*)buffP, (hid_t)buf_type_id, (hid_t)space_id); + if(fillP) { + /* free the buffer without copying back */ + /* end if */ ENVPTR->ReleaseByteArrayElements(ENVPAR fill, fillP, JNI_ABORT); + } + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + if (isCopy2 == JNI_TRUE) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0); + } /* end if */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Dfill */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dset_extent + * Signature: (J[J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Dset_1extent(JNIEnv *env, jclass clss, jlong loc_id, jlongArray buf) +{ + herr_t status; + hsize_t *dims; + jlong *buffP; + jsize rank; + jboolean isCopy; + int i = 0; + + if (buf == NULL) { + h5nullArgument(env, "H5Dset_extent: buf is NULL"); + return; + } /* end if */ + + rank = ENVPTR->GetArrayLength(ENVPAR buf); + if (rank <= 0) { + h5JNIFatalError(env, "H5Dset_extent: rank <=0"); + } /* end if */ + else { + buffP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); + if (buffP == NULL) { + h5JNIFatalError( env, "H5Dset_extent: buf not pinned"); + } /* end if */ + else { + dims = (hsize_t*)HDmalloc((size_t)rank * sizeof(hsize_t)); + for (i = 0; i< rank; i++) + dims[i] = (hsize_t)buffP[i]; + + status = H5Dset_extent((hid_t)loc_id, (hsize_t*)dims); + + HDfree (dims); + + /* free the buffer without copying back */ + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, JNI_ABORT); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Dset_1extent */ + +static herr_t +H5D_iterate_cb(void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *op_data) { + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jbyteArray elemArray; + jlongArray pointArray; + jsize size; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I"); + if (mid == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + + if (elem == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + if (point == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + + size = (jsize)H5Tget_size(elem_id); + elemArray = CBENVPTR->NewByteArray(CBENVPAR size); + if (elemArray == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + CBENVPTR->SetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem); + + pointArray = CBENVPTR->NewLongArray(CBENVPAR 2); + if (pointArray == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + CBENVPTR->SetLongArrayRegion(CBENVPAR pointArray, 0, 2, (const jlong *)point); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, (void*)elemArray, elem_id, ndim, pointArray, op_data); + + CBENVPTR->GetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem); + + JVMPTR->DetachCurrentThread(JVMPAR); + + return status; +} /* end H5D_iterate_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Diterate + * Signature: ([BJJLjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Diterate(JNIEnv *env, jclass clss, jbyteArray buf, jlong buf_type, jlong space, + jobject callback_op, jobject op_data) +{ + herr_t status = -1; + jboolean isCopy; + jbyte *buffP; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if (op_data == NULL) { + h5nullArgument(env, "H5Diterate: op_data is NULL"); + return -1; + } /* end if */ + if (callback_op == NULL) { + h5nullArgument(env, "H5Diterate: callback_op is NULL"); + return -1; + } /* end if */ + + if (buf == NULL) { + h5nullArgument(env, "H5Diterate: buf is NULL"); + return -1; + } /* end if */ + buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Diterate: buf not pinned"); + } /* end if */ + else { + status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)op_data); + + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + if (isCopy == JNI_TRUE) { + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0); + } /* end if */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Diterate */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h new file mode 100644 index 0000000..12078e8 --- /dev/null +++ b/java/src/jni/h5dImp.h @@ -0,0 +1,319 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5D */ + +#ifndef _Included_hdf_hdf5lib_H5_H5D +#define _Included_hdf_hdf5lib_H5_H5D + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate + (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dopen + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen + (JNIEnv*, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_space + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1space + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_type + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1type + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread + * Signature: (JJJJJ[BZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jbyteArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite + * Signature: (JJJJJ[BZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jbyteArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Dclose + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_storage_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1storage_1size + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dvlen_reclaim + * Signature: (JJJ[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim + (JNIEnv*, jclass, jlong, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_short + * Signature: (JJJJJ[SZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1short + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jshortArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_short + * Signature: (JJJJJ[SZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1short + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jshortArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_int + * Signature: (JJJJJ[IZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1int + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jintArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_int + * Signature: (JJJJJ[IZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1int + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jintArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_long + * Signature: (JJJJJ[JZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1long + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_long + * Signature: (JJJJJ[JZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1long + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_float + * Signature: (JJJJJ[FZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1float + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jfloatArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_float + * Signature: (JJJJJ[FZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1float + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jfloatArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_double + * Signature: (JJJJJ[DZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1double + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jdoubleArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_double + * Signature: (JJJJJ[DZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1double + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jdoubleArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_string + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1string + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_string + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1string +(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_VLStrings + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1VLStrings +(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dwrite_VLStrings + * Signature: (JJJJJ[BZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_reg_ref + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref +(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dread_reg_ref_data + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate2 + * Signature: (JLjava/lang/String;JJJJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate2 + (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dopen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen2 + (JNIEnv*, jclass, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Dcreate_anon + * Signature: (JJJJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate_1anon + (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_space_status + * Signature: (J)I; + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dget_1space_1status + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_access_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1access_1plist + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dget_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1offset + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dvlen_get_buf_size + * Signature: (JJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size + (JNIEnv*, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dfill + * Signature: ([BJ[BJJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dfill + (JNIEnv*, jclass, jbyteArray, jlong, jbyteArray, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Dset_extent + * Signature: (J[J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dset_1extent + (JNIEnv*, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Diterate + * Signature: ([BJJLjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Diterate + (JNIEnv*, jclass, jbyteArray, jlong, jlong, jobject, jobject); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5D */ diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c new file mode 100644 index 0000000..f0c4135 --- /dev/null +++ b/java/src/jni/h5eImp.c @@ -0,0 +1,524 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * This code is the C-interface called by Java programs to access the + * general library functions of the HDF5 library. + * + * Each routine wraps a single HDF entry point, generally with the + * analogous arguments and return codes. + * + * For details of the HDF libraries, see the HDF Documentation at: + * http://www.hdfgroup.org/HDF5/doc/ + * + */ + +#include <jni.h> +#include <stdlib.h> +#include "hdf5.h" +#include "h5jni.h" +#include "h5eImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +#ifdef __cplusplus + #define CBENVPTR (cbenv) + #define CBENVPAR + #define JVMPTR (jvm) + #define JVMPAR + #define JVMPAR2 +#else /* __cplusplus */ + #define CBENVPTR (*cbenv) + #define CBENVPAR cbenv, + #define JVMPTR (*jvm) + #define JVMPAR jvm + #define JVMPAR2 jvm, +#endif /* __cplusplus */ + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5E_walk_cb(int nindx, const H5E_error2_t *info, void *op_data); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eauto_is_v2 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2(JNIEnv *env, jclass cls, jlong stk_id) +{ + unsigned int is_stack = 0; + + if (stk_id < 0) { + h5badArgument(env, "H5Eauto_is_v2: invalid argument"); + } /* end if */ + else if (H5Eauto_is_v2((hid_t)stk_id, &is_stack) < 0) + h5libraryError(env); + + return (jboolean)is_stack; +} /* end Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eregister_class + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Eregister_1class(JNIEnv *env, jclass cls, jstring cls_name, jstring lib_name, jstring version) +{ + hid_t ret_val = -1; + const char* the_cls_name; + const char* the_lib_name; + const char* the_version; + + PIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version, -1); + + ret_val = H5Eregister_class(the_cls_name, the_lib_name, the_version); + + UNPIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version); + + if (ret_val < 0) + h5libraryError(env); + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Eregister_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eunregister_class + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eunregister_1class(JNIEnv *env, jclass cls, jlong cls_id) +{ + if (cls_id < 0) { + h5badArgument(env, "H5Eunregister_class: invalid argument"); + } /* end if */ + else if (H5Eunregister_class((hid_t)cls_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Eunregister_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclose_msg + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eclose_1msg(JNIEnv *env, jclass cls, jlong err_id) +{ + if (err_id < 0) { + h5badArgument(env, "H5Eclose_msg: invalid argument"); + } /* end if */ + else if (H5Eclose_msg((hid_t)err_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Eclose_1msg */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ecreate_msg + * Signature: (JILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Ecreate_1msg(JNIEnv *env, jclass cls, jlong err_id, jint msg_type, jstring err_msg) +{ + hid_t ret_val = -1; + const char *the_err_msg; + H5E_type_t error_msg_type = (H5E_type_t)msg_type; + + if (err_id < 0) { + h5badArgument(env, "H5Ecreate_msg: invalid argument"); + } /* end if */ + else { + PIN_JAVA_STRING(err_msg, the_err_msg, -1); + + ret_val = H5Ecreate_msg((hid_t)err_id, error_msg_type, the_err_msg); + + UNPIN_JAVA_STRING(err_msg, the_err_msg); + + if (ret_val < 0) + h5libraryError(env); + } /* end else */ + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Ecreate_1msg */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ecreate_stack + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Ecreate_1stack(JNIEnv *env, jclass cls) +{ + hid_t ret_val = -1; + + ret_val = H5Ecreate_stack(); + if (ret_val < 0) + h5libraryError(env); + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Ecreate_1stack */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_current_stack + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Eget_1current_1stack(JNIEnv *env, jclass cls) +{ + hid_t ret_val = -1; + + ret_val = H5Eget_current_stack(); + if (ret_val < 0) + h5libraryError(env); + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Eget_1current_1stack */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclose_stack + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eclose_1stack(JNIEnv *env, jclass cls, jlong stk_id) +{ + if (stk_id < 0) { + h5badArgument(env, "H5Eclose_stack: invalid argument"); + } /* end if */ + else if (H5Eclose_stack((hid_t)stk_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Eclose_1stack */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eprint2 + * Signature: (JLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eprint2(JNIEnv *env, jclass cls, jlong stk_id, jobject stream_obj) +{ + herr_t ret_val = -1; + + if (stk_id < 0) { + h5badArgument(env, "H5Eprint2: invalid argument"); + } /* end if */ + else { + if(!stream_obj) + ret_val = H5Eprint2((hid_t)stk_id, stdout); + else + ret_val = H5Eprint2((hid_t)stk_id, (FILE*)stream_obj); + + if (ret_val < 0) + h5libraryError(env); + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Eprint2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_class_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Eget_1class_1name(JNIEnv *env, jclass cls, jlong cls_id) +{ + char *namePtr; + jstring str = NULL; + ssize_t buf_size; + + if (cls_id < 0) { + h5badArgument(env, "H5Eget_class_name: invalid argument"); + } /* end if */ + else { + /* get the length of the name */ + buf_size = H5Eget_class_name((hid_t)cls_id, NULL, 0); + + if (buf_size < 0) { + h5badArgument( env, "H5Eget_class_name: buf_size < 0"); + } /* end if */ + else if (buf_size == 0) { + h5badArgument( env, "H5Eget_class_name: No class name"); + } /* end else if */ + else { + buf_size++; /* add extra space for the null terminator */ + namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); + if (namePtr == NULL) { + h5outOfMemory( env, "H5Eget_class_name: malloc failed"); + } /* end if */ + else { + buf_size = H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size); + + if (buf_size < 0) { + HDfree(namePtr); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR namePtr); + HDfree(namePtr); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + return str; +} /* end Java_hdf_hdf5lib_H5_H5Eget_1class_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eset_current_stack + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eset_1current_1stack(JNIEnv *env, jclass cls, jlong stk_id) +{ + if (stk_id < 0) { + h5badArgument(env, "H5Eset_current_stack: invalid argument"); + } /* end if */ + else if (H5Eset_current_stack((hid_t)stk_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Eset_1current_1stack */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Epop + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Epop(JNIEnv *env, jclass cls, jlong stk_id, jlong count) +{ + if (stk_id < 0) { + h5badArgument(env, "H5Epop: invalid argument"); + } /* end if */ + else if (H5Epop((hid_t)stk_id, (size_t)count) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Epop */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Epush2 + * Signature: (JLjava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Epush2(JNIEnv *env, jclass cls, jlong stk_id, jstring filename, jstring funcname, + jint linenumber, jlong class_id, jlong major_id, jlong minor_id, jstring err_desc) +{ + herr_t ret_val = -1; + const char* fName; + const char* fncName; + const char* errMsg; + + if (stk_id < 0) { + h5badArgument(env, "H5Epush: invalid argument"); + } /* end if */ + else if (class_id < 0) { + h5badArgument(env, "H5Epush: invalid class_id argument"); + } /* end else if */ + else if (major_id < 0) { + h5badArgument(env, "H5Epush: invalid major_id argument"); + } /* end else if */ + else if (minor_id < 0) { + h5badArgument(env, "H5Epush: invalid minor_id argument"); + } /* end else if */ + else { + PIN_JAVA_STRING_THREE0(filename, fName, funcname, fncName, err_desc, errMsg); + + ret_val = H5Epush2((hid_t)stk_id, fName, fncName, (unsigned)linenumber, (hid_t)class_id, + (hid_t)major_id, (hid_t)minor_id, errMsg); + + UNPIN_JAVA_STRING_THREE(filename, fName, funcname, fncName, err_desc, errMsg); + + if (ret_val < 0) + h5libraryError(env); + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Epush2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclear2 + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Eclear2(JNIEnv *env, jclass cls, jlong stk_id) +{ + if (stk_id < 0) { + h5badArgument(env, "H5Eclear2: invalid argument"); + } /* end if */ + else if (H5Eclear2((hid_t)stk_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Eclear2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_msg + * Signature: (J[I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Eget_1msg(JNIEnv *env, jclass cls, jlong msg_id, jintArray error_msg_type_list) +{ + char *namePtr; + jstring str = NULL; + jboolean isCopy; + ssize_t buf_size; + jint *theArray; + H5E_type_t error_msg_type; + + if (msg_id < 0) { + h5badArgument(env, "H5Eget_msg: invalid argument"); + } /* end if */ + else if (error_msg_type_list == NULL) { + h5nullArgument(env, "H5Eget_msg: error_msg_type_list is NULL"); + } /* end if */ + else { + /* get the length of the name */ + buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0); + + if ((buf_size < 0) || (buf_size == 0)) { + h5JNIFatalError(env, "H5Eget_msg: Invalid message"); + } /* end if */ + else { + buf_size++; /* add extra space for the null terminator */ + namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); + if (namePtr == NULL) { + h5outOfMemory(env, "H5Eget_msg: malloc failed"); + } /* end if */ + else { + theArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR error_msg_type_list, &isCopy); + if (theArray == NULL) { + HDfree(namePtr); + h5JNIFatalError(env, "H5Eget_msg: error_msg_type_list not pinned"); + } /* end if */ + else { + buf_size = H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size); + + if (buf_size < 0) { + HDfree(namePtr); + ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = error_msg_type; + ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, 0); + + str = ENVPTR->NewStringUTF(ENVPAR namePtr); + HDfree(namePtr); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return str; +} /* end Java_hdf_hdf5lib_H5_H5Eget_1msg */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_num + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Eget_1num(JNIEnv *env, jclass cls, jlong stk_id) +{ + ssize_t ret_val = -1; + + if (stk_id < 0) { + h5badArgument(env, "H5Eget_num: invalid argument"); + } /* end if */ + else { + ret_val = H5Eget_num((hid_t)stk_id); + if (ret_val < 0) + h5libraryError(env); + } /* end else */ + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Eget_1num */ + +static herr_t +H5E_walk_cb(int nindx, const H5E_error2_t *info, void *op_data) +{ + JNIEnv *cbenv; + jint status = -1; + jclass cls; + jmethodID mid; + jstring str1, str2, str3; + jmethodID constructor; + jvalue args[7]; + jobject cb_info_t = NULL; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I"); + if (mid != 0) { + args[0].j = info->cls_id; + args[1].j = info->maj_num; + args[2].j = info->min_num; + args[3].i = (jint)info->line; + str1 = CBENVPTR->NewStringUTF(CBENVPAR info->func_name); + args[4].l = str1; + str2 = CBENVPTR->NewStringUTF(CBENVPAR info->file_name); + args[5].l = str2; + str3 = CBENVPTR->NewStringUTF(CBENVPAR info->desc); + args[6].l = str3; + // get a reference to your class if you don't have it already + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5E_error2_t"); + if (cls != 0) { + // get a reference to the constructor; the name is <init> + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + if (constructor != 0) { + cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, nindx, cb_info_t, op_data); + } /* end if (constructor != 0) */ + } /* end if(cls != 0) */ + } /* end if (mid != 0) */ + } /* end if (cls != 0) */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return (herr_t)status; +} /* end H5E_walk_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ewalk2 + * Signature: (JJLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Ewalk2(JNIEnv *env, jclass cls, jlong stk_id, jlong direction, jobject callback_op, jobject op_data) +{ + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Ewalk2: op_data or callback_op is NULL"); + } /* end if */ + else if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void*)op_data) < 0) + h5libraryError(env); +} /* end iJava_hdf_hdf5lib_H5_H5Ewalk2f */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5eImp.h b/java/src/jni/h5eImp.h new file mode 100644 index 0000000..c40c013 --- /dev/null +++ b/java/src/jni/h5eImp.h @@ -0,0 +1,167 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5E */ + +#ifndef _Included_hdf_hdf5lib_H5_H5E +#define _Included_hdf_hdf5lib_H5_H5E + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eauto_is_v2 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eregister_class + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eregister_1class + (JNIEnv *, jclass, jstring, jstring, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eunregister_class + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eunregister_1class + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclose_msg + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1msg + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ecreate_msg + * Signature: (JILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1msg + (JNIEnv *, jclass, jlong, jint, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ecreate_stack + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1stack + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_current_stack + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eget_1current_1stack + (JNIEnv *, jclass); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclose_stack + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1stack + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eprint2 + * Signature: (JLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eprint2 + (JNIEnv *, jclass, jlong, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_class_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1class_1name + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eset_current_stack + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eset_1current_1stack + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Epop + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Epop + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Epush2 + * Signature: (JLjava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Epush2 + (JNIEnv *, jclass, jlong, jstring, jstring, jint, jlong, jlong, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eclear2 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclear2 + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_msg + * Signature: (J[I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1msg + (JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Eget_num + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eget_1num + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ewalk2 + * Signature: (JJLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ewalk2 + (JNIEnv *, jclass, jlong, jlong, jobject, jobject); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5E */ diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c new file mode 100644 index 0000000..b484fb2 --- /dev/null +++ b/java/src/jni/h5fImp.c @@ -0,0 +1,516 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include <stdio.h> +#include <stdlib.h> +#include "hdf5.h" +#include "h5fImp.h" +#include "h5util.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fopen + * Signature: (Ljava/lang/String;IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Fopen(JNIEnv *env, jclass clss, jstring name, jint flags, jlong access_id) +{ + hid_t status = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id ); + + UNPIN_JAVA_STRING(name, fileName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Fopen */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fcreate + * Signature: (Ljava/lang/String;IJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Fcreate(JNIEnv *env, jclass clss, jstring name, jint flags, jlong create_id, jlong access_id) +{ + hid_t status = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id); + + UNPIN_JAVA_STRING(name, fileName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Fcreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fflush + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Fflush(JNIEnv *env, jclass clss, jlong object_id, jint scope) +{ + herr_t retVal = -1; + + retVal = H5Fflush((hid_t)object_id, (H5F_scope_t)scope ); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Fflush */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1name(JNIEnv *env, jclass cls, jlong file_id) +{ + char *namePtr; + jstring str = NULL; + ssize_t buf_size; + + /* get the length of the name */ + buf_size = H5Fget_name((hid_t)file_id, NULL, 0); + + if (buf_size <= 0) { + h5badArgument(env, "H5Fget_name: buf_size <= 0"); + } /* end if */ + else { + buf_size++; /* add extra space for the null terminator */ + namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); + if (namePtr == NULL) { + h5outOfMemory(env, "H5Fget_name: malloc failed"); + } /* end if */ + else { + buf_size = H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size); + if (buf_size < 0) { + HDfree(namePtr); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR namePtr); + HDfree(namePtr); + }/* end else */ + }/* end else */ + }/* end else */ + + return str; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fis_hdf5 + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fis_1hdf5(JNIEnv *env, jclass clss, jstring name) +{ + htri_t bval = JNI_FALSE; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, JNI_FALSE); + + bval = H5Fis_hdf5(fileName); + + UNPIN_JAVA_STRING(name, fileName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist(JNIEnv *env, jclass clss, jlong file_id) +{ + hid_t retVal = -1; + + retVal = H5Fget_create_plist((hid_t)file_id ); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_access_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist(JNIEnv *env, jclass clss, jlong file_id) +{ + hid_t retVal = -1; + + retVal = H5Fget_access_plist((hid_t)file_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_intent + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1intent(JNIEnv *env, jclass cls, jlong file_id) +{ + unsigned intent = 0; + + if (H5Fget_intent((hid_t)file_id, &intent) < 0) + h5libraryError(env); + + return (jint)intent; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1intent */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Fclose(JNIEnv *env, jclass clss, jlong file_id) +{ + herr_t status = -1; + + if (file_id > 0) + status = H5Fclose((hid_t)file_id ); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5__1H5Fclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fmount + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Fmount(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong child_id, jlong plist_id) +{ + herr_t status = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id); + + UNPIN_JAVA_STRING(name, fileName); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Fmount */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Funmount + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Funmount(JNIEnv *env, jclass clss, jlong loc_id, jstring name) +{ + herr_t status = -1; + const char *fileName; + + PIN_JAVA_STRING(name, fileName, -1); + + status = H5Funmount((hid_t)loc_id, fileName); + + UNPIN_JAVA_STRING(name, fileName); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Funmount */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_freespace + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1freespace(JNIEnv *env, jclass cls, jlong file_id) +{ + hssize_t ret_val = H5Fget_freespace((hid_t)file_id); + + if (ret_val < 0) + h5libraryError(env); + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1freespace */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Freopen + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Freopen(JNIEnv *env, jclass clss, jlong file_id) +{ + hid_t retVal = -1; + + retVal = H5Freopen((hid_t)file_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Freopen */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_obj_ids + * Signature: (JIJ[J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids(JNIEnv *env, jclass cls, jlong file_id, jint types, jlong maxObjs, + jlongArray obj_id_list) +{ + ssize_t ret_val = -1; + jlong *obj_id_listP; + jboolean isCopy; + hid_t *id_list; + size_t rank; + size_t i; + + if (obj_id_list == NULL) { + h5nullArgument(env, "H5Fget_obj_ids: obj_id_list is NULL"); + } /* end if */ + else { + obj_id_listP = ENVPTR->GetLongArrayElements(ENVPAR obj_id_list, &isCopy); + if (obj_id_listP == NULL) { + h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not pinned"); + } /* end if */ + else { + rank = (size_t)ENVPTR->GetArrayLength(ENVPAR obj_id_list); + + id_list = (hid_t *)HDmalloc(rank * sizeof(hid_t)); + if (id_list == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT); + h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not converted to hid_t"); + } /* end if */ + else { + ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list); + + if (ret_val < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT); + HDfree(id_list); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < rank; i++) { + obj_id_listP[i] = (jlong)id_list[i]; + } /* end for */ + HDfree(id_list); + ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_obj_count + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1obj_1count(JNIEnv *env, jclass cls, jlong file_id, jint types) +{ + ssize_t ret_val = H5Fget_obj_count((hid_t)file_id, (unsigned int)types); + + if (ret_val < 0) + h5libraryError(env); + + return (jlong)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1count_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_filesize + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1filesize(JNIEnv *env, jclass clss, jlong file_id) +{ + hsize_t size = 0; + + if (H5Fget_filesize ((hid_t)file_id, &size) < 0) + h5libraryError(env); + + return (jlong) size; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1filesize */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_hit_rate + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate(JNIEnv *env, jclass cls, jlong file_id) +{ + double rate = 0.0; + + if (H5Fget_mdc_hit_rate((hid_t)file_id, &rate) < 0) + h5libraryError(env); + + return (jdouble)rate; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size(JNIEnv *env, jclass cls, jlong file_id, jlongArray metadata_cache) +{ + jint size = 0; + jlong *metadata_cache_ptr; + size_t max_size = 0, min_clean_size = 0, cur_size = 0; + int cur_num_entries = -1; + jboolean isCopy; + + if (metadata_cache == NULL) { + h5nullArgument(env, "H5Fget_mdc_size: metadata_cache is NULL"); + } /* end if */ + else { + size = (int)ENVPTR->GetArrayLength(ENVPAR metadata_cache); + if (size < 3) { + h5badArgument(env, "H5Fget_mdc_size: length of metadata_cache < 3."); + } /* end if */ + else { + if (H5Fget_mdc_size((hid_t)file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) { + h5libraryError(env); + } /* end if */ + else { + metadata_cache_ptr = ENVPTR->GetLongArrayElements(ENVPAR metadata_cache, &isCopy); + metadata_cache_ptr[0] = (jlong)max_size; + metadata_cache_ptr[1] = (jlong)min_clean_size; + metadata_cache_ptr[2] = (jlong)cur_size; + ENVPTR->ReleaseLongArrayElements(ENVPAR metadata_cache, metadata_cache_ptr, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)cur_num_entries; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5F_info2_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1info(JNIEnv *env, jclass clss, jlong obj_id) +{ + H5F_info2_t finfo; + jvalue args[9]; + jobject ihinfobuf; + jobject ret_obj = NULL; + + if (H5Fget_info2((hid_t)obj_id, &finfo) < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].j = (jlong)finfo.sohm.msgs_info.index_size; + args[1].j = (jlong)finfo.sohm.msgs_info.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf = ret_obj; + + args[0].i = (jint)finfo.super.version; + args[1].j = (jlong)finfo.super.super_size; + args[2].j = (jlong)finfo.super.super_ext_size; + args[3].i = (jint)finfo.free.version; + args[4].j = (jlong)finfo.free.meta_size; + args[5].j = (jlong)finfo.free.tot_space; + args[6].j = (jint)finfo.sohm.version; + args[7].j = (jlong)finfo.sohm.hdr_size; + args[8].l = ihinfobuf; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5F_info2_t", "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Fget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Freset_mdc_hit_rate_stats + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats(JNIEnv *env, jclass cls, jlong file_id) +{ + if (H5Freset_mdc_hit_rate_stats((hid_t)file_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fclear_elink_file_cache + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache(JNIEnv *env, jclass cls, jlong file_id) +{ + if (H5Fclear_elink_file_cache((hid_t)file_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h new file mode 100644 index 0000000..5a72fab --- /dev/null +++ b/java/src/jni/h5fImp.h @@ -0,0 +1,198 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5F */ + +#ifndef _Included_hdf_hdf5lib_H5_H5F +#define _Included_hdf_hdf5lib_H5_H5F + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fopen + * Signature: (Ljava/lang/String;IJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fopen + (JNIEnv*, jclass, jstring, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fcreate + * Signature: (Ljava/lang/String;IJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fcreate + (JNIEnv*, jclass, jstring, jint, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fflush + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fflush + (JNIEnv*, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Fget_1name + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fis_hdf5 + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1hdf5 + (JNIEnv*, jclass, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_access_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_intent + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1intent + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Fclose + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fmount + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fmount + (JNIEnv*, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Funmount + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Funmount + (JNIEnv*, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_freespace + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1freespace + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Freopen + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Freopen + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_obj_ids + * Signature: (JIJ[J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids + (JNIEnv*, jclass, jlong, jint, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_obj_count + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1obj_1count + (JNIEnv*, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_filesize + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1filesize + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_hit_rate + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size + (JNIEnv*, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Freset_mdc_hit_rate_stats + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5F_info2_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Fget_1info + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fclear_elink_file_cache + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5F */ diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c new file mode 100644 index 0000000..632942a --- /dev/null +++ b/java/src/jni/h5gImp.c @@ -0,0 +1,257 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "hdf5.h" +#include "h5util.h" +#include "h5gImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Gclose(JNIEnv *env, jclass clss, jlong group_id) +{ + herr_t retVal = -1; + + retVal = H5Gclose((hid_t)group_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Gclose */ + +/* + * Create a java object of hdf.h5.structs.H5G_info_t + * public class H5G_info_t { + * public H5G_STORAGE_TYPE storage_type; // Type of storage for links in group + * public long nlinks; // Number of links in group + * public long max_corder; // Current max. creation order value for group + * public int mounted; // Whether group has a file mounted on it + * } + * + */ +jobject +create_H5G_info_t(JNIEnv *env, H5G_info_t group_info) +{ + jclass cls; + jboolean jmounted; + jint storage_type; + jobject obj; + jfieldID fid_storage_type, fid_nlinks, fid_max_corder, fid_mounted; + + cls = ENVPTR->FindClass(ENVPAR "hdf/hdf5lib/structs/H5G_info_t"); + if (cls == NULL) + return NULL; + + obj = ENVPTR->AllocObject(ENVPAR cls); + if (obj == NULL) + return NULL; + + fid_storage_type = ENVPTR->GetFieldID(ENVPAR cls, "storage_type", "I"); + fid_nlinks = ENVPTR->GetFieldID(ENVPAR cls, "nlinks", "J"); + fid_max_corder = ENVPTR->GetFieldID(ENVPAR cls, "max_corder", "J"); + fid_mounted = ENVPTR->GetFieldID(ENVPAR cls, "mounted", "Z"); + + if (fid_storage_type==NULL || fid_nlinks==NULL || fid_max_corder==NULL || fid_mounted == NULL) + return NULL; + + jmounted = (group_info.mounted==0) ? JNI_FALSE : JNI_TRUE; + storage_type = (jint)group_info.storage_type; + + ENVPTR->SetIntField(ENVPAR obj, fid_storage_type, (jint)storage_type); + ENVPTR->SetLongField(ENVPAR obj, fid_nlinks, (jlong)group_info.nlinks); + ENVPTR->SetLongField(ENVPAR obj, fid_max_corder, (jlong)group_info.max_corder); + ENVPTR->SetBooleanField(ENVPAR obj, fid_mounted, jmounted); + + return obj; +} /* end create_H5G_info_t */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gcreate2 + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Gcreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +{ + hid_t group_id = -1; + const char *gName; + + PIN_JAVA_STRING(name, gName, -1); + + group_id = H5Gcreate2((hid_t)loc_id, gName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id ); + + UNPIN_JAVA_STRING(name, gName); + if (group_id < 0) + h5libraryError(env); + + return (jlong)group_id; +} /* end Java_hdf_hdf5lib_H5__1H5Gcreate2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gcreate_anon + * Signature: (JJJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Gcreate_1anon(JNIEnv *env, jclass cls, jlong loc_id, jlong gcpl_id, jlong gapl_id) +{ + hid_t group_id = -1; + + group_id = H5Gcreate_anon((hid_t)loc_id, (hid_t)gcpl_id, (hid_t)gapl_id); + if (group_id < 0) + h5libraryError(env); + + return (jlong)group_id; +} /* end JNICALL */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gopen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Gopen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) +{ + hid_t group_id = -1; + const char *gName; + + PIN_JAVA_STRING(name, gName, -1); + + group_id = H5Gopen2((hid_t)loc_id, gName, (hid_t)access_plist_id ); + + UNPIN_JAVA_STRING(name, gName); + + if (group_id < 0) + h5libraryError(env); + + return (jlong)group_id; +} /* end Java_hdf_hdf5lib_H5__1H5Gopen2 */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1create_1plist(JNIEnv *env, jclass cls, jlong loc_id) +{ + hid_t plist_id = H5Gget_create_plist((hid_t)loc_id); + + if (plist_id < 0) + h5libraryError(env); + + return (jlong)plist_id; +} /* end Java_hdf_hdf5lib_H5_H5Gget_1create_1plist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1info(JNIEnv *env, jclass cls, jlong loc_id) +{ + H5G_info_t group_info; + + if (H5Gget_info((hid_t)loc_id, &group_info) < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + return create_H5G_info_t(env, group_info); +} /* end Java_hdf_hdf5lib_H5_H5Gget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info_by_name + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name(JNIEnv *env, jclass cls, jlong loc_id, jstring name, jlong lapl_id) +{ + herr_t ret_val = -1; + const char *gName; + H5G_info_t group_info; + + PIN_JAVA_STRING(name, gName, NULL); + + ret_val = H5Gget_info_by_name((hid_t)loc_id, gName, &group_info, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(name, gName); + + if (ret_val < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + return create_H5G_info_t(env, group_info); +} /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx(JNIEnv *env, jclass cls, jlong loc_id, jstring name, jint index_type, + jint order, jlong n, jlong lapl_id) +{ + herr_t ret_val = -1; + const char *gName; + H5G_info_t group_info; + H5_index_t cindex_type = (H5_index_t)index_type; + H5_iter_order_t corder = (H5_iter_order_t)order; + + PIN_JAVA_STRING(name, gName, NULL); + + ret_val = H5Gget_info_by_idx((hid_t)loc_id, gName, cindex_type, + corder, (hsize_t)n, &group_info, (hid_t)lapl_id); + + UNPIN_JAVA_STRING(name, gName); + + if (ret_val < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + return create_H5G_info_t(env, group_info); +} /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5gImp.h b/java/src/jni/h5gImp.h new file mode 100644 index 0000000..2b9bc57 --- /dev/null +++ b/java/src/jni/h5gImp.h @@ -0,0 +1,96 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5G */ + +#ifndef _Included_hdf_hdf5lib_H5_H5G +#define _Included_hdf_hdf5lib_H5_H5G + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Gclose + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gcreate2 + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gcreate2 + (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gcreate_anon + * Signature: (JJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gcreate_1anon + (JNIEnv*, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Gopen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gopen2 + (JNIEnv*, jclass, jlong, jstring, jlong); + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_create_plist + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Gget_1create_1plist +(JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info_by_name + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name + (JNIEnv*, jclass, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5G_info_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5G */ diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c new file mode 100644 index 0000000..e7d663f --- /dev/null +++ b/java/src/jni/h5iImp.c @@ -0,0 +1,289 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include <stdlib.h> +#include <jni.h> +#include "h5jni.h" +#include "h5iImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Iget_1type(JNIEnv *env, jclass clss, jlong obj_id) +{ + H5I_type_t retVal = H5I_BADID; + + retVal = H5Iget_type((hid_t)obj_id); + if (retVal == H5I_BADID) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Iget_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_name + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Iget_1name(JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, jlong buf_size) +{ + char *aName; + jstring str; + hssize_t size = -1; + long bs; + + bs = (long)buf_size; + if (bs <= 0) { + h5badArgument(env, "H5Iget_name: buf_size <= 0"); + } /* end if */ + else { + aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); + if (aName == NULL) { + h5outOfMemory(env, "H5Iget_name: malloc failed"); + } /* end if */ + else { + size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size); + if (size < 0) { + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR aName); + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); + } + HDfree(aName); + } + } + return (jlong)size; +} /* end Java_hdf_hdf5lib_H5_H5Iget_1name */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Iget_1ref(JNIEnv *env, jclass clss, jlong obj_id) +{ + int retVal = -1; + + retVal = H5Iget_ref((hid_t)obj_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Iget_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iinc_ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Iinc_1ref(JNIEnv *env, jclass clss, jlong obj_id) +{ + int retVal = -1; + + retVal = H5Iinc_ref((hid_t)obj_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Iinc_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idec_1ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Idec_1ref(JNIEnv *env, jclass clss, jlong obj_id) +{ + int retVal = -1; + + retVal = H5Idec_ref((hid_t)obj_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Idec_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_file_id + * Signature: (J)J + */ + +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Iget_1file_1id(JNIEnv *env, jclass clss, jlong obj_id) +{ + hid_t file_id = -1; + + file_id = H5Iget_file_id((hid_t)obj_id); + if (file_id < 0) + h5libraryError(env); + + return (jlong) file_id; +} /* end Java_hdf_hdf5lib_H5_H5Iget_1file_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Iget_1type_1ref(JNIEnv *env, jclass clss, jint type) +{ + int retVal = -1; + + retVal = H5Iget_type_ref((H5I_type_t)type); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Iget_1type_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idec_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Idec_1type_1ref(JNIEnv *env, jclass clss, jint type) +{ + int retVal = -1; + + retVal = H5Idec_type_ref((H5I_type_t)type); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Idec_1type_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iinc_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref(JNIEnv *env, jclass clss, jint type) +{ + int retVal = -1; + + retVal = H5Iinc_type_ref((H5I_type_t)type); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Inmembers + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Inmembers(JNIEnv *env, jclass clss, jint type) +{ + hsize_t num_members; + + if (H5Inmembers((H5I_type_t)type, &num_members) < 0) + h5libraryError(env); + + return (jint)num_members; +} /* end Java_hdf_hdf5lib_H5_H5Inmembers */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iis_valid + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Iis_1valid(JNIEnv *env, jclass clss, jlong obj_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Iis_valid((hid_t)obj_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Iis_1valid */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Itype_exists + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Itype_1exists(JNIEnv *env, jclass clss, jint type) +{ + htri_t bval = JNI_FALSE; + + bval = H5Itype_exists((H5I_type_t)type); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end else Java_hdf_hdf5lib_H5_H5Itype_1exists */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iclear_type + * Signature: (IZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Iclear_1type(JNIEnv *env, jclass clss, jint type, jboolean force) +{ + if (H5Iclear_type((H5I_type_t)type, (hbool_t)force) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Iclear_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idestroy_type + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Idestroy_1type(JNIEnv *env, jclass clss, jint type) +{ + if (H5Idestroy_type((H5I_type_t)type) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Idestroy_1type */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5iImp.h b/java/src/jni/h5iImp.h new file mode 100644 index 0000000..fe36b5b --- /dev/null +++ b/java/src/jni/h5iImp.h @@ -0,0 +1,143 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5I */ + +#ifndef _Included_hdf_hdf5lib_H5_H5I +#define _Included_hdf_hdf5lib_H5_H5I + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1type + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_name + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name + (JNIEnv*, jclass, jlong, jobjectArray, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1ref + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iinc_ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1ref + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idec_1ref + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1ref + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_file_id + * Signature: (J)J + */ + +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1file_1id + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iget_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1type_1ref + (JNIEnv*, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idec_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1type_1ref + (JNIEnv*, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iinc_type_ref + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref + (JNIEnv*, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Inmembers + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Inmembers + (JNIEnv*, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iis_valid + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Iis_1valid + (JNIEnv*, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Itype_exists + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Itype_1exists + (JNIEnv*, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Iclear_type + * Signature: (IZ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Iclear_1type + (JNIEnv*, jclass, jint, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Idestroy_type + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Idestroy_1type + (JNIEnv*, jclass, jint); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5I */ diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h new file mode 100644 index 0000000..da49eeb --- /dev/null +++ b/java/src/jni/h5jni.h @@ -0,0 +1,249 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#include <jni.h> +#include "H5version.h" +#include <string.h> +#include "H5private.h" + +#ifndef _Included_h5jni +#define _Included_h5jni + +#ifdef __cplusplus + #define ENVPTR (env) + #define ENVPAR + #define ENVONLY + #define CBENVPTR (cbenv) + #define CBENVPAR + #define JVMPTR (jvm) + #define JVMPAR + #define JVMPAR2 +#else /* __cplusplus */ + #define ENVPTR (*env) + #define ENVPAR env, + #define ENVONLY env + #define CBENVPTR (*cbenv) + #define CBENVPAR cbenv, + #define JVMPTR (*jvm) + #define JVMPAR jvm + #define JVMPAR2 jvm, +#endif /* __cplusplus */ + +/* Macros for class access */ +/* Calling code must define ret_obj as jobject */ +#define CALL_CONSTRUCTOR(classname,classsig,args) { \ + jclass cls; \ + jmethodID constructor; \ + cls = ENVPTR->FindClass(ENVPAR (classname)); \ + if (cls == 0) { \ + h5JNIFatalError(env, "JNI error: GetObjectClass\n"); \ + ret_obj = NULL; \ + } \ + constructor = ENVPTR->GetMethodID(ENVPAR cls, "<init>", (classsig)); \ + if (constructor == 0) { \ + h5JNIFatalError(env, "JNI error: GetMethodID failed\n"); \ + ret_obj = NULL; \ + } \ + ret_obj = ENVPTR->NewObjectA(ENVPAR cls, constructor, (args)); \ +} + + +/* Macros for string access */ +#define PIN_JAVA_STRING(javastr,localstr,retdefault) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return (retdefault); \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return (retdefault); \ + } \ +} + +#define PIN_JAVA_STRING0(javastr,localstr) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return; \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return; \ + } \ +} + +#define UNPIN_JAVA_STRING(javastr,localstr) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ +} + +#define PIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str,retdefault) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return (retdefault); \ + } \ + if ((java2str) == NULL) { \ + h5nullArgument(env, "second java string is NULL"); \ + return (retdefault); \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return (retdefault); \ + } \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + return (retdefault); \ + } \ +} + +#define PIN_JAVA_STRING_TWO0(javastr,localstr,java2str,local2str) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return; \ + } \ + if ((java2str) == NULL) { \ + h5nullArgument(env, "second java string is NULL"); \ + return; \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return; \ + } \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + return; \ + } \ +} + +#define UNPIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ +} + +#define PIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str,retdefault) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return (retdefault); \ + } \ + if ((java2str) == NULL) { \ + h5nullArgument(env, "second java string is NULL"); \ + return (retdefault); \ + } \ + if ((java3str) == NULL) { \ + h5nullArgument(env, "third java string is NULL"); \ + return (retdefault); \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return (retdefault); \ + } \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + return (retdefault); \ + } \ + (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ + if ((local3str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ + h5JNIFatalError(env, "third local c string is not pinned"); \ + return (retdefault); \ + } \ +} + +#define PIN_JAVA_STRING_THREE0(javastr,localstr,java2str,local2str,java3str,local3str) { \ + jboolean isCopy; \ + if ((javastr) == NULL) { \ + h5nullArgument(env, "java string is NULL"); \ + return; \ + } \ + if ((java2str) == NULL) { \ + h5nullArgument(env, "second java string is NULL"); \ + return; \ + } \ + if ((java3str) == NULL) { \ + h5nullArgument(env, "third java string is NULL"); \ + return; \ + } \ + (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ + if ((localstr) == NULL) { \ + h5JNIFatalError(env, "local c string is not pinned"); \ + return; \ + } \ + (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ + if ((local2str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + h5JNIFatalError(env, "second local c string is not pinned"); \ + return; \ + } \ + (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ + if ((local3str) == NULL) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ + h5JNIFatalError(env, "third local c string is not pinned"); \ + return; \ + } \ +} + +#define UNPIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ + ENVPTR->ReleaseStringUTFChars(ENVPAR (java3str), (local3str)); \ +} + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern jboolean h5JNIFatalError(JNIEnv *, const char *); +extern jboolean h5nullArgument(JNIEnv *, const char *); +extern jboolean h5badArgument (JNIEnv *, const char *); +extern jboolean h5outOfMemory (JNIEnv *, const char *); +extern jboolean h5libraryError(JNIEnv *env ); +extern jboolean h5raiseException(JNIEnv *, const char *, const char *); +extern jboolean h5unimplemented( JNIEnv *env, const char *functName); + +/* implemented at H5.c */ +extern jint get_enum_value(JNIEnv *env, jobject enum_obj); +extern jobject get_enum_object(JNIEnv *env, const char* enum_class_name, + jint enum_val, const char* enum_field_desc); + +/* implemented at H5G.c */ +extern jobject create_H5G_info_t(JNIEnv *env, H5G_info_t group_info); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_h5jni */ diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c new file mode 100644 index 0000000..739e43b --- /dev/null +++ b/java/src/jni/h5lImp.c @@ -0,0 +1,736 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include <stdlib.h> +#include "hdf5.h" +#include "h5jni.h" +#include "h5lImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info_t *info, void *op_data); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcopy + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lcopy(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + + status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Lcopy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_external + * Signature: (Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lcreate_1external(JNIEnv *env, jclass clss, jstring file_name, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lFileName; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_THREE0(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); + + status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Lcreate_1external */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_hard + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lcreate_1hard(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + + status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Lcreate_1hard */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_soft + * Signature: (Ljava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lcreate_1soft(JNIEnv *env, jclass clss, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + + status = H5Lcreate_soft(lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Lcreate_1soft */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ldelete + * Signature: (JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Ldelete(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + herr_t status = -1; + const char *lName; + + PIN_JAVA_STRING0(name, lName); + + status = H5Ldelete((hid_t)loc_id, lName, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Ldelete */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ldelete_by_idx + * Signature: (JLjava/lang/String;IIJJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong access_id) +{ + hsize_t n = (hsize_t)link_n; + herr_t status; + const char *lName; + + PIN_JAVA_STRING0(name, lName); + + status = H5Ldelete_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lexists + * Signature: (JLjava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Lexists(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + htri_t bval = JNI_FALSE; + const char *lName; + + PIN_JAVA_STRING(name, lName, JNI_FALSE); + + bval = H5Lexists((hid_t)loc_id, lName, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Lexists */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_info + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5L_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Lget_1info(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + jobject ret_obj = NULL; + jvalue args[5]; + herr_t status; + H5L_info_t infobuf; + const char *lName; + + PIN_JAVA_STRING(name, lName, NULL); + + status = H5Lget_info((hid_t)loc_id, lName, &infobuf, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + if(infobuf.type==0) + args[4].j = (jlong)infobuf.u.address; + else + args[4].j = (jlong)infobuf.u.val_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Lget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5L_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong access_id) +{ + jobject ret_obj = NULL; + jvalue args[5]; + herr_t status; + H5L_info_t infobuf; + const char *lName; + + PIN_JAVA_STRING(name, lName, NULL); + + status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + if(infobuf.type==0) + args[4].j = (jlong)infobuf.u.address; + else + args[4].j = (jlong)infobuf.u.val_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); + } /* end els */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_name_by_idx + * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong access_id) +{ + jlong status_size; + jstring str = NULL; + size_t buf_size; + const char *lName; + char *lValue; + + PIN_JAVA_STRING(name, lName, NULL); + + /* get the length of the link name */ + status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)NULL, (size_t)0, H5P_DEFAULT); + if(status_size < 0) { + UNPIN_JAVA_STRING(name, lName); + h5libraryError(env); + } /* end if */ + else { + buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ + + lValue = (char*)HDmalloc(sizeof(char) * buf_size); + if (lValue == NULL) { + UNPIN_JAVA_STRING(name, lName); + h5outOfMemory(env, "H5Lget_name_by_idx: malloc failed "); + } /* end if */ + else { + status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)lValue, (size_t)buf_size, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status_size < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR lValue); + HDfree(lValue); + if (str == NULL) + h5JNIFatalError(env, "H5Lget_name_by_idx: return string not created"); + } /* end else */ + } /* end else */ + } /* end else */ + return str; +} /* end Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_value + * Signature: (JLjava/lang/String;[Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Lget_1value(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jobjectArray link_value, jlong access_id) +{ + size_t buf_size; + herr_t status; + H5L_info_t infobuf; + const char *lName; + char *lValue; + const char *file_name; + const char *obj_name; + jstring str; + + PIN_JAVA_STRING(name, lName, -1); + + infobuf.type = -1; + /* get the length of the link val */ + status = H5Lget_info((hid_t)loc_id, lName, &infobuf, H5P_DEFAULT); + if(status < 0) { + UNPIN_JAVA_STRING(name, lName); + h5libraryError(env); + } /* end if */ + else { + buf_size = infobuf.u.val_size + 1;/* add extra space for the null terminator */ + + if(infobuf.type == H5L_TYPE_HARD) { + UNPIN_JAVA_STRING(name, lName); + h5JNIFatalError(env, "H5Lget_val: link is hard type"); + } /* end if */ + else { + lValue = (char*)HDmalloc(sizeof(char) * buf_size); + if (lValue == NULL) { + UNPIN_JAVA_STRING(name, lName); + h5outOfMemory(env, "H5Lget_val: malloc failed"); + } /* end if */ + else { + status = H5Lget_val((hid_t)loc_id, lName, (void*)lValue, buf_size, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else if(infobuf.type == H5L_TYPE_EXTERNAL) { + status = H5Lunpack_elink_val(lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, &file_name, &obj_name); + if (status < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR obj_name); + if (str == NULL) { + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + + str = ENVPTR->NewStringUTF(ENVPAR file_name); + if (str == NULL) { + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); + HDfree(lValue); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR lValue); + if (str == NULL) { + /* exception -- fatal JNI error */ + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + HDfree(lValue); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return infobuf.type; +} /* end Java_hdf_hdf5lib_H5_H5Lget_1val */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_value_by_idx + * Signature: (JLjava/lang/String;IIJ[Ljava/lang/String;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, + jlong link_n, jobjectArray link_value, jlong access_id) +{ + herr_t status; + size_t buf_size; + H5L_info_t infobuf; + const char *lName; + void *lValue; + const char *file_name; + const char *obj_name; + jstring str; + + PIN_JAVA_STRING(name, lName, -1); + + infobuf.type = -1; + /* get the length of the link valuee */ + status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); + if(status < 0) { + UNPIN_JAVA_STRING(name, lName); + h5libraryError(env); + return -1; + } /* end if */ + else { + buf_size = infobuf.u.val_size; + if(buf_size < 0) { + UNPIN_JAVA_STRING(name, lName); + h5libraryError(env); + return -1; + } /* end if */ + else { + lValue = (void*)HDmalloc(buf_size); + if (lValue == NULL) { + UNPIN_JAVA_STRING(name, lName); + h5outOfMemory(env, "H5Lget_val_by_idx: malloc failed "); + return -1; + } /* end if */ + else { + status = H5Lget_val_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void*)lValue, (size_t)buf_size, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else if(infobuf.type == H5L_TYPE_EXTERNAL) { + status = H5Lunpack_elink_val((char*)lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, (const char**)&file_name, (const char**)&obj_name); + if (status < 0) { + HDfree(lValue); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR obj_name); + if (str == NULL) { + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + + str = ENVPTR->NewStringUTF(ENVPAR file_name); + if (str == NULL) { + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); + HDfree(lValue); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR (char *)lValue); + if (str == NULL) { + HDfree(lValue); + h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); + } /* end if */ + else { + ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); + HDfree(lValue); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + return infobuf.type; +} /* end Java_hdf_hdf5lib_H5_H5Lget_1val_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lmove + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lmove(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + + status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); + +} /* end Java_hdf_hdf5lib_H5_H5Lmove */ + +static herr_t +H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info_t *info, void *op_data) { + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jstring str; + jmethodID constructor; + jvalue args[5]; + jobject cb_info_t = NULL; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_t;)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + + args[0].i = info->type; + args[1].z = info->corder_valid; + args[2].j = info->corder; + args[3].i = info->cset; + if(info->type==0) + args[4].j = (jlong)info->u.address; + else + args[4].j = (jlong)info->u.val_size; + // get a reference to your class if you don't have it already + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5L_info_t"); + if (cls != 0) { + // get a reference to the constructor; the name is <init> + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(IZJIJ)V"); + if (constructor != 0) { + cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5L_iterate_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lvisit + * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Lvisit(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jobject callback_op, jobject op_data) +{ + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Lvisit: op_data or callback_op is NULL"); + } /* end if */ + else { + status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data); + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Lvisit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lvisit_by_name + * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, + jobject callback_op, jobject op_data, jlong access_id) +{ + herr_t status = -1; + const char *lName; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Lvisit_by_name: op_data or callback_op is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING(name, lName, -1); + + status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Literate + * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Literate(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jlong idx, jobject callback_op, jobject op_data) +{ + hsize_t start_idx = (hsize_t)idx; + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Literate: op_data or callback_op is NULL"); + } /* end if */ + else { + status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Literate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Literate_by_name + * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Literate_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, + jlong idx, jobject callback_op, jobject op_data, jlong access_id) +{ + hsize_t start_idx = (hsize_t)idx; + herr_t status = -1; + const char *lName; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if ((op_data == NULL) || (callback_op == NULL)) { + h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING(name, lName, -1); + + status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)op_data, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Literate_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lis_registered + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Lis_1registered(JNIEnv *env, jclass clss, jint link_cls_id) +{ + htri_t ret_val = H5Lis_registered((H5L_type_t)link_cls_id); + + if (ret_val < 0) + h5libraryError(env); + + return (int)ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Lis_1registered */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Lunregister + * Signature: (I)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Lunregister(JNIEnv *env, jclass clss, jint link_cls_id) +{ + if (H5Lunregister((H5L_type_t)link_cls_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Lunregister */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5lImp.h b/java/src/jni/h5lImp.h new file mode 100644 index 0000000..f0a9a63 --- /dev/null +++ b/java/src/jni/h5lImp.h @@ -0,0 +1,183 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5_H5L */ + +#ifndef _Included_hdf_hdf5lib_H5_H5L +#define _Included_hdf_hdf5lib_H5_H5L + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcopy + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcopy + (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_external + * Signature: (Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1external + (JNIEnv*, jclass, jstring, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_hard + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1hard + (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lcreate_soft + * Signature: (Ljava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1soft + (JNIEnv*, jclass, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Ldelete + * Signature: (JLjava/lang/String;J)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ldelete + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Ldelete_by_idx + * Signature: (JLjava/lang/String;IIJJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lexists + * Signature: (JLjava/lang/String;J)Z + */ + JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Lexists + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_info + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5L_info_t; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5L_info_t; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_name_by_idx + * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_value + * Signature: (JLjava/lang/String;[Ljava/lang/String;J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value + (JNIEnv*, jclass, jlong, jstring, jobjectArray, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lget_value_by_idx + * Signature: (JLjava/lang/String;IIJ[Ljava/lang/String;J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobjectArray, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lmove + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lmove + (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lvisit + * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lvisit + (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lvisit_by_name + * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name + (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Literate + * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Literate + (JNIEnv*, jclass, jlong, jint, jint, jlong, jobject, jobject); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Literate_by_name + * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Literate_1by_1name + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobject, jobject, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lis_registered + * Signature: (I)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lis_1registered + (JNIEnv*, jclass, jint); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Lunregister + * Signature: (I)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lunregister + (JNIEnv*, jclass, jint); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5L */ diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c new file mode 100644 index 0000000..c38ec9a --- /dev/null +++ b/java/src/jni/h5oImp.c @@ -0,0 +1,766 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdlib.h> +#include "hdf5.h" +#include "h5jni.h" +#include "h5oImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *op_data); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Oopen(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) +{ + hid_t status; + const char *oName; + + PIN_JAVA_STRING(name, oName, -1); + + status = H5Oopen((hid_t)loc_id, oName, (hid_t)access_plist_id ); + + UNPIN_JAVA_STRING(name, oName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Oopen */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Oclose(JNIEnv *env, jclass clss, jlong object_id) +{ + herr_t retVal = H5Oclose((hid_t)object_id); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Oclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ocopy + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Ocopy(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lCurName; + const char *lDstName; + + PIN_JAVA_STRING_TWO0(cur_name, lCurName, dst_name, lDstName); + + status = H5Ocopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Ocopy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5O_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1info(JNIEnv *env, jclass clss, jlong loc_id) +{ + herr_t status = -1; + H5O_info_t infobuf; + jvalue args[12]; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jobject ret_obj = NULL; + + status = H5Oget_info((hid_t)loc_id, &infobuf); + + if (status < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf1 = ret_obj; + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); + + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_name + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5O_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + const char *lName; + herr_t status = -1; + H5O_info_t infobuf; + jvalue args[12]; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jobject ret_obj = NULL; + + PIN_JAVA_STRING(name, lName, NULL); + + status = H5Oget_info_by_name((hid_t)loc_id, lName, &infobuf, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf1 = ret_obj; + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); + + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5O_info_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, + jstring name, jint index_field, jint order, jlong link_n, jlong access_id) +{ + const char *lName; + herr_t status; + H5O_info_t infobuf; + jvalue args[12]; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jobject ret_obj = NULL; + + PIN_JAVA_STRING(name, lName, NULL); + + status = H5Oget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) { + h5libraryError(env); + return NULL; + } /* end if */ + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf1 = ret_obj; + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); + + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Olink + * Signature: (JJLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Olink(JNIEnv *env, jclass clss, jlong cur_loc_id, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) +{ + herr_t status = -1; + const char *lDstName; + + PIN_JAVA_STRING0(dst_name, lDstName); + + status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + + UNPIN_JAVA_STRING(dst_name, lDstName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Olink */ + +static herr_t +H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info_t *info, void *op_data) +{ + JNIEnv *cbenv; + jint status = -1; + jclass cls; + jmethodID mid; + jstring str; + jmethodID constructor; + jvalue args[12]; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jobject cb_info_t = NULL; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { + /* printf("JNI H5O_iterate_cb error: AttachCurrentThread failed\n"); */ + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls == 0) { + /* printf("JNI H5O_iterate_cb error: GetObjectClass failed\n"); */ + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I"); + if (mid == 0) { + /* printf("JNI H5O_iterate_cb error: GetMethodID failed\n"); */ + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + str = CBENVPTR->NewStringUTF(CBENVPAR name); + + args[0].i = (jint)info->hdr.version; + args[1].i = (jint)info->hdr.nmesgs; + args[2].i = (jint)info->hdr.nchunks; + args[3].i = (jint)info->hdr.flags; + args[4].j = (jlong)info->hdr.space.total; + args[5].j = (jlong)info->hdr.space.meta; + args[6].j = (jlong)info->hdr.space.mesg; + args[7].j = (jlong)info->hdr.space.free; + args[8].j = (jlong)info->hdr.mesg.present; + args[9].j = (jlong)info->hdr.mesg.shared; + // get a reference to the H5_hdr_info_t class + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5O_hdr_info_t"); + if (cls == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + // get a reference to the constructor; the name is <init> + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(IIIIJJJJJJ)V"); + if (constructor == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + hdrinfobuf = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + args[0].j = (jlong)info->meta_size.obj.index_size; + args[1].j = (jlong)info->meta_size.obj.heap_size; + // get a reference to the H5_ih_info_t class + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5_ih_info_t"); + if (cls == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + // get a reference to the constructor; the name is <init> + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(JJ)V"); + if (constructor == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + ihinfobuf1 = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + args[0].j = (jlong)info->meta_size.attr.index_size; + args[1].j = (jlong)info->meta_size.attr.heap_size; + ihinfobuf2 = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + args[0].j = (jlong)info->fileno; + args[1].j = (jlong)info->addr; + args[2].i = info->type; + args[3].i = (jint)info->rc; + args[4].j = (jlong)info->num_attrs; + args[5].j = info->atime; + args[6].j = info->mtime; + args[7].j = info->ctime; + args[8].j = info->btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + // get a reference to the H5O_info_t class + cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5O_info_t"); + if (cls == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + // get a reference to the constructor; the name is <init> + constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V"); + if (constructor == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); + + JVMPTR->DetachCurrentThread(JVMPAR); + + return status; +} /* end H5O_iterate_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ovisit + * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Ovisit(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jobject callback_op, jobject op_data) +{ + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if (op_data == NULL) { + h5nullArgument(env, "H5Ovisit: op_data is NULL"); + return -1; + } /* end if */ + if (callback_op == NULL) { + h5nullArgument(env, "H5Ovisit: callback_op is NULL"); + return -1; + } /* end if */ + + status = H5Ovisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data); + + if (status < 0) + h5libraryError(env); + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Ovisit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Ovisit_by_name + * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, + jobject callback_op, jobject op_data, jlong access_id) +{ + herr_t status = -1; + const char *lName; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if (op_data == NULL) { + h5nullArgument(env, "H5Ovisit_by_name: op_data is NULL"); + return -1; + } /* end if */ + if (callback_op == NULL) { + h5nullArgument(env, "H5Ovisit_by_name: callback_op is NULL"); + return -1; + } /* end if */ + + PIN_JAVA_STRING(name, lName, -1); + + status = H5Ovisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, lName); + + if (status < 0) + h5libraryError(env); + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oset_comment + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Oset_1comment(JNIEnv *env, jclass clss, jlong loc_id, jstring comment) +{ + herr_t status = -1; + const char *oComment; + jboolean isCopy; + + if (comment == NULL) { + oComment = NULL; + } /* end if */ + else { + oComment = ENVPTR->GetStringUTFChars(ENVPAR comment, &isCopy); + if (oComment == NULL) { + h5JNIFatalError( env, "H5Oset_comment: comment not pinned"); + return; + } /* end if */ + } /* end else */ + + status = H5Oset_comment((hid_t)loc_id, oComment); + + if(oComment) + ENVPTR->ReleaseStringUTFChars(ENVPAR comment, oComment); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Oset_1comment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oset_comment_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, + jstring name, jstring comment, jlong access_id) +{ + herr_t status = -1; + const char *oName; + const char *oComment; + + PIN_JAVA_STRING0(name, oName); + + if (comment == NULL) { + oComment = NULL; + } /* end if */ + else { + jboolean isCopy; + oComment = ENVPTR->GetStringUTFChars(ENVPAR comment, &isCopy); + if (oComment == NULL) { + UNPIN_JAVA_STRING(name, oName); + h5JNIFatalError( env, "H5Oset_comment_by_name: comment not pinned"); + return; + } /* end if */ + } /* end else */ + + status = H5Oset_comment_by_name((hid_t)loc_id, oName, oComment, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, oName); + + if(oComment) + ENVPTR->ReleaseStringUTFChars(ENVPAR comment, oComment); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_comment + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1comment(JNIEnv *env, jclass clss, jlong loc_id) +{ + char *oComment; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + /* get the length of the comment */ + buf_size = H5Oget_comment((hid_t)loc_id, NULL, 0); + if (buf_size < 0) { + h5badArgument( env, "H5Oget_comment: buf_size < 0"); + return NULL; + } /* end if */ + if (buf_size == 0) { + return NULL; + } /* end if */ + + buf_size++; /* add extra space for the null terminator */ + oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (oComment == NULL) { + /* exception -- out of memory */ + h5outOfMemory( env, "H5Oget_comment: malloc failed"); + return NULL; + } /* end if */ + + status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size); + + if (status >= 0) { + /* may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR oComment); + HDfree(oComment); + if (str == NULL) { + h5JNIFatalError( env, "H5Oget_comment: return string not allocated"); + } /* end if */ + } /* end if */ + else { + HDfree(oComment); + h5libraryError(env); + } /* end else */ + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1comment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_comment_by_name + * Signature: (JLjava/lang/String;J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + char *oComment; + const char *oName; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + PIN_JAVA_STRING(name, oName, NULL); + + /* get the length of the comment */ + buf_size = H5Oget_comment_by_name((hid_t)loc_id, oName, NULL, 0, (hid_t)access_id); + if (buf_size < 0) { + UNPIN_JAVA_STRING(name, oName); + h5badArgument( env, "H5Oget_comment_by_name: buf_size < 0"); + return NULL; + } /* end if */ + if (buf_size == 0) { + UNPIN_JAVA_STRING(name, oName); + return NULL; + } /* end if */ + + buf_size++; /* add extra space for the null terminator */ + oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (oComment == NULL) { + UNPIN_JAVA_STRING(name, oName); + h5outOfMemory( env, "H5Oget_comment_by_name: malloc failed"); + return NULL; + } /* end if */ + + status = H5Oget_comment_by_name((hid_t)loc_id, oName, oComment, (size_t)buf_size, (hid_t)access_id); + UNPIN_JAVA_STRING(name, oName); + + if (status >= 0) { + /* may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR oComment); + HDfree(oComment); + if (str == NULL) { + h5JNIFatalError( env, "H5Oget_comment_by_name: return string not allocated"); + } /* end if */ + } /* end if */ + else { + HDfree(oComment); + h5libraryError(env); + } /* end else */ + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oexists_by_name + * Signature: (JLjava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Oexists_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +{ + htri_t bval = JNI_FALSE; + const char *oName; + + PIN_JAVA_STRING(name, oName, JNI_FALSE); + + bval = H5Oexists_by_name((hid_t)loc_id, oName, (hid_t)access_id); + + UNPIN_JAVA_STRING(name, oName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Oexists_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Odecr_refcount + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Odecr_1refcount(JNIEnv *env, jclass clss, jlong object_id) +{ + if (H5Odecr_refcount((hid_t)object_id) < 0) + h5libraryError(env); +} +/* end Java_hdf_hdf5lib_H5_H5Odecr_1refcount */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Oincr_refcount + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Oincr_1refcount(JNIEnv *env, jclass clss, jlong object_id) +{ + if (H5Oincr_refcount((hid_t)object_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Oincr_1refcount */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen_by_addr + * Signature: (JJ)J; + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr(JNIEnv *env, jclass clss, jlong loc_id, jlong addr) +{ + hid_t retVal = -1; + + retVal = H5Oopen_by_addr((hid_t)loc_id, (haddr_t)addr ); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen_by_idx + * Signature: (JLjava/lang/String;IIJJ)J; + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong lapl_id) +{ + hid_t retVal = -1; + const char *oName; + + PIN_JAVA_STRING(name, oName, -1); + + retVal = H5Oopen_by_idx((hid_t)loc_id, oName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (hid_t)lapl_id ); + + UNPIN_JAVA_STRING(name, oName); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5oImp.h b/java/src/jni/h5oImp.h new file mode 100644 index 0000000..e6889b2 --- /dev/null +++ b/java/src/jni/h5oImp.h @@ -0,0 +1,175 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5_H5O */ + +#ifndef _Included_hdf_hdf5lib_H5_H5O +#define _Included_hdf_hdf5lib_H5_H5O + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + /* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen + * Signature: (JLjava/lang/String;J)J + */ + JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oclose + * Signature: (J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Oclose + (JNIEnv*, jclass, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Ocopy + * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ocopy + (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info + * Signature: (J)Lhdf/hdf5lib/structs/H5O_info_t; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info + (JNIEnv*, jclass, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_name + * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5O_info_t; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_info_by_idx + * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5O_info_t; + */ + JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Olink + * Signature: (JJLjava/lang/String;JJ)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Olink + (JNIEnv*, jclass, jlong, jlong, jstring, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Ovisit + * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Ovisit + (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Ovisit_by_name + * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I + */ + JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name + (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oset_comment + * Signature: (JLjava/lang/String;)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment + (JNIEnv*, jclass, jlong, jstring); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oset_comment_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;J)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name + (JNIEnv*, jclass, jlong, jstring, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_comment + * Signature: (J)Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment + (JNIEnv*, jclass, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oget_comment_by_name + * Signature: (JLjava/lang/String;J)Ljava/lang/String; + */ + JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oexists_by_name + * Signature: (JLjava/lang/String;J)Z + */ + JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Oexists_1by_1name + (JNIEnv*, jclass, jlong, jstring, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Odecr_refcount + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Odecr_1refcount + (JNIEnv*, jclass, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: H5Oincr_refcount + * Signature: (J)V + */ + JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oincr_1refcount + (JNIEnv*, jclass, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen_by_addr + * Signature: (JJ)J; + */ + JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr + (JNIEnv*, jclass, jlong, jlong); + + /* + * Class: hdf_hdf5lib_H5 + * Method: _H5Oopen_by_idx + * Signature: (JLjava/lang/String;IIJJ)J; + */ + JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx + (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5O */ diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c new file mode 100644 index 0000000..f4fee74 --- /dev/null +++ b/java/src/jni/h5pImp.c @@ -0,0 +1,5344 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdlib.h> +#include "hdf5.h" +#include "h5util.h" +#include "h5pImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; +extern jobject copy_callback; +extern jobject close_callback; +extern jobject create_callback; +extern jobject compare_callback; +extern jobject get_callback; +extern jobject set_callback; +extern jobject delete_callback; + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5P_cls_create_func_cb(hid_t prop_id, void *create_data); +static herr_t H5P_cls_copy_func_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); +static herr_t H5P_cls_close_func_cb(hid_t prop_id, void *close_data); + +static herr_t H5P_prp_create_func_cb(const char *name, size_t size, void *value); +static herr_t H5P_prp_copy_func_cb(const char *name, size_t size, void *value); +static herr_t H5P_prp_close_func_cb(const char *name, size_t size, void *value); +static int H5P_prp_compare_func_cb(void *value1, void *value2, size_t size); +static herr_t H5P_prp_get_func_cb(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P_prp_set_func_cb(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P_prp_delete_func_cb(hid_t prop_id, const char *name, size_t size, void *value); + +static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *op_data); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcreate + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate(JNIEnv *env, jclass clss, jlong type) +{ + hid_t retVal = -1; + + retVal = H5Pcreate((hid_t)type); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pcreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Pclose(JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = 0; + + if (plist > 0) + retVal = H5Pclose((hid_t)plist); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1class(JNIEnv *env, jclass clss, jlong plist) +{ + hid_t retVal = -1; + + retVal = retVal = H5Pget_class((hid_t) plist); + if (retVal == H5P_ROOT) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcopy(JNIEnv *env, jclass clss, jlong plist) +{ + hid_t retVal = -1; + + retVal = H5Pcopy((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pcopy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_version + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1version(JNIEnv *env, jclass clss, jlong plist, jintArray version_info) +{ + herr_t status = -1; + jint *theArray; + jboolean isCopy; + + if (version_info == NULL) { + h5nullArgument(env, "H5Pget_version: version_info input array is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR version_info) < 4) { + h5badArgument(env, "H5Pget_version: version_info input array < 4"); + } /* end else if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR version_info, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_version: version_info not pinned"); + } /* end if */ + else { + status = H5Pget_version((hid_t)plist, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]), (unsigned *)&(theArray[2]), (unsigned *)&(theArray[3])); + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR version_info, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR version_info, theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1version */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_userblock + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1userblock(JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + herr_t retVal = -1; + long sz = (long)size; + + retVal = H5Pset_userblock((hid_t)plist, (hsize_t)sz); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1userblock */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_userblock + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1userblock(JNIEnv *env, jclass clss, jlong plist, jlongArray size) +{ + herr_t status = -1; + jlong *theArray; + jboolean isCopy; + hsize_t s; + + if (size == NULL) { + h5nullArgument(env, "H5Pget_userblock: size is NULL"); + } /* end if */ + else { + theArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_userblock: size not pinned"); + } /* end if */ + else { + status = H5Pget_userblock((hid_t)plist, &s); + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jlong)s; + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1userblock */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sizes + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sizes(JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size) +{ + herr_t retVal = -1; + + retVal = H5Pset_sizes((hid_t)plist, (size_t)sizeof_addr, (size_t)sizeof_size); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sizes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sizes + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sizes(JNIEnv *env, jclass clss, jlong plist, jlongArray size) +{ + herr_t status = -1; + jlong *theArray; + jboolean isCopy; + size_t ss; + size_t sa; + + if (size == NULL) { + h5nullArgument(env, "H5Pget_sizes: size is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) { + h5badArgument(env, "H5Pget_sizes: size input array < 2 elements"); + } + else { + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_sizes: size not pinned"); + } /* end if */ + else { + status = H5Pget_sizes((hid_t)plist, &sa, &ss); + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jlong)sa; + theArray[1] = (jlong)ss; + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sizes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sym_k + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sym_1k(JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk) +{ + herr_t retVal = -1; + + retVal = H5Pset_sym_k((hid_t)plist, (unsigned)ik, (unsigned)lk); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sym_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sym_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sym_1k(JNIEnv *env, jclass clss, jlong plist, jintArray size) +{ + herr_t status = -1; + jint *theArray; + jboolean isCopy; + + if (size == NULL) { + h5nullArgument(env, "H5Pget_sym_k: size is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) { + h5badArgument(env, "H5Pget_sym_k: size < 2 elements"); + } /* end else if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR size, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_sym_k: size not pinned"); + } /* end if */ + else { + status = H5Pget_sym_k((hid_t)plist, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1])); + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sym_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_istore_k + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1istore_1k(JNIEnv *env, jclass clss, jlong plist, jint ik) +{ + herr_t retVal = -1; + + retVal = H5Pset_istore_k((hid_t)plist, (unsigned)ik); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1istore_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_istore_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1istore_1k(JNIEnv *env, jclass clss, jlong plist, jintArray ik) +{ + herr_t status = -1; + jint *theArray; + jboolean isCopy; + + if (ik == NULL) { + h5nullArgument(env, "H5Pget_store_k: ik is NULL"); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR ik, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_store_k: size not pinned"); + } /* end if */ + else { + status = H5Pget_istore_k((hid_t)plist, (unsigned *)&(theArray[0])); + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1istore_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_layout + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1layout(JNIEnv *env, jclass clss, jlong plist, jint layout) +{ + herr_t retVal = -1; + + retVal = H5Pset_layout((hid_t)plist, (H5D_layout_t)layout); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1layout */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_layout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1layout(JNIEnv *env, jclass clss, jlong plist) +{ + H5D_layout_t retVal = H5D_LAYOUT_ERROR; + + retVal = H5Pget_layout((hid_t)plist); + if (retVal == H5D_LAYOUT_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1layout */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk(JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) +{ + herr_t status = -1; + jbyte *theArray; + jboolean isCopy; + hsize_t *da; + hsize_t *lp; + jlong *jlp; + size_t i; + size_t rank; + + if (dim == NULL) { + h5nullArgument(env, "H5Pset_chunk: dim array is NULL"); + } /* end if */ + else { + i = (size_t)ENVPTR->GetArrayLength(ENVPAR dim); + rank = i / sizeof(jlong); + if (rank < ndims) { + h5badArgument(env, "H5Pset_chunk: dims array < ndims"); + } /* end if */ + else { + theArray = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR dim, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pset_chunk: dim array not pinned"); + } /* end if */ + else { + da = lp = (hsize_t *)HDmalloc(rank * sizeof(hsize_t)); + if (da == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pset_chunk: dims not converted to hsize_t"); + } /* end if */ + else { + jlp = (jlong *)theArray; + for (i = 0; i < rank; i++) { + *lp = (hsize_t)*jlp; + lp++; + jlp++; + } /* end if */ + + status = H5Pset_chunk((hid_t)plist, (int)ndims, da); + + ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT); + HDfree(da); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk + * Signature: (JI[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk(JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims) +{ + herr_t status = -1; + jlong *theArray; + jboolean isCopy; + hsize_t *da; + int i; + + if (dims == NULL) { + h5nullArgument(env, "H5Pget_chunk: dims is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR dims) < max_ndims) { + h5badArgument(env, "H5Pget_chunk: dims array < max_ndims"); + } /* end else if */ + else { + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_chunk: input dims not pinned"); + } /* end if */ + else { + da = (hsize_t *)HDmalloc((size_t)max_ndims * sizeof(hsize_t)); + if (da == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_chunk: dims not converted to hsize_t"); + } /* end if */ + else { + status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da); + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT); + HDfree (da); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < max_ndims; i++) { + theArray[i] = (jlong)da[i]; + } + HDfree (da); + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alignment + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alignment(JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment) +{ + herr_t retVal = -1; + long thr = (long)threshold; + long align = (long)alignment; + + retVal = H5Pset_alignment((hid_t)plist, (hsize_t)thr, (hsize_t)align); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1alignment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alignment + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alignment(JNIEnv *env, jclass clss, jlong plist, jlongArray alignment) +{ + herr_t status = -1; + jlong *theArray; + jboolean isCopy; + hsize_t t; + hsize_t a; + + if (alignment == NULL) { + h5nullArgument(env, "H5Pget_alignment: input alignment is NULL"); + } /* end if */ + else { + if (ENVPTR->GetArrayLength(ENVPAR alignment) < 2) { + h5badArgument(env, "H5Pget_alignment: alignment input array < 2"); + } /* end if */ + else { + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR alignment, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_alignment: input array not pinned"); + } /* end if */ + else { + status = H5Pget_alignment((hid_t)plist, &t, &a); + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jlong)t; + theArray[1] = (jlong)a; + ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1alignment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_external + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1external(JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, jlong size) +{ + herr_t status = -1; + const char *fileName; + off_t off; + hsize_t sz; + hid_t plid; + + plid = (hid_t)plist; + off = (off_t)offset; + sz = (hsize_t)size; + + PIN_JAVA_STRING(name, fileName, -1); + + status = H5Pset_external(plid, fileName, off, sz); + + UNPIN_JAVA_STRING(name, fileName); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1external */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external_count + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external_1count(JNIEnv *env, jclass clss, jlong plist) +{ + int retVal = -1; + + retVal = H5Pget_external_count((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1external_1count */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external + * Signature: (JIJ[Ljava/lang/String;[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external(JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size, + jobjectArray name, jlongArray size) +{ + herr_t status = -1; + jlong *theArray; + jboolean isCopy; + char *file; + jstring str; + off_t o; + hsize_t s; + + if (name_size < 0) { + h5badArgument(env, "H5Pget_external: name_size < 0"); + return -1; + } /* end if */ + else if (name_size == 0) { + file = NULL; + } /* end else if */ + else { + file = (char *)HDmalloc(sizeof(char)*(size_t)name_size); + } /* end else */ + + if (size != NULL) { + if (ENVPTR->GetArrayLength(ENVPAR size) < 2) { + HDfree(file); + h5badArgument(env, "H5Pget_external: size input array < 2"); + return -1; + } /* end if */ + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); + if (theArray == NULL) { + HDfree(file); + h5JNIFatalError( env, "H5Pget_external: size array not pinned"); + return -1; + } /* end if */ + } /* end if */ + + status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, + file, (off_t *)&o, (hsize_t *)&s); + if (status < 0) { + if (size != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT); + } /* end if */ + HDfree(file); + h5libraryError(env); + } /* end if */ + else { + if (size != NULL) { + theArray[0] = o; + theArray[1] = (jlong)s; + ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); + } /* end if */ + + if (file != NULL) { + /* NewStringUTF may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR file); + if (str == NULL) { + HDfree(file); + h5JNIFatalError(env, "H5Pget_external: return array not created"); + } /* end if */ + else { + /* SetObjectArrayElement may raise exceptions */ + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); + HDfree(file); + } /* end else */ + } /* end if */ + } /* end else */ + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1external */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1value(JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +{ + jint status = -1; + jbyte *byteP; + jboolean isCopy; + + if (value != NULL) { + byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); + if (byteP == NULL) { + h5JNIFatalError(env, "H5Pget_fill_value: value array not pinned"); + return -1; + } /* end if */ + } /* end if */ + + status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP); + + if (value != NULL) + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1value(JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +{ + jint status = -1; + jbyte *byteP; + jboolean isCopy; + + if (value == NULL) { + h5badArgument(env, "H5Pget_fill_value: value is NULL"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); + if (byteP == NULL) { + h5JNIFatalError(env, "H5Pget_fill_value: value array not pinned"); + } /* end if */ + else { + status = H5Pget_fill_value((hid_t)plist_id, (hid_t)type_id, byteP); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); + } /* end else */ + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, + jlong cd_nelmts, jintArray cd_values) +{ + herr_t status = -1; + jint *theArray; + jboolean isCopy; + + if (cd_values == NULL) { + status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int)flags, (size_t)cd_nelmts, NULL); + if (status < 0) + h5libraryError(env); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pset_filter: input array not pinned"); + }/* end if */ + else { + status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int)flags, (size_t)cd_nelmts, (const unsigned int *)theArray); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, theArray, JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nfilters + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nfilters(JNIEnv *env, jclass clss, jlong plist) +{ + int retVal = -1; + + retVal = H5Pget_nfilters((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nfilters */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags, + jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +{ + herr_t status = -1; + jint *flagsArray; + jlong *cd_nelmtsArray; + jint *cd_valuesArray; + jboolean isCopy; + jstring str; + char *filter; + + if (namelen <= 0) { + h5badArgument(env, "H5Pget_filter: namelen <= 0"); + } /* end if */ + else if (flags == NULL) { + h5badArgument(env, "H5Pget_filter: flags is NULL"); + } /* end else if */ + else if (cd_nelmts == NULL) { + h5badArgument(env, "H5Pget_filter: cd_nelmts is NULL"); + } /* end else if */ + else if (cd_values == NULL) { + h5badArgument(env, "H5Pget_filter: cd_values is NULL"); + } /* end else if */ + else { + filter = (char *)HDmalloc(sizeof(char)*(size_t)namelen); + if (filter == NULL) { + h5outOfMemory(env, "H5Pget_filter: namelent malloc failed"); + return -1; + } /* end if */ + flagsArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); + if (flagsArray == NULL) { + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: flags array not pinned"); + return -1; + } /* end if */ + cd_nelmtsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); + if (cd_nelmtsArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: nelmts array not pinned"); + return -1; + } /* end if */ + cd_valuesArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); + if (cd_valuesArray == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: elmts array not pinned"); + return -1; + } /* end if */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *(cd_nelmtsArray); + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; + unsigned int filter_config; + status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, filter, &filter_config); + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special */ + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); + + /* NewStringUTF may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR filter); + HDfree(filter); + if (str == NULL) { + h5JNIFatalError(env, "H5Pget_filter: return string not pinned"); + } /* end if */ + else { + /* SetObjectArrayElement may throw exceptiosn */ + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_driver + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1driver(JNIEnv *env, jclass clss, jlong plist) +{ + hid_t retVal = -1; + + retVal = H5Pget_driver((hid_t) plist); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1driver */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_cache + * Signature: (JIJJD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1cache(JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts, + jlong rdcc_nbytes, jdouble rdcc_w0) +{ + herr_t retVal = -1; + + retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts, + (size_t)rdcc_nbytes, (double) rdcc_w0); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_cache + * Signature: (J[I[J[J[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1cache(JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts, + jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +{ + herr_t status = -1; + jint mode; + jdouble *w0Array; + jlong *rdcc_nelmtsArray; + jlong *nbytesArray; + jboolean isCopy; + + if (rdcc_w0 == NULL) { + w0Array = (jdouble *)NULL; + } /* end if */ + else { + w0Array = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR rdcc_w0, &isCopy); + if (w0Array == NULL) { + h5JNIFatalError(env, "H5Pget_cache: w0_array array not pinned"); + return -1; + } /* end if */ + } /* end else */ + + if (rdcc_nelmts == NULL) { + rdcc_nelmtsArray = (jlong *) NULL; + } /* end if */ + else { + rdcc_nelmtsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nelmts, &isCopy); + if (rdcc_nelmtsArray == NULL) { + /* exception -- out of memory */ + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); + } + h5JNIFatalError(env, "H5Pget_cache: rdcc_nelmts array not pinned"); + return -1; + } /* end if */ + } /* end else */ + + if (rdcc_nbytes == NULL) { + nbytesArray = (jlong *) NULL; + } /* end if */ + else { + nbytesArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nbytes, &isCopy); + if (nbytesArray == NULL) { + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); + } /* end if */ + if (rdcc_nelmtsArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nelmts, rdcc_nelmtsArray, JNI_ABORT); + } /* end if */ + h5JNIFatalError(env, "H5Pget_cache: nbytesArray array not pinned"); + return -1; + } /* end if */ + } /* end else */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long rdcc_nelmts_temp = *(rdcc_nelmtsArray); + size_t rdcc_nelmts_t = (size_t)rdcc_nelmts_temp; + long long nbytes_temp = *(nbytesArray); + size_t nbytes_t = (size_t)nbytes_temp; + + status = H5Pget_cache((hid_t)plist, (int *)NULL, &rdcc_nelmts_t, + &nbytes_t, (double *)w0Array); + + *rdcc_nelmtsArray = (jlong)rdcc_nelmts_t; + *nbytesArray = (jlong)nbytes_t; + } /* end direct cast special */ + + + if (status < 0) { + mode = JNI_ABORT; + } /* end if */ + else { + mode = 0; /* commit and free */ + } /* end else */ + + if (rdcc_nelmtsArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nelmts, rdcc_nelmtsArray, mode); + } /* end if */ + + if (nbytesArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nbytes, nbytesArray, mode); + } /* end if */ + + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, mode); + } /* end if */ + + if (status < 0) { + h5libraryError(env); + } /* end if */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer + * Signature: (JJ[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer(JNIEnv *env, jclass clss, jlong plist, jlong size, jbyteArray tconv, jbyteArray bkg) +{ + h5unimplemented(env, "H5Pset_buffer: not implemented"); + return -1; +#ifdef notdef + +/* DON'T IMPLEMENT THIS!!! */ + jint status = -1; + jbyte *tconvP; + jbyte *bkgP; + jboolean isCopy; + + if (tconv == NULL) + tconvP = (jbyte *)NULL; + else { + tconvP = ENVPTR->GetByteArrayElements(ENVPAR tconv, &isCopy); + if (tconvP == NULL) { + h5JNIFatalError(env, "H5Pset_buffer: tconv not pinned"); + return -1; + } + } + if (bkg == NULL) + bkgP = (jbyte *)NULL; + else { + bkgP = ENVPTR->GetByteArrayElements(ENVPAR bkg, &isCopy); + if (bkgP == NULL) { + h5JNIFatalError(env, "H5Pset_buffer: bkg not pinned"); + return -1; + } + } + + status = H5Pset_buffer((hid_t)plist, (size_t)size, tconvP, bkgP); + if (status < 0) { + if (tconv != NULL) + ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, JNI_ABORT); + if (bkg != NULL) + ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, JNI_ABORT); + h5libraryError(env); + return -1; + } + + if (tconv != NULL) + ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, 0); + if (bkg != NULL) + ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, 0); + + return status; +#endif +} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer + * Signature: (J[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer(JNIEnv *env, jclass clss, jlong plist, jbyteArray tconv, jbyteArray bkg) +{ + h5unimplemented(env, "H5Pget_buffer: not implemented"); + return -1; +#ifdef notdef + +/* DON'T IMPLEMENT THIS!!! */ + jlong status = -1; + jbyte *tconvP; + jbyte *bkgP; + jboolean isCopy; + + if (tconv == NULL) { + h5nullArgument(env, "H5Pget_buffer: tconv input array is NULL"); + return -1; + } + tconvP = ENVPTR->GetByteArrayElements(ENVPAR tconv, &isCopy); + if (tconvP == NULL) { + h5JNIFatalError(env, "H5Pget_buffer: tconv not pinned"); + return -1; + } + if (bkg == NULL) { + h5nullArgument(env, "H5Pget_buffer: bkg array is NULL"); + return -1; + } + bkgP = ENVPTR->GetByteArrayElements(ENVPAR bkg, &isCopy); + if (bkgP == NULL) { + h5JNIFatalError(env, "H5Pget_buffer: bkg not pinned"); + return -1; + } + + status = H5Pget_buffer((hid_t)plist, tconvP, bkgP); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, JNI_ABORT); + ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, JNI_ABORT); + h5libraryError(env); + return -1; + } + ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, 0); + + return status; +#endif +} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + if (H5Pset_buffer((hid_t)plist, (size_t)size, NULL, NULL) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size(JNIEnv *env, jclass clss, jlong plist) +{ + size_t size = 0; + + size = H5Pget_buffer((hid_t)plist, NULL, NULL); + if (size == 0) + h5libraryError(env); + + return (jlong)size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_preserve + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1preserve(JNIEnv *env, jclass clss, jlong plist, jboolean status) +{ + hbool_t st; + herr_t retVal = -1; + + if (status == JNI_TRUE) { + st = TRUE; + } /* end if */ + else if (status == JNI_FALSE) { + st = false; + } /* end else if */ + else { + h5badArgument(env, "H5Pset_preserve: status not TRUE or FALSE"); + return -1; + } /* end else */ + + retVal = H5Pset_preserve((hid_t)plist, st); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1preserve */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_preserve + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1preserve(JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = -1; + + retVal = H5Pget_preserve((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1preserve */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_deflate + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1deflate(JNIEnv *env, jclass clss, jlong plist, jint level) +{ + herr_t retVal = -1; + + retVal = H5Pset_deflate((hid_t)plist, (unsigned)level); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1deflate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_gc_references + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1gc_1references(JNIEnv *env, jclass clss, jlong fapl_id, jboolean gc_ref) +{ + herr_t retVal = -1; + unsigned gc_ref_val; + + if (gc_ref == JNI_TRUE) + gc_ref_val = 1; + else + gc_ref_val = 0; + + retVal = H5Pset_gc_references((hid_t)fapl_id, gc_ref_val); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1gc_1references */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_gc_references + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1gc_1references(JNIEnv *env, jclass clss, jlong fapl_id) +{ + unsigned gc_ref_val = 0; + jboolean bval = JNI_FALSE; + + if (H5Pget_gc_references((hid_t)fapl_id, (unsigned *)&gc_ref_val) < 0) { + h5libraryError(env); + } /* end if */ + else { + if (gc_ref_val == 1) + bval = JNI_TRUE; + } /* end else */ + + return bval; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1gc_1references */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_btree_ratios + * Signature: (JDDD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios(JNIEnv *env, jclass clss, jlong plist_id, jdouble left, jdouble middle, jdouble right) +{ + herr_t status = -1; + + status = H5Pset_btree_ratios((hid_t)plist_id, (double)left,(double)middle, (double)right); + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_btree_ratios + * Signature: (J[D[D[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios(JNIEnv *env, jclass clss, jlong plist_id, jdoubleArray left, + jdoubleArray middle, jdoubleArray right) +{ + herr_t status = -1; + jdouble *leftP; + jdouble *middleP; + jdouble *rightP; + jboolean isCopy; + + if (left == NULL) { + h5nullArgument(env, "H5Pget_btree_ratios: left input array is NULL"); + } /* end if */ + else if (middle == NULL) { + h5nullArgument(env, "H5Pget_btree_ratios: middle input array is NULL"); + } /* end else if */ + else if (right == NULL) { + h5nullArgument(env, "H5Pget_btree_ratios: right input array is NULL"); + } /* end else if */ + else { + leftP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR left, &isCopy); + if (leftP == NULL) { + h5JNIFatalError(env, "H5Pget_btree_ratios: left not pinned"); + } /* end if */ + else { + middleP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR middle, &isCopy); + if (middleP == NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_btree_ratios: middle not pinned"); + } /* end if */ + else { + rightP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR right, &isCopy); + if (rightP == NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_btree_ratios: middle not pinned"); + } /* end if */ + else { + status = H5Pget_btree_ratios((hid_t)plist_id, (double *)leftP, + (double *)middleP, (double *)rightP); + if (status < 0) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, JNI_ABORT); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR right, rightP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, 0); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, 0); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR right, rightP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_small_data_block_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + long sz = (long)size; + herr_t retVal = -1; + + retVal = H5Pset_small_data_block_size((hid_t)plist, (hsize_t)sz); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_small_data_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size(JNIEnv *env, jclass clss, jlong plist) +{ + hsize_t s; + + if (H5Pget_small_data_block_size((hid_t)plist, &s) < 0) + h5libraryError(env); + + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alloc_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time(JNIEnv *env, jclass clss, jlong plist, jint alloc_time) +{ + herr_t retVal = -1; + + retVal = H5Pset_alloc_time((hid_t)plist, (H5D_alloc_time_t)alloc_time); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alloc_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time(JNIEnv *env, jclass clss, jlong plist, jintArray alloc_time) +{ + herr_t retVal = -1; + jint *theArray; + jboolean isCopy; + H5D_alloc_time_t time; + + if (alloc_time == NULL) { + /* exception ? */ + h5nullArgument(env, "H5Pget_alloc_time: alloc_time is NULL"); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR alloc_time, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_alloc_time: alloc_time not pinned"); + } /* end if */ + else { + retVal = H5Pget_alloc_time((hid_t)plist, &time); + if (retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR alloc_time, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = time; + ENVPTR->ReleaseIntArrayElements(ENVPAR alloc_time, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1time(JNIEnv *env, jclass clss, jlong plist, jint fill_time) +{ + herr_t retVal = -1; + + retVal = H5Pset_fill_time((hid_t)plist, (H5D_fill_time_t)fill_time); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1time(JNIEnv *env, jclass clss, jlong plist, jintArray fill_time) +{ + herr_t retVal = -1; + jint *theArray; + jboolean isCopy; + H5D_fill_time_t time; + + if (fill_time == NULL) { + /* exception ? */ + h5nullArgument(env, "H5Pget_fill_time: fill_time is NULL"); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR fill_time, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_fill_time: fill_time not pinned"); + } /* end if */ + else { + retVal = H5Pget_fill_time((hid_t)plist, &time); + if (retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR fill_time, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jint)time; + ENVPTR->ReleaseIntArrayElements(ENVPAR fill_time, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pfill_value_defined + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined(JNIEnv *env, jclass clss, jlong plist, jintArray status) +{ + herr_t retVal = -1; + jint *theArray; + jboolean isCopy; + H5D_fill_value_t value; + + if (status == NULL) { + /* exception ? */ + h5nullArgument(env, "H5Pfill_value_defined: status is NULL"); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR status, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pfill_value_defined: status not pinned"); + } /* end if */ + else { + retVal = H5Pfill_value_defined((hid_t)plist, &value); + if (retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR status, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = value; + ENVPTR->ReleaseIntArrayElements(ENVPAR status, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fletcher32 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fletcher32(JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = -1; + + retVal = H5Pset_fletcher32((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_edc_check + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1edc_1check(JNIEnv *env, jclass clss, jlong plist, jint check) +{ + herr_t retVal = -1; + + retVal = H5Pset_edc_check((hid_t)plist, (H5Z_EDC_t)check); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1edc_1check */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_edc_check + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1edc_1check(JNIEnv *env, jclass clss, jlong plist) +{ + H5Z_EDC_t retVal = -1; + + retVal = H5Pget_edc_check((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1edc_1check */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shuffle + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shuffle(JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = -1; + + retVal = H5Pset_shuffle((hid_t)plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shuffle */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_szip + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1szip(JNIEnv *env, jclass clss, jlong plist, jint options_mask, jint pixels_per_block) +{ + herr_t retVal = -1; + + retVal = H5Pset_szip((hid_t)plist, (unsigned int)options_mask, (unsigned int)pixels_per_block); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1szip */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_hyper_vector_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size(JNIEnv *env, jclass clss, jlong plist, jlong vector_size) +{ + herr_t retVal = -1; + + retVal = H5Pset_hyper_vector_size((hid_t)plist, (size_t)vector_size); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_hyper_vector_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size(JNIEnv *env, jclass clss, jlong plist, jlongArray vector_size) +{ + herr_t retVal = -1; + jlong *theArray; + size_t size; + jboolean isCopy; + + if (vector_size == NULL) { + /* exception ? */ + h5nullArgument(env, "H5Pget_hyper_vector_size: vector_size is NULL"); + } /* end if */ + else { + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR vector_size, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_hyper_vector_size: vector_size not pinned"); + } /* end if */ + else { + retVal = H5Pget_hyper_vector_size((hid_t)plist, &size); + if (retVal < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR vector_size, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jlong)size; + ENVPTR->ReleaseLongArrayElements(ENVPAR vector_size, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pall_filters_avail + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail(JNIEnv *env, jclass clss, jlong dcpl_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Pall_filters_avail((hid_t)dcpl_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pmodify_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pmodify_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter, + jint flags, jlong cd_nelmts, jintArray cd_values) +{ + herr_t status = -1; + jint *cd_valuesP; + jboolean isCopy; + + if (cd_values == NULL) { + h5nullArgument(env, "H5Pmodify_filter: cd_values is NULL"); + } /* end if */ + else { + cd_valuesP = ENVPTR->GetIntArrayElements(ENVPAR cd_values,&isCopy); + if (cd_valuesP == NULL) { + h5JNIFatalError(env, "H5Pmodify_filter: cd_values not pinned"); + } /* end if */ + else { + status = H5Pmodify_filter((hid_t)plist, (H5Z_filter_t)filter,(const unsigned int)flags, + (size_t)cd_nelmts, (unsigned int *)cd_valuesP); + + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pmodify_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id(JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +{ + jboolean isCopy; + herr_t status = -1; + jint *cd_valuesArray; + jint *flagsArray; + jlong *cd_nelmtsArray; + jstring str; + char *aName; + int i = 0; + int rank; + long bs; + + bs = (long)namelen; + if (bs <= 0) { + h5badArgument(env, "H5Pget_filter_by_id: namelen <= 0"); + } /* end if */ + else if (flags == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: flags is NULL"); + } /* end else if */ + else if (cd_nelmts == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: cd_nelms is NULL"); + } /* end else if */ + else if (cd_values == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: cd_values is NULL"); + } /* end else if */ + else if (name == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: name is NULL"); + } /* end else if */ + else { + aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); + if (aName == NULL) { + h5outOfMemory(env, "H5Pget_filter_by_id: malloc failed"); + return -1; + } /* end if */ + + flagsArray = ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); + if (flagsArray == NULL) { + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); + return -1; + } /* end if */ + + cd_nelmtsArray = ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); + if (cd_nelmtsArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: cd_nelms not pinned"); + return -1; + } /* end if */ + + cd_valuesArray = ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); + rank = ENVPTR->GetArrayLength(ENVPAR cd_values); + if (cd_valuesArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: cd_values array not converted to unsigned int."); + return -1; + } /* end if */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *(cd_nelmtsArray); + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; + unsigned int filter_config; + + status = H5Pget_filter_by_id2( (hid_t)plist, (H5Z_filter_t)filter, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, (char *)aName, &filter_config); + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special */ + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + HDfree(aName); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR aName); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); + + HDfree(aName); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fclose_degree + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree(JNIEnv *env, jclass clss, jlong plist, jint fc_degree) +{ + herr_t retVal = -1; + + retVal = H5Pset_fclose_degree((hid_t)plist, (H5F_close_degree_t)fc_degree); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fclose_degree + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree(JNIEnv *env, jclass clss, jlong plist) +{ + H5F_close_degree_t degree; + + if (H5Pget_fclose_degree((hid_t)plist, °ree) < 0) + h5libraryError(env); + + return (jint)degree; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree */ + + +/********************************************************************** + * * + * File access properties * + * * + **********************************************************************/ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_family + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family(JNIEnv *env, jclass clss, jlong plist, jlong memb_size, jlong memb_plist) +{ + long ms = (long)memb_size; + herr_t retVal = -1; + + retVal = H5Pset_fapl_family((hid_t)plist, (hsize_t)ms, (hid_t)memb_plist); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_family + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family(JNIEnv *env, jclass clss, jlong tid, jlongArray memb_size, jlongArray memb_plist) +{ + herr_t status = -1; + jlong *sizeArray; + jlong *plistArray; + jboolean isCopy; + hsize_t *sa; + size_t i; + size_t rank; + + if (memb_size == NULL) { + h5nullArgument(env, "H5Pget_family: memb_size is NULL"); + } /* end if */ + else if (memb_plist == NULL) { + h5nullArgument(env, "H5Pget_family: memb_plist is NULL"); + } /* end else if */ + else { + sizeArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_size, &isCopy); + if (sizeArray == NULL) { + h5JNIFatalError(env, "H5Pget_family: sizeArray not pinned"); + return -1; + } /* end if */ + rank = (size_t)ENVPTR->GetArrayLength(ENVPAR memb_size); + sa = (hsize_t *)HDmalloc(rank * sizeof(hsize_t)); + if (sa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_size, sizeArray, JNI_ABORT); + h5JNIFatalError(env, "H5Screate-simple: dims not converted to hsize_t"); + return -1; + } /* end if */ + plistArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_plist, &isCopy); + if (plistArray == NULL) { + HDfree(sa); + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_size, sizeArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_family: plistArray not pinned"); + return -1; + } /* end if */ + + status = H5Pget_fapl_family ((hid_t)tid, sa, (hid_t *)plistArray); + + if (status < 0) { + HDfree(sa); + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_size, sizeArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_plist, plistArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < rank; i++) { + sizeArray[i] = (jlong)sa[i]; + } /* end for */ + HDfree(sa); + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_size, sizeArray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_plist, plistArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_core + * Signature: (JJZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core(JNIEnv *env, jclass clss, jlong fapl_id, jlong increment, jboolean backing_store) +{ + herr_t retVal = -1; + + retVal = H5Pset_fapl_core((hid_t)fapl_id, (size_t)increment, (hbool_t)backing_store); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_core + * Signature: (J[J[Z)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core(JNIEnv *env, jclass clss, jlong fapl_id, jlongArray increment, jbooleanArray backing_store) +{ + herr_t status = -1; + jlong *incArray; + jboolean *backArray; + jboolean isCopy; + + if (increment == NULL) { + h5nullArgument(env, "H5Pget_fapl_core: increment is NULL"); + } /* end if */ + else if (backing_store == NULL) { + h5nullArgument(env, "H5Pget_fapl_core: backing_store is NULL"); + } /* end else if */ + else { + incArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR increment, &isCopy); + if (incArray == NULL) { + h5JNIFatalError(env, "H5Pget_fapl_core: incArray not pinned"); + return -1; + } /* end if */ + + backArray = (jboolean *)ENVPTR->GetBooleanArrayElements(ENVPAR backing_store, &isCopy); + if (backArray == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR increment, incArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_fapl_core: backArray not pinned"); + return -1; + } /* end if */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long inc_temp = *(incArray); + size_t inc_t = (size_t)inc_temp; + + status = H5Pget_fapl_core((hid_t)fapl_id, &inc_t, (hbool_t *)backArray); + + *incArray = (jlong)inc_t; + } /* end direct cast special */ + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR increment, incArray, JNI_ABORT); + ENVPTR->ReleaseBooleanArrayElements(ENVPAR backing_store, backArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseLongArrayElements(ENVPAR increment, incArray, 0); + ENVPTR->ReleaseBooleanArrayElements(ENVPAR backing_store, backArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_family_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1family_1offset(JNIEnv *env, jclass clss, jlong fapl_id, jlong offset) +{ + herr_t retVal = -1; + + retVal = H5Pset_family_offset ((hid_t)fapl_id, (hsize_t)offset); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1family_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_family_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1family_1offset(JNIEnv *env, jclass clss, jlong fapl_id) +{ + hsize_t offset = 0; + herr_t retVal = -1; + + retVal = H5Pget_family_offset ((hid_t)fapl_id, &offset); + if (retVal < 0) + h5libraryError(env); + + return (jlong)offset; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1family_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_log + * Signature: (JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log(JNIEnv *env, jclass clss, jlong fapl_id, jstring logfile, jlong flags, jlong buf_size) +{ + herr_t retVal = -1; + const char *pLogfile; + + PIN_JAVA_STRING0(logfile, pLogfile); + + retVal = H5Pset_fapl_log( (hid_t)fapl_id, pLogfile, (unsigned long long)flags, (size_t)buf_size ); + + UNPIN_JAVA_STRING(logfile, pLogfile); + + if (retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove_filter + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5P1remove_1filter(JNIEnv *env, jclass clss, jlong obj_id, jint filter) +{ + herr_t status = -1; + + status = H5Premove_filter ((hid_t)obj_id, (H5Z_filter_t)filter); + if (status < 0) + h5libraryError(env); + + return status; +} /* end Java_hdf_hdf5lib_H5_H5P1remove_1filter */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset + * Signature: (JLjava/lang/String;I)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pset(JNIEnv *env, jclass clss, jlong plid, jstring name, jint val) +{ + hid_t retVal = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Pset((hid_t)plid, cstr, &val); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pexist + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pexist(JNIEnv *env, jclass clss, jlong plid, jstring name) +{ + hid_t retVal = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Pexist((hid_t)plid, cstr); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pexist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_size + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1size(JNIEnv *env, jclass clss, jlong plid, jstring name) +{ + hid_t retVal = -1; + const char *cstr; + size_t size; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Pget_size((hid_t)plid, cstr, &size); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jlong) size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nprops + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nprops(JNIEnv *env, jclass clss, jlong plid) +{ + size_t nprops; + + if (H5Pget_nprops((hid_t)plid, &nprops) < 0) + h5libraryError(env); + + return (jlong)nprops; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nprops */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1class_1name(JNIEnv *env, jclass clss, jlong plid) +{ + char *c_str; + jstring j_str; + + c_str = H5Pget_class_name((hid_t)plid); + if (c_str == NULL) { + h5libraryError(env); + } /* end if */ + else { + j_str = ENVPTR->NewStringUTF(ENVPAR c_str); + H5free_memory(c_str); + + if (j_str == NULL) + h5JNIFatalError(env,"H5Pget_class_name: return string failed"); + } /* end else */ + return j_str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class_parent + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1class_1parent(JNIEnv *env, jclass clss, jlong plid) +{ + hid_t retVal = -1; + + retVal = H5Pget_class_parent((hid_t)plid); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1parent */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pisa_class + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pisa_1class(JNIEnv *env, jclass clss, jlong plid, jlong pcls) +{ + htri_t retVal = -1; + + retVal = H5Pisa_class((hid_t)plid, (hid_t)pcls); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pisa_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget(JNIEnv *env, jclass clss, jlong plid, jstring name) +{ + herr_t retVal = -1; + const char *cstr; + jint val; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Pget((hid_t)plid, cstr, &val); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jint)val; +} /* end Java_hdf_hdf5lib_H5_H5Pget */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pequal + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pequal(JNIEnv *env, jclass clss, jlong plid1, jlong plid2) +{ + htri_t retVal = -1; + + retVal = H5Pequal((hid_t)plid1, (hid_t)plid2); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pequal */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcopy_prop + * Signature: (JJLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pcopy_1prop(JNIEnv *env, jclass clss, jlong dst_plid, jlong src_plid, jstring name) +{ + herr_t retVal = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Pcopy_prop((hid_t)dst_plid, (hid_t)src_plid, cstr); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pcopy_1prop */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Premove(JNIEnv *env, jclass clss, jlong plid, jstring name) +{ + herr_t retVal = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Premove((hid_t)plid, cstr); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Premove */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Punregister + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Punregister(JNIEnv *env, jclass clss, jlong plid, jstring name) +{ + herr_t retVal = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + retVal = H5Punregister((hid_t)plid, cstr); + + UNPIN_JAVA_STRING(name, cstr); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Punregister */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pclose_class + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Pclose_1class(JNIEnv *env, jclass clss, jlong plid) +{ + herr_t retVal = -1; + + retVal = H5Pclose_class((hid_t)plid); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter2(JNIEnv *env, jclass clss, jlong plist, jint filter_number, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, + jobjectArray name, jintArray filter_config) +{ + herr_t status = -1; + jint *flagsArray; + jlong *cd_nelmtsArray; + jint *cd_valuesArray; + jint *filter_configArray; + jboolean isCopy; + char *filter; + jstring str; + + if (namelen <= 0) { + h5badArgument(env, "H5Pget_filter: namelen <= 0"); + } /* end if */ + else if (flags == NULL) { + h5badArgument(env, "H5Pget_filter: flags is NULL"); + } /* end else if */ + else if (cd_nelmts == NULL) { + h5badArgument(env, "H5Pget_filter: cd_nelmts is NULL"); + } /* end else if */ + else if (filter_config == NULL) { + h5badArgument(env, "H5Pget_filter: filter_config is NULL"); + } /* end else if */ + else { + filter = (char*)HDmalloc(sizeof(char)*(size_t)namelen); + if (filter == NULL) { + h5outOfMemory(env, "H5Pget_filter: namelent malloc failed"); + return -1; + } /* end if */ + flagsArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); + if (flagsArray == NULL) { + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: flags array not pinned"); + return -1; + } /* end if */ + + cd_nelmtsArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); + if (cd_nelmtsArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: nelmts array not pinned"); + return -1; + } /* end if */ + filter_configArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR filter_config, &isCopy); + if (filter_configArray == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: filter_config array not pinned"); + return -1; + } /* end if */ + + if (*cd_nelmtsArray == 0 && cd_values == NULL) { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = 0; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; + + status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, NULL, + (size_t)namelen, filter, (unsigned int *)filter_configArray); + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end if */ + else { + if (cd_values == NULL) { + h5badArgument(env, "H5Pget_filter: cd_values is NULL"); + return -1; + } /* end if */ + cd_valuesArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); + if (cd_valuesArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5JNIFatalError(env, "H5Pget_filter: elmts array not pinned"); + return -1; + } /* end if */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *(cd_nelmtsArray); + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; + + status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, filter, (unsigned int *)filter_configArray); + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special */ + } /* end else */ + + if (status < 0) { + if (cd_values) + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(filter); + h5libraryError(env); + } /* end if */ + else { + if (cd_values) + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); + /* NewStringUTF may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR filter); + HDfree(filter); + if (str == NULL) + h5JNIFatalError(env, "H5Pget_filter: return string not pinned"); + else + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2(JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name, jintArray filter_config) +{ + herr_t status = -1; + int i = 0; + jint *cd_valuesArray; + jint *flagsArray; + jint *filter_configArray; + jlong *cd_nelmtsArray; + jboolean isCopy; + long bs; + char *aName; + jstring str; + + bs = (long)namelen; + if (bs <= 0) { + h5badArgument(env, "H5Pget_filter_by_id: namelen <= 0"); + } /* end if */ + else if (flags == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: flags is NULL"); + } /* end else if */ + else if (cd_nelmts == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: cd_nelms is NULL"); + } /* end else if */ + else if (cd_values == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: cd_values is NULL"); + } /* end else if */ + else if (name == NULL) { + h5nullArgument(env, "H5Pget_filter_by_id: name is NULL"); + } /* end else if */ + else if (filter_config == NULL) { + h5badArgument(env, "H5Pget_filter_by_id: filter_config is NULL"); + } /* end else if */ + else { + aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); + if (aName == NULL) { + h5outOfMemory(env, "H5Pget_filter_by_id: malloc failed"); + return -1; + } /* end if */ + flagsArray = ENVPTR->GetIntArrayElements(ENVPAR flags,&isCopy); + if (flagsArray == NULL) { + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); + return -1; + } /* end if */ + cd_nelmtsArray = ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); + if (cd_nelmtsArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: cd_nelms not pinned"); + return -1; + } /* end if */ + cd_valuesArray = ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); + if (cd_valuesArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: cd_values array not converted to unsigned int."); + return -1; + } /* end if */ + filter_configArray = ENVPTR->GetIntArrayElements(ENVPAR filter_config, &isCopy); + if (filter_configArray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + HDfree(aName); + h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); + return -1; + } /* end if */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *(cd_nelmtsArray); + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; + + status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, (char *)aName, (unsigned int *)filter_configArray); + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special handling */ + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); + HDfree(aName); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR aName); + HDfree(aName); + ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nlinks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nlinks(JNIEnv *env, jclass clss, jlong lapl_id) +{ + size_t nlinks; + if (H5Pget_nlinks((hid_t)lapl_id, &nlinks) < 0) + h5libraryError(env); + + return (jlong) nlinks; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nlinks */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nlinks + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nlinks(JNIEnv *env, jclass clss, jlong lapl_id, jlong nlinks) +{ + herr_t retVal = -1; + + if (nlinks <= 0) { + h5badArgument(env, "H5Pset_1nlinks: nlinks_l <= 0"); + } /* end if */ + else { + retVal = H5Pset_nlinks((hid_t)lapl_id, (size_t)nlinks); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1nlinks */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_libver_bounds + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds(JNIEnv *env, jclass clss, jlong fapl_id, jintArray libver) +{ + herr_t retVal = -1; + H5F_libver_t *theArray = NULL; + jboolean isCopy; + + if (libver == NULL) { + h5nullArgument(env, "H5Pget_libver_bounds: libversion bounds is NULL"); + } /* end if */ + else { + theArray = (H5F_libver_t*)ENVPTR->GetIntArrayElements(ENVPAR libver, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_libver_bounds: input not pinned"); + } /* end if */ + else { + retVal = H5Pget_libver_bounds((hid_t)fapl_id, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR libver, (jint*)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR libver, (jint*)theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_libver_bounds + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds(JNIEnv *env, jclass clss, jlong fapl_id, jint low, jint high) +{ + herr_t retVal = -1; + + if ((H5F_libver_t)high != H5F_LIBVER_LATEST) { + h5badArgument(env, "H5Pset_libver_bounds: invalid high library version bound"); + } /* end if */ + else if(((H5F_libver_t)low !=H5F_LIBVER_EARLIEST) && ((H5F_libver_t)low != H5F_LIBVER_LATEST)) { + h5badArgument(env, "H5Pset_libver_bounds: invalid low library version bound"); + } /* end else if */ + else { + retVal = H5Pset_libver_bounds((hid_t)fapl_id, (H5F_libver_t)low, (H5F_libver_t)high); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order(JNIEnv *env, jclass clss, jlong gcpl_id) +{ + unsigned crt_order_flags; + + if(H5Pget_link_creation_order((hid_t)gcpl_id, &crt_order_flags) < 0) + h5libraryError(env); + + return (jint)crt_order_flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order(JNIEnv *env, jclass clss, jlong gcpl_id, jint crt_order_flags) +{ + herr_t retVal = -1; + + retVal = H5Pset_link_creation_order((hid_t)gcpl_id, (unsigned)crt_order_flags); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order(JNIEnv *env, jclass clss, jlong ocpl_id) +{ + unsigned crt_order_flags; + + if(H5Pget_attr_creation_order((hid_t)ocpl_id, &crt_order_flags) < 0) + h5libraryError(env); + + return (jint)crt_order_flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order(JNIEnv *env, jclass clss, jlong ocpl_id, jint crt_order_flags) +{ + herr_t retVal = -1; + + retVal = H5Pset_attr_creation_order((hid_t)ocpl_id, (unsigned)crt_order_flags); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_copy_object + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1copy_1object(JNIEnv *env, jclass clss, jlong ocp_plist_id, jint copy_options) +{ + herr_t retVal = -1; + + retVal = H5Pset_copy_object((hid_t)ocp_plist_id, (unsigned)copy_options); + if(retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1copy_1object */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_copy_object + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1copy_1object(JNIEnv *env, jclass clss, jlong ocp_plist_id) +{ + unsigned copy_options; + + if(H5Pget_copy_object((hid_t)ocp_plist_id, ©_options) < 0) + h5libraryError(env); + + return (jint)copy_options; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1copy_1object */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_create_intermediate_group + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group(JNIEnv *env, jclass clss, jlong lcpl_id, jboolean crt_intermed_group) +{ + herr_t retVal = -1; + + retVal = H5Pset_create_intermediate_group((hid_t)lcpl_id, (unsigned)crt_intermed_group); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_create_intermediate_group + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group(JNIEnv *env, jclass clss, jlong lcpl_id) +{ + unsigned crt_intermed_group; + + if(H5Pget_create_intermediate_group((hid_t)lcpl_id, &crt_intermed_group) < 0) + h5libraryError(env); + + return (jboolean)crt_intermed_group; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_data_transform + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1data_1transform(JNIEnv *env, jclass clss, jlong plist_id, jstring expression) +{ + herr_t retVal = -1; + const char *express; + + PIN_JAVA_STRING(expression, express, -1); + + retVal = H5Pset_data_transform((hid_t)plist_id, express); + + UNPIN_JAVA_STRING(expression, express); + + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1data_1transform */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_data_transform + * Signature: (J[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1data_1transform(JNIEnv *env, jclass clss, jlong plist_id, jobjectArray expression, jlong size) +{ + size_t buf_size; + char *express; + jlong express_size = -1; + jstring str = NULL; + + if (size <= 0) { + h5badArgument(env, "H5Pget_data_transform: size <= 0"); + } /* end if */ + else { + express_size = (jlong)H5Pget_data_transform((hid_t)plist_id, (char*)NULL, (size_t)size); + if(express_size < 0) { + h5libraryError(env); + } /* end if */ + else { + buf_size = (size_t)express_size + 1;/* add extra space for the null terminator */ + express = (char*)HDmalloc(sizeof(char) * buf_size); + if (express == NULL) { + h5outOfMemory(env, "H5Pget_data_transform: malloc failed "); + } /* end if */ + else { + express_size = (jlong)H5Pget_data_transform((hid_t)plist_id, express, (size_t)size); + if (express_size < 0) { + HDfree(express); + h5libraryError(env); + } + else { + str = ENVPTR->NewStringUTF(ENVPAR express); + HDfree(express); + if (str == NULL) + h5JNIFatalError(env, "H5Pget_data_transform: return string not created"); + else + ENVPTR->SetObjectArrayElement(ENVPAR expression, 0, str); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + return express_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1data_1transform */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_acc_flags + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags(JNIEnv *env, jclass clss, jlong lapl_id) +{ + unsigned flags; + + if(H5Pget_elink_acc_flags((hid_t)lapl_id, &flags) < 0) + h5libraryError(env); + + return (jint)flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_acc_flags + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags(JNIEnv *env, jclass clss, jlong lapl_id, jint flags) +{ + herr_t retVal = -1; + + if (((unsigned) flags != H5F_ACC_RDWR) && + ((unsigned) flags != H5F_ACC_RDONLY) && + ((unsigned) flags != H5F_ACC_DEFAULT)) { + h5badArgument(env, "H5Pset_elink_acc_flags: invalid flags value"); + } /* end if */ + else { + retVal = H5Pset_elink_acc_flags((hid_t)lapl_id, (unsigned)flags); + if (retVal < 0) + h5libraryError(env); + } /* end else */ + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change(JNIEnv *env, jclass clss, jlong gcpl_id, jint max_compact, jint min_dense) +{ + herr_t retVal = -1; + + if(max_compact < min_dense) { + h5badArgument(env, "H5Pset_link_phase_change: max compact value must be >= min dense value"); + } /* end if */ + else if(max_compact > 65535) { + h5badArgument(env, "H5Pset_link_phase_change: max compact value must be < 65536"); + } /* end else if */ + else if(min_dense > 65535) { + h5badArgument(env, "H5Pset_link_phase_change: min dense value must be < 65536"); + } /* end else if */ + else { + retVal = H5Pset_link_phase_change((hid_t)gcpl_id, (unsigned)max_compact, (unsigned)min_dense); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray links) +{ + herr_t retVal = -1; + unsigned *theArray = NULL; + jboolean isCopy; + + if (links == NULL) { + h5nullArgument( env, "H5Pget_link_phase_change: links is NULL"); + } /* end if */ + else { + theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR links, &isCopy); + if (theArray == NULL) { + h5JNIFatalError( env, "H5Pget_link_phase_change: input not pinned"); + } /* end if */ + else { + retVal = H5Pget_link_phase_change((hid_t)gcpl_id, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR links, (jint *)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR links, (jint *)theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change(JNIEnv *env, jclass clss, jlong ocpl_id, jintArray attributes) +{ + herr_t retVal = -1; + unsigned *theArray = NULL; + jboolean isCopy; + + if (attributes == NULL) { + h5nullArgument(env, "H5Pget_attr_phase_change: attributes is NULL"); + } /* end if */ + else { + theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR attributes, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_attr_phase_change: input not pinned"); + } /* end if */ + else { + retVal = H5Pget_attr_phase_change((hid_t)ocpl_id, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR attributes, (jint *)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR attributes, (jint *)theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_phase_change + * Signature: (JII)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change(JNIEnv *env, jclass clss, jlong ocpl_id, jint max_compact, jint min_dense) +{ + herr_t retVal = -1; + + retVal = H5Pset_attr_phase_change((hid_t)ocpl_id, (unsigned)max_compact, (unsigned)min_dense); + if(retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change(JNIEnv *env, jclass clss, jlong fcpl_id, jintArray size) +{ + herr_t retVal = -1; + unsigned *theArray = NULL; + jboolean isCopy; + + if (size == NULL) { + h5nullArgument(env, "H5Pget_shared_mesg_phase_change: size is NULL"); + } /* end if */ + else { + theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR size, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_shared_mesg_phase_change: input not pinned"); + } /* end if */ + else { + retVal = H5Pget_shared_mesg_phase_change((hid_t)fcpl_id, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR size, (jint *)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR size, (jint *)theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change(JNIEnv *env, jclass clss, jlong fcpl_id, jint max_list, jint min_btree) +{ + herr_t retVal = -1; + + /* Check that values are sensible. The min_btree value must be no greater + * than the max list plus one. + * + * Range check to make certain they will fit into encoded form. + */ + + if(max_list + 1 < min_btree) { + h5badArgument(env, "H5Pset_shared_mesg_phase_change: minimum B-tree value is greater than maximum list value"); + } /* end if */ + else if(max_list > H5O_SHMESG_MAX_LIST_SIZE) { + h5badArgument(env, "H5Pset_shared_mesg_phase_change: max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + } /* end else if */ + else if(min_btree > H5O_SHMESG_MAX_LIST_SIZE) { + h5badArgument(env, "H5Pset_shared_mesg_phase_change: min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + } /* end else if */ + else { + retVal = H5Pset_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned)max_list, (unsigned)min_btree); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_nindexes + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes(JNIEnv *env, jclass clss, jlong fcpl_id) +{ + unsigned nindexes; + + if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) + h5libraryError(env); + + return (jint)nindexes; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_nindexes + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes(JNIEnv *env, jclass clss, jlong plist_id, jint nindexes) +{ + herr_t retVal = -1; + + if (nindexes > H5O_SHMESG_MAX_NINDEXES) { + h5badArgument(env, "H5Pset_shared_mesg_nindexes: number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); + } /* end if */ + else { + retVal = H5Pset_shared_mesg_nindexes((hid_t)plist_id, (unsigned)nindexes); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_index + * Signature: (JIII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index(JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, + jint mesg_type_flags, jint min_mesg_size) +{ + herr_t retVal = -1; + unsigned nindexes;/* Number of SOHM indexes */ + + /* Check arguments */ + if(mesg_type_flags > H5O_SHMESG_ALL_FLAG) { + h5badArgument(env, "H5Pset_shared_mesg_index: unrecognized flags in mesg_type_flags"); + } /* end if */ + else if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) { /* Read the current number of indexes */ + h5libraryError(env); + } /* end else if */ + else { + /* Range check */ + if((unsigned)index_num >= nindexes) { + h5badArgument(env, "H5Pset_shared_mesg_index: index_num is too large; no such index"); + } /* end if */ + else { + retVal = H5Pset_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned) mesg_type_flags, (unsigned) min_mesg_size); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_index + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index(JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, jintArray mesg_info) +{ + herr_t retVal = -1; + unsigned nindexes;/* Number of SOHM indexes */ + unsigned *theArray = NULL; + jboolean isCopy; + + /* Read the current number of indexes */ + if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes)<0) { + h5libraryError(env); + } /* end if */ + else { + /* Range check */ + if((unsigned)index_num >= nindexes) { + h5badArgument(env, "H5Pget_shared_mesg_index: index_num is too large; no such index"); + } /* end if */ + else if (mesg_info == NULL) { + h5nullArgument(env, "H5Pget_shared_mesg_index: mesg_info is NULL"); + } /* end else if */ + else { + theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR mesg_info, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_shared_mesg_index: input not pinned"); + } /* end if */ + else { + retVal = H5Pget_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR mesg_info, (jint*)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR mesg_info, (jint*)theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_local_heap_size_hint + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint(JNIEnv *env, jclass clss, jlong gcpl_id, jlong size_hint) +{ + herr_t retVal = -1; + + retVal = H5Pset_local_heap_size_hint((hid_t)gcpl_id, (size_t)size_hint); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_local_heap_size_hint + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint(JNIEnv *env, jclass clss, jlong gcpl_id) +{ + size_t size_hint; + + if(H5Pget_local_heap_size_hint((hid_t)gcpl_id, &size_hint) < 0) + h5libraryError(env); + + return (jlong)size_hint; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nbit + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nbit(JNIEnv *env, jclass clss, jlong plist_id) +{ + herr_t retVal = -1; + + retVal = H5Pset_nbit((hid_t)plist_id); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1nbit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_scaleoffset + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset(JNIEnv *env, jclass clss, jlong plist_id, jint scale_type, jint scale_factor) +{ + herr_t retVal = -1; + + /* Check arguments */ + if(scale_factor < 0) { + h5badArgument(env, "H5Pset_scaleoffset: scale factor must be > 0"); + } /* end if */ + else { + if(scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT){ + h5badArgument(env, "H5Pset_scaleoffset: invalid scale type"); + } /* end if */ + else { + retVal = H5Pset_scaleoffset((hid_t)plist_id, (H5Z_SO_scale_type_t)scale_type, scale_factor); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_est_link_info + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info(JNIEnv *env, jclass clss, jlong gcpl_id, jint est_num_entries, jint est_name_len) +{ + herr_t retVal = -1; + + /* Range check values */ + if((est_num_entries > 65535) || (est_name_len > 65535)) { + h5badArgument(env, "H5Pset_est_link_info: est. name length or number of entries must be < 65536"); + } /* end if */ + else { + retVal = H5Pset_est_link_info((hid_t)gcpl_id, (unsigned)est_num_entries, (unsigned)est_name_len); + if(retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_est_link_info + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info(JNIEnv *env, jclass clss, jlong gcpl_id, jintArray link_info) +{ + herr_t retVal = -1; + unsigned *theArray = NULL; + jboolean isCopy; + + if (link_info == NULL) { + h5nullArgument(env, "H5Pget_est_link_info: link_info is NULL"); + } /* end if */ + else { + theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR link_info,&isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_est_link_info: input not pinned"); + } /* end if */ + else { + retVal= H5Pget_est_link_info((hid_t)gcpl_id, &(theArray[0]), &(theArray[1])); + if(retVal < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR link_info, (jint *)theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR link_info, (jint *)theArray, 0); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_fapl + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl(JNIEnv *env, jclass clss, jlong lapl_id, jlong fapl_id) +{ + herr_t retVal = -1; + + retVal = H5Pset_elink_fapl((hid_t)lapl_id, (hid_t)fapl_id); + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pget_elink_fapl + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl(JNIEnv *env, jclass clss, jlong lapl_id) +{ + hid_t retVal = -1; + + retVal = H5Pget_elink_fapl((hid_t)lapl_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_prefix + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix(JNIEnv *env, jclass clss, jlong lapl_id, jstring prefix) +{ + herr_t retVal = -1; + const char *aName; + + PIN_JAVA_STRING(prefix, aName, -1); + + retVal = H5Pset_elink_prefix((hid_t)lapl_id, aName); + + UNPIN_JAVA_STRING(prefix, aName); + + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_prefix + * Signature: (J[Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix(JNIEnv *env, jclass clss, jlong lapl_id, jobjectArray prefix) +{ + size_t size = 0; + char *pre; + jlong prefix_size; + jstring str = NULL; + + if (prefix == NULL) { + h5nullArgument(env, "H5Pget_elink_prefix: prefix is NULL"); + } /* end if */ + else { + prefix_size = (jlong)H5Pget_elink_prefix((hid_t)lapl_id, (char*)NULL, size); + if(prefix_size < 0) { + h5libraryError(env); + } /* end if */ + else { + size = (size_t)prefix_size + 1;/* add extra space for the null terminator */ + pre = (char*)HDmalloc(sizeof(char)*size); + if (pre == NULL) { + h5outOfMemory(env, "H5Pget_elink_prefix: malloc failed "); + } /* end if */ + else { + prefix_size = (jlong)H5Pget_elink_prefix((hid_t)lapl_id, (char*)pre, size); + + if (prefix_size < 0) { + HDfree(pre); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR pre); + HDfree(pre); + if (str == NULL) { + h5JNIFatalError(env, "H5Pget_elink_prefix: return string not created"); + } /* end if */ + else + ENVPTR->SetObjectArrayElement(ENVPAR prefix, 0, str); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return prefix_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_direct + * Signature: (JJJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct(JNIEnv *env, jclass clss, jlong fapl_id, jlong alignment, + jlong block_size, jlong cbuf_size) +{ + herr_t retVal = -1; + +#ifdef H5_HAVE_DIRECT + retVal = H5Pset_fapl_direct((hid_t)fapl_id, (size_t)alignment, (size_t)block_size, (size_t)cbuf_size); +#endif + if(retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_direct + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct(JNIEnv *env, jclass clss, jlong fapl_id, jlongArray info) +{ + herr_t retVal = -1; + +#ifdef H5_HAVE_DIRECT + size_t alignment = 0; + size_t block_size = 0; + size_t cbuf_size = 0; + jlong *theArray; + jboolean isCopy; + if (info == NULL) { + h5nullArgument(env, "H5Pget_fapl_direct: info input array is NULL"); + } /* end if */ + else { + if (ENVPTR->GetArrayLength(ENVPAR info) < 3) { + h5badArgument( env, "H5Pget_fapl_direct: info input array < 4"); + } /* end if */ + else { + theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR info, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Pget_fapl_direct: info not pinned"); + } /* end if */ + else { + retVal = H5Pget_fapl_direct((hid_t)fapl_id, &alignment, &block_size, &cbuf_size); + if(retVal < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR info, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + theArray[0] = (jlong)alignment; + theArray[1] = (jlong)block_size; + theArray[2] = (jlong)cbuf_size; + ENVPTR->ReleaseLongArrayElements(ENVPAR info, theArray, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ +#else + if (retVal < 0) + h5libraryError(env); +#endif + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_sec2 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2(JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = -1; + + retVal = H5Pset_fapl_sec2((hid_t) fapl_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_stdio + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio(JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = -1; + + retVal = H5Pset_fapl_stdio((hid_t) fapl_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_windows + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows(JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = -1; + +#ifdef H5_HAVE_WINDOWS + retVal = H5Pset_fapl_windows((hid_t) fapl_id); +#endif + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_muti + * Signature: (J[I[J[Ljava/lang/String;[J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi(JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr) +{ + herr_t status = -1; + int i; + jint *themapArray = NULL; + jlong *thefaplArray = NULL; + jlong *theaddrArray = NULL; + char **mName = NULL; + jstring str; + jboolean isCopy; + int relax = 0; + + if (memb_map) { + themapArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR memb_map, &isCopy); + if (themapArray == NULL) { + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_map not pinned"); + return 0; + } /* end if */ + } /* end if */ + + if (memb_fapl) { + thefaplArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR memb_fapl, &isCopy); + if (thefaplArray == NULL) { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_fapl not pinned"); + return 0; + } /* end if */ + } /* end if */ + + if (memb_addr) { + theaddrArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR memb_addr, &isCopy); + if (theaddrArray == NULL) { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_addr not pinned"); + return 0; + } /* end if */ + } /* end if */ + + if (memb_name) + mName = (char**)HDcalloc(H5FD_MEM_NTYPES, sizeof (*mName)); + + status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t*)themapArray, (hid_t*)thefaplArray, mName, (haddr_t*)theaddrArray, (hbool_t*)&relax); + + if (status < 0) { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); + if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, JNI_ABORT); + if (memb_name) h5str_array_free(mName, H5FD_MEM_NTYPES); + h5libraryError(env); + } /* end if */ + else { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, 0); + if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, 0); + if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, 0); + + if (memb_name) { + if (mName) { + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (*(mName + i)) { + str = ENVPTR->NewStringUTF(ENVPAR *(mName+i)); + ENVPTR->SetObjectArrayElement(ENVPAR memb_name, i, (jobject)str); + } /* end if */ + } /* for (i=0; i<n; i++)*/ + } /* end if */ + h5str_array_free(mName, H5FD_MEM_NTYPES); + } /* end if */ + } /* end else */ + + return (relax!=0); +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_muti + * Signature: (J[I[J[Ljava/lang/String;[JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi(JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, jboolean relax) +{ + herr_t status = -1; + jint *themapArray = NULL; + jlong *thefaplArray = NULL; + jlong *theaddrArray = NULL; + jboolean isCopy; + jclass Sjc; + jstring rstring; + jobject o; + jboolean bb; + const char **mName = NULL; + char *member_name[H5FD_MEM_NTYPES]; + + if (memb_map) { + themapArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR memb_map, &isCopy); + if (themapArray == NULL) { + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_map not pinned"); + return; + } /* end if */ + } /* end if */ + + if (memb_fapl) { + thefaplArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_fapl, &isCopy); + if (thefaplArray == NULL) { + if (memb_map) + ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_fapl not pinned"); + return; + } /* end if */ + } /* end if */ + + if (memb_addr) { + theaddrArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_addr, &isCopy); + if (theaddrArray == NULL) { + if (memb_map) + ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + if (memb_fapl) + ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_fapl_muti: memb_addr not pinned"); + return; + } /* end if */ + } /* end if */ + + HDmemset(member_name, 0, H5FD_MEM_NTYPES * sizeof(char*)); + if (memb_name) { + int i; + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) memb_name, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + member_name[i] = (char*)HDmalloc(strlen(utf8) + 1); + if (member_name[i]) { + strcpy(member_name[i], utf8); + } /* end if */ + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for */ + mName = (const char **)member_name; + } /* end if */ + + status = H5Pset_fapl_multi((hid_t)tid, (const H5FD_mem_t *)themapArray, (const hid_t *)thefaplArray, mName, (const haddr_t *)theaddrArray, (hbool_t)relax); + + if (status < 0) { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); + if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); + if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, JNI_ABORT); + if (memb_name) { + int i; + for (i = 0; i < H5FD_MEM_NTYPES; i++) + HDfree(member_name[i]); + } /* end if */ + h5libraryError(env); + } /* end if */ + else { + if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, 0); + if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, 0); + if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, 0); + if (memb_name) { + if (mName != NULL) { + int i; + Sjc = ENVPTR->FindClass(ENVPAR "java/lang/String"); + if (Sjc != NULL) { + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + rstring = ENVPTR->NewStringUTF(ENVPAR member_name[i]); + o = ENVPTR->GetObjectArrayElement(ENVPAR memb_name, i); + if (o != NULL) { + bb = ENVPTR->IsInstanceOf(ENVPAR o, Sjc); + if (bb == JNI_TRUE) { + ENVPTR->SetObjectArrayElement(ENVPAR memb_name, i, (jobject)rstring); + } /* end if */ + ENVPTR->DeleteLocalRef(ENVPAR o); + } /* end if */ + HDfree(member_name[i]); + } /* end for */ + } /* end if */ + } /* end if */ + } /* end if */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_split + * Signature: (JLjava/lang/String;JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split(JNIEnv *env, jclass clss, jlong fapl_id, jstring metaext, jlong meta_pl_id, jstring rawext, jlong raw_pl_id) +{ + herr_t retVal = -1; + const char *mstr; + const char *rstr; + + PIN_JAVA_STRING_TWO0(metaext, mstr, rawext, rstr); + + retVal = H5Pset_fapl_split((hid_t)fapl_id, mstr, (hid_t)meta_pl_id, rstr, (hid_t)raw_pl_id); + + UNPIN_JAVA_STRING_TWO(metaext, mstr, rawext, rstr); + + if (retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_meta_block_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + long sz = (long)size; + + if (H5Pset_meta_block_size((hid_t)plist, (hsize_t)sz) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_meta_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size(JNIEnv *env, jclass clss, jlong plist) +{ + hsize_t s; + + if (H5Pget_meta_block_size((hid_t)plist, &s) < 0) + h5libraryError(env); + + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sieve_buf_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + size_t sz = (size_t)size; + + if (H5Pset_sieve_buf_size((hid_t)plist, (size_t)sz) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sieve_buf_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size(JNIEnv *env, jclass clss, jlong plist) +{ + size_t s; + + if ( H5Pget_sieve_buf_size((hid_t)plist, &s) < 0) + h5libraryError(env); + + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_file_cache_size + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size(JNIEnv *env, jclass clss, jlong plist, jint size) +{ + unsigned sz = (unsigned)size; + + if (H5Pset_elink_file_cache_size((hid_t)plist, (unsigned)sz) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_file_cache_size + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size(JNIEnv *env, jclass clss, jlong plist) +{ + unsigned s; + + if (H5Pget_elink_file_cache_size((hid_t)plist, &s) < 0) + h5libraryError(env); + + return (jint)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_config + * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config(JNIEnv *env, jclass clss, jlong plist) +{ + H5AC_cache_config_t cacheinfo; + herr_t status = -1; + jvalue args[30]; + jstring j_str = NULL; + jobject ret_obj = NULL; + + HDmemset(&cacheinfo, 0, sizeof(H5AC_cache_config_t)); + cacheinfo.version = H5AC__CURR_CACHE_CONFIG_VERSION; + + status = H5Pget_mdc_config((hid_t)plist, &cacheinfo); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + args[0].i = cacheinfo.version; + args[1].z = cacheinfo.rpt_fcn_enabled; + args[2].z = cacheinfo.open_trace_file; + args[3].z = cacheinfo.close_trace_file; + if (cacheinfo.trace_file_name != NULL) { + j_str = ENVPTR->NewStringUTF(ENVPAR cacheinfo.trace_file_name); + } /* end if */ + args[4].l = j_str; + args[5].z = cacheinfo.evictions_enabled; + args[6].z = cacheinfo.set_initial_size; + args[7].j = (jlong)cacheinfo.initial_size; + args[8].d = cacheinfo.min_clean_fraction; + args[9].j = (jlong)cacheinfo.max_size; + args[10].j = (jlong)cacheinfo.min_size; + args[11].j = cacheinfo.epoch_length; + args[12].i = cacheinfo.incr_mode; + args[13].d = cacheinfo.lower_hr_threshold; + args[14].d = cacheinfo.increment; + args[15].z = cacheinfo.apply_max_increment; + args[16].j = (jlong)cacheinfo.max_increment; + args[17].i = cacheinfo.flash_incr_mode; + args[18].d = cacheinfo.flash_multiple; + args[19].d = cacheinfo.flash_threshold; + args[20].i = cacheinfo.decr_mode; + args[21].d = cacheinfo.upper_hr_threshold; + args[22].d = cacheinfo.decrement; + args[23].z = cacheinfo.apply_max_decrement; + args[24].j = (jlong)cacheinfo.max_decrement; + args[25].i = cacheinfo.epochs_before_eviction; + args[26].z = cacheinfo.apply_empty_reserve; + args[27].d = cacheinfo.empty_reserve; + args[28].j = (jlong)cacheinfo.dirty_bytes_threshold; + args[29].i = cacheinfo.metadata_write_strategy; + CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5AC_cache_config_t", "(IZZZLjava/lang/String;ZZJDJJJIDDZJIDDIDDZJIZDJI)V", args); + } /* end else */ + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_config + * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config(JNIEnv *env, jclass clss, jlong plist, jobject cache_config) +{ + herr_t status = -1; + jclass cls; + jfieldID fid; + jstring j_str; + const char *str; + H5AC_cache_config_t cacheinfo; + + cls = ENVPTR->GetObjectClass(ENVPAR cache_config); + fid = ENVPTR->GetFieldID(ENVPAR cls, "version", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: version"); + return; + } /* end if */ + cacheinfo.version = ENVPTR->GetIntField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading version failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "rpt_fcn_enabled", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: rpt_fcn_enabled"); + return; + } /* end if */ + cacheinfo.rpt_fcn_enabled = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading rpt_fcn_enabled failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "open_trace_file", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: open_trace_file"); + return; + } /* end if */ + cacheinfo.open_trace_file = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading open_trace_file failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "close_trace_file", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: close_trace_file"); + return; + } /* end if */ + cacheinfo.close_trace_file = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading close_trace_file failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "trace_file_name", "Ljava/lang/String;"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: trace_file_name"); + return; + } /* end if */ + j_str = (jstring)ENVPTR->GetObjectField(ENVPAR cache_config, fid); + str = ENVPTR->GetStringUTFChars(ENVPAR j_str, NULL); + if (str == NULL) { + h5JNIFatalError(env, "H5Pset_mdc_config: out of memory trace_file_name"); + return; + } /* end if */ + strncpy(cacheinfo.trace_file_name, str, 1025); + ENVPTR->ReleaseStringUTFChars(ENVPAR j_str, str); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading trace_file_name failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "evictions_enabled", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: evictions_enabled"); + return; + } /* end if */ + cacheinfo.evictions_enabled = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading evictions_enabled failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "set_initial_size", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: set_initial_size"); + return; + } /* end if */ + cacheinfo.set_initial_size = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading set_initial_size failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "initial_size", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: initial_size"); + return; + } /* end if */ + cacheinfo.initial_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading initial_size failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "min_clean_fraction", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: min_clean_fraction"); + return; + } /* end if */ + cacheinfo.min_clean_fraction = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading min_clean_fraction failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "max_size", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: max_size"); + return; + } /* end if */ + cacheinfo.max_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading max_size failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "min_size", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: min_size"); + return; + } /* end if */ + cacheinfo.min_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading min_size failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "epoch_length", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: epoch_length"); + return; + } + cacheinfo.epoch_length = (long int)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading epoch_length failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "incr_mode", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: incr_mode"); + return; + } /* end if */ + cacheinfo.incr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_incr_mode) */ + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading incr_mode failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "lower_hr_threshold", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: lower_hr_threshold"); + return; + } /* end if */ + cacheinfo.lower_hr_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading lower_hr_threshold failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "increment", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: increment"); + return; + } /* end if */ + cacheinfo.increment = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading increment failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_max_increment", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: apply_max_increment"); + return; + } /* end if */ + cacheinfo.apply_max_increment = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_max_increment failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "max_increment", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: max_increment"); + return; + } /* end if */ + cacheinfo.max_increment = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading max_increment failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_incr_mode", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: flash_incr_mode"); + return; + } /* end if */ + cacheinfo.flash_incr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_flash_incr_mode) */ + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_incr_mode failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_multiple", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: flash_multiple"); + return; + } /* end if */ + cacheinfo.flash_multiple = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_multiple failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_threshold", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: flash_threshold"); + return; + } /* end if */ + cacheinfo.flash_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_threshold failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "decr_mode", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: decr_mode"); + return; + } /* end if */ + cacheinfo.decr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_decr_mode) */ + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading decr_mode failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "upper_hr_threshold", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: upper_hr_threshold"); + return; + } /* end if */ + cacheinfo.upper_hr_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading upper_hr_threshold failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "decrement", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: decrement"); + return; + } /* end if */ + cacheinfo.decrement = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading decrement failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_max_decrement", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: apply_max_decrement"); + return; + } /* end if */ + cacheinfo.apply_max_decrement = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_max_decrement failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "max_decrement", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: max_decrement"); + return; + } /* end if */ + cacheinfo.max_decrement = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading max_decrement failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "epochs_before_eviction", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: epochs_before_eviction"); + return; + } /* end if */ + cacheinfo.epochs_before_eviction = ENVPTR->GetIntField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading epochs_before_eviction failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_empty_reserve", "Z"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: apply_empty_reserve"); + return; + } /* end if */ + cacheinfo.apply_empty_reserve = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_empty_reserve failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "empty_reserve", "D"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: empty_reserve"); + return; + } /* end if */ + cacheinfo.empty_reserve = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading empty_reserve failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "dirty_bytes_threshold", "J"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: dirty_bytes_threshold"); + return; + } /* end if */ + cacheinfo.dirty_bytes_threshold = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading dirty_bytes_threshold failed"); + return; + } /* end if */ + + fid = ENVPTR->GetFieldID(ENVPAR cls, "metadata_write_strategy", "I"); + if(fid == 0) { + h5badArgument(env, "H5Pset_mdc_config: metadata_write_strategy"); + return; + } /* end if */ + cacheinfo.metadata_write_strategy = ENVPTR->GetIntField(ENVPAR cache_config, fid); + if(ENVPTR->ExceptionOccurred(ENVONLY)) { + h5JNIFatalError(env, "H5Pset_mdc_config: loading metadata_write_strategy failed"); + return; + } /* end if */ + + status = H5Pset_mdc_config((hid_t)plist, &cacheinfo); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_cache + * Signature: (JJJD)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache(JNIEnv *env, jclass clss, jlong dapl, jlong rdcc_nslots, + jlong rdcc_nbytes, jdouble rdcc_w0) +{ + if (H5Pset_chunk_cache((hid_t)dapl, (size_t)rdcc_nslots, (size_t)rdcc_nbytes, (double) rdcc_w0) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_cache + * Signature: (J[J[J[D)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache(JNIEnv *env, jclass clss, jlong dapl, jlongArray rdcc_nslots, + jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +{ + herr_t status = -1; + jint mode; + jdouble *w0Array; + jlong *rdcc_nslotsArray; + jlong *nbytesArray; + jboolean isCopy; + + if (rdcc_w0 == NULL) { + w0Array = (jdouble *)NULL; + } /* end if */ + else { + w0Array = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR rdcc_w0, &isCopy); + if (w0Array == NULL) { + h5JNIFatalError(env, "H5Pget_chunk_cache: w0_array array not pinned"); + return; + } /* end if */ + } /* end else */ + + if (rdcc_nslots == NULL) { + rdcc_nslotsArray = (jlong *)NULL; + } /* end if */ + else { + rdcc_nslotsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nslots, &isCopy); + if (rdcc_nslotsArray == NULL) { + /* exception -- out of memory */ + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); + } /* end if */ + h5JNIFatalError(env, "H5Pget_chunk_cache: rdcc_nslots array not pinned"); + return; + } /* end if */ + } /* end else */ + + if (rdcc_nbytes == NULL) { + nbytesArray = (jlong *)NULL; + } /* end if */ + else { + nbytesArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nbytes, &isCopy); + if (nbytesArray == NULL) { + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); + } /* end if */ + if (rdcc_nslotsArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nslots, rdcc_nslotsArray, JNI_ABORT); + } /* end if */ + h5JNIFatalError(env, "H5Pget_chunk_cache: nbytesArray array not pinned"); + return; + } /* end if */ + } /* end else */ + + { /* direct cast (size_t *)variable fails on 32-bit environment */ + long long rdcc_nslots_temp = *(rdcc_nslotsArray); + size_t rdcc_nslots_t = (size_t)rdcc_nslots_temp; + long long nbytes_temp = *(nbytesArray); + size_t nbytes_t = (size_t)nbytes_temp; + + status = H5Pget_chunk_cache((hid_t)dapl, &rdcc_nslots_t, &nbytes_t, (double *)w0Array); + + *rdcc_nslotsArray = (jlong)rdcc_nslots_t; + *nbytesArray = (jlong)nbytes_t; + } /* end direct cast special handling */ + + if (status < 0) { + mode = JNI_ABORT; + } /* end if */ + else { + mode = 0; /* commit and free */ + } /* end else */ + + if (rdcc_nslotsArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nslots, rdcc_nslotsArray, mode); + } + /* end if */ + if (nbytesArray != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nbytes, nbytesArray, mode); + } /* end if */ + + if (w0Array != NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, mode); + } /* end if */ + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_obj_track_times + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times(JNIEnv *env, jclass clss, jlong objplid) +{ + hbool_t track_times; + + if (H5Pget_obj_track_times((hid_t)objplid, &track_times) < 0) { + h5libraryError(env); + return JNI_FALSE; + } /* end if */ + if (track_times == 1) { + return JNI_TRUE; + } /* end if */ + return JNI_FALSE; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_obj_track_times + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times(JNIEnv *env, jclass clss, jlong objplid, jboolean track_times) +{ + hbool_t track; + + if (track_times == JNI_TRUE) { + track = 1; + } /* end if */ + else { + track = 0; + } /* end else */ + + if (H5Pset_obj_track_times((hid_t)objplid, track) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_char_encoding + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding(JNIEnv *env, jclass clss, jlong acpl) +{ + H5T_cset_t encoding; + + if (H5Pget_char_encoding((hid_t)acpl, &encoding) < 0) + h5libraryError(env); + + return encoding; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_char_encoding + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding(JNIEnv *env, jclass clss, jlong acpl, jint encoding) +{ + if (H5Pset_char_encoding((hid_t)acpl, (H5T_cset_t)encoding) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual + * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual(JNIEnv *env, jclass clss, jlong dcpl_id, jlong vspace_id, + jstring src_file_name, jstring src_dset_name, jlong src_space_id) +{ + herr_t retVal = -1; + const char *fstr; + const char *dstr; + + PIN_JAVA_STRING_TWO0(src_file_name, fstr, src_dset_name, dstr); + + retVal = H5Pset_virtual((hid_t)dcpl_id, (hid_t)vspace_id, fstr, dstr, (hid_t)src_space_id); + + UNPIN_JAVA_STRING_TWO(src_file_name, fstr, src_dset_name, dstr); + + if (retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_count + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count(JNIEnv *env, jclass clss, jlong dcpl_id) +{ + size_t s; + + if (H5Pget_virtual_count((hid_t)dcpl_id, &s) < 0) + h5libraryError(env); + + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_vspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace(JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + hid_t space_id = -1; + + space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t)index); + if (space_id < 0) + h5libraryError(env); + + return (jlong)space_id; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_srcspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace(JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + hid_t space_id = -1; + + space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t)index); + if (space_id < 0) + h5libraryError(env); + + return (jlong)space_id; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_filename + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename(JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + char *fname; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + /* get the length of the filename */ + buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, NULL, 0); + if (buf_size < 0) { + h5badArgument( env, "H5Pget_virtual_filename: buf_size < 0"); + } /* end if */ + else if (buf_size >= 0) { + buf_size++; /* add extra space for the null terminator */ + fname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (fname == NULL) { + h5outOfMemory( env, "H5Pget_virtual_filename: malloc failed"); + } /* end if */ + else { + status = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, fname, (size_t)buf_size); + + if (status >= 0) { + str = ENVPTR->NewStringUTF(ENVPAR fname); + HDfree(fname); + if (str == NULL) + h5JNIFatalError( env, "H5Pget_virtual_filename: return string not allocated"); + } /* end if */ + else { + HDfree(fname); + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else if */ + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_dsetname + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname(JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + char *dname; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + /* get the length of the filename */ + buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, NULL, 0); + if (buf_size < 0) { + h5badArgument( env, "H5Pget_virtual_dsetname: buf_size < 0"); + } /* end if */ + else if (buf_size > 0) { + buf_size++; /* add extra space for the null terminator */ + dname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (dname == NULL) { + h5outOfMemory( env, "H5Pget_virtual_dsetname: malloc failed"); + } /* end if */ + else { + status = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, dname, (size_t)buf_size); + + if (status >= 0) { + str = ENVPTR->NewStringUTF(ENVPAR dname); + HDfree(dname); + if (str == NULL) + h5JNIFatalError( env, "H5Pget_virtual_dsetname: return string not allocated"); + } /* end if */ + else { + HDfree(dname); + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else if */ + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_view + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view(JNIEnv *env, jclass clss, jlong dapl_id) +{ + H5D_vds_view_t virtual_view; + + if (H5Pget_virtual_view((hid_t)dapl_id, &virtual_view) < 0) + h5libraryError(env); + + return (jint)virtual_view; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_view + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view(JNIEnv *env, jclass clss, jlong dapl_id, jint view) +{ + if (H5Pset_virtual_view((hid_t)dapl_id, (H5D_vds_view_t)view) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_printf_gap + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap(JNIEnv *env, jclass clss, jlong dapl_id) +{ + hsize_t gap_size; + + if (H5Pget_virtual_printf_gap((hid_t)dapl_id, &gap_size) < 0) + h5libraryError(env); + + return (jlong)gap_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_printf_gap + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap(JNIEnv *env, jclass clss, jlong dapl_id, jlong gap_size) +{ + if (H5Pset_virtual_printf_gap((hid_t)dapl_id, (hsize_t)gap_size) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space + * Signature: (J[I[J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space(JNIEnv *env, jclass clss, jlong fcpl_id, jintArray strategy, jlongArray threshold) +{ + herr_t status = -1; + jint *thestrategyArray = NULL; + jlong *thethresholdArray = NULL; + jboolean isCopy; + + if (strategy) { + thestrategyArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR strategy, &isCopy); + if (thestrategyArray == NULL) { + h5JNIFatalError(env, "H5Pget_file_space: strategy not pinned"); + return; + } + } + + if (threshold) { + thethresholdArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR threshold, &isCopy); + if (thethresholdArray == NULL) { + if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, JNI_ABORT); + h5JNIFatalError(env, "H5Pget_file_space: threshold not pinned"); + return; + } /* end if */ + } /* end if */ + + status = H5Pget_file_space((hid_t)fcpl_id, (H5F_file_space_type_t*)thestrategyArray, (hsize_t*)thethresholdArray); + + if (status < 0) { + if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, JNI_ABORT); + if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + if (strategy) ENVPTR->ReleaseIntArrayElements(ENVPAR strategy, thestrategyArray, 0); + if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, 0); + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space + * Signature: (JIJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space(JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jlong threshold) +{ + if (H5Pset_file_space((hid_t)fcpl_id, (H5F_file_space_type_t)strategy, (hsize_t)threshold) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1file_1space */ + + +static herr_t +H5P_cls_create_cb(hid_t prop_id, void *create_data) +{ + JNIEnv *cbenv; + jint status = -1; + jclass cls; + jmethodID mid; + jmethodID constructor; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_create_func_t;)I"); + if (mid != 0) { + /* fprintf(stderr, "JNI H5P_cls_create_func_cb execute\n"); fflush(stderr); */ + status = CBENVPTR->CallIntMethod(CBENVPAR create_callback, mid, prop_id, create_data); + /* fprintf(stderr, "\nJNI H5P_cls_create_func_cb status: %d\n", status); fflush(stderr); */ + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_cls_create_cb */ + +static herr_t +H5P_cls_copy_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JJLhdf/hdf5lib/callbacks/H5P_cls_copy_func_t;)I"); + if (mid != 0) { + status = CBENVPTR->CallIntMethod(CBENVPAR copy_callback, mid, new_prop_id, old_prop_id, copy_data); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_cls_ccopy_cb */ + +static herr_t +H5P_cls_close_cb(hid_t prop_id, void *close_data) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_close_func_t;)I"); + if (mid != 0) { + status = CBENVPTR->CallIntMethod(CBENVPAR close_callback, mid, prop_id, close_data); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_cls_close_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pcreate_class_nocb + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb(JNIEnv *env, jclass clss, jlong parent_class, jstring name) +{ + hid_t class_id = -1; + const char *cstr; + + PIN_JAVA_STRING(name, cstr, -1); + + class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL); + + UNPIN_JAVA_STRING(name, cstr); + + if (class_id < 0) + h5libraryError(env); + + return (jlong)class_id; +} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pcreate_class + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class(JNIEnv *env, jclass clss, jlong parent_class, jstring name, jobject create_op, + jobject create_data, jobject copy_op, jobject copy_data, jobject close_op, jobject close_data) +{ + hid_t class_id = -1; + const char *cstr; + copy_callback = copy_op; + close_callback = close_op; + create_callback = create_op; + + PIN_JAVA_STRING(name, cstr, -1); + + class_id = H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, (void*) create_data, + (H5P_cls_copy_func_t)H5P_cls_copy_cb, (void*) copy_data, (H5P_cls_close_func_t)H5P_cls_close_cb, (void*) close_data); + + UNPIN_JAVA_STRING(name, cstr); + + if (class_id < 0) + h5libraryError(env); + + return (jlong)class_id; +} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class */ + +static herr_t +H5P_prp_create_cb(const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR create_callback, mid, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_create_cb */ + +static herr_t +H5P_prp_copy_cb(const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR copy_callback, mid, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_copy_cb */ + +static herr_t +H5P_prp_close_cb(const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR close_callback, mid, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_close_cb */ + +static int +H5P_prp_compare_cb(void *value1, void *value2, size_t size) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR compare_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "([B[BJ)I"); + if (mid != 0) { + status = CBENVPTR->CallIntMethod(CBENVPAR compare_callback, mid, value1, value2, size); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_compare_cb */ + +static herr_t +H5P_prp_get_cb(hid_t prop_id, const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR get_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR get_callback, mid, prop_id, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_get_cb */ + +static herr_t +H5P_prp_set_cb(hid_t prop_id, const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR set_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR set_callback, mid, prop_id, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_set_cb */ + +static herr_t +H5P_prp_delete_cb(hid_t prop_id, const char *name, size_t size, void *value) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jmethodID constructor; + jstring str; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { + cls = CBENVPTR->GetObjectClass(CBENVPAR delete_callback); + if (cls != 0) { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); + if (mid != 0) { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + status = CBENVPTR->CallIntMethod(CBENVPAR delete_callback, mid, prop_id, str, size, value); + } /* end if */ + } /* end if */ + } /* end if */ + JVMPTR->DetachCurrentThread(JVMPAR); + return status; +} /* end H5P_prp_delete_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pregister2_nocb + * Signature: (JLjava/lang/String;J[B)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2_1nocb(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) +{ + herr_t status = -1; + jbyte *buffP; + jboolean isCopy2; + const char *cstr; + + PIN_JAVA_STRING0(name, cstr); + buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); + if (buffP == NULL) { + UNPIN_JAVA_STRING(name, cstr); + h5JNIFatalError(env, "H5Pregister2: buf not pinned"); + } /* end if */ + else { + status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + + UNPIN_JAVA_STRING(name, cstr); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pregister2_1nocb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pregister2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_create, jobject prp_set, jobject prp_get, jobject prp_delete, + jobject prp_copy, jobject prp_cmp, jobject prp_close) +{ + herr_t status = -1; + jbyte *buffP; + jboolean isCopy2; + const char *cstr; + copy_callback = prp_copy; + close_callback = prp_close; + create_callback = prp_create; + compare_callback = prp_cmp; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; + + PIN_JAVA_STRING0(name, cstr); + buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); + if (buffP == NULL) { + UNPIN_JAVA_STRING(name, cstr); + h5JNIFatalError(env, "H5Pregister2: buf not pinned"); + } /* end if */ + else { + status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, (H5P_prp_create_func_t)H5P_prp_create_cb, + (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, + (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb); + + UNPIN_JAVA_STRING(name, cstr); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pregister2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pinsert2_nocb + * Signature: (JLjava/lang/String;J[B)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) +{ + herr_t status = -1; + jbyte *buffP; + jboolean isCopy2; + const char *cstr; + + PIN_JAVA_STRING0(name, cstr); + buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); + if (buffP == NULL) { + UNPIN_JAVA_STRING(name, cstr); + h5JNIFatalError(env, "H5Pinsert2: buf not pinned"); + } /* end if */ + else { + status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, NULL, NULL, NULL, NULL, NULL, NULL); + + UNPIN_JAVA_STRING(name, cstr); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pinsert2 */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pinsert2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_set, jobject prp_get, jobject prp_delete, + jobject prp_copy, jobject prp_cmp, jobject prp_close) +{ + herr_t status = -1; + jbyte *buffP; + jboolean isCopy2; + const char *cstr; + copy_callback = prp_copy; + close_callback = prp_close; + compare_callback = prp_cmp; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; + + PIN_JAVA_STRING0(name, cstr); + buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); + if (buffP == NULL) { + UNPIN_JAVA_STRING(name, cstr); + h5JNIFatalError(env, "H5Pinsert2: buf not pinned"); + } /* end if */ + else { + status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, + (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, + (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb); + + UNPIN_JAVA_STRING(name, cstr); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pinsert2 */ + +static herr_t +H5P_iterate_cb(hid_t prop_id, const char *name, void *op_data) +{ + JNIEnv *cbenv; + jint status = -1; + jclass cls; + jmethodID mid; + jstring str; + jmethodID constructor; + + /* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */ + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { + /* fprintf(stderr, "\nJNI H5P_iterate_cb error: AttachCurrentThread failed\n"); fflush(stderr); */ + JVMPTR->DetachCurrentThread(JVMPAR); + } /* end if */ + else { + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls == 0) { + /* fprintf(stderr, "\nJNI H5P_iterate_cb error: GetObjectClass failed\n"); fflush(stderr); */ + JVMPTR->DetachCurrentThread(JVMPAR); + } /* end if */ + else { + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/callbacks/H5P_iterate_t;)I"); + if (mid == 0) { + /* fprintf(stderr, "\nJNI H5P_iterate_cb error: GetMethodID failed\n"); fflush(stderr); */ + JVMPTR->DetachCurrentThread(JVMPAR); + } /* end if */ + else { + str = CBENVPTR->NewStringUTF(CBENVPAR name); + + /* fprintf(stderr, "JNI H5P_iterate_cb execute\n"); fflush(stderr); */ + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, prop_id, str, op_data); + /* fprintf(stderr, "\nJNI H5P_iterate_cb status: %d\n", status); fflush(stderr); */ + } /* end else */ + } /* end else */ + } /* end else */ + + JVMPTR->DetachCurrentThread(JVMPAR); + /* fprintf(stderr, "\nJNI H5P_iterate_cb leave\n"); fflush(stderr); */ + + return status; +} /* end H5P_iterate_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Piterate + * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Piterate(JNIEnv *env, jclass clss, jlong prop_id, jintArray idx, + jobject callback_op, jobject op_data) +{ + herr_t status = -1; + jint *theArray = NULL; + jboolean isCopy; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if (op_data == NULL) { + h5nullArgument(env, "H5Piterate: op_data is NULL"); + } /* end if */ + else if (callback_op == NULL) { + h5nullArgument(env, "H5Piterate: callback_op is NULL"); + } /* end else if */ + else { + if (idx == NULL) { + status = H5Piterate((hid_t)prop_id, NULL, (H5P_iterate_t)H5P_iterate_cb, (void*)op_data); + } /* end if */ + else { + theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR idx, &isCopy); + if (theArray == NULL) { + h5JNIFatalError(env, "H5Piterate: idx not pinned"); + return -1; + } /* end if */ + status = H5Piterate((hid_t)prop_id, (int*)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void*)op_data); + } /* end else */ + + if (status < 0) { + if(idx) + ENVPTR->ReleaseIntArrayElements(ENVPAR idx, theArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else if (idx) + ENVPTR->ReleaseIntArrayElements(ENVPAR idx, theArray, 0); + } /* end else */ + + return status; +} /* end Java_hdf_hdf5lib_H5_H5Piterate */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h new file mode 100644 index 0000000..ea1ee52 --- /dev/null +++ b/java/src/jni/h5pImp.h @@ -0,0 +1,1313 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5_H5P */ + +#ifndef _Included_hdf_hdf5lib_H5_H5P +#define _Included_hdf_hdf5lib_H5_H5P + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcreate + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Pclose +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcopy +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_version + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1version +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_userblock + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1userblock +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_userblock + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1userblock +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sizes + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sizes +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sizes + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sizes +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sym_k + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sym_1k +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sym_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sym_1k +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_istore_k + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1istore_1k +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_istore_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1istore_1k +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_layout + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1layout +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_layout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1layout +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk +(JNIEnv *, jclass, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk + * Signature: (JI[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk +(JNIEnv *, jclass, jlong, jint, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alignment + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1alignment +(JNIEnv *, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alignment + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1alignment +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_external + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1external +(JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external_count + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1external_1count +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external + * Signature: (JIJ[Ljava/lang/String;[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1external +(JNIEnv *, jclass, jlong, jint, jlong, jobjectArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fill_1value +(JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fill_1value +(JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1filter +(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nfilters + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nfilters +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_driver + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1driver +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_cache + * Signature: (JIJJD)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1cache +(JNIEnv *, jclass, jlong, jint, jlong, jlong, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_cache + * Signature: (J[I[J[J[D)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1cache +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jlongArray, jdoubleArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer + * Signature: (JJ[B[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1buffer +(JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer + * Signature: (J[B[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1buffer +(JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_preserve + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1preserve +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_preserve + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1preserve +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_deflate + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1deflate +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_gc_references + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1gc_1references +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_gc_references + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1gc_1references +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_btree_ratios + * Signature: (JDDD)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios +(JNIEnv *, jclass, jlong, jdouble, jdouble, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_btree_ratios + * Signature: (J[D[D[D)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios +(JNIEnv *, jclass, jlong, jdoubleArray, jdoubleArray, jdoubleArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_small_data_block_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_small_data_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alloc_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alloc_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fill_1time +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fill_1time +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pfill_value_defined + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fletcher32 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_edc_check + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1edc_1check +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_edc_check + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1edc_1check +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shuffle + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shuffle +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_szip + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1szip +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_hyper_vector_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_hyper_vector_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pall_filters_avail + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pmodify_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pmodify_1filter +(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fclose_degree + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fclose_degree + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_family + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family +(JNIEnv *, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_family + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family +(JNIEnv *, jclass, jlong, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_core + * Signature: (JJZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core +(JNIEnv *, jclass, jlong, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_core + * Signature: (J[J[Z)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core +(JNIEnv *, jclass, jlong, jlongArray, jbooleanArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_family_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1family_1offset +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_family_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1family_1offset +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_log + * Signature: (JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log +(JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove_filter + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5P1remove_1filter +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset + * Signature: (JLjava/lang/String;I)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pset +(JNIEnv *, jclass, jlong, jstring, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pexist + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pexist +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_size + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1size +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nprops + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nprops +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class_name + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class_1name +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_class_parent + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class_1parent +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pisa_class + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pisa_1class +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pequal + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pequal +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pcopy_prop + * Signature: (JJLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pcopy_1prop +(JNIEnv *, jclass, jlong, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Premove +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Punregister + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Punregister +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pclose_class + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Pclose_1class +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter2 +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nlinks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nlinks +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nlinks + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1nlinks +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_libver_bounds + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_libver_bounds + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_copy_object + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1copy_1object +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_copy_object + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1copy_1object +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_create_intermediate_group + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_create_intermediate_group + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_data_transform + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1data_1transform +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_data_transform + * Signature: (J[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1data_1transform +(JNIEnv *, jclass, jlong, jobjectArray, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_acc_flags + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_acc_flags + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_phase_change + * Signature: (JII)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_nindexes + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_nindexes + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_index + * Signature: (JIII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index +(JNIEnv *, jclass, jlong, jint, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_index + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index +(JNIEnv *, jclass, jlong, jint, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_local_heap_size_hint + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_local_heap_size_hint + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nbit + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1nbit +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_scaleoffset + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_est_link_info + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_est_link_info + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_fapl + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pget_elink_fapl + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_prefix + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_prefix + * Signature: (J[Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix +(JNIEnv *, jclass, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_direct + * Signature: (JJJJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct +(JNIEnv *, jclass, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_direct + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_sec2 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_stdio + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_windows + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_muti + * Signature: (J[I[J[Ljava/lang/String;[J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_muti + * Signature: (J[I[J[Ljava/lang/String;[JZ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_split + * Signature: (JLjava/lang/String;JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split +(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_meta_block_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_meta_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sieve_buf_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sieve_buf_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_file_cache_size + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_file_cache_size + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size +(JNIEnv *, jclass, jlong); + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_config + * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; + */ +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_config + * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config +(JNIEnv *, jclass, jlong, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_cache + * Signature: (JJJD)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache +(JNIEnv *, jclass, jlong, jlong, jlong, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_cache + * Signature: (J[J[J[D)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache +(JNIEnv *, jclass, jlong, jlongArray, jlongArray, jdoubleArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_obj_track_times + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_obj_track_times + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_char_encoding + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_char_encoding + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual + * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual +(JNIEnv *, jclass, jlong, jlong, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_count + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_vspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_srcspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_filename + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_dsetname + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_view + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_view + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_printf_gap + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_printf_gap + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space + * Signature: (J[I[J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pget_1file_1space +(JNIEnv *, jclass, jlong, jintArray, jlongArray); + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space + * Signature: (JIJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1file_1space +(JNIEnv *, jclass, jlong, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pcreate_class_nocb + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb + (JNIEnv*, jclass, jlong, jstring); +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pcreate_class + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate_1class + (JNIEnv*, jclass, jlong, jstring, jobject, jobject, jobject, jobject, jobject, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pregister2_nocb + * Signature: (JLjava/lang/String;J[B)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pregister2_1nocb + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pregister2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pregister2 + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pinsert2_nocb + * Signature: (JLjava/lang/String;J[B)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pinsert2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pinsert2 + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Piterate + * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Piterate + (JNIEnv*, jclass, jlong, jintArray, jobject, jobject); + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5P */ diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c new file mode 100644 index 0000000..9b19bfb --- /dev/null +++ b/java/src/jni/h5rImp.c @@ -0,0 +1,324 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include <jni.h> +#include <stdlib.h> +#include "h5jni.h" +#include "h5rImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rcreate + * Signature: ([BJLjava/lang/String;IJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Rcreate(JNIEnv *env, jclass clss, jbyteArray ref, jlong loc_id, jstring name, jint ref_type, jlong space_id) +{ + const char *rName; + herr_t status = -1; + jbyte *refP; + jboolean isCopy2; + + PIN_JAVA_STRING(name, rName, -1); + + if (ref == NULL) { + UNPIN_JAVA_STRING(name, rName); + h5nullArgument( env, "H5Rcreate: ref is NULL"); + } /* end if */ + else { + if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { + UNPIN_JAVA_STRING(name, rName); + h5badArgument( env, "H5Rcreate: ref input array != H5R_OBJ_REF_BUF_SIZE"); + } /* end if */ + else if ((ref_type == H5R_DATASET_REGION) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { + UNPIN_JAVA_STRING(name, rName); + h5badArgument( env, "H5Rcreate: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); + } /* end else if */ + else if ((ref_type != H5R_OBJECT) && (ref_type != H5R_DATASET_REGION)) { + UNPIN_JAVA_STRING(name, rName); + h5badArgument( env, "H5Rcreate: ref_type unknown type "); + } /* end else if */ + else { + refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy2); + if (refP == NULL) { + UNPIN_JAVA_STRING(name, rName); + h5JNIFatalError(env, "H5Rcreate: ref not pinned"); + } /* end if */ + else { + status = H5Rcreate(refP, (hid_t)loc_id, rName, (H5R_type_t)ref_type, (hid_t)space_id); + + UNPIN_JAVA_STRING(name, rName); + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Rcreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Rdereference + * Signature: (JJI[B)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Rdereference(JNIEnv *env, jclass clss, jlong dataset, jlong access_list, jint ref_type, jbyteArray ref) +{ + jboolean isCopy; + jbyte *refP; + hid_t retVal = -1; + + if (ref == NULL) { + h5nullArgument( env, "H5Rdereference: ref is NULL"); + } /* end if */ + else if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { + h5badArgument( env, "H5Rdereference: obj ref input array != H5R_OBJ_REF_BUF_SIZE"); + } /* end else if */ + else if ((ref_type == H5R_DATASET_REGION) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { + h5badArgument( env, "H5Rdereference: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); + } /* end else if */ + else { + refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); + if (refP == NULL) { + h5JNIFatalError(env, "H5Rderefernce: ref not pinned"); + } /* end if */ + else { + retVal = H5Rdereference2((hid_t)dataset, (hid_t)access_list, (H5R_type_t)ref_type, refP); + + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + + if (retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Rdereference */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rget_region + * Signature: (JI[B)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Rget_1region(JNIEnv *env, jclass clss, jlong dataset, jint ref_type, jbyteArray ref) +{ + hid_t retVal = -1; + jboolean isCopy; + jbyte *refP; + + if (ref_type != H5R_DATASET_REGION) { + h5badArgument( env, "H5Rget_region: bad ref_type "); + } /* end if */ + else if (ref == NULL) { + h5nullArgument( env, "H5Rget_region: ref is NULL"); + } /* end if */ + else if ( ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { + h5badArgument( env, "H5Rget_region: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); + } /* end if */ + else { + refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); + if (refP == NULL) { + h5JNIFatalError(env, "H5Rget_region: ref not pinned"); + } /* end if */ + else { + retVal = H5Rget_region((hid_t)dataset, (H5R_type_t)ref_type, refP); + + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + + if (retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Rget_1region */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5G_obj_t H5Rget_obj_type + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Rget_1obj_1type(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref) +{ + int retVal =-1; + jboolean isCopy; + jbyte *refP; + H5O_type_t object_info; + + + if (ref == NULL) { + h5nullArgument( env, "H5Rget_object_type: ref is NULL"); + } /* end if */ + else { + refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); + if (refP == NULL) { + h5JNIFatalError(env, "H5Rget_object_type: ref not pinned"); + } /* end if */ + else { + retVal = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refP, &object_info); + if(retVal >= 0) + retVal = object_info; + + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + + if (retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: int H5Rget_obj_type2 + * Signature: (JI[B[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jintArray ref_obj) +{ + + jint status; + jboolean isCopy; + jbyte *refP; + jint *ref_objP; + int retVal = -1; + + + if (ref == NULL) { + h5nullArgument( env, "H5Rget_object_type: ref is NULL"); + } /* end if */ + else if (ref_obj == NULL) { + h5nullArgument( env, "H5Rget_object_type: ref_obj is NULL"); + } /* end else if */ + else { + refP = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); + if (refP == NULL) { + h5JNIFatalError(env, "H5Rget_object_type: ref not pinned"); + } /* end if */ + else { + ref_objP = (jint *)ENVPTR->GetIntArrayElements(ENVPAR ref_obj, &isCopy); + if (ref_objP == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR ref,refP,0); + h5JNIFatalError(env, "H5Rget_object_type: ref_obj not pinned"); + } /* end if */ + else { + status = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refP, (H5O_type_t*)ref_objP); + retVal = ref_objP[0]; + + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR ref_obj,ref_objP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + ENVPTR->ReleaseIntArrayElements(ENVPAR ref_obj, ref_objP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rget_name + * Signature: (JI[B[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Rget_1name(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jobjectArray name, jlong size) +{ + jlong ret_val = -1; + jbyte *refP; + jboolean isCopy; + char *aName = NULL; + jstring str; + size_t bs; + + bs = (size_t)size; + if (bs <= 0) { + h5badArgument(env, "H5Rget_name: size <= 0"); + } /* end if */ + else if (ref == NULL) { + h5nullArgument(env, "H5Rget_name: ref is NULL"); + } /* end else if */ + else { + if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { + h5badArgument(env, "H5Rget_name: obj ref input array != H5R_OBJ_REF_BUF_SIZE"); + } /* end if */ + else if ((ref_type == H5R_DATASET_REGION) + && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { + h5badArgument(env, "H5Rget_name: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); + } /* end else if */ + else { + refP = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); + if (refP == NULL) { + h5JNIFatalError(env, "H5Rget_name: ref not pinned"); + } /* end if */ + else { + aName = (char*)HDmalloc(sizeof(char)*bs); + if (aName == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + h5outOfMemory(env, "H5Rget_name: malloc failed"); + } /* end if */ + else { + ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refP, aName, bs) ; + + ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); + if (ret_val < 0) { + HDfree(aName); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR aName); + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); + + HDfree(aName); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Rget_1name */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5rImp.h b/java/src/jni/h5rImp.h new file mode 100644 index 0000000..2afb345 --- /dev/null +++ b/java/src/jni/h5rImp.h @@ -0,0 +1,78 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5R */ + +#ifndef _Included_hdf_hdf5lib_H5_H5R +#define _Included_hdf_hdf5lib_H5_H5R + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rcreate + * Signature: ([BJLjava/lang/String;IJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rcreate + (JNIEnv *, jclass, jbyteArray, jlong, jstring, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Rdereference + * Signature: (JJI[B)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rdereference + (JNIEnv *, jclass, jlong, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rget_region + * Signature: (JI[B)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rget_1region + (JNIEnv *, jclass, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5G_obj_t H5Rget_obj_type + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type + (JNIEnv *, jclass, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: int H5Rget_obj_type2 + * Signature: (JI[B[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 + (JNIEnv *, jclass, jlong, jint, jbyteArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Rget_name + * Signature: (JI[B[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Rget_1name + (JNIEnv *, jclass, jlong, jint, jbyteArray, jobjectArray, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5R */ diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c new file mode 100644 index 0000000..2aad3d0 --- /dev/null +++ b/java/src/jni/h5sImp.c @@ -0,0 +1,1408 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdlib.h> +#include "hdf5.h" +#include "h5jni.h" +#include "h5sImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Screate + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Screate(JNIEnv *env, jclass clss, jint type) +{ + hid_t retVal = -1; + + retVal = H5Screate((H5S_class_t) type); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Screate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Screate_simple + * Signature: (I[J[J)G + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Screate_1simple(JNIEnv *env, jclass clss, jint rank, + jlongArray dims, jlongArray maxdims) +{ + hid_t retVal = -1; + jlong *dimsP, *maxdimsP; + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + int i; + int drank, mrank; + hsize_t *lp; + jlong *jlp; + + if (rank < 0) { + h5badArgument(env, "H5Screate_simple: rank is invalid"); + } /* end if */ + else if (dims == NULL) { + h5nullArgument(env, "H5Screate_simple: dims is NULL"); + } /* end else if */ + else { + drank = (int)ENVPTR->GetArrayLength(ENVPAR dims); + if (drank != rank) { + h5badArgument(env, "H5Screate_simple: dims rank is invalid"); + return -1; + } /* end if */ + if (maxdims != NULL) { + mrank = (int)ENVPTR->GetArrayLength(ENVPAR maxdims); + if (mrank != rank) { + h5badArgument(env, "H5Screate_simple: maxdims rank is invalid"); + return -1; + } /* end if */ + } /* end if */ + dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); + if (dimsP == NULL) { + h5JNIFatalError(env, "H5Screate_simple: dims not pinned"); + return -1; + } /* end if */ + + sa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (sa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Screate_simple: dims not converted to hsize_t"); + return -1; + } /* end if */ + + jlp = (jlong *) dimsP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + + if (maxdims == NULL) { + maxdimsP = NULL; + msa = (hsize_t *)maxdimsP; + } /* end if */ + else { + maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); + if (maxdimsP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + h5JNIFatalError(env, "H5Screate_simple: maxdims not pinned"); + return -1; + } /* end if */ + msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (msa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + HDfree(sa); + h5JNIFatalError(env, "H5Screate_simple: dims not converted to hsize_t"); + return -1; + } /* end if */ + jlp = (jlong *)maxdimsP; + for (i = 0; i < mrank; i++) { + *lp = (hsize_t)*jlp; + lp++; + jlp++; + } /* end for */ + } /* end else */ + + retVal = H5Screate_simple(rank, (const hsize_t *)sa, (const hsize_t *)msa); + + if (maxdimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + if (msa) + HDfree(msa); + } /* end if */ + + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + if (sa) + HDfree(sa); + + if (retVal < 0) + h5libraryError(env); + } /* end else */ + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Screate_1simple */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Scopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Scopy(JNIEnv *env, jclass clss, jlong space_id) +{ + hid_t retVal = -1; + + retVal = H5Scopy(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Scopy */ + +#ifdef notdef +// 10/28/99 -- added code to copy the array -- this is not used, +// but serves as a reminder in case we try to implement this in +// the future.... +/* + * Note: the argument coord is actually long coord[][], which has been + * flattened by the caller. + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_elements + * Signature: (JII[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jlongArray coord) +{ + herr_t status = -1; + jint i; + jlong *P; + jboolean isCopy; + hssize_t *sa; + int rank; + + if (coord == NULL) { + h5nullArgument( env, "H5Sselect_elements: coord is NULL"); + return -1; + } /* end if */ + + P = ENVPTR->GetLongArrayElements(ENVPAR env,coord,&isCopy); + if (P == NULL) { + h5JNIFatalError(env, "H5Sselect_elements: coord not pinned"); + return -1; + } /* end if */ + sa = (hssize_t *)HDmalloc( (size_t)num_elems * 2 * sizeof(hssize_t)); + if (sa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR env,coord,P,JNI_ABORT); + h5JNIFatalError(env, "H5Sselect_elements: coord array not converted to hssize_t"); + return -1; + } /* end if */ + for (i= 0; i < (num_elsms * 2); i++) { + sa[i] = P[i]; + } /* end for */ + + status = H5Sselect_elements (space_id, (H5S_seloper_t)op, num_elemn, (const hssize_t **)&sa); + ENVPTR->ReleaseLongArrayElements(ENVPAR env, coord, P, JNI_ABORT); + HDfree(sa); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1elements */ +#endif + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_elements + * Signature: (JII[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id, jint op, + jint num_elemn, jbyteArray coord) +{ + int ii; + hsize_t *lp = NULL; + hsize_t *llp; + jlong *jlp; + herr_t status = -1; + jbyte *P; + jboolean isCopy; + jsize size; + int nlongs; + + if (coord == NULL) { + h5nullArgument(env, "H5Sselect_elements: coord is NULL"); + } /* end if */ + else { + P = ENVPTR->GetByteArrayElements(ENVPAR coord, &isCopy); + if (P == NULL) { + h5JNIFatalError(env, "H5Sselect_elements: coord not pinned"); + } /* end if */ + else { + size = (int)ENVPTR->GetArrayLength(ENVPAR coord); + nlongs = (int)((size_t)size / sizeof(jlong)); + lp = (hsize_t *)HDmalloc((size_t)nlongs * sizeof(hsize_t)); + jlp = (jlong *) P; + llp = lp; + for (ii = 0; ii < nlongs; ii++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + + status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp); + + ENVPTR->ReleaseByteArrayElements(ENVPAR coord, P, JNI_ABORT); + + if (llp) + HDfree(llp); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1elements */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_all + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1all(JNIEnv *env, jclass clss, jlong space_id) +{ + herr_t retVal = -1; + + retVal = H5Sselect_all(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1all */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_none + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1none(JNIEnv *env, jclass clss, jlong space_id) +{ + herr_t retVal = -1; + + retVal = H5Sselect_none(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1none */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_valid + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1valid(JNIEnv *env, jclass clss, jlong space_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Sselect_valid(space_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1valid */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints(JNIEnv *env, jclass clss, jlong space_id) +{ + hssize_t retVal = H5Sget_simple_extent_npoints(space_id); + + if (retVal < 0) + h5libraryError(env); + + return (jlong) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints(JNIEnv *env, jclass clss, jlong space_id) +{ + hssize_t retVal = H5Sget_select_npoints(space_id); + + if (retVal < 0) + h5libraryError(env); + + return (jlong) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1type(JNIEnv *env, jclass clss, jlong space_id) +{ + int retVal = -1; + + retVal = H5Sget_select_type(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_ndims + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims(JNIEnv *env, jclass clss, jlong space_id) +{ + int retVal = -1; + + retVal = H5Sget_simple_extent_ndims(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_dims + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims(JNIEnv *env, jclass clss, jlong space_id, + jlongArray dims, jlongArray maxdims) +{ + int status = -1; + jlong *dimsP, *maxdimsP; + jboolean isCopy; + hsize_t *sa; + hsize_t *msa; + int i; + int rank = -1; + int mrank; + + if (dims == NULL) { + dimsP = NULL; + sa = (hsize_t *) dimsP; + } /* end if */ + else { + dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); + if (dimsP == NULL) { + h5JNIFatalError(env, "H5Pget_simple_extent_dims: dims not pinned"); + return -1; + } /* end if */ + rank = (int)ENVPTR->GetArrayLength(ENVPAR dims); + sa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (sa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_simple_extent_dims: dims not converted to hsize_t"); + return -1; + } /* end if */ + } /* end else */ + if (maxdims == NULL) { + maxdimsP = NULL; + msa = (hsize_t *) maxdimsP; + } /* end if */ + else { + maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); + if (maxdimsP == NULL) { + if (dimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + } /* end if */ + h5JNIFatalError(env, "H5Pget_simple_extent_dims: maxdims not pinned"); + return -1; + } /* end if */ + mrank = (int) ENVPTR->GetArrayLength(ENVPAR maxdims); + if (rank < 0) + rank = mrank; + else if (mrank != rank) { + if (dimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + } /* end if */ + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); + return -1; + } /* end else if */ + msa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (msa == NULL) { + if (dimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + } /* end if */ + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_simple_extent_dims: maxdims not converted to hsize_t"); + return -1; + } /* end if */ + } /* end else */ + + status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa); + + if (status < 0) { + if (dimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + } /* end if */ + if (maxdimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + HDfree(msa); + } /* end if */ + h5libraryError(env); + return -1; + } /* end if */ + + if (dimsP != NULL) { + for (i = 0; i < rank; i++) { + dimsP[i] = (jlong)sa[i]; + } /* end for */ + HDfree(sa); + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); + } /* end if */ + if (maxdimsP != NULL) { + for (i = 0; i < rank; i++) { + maxdimsP[i] = (jlong)msa[i]; + } /* end for */ + HDfree(msa); + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, 0); + } /* end if */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type(JNIEnv *env, jclass clss, jlong space_id) +{ + H5S_class_t retVal = H5S_NO_CLASS; + + if (space_id < 0) + h5libraryError(env); + + retVal = H5Sget_simple_extent_type(space_id); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sset_extent_simple + * Signature: (JI[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple(JNIEnv *env, jclass clss, jlong space_id, + jint rank, jlongArray dims, jlongArray maxdims) +{ + herr_t status = -1; + jlong *dimsP, *maxdimsP; + jboolean isCopy; + hsize_t *sa; + hsize_t *msa; + int i; + int drank, mrank; + hsize_t *lp; + jlong *jlp; + + if (dims == NULL) { + h5nullArgument(env, "H5Sset_simple_extent: dims is NULL"); + return -1; + } /* end if */ + drank = (int) ENVPTR->GetArrayLength(ENVPAR dims); + if (drank != rank) { + h5badArgument(env, "H5Screate_simple: dims rank is invalid"); + return -1; + } /* end if */ + if (maxdims != NULL) { + mrank = (int) ENVPTR->GetArrayLength(ENVPAR maxdims); + if (mrank != rank) { + h5badArgument(env, "H5Screate_simple: maxdims rank is invalid"); + return -1; + } /* end if */ + } /* end if */ + dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); + if (dimsP == NULL) { + h5JNIFatalError(env, "H5Pset_simple_extent: dims not pinned"); + return -1; + } /* end if */ + sa = lp = (hsize_t *) malloc((size_t)rank * sizeof(hsize_t)); + if (sa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Sset_simple_extent: dims not converted to hsize_t"); + return -1; + } /* end if */ + jlp = (jlong *) dimsP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + if (maxdims == NULL) { + maxdimsP = NULL; + msa = (hsize_t *) maxdimsP; + } /* end if */ + else { + maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); + if (maxdimsP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5JNIFatalError(env, "H5Pset_simple_extent: maxdims not pinned"); + return -1; + } /* end if */ + msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (msa == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + HDfree(sa); + h5JNIFatalError(env, "H5Sset_simple_extent: maxdims not converted to hsize_t"); + return -1; + } /* end if */ + jlp = (jlong *) maxdimsP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + } /* end else */ + + status = H5Sset_extent_simple(space_id, rank, (hsize_t *) sa, (hsize_t *) msa); + + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + HDfree(sa); + if (maxdimsP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); + HDfree(msa); + } /* end if */ + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end v */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sis_simple + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Sis_1simple(JNIEnv *env, jclass clss, jlong space_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Sis_simple(space_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Sis_1simple */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Soffset_simple + * Signature: (J[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Soffset_1simple(JNIEnv *env, jclass clss, jlong space_id, jbyteArray offset) +{ + herr_t status; + jbyte *P = NULL; + jboolean isCopy; + hssize_t *sa; + size_t rank; + size_t i; + hssize_t *lp; + jlong *jlp; + + if (offset != NULL) { + P = ENVPTR->GetByteArrayElements(ENVPAR offset, &isCopy); + if (P == NULL) { + h5JNIFatalError(env, "H5Soffset_simple: offset not pinned"); + return -1; + } /* end if */ + i = (size_t)ENVPTR->GetArrayLength(ENVPAR offset); + rank = i / sizeof(jlong); + sa = lp = (hssize_t *)HDmalloc((size_t)rank * sizeof(hssize_t)); + if (sa == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR offset, P, JNI_ABORT); + h5JNIFatalError(env, "H5Soffset_simple: offset not converted to hssize_t"); + return -1; + } /* end if */ + jlp = (jlong *) P; + for (i = 0; i < rank; i++) { + *lp = (hssize_t) *jlp; + lp++; + jlp++; + } /* end for */ + } /* end if */ + else { + P = NULL; + sa = (hssize_t *) P; + } /* end else */ + + status = H5Soffset_simple(space_id, sa); + if (P != NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR offset, P, JNI_ABORT); + HDfree(sa); + } /* end if */ + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Soffset_1simple */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sextent_copy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sextent_1copy(JNIEnv *env, jclass clss, jlong space_id, jlong src_id) +{ + herr_t retVal = -1; + + retVal = H5Sextent_copy(space_id, src_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sextent_1copy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sextent_equal + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Sextent_1equal(JNIEnv *env, jclass clss, jlong space_id, jlong src_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Sextent_equal(space_id, src_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Sextent_1equal */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sset_extent_none + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sset_1extent_1none(JNIEnv *env, jclass clss, jlong space_id) +{ + herr_t retVal = -1; + + retVal = H5Sset_extent_none(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sset_1extent_1none */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_hyperslab + * Signature: (JI[J[J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab(JNIEnv *env, jclass clss, jlong space_id, jint op, + jlongArray start, jlongArray stride, jlongArray count, jlongArray block) +{ + herr_t status = -1; + jlong *startP, *strideP, *countP, *blockP; + jboolean isCopy; + hsize_t *strt; + hsize_t *strd; + hsize_t *cnt; + hsize_t *blk; + int rank; + int i; + hsize_t *lp; + jlong *jlp; + + if (start == NULL) { + h5nullArgument(env, "H5Sselect_hyperslab: start is NULL"); + } /* end if */ + else if (count == NULL) { + h5nullArgument(env, "H5Sselect_hyperslab: count is NULL"); + } /* end if */ + else { + rank = (int) ENVPTR->GetArrayLength(ENVPAR start); + if (rank != ENVPTR->GetArrayLength(ENVPAR count)) { + h5badArgument(env, "H5Sselect_hyperslab: count and start have different rank!"); + return -1; + } /* end if */ + + startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); + if (startP == NULL) { + h5JNIFatalError(env, "H5Sselect_hyperslab: start not pinned"); + return -1; + } /* end if */ + strt = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (strt == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + h5JNIFatalError(env, "H5Sselect_hyperslab: start not converted to hsize_t"); + return -1; + } /* end if */ + + jlp = (jlong *) startP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end if */ + + countP = ENVPTR->GetLongArrayElements(ENVPAR count, &isCopy); + if (countP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(strt); + h5JNIFatalError(env, "H5Sselect_hyperslab: count not pinned"); + return -1; + } /* end if */ + cnt = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (cnt == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + HDfree(strt); + h5JNIFatalError(env, "H5Sselect_hyperslab: count not converted to hsize_t"); + return -1; + } /* end if */ + + jlp = (jlong *) countP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end if */ + if (stride == NULL) { + strideP = NULL; + strd = (hsize_t *) strideP; + } /* end if */ + else { + strideP = ENVPTR->GetLongArrayElements(ENVPAR stride, &isCopy); + if (strideP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + h5badArgument(env, "H5Sselect_hyperslab: stride not pinned"); + return -1; + } /* end if */ + strd = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (strd == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + h5JNIFatalError(env, "H5Sselect_hyperslab: stride not converted to hsize_t"); + return -1; + } /* end if */ + jlp = (jlong *) strideP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end if */ + } /* end if */ + if (block == NULL) { + blockP = NULL; + blk = (hsize_t *) blockP; + } /* end if */ + else { + blockP = ENVPTR->GetLongArrayElements(ENVPAR block, &isCopy); + if (blockP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + if (strd != NULL) + free(strd); + + h5JNIFatalError(env, "H5Sselect_hyperslab: block not pinned"); + return -1; + } /* end if */ + blk = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (blk == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + if (strd != NULL) + free(strd); + + h5JNIFatalError(env, "H5Sget_simple_extent: block not converted to hsize_t"); + return -1; + } /* end if */ + jlp = (jlong *) blockP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + } /* end else */ + + status = H5Sselect_hyperslab(space_id, (H5S_seloper_t) op, (const hsize_t *) strt, (const hsize_t *) strd, + (const hsize_t *) cnt, (const hsize_t *) blk); + + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + HDfree(strt); + HDfree(cnt); + if (strideP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + HDfree(strd); + } /* end if */ + if (blockP != NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); + HDfree(blk); + } /* end if */ + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Sclose(JNIEnv *env, jclass clss, jlong space_id) +{ + herr_t retVal = -1; + + retVal = H5Sclose(space_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Sclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_hyper_nblocks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks(JNIEnv *env, jclass clss, jlong spaceid) +{ + hssize_t retVal = -1; + + retVal = H5Sget_select_hyper_nblocks((hid_t) spaceid); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_elem_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints(JNIEnv *env, jclass clss, jlong spaceid) +{ + hssize_t retVal = -1; + + retVal = H5Sget_select_elem_npoints((hid_t) spaceid); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_hyper_blocklist + * Signature: (JJJ[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist(JNIEnv *env, jclass clss, + jlong spaceid, jlong startblock, jlong numblocks, jlongArray buf) +{ + herr_t status = -1; + jlong *bufP; + jboolean isCopy; + hsize_t *ba; + int i; + int rank; + hsize_t st; + hsize_t nb; + + st = (hsize_t) startblock; + nb = (hsize_t) numblocks; + + if (buf == NULL) { + h5nullArgument(env, "H5Sget_select_hyper_blocklist: buf is NULL"); + } /* end if */ + else { + rank = H5Sget_simple_extent_ndims(spaceid); + if (rank <= 0) + rank = 1; + if (ENVPTR->GetArrayLength(ENVPAR buf) < (numblocks * rank)) { + h5badArgument(env, "H5Sget_select_hyper_blocklist: buf input array too small"); + } /* end if */ + else { + bufP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); + if (bufP == NULL) { + h5JNIFatalError(env, "H5Sget_select_hyper_blocklist: buf not pinned"); + } /* end if */ + else { + ba = (hsize_t *) malloc((size_t)nb * 2 * (size_t)rank * sizeof(hsize_t)); + if (ba == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); + h5JNIFatalError(env, "H5Screate-simple: buffer not converted to hsize_t"); + } /* end if */ + else { + status = H5Sget_select_hyper_blocklist((hid_t)spaceid, st, nb, (hsize_t *)ba); + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); + free(ba); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < (numblocks * 2 * rank); i++) { + bufP[i] = (jlong)ba[i]; + } /* end for */ + free(ba); + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_elem_pointlist + * Signature: (JJJ[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist(JNIEnv *env, jclass clss, jlong spaceid, + jlong startpoint, jlong numpoints, jlongArray buf) +{ + herr_t status = -1; + jlong *bufP; + jboolean isCopy; + hsize_t *ba; + int i; + int rank; + + if (buf == NULL) { + h5nullArgument(env, "H5Sget_select_elem_pointlist: buf is NULL"); + } /* end if */ + else { + rank = H5Sget_simple_extent_ndims(spaceid); + if (rank <= 0) + rank = 1; + if (ENVPTR->GetArrayLength(ENVPAR buf) < (numpoints * rank)) { + h5badArgument(env, "H5Sget_select_elem_pointlist: buf input array too small"); + } /* end if */ + else { + bufP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); + if (bufP == NULL) { + h5JNIFatalError(env, "H5Sget_select_elem_pointlist: buf not pinned"); + } /* end if */ + else { + ba = (hsize_t *)HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)); + if (ba == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_select_elem_pointlist: buf not converted to hsize_t"); + } /* end if */ + else { + status = H5Sget_select_elem_pointlist((hid_t) spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba); + + if (status < 0) { + HDfree(ba); + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < (numpoints * rank); i++) { + bufP[i] = (jlong)ba[i]; + } /* end for */ + HDfree(ba); + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end if */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_bounds + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds(JNIEnv *env, jclass clss, jlong spaceid, + jlongArray start, jlongArray end) +{ + herr_t status = -1; + jlong *startP, *endP; + jboolean isCopy; + hsize_t *strt; + hsize_t *en; + int rank; + int i; + + if (start == NULL) { + h5nullArgument(env, "H5Sget_select_bounds: start is NULL"); + } /* end if */ + else if (end == NULL) { + h5nullArgument(env, "H5Sget_select_bounds: end is NULL"); + } /* end else if */ + else { + startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); + if (startP == NULL) { + h5JNIFatalError(env, "H5Sget_select_bounds: start not pinned"); + return -1; + } /* end if */ + rank = (int) ENVPTR->GetArrayLength(ENVPAR start); + strt = (hsize_t *)malloc((size_t)rank * sizeof(hsize_t)); + if (strt == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_select_bounds: start not converted to hsize_t"); + return -1; + } /* end if */ + + endP = ENVPTR->GetLongArrayElements(ENVPAR end, &isCopy); + if (endP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + free(strt); + h5JNIFatalError(env, "H5Sget_select_bounds: end not pinned"); + return -1; + } /* end if */ + en = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (en == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(strt); + h5JNIFatalError(env, "H5Sget_simple_extent: dims not converted to hsize_t"); + return -1; + } /* end if */ + + status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en); + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, JNI_ABORT); + HDfree(strt); + HDfree(en); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < rank; i++) { + startP[i] = (jlong)strt[i]; + endP[i] = (jlong)en[i]; + } /* end for */ + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, 0); + HDfree(strt); + HDfree(en); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sencode + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_H5_H5Sencode(JNIEnv *env, jclass cls, jlong obj_id) +{ + herr_t status = -1; + unsigned char *bufPtr; + size_t buf_size = 0; + jbyteArray returnedArray = NULL; + + if (obj_id < 0) { + h5badArgument(env, "H5Sencode: invalid argument"); + } /* end if */ + else { + status = H5Sencode(obj_id, NULL, &buf_size); + + if (status < 0) { + h5libraryError(env); + } /* end else if */ + else if (buf_size < 0) { + h5badArgument(env, "H5Sencode: buf_size < 0"); + } /* end if */ + else { + bufPtr = (unsigned char*)HDcalloc((size_t) 1, buf_size); + if (bufPtr == NULL) { + h5outOfMemory(env, "H5Sencode: calloc failed"); + } /* end if */ + else { + status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size); + + if (status < 0) { + HDfree(bufPtr); + h5libraryError(env); + } /* end if */ + else { + returnedArray = ENVPTR->NewByteArray(ENVPAR (jsize)buf_size); + ENVPTR->SetByteArrayRegion(ENVPAR returnedArray, 0, (jsize)buf_size, (jbyte*) bufPtr); + HDfree(bufPtr); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return returnedArray; +} /* end Java_hdf_hdf5lib_H5_H5Sencode */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sdecode + * Signature: ([B)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Sdecode(JNIEnv *env, jclass cls, jbyteArray buf) +{ + hid_t sid = -1; + jbyte *bufP; + jboolean isCopy; + + if (buf == NULL) { + h5nullArgument(env, "H5Sdecode: buf is NULL"); + } /* end if */ + else { + bufP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (bufP == NULL) { + h5JNIFatalError( env, "H5Sdecode: buf not pinned"); + } /* end if */ + else { + sid = H5Sdecode(bufP); + + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, bufP, JNI_ABORT); + + if (sid < 0) + h5libraryError(env); + } /* end else if */ + } /* end else if */ + + return (jlong)sid; +} /* end Java_hdf_hdf5lib_H5_H5Sdecode */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sis_regular_hyperslab + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab(JNIEnv *env, jclass cls, jlong obj_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Sis_regular_hyperslab((hid_t)obj_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_regular_hyperslab + * Signature: (J[J[J[J[J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab(JNIEnv *env, jclass clss, jlong space_id, + jlongArray start, jlongArray stride, jlongArray count, jlongArray block) +{ + herr_t status; + jlong *startP, *strideP, *countP, *blockP; + jboolean isCopy; + hsize_t *strt; + hsize_t *strd; + hsize_t *cnt; + hsize_t *blk; + int rank; + int i; + + if (start == NULL) { + h5nullArgument(env, "H5Sget_regular_hyperslab: start is NULL"); + } /* end if */ + else if (count == NULL) { + h5nullArgument(env, "H5Sget_regular_hyperslab: count is NULL"); + } /* end else if */ + else { + rank = (int) ENVPTR->GetArrayLength(ENVPAR start); + if (rank != ENVPTR->GetArrayLength(ENVPAR count)) { + h5badArgument(env, "H5Sget_regular_hyperslab: count and start have different rank!"); + return; + } /* end if */ + + startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); + if (startP == NULL) { + h5JNIFatalError(env, "H5Sget_regular_hyperslab: start not pinned"); + return; + } /* end if */ + strt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (strt == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: start not converted to hsize_t"); + return; + } /* end if */ + + countP = ENVPTR->GetLongArrayElements(ENVPAR count, &isCopy); + if (countP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(strt); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: count not pinned"); + return; + } /* end if */ + cnt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (cnt == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + HDfree(strt); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: count not converted to hsize_t"); + return; + } /* end if */ + + strideP = ENVPTR->GetLongArrayElements(ENVPAR stride, &isCopy); + if (strideP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + h5badArgument(env, "H5Sget_regular_hyperslab: stride not pinned"); + return; + } /* end if */ + strd = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (strd == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: stride not converted to hsize_t"); + return; + } /* end if */ + + blockP = ENVPTR->GetLongArrayElements(ENVPAR block, &isCopy); + if (blockP == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + HDfree(strd); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: block not pinned"); + return; + } /* end if */ + blk = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); + if (blk == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); + HDfree(cnt); + HDfree(strt); + HDfree(strd); + h5JNIFatalError(env, "H5Sget_regular_hyperslab: block not converted to hsize_t"); + return; + } /* end if */ + + status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk); + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); + HDfree(strt); + HDfree(cnt); + HDfree(strd); + HDfree(blk); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < (rank); i++) { + startP[i] = (jlong)strt[i]; + countP[i] = (jlong)cnt[i]; + strideP[i] = (jlong)strd[i]; + blockP[i] = (jlong)blk[i]; + } /* end for */ + HDfree(strt); + HDfree(cnt); + HDfree(strd); + HDfree(blk); + ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5sImp.h b/java/src/jni/h5sImp.h new file mode 100644 index 0000000..007b9a7 --- /dev/null +++ b/java/src/jni/h5sImp.h @@ -0,0 +1,288 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5S */ + +#ifndef _Included_hdf_hdf5lib_H5_H5S +#define _Included_hdf_hdf5lib_H5_H5S + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Screate + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate( + JNIEnv *, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Screate_simple + * Signature: (I[J[J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate_1simple( + JNIEnv *, jclass, jint, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Scopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Scopy( + JNIEnv *, jclass, jlong); + +#ifdef notdef +// 10/28/99 -- added code to copy the array -- this is not used, +// but serves as a reminder in case we try to implement this in +// the future.... +/* + * Note: the argument coord is actually long coord[][], which has been + * flattened by the caller. + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_elements + * Signature: (JII[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements +(JNIEnv *, jclass, jlong, jint, jint, jlongArray); +#endif + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_elements + * Signature: (JII[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements( + JNIEnv *, jclass, jlong, jint, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_all + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1all( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_none + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1none( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_valid + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1valid( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1type( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_ndims + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_dims + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims( + JNIEnv *, jclass, jlong, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_simple_extent_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sset_extent_simple + * Signature: (JI[J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple( + JNIEnv *, jclass, jlong, jint, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sis_simple + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sis_1simple( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Soffset_simple + * Signature: (J[B)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Soffset_1simple( + JNIEnv *, jclass, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sextent_copy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sextent_1copy( + JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sextent_equal + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sextent_1equal + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sset_extent_none + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1none( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sselect_hyperslab + * Signature: (JI[J[J[J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab( + JNIEnv *, jclass, jlong, jint, jlongArray, jlongArray, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Sclose( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_hyper_nblocks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_elem_npoints + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints( + JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_hyper_blocklist + * Signature: (JJJ[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist( + JNIEnv *, jclass, jlong, jlong, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_elem_pointlist + * Signature: (JJJ[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist( + JNIEnv *, jclass, jlong, jlong, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_select_bounds + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds( + JNIEnv *, jclass, jlong, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sencode + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Sencode + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sdecode + * Signature: ([B)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sdecode + (JNIEnv *, jclass, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sis_regular_hyperslab + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Sget_regular_hyperslab + * Signature: (J[J[J[J[J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab( + JNIEnv *, jclass, jlong, jlongArray, jlongArray, jlongArray, jlongArray); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5S */ diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c new file mode 100644 index 0000000..83882a0 --- /dev/null +++ b/java/src/jni/h5tImp.c @@ -0,0 +1,1588 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "hdf5.h" +#include "h5jni.h" +#include "h5tImp.h" + +extern JavaVM *jvm; +extern jobject visit_callback; + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Topen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Topen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) +{ + hid_t status; + const char *tName; + + PIN_JAVA_STRING(name, tName, -1); + + status = H5Topen2((hid_t)loc_id, tName, (hid_t)access_plist); + + UNPIN_JAVA_STRING(name, tName); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5__1H5Topen2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tcommitted + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Tcommitted(JNIEnv *env, jclass clss, jlong type_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Tcommitted(type_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Tcommitted */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tcreate + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tcreate(JNIEnv *env, jclass clss, jint dclass, jlong size) +{ + hid_t retVal = -1; + + retVal = H5Tcreate((H5T_class_t )dclass, (size_t)size); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tcreate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tcopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tcopy(JNIEnv *env, jclass clss, jlong type_id) +{ + hid_t retVal = -1; + + retVal = H5Tcopy((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tcopy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tequal + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Tequal(JNIEnv *env, jclass clss, jlong type_id1, jlong type_id2) +{ + htri_t bval = JNI_FALSE; + + bval = H5Tequal((hid_t)type_id1, (hid_t)type_id2); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Tequal */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tlock + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tlock(JNIEnv *env, jclass clss, jlong type_id) +{ + herr_t retVal = -1; + + retVal = H5Tlock((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tlock */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_class + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1class(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_class_t retVal = H5T_NO_CLASS; + + retVal = H5Tget_class((hid_t)type_id); + if (retVal == H5T_NO_CLASS) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1size(JNIEnv *env, jclass clss, jlong type_id) +{ + size_t retVal = 0; + + retVal = H5Tget_size((hid_t)type_id); + if (retVal == 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1size*/ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1size(JNIEnv *env, jclass clss, jlong type_id, jlong size) +{ + size_t tsize = (size_t)size; + herr_t retVal = -1; + + retVal = H5Tset_size((hid_t)type_id, tsize); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end ifJava_hdf_hdf5lib_H5_H5Tset_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1order(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_order_t retVal = H5T_ORDER_ERROR; + + retVal = H5Tget_order((hid_t)type_id); + if (retVal == H5T_ORDER_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1order(JNIEnv *env, jclass clss, jlong type_id, jint order) +{ + herr_t retVal = -1; + + retVal = H5Tset_order((hid_t)type_id, (H5T_order_t)order); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_precision + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1precision(JNIEnv *env, jclass clss, jlong type_id) +{ + size_t retVal = 0; + + retVal = H5Tget_precision((hid_t)type_id); + if (retVal == 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1precision */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_precision_long + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1precision_1long(JNIEnv *env, jclass clss, jlong type_id) +{ + size_t retVal = 0; + + retVal = H5Tget_precision((hid_t)type_id); + if (retVal == 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1precision_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_precision + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1precision(JNIEnv *env, jclass clss, jlong type_id, jlong precision) +{ + herr_t retVal = -1; + + retVal = H5Tset_precision((hid_t)type_id, (size_t)precision); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1precision */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_offset + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1offset(JNIEnv *env, jclass clss, jlong type_id) +{ + int retVal = -1; + + retVal = H5Tget_offset((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1offset(JNIEnv *env, jclass clss, jlong type_id, jlong offset) +{ + herr_t retVal = -1; + + retVal = H5Tset_offset((hid_t)type_id, (size_t)offset); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_pad + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1pad(JNIEnv *env, jclass clss, jlong type_id, jintArray pad) +{ + herr_t status = -1; + jboolean isCopy; + jint *P; + + if (pad == NULL) { + h5nullArgument(env, "H5Tget_pad: pad is NULL"); + } /* end if */ + else { + P = ENVPTR->GetIntArrayElements(ENVPAR pad, &isCopy); + if (P == NULL) { + h5JNIFatalError(env, "H5Tget_pad: pad not pinned"); + } /* end if */ + else { + status = H5Tget_pad((hid_t)type_id, (H5T_pad_t *)&(P[0]), (H5T_pad_t *)&(P[1])); + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR pad, P, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR pad, P, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1pad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_pad + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1pad(JNIEnv *env, jclass clss, jlong type_id, jint lsb, jint msb) +{ + herr_t retVal = -1; + + retVal = H5Tset_pad((hid_t)type_id, (H5T_pad_t)lsb, (H5T_pad_t)msb); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1pad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_sign + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1sign(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_sign_t retVal = H5T_SGN_ERROR; + + retVal = H5Tget_sign((hid_t)type_id); + if (retVal == H5T_SGN_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1sign */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_sign + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1sign(JNIEnv *env, jclass clss, jlong type_id, jint sign) +{ + herr_t retVal = -1; + + retVal = H5Tset_sign((hid_t)type_id, (H5T_sign_t)sign); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1sign */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_fields_int + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1fields_1int(JNIEnv *env, jclass clss, jlong type_id, jintArray fields) +{ + herr_t status; + jboolean isCopy; + jint *P; + + if (fields == NULL) { + h5nullArgument(env, "H5Tget_fields: fields is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR fields) < 5) { + h5badArgument(env, "H5Tget_fields: fields input array < order 5"); + } /* end else if */ + else { + P = ENVPTR->GetIntArrayElements(ENVPAR fields, &isCopy); + if (P == NULL) { + h5JNIFatalError(env, "H5Tget_fields: fields not pinned"); + } /* end if */ + else { + status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), (size_t *)&(P[3]), (size_t *)&(P[4])); + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR fields, P, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR fields, P, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1fields_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_fields + * Signature: (J[J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1fields(JNIEnv *env, jclass clss, jlong type_id, jlongArray fields) +{ + herr_t status; + jboolean isCopy; + jlong *fieldsArray; + + if (fields == NULL) { + h5nullArgument(env, "H5Tget_fields: fields is NULL"); + } /* end if */ + else if (ENVPTR->GetArrayLength(ENVPAR fields) < 5) { + h5badArgument(env, "H5Tget_fields: fields input array < order 5"); + } /* end else if */ + else { + fieldsArray = ENVPTR->GetLongArrayElements(ENVPAR fields, &isCopy); + if (fieldsArray == NULL) { + h5JNIFatalError(env, "H5Tget_fields: fields not pinned"); + } /* end if */ + else { + { /* direct cast (size_t *)variable fails on 32-bit environment */ + size_t spos_t = 0; + size_t epos_t = 0; + size_t esize_t = 0; + size_t mpos_t = 0; + size_t msize_t = 0; + long long fields_temp = *(&fieldsArray[0]); + spos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[1]); + epos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[2]); + esize_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[3]); + mpos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[4]); + msize_t = (size_t)fields_temp; + + status = H5Tget_fields((hid_t)type_id, &spos_t, &epos_t, &esize_t, &mpos_t, &msize_t); + + *(&fieldsArray[0]) = (jlong)spos_t; + *(&fieldsArray[1]) = (jlong)epos_t; + *(&fieldsArray[2]) = (jlong)esize_t; + *(&fieldsArray[3]) = (jlong)mpos_t; + *(&fieldsArray[4]) = (jlong)msize_t; + } /* end direct cast special handling */ + + if (status < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR fields, fieldsArray, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseLongArrayElements(ENVPAR fields, fieldsArray, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Tget_1fields */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_fields + * Signature: (JJJJJJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1fields(JNIEnv *env, jclass clss, jlong type_id, jlong spos, jlong epos, + jlong esize, jlong mpos, jlong msize) +{ + if (H5Tset_fields((hid_t)type_id, (size_t)spos, (size_t)epos, (size_t)esize, (size_t)mpos, (size_t)msize) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Tset_1fields */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_ebias + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1ebias(JNIEnv *env, jclass clss, jlong type_id) +{ + size_t retVal = 0; + + retVal = H5Tget_ebias((hid_t)type_id); + if (retVal == 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1ebias */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_ebias_long + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long(JNIEnv *env, jclass clss, jlong type_id) +{ + size_t retVal = 0; + + retVal = H5Tget_ebias((hid_t)type_id); + if (retVal == 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_ebias + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1ebias(JNIEnv *env, jclass clss, jlong type_id, jlong ebias) +{ + herr_t retVal = -1; + + retVal = H5Tset_ebias((hid_t)type_id, (size_t)ebias); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1ebias */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_norm + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1norm(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_norm_t retVal = H5T_NORM_ERROR; + + retVal = H5Tget_norm((hid_t)type_id); + if (retVal == H5T_NORM_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1norm */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_norm + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1norm(JNIEnv *env, jclass clss, jlong type_id, jint norm) +{ + herr_t retVal = -1; + + retVal = H5Tset_norm((hid_t)type_id, (H5T_norm_t )norm); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1norm */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_inpad + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1inpad(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_pad_t retVal = H5T_PAD_ERROR; + + retVal = H5Tget_inpad((hid_t)type_id ); + if (retVal == H5T_PAD_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1inpad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_inpad + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1inpad(JNIEnv *env, jclass clss, jlong type_id, jint inpad) +{ + herr_t retVal = -1; + + retVal = H5Tset_inpad((hid_t)type_id, (H5T_pad_t) inpad); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1inpad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_cset + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1cset(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_cset_t retVal = H5T_CSET_ERROR; + + retVal = H5Tget_cset((hid_t)type_id); + if (retVal == H5T_CSET_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1cset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_cset + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1cset(JNIEnv *env, jclass clss, jlong type_id, jint cset) +{ + herr_t retVal = -1; + + retVal = H5Tset_cset((hid_t)type_id, (H5T_cset_t)cset); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1cset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_strpad + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1strpad(JNIEnv *env, jclass clss, jlong type_id) +{ + H5T_str_t retVal = H5T_STR_ERROR; + + retVal = H5Tget_strpad((hid_t)type_id); + if (retVal == H5T_STR_ERROR) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1strpad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_strpad + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1strpad(JNIEnv *env, jclass clss, jlong type_id, jint strpad) +{ + herr_t retVal = -1; + + retVal = H5Tset_strpad((hid_t)type_id, (H5T_str_t)strpad); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1strpad */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_nmembers + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1nmembers(JNIEnv *env, jclass clss, jlong type_id) +{ + int retVal = -1; + + retVal = H5Tget_nmembers((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1nmembers */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_name + * Signature: (JI)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1name(JNIEnv *env, jclass clss, jlong type_id, jint field_idx) +{ + char *name; + jstring str = NULL; + + name = H5Tget_member_name((hid_t)type_id, (unsigned)field_idx); + if (name != NULL) { + str = ENVPTR->NewStringUTF(ENVPAR name); + H5free_memory(name); + + if (str == NULL) + h5JNIFatalError(env, "H5Tget_member_name: returned string not created"); + } /* end if */ + + return str; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_index + * Signature: (JLjava/lang/String)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1index(JNIEnv *env, jclass clss, jlong type_id, jstring field_name) +{ + const char *tName; + int index = -1; + + PIN_JAVA_STRING(field_name, tName, -1); + + index = H5Tget_member_index((hid_t)type_id, tName); + + UNPIN_JAVA_STRING(field_name, tName); + + if (index < 0) + h5libraryError(env); + + return (jint)index; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1index */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_type + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tget_1member_1type(JNIEnv *env, jclass clss, jlong type_id, jint field_idx) +{ + hid_t retVal = -1; + + retVal = H5Tget_member_type((hid_t)type_id, (unsigned)field_idx); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tget_1member_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_offset + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1offset(JNIEnv *env, jclass clss, jlong type_id, jint memno) +{ + return (jlong)H5Tget_member_offset((hid_t)type_id, (unsigned)memno); +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_class + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1class(JNIEnv *env, jclass clss, jlong type_id, jint memno) +{ + int retVal = -1; + + retVal = H5Tget_member_class((hid_t)type_id, (unsigned)memno); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tinsert + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tinsert(JNIEnv *env, jclass clss, jlong type_id, jstring name, jlong offset, jlong field_id) +{ + herr_t status; + const char *tName; + long off = (long)offset; + + PIN_JAVA_STRING(name, tName, -1); + + status = H5Tinsert((hid_t)type_id, tName, (size_t)off, field_id); + + UNPIN_JAVA_STRING(name,tName); + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tinsert */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tpack + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tpack(JNIEnv *env, jclass clss, jlong type_id) +{ + herr_t retVal = -1; + + retVal = H5Tpack((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Tpack */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Tclose(JNIEnv *env, jclass clss, jlong type_id) +{ + herr_t retVal = -1; + + retVal = H5Tclose((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tvlen_create + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tvlen_1create(JNIEnv *env, jclass clss, jlong base_id) +{ + hid_t retVal = -1; + + retVal = H5Tvlen_create((hid_t)base_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tvlen_1create */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_tag + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tset_1tag(JNIEnv *env, jclass clss, jlong type, jstring tag) +{ + herr_t status = -1; + const char *tagP; + + PIN_JAVA_STRING(tag, tagP, -1); + + status = H5Tset_tag((hid_t)type, tagP); + + UNPIN_JAVA_STRING(tag,tagP); + + if (status < 0) + h5libraryError(env); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tset_1tag */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_tag + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1tag(JNIEnv *env, jclass clss, jlong type) +{ + jstring str = NULL; + char *tag; + + tag = H5Tget_tag((hid_t)type); + if (tag != NULL) { + str = ENVPTR->NewStringUTF(ENVPAR tag); + H5free_memory(tag); + + if (str == NULL) + h5JNIFatalError(env, "H5Tget_tag: returned string not created"); + } /* end if */ + + return str; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1tag */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_super + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tget_1super(JNIEnv *env, jclass clss, jlong type_id) +{ + hid_t retVal = -1; + + retVal = H5Tget_super((hid_t)type_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tget_1super */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tenum_create + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tenum_1create(JNIEnv *env, jclass clss, jlong base_id) +{ + hid_t retVal = -1; + + retVal = H5Tenum_create((hid_t)base_id); + if (retVal < 0) + h5libraryError(env); + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tenum_1create */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_insert_int + * Signature: (JLjava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int(JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) +{ + herr_t status = -1; + jint *intP; + const char *nameP; + jboolean isCopy2; + + if (value == NULL ) { + h5nullArgument(env, "H5Tenum_insert: value is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING(name, nameP, -1); + + intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy2); + if (intP == NULL) { + UNPIN_JAVA_STRING(name, nameP); + h5JNIFatalError(env, "H5Tenum_insert: value not pinned"); + return -1; + } /* end if */ + else { + status = H5Tenum_insert((hid_t)type_id, nameP, intP); + + UNPIN_JAVA_STRING(name, nameP); + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_insert + * Signature: (JLjava/lang/String;[B)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1insert(JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) +{ + herr_t status = -1; + jbyte *byteP; + const char *nameP; + jboolean isCopy2; + + if (value == NULL) { + h5nullArgument(env, "H5Tenum_insert: value is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING0(name, nameP); + + byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy2); + if (byteP == NULL) { + UNPIN_JAVA_STRING(name, nameP); + h5JNIFatalError(env, "H5Tenum_insert: value not pinned"); + } /* end if */ + else { + status = H5Tenum_insert((hid_t)type_id, nameP, byteP); + + UNPIN_JAVA_STRING(name, nameP); + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1insert */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_nameof_int + * Signature: (J[I[Ljava/lang/String;I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int(JNIEnv *env, jclass clss, jlong type_id, jintArray value, jobjectArray name, + jint size) +{ + herr_t status = -1; + jint *intP; + char *nameP; + jboolean isCopy; + jstring str; + + if (size <= 0) { + h5badArgument(env, "H5Tenum_nameof: name size < 0"); + } /* end if */ + else if (value == NULL) { + h5nullArgument(env, "H5Tenum_nameof: value is NULL"); + } /* end if */ + else { + nameP = (char*)HDmalloc(sizeof(char) * (size_t)size); + if (nameP == NULL) { + /* exception -- out of memory */ + h5outOfMemory(env, "H5Tenum_nameof: malloc name size"); + } /* end if */ + else { + intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy); + if (intP == NULL) { + HDfree(nameP); + h5JNIFatalError(env, "H5Tenum_nameof: value not pinned"); + } /* end if */ + else { + status = H5Tenum_nameof((hid_t)type_id, intP, nameP, (size_t)size); + + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); + + if (status < 0) { + HDfree(nameP); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR nameP); + HDfree(nameP); + if (str == NULL) { + h5JNIFatalError(env, "H5Tenum_nameof: return array not created"); + } /* end if */ + else + ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_nameof + * Signature: (J[BJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1nameof(JNIEnv *env, jclass clss, jlong type_id, jbyteArray value, jlong size) +{ + herr_t status = -1; + jbyte *byteP; + char *nameP; + jboolean isCopy; + jstring str = NULL; + + if (size <= 0) { + h5badArgument(env, "H5Tenum_nameof: name size < 0"); + } /* end if */ + else if (value == NULL ) { + h5nullArgument(env, "H5Tenum_nameof: value is NULL"); + } /* end if */ + else { + nameP = (char*)HDmalloc(sizeof(char) * (size_t)size); + if (nameP == NULL) { + h5outOfMemory(env, "H5Tenum_nameof: malloc name size"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); + if (byteP == NULL) { + HDfree(nameP); + h5JNIFatalError(env, "H5Tenum_nameof: value not pinned"); + } /* end if */ + else { + status = H5Tenum_nameof((hid_t)type_id, byteP, nameP, (size_t)size); + + /* free the buffer without copying back */ + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + + if (status < 0) { + HDfree(nameP); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR nameP); + HDfree(nameP); + if (str == NULL) { + h5JNIFatalError(env, "H5Tenum_nameof: return array not created"); + } /* end if */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return str; +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1nameof */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_valueof_int + * Signature: (JLjava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int(JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) +{ + herr_t status = -1; + jint *intP; + const char *nameP; + jboolean isCopy2; + + if (value == NULL) { + h5nullArgument(env, "H5Tenum_valueof: value is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING(name, nameP, -1); + + intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy2); + if (intP == NULL) { + UNPIN_JAVA_STRING(name, nameP); + h5JNIFatalError(env, "H5Tenum_valueof: value not pinned"); + } /* end if */ + else { + status = H5Tenum_valueof((hid_t)type_id, nameP, intP); + + UNPIN_JAVA_STRING(name, nameP); + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_valueof + * Signature: (JLjava/lang/String;[B)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tenum_1valueof(JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) +{ + herr_t status = -1; + jbyte *byteP; + const char *nameP; + jboolean isCopy2; + + if (value == NULL) { + h5nullArgument(env, "H5Tenum_valueof: value is NULL"); + } /* end if */ + else { + PIN_JAVA_STRING0(name, nameP); + + byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy2); + if (byteP == NULL) { + UNPIN_JAVA_STRING(name,nameP); + h5JNIFatalError(env, "H5Tenum_valueof: value not pinned"); + } /* end if */ + else { + status = H5Tenum_valueof((hid_t)type_id, nameP, byteP); + + UNPIN_JAVA_STRING(name, nameP); + + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Tenum_1valueof */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_value_int + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int(JNIEnv *env, jclass clss, jlong type_id, jint membno, jintArray value) +{ + herr_t status = -1; + jint *intP; + jboolean isCopy; + + if (value == NULL) { + h5nullArgument(env, "H5Tget_member_value: value is NULL"); + } /* end if */ + else { + intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy); + if (intP == NULL) { + h5JNIFatalError(env, "H5Tget_member_value: value not pinned"); + } /* end if */ + else { + status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, intP); + + + if (status < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, 0); + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_value + * Signature: (JI[B)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1member_1value(JNIEnv *env, jclass clss, jlong type_id, jint membno, jbyteArray value) +{ + herr_t status = -1; + jbyte *byteP; + jboolean isCopy; + + if (value == NULL) { + h5nullArgument( env, "H5Tget_member_value: value is NULL"); + } /* end if */ + else { + byteP = ENVPTR->GetByteArrayElements(ENVPAR value,&isCopy); + if (byteP == NULL) { + h5JNIFatalError(env, "H5Tget_member_value: value not pinned"); + } /* end if */ + else { + status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, byteP); + + if (status < 0) { + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else + ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_array_dims + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims(JNIEnv *env, jclass clss, jlong type_id) +{ + int ndims = -1; + + ndims = H5Tget_array_ndims((hid_t)type_id); + if (ndims < 0) + h5libraryError(env); + + return (jint)ndims; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tarray_get_dims + * Signature: (J[I[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1array_1dims(JNIEnv *env, jclass clss, jlong type_id, jintArray dims, jintArray perms) +{ + int ndims = -1; + int dlen; + int i; + jint *dimsP; + hsize_t *cdims = NULL; + jboolean isCopy; + + if (dims == NULL) { + h5nullArgument( env, "H5Tget_array_dims: value is NULL"); + } /* end if */ + else { + dimsP = ENVPTR->GetIntArrayElements(ENVPAR dims, &isCopy); + if (dimsP == NULL) { + h5JNIFatalError(env, "H5Tget_array_dims: dimsP not pinned"); + } /* end if */ + else { + dlen = ENVPTR->GetArrayLength(ENVPAR dims); + cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); + + ndims = H5Tget_array_dims2((hid_t)type_id, cdims); + + if (ndims < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < dlen; i++) { + dimsP[i] = (jint) cdims[i]; + } /* end for */ + ENVPTR->ReleaseIntArrayElements(ENVPAR dims, dimsP, 0); + + if (cdims) HDfree(cdims); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)ndims; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1dims */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tis_variable_str + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Tis_1variable_1str(JNIEnv *env, jclass clss, jlong type_id) +{ + htri_t bval = JNI_FALSE; + + bval = H5Tis_variable_str((hid_t)type_id); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Tis_1variable_1str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_native_type + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5__1H5Tget_1native_1type(JNIEnv *env, jclass clss, jlong type_id, jint direction) +{ + hid_t native_tid = -1; + + native_tid = H5Tget_native_type((hid_t)type_id, (H5T_direction_t)direction); + + if (native_tid < 0) + h5libraryError(env); + + return (jint)native_tid; +} /* end Java_hdf_hdf5lib_H5__1H5Tget_1native_1type */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tdetect_class + * Signature: (JI)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Tdetect_1class(JNIEnv *env, jclass clss, jlong type_id, jint dtype_class) +{ + htri_t bval = JNI_FALSE; + + bval = H5Tdetect_class((hid_t)type_id, (H5T_class_t)dtype_class); + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Tdetect_1class */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tcommit + * Signature: (JLjava/lang/String;JJJJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tcommit(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type, + jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +{ + herr_t status = -1; + const char *tName; + + PIN_JAVA_STRING0(name, tName); + + status = H5Tcommit2((hid_t)loc_id, tName, (hid_t)type, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id); + + UNPIN_JAVA_STRING(name, tName); + + if (status < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Tcommit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tarray_create2 + * Signature: (JI[J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Tarray_1create2(JNIEnv *env, jclass clss, jlong base_id, jint rank, jlongArray dims) +{ + hid_t retVal = -1; + jlong *dimsP; + int dlen; + hsize_t *cdims = NULL; + jboolean isCopy; + int i; + + if (rank <= 0) { + h5badArgument(env, "H5Tarray_create: rank is < 1"); + } /* end if */ + else if (dims == NULL) { + h5nullArgument(env, "H5Tarray_create: dims is NULL"); + } /* end else if */ + else { + dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); + if (dimsP == NULL) { + h5JNIFatalError( env, "H5Tarray_create: dimsP not pinned"); + } /* end if */ + else { + dlen = ENVPTR->GetArrayLength(ENVPAR dims); + if (dlen != rank) { + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + } /* end if */ + else { + cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); + for (i = 0; i < dlen; i++) { + cdims[i] = (hsize_t)dimsP[i]; + } /* end for */ + + retVal = H5Tarray_create2((hid_t)base_id, (unsigned)rank, (const hsize_t*)cdims); + + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); + + HDfree(cdims); + if (retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Tarray_1create2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tarray_get_dims2 + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2(JNIEnv *env, jclass clss, jlong type_id, jlongArray dims) +{ + int ndims = -1; + int dlen; + int i; + jlong *dimsP; + hsize_t *cdims=NULL; + jboolean isCopy; + + if (dims == NULL) { + h5nullArgument(env, "H5Tget_array_dims: value is NULL"); + } /* end if */ + else { + dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims,&isCopy); + if (dimsP == NULL) { + h5JNIFatalError(env, "H5Tget_array_dims: dimsP not pinned"); + } /* end if */ + else { + dlen = ENVPTR->GetArrayLength(ENVPAR dims); + cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); + + ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims); + + if (ndims < 0) { + if (cdims) + free(cdims); + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + for (i = 0; i < dlen; i++) { + dimsP[i] = (jlong) cdims[i]; + } /* end for */ + ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); + + if (cdims) + HDfree(cdims); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)ndims; +} /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tconvert + * Signature: (JJJ[B[BJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Tconvert(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id, jlong nelmts, + jbyteArray buf, jbyteArray background, jlong plist_id) +{ + herr_t status; + jbyte *bufP; + jbyte *bgP = NULL; + jboolean isCopy; + + if (nelmts <= 0) { + h5badArgument(env, "H5Tconvert: name nelmts < 0"); + } /* end if */ + else { + bufP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); + if (bufP == NULL) { + h5JNIFatalError(env, "H5Tconvert: value not pinned"); + } /* end if */ + else { + if (background) + bgP = ENVPTR->GetByteArrayElements(ENVPAR background, &isCopy); + + status = H5Tconvert((hid_t)src_id, (hid_t)dst_id, (size_t)nelmts, (void *)bufP, (void *)bgP, (hid_t)plist_id) ; + + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, bufP, 0); + + if (bgP) + ENVPTR->ReleaseByteArrayElements(ENVPAR background, bgP, 0); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Tconvert */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5tImp.h b/java/src/jni/h5tImp.h new file mode 100644 index 0000000..f9e6985 --- /dev/null +++ b/java/src/jni/h5tImp.h @@ -0,0 +1,550 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5T */ + +#ifndef _Included_hdf_hdf5lib_H5_H5T +#define _Included_hdf_hdf5lib_H5_H5T + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Topen2 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Topen2 + (JNIEnv *, jclass, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tcommitted + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tcommitted + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tcreate + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcreate + (JNIEnv *, jclass, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tcopy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcopy + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tequal + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tequal + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tlock + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tlock + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_class + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1class + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1size + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1size + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1order + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1order + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_precision + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1precision + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_precision_long + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1precision_1long + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_precision + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1precision + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_offset + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1offset + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1offset + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_pad + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1pad + (JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_pad + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1pad + (JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_sign + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1sign + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_sign + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1sign + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_fields_int + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields_1int + (JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_fields + * Signature: (J[J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields + (JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_fields + * Signature: (JJJJJJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tset_1fields + (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_ebias + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1ebias + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_ebias_long + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_ebias + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1ebias + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_norm + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1norm + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_norm + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1norm + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_inpad + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1inpad + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_inpad + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1inpad + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_cset + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1cset + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_cset + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1cset + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_strpad + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1strpad + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_strpad + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1strpad + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_nmembers + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1nmembers + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_name + * Signature: (JI)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1name + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_index + * Signature: (JLjava/lang/String)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1index + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_type + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1member_1type + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_offset + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1offset + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_class + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1class + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tinsert + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tinsert + (JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tpack + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tpack + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tclose + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tclose + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tvlen_create + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tvlen_1create + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tset_tag + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1tag + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_tag + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1tag + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_super + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1super + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tenum_create + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tenum_1create + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_insert_int + * Signature: (JLjava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int + (JNIEnv *, jclass, jlong, jstring, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_insert + * Signature: (JLjava/lang/String;[B)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert + (JNIEnv *, jclass, jlong, jstring, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_nameof_int + * Signature: (J[I[Ljava/lang/String;I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int + (JNIEnv *, jclass, jlong, jintArray, jobjectArray, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_nameof + * Signature: (J[BJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1nameof + (JNIEnv *, jclass, jlong, jbyteArray, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_valueof_int + * Signature: (JLjava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int + (JNIEnv *, jclass, jlong, jstring, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tenum_valueof + * Signature: (JLjava/lang/String;[B)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof + (JNIEnv *, jclass, jlong, jstring, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_value_int + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int + (JNIEnv *, jclass, jlong, jint, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_member_value + * Signature: (JI[B)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value + (JNIEnv *, jclass, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_array_ndims + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_array_dims + * Signature: (J[I[I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims + (JNIEnv *, jclass, jlong, jintArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tis_variable_str + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tis_1variable_1str + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_native_type + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tdetect_class + * Signature: (JI)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tdetect_1class + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tcommit + * Signature: (JLjava/lang/String;JJJJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tcommit + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Tarray_create2 + * Signature: (JI[J)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tarray_1create2 + (JNIEnv *, jclass, jlong, jint, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tget_array_dims2 + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 + (JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Tconvert + * Signature: (JJJ[B[BJ)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tconvert + (JNIEnv *, jclass, jlong, jlong, jlong, jbyteArray, jbyteArray, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5T */ diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c new file mode 100644 index 0000000..90c8ad2 --- /dev/null +++ b/java/src/jni/h5util.c @@ -0,0 +1,2592 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include "hdf5.h" +#include "h5util.h" + +/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */ +hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */ +int H5TOOLS_TEXT_BLOCK = 16; /* Number of elements on a line in a text export file */ + +JavaVM *jvm; +jobject visit_callback; +jobject copy_callback; +jobject close_callback; +jobject create_callback; +jobject compare_callback; +jobject get_callback; +jobject set_callback; +jobject delete_callback; + +/********************/ +/* Local Prototypes */ +/********************/ + +static int h5str_dump_region_blocks(h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_dump_region_points(h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_is_zero(const void *_mem, size_t size); +static hid_t h5str_get_native_type(hid_t type); +static hid_t h5str_get_little_endian_type(hid_t type); +static hid_t h5str_get_big_endian_type(hid_t type); +static htri_t h5str_detect_vlen(hid_t tid); +static htri_t h5str_detect_vlen_str(hid_t tid); +static int h5tools_dump_simple_data(FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts); +static int h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts); +static int render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, + hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); +static int render_bin_output_region_blocks(FILE *stream, hid_t region_space, + hid_t region_id, hid_t container); +static int render_bin_output_region_data_points(FILE *stream, hid_t region_space, hid_t region_id, + hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata); +static int render_bin_output_region_points(FILE *stream, hid_t region_space, + hid_t region_id, hid_t container); + +/** frees memory held by array of strings */ +void +h5str_array_free(char **strs, size_t len) { + size_t i; + + if (!strs || len <= 0) + return; + + for (i = 0; i < len; i++) { + if (*(strs + i)) + HDfree(*(strs + i)); + } /* for (i=0; i<n; i++)*/ + HDfree(strs); +} /* end h5str_array_free */ + +/** allocate a new str with given length */ +void +h5str_new(h5str_t *str, size_t len) { + if (str && len > 0) { + str->s = (char *)HDmalloc(len); + str->max = len; + str->s[0] = '\0'; + } /* end if */ +} /* end h5str_new */ + +/** free string memory */ +void +h5str_free(h5str_t *str) { + if (str && str->max > 0) { + HDfree(str->s); + HDmemset(str, 0, sizeof(h5str_t)); + } /* end if */ +} /* end h5str_free */ + +/** reset the max size of the string */ +void +h5str_resize(h5str_t *str, size_t new_len) { + char *new_str; + + if (!str || new_len <= 0 || str->max == new_len) + return; + + new_str = (char *)HDmalloc(new_len); + if (new_len > str->max) /* increase memory */ + HDstrcpy(new_str, str->s); + else + HDstrncpy(new_str, str->s, new_len - 1); + + HDfree(str->s); + str->s = new_str; + str->max = new_len; +} /* end h5str_resize */ + +/* appends a copy of the string pointed to by cstr to the h5str. + Return Value: + the char string point to str->s + */ +char* +h5str_append(h5str_t *str, const char* cstr) { + size_t len; + + if (!str) + return NULL; + else if (!cstr) + return str->s; + + len = HDstrlen(str->s) + HDstrlen(cstr); + while (len >= str->max) /* not enough to hold the new string, double the space */ + { + h5str_resize(str, str->max * 2); + } + + return HDstrcat(str->s, cstr); +} /* end h5str_append */ + +/** print value of a data point into string. + Return Value: + On success, the total number of characters printed is returned. + On error, a negative number is returned. + */ +size_t +h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *ptr, int expand_data) { + unsigned char tmp_uchar = 0; + char tmp_char = 0; + unsigned short tmp_ushort = 0; + short tmp_short = 0; + unsigned int tmp_uint = 0; + int tmp_int = 0; + unsigned long tmp_ulong = 0; + long tmp_long = 0; + unsigned long long tmp_ullong = 0; + long long tmp_llong = 0; + float tmp_float = 0.0; + double tmp_double = 0.0; + long double tmp_ldouble = 0.0; + static char fmt_llong[8], fmt_ullong[8]; + + hid_t mtid = -1; + size_t offset; + size_t nll; + char *this_str; + size_t this_strlen; + int n; + int len; + hvl_t *vlptr; + char *cptr = (char*) ptr; + unsigned char *ucptr = (unsigned char*) ptr; + H5T_class_t tclass = H5Tget_class(tid); + size_t size = H5Tget_size(tid); + H5T_sign_t nsign = H5Tget_sign(tid); + int bdata_print = 0; + + if (!str || !ptr) + return 0; + + /* Build default formats for long long types */ + if (!fmt_llong[0]) { + sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); + } /* end if */ + + this_str = NULL; + this_strlen = 0; + + switch (tclass) { + case H5T_FLOAT: + if (sizeof(float) == size) { + /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */ + HDmemcpy(&tmp_float, ptr, sizeof(float)); + this_str = (char*)HDmalloc(25); + sprintf(this_str, "%g", tmp_float); + } + else if (sizeof(double) == size) { + /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */ + HDmemcpy(&tmp_double, ptr, sizeof(double)); + this_str = (char*)HDmalloc(25); + sprintf(this_str, "%g", tmp_double); + } +#if H5_SIZEOF_LONG_DOUBLE !=0 + else if (sizeof(long double) == size) { + /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */ + HDmemcpy(&tmp_ldouble, ptr, sizeof(long double)); + this_str = (char*)HDmalloc(27); + sprintf(this_str, "%Lf", tmp_ldouble); + } +#endif + break; + case H5T_STRING: + { + char *tmp_str; + size = 0; + + if (H5Tis_variable_str(tid)) { + tmp_str = *(char**) ptr; + if (tmp_str != NULL) + size = HDstrlen(tmp_str); + } + else { + tmp_str = cptr; + } + + /* Check for NULL pointer for string */ + if (tmp_str == NULL) { + this_str = (char *)HDmalloc(5); + HDstrncpy(this_str, "NULL", 4); + } + else { + if (size > 0) { + this_str = (char *)HDmalloc(size+1); + HDstrncpy(this_str, tmp_str, size); + } + } + } + break; + case H5T_INTEGER: + if (sizeof(char) == size) { + if(H5T_SGN_NONE == nsign) { + /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */ + HDmemcpy(&tmp_uchar, ptr, sizeof(unsigned char)); + this_str = (char*)HDmalloc(7); + sprintf(this_str, "%u", tmp_uchar); + } + else { + /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */ + HDmemcpy(&tmp_char, ptr, sizeof(char)); + this_str = (char*)HDmalloc(7); + sprintf(this_str, "%hhd", tmp_char); + } + } + else if (sizeof(int) == size) { + if(H5T_SGN_NONE == nsign) { + /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */ + HDmemcpy(&tmp_uint, ptr, sizeof(unsigned int)); + this_str = (char*)HDmalloc(14); + sprintf(this_str, "%u", tmp_uint); + } + else { + /* if (H5Tequal(tid, H5T_NATIVE_INT)) */ + HDmemcpy(&tmp_int, ptr, sizeof(int)); + this_str = (char*)HDmalloc(14); + sprintf(this_str, "%d", tmp_int); + } + } + else if (sizeof(short) == size) { + if(H5T_SGN_NONE == nsign) { + /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */ + HDmemcpy(&tmp_ushort, ptr, sizeof(unsigned short)); + this_str = (char*)HDmalloc(9); + sprintf(this_str, "%u", tmp_ushort); + } + else { + /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */ + HDmemcpy(&tmp_short, ptr, sizeof(short)); + this_str = (char*)HDmalloc(9); + sprintf(this_str, "%d", tmp_short); + } + } + else if (sizeof(long) == size) { + if(H5T_SGN_NONE == nsign) { + /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */ + HDmemcpy(&tmp_ulong, ptr, sizeof(unsigned long)); + this_str = (char*)HDmalloc(23); + sprintf(this_str, "%lu", tmp_ulong); + } + else { + /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */ + HDmemcpy(&tmp_long, ptr, sizeof(long)); + this_str = (char*)HDmalloc(23); + sprintf(this_str, "%ld", tmp_long); + } + } + else if (sizeof(long long) == size) { + if(H5T_SGN_NONE == nsign) { + /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */ + HDmemcpy(&tmp_ullong, ptr, sizeof(unsigned long long)); + this_str = (char*)HDmalloc(25); + sprintf(this_str, fmt_ullong, tmp_ullong); + } + else { + /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */ + HDmemcpy(&tmp_llong, ptr, sizeof(long long)); + this_str = (char*)HDmalloc(25); + sprintf(this_str, fmt_llong, tmp_llong); + } + } + break; + case H5T_COMPOUND: + { + unsigned i; + n = H5Tget_nmembers(tid); + h5str_append(str, " {"); + + for (i = 0; i < n; i++) { + offset = H5Tget_member_offset(tid, i); + mtid = H5Tget_member_type(tid, i); + h5str_sprintf(str, container, mtid, cptr + offset, expand_data); + if (i < n - 1) + h5str_append(str, ", "); + H5Tclose(mtid); + } + h5str_append(str, "} "); + } + break; + case H5T_ENUM: + { + char enum_name[1024]; + if (H5Tenum_nameof(tid, ptr, enum_name, sizeof enum_name) >= 0) { + h5str_append(str, enum_name); + } + else { + size_t i; + nll = H5Tget_size(tid); + this_str = (char*)HDmalloc(4 * (nll + 1)); + + if (1 == nll) { + sprintf(this_str, "0x%02x", ucptr[0]); + } + else { + for (i = 0; i < (int)nll; i++) + sprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]); + } + } + } + break; + case H5T_REFERENCE: + if (h5str_is_zero(ptr, size)) { + h5str_append(str, "NULL"); + } + else { + if (H5R_DSET_REG_REF_BUF_SIZE == size) { + /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */ + /* + * Dataset region reference -- + * show the type and the referenced object + */ + char ref_name[1024]; + hid_t region_obj; + hid_t region; + H5S_sel_type region_type; + + /* get name of the dataset the region reference points to using H5Rget_name */ + region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, ptr); + if (region_obj >= 0) { + region = H5Rget_region(container, H5R_DATASET_REGION, ptr); + if (region >= 0) { + if(expand_data) { + region_type = H5Sget_select_type(region); + if(region_type==H5S_SEL_POINTS) { + h5str_dump_region_points_data(str, region, region_obj); + } + else { + h5str_dump_region_blocks_data(str, region, region_obj); + } + } + else { + if(H5Rget_name(region_obj, H5R_DATASET_REGION, ptr, (char*)ref_name, 1024) >= 0) { + h5str_append(str, ref_name); + } + + region_type = H5Sget_select_type(region); + + if(region_type==H5S_SEL_POINTS) { + h5str_append(str, " REGION_TYPE POINT"); + h5str_dump_region_points(str, region, region_obj); + } + else { + h5str_append(str, " REGION_TYPE BLOCK"); + h5str_dump_region_blocks(str, region, region_obj); + } + } + + H5Sclose(region); + } + H5Dclose(region_obj); + } + } + else if (H5R_OBJ_REF_BUF_SIZE == size) { + /* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */ + /* + * Object references -- show the type and OID of the referenced + * object. + */ + H5O_info_t oi; + hid_t obj; + + this_str = (char*)HDmalloc(64); + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, ptr); + H5Oget_info(obj, &oi); + + /* Print object data and close object */ + sprintf(this_str, "%u-%lu", (unsigned) oi.type, oi.addr); + H5Oclose(obj); + } + } + break; + case H5T_ARRAY: + { + int rank = 0; + hsize_t i, dims[H5S_MAX_RANK], total_elmts; + h5str_append(str, "[ "); + + mtid = H5Tget_super(tid); + size = H5Tget_size(mtid); + rank = H5Tget_array_ndims(tid); + + H5Tget_array_dims2(tid, dims); + + total_elmts = 1; + for (i = 0; i < rank; i++) + total_elmts *= dims[i]; + + for (i = 0; i < total_elmts; i++) { + h5str_sprintf(str, container, mtid, cptr + i * size, expand_data); + if (i < total_elmts - 1) + h5str_append(str, ", "); + } + H5Tclose(mtid); + h5str_append(str, "] "); + } + break; + case H5T_VLEN: + { + unsigned int i; + mtid = H5Tget_super(tid); + size = H5Tget_size(mtid); + + vlptr = (hvl_t *) cptr; + + nll = vlptr->len; + for (i = 0; i < (int)nll; i++) { + h5str_sprintf(str, container, mtid, ((char *) (vlptr->p)) + i * size, expand_data); + if (i < (int)nll - 1) + h5str_append(str, ", "); + } + H5Tclose(mtid); + } + break; + + default: + { + /* All other types get printed as hexadecimal */ + size_t i; + nll = H5Tget_size(tid); + this_str = (char*)HDmalloc(4 * (nll + 1)); + + if (1 == nll) { + sprintf(this_str, "0x%02x", ucptr[0]); + } + else { + for (i = 0; i < (int)nll; i++) + sprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]); + } + } + break; + } /* end switch */ + + if (this_str) { + h5str_append(str, this_str); + this_strlen = HDstrlen(str->s); + HDfree(this_str); + } /* end if */ + + return this_strlen; +} /* end h5str_sprintf */ + +/*------------------------------------------------------------------------- + * Purpose: Print the data values from a dataset referenced by region blocks. + * + * Description: + * This is a special case subfunction to print the data in a region reference of type blocks. + * + * Return: + * The function returns FAIL if there was an error, otherwise SUCEED + *------------------------------------------------------------------------- + */ +static int +h5str_print_region_data_blocks(hid_t region_id, + h5str_t *str, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) +{ + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t blkndx; + hsize_t total_size[H5S_MAX_RANK]; + unsigned int region_flags; /* buffer extent flags */ + hsize_t numelem; + hsize_t numindex; + size_t jndx; + unsigned indx; + size_t type_size; + int ret_value = SUCCEED; + hid_t mem_space = -1; + hid_t sid1 = -1; + void *region_buf = NULL; + + /* Get the dataspace of the dataset */ + if((sid1 = H5Dget_space(region_id)) >= 0) { + + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + + /* find the dimensions of each data space from the block coordinates */ + numelem = 1; + for (jndx = 0; jndx < ndims; jndx++) { + dims1[jndx] = ptdata[jndx + (size_t)ndims] - ptdata[jndx] + 1; + numelem = dims1[jndx] * numelem; + } /* end for */ + + /* Create dataspace for reading buffer */ + if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) { + if((type_size = H5Tget_size(type_id)) > 0) { + if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) { + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + if((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + if((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + for (blkndx = 0; blkndx < nblocks; blkndx++) { + for (indx = 0; indx < ndims; indx++) { + start[indx] = ptdata[indx + blkndx * (hsize_t)ndims * 2]; + count[indx] = dims1[indx]; + } /* end for */ + + if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { + if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { + if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + for (numindex = 0; numindex < numelem; numindex++) { + h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 1); + + if (numindex + 1 < numelem) + h5str_append(str, ", "); + } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ + } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ + } /* end if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) */ + } /* end if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) */ + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + + HDfree(count); + } /* end if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + + HDfree(start); + } /* end if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + + HDfree(region_buf); + } /* end if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) */ + else + ret_value = -1; + } /* end if((type_size = H5Tget_size(type_id)) > 0) */ + else + ret_value = -1; + + if(H5Sclose(mem_space) < 0) + ret_value = -1; + } /* end if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) */ + else + ret_value = -1; + + HDfree(dims1); + } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + + if(H5Sclose(sid1) < 0) + ret_value = -1; + } /* end if((sid1 = H5Dget_space(region_id)) >= 0) */ + else + ret_value = -1; + + return ret_value; +} /* end h5str_print_region_data_blocks */ + +int +h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_id) +{ + int ret_value = 0; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata; + hid_t dtype = -1; + hid_t type_id = -1; + char tmp_str[256]; + int ndims = H5Sget_simple_extent_ndims(region); + + /* + * This function fails if the region does not have blocks. + */ + H5E_BEGIN_TRY { + nblocks = H5Sget_select_hyper_nblocks(region); + } H5E_END_TRY; + + /* Print block information */ + if (nblocks > 0) { + int i; + + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { + ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + H5Sget_select_hyper_blocklist(region, (hsize_t) 0, + (hsize_t) nblocks, ptdata); + + + if((dtype = H5Dget_type(region_id)) >= 0) { + if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + + h5str_print_region_data_blocks(region_id, str, ndims, type_id, nblocks, ptdata); + + if(H5Tclose(type_id) < 0) + ret_value = -1; + } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ + else + ret_value = -1; + + if(H5Tclose(dtype) < 0) + ret_value = -1; + } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ + else + ret_value = -1; + HDfree(ptdata); + } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ + } /* if (nblocks > 0) */ + + return ret_value; +} /* end h5str_dump_region_blocks_data */ + +static int +h5str_dump_region_blocks(h5str_t *str, hid_t region, hid_t region_id) +{ + int ret_value = 0; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata; + hid_t dtype = -1; + hid_t type_id = -1; + char tmp_str[256]; + int ndims = H5Sget_simple_extent_ndims(region); + + /* + * This function fails if the region does not have blocks. + */ + H5E_BEGIN_TRY { + nblocks = H5Sget_select_hyper_nblocks(region); + } H5E_END_TRY; + + /* Print block information */ + if (nblocks > 0) { + int i; + + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { + ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + H5Sget_select_hyper_blocklist(region, (hsize_t) 0, + (hsize_t) nblocks, ptdata); + + h5str_append(str, " {"); + for (i = 0; i < nblocks; i++) { + int j; + + h5str_append(str, " "); + + /* Start coordinates and opposite corner */ + for (j = 0; j < ndims; j++) { + tmp_str[0] = '\0'; + sprintf(tmp_str, "%s%lu", j ? "," : "(", + (unsigned long) ptdata[i * 2 * ndims + j]); + h5str_append(str, tmp_str); + } + + for (j = 0; j < ndims; j++) { + tmp_str[0] = '\0'; + sprintf(tmp_str, "%s%lu", j ? "," : ")-(", + (unsigned long) ptdata[i * 2 * ndims + j + ndims]); + h5str_append(str, tmp_str); + } + h5str_append(str, ") "); + tmp_str[0] = '\0'; + } + h5str_append(str, " }"); + + HDfree(ptdata); + } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ + } /* if (nblocks > 0) */ + + return ret_value; +} /* end h5str_dump_region_blocks */ + +/*------------------------------------------------------------------------- + * Purpose: Print the data values from a dataset referenced by region points. + * + * Description: + * This is a special case subfunction to print the data in a region reference of type points. + * + * Return: + * The function returns FAIL on error, otherwise SUCCEED + *------------------------------------------------------------------------- + */ +static int +h5str_print_region_data_points(hid_t region_space, hid_t region_id, + h5str_t *str, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) +{ + hsize_t *dims1 = NULL; + hsize_t total_size[H5S_MAX_RANK]; + size_t jndx; + unsigned indx; + size_t type_size; + int ret_value = SUCCEED; + unsigned int region_flags; /* buffer extent flags */ + hid_t mem_space = -1; + void *region_buf = NULL; + char tmp_str[256]; + + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + + dims1[0] = (hsize_t)npoints; + + /* Create dataspace for reading buffer */ + if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) { + + if((type_size = H5Tget_size(type_id)) > 0) { + + if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) { + + if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) { + + for (jndx = 0; jndx < npoints; jndx++) { + if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + + h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 1); + + if (jndx + 1 < npoints) + h5str_append(str, ", "); + + } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ + } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ + } /* end if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) */ + else + ret_value = -1; + + HDfree(region_buf); + } /* end if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) */ + else + ret_value = -1; + } /* end if((type_size = H5Tget_size(type_id)) > 0) */ + else + ret_value = -1; + + if(H5Sclose(mem_space) < 0) + ret_value = -1; + } /* end if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) */ + else + ret_value = -1; + HDfree(dims1); + } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + + return ret_value; +} /* end h5str_print_region_data_points */ + +int +h5str_dump_region_points_data(h5str_t *str, hid_t region, hid_t region_id) +{ + int ret_value = 0; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata; + char tmp_str[256]; + hid_t dtype = -1; + hid_t type_id = -1; + int ndims = H5Sget_simple_extent_ndims(region); + + /* + * This function fails if the region does not have points. + */ + H5E_BEGIN_TRY { + npoints = H5Sget_select_elem_npoints(region); + } H5E_END_TRY; + + /* Print point information */ + if (npoints > 0) { + int i; + + alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { + ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + H5Sget_select_elem_pointlist(region, (hsize_t) 0, + (hsize_t) npoints, ptdata); + + if((dtype = H5Dget_type(region_id)) >= 0) { + if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + + h5str_print_region_data_points(region, region_id, + str, ndims, type_id, npoints, ptdata); + + if(H5Tclose(type_id) < 0) + ret_value = -1; + } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ + else + ret_value = -1; + + if(H5Tclose(dtype) < 0) + ret_value = -1; + } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ + else + ret_value = -1; + HDfree(ptdata); + } + } + + return ret_value; +} /* end h5str_dump_region_points_data */ + +static int +h5str_dump_region_points(h5str_t *str, hid_t region, hid_t region_id) +{ + int ret_value = 0; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata; + char tmp_str[256]; + hid_t dtype = -1; + hid_t type_id = -1; + int ndims = H5Sget_simple_extent_ndims(region); + + /* + * This function fails if the region does not have points. + */ + H5E_BEGIN_TRY { + npoints = H5Sget_select_elem_npoints(region); + } H5E_END_TRY; + + /* Print point information */ + if (npoints > 0) { + int i; + + alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { + ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + H5Sget_select_elem_pointlist(region, (hsize_t) 0, + (hsize_t) npoints, ptdata); + + h5str_append(str, " {"); + for (i = 0; i < npoints; i++) { + int j; + + h5str_append(str, " "); + + for (j = 0; j < ndims; j++) { + tmp_str[0] = '\0'; + sprintf(tmp_str, "%s%lu", j ? "," : "(", + (unsigned long) (ptdata[i * ndims + j])); + h5str_append(str, tmp_str); + } /* end for (j = 0; j < ndims; j++) */ + + h5str_append(str, ") "); + } /* end for (i = 0; i < npoints; i++) */ + h5str_append(str, " }"); + + HDfree(ptdata); + } /* end if (alloc_size == (hsize_t)((size_t) alloc_size)) */ + } /* end if (npoints > 0) */ + + return ret_value; +} /* end h5str_dump_region_points */ + +static int +h5str_is_zero(const void *_mem, size_t size) { + const unsigned char *mem = (const unsigned char *) _mem; + + while (size-- > 0) + if (mem[size]) + return 0; + + return 1; +} /* end h5str_is_zero */ + +/*------------------------------------------------------------------------- + * Function: h5str_detect_vlen_str + * + * Purpose: Recursive check for variable length string of a datatype. + * + * Return: + * TRUE : type conatains any variable length string + * FALSE : type doesn't contain any variable length string + * Negative value: error occur + * + *------------------------------------------------------------------------- + */ +static htri_t +h5str_detect_vlen_str(hid_t tid) +{ + H5T_class_t tclass = H5T_NO_CLASS; + htri_t ret = 0; + + ret = H5Tis_variable_str(tid); + if((ret == 1) || (ret < 0)) + goto done; + + tclass = H5Tget_class(tid); + if(tclass == H5T_ARRAY || tclass == H5T_VLEN) { + hid_t btid = H5Tget_super(tid); + + if(btid < 0) { + ret = (htri_t)btid; + goto done; + } /* end if */ + ret = h5str_detect_vlen_str(btid); + if((ret == 1) || (ret < 0)) { + H5Tclose(btid); + goto done; + } /* end if */ + } /* end if */ + else if(tclass == H5T_COMPOUND) { + unsigned i = 0; + int n = H5Tget_nmembers(tid); + + if(n < 0) { + n = ret; + goto done; + } /* end if */ + + for(i = 0; i < n; i++) { + hid_t mtid = H5Tget_member_type(tid, i); + + ret = h5str_detect_vlen_str(mtid); + if((ret == 1) || (ret < 0)) { + H5Tclose(mtid); + goto done; + } + H5Tclose(mtid); + } /* end for */ + } /* end else */ + +done: + return ret; +} /* end h5str_detect_vlen_str */ + +/*------------------------------------------------------------------------- + * Function: h5str_get_native_type + * + * Purpose: Wrapper around H5Tget_native_type() to work around + * Problems with bitfields. + * + * Return: Success: datatype ID + * Failure: FAIL + *------------------------------------------------------------------------- + */ +static hid_t +h5str_get_native_type(hid_t type) +{ + hid_t p_type; + H5T_class_t type_class; + + type_class = H5Tget_class(type); + if(type_class==H5T_BITFIELD) + p_type=H5Tcopy(type); + else + p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT); + + return(p_type); +} /* end h5str_get_native_type */ + + +/*------------------------------------------------------------------------- + * Function: h5str_get_little_endian_type + * + * Purpose: Get a little endian type from a file type + * + * Return: Success: datatype ID + * Failure: FAIL + *------------------------------------------------------------------------- + */ +static hid_t +h5str_get_little_endian_type(hid_t tid) +{ + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8LE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16LE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32LE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64LE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8LE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16LE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32LE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64LE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32LE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64LE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + return(p_type); +} /* end h5str_get_little_endian_type */ + +/*------------------------------------------------------------------------- + * Function: h5str_get_big_endian_type + * + * Purpose: Get a big endian type from a file type + * + * Return: Success: datatype ID + * Failure: FAIL + *------------------------------------------------------------------------- + */ +static hid_t +h5str_get_big_endian_type(hid_t tid) +{ + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8BE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16BE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32BE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64BE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8BE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16BE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32BE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64BE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32BE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64BE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + return(p_type); +} /* end h5str_get_big_endian_type */ + +/*------------------------------------------------------------------------- + * Function: h5str_detect_vlen + * + * Purpose: Recursive check for any variable length data in given type. + * + * Return: + * 1 : type conatains any variable length data + * 0 : type doesn't contain any variable length data + * Negative value: error occur + *------------------------------------------------------------------------- + */ +static htri_t +h5str_detect_vlen(hid_t tid) +{ + htri_t ret; + + /* recursive detect any vlen data values in type (compound, array ...) */ + ret = H5Tdetect_class(tid, H5T_VLEN); + if((ret == 1) || (ret < 0)) + goto done; + + /* recursive detect any vlen string in type (compound, array ...) */ + ret = h5str_detect_vlen_str(tid); + if((ret == 1) || (ret < 0)) + goto done; + +done: + return ret; +} /* end h5str_detect_vlen */ + +/*------------------------------------------------------------------------- + * Function: render_bin_output + * + * Purpose: Write one element of memory buffer to a binary file stream + * + * Return: Success: SUCCEED + * Failure: FAIL + *------------------------------------------------------------------------- + */ +static int +h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) +{ + int ret_value = 0; + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t block_index; + H5T_class_t type_class; + + if((size = H5Tget_size(tid)) > 0) { + + if((type_class = H5Tget_class(tid)) >= 0) { + + switch (type_class) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_ENUM: + block_index = block_nelmts * size; + while(block_index > 0) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + size_t item_size = size; /* size of items in bytes */ + + if(block_index > sizeof(size_t)) + bytes_in = sizeof(size_t); + else + bytes_in = (size_t)block_index; + + bytes_wrote = fwrite(mem, 1, bytes_in, stream); + + if(bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(stream))) { + ret_value = -1; + break; + } + + block_index -= (hsize_t)bytes_wrote; + mem = mem + bytes_wrote; + } + break; + case H5T_STRING: + { + unsigned int i; + H5T_str_t pad; + char *s; + unsigned char tempuchar; + + pad = H5Tget_strpad(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + + if (H5Tis_variable_str(tid)) { + s = *(char**) mem; + if (s != NULL) + size = strlen(s); + } + else { + s = (char *) mem; + } + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); + if (1 != fwrite(&tempuchar, sizeof(unsigned char), 1, stream)) { + ret_value = -1; + break; + } + } /* i */ + if(ret_value < 0) + break; + } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ + } + break; + case H5T_COMPOUND: + { + unsigned j; + hid_t memb; + unsigned nmembs; + size_t offset; + + nmembs = (unsigned)H5Tget_nmembers(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + for (j = 0; j < nmembs; j++) { + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (h5str_render_bin_output(stream, container, memb, mem + offset, 1) < 0) { + H5Tclose(memb); + ret_value = -1; + break; + } + + H5Tclose(memb); + } + if(ret_value < 0) + break; + } + } + break; + case H5T_ARRAY: + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb; + + /* get the array's base datatype for each element */ + memb = H5Tget_super(tid); + ndims = H5Tget_array_ndims(tid); + H5Tget_array_dims2(tid, dims); + + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + /* dump the array element */ + if (h5str_render_bin_output(stream, container, memb, mem, nelmts) < 0) { + ret_value = -1; + break; + } + } + H5Tclose(memb); + } + break; + case H5T_VLEN: + { + unsigned int i; + hsize_t nelmts; + hid_t memb; + + /* get the VL sequences's base datatype for each element */ + memb = H5Tget_super(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) mem)->len; + + /* dump the array element */ + if (h5str_render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) { + ret_value = -1; + break; + } + } + H5Tclose(memb); + } + break; + case H5T_REFERENCE: + { + if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { + /* region data */ + hid_t region_id, region_space; + H5S_sel_type region_type; + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem); + if (region_id >= 0) { + region_space = H5Rget_region(container, H5R_DATASET_REGION, mem); + if (region_space >= 0) { + region_type = H5Sget_select_type(region_space); + if(region_type == H5S_SEL_POINTS) + ret_value = render_bin_output_region_points(stream, region_space, region_id, container); + else + ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container); + H5Sclose(region_space); + } /* end if (region_space >= 0) */ + H5Dclose(region_id); + } /* end if (region_id >= 0) */ + if(ret_value < 0) + break; + } + } + else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { + ; + } + } + break; + default: + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + if (size != fwrite(mem, sizeof(char), size, stream)) { + ret_value = -1; + break; + } + } + break; + } + } /* end if((type_class = H5Tget_class(tid)) >= 0) */ + else + ret_value = -1; + } /* end if((size = H5Tget_size(tid)) > 0) */ + else + ret_value = -1; + + return ret_value; +} /* end h5str_render_bin_output */ + +/*------------------------------------------------------------------------- + * Purpose: Print the data values from a dataset referenced by region blocks. + * + * Description: + * This is a special case subfunction to print the data in a region reference of type blocks. + * + * Return: + * The function returns FAIL if there was an error, otherwise SUCEED + * + *------------------------------------------------------------------------- + */ +static int +render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, + hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) +{ + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t numelem; + hsize_t numindex; + hsize_t total_size[H5S_MAX_RANK]; + int jndx; + size_t type_size; + hid_t mem_space = -1; + void *region_buf = NULL; + int blkndx; + hid_t sid1 = -1; + int ret_value = SUCCEED; + + /* Get the dataspace of the dataset */ + if((sid1 = H5Dget_space(region_id)) >= 0) { + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + /* find the dimensions of each data space from the block coordinates */ + numelem = 1; + for (jndx = 0; jndx < ndims; jndx++) { + dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; + numelem = dims1[jndx] * numelem; + } + + /* Create dataspace for reading buffer */ + if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) { + if((type_size = H5Tget_size(type_id)) > 0) { + if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) { + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + if((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + if((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + for (blkndx = 0; blkndx < nblocks; blkndx++) { + for (jndx = 0; jndx < ndims; jndx++) { + start[jndx] = ptdata[jndx + blkndx * ndims * 2]; + count[jndx] = dims1[jndx]; + } + + if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { + if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { + if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + ret_value = h5str_render_bin_output(stream, container, type_id, (char*)region_buf, numelem); + } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ + else { + ret_value = -1; + break; + } + } /* end if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) */ + else { + ret_value = -1; + break; + } + } /* end if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) */ + else { + ret_value = -1; + break; + } + /* Render the region data element end */ + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + + HDfree(count); + } /* end if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + HDfree(start); + } /* end if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + HDfree(region_buf); + } /* end if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) */ + else + ret_value = -1; + } /* end if((type_size = H5Tget_size(type_id)) > 0) */ + else + ret_value = -1; + + if(H5Sclose(mem_space) < 0) + ret_value = -1; + } /* end if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) */ + else + ret_value = -1; + HDfree(dims1); + } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + if(H5Sclose(sid1) < 0) + ret_value = -1; + } /* end if((sid1 = H5Dget_space(region_id)) >= 0) */ + else + ret_value = -1; + + return ret_value; +} /* end render_bin_output_region_data_blocks */ + +/*------------------------------------------------------------------------- + * Purpose: Print some values from a dataset referenced by region blocks. + * + * Description: + * This is a special case subfunction to dump a region reference using blocks. + * + * Return: + * The function returns False if ERROR, otherwise True + * + *------------------------------------------------------------------------- + */ +static int +render_bin_output_region_blocks(FILE *stream, hid_t region_space, hid_t region_id, hid_t container) +{ + int ret_value = SUCCEED; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + int ndims; + hid_t dtype; + hid_t type_id; + + if((nblocks = H5Sget_select_hyper_nblocks(region_space)) > 0) { + /* Print block information */ + if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) { + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + if((ptdata = (hsize_t*)HDmalloc((size_t)alloc_size)) != NULL) { + if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, (hsize_t)nblocks, ptdata) >= 0) { + if((dtype = H5Dget_type(region_id)) >= 0) { + if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + ret_value = render_bin_output_region_data_blocks(stream, region_id, container, ndims, + type_id, nblocks, ptdata); + + if(H5Tclose(type_id) < 0) + ret_value = -1; + } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ + else + ret_value = -1; + + if(H5Tclose(dtype) < 0) + ret_value = -1; + } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ + else + ret_value = -1; + } /* end if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) >= 0) */ + else + ret_value = -1; + + HDfree(ptdata); + } /* end if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) != NULL) */ + else + ret_value = -1; + } /* end if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) */ + else + ret_value = -1; + } /* end if((nblocks = H5Sget_select_hyper_nblocks(region_space)) > 0) */ + else + ret_value = -1; + + return ret_value; +} /* end render_bin_output_region_blocks */ + +/*------------------------------------------------------------------------- + * Purpose: Print the data values from a dataset referenced by region points. + * + * Description: + * This is a special case subfunction to print the data in a region reference of type points. + * + * Return: + * The function returns FAIL on error, otherwise SUCCEED + * + *------------------------------------------------------------------------- + */ +static int +render_bin_output_region_data_points(FILE *stream, hid_t region_space, hid_t region_id, + hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) +{ + hsize_t *dims1 = NULL; + int jndx; + size_t type_size; + hid_t mem_space = -1; + void *region_buf = NULL; + int ret_value = SUCCEED; + + if((type_size = H5Tget_size(type_id)) > 0) { + if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) { + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + dims1[0] = (hsize_t)npoints; + if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) { + if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) { + if(H5Sget_simple_extent_dims(region_space, dims1, NULL) >= 0) { + ret_value = h5str_render_bin_output(stream, container, type_id, (char*)region_buf, (hsize_t)npoints); + } /* end if(H5Sget_simple_extent_dims(region_space, dims1, NULL) >= 0) */ + else + ret_value = -1; + } /* end if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) */ + else + ret_value = -1; + } /* end if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) */ + else + ret_value = -1; + + HDfree(dims1); + } /* end if((dims1 = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) != NULL) */ + else + ret_value = -1; + HDfree(region_buf); + } /* end if((region_buf = malloc(type_size * (size_t)npoints)) != NULL) */ + else + ret_value = -1; + + if(H5Sclose(mem_space) < 0) + ret_value = -1; + } /* end if((type_size = H5Tget_size(type_id)) > 0) */ + else + ret_value = -1; + + return ret_value; +} /* end render_bin_output_region_data_points */ + +/*------------------------------------------------------------------------- + * Purpose: Print some values from a dataset referenced by region points. + * + * Description: + * This is a special case subfunction to dump a region reference using points. + * + * Return: + * The function returns False if the last dimension has been reached, otherwise True + * + *------------------------------------------------------------------------- + */ +static int +render_bin_output_region_points(FILE *stream, hid_t region_space, hid_t region_id, hid_t container) +{ + int ret_value = SUCCEED; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata; + int ndims; + hid_t dtype; + hid_t type_id; + + if((npoints = H5Sget_select_elem_npoints(region_space)) > 0) { + /* Allocate space for the dimension array */ + if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) { + alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); + if(NULL != (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) { + if(H5Sget_select_elem_pointlist(region_space, (hsize_t)0, (hsize_t)npoints, ptdata) >= 0) { + if((dtype = H5Dget_type(region_id)) >= 0) { + if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + ret_value = render_bin_output_region_data_points(stream, region_space, region_id, + container, ndims, type_id, npoints, ptdata); + + if(H5Tclose(type_id) < 0) + ret_value = -1; + } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ + else + ret_value = -1; + + if(H5Tclose(dtype) < 0) + ret_value = -1; + } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ + else + ret_value = -1; + } /* end if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) >= 0) */ + else + ret_value = -1; + + HDfree(ptdata); + } /* end if(NULL != (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size))) */ + else + ret_value = -1; + } /* end if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) */ + else + ret_value = -1; + + } /* end if((npoints = H5Sget_select_elem_npoints(region_space)) > 0) */ + else + ret_value = -1; + + return ret_value; +} /* end render_bin_output_region_points */ + +int +h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order) +{ + int ret_value = SUCCEED; + hid_t f_space = -1; /* file data space */ + hsize_t elmtno; /* counter */ + size_t i; /* counter */ + int ndims; + int carry; /* counter carry value */ + hsize_t zero[8]; /* vector of zeros */ + unsigned int flags; /* buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + + /* Print info */ + size_t p_type_nbytes; /* size of memory type */ + hsize_t p_nelmts; /* total selected elmts */ + + /* Stripmine info */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space = -1; /* stripmine data space */ + + /* Hyperslab info */ + hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts; /* elements in request */ + + /* VL data special information */ + unsigned int vl_data = 0; /* contains VL datatypes */ + hid_t p_type = -1; + hid_t f_type = -1; + + if(dset < 0) return -1; + f_type = H5Dget_type(dset); + if (binary_order == 1) + p_type = h5str_get_native_type(f_type); + else if (binary_order == 2) + p_type = h5str_get_little_endian_type(f_type); + else if (binary_order == 3) + p_type = h5str_get_big_endian_type(f_type); + else + p_type = H5Tcopy(f_type); + + H5Tclose(f_type); + + if (p_type >= 0) { + if((f_space = H5Dget_space(dset)) >= 0) { + ndims = H5Sget_simple_extent_ndims(f_space); + + if ((size_t)ndims <= (sizeof(sm_size)/sizeof(sm_size[0]))) { + H5Sget_simple_extent_dims(f_space, total_size, NULL); + + /* calculate the number of elements we're going to print */ + p_nelmts = 1; + + if (ndims > 0) { + for (i = 0; i < ndims; i++) + p_nelmts *= total_size[i]; + } /* end if */ + + if (p_nelmts > 0) { + /* Check if we have VL data in the dataset's datatype */ + if (h5str_detect_vlen(p_type) != 0) + vl_data = 1; + + /* + * Determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ + sm_nbytes = p_type_nbytes = H5Tget_size(p_type); + + if (ndims > 0) { + for (i = (size_t)ndims; i > 0; --i) { + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size)); + sm_nbytes *= sm_size[i - 1]; + } + } + + if(sm_nbytes > 0) { + sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes); + + sm_nelmts = sm_nbytes / p_type_nbytes; + sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + + /* The stripmine loop */ + HDmemset(hs_offset, 0, sizeof hs_offset); + HDmemset(zero, 0, sizeof zero); + + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { + /* Calculate the hyperslab size */ + if (ndims > 0) { + for (i = 0, hs_nelmts = 1; i < ndims; i++) { + hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i])) ? (total_size[i] - hs_offset[i]) : (sm_size[i])); + hs_nelmts *= hs_size[i]; + } + + H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); + H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL); + } + else { + H5Sselect_all(f_space); + H5Sselect_all(sm_space); + hs_nelmts = 1; + } + + /* Read the data */ + if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) >= 0) { + + if (binary_order == 99) + ret_value = h5tools_dump_simple_data(stream, dset, p_type, sm_buf, hs_nelmts); + else + ret_value = h5str_render_bin_output(stream, dset, p_type, sm_buf, hs_nelmts); + + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf); + } + else { + ret_value = -1; + break; + } + + if(ret_value < 0) break; + + /* Calculate the next hyperslab offset */ + for (i = (size_t)ndims, carry = 1; i > 0 && carry; --i) { + hs_offset[i - 1] += hs_size[i - 1]; + + if (hs_offset[i - 1] == total_size[i - 1]) + hs_offset[i - 1] = 0; + else + carry = 0; + } + } + + if(sm_buf) + HDfree(sm_buf); + } + if(sm_space >= 0 && H5Sclose(sm_space) < 0) + ret_value = -1; + } + } + if(f_space >= 0 && H5Sclose(f_space) < 0) + ret_value = -1; + } /* end if((f_space = H5Dget_space(dset)) >= 0) */ + else + ret_value = -1; + + if (p_type >= 0) + H5Tclose(p_type); + } + return ret_value; +} /* end h5str_dump_simple_dset */ + +static int +h5tools_dump_simple_data(FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts) +{ + int ret_value = 0; + int line_count; + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + H5T_class_t type_class; + hsize_t i; /*element counter */ + h5str_t buffer; /*string into which to render */ + + if((size = H5Tget_size(type)) > 0) { + for (i = 0, line_count = 0; i < nelmts; i++, line_count++) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + void* memref = mem + i * size; + + /* Render the data element*/ + h5str_new(&buffer, 32 * size); + bytes_in = h5str_sprintf(&buffer, container, type, memref, 1); + if(i > 0) { + HDfprintf(stream, ", "); + if (line_count >= H5TOOLS_TEXT_BLOCK) { + line_count = 0; + HDfprintf(stream, "\n"); + } + } + HDfprintf(stream, "%s", buffer.s); + h5str_free(&buffer); + } /* end for (i = 0; i < nelmts... */ + HDfprintf(stream, "\n"); + } /* end if((size = H5Tget_size(tid)) > 0) */ + else + ret_value = -1; + + return ret_value; +} /* end h5tools_dump_simple_data */ + +/* + * Utility Java APIs + * Functions designed to workaround issues with the Java-C interface + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AwriteVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +{ + herr_t status = -1; + char **wdata; + jsize size; + jint i; + + size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + + wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); + if (!wdata) { + h5JNIFatalError(env, "H5AwriteVL: cannot allocate buffer"); + } /* end if */ + else { + HDmemset(wdata, 0, (size_t)size * sizeof(char*)); + for (i = 0; i < size; ++i) { + jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + wdata[i] = (char*)HDmalloc((size_t)length + 1); + if (wdata[i]) { + HDmemset(wdata[i], 0, ((size_t)length + 1)); + HDstrncpy(wdata[i], utf8, (size_t)length); + } /* end if */ + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for (i = 0; i < size; ++i) */ + + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, wdata); + + for (i = 0; i < size; i++) { + if(wdata[i]) { + HDfree(wdata[i]); + } /* end if */ + } /* end for */ + HDfree(wdata); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5AwriteVL */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +{ + herr_t status = -1; + jstring jstr; + char **strs; + int i, n; + hid_t sid; + hsize_t dims[H5S_MAX_RANK]; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + + strs =(char **)HDmalloc((size_t)n * sizeof(char *)); + if (strs == NULL) { + h5JNIFatalError( env, "H5AreadVL: failed to allocate buff for read variable length strings"); + } /* end if */ + else { + status = H5Aread(attr_id, mem_type_id, strs); + if (status < 0) { + dims[0] = (hsize_t)n; + sid = H5Screate_simple(1, dims, NULL); + H5Dvlen_reclaim(mem_type_id, sid, H5P_DEFAULT, strs); + H5Sclose(sid); + HDfree(strs); + h5JNIFatalError(env, "H5AreadVL: failed to read variable length strings"); + } /* end if */ + else { + for (i=0; i<n; i++) { + jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + HDfree (strs[i]); + } /* end for */ + + /* + for repeatedly reading an attribute with a large number of strs (e.g., 1,000,000 strings, + H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + free space in time. Instead, use "free(strs[i])" to free individual strings + after it is done. + H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); + */ + + HDfree(strs); + } /* end else */ + } /* end else */ + return status; +} /* end Java_hdf_hdf5lib_H5_H5AreadVL */ + +/* + * Copies the content of one dataset to another dataset + * Class: hdf_hdf5lib_H5 + * Method: H5Acopy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Acopy(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) +{ + jbyte *buf; + herr_t retVal = -1; + hid_t src_did = (hid_t)src_id; + hid_t dst_did = (hid_t)dst_id; + hid_t tid = -1; + hid_t sid = -1; + hsize_t total_size = 0; + + + sid = H5Aget_space(src_did); + if (sid < 0) { + h5libraryError(env); + } /* end if */ + else { + tid = H5Aget_type(src_did); + if (tid < 0) { + H5Sclose(sid); + h5libraryError(env); + } /* end if */ + else { + total_size = (hsize_t)H5Sget_simple_extent_npoints(sid) * (hsize_t)H5Tget_size(tid); + + H5Sclose(sid); + + buf = (jbyte *)HDmalloc( (size_t)total_size * sizeof(jbyte)); + if (buf == NULL) { + H5Tclose(tid); + h5outOfMemory( env, "H5Acopy: malloc failed"); + } /* end if */ + else { + retVal = H5Aread(src_did, tid, buf); + H5Tclose(tid); + + if (retVal < 0) { + HDfree(buf); + h5libraryError(env); + } /* end if */ + else { + tid = H5Aget_type(dst_did); + if (tid < 0) { + HDfree(buf); + h5libraryError(env); + } /* end if */ + else { + retVal = H5Awrite(dst_did, tid, buf); + + H5Tclose(tid); + HDfree(buf); + + if (retVal < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Acopy */ + +/* + * Copies the content of one dataset to another dataset + * Class: hdf_hdf5lib_H5 + * Method: H5Dcopy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Dcopy(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) +{ + jbyte *buf; + herr_t retVal = -1; + hid_t src_did = (hid_t)src_id; + hid_t dst_did = (hid_t)dst_id; + hid_t tid = -1; + hid_t sid = -1; + hsize_t total_size = 0, total_allocated_size; + + total_allocated_size = H5Dget_storage_size(src_did); + if (total_allocated_size <=0) + return 0; // nothing to write; + + sid = H5Dget_space(src_did); + if (sid < 0) { + h5libraryError(env); + return -1; + } /* end if */ + + tid = H5Dget_type(src_did); + if (tid < 0) { + H5Sclose(sid); + h5libraryError(env); + return -1; + } /* end if */ + + total_size = (hsize_t)H5Sget_simple_extent_npoints(sid) * (hsize_t)H5Tget_size(tid); + + H5Sclose(sid); + + buf = (jbyte*)HDmalloc((size_t)total_size * sizeof(jbyte)); + if (buf == NULL) { + H5Tclose(tid); + h5outOfMemory(env, "H5Dcopy: malloc failed"); + return -1; + } /* end if */ + + retVal = H5Dread(src_did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Tclose(tid); + + if (retVal < 0) { + HDfree(buf); + h5libraryError(env); + return (jint)retVal; + } /* end if */ + + tid = H5Dget_type(dst_did); + if (tid < 0) { + HDfree(buf); + h5libraryError(env); + return -1; + } /* end if */ + retVal = H5Dwrite(dst_did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + H5Tclose(tid); + HDfree(buf); + + if (retVal < 0) { + h5libraryError(env); + } /* end if */ + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Dcopy */ + +/* +///////////////////////////////////////////////////////////////////////////////// +// +// +// Add these methods so that we don't need to call H5Gget_objtype_by_idx +// in a loop to get information for all the object in a group, which takes +// a lot of time to finish if the number of objects is more than 10,000 +// +///////////////////////////////////////////////////////////////////////////////// +*/ + +#ifdef __cplusplus + herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); + herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); + int H5Gget_obj_info_max(hid_t, char **, int *, int *, unsigned long *, long); + int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder); +#else + static herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); + static herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info_t *linfo, void *op_data); + static int H5Gget_obj_info_max(hid_t, char **, int *, int *, unsigned long *, long); + static int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder); +#endif + +typedef struct info_all +{ + char **objname; + int *otype; + int *ltype; + unsigned long *objno; + unsigned long *fno; + unsigned long idxnum; + int count; +} info_all_t; + + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_obj_info_full + * Signature: (JLjava/lang/String;[Ljava/lang/String;[I[I[J[JIII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full(JNIEnv *env, jclass clss, jlong loc_id, jstring group_name, + jobjectArray objName, jintArray oType, jintArray lType, jlongArray fNo, + jlongArray oRef, jint n, jint indx_type, jint indx_order) +{ + herr_t ret_val = -1; + const char *gName = NULL; + char **oName = NULL; + jboolean isCopy; + jstring str; + jint *otarr; + jint *ltarr; + jlong *refP; + jlong *fnoP; + unsigned long *refs=NULL; + unsigned long *fnos=NULL; + hid_t gid = (hid_t)loc_id; + int i; + int indexType = indx_type; + int indexOrder = indx_order; + + if (oType == NULL) { + h5nullArgument(env, "H5Gget_obj_info_full: oType is NULL"); + } + else if (lType == NULL) { + h5nullArgument(env, "H5Gget_obj_info_full: lType is NULL"); + } + else if (oRef == NULL) { + h5nullArgument(env, "H5Gget_obj_info_full: oRef is NULL"); + } + else if (fNo == NULL) { + h5nullArgument(env, "H5Gget_obj_info_full: fNo is NULL"); + } + else { + otarr = ENVPTR->GetIntArrayElements(ENVPAR oType, &isCopy); + if (otarr == NULL) { + h5JNIFatalError(env, "H5Gget_obj_info_full: otype not pinned"); + return -1; + } /* end if */ + ltarr = ENVPTR->GetIntArrayElements(ENVPAR lType, &isCopy); + if (ltarr == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_full: ltype not pinned"); + return -1; + } /* end if */ + refP = ENVPTR->GetLongArrayElements(ENVPAR oRef, &isCopy); + if (refP == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_full: oRef not pinned"); + return -1; + } /* end if */ + fnoP = ENVPTR->GetLongArrayElements(ENVPAR fNo, &isCopy); + if (fnoP == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_full: fNo not pinned"); + return -1; + } /* end if */ + oName = (char **)HDcalloc((size_t)n, sizeof(*oName)); + if (!oName) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_full: oName not allocated"); + return -1; + } /* end if */ + + refs = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); + fnos = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); + if (!refs || !fnos) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); + h5str_array_free(oName, (size_t)n); + if (refs) + HDfree(refs); + if (fnos) + HDfree(fnos); + h5JNIFatalError(env, "H5Gget_obj_info_full: result arrays not allocated"); + return -1; + } /* end if */ + + if (group_name != NULL) { + gid = -1; + gName = ENVPTR->GetStringUTFChars(ENVPAR group_name, &isCopy); + if (gName != NULL) { + gid = H5Gopen2((hid_t)loc_id, gName, H5P_DEFAULT); + + ENVPTR->ReleaseStringUTFChars(ENVPAR group_name, gName); + } /* end if */ + if(gid < 0) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); + h5str_array_free(oName, (size_t)n); + HDfree(refs); + HDfree(fnos); + h5JNIFatalError(env, "H5Gget_obj_info_full: could not get group identifier"); + return -1; + } /* end if */ + } /* end if */ + + ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, refs, indexType, indexOrder); + + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, 0); + + if (group_name != NULL) + H5Gclose(gid); + + if (ret_val < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); + h5str_array_free(oName, (size_t)n); + HDfree(refs); + HDfree(fnos); + h5libraryError(env); + } /* end if */ + else { + for (i=0; i<n; i++) { + refP[i] = (jlong)refs[i]; + } /* end for */ + HDfree(refs); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, 0); + + for (i=0; i<n; i++) { + fnoP[i] = (jlong)fnos[i]; + } /* end for */ + HDfree(fnos); + ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, 0); + + for (i=0; i<n; i++) { + if (*(oName+i)) { + str = ENVPTR->NewStringUTF(ENVPAR *(oName+i)); + ENVPTR->SetObjectArrayElement(ENVPAR objName, i, (jobject)str); + } /* end if */ + } /* for (i=0; i<n; i++)*/ + h5str_array_free(oName, (size_t)n); + } /* end else */ + } /* end else */ + return ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_obj_info_max + * Signature: (J[Ljava/lang/String;[I[I[JJI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max(JNIEnv *env, jclass clss, jlong loc_id, jobjectArray objName, + jintArray oType, jintArray lType, jlongArray oRef, + jlong maxnum, jint n) +{ + herr_t ret_val = -1; + char **oName=NULL; + jboolean isCopy; + jstring str; + jint *otarr; + jint *ltarr; + jlong *refP; + unsigned long *refs; + int i; + + if (oType == NULL) { + h5nullArgument(env, "H5Gget_obj_info_max: oType is NULL"); + } /* end if */ + else if (lType == NULL) { + h5nullArgument(env, "H5Gget_obj_info_max: lType is NULL"); + } /* end else if */ + else if (oRef == NULL) { + h5nullArgument(env, "H5Gget_obj_info_max: oRef is NULL"); + } /* end else if */ + else { + otarr = ENVPTR->GetIntArrayElements(ENVPAR oType, &isCopy); + if (otarr == NULL) { + h5JNIFatalError(env, "H5Gget_obj_info_max: otype not pinned"); + return -1; + } /* end if */ + + ltarr = ENVPTR->GetIntArrayElements(ENVPAR lType, &isCopy); + if (ltarr == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_max: ltype not pinned"); + return -1; + } /* end if */ + + refP = ENVPTR->GetLongArrayElements(ENVPAR oRef, &isCopy); + if (refP == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_max: oRef not pinned"); + return -1; + } /* end if */ + + oName = (char **)HDcalloc((size_t)n, sizeof(*oName)); + if (!oName) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + h5JNIFatalError(env, "H5Gget_obj_info_max: oName not allocated"); + return -1; + } /* end if */ + refs = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); + if (!refs) { + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + h5str_array_free(oName, (size_t)n); + h5JNIFatalError(env, "H5Gget_obj_info_max: result array not allocated"); + return -1; + } /* end if */ + + ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int*)otarr, (int*)ltarr, refs, maxnum ); + ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, 0); + + if (ret_val < 0) { + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); + h5str_array_free(oName, (size_t)n); + HDfree(refs); + h5libraryError(env); + } /* end if */ + else { + for (i=0; i<n; i++) { + refP[i] = (jlong) refs[i]; + } /* end for */ + HDfree(refs); + ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, 0); + + for (i=0; i<n; i++) { + if (*(oName+i)) { + str = ENVPTR->NewStringUTF(ENVPAR *(oName+i)); + ENVPTR->SetObjectArrayElement(ENVPAR objName, i, (jobject)str); + } + } /* for (i=0; i<n; i++)*/ + + h5str_array_free(oName, (size_t)n); + } /* end else */ + } /* end else */ + + return ret_val; +} /* end Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max */ + +int +H5Gget_obj_info_full(hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder) +{ + info_all_t info; + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = 0; + info.fno = fno; + info.objno = objno; + info.count = 0; + + if(H5Literate(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { + /* iterate failed, try normal alphabetical order */ + if(H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) + return -1; + } /* end if */ + + return info.count; +} /* end H5Gget_obj_info_full */ + +int +H5Gget_obj_info_max(hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *objno, long maxnum) +{ + info_all_t info; + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = (unsigned long)maxnum; + info.objno = objno; + info.count = 0; + + if(H5Lvisit(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) + return -1; + + return info.count; +} /* end H5Gget_obj_info_max */ + +herr_t +obj_info_all(hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) +{ + int type = -1; + hid_t oid = -1; + herr_t retVal = -1; + info_all_t *datainfo = (info_all_t*)op_data; + H5O_info_t object_info; + + retVal = H5Oget_info_by_name(loc_id, name, &object_info, H5P_DEFAULT); + + if (retVal < 0) { + *(datainfo->otype+datainfo->count) = -1; + *(datainfo->ltype+datainfo->count) = -1; + *(datainfo->objname+datainfo->count) = (char *)HDmalloc(strlen(name)+1); + HDstrcpy(*(datainfo->objname+datainfo->count), name); + *(datainfo->objno+datainfo->count) = (unsigned long)-1; + } /* end if */ + else { + *(datainfo->otype+datainfo->count) = object_info.type; + *(datainfo->ltype+datainfo->count) = info->type; + *(datainfo->objname+datainfo->count) = (char *)HDmalloc(HDstrlen(name)+1); + HDstrcpy(*(datainfo->objname+datainfo->count), name); + + *(datainfo->fno+datainfo->count) = object_info.fileno; + *(datainfo->objno+datainfo->count) = (unsigned long)object_info.addr; + /* + if(info->type==H5L_TYPE_HARD) + *(datainfo->objno+datainfo->count) = (unsigned long)info->u.address; + else + *(datainfo->objno+datainfo->count) = info->u.val_size; + */ + } /* end else */ + + datainfo->count++; + + return 0; +} /* end obj_info_all */ + +herr_t +obj_info_max(hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) +{ + int type = -1; + herr_t retVal = 0; + info_all_t *datainfo = (info_all_t*)op_data; + H5O_info_t object_info; + + retVal = H5Oget_info(loc_id, &object_info); + if (retVal < 0) { + *(datainfo->otype+datainfo->count) = -1; + *(datainfo->ltype+datainfo->count) = -1; + *(datainfo->objname+datainfo->count) = NULL; + *(datainfo->objno+datainfo->count) = (unsigned long)-1; + return 1; + } /* end if */ + else { + *(datainfo->otype+datainfo->count) = object_info.type; + *(datainfo->ltype+datainfo->count) = info->type; + /* this will be freed by h5str_array_free(oName, n)*/ + *(datainfo->objname+datainfo->count) = (char *)HDmalloc(HDstrlen(name)+1); + strcpy(*(datainfo->objname+datainfo->count), name); + if(info->type==H5L_TYPE_HARD) + *(datainfo->objno+datainfo->count) = (unsigned long)info->u.address; + else + *(datainfo->objno+datainfo->count) = info->u.val_size; + } /* end else */ + datainfo->count++; + if(datainfo->count < (int)datainfo->idxnum) + return 0; + else + return 1; +} /* end obj_info_max */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5export_dataset + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *env, jclass cls, jstring file_export_name, jstring file_name, jstring object_path, jint binary_order) +{ + herr_t status = -1; + herr_t ret_val = -1; + hid_t file_id = -1; + hid_t dataset_id = -1; + FILE *stream; + const char *file_export; + const char *object_name; + const char *fileName; + jboolean isCopy2; + + if (file_export_name == NULL) { + h5nullArgument(env, "HDF5Library_export_data: file_export_name is NULL"); + } /* end if */ + else if (object_path == NULL) { + h5nullArgument(env, "HDF5Library_export_data: object_path is NULL"); + } /* end else if */ + else { + PIN_JAVA_STRING0(file_name, fileName); + + file_id = H5Fopen(fileName, (unsigned)H5F_ACC_RDWR, (hid_t)H5P_DEFAULT); + + UNPIN_JAVA_STRING(file_name, fileName); + + if (file_id < 0) { + /* throw exception */ + h5libraryError(env); + } /* end if */ + else { + object_name = ENVPTR->GetStringUTFChars(ENVPAR object_path, &isCopy2); + if (object_name == NULL) { + h5JNIFatalError( env, "H5Dopen: object name not pinned"); + } /* end if */ + else { + dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT); + + ENVPTR->ReleaseStringUTFChars(ENVPAR object_path, object_name); + + if (dataset_id < 0) { + H5Fclose(file_id); + h5libraryError(env); + } /* end if */ + else { + file_export = ENVPTR->GetStringUTFChars(ENVPAR file_export_name, 0); + stream = HDfopen(file_export, "w+"); + ENVPTR->ReleaseStringUTFChars(ENVPAR file_export_name, file_export); + + ret_val = h5str_dump_simple_dset(stream, dataset_id, binary_order); + + if (stream) + HDfclose(stream); + + H5Dclose(dataset_id); + + H5Fclose(file_id); + + if (ret_val < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5export_1dataset */ + +#ifdef __cplusplus +} +#endif diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h new file mode 100644 index 0000000..fcf343d --- /dev/null +++ b/java/src/jni/h5util.h @@ -0,0 +1,108 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifndef H5UTIL_H__ +#define H5UTIL_H__ + +#include "h5jni.h" + +#ifndef SUCCEED +#define SUCCEED 0 +#endif + +#ifndef FAIL +#define FAIL (-1) +#endif + +typedef struct h5str_t { + char *s; + size_t max; /* the allocated size of the string */ +} h5str_t; + +extern void h5str_new (h5str_t *str, size_t len); +extern void h5str_free (h5str_t *str); +extern void h5str_resize (h5str_t *str, size_t new_len); +extern char* h5str_append (h5str_t *str, const char* cstr); +extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int expand_data); +extern void h5str_array_free(char **strs, size_t len); +extern int h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order); +extern int h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_obj); +extern int h5str_dump_region_points_data(h5str_t *str, hid_t region, hid_t region_obj); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AwriteVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AwriteVL + (JNIEnv *, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadVL + (JNIEnv *, jclass, jlong, jlong, jobjectArray); + +/* + * Copies the content of one dataset to another dataset + * Class: hdf_hdf5lib_H5 + * Method: H5Acopy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Acopy + (JNIEnv *, jclass, jlong, jlong); + +/* + * Copies the content of one dataset to another dataset + * Class: hdf_hdf5lib_H5 + * Method: H5Dcopy + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dcopy + (JNIEnv*, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_obj_info_full + * Signature: (JLjava/lang/String;[Ljava/lang/String;[I[I[J[JIII)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full + (JNIEnv*, jclass, jlong, jstring, jobjectArray, jintArray, jintArray, jlongArray, jlongArray, jint, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Gget_obj_info_max + * Signature: (J[Ljava/lang/String;[I[I[JJI)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max + (JNIEnv*, jclass, jlong, jobjectArray, jintArray, jintArray, jlongArray, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5export_dataset + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5export_1dataset + (JNIEnv*, jclass, jstring, jstring, jstring, jint); + +#endif /* H5UTIL_H__ */ diff --git a/java/src/jni/h5zImp.c b/java/src/jni/h5zImp.c new file mode 100644 index 0000000..a60854d --- /dev/null +++ b/java/src/jni/h5zImp.c @@ -0,0 +1,84 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include <jni.h> +#include <stdlib.h> +#include "h5jni.h" +#include "h5zImp.h" + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zunregister + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Zunregister(JNIEnv *env, jclass clss, jint filter) +{ + herr_t retValue = H5Zunregister((H5Z_filter_t)filter); + + if (retValue < 0) + h5libraryError(env); + + return (jint)retValue; +} /* end Java_hdf_hdf5lib_H5_H5Zunregister */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zfilter_avail + * Signature: (I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Zfilter_1avail(JNIEnv *env, jclass clss, jint filter) +{ + herr_t retValue = H5Zfilter_avail((H5Z_filter_t)filter); + + if (retValue < 0) + h5libraryError(env); + + return (jint)retValue; +} /* end Java_hdf_hdf5lib_H5_H5Zfilter_1avail */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zget_filter_info + * Signature: (I)I + */ + +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Zget_1filter_1info(JNIEnv *env, jclass clss, jint filter) +{ + unsigned int flags = 0; + + if (H5Zget_filter_info ((H5Z_filter_t) filter, (unsigned *) &flags) < 0) + h5libraryError(env); + + return (jint)flags; +} /* end Java_hdf_hdf5lib_H5_H5Zget_1filter_1info */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5zImp.h b/java/src/jni/h5zImp.h new file mode 100644 index 0000000..de0d6e6 --- /dev/null +++ b/java/src/jni/h5zImp.h @@ -0,0 +1,55 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5Z */ + +#ifndef _Included_hdf_hdf5lib_H5_H5Z +#define _Included_hdf_hdf5lib_H5_H5Z + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zunregister + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zunregister + (JNIEnv *, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zfilter_avail + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zfilter_1avail + (JNIEnv *, jclass, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Zget_filter_info + * Signature: (I)I + */ + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zget_1filter_1info + (JNIEnv *, jclass, jint); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5Z */ diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c new file mode 100644 index 0000000..da86e09 --- /dev/null +++ b/java/src/jni/nativeData.c @@ -0,0 +1,1195 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfdfgroup.org/HDF5/doc/ + * + */ +/* + * This module contains the implementation of all the native methods + * used for number conversion. This is represented by the Java + * class HDFNativeData. + * + * These routines convert one dimensional arrays of bytes into + * one-D arrays of other types (int, float, etc) and vice versa. + * + * These routines are called from the Java parts of the Java-C + * interface. + * + * ***Important notes: + * + * 1. These routines are designed to be portable--they use the + * C compiler to do the required native data manipulation. + * 2. These routines copy the data at least once -- a serious + * but unavoidable performance hit. + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <jni.h> +#include "hdf5.h" +#include "h5jni.h" +#include "nativeData.h" + + +/* returns int [] */ +JNIEXPORT jintArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +{ + jbyte *barr; + jintArray rarray = NULL; + int blen; + jint *iarray; + jboolean bb; + char *bp; + jint *iap; + int ii; + int len; + + if (bdata == NULL) { + h5nullArgument( env, "byteToInt: bdata is NULL?"); + } /* end if */ + else { + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToInt: pin failed"); + } /* end if */ + else { + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + + len = blen/(int)sizeof(jint); + rarray = ENVPTR->NewIntArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToInt" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetIntArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToInt: pin iarray failed"); + return NULL; + } /* end if */ + + bp = (char *)barr; + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jint *)bp; + iap++; + bp += sizeof(jint); + } /* end for */ + + ENVPTR->ReleaseIntArrayElements(ENVPAR rarray,iarray, 0); + } /* end else */ + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + } /* end else */ + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B */ + +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +{ + jbyte *barr; + jfloatArray rarray; + int blen; + jfloat *farray; + jboolean bb; + char *bp; + jfloat *iap; + int ii; + int len; + + if (bdata == NULL) { + h5nullArgument( env, "byteToFloat: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToFloat: pin failed"); + return NULL; + } /* end if */ + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + + len = blen/(int)sizeof(jfloat); + rarray = ENVPTR->NewFloatArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToFloat" ); + return NULL; + } /* end if */ + farray = ENVPTR->GetFloatArrayElements(ENVPAR rarray,&bb); + if (farray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToFloat: pin farray failed"); + return NULL; + } /* end if */ + + bp = (char *)barr; + iap = farray; + for (ii = 0; ii < len; ii++) { + *iap = *(jfloat *)bp; + iap++; + bp += sizeof(jfloat); + } /* end for */ + + ENVPTR->ReleaseFloatArrayElements(ENVPAR rarray,farray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B */ + +/* returns short [] */ +JNIEXPORT jshortArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +{ + jbyte *barr; + jshortArray rarray; + int blen; + jshort *sarray; + jboolean bb; + char *bp; + jshort *iap; + int ii; + int len; + + if (bdata == NULL) { + h5nullArgument( env, "byteToShort: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToShort: pin failed"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + + len = blen/(int)sizeof(jshort); + rarray = ENVPTR->NewShortArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToShort" ); + return NULL; + } /* end if */ + + sarray = ENVPTR->GetShortArrayElements(ENVPAR rarray,&bb); + if (sarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToShort: pin sarray failed"); + return NULL; + } /* end if */ + + bp = (char *)barr; + iap = sarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jshort *)bp; + iap++; + bp += sizeof(jshort); + } /* end for */ + + ENVPTR->ReleaseShortArrayElements(ENVPAR rarray,sarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B */ + + +/* returns long [] */ +JNIEXPORT jlongArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +{ + jbyte *barr; + jlongArray rarray; + int blen; + jlong *larray; + jboolean bb; + char *bp; + jlong *iap; + int ii; + int len; + + if (bdata == NULL) { + h5nullArgument( env, "byteToLong: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToLong: pin failed"); + return NULL; + } /* end if */ + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + + len = blen/(int)sizeof(jlong); + rarray = ENVPTR->NewLongArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToLong" ); + return NULL; + } /* end if */ + + larray = ENVPTR->GetLongArrayElements(ENVPAR rarray,&bb); + if (larray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToLong: pin larray failed"); + return NULL; + } /* end if */ + + bp = (char *)barr; + iap = larray; + for (ii = 0; ii < len; ii++) { + *iap = *(jlong *)bp; + iap++; + bp += sizeof(jlong); + } /* end for */ + ENVPTR->ReleaseLongArrayElements(ENVPAR rarray,larray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B */ + + +/* returns double [] */ +JNIEXPORT jdoubleArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +{ + jbyte *barr; + jdoubleArray rarray; + int blen; + jdouble *darray; + jboolean bb; + char *bp; + jdouble *iap; + int ii; + int len; + + if (bdata == NULL) { + h5nullArgument( env, "byteToDouble: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToDouble: pin failed"); + return NULL; + } /* end if */ + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + + len = blen/(int)sizeof(jdouble); + rarray = ENVPTR->NewDoubleArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToDouble" ); + return NULL; + } /* end if */ + + darray = ENVPTR->GetDoubleArrayElements(ENVPAR rarray,&bb); + if (darray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToDouble: pin darray failed"); + return NULL; + } /* end if */ + + bp = (char *)barr; + iap = darray; + for (ii = 0; ii < len; ii++) { + *iap = *(jdouble *)bp; + iap++; + bp += sizeof(jdouble); + } /* end for */ + + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rarray,darray,0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B */ + + +/* returns int [] */ +JNIEXPORT jintArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +{ + char *bp; + jbyte *barr; + jintArray rarray; + int blen; + jint *iarray; + jint *iap; + int ii; + jboolean bb; + + if (bdata == NULL) { + h5nullArgument( env, "byteToInt: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError(env, "byteToInt: pin failed"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + if ((start < 0) || ((int)(start + (len*(int)sizeof(jint))) > blen)) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToInt: getLen failed"); + return NULL; + } /* end if */ + + bp = (char *)barr + start; + + rarray = ENVPTR->NewIntArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToInt" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetIntArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError(env, "byteToInt: pin iarray failed"); + return NULL; + } /* end if */ + + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jint *)bp; + iap++; + bp += sizeof(jint); + } /* end for */ + + ENVPTR->ReleaseIntArrayElements(ENVPAR rarray,iarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B */ + +/* returns short [] */ +JNIEXPORT jshortArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +{ + char *bp; + jbyte *barr; + jshortArray rarray; + int blen; + jshort *iarray; + jshort *iap; + int ii; + jboolean bb; + + if (bdata == NULL) { + h5nullArgument( env, "byteToShort: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError( env, "byteToShort: getByte failed?"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + if ((start < 0) || ((int)(start + (len*(int)sizeof(jshort))) > blen)) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5badArgument( env, "byteToShort: start or len is out of bounds"); + return NULL; + } /* end if */ + + bp = (char *)barr + start; + + rarray = ENVPTR->NewShortArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToShort" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetShortArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError( env, "byteToShort: getShort failed?"); + return NULL; + } /* end if */ + + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jshort *)bp; + iap++; + bp += sizeof(jshort); + } /* end for */ + + ENVPTR->ReleaseShortArrayElements(ENVPAR rarray,iarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B */ + +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +{ + char *bp; + jbyte *barr; + jfloatArray rarray; + int blen; + jfloat *iarray; + jfloat *iap; + int ii; + jboolean bb; + + if (bdata == NULL) { + h5nullArgument( env, "byteToFloat: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError( env, "byteToFloat: getByte failed?"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + if ((start < 0) || ((int)(start + (len*(int)sizeof(jfloat))) > blen)) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5badArgument( env, "byteToFloat: start or len is out of bounds"); + return NULL; + } /* end if */ + + bp = (char *)barr + start; + + rarray = ENVPTR->NewFloatArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToFloat" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetFloatArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError( env, "byteToFloat: getFloat failed?"); + return NULL; + } /* end if */ + + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jfloat *)bp; + iap++; + bp += sizeof(jfloat); + } /* end for */ + + ENVPTR->ReleaseFloatArrayElements(ENVPAR rarray,iarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B */ + +/* returns long [] */ +JNIEXPORT jlongArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +{ + char *bp; + jbyte *barr; + jlongArray rarray; + int blen; + jlong *iarray; + jlong *iap; + int ii; + jboolean bb; + + if (bdata == NULL) { + h5nullArgument( env, "byteToLong: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError( env, "byteToLong: getByte failed?"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + if ((start < 0) || ((int)(start + (len*(int)sizeof(jlong))) > blen)) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5badArgument( env, "byteToLong: start or len is out of bounds"); + return NULL; + } /* end if */ + + bp = (char *)barr + start; + + rarray = ENVPTR->NewLongArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToLong" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetLongArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError( env, "byteToLong: getLong failed?"); + return NULL; + } /* end if */ + + iap = iarray; + for (ii = 0; ii < len; ii++) { + + *iap = *(jlong *)bp; + iap++; + bp += sizeof(jlong); + } /* end for */ + + ENVPTR->ReleaseLongArrayElements(ENVPAR rarray,iarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B */ + +/* returns double [] */ +JNIEXPORT jdoubleArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B(JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +{ + char *bp; + jbyte *barr; + jdoubleArray rarray; + int blen; + jdouble *iarray; + jdouble *iap; + int ii; + jboolean bb; + + if (bdata == NULL) { + h5nullArgument( env, "byteToDouble: bdata is NULL?"); + return NULL; + } /* end if */ + barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); + if (barr == NULL) { + h5JNIFatalError( env, "byteToDouble: getByte failed?"); + return NULL; + } /* end if */ + + blen = ENVPTR->GetArrayLength(ENVPAR bdata); + if ((start < 0) || ((int)(start + (len*(int)sizeof(jdouble))) > blen)) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5badArgument( env, "byteToDouble: start or len is out of bounds"); + return NULL; + } /* end if */ + + bp = (char *)barr + start; + + rarray = ENVPTR->NewDoubleArray(ENVPAR len); + if (rarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5outOfMemory( env, "byteToDouble" ); + return NULL; + } /* end if */ + + iarray = ENVPTR->GetDoubleArrayElements(ENVPAR rarray,&bb); + if (iarray == NULL) { + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + h5JNIFatalError( env, "byteToDouble: getDouble failed?"); + return NULL; + } /* end if */ + + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jdouble *)bp; + iap++; + bp += sizeof(jdouble); + } /* end for */ + + ENVPTR->ReleaseDoubleArrayElements(ENVPAR rarray,iarray, 0); + ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I(JNIEnv *env, jclass clss, jint start, jint len, jintArray idata) /* IN: array of int */ +{ + jint *ip; + jint *iarr; + int ilen; + jbyteArray rarray; + int blen; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ii; + int ij; + union things { + int ival; + char bytes[4]; + } u; + + if (idata == NULL) { + h5nullArgument( env, "intToByte: idata is NULL?"); + return NULL; + } /* end if */ + + iarr = ENVPTR->GetIntArrayElements(ENVPAR idata,&bb); + if (iarr == NULL) { + h5JNIFatalError( env, "intToByte: getInt failed?"); + return NULL; + } /* end if */ + + ilen = ENVPTR->GetArrayLength(ENVPAR idata); + if ((start < 0) || (((start + len)) > ilen)) { + ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5badArgument( env, "intToByte: start or len is out of bounds"); + return NULL; + } /* end if */ + + ip = iarr + start; + + blen = ilen * (int)sizeof(jint); + rarray = ENVPTR->NewByteArray(ENVPAR blen); + if (rarray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5outOfMemory( env, "intToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5JNIFatalError( env, "intToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + for (ii = 0; ii < len; ii++) { + u.ival = *ip++; + for (ij = 0; ij < sizeof(jint); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S(JNIEnv *env, jclass clss, jint start, jint len, jshortArray idata) /* IN: array of short */ +{ + jshort *ip; + jshort *iarr; + int ilen; + jbyteArray rarray; + int blen; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ii; + int ij; + union things { + short ival; + char bytes[4]; + } u; + + if (idata == NULL) { + h5nullArgument( env, "shortToByte: idata is NULL?"); + return NULL; + } /* end if */ + iarr = ENVPTR->GetShortArrayElements(ENVPAR idata,&bb); + if (iarr == NULL) { + h5JNIFatalError( env, "shortToByte: getShort failed?"); + return NULL; + } /* end if */ + + ilen = ENVPTR->GetArrayLength(ENVPAR idata); + if ((start < 0) || (((start + len)) > ilen)) { + ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5badArgument( env, "shortToByte: start or len is out of bounds"); + return NULL; + } /* end if */ + + ip = iarr + start; + + blen = ilen * (int)sizeof(jshort); + rarray = ENVPTR->NewByteArray(ENVPAR blen); + if (rarray == NULL) { + ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5outOfMemory( env, "shortToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5JNIFatalError( env, "shortToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + for (ii = 0; ii < len; ii++) { + u.ival = *ip++; + for (ij = 0; ij < sizeof(jshort); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F(JNIEnv *env, jclass clss, jint start, jint len, jfloatArray idata) /* IN: array of float */ +{ + jfloat *ip; + jfloat *iarr; + int ilen; + jbyteArray rarray; + int blen; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ii; + int ij; + union things { + float ival; + char bytes[4]; + } u; + + if (idata == NULL) { + h5nullArgument( env, "floatToByte: idata is NULL?"); + return NULL; + } /* end if */ + iarr = ENVPTR->GetFloatArrayElements(ENVPAR idata,&bb); + if (iarr == NULL) { + h5JNIFatalError( env, "floatToByte: getFloat failed?"); + return NULL; + } /* end if */ + + ilen = ENVPTR->GetArrayLength(ENVPAR idata); + if ((start < 0) || (((start + len)) > ilen)) { + ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5badArgument( env, "floatToByte: start or len is out of bounds"); + return NULL; + } /* end if */ + + ip = iarr + start; + + blen = ilen * (int)sizeof(jfloat); + rarray = ENVPTR->NewByteArray(ENVPAR blen); + if (rarray == NULL) { + ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5outOfMemory( env, "floatToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5JNIFatalError( env, "floatToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + for (ii = 0; ii < len; ii++) { + u.ival = *ip++; + for (ij = 0; ij < sizeof(jfloat); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D(JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray idata) /* IN: array of double */ +{ + jdouble *ip; + jdouble *iarr; + int ilen; + jbyteArray rarray; + int blen; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ii; + int ij; + union things { + double ival; + char bytes[8]; + } u; + + if (idata == NULL) { + h5nullArgument( env, "doubleToByte: idata is NULL?"); + return NULL; + } /* end if */ + iarr = ENVPTR->GetDoubleArrayElements(ENVPAR idata,&bb); + if (iarr == NULL) { + h5JNIFatalError( env, "doubleToByte: getDouble failed?"); + return NULL; + } /* end if */ + + ilen = ENVPTR->GetArrayLength(ENVPAR idata); + if ((start < 0) || (((start + len)) > ilen)) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5badArgument( env, "doubleToByte: start or len is out of bounds"); + return NULL; + } /* end if */ + + ip = iarr + start; + + blen = ilen * (int)sizeof(jdouble); + rarray = ENVPTR->NewByteArray(ENVPAR blen); + if (rarray == NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5outOfMemory( env, "doubleToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5JNIFatalError( env, "doubleToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + for (ii = 0; ii < len; ii++) { + u.ival = *ip++; + for (ij = 0; ij < sizeof(jdouble); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D */ + + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J(JNIEnv *env, jclass clss, jint start, jint len, jlongArray idata) /* IN: array of long */ +{ + jlong *ip; + jlong *iarr; + int ilen; + jbyteArray rarray; + int blen; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ii; + int ij; + union things { + jlong ival; + char bytes[8]; + } u; + + if (idata == NULL) { + h5nullArgument( env, "longToByte: idata is NULL?"); + return NULL; + } /* end if */ + iarr = ENVPTR->GetLongArrayElements(ENVPAR idata,&bb); + if (iarr == NULL) { + h5JNIFatalError( env, "longToByte: getLong failed?"); + return NULL; + } /* end if */ + + ilen = ENVPTR->GetArrayLength(ENVPAR idata); + if ((start < 0) || (((start + len)) > ilen)) { + ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5badArgument( env, "longToByte: start or len is out of bounds?\n"); + return NULL; + } /* end if */ + + ip = iarr + start; + + blen = ilen * (int)sizeof(jlong); + rarray = ENVPTR->NewByteArray(ENVPAR blen); + if (rarray == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5outOfMemory( env, "longToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); + h5JNIFatalError( env, "longToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + for (ii = 0; ii < len; ii++) { + u.ival = *ip++; + for (ij = 0; ij < sizeof(jlong); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J */ + + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_intToByte__I(JNIEnv *env, jclass clss, jint idata) /* IN: int */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + int ij; + jboolean bb; + union things { + int ival; + char bytes[sizeof(int)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jint)); + if (rarray == NULL) { + h5outOfMemory( env, "intToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "intToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jint); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_intToByte__I */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_floatToByte__F(JNIEnv *env, jclass clss, jfloat idata) /* IN: int */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ij; + union things { + float ival; + char bytes[sizeof(float)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jfloat)); + if (rarray == NULL) { + h5outOfMemory( env, "floatToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "floatToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jfloat); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_floatToByte__F */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_shortToByte__S(JNIEnv *env, jclass clss, jshort idata) /* IN: short */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ij; + union things { + short ival; + char bytes[sizeof(short)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jshort)); + if (rarray == NULL) { + h5outOfMemory( env, "shortToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "shortToByte: getShort failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jshort); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_shortToByte__S */ + + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D(JNIEnv *env, jclass clss, jdouble idata) /* IN: double */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ij; + union things { + double ival; + char bytes[sizeof(double)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jdouble)); + if (rarray == NULL) { + h5outOfMemory( env, "doubleToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "doubleToByte: getDouble failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jdouble); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D */ + + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_longToByte__J(JNIEnv *env, jclass clss, jlong idata) /* IN: array of long */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ij; + union things { + jlong ival; + char bytes[sizeof(jlong)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jlong)); + if (rarray == NULL) { + h5outOfMemory( env, "longToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "longToByte: getLong failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jlong); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_longToByte__J */ + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToByte__B(JNIEnv *env, jclass clss, jbyte idata) /* IN: array of long */ +{ + jbyteArray rarray; + jbyte *barray; + jbyte *bap; + jboolean bb; + int ij; + union things { + jbyte ival; + char bytes[sizeof(jbyte)]; + } u; + + rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jbyte)); + if (rarray == NULL) { + h5outOfMemory( env, "byteToByte" ); + return NULL; + } /* end if */ + + barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); + if (barray == NULL) { + h5JNIFatalError( env, "byteToByte: getByte failed?"); + return NULL; + } /* end if */ + + bap = barray; + u.ival = idata; + for (ij = 0; ij < sizeof(jbyte); ij++) { + *bap = u.bytes[ij]; + bap++; + } /* end for */ + + ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToByte__B */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/nativeData.h b/java/src/jni/nativeData.h new file mode 100644 index 0000000..1af06b4 --- /dev/null +++ b/java/src/jni/nativeData.h @@ -0,0 +1,115 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_HDFNativeData */ + +#ifndef _Included_hdf_hdf5lib_HDFNativeData +#define _Included_hdf_hdf5lib_HDFNativeData + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* returns int [] */ +JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B +(JNIEnv *, jclass, jbyteArray); + +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B +(JNIEnv *, jclass, jbyteArray); + +/* returns short [] */ +JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B +(JNIEnv *, jclass, jbyteArray); + +/* returns long [] */ +JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B +(JNIEnv *, jclass, jbyteArray); + +/* returns double [] */ +JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B +(JNIEnv *, jclass, jbyteArray); + +/* returns int [] */ +JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B +(JNIEnv *, jclass, jint, jint, jbyteArray); + +/* returns short [] */ +JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B +(JNIEnv *, jclass, jint, jint, jbyteArray); + +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B +(JNIEnv *, jclass, jint, jint, jbyteArray); + +/* returns long [] */ +JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B +(JNIEnv *, jclass, jint, jint, jbyteArray); + +/* returns double [] */ +JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B +(JNIEnv *, jclass, jint, jint, jbyteArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I +(JNIEnv *, jclass, jint, jint, jintArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S +(JNIEnv *, jclass, jint, jint, jshortArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F +(JNIEnv *, jclass, jint, jint, jfloatArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D +(JNIEnv *, jclass, jint, jint, jdoubleArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J +(JNIEnv *, jclass, jint, jint, jlongArray); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__I +(JNIEnv *, jclass, jint); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__F +(JNIEnv *, jclass, jfloat); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__S +(JNIEnv *, jclass, jshort); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D +(JNIEnv *env, jclass, jdouble); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__J +(JNIEnv *, jclass, jlong); + +/* returns byte [] */ +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToByte__B +(JNIEnv *, jclass, jbyte); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_HDFNativeData */ |