summaryrefslogtreecommitdiffstats
path: root/java/src/jni
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2018-08-24 14:14:56 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2018-08-24 14:14:56 (GMT)
commit6569f208b8f39ace9e442e94ab110bec94c67d37 (patch)
treeb477826af1b6b47b1da9dfe948050ed7a50e75c4 /java/src/jni
parent2ad049a6411923653365962c826cf59cf801d0d7 (diff)
parent21eef8a98ee6949c69d79c6c4d87fc8e4e38dc29 (diff)
downloadhdf5-6569f208b8f39ace9e442e94ab110bec94c67d37.zip
hdf5-6569f208b8f39ace9e442e94ab110bec94c67d37.tar.gz
hdf5-6569f208b8f39ace9e442e94ab110bec94c67d37.tar.bz2
Merge pull request #1220 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:1.10/master to 1.10/master
* commit '21eef8a98ee6949c69d79c6c4d87fc8e4e38dc29': (354 commits) Commit version with new release date. Add example packaging option and fix html5 issues Commit version with new release date. Commit files changed by autogen.sh. Merge pull request #1208 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:hdf5_1_10 to hdf5_1_10 Merge pull request #1207 in HDFFV/hdf5 from ~BYRN/hdf5_adb:hdf5_1_10 to hdf5_1_10 Merge pull request #1203 in HDFFV/hdf5 from ~BYRN/hdf5_adb:hdf5_1_10 to hdf5_1_10 Commit version with new release date. Commit new generated H5version.h including #defines for H5_USE_110_API. Correct nested c-style comment. Merge pull request #1197 in HDFFV/hdf5 from ~BYRN/hdf5_merge_adb:hdf5_1_10 to hdf5_1_10 Merge pull request #1194 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:hdf5_1_10 to hdf5_1_10 Updated the H5Dread/write_chunk() release note. Added a release note for the H5Dread/write_chunk() API calls. Update Intel Fortran version for Windows 10. RELEASE.txt updates. Version change for 1.10.3 release. Revised entry on CVE issues Added notes about CVE issues Update version for HDF5 1.10.3 release. Add placeholder for performance improvement in RELEASE.txt updated fortran fixes ...
Diffstat (limited to 'java/src/jni')
-rw-r--r--java/src/jni/CMakeLists.txt9
-rw-r--r--java/src/jni/Makefile.in22
-rw-r--r--java/src/jni/exceptionImp.c19
-rw-r--r--java/src/jni/exceptionImp.h8
-rw-r--r--java/src/jni/h5Constants.c14
-rw-r--r--java/src/jni/h5aImp.c334
-rw-r--r--java/src/jni/h5aImp.h18
-rw-r--r--java/src/jni/h5dImp.c311
-rw-r--r--java/src/jni/h5dImp.h9
-rw-r--r--java/src/jni/h5eImp.c8
-rw-r--r--java/src/jni/h5lImp.c8
-rw-r--r--java/src/jni/h5oImp.c117
-rw-r--r--java/src/jni/h5oImp.h20
-rw-r--r--java/src/jni/h5pImp.c4
-rw-r--r--java/src/jni/h5util.c716
-rw-r--r--java/src/jni/h5util.h23
16 files changed, 1272 insertions, 368 deletions
diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt
index 96e7035..a0228e1 100644
--- a/java/src/jni/CMakeLists.txt
+++ b/java/src/jni/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.10)
-PROJECT (HDF5_JAVA_JNI C CXX)
+project (HDF5_JAVA_JNI C)
set (HDF5_JAVA_JNI_CSRCS
${HDF5_JAVA_JNI_SOURCE_DIR}/exceptionImp.c
@@ -44,17 +44,16 @@ set (HDF5_JAVA_JNI_CHDRS
${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_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE ${HDF5_BINARY_DIR} ${HDF5_JAVA_JNI_SOURCE_DIR})
+TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED)
target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${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})
+H5_SET_LIB_OPTIONS (${HDF5_JAVA_JNI_LIB_TARGET} ${HDF5_JAVA_JNI_LIB_NAME} SHARED "JAVA")
if (WIN32)
get_filename_component (HDF5_JAVA_JNI_DLL_NAME ${HDF5_JAVA_JNI_LIB_TARGET} NAME_WE)
set (HDF5_JAVA_JNI_DLL_NAME "${HDF5_JAVA_JNI_DLL_NAME}$<$<CONFIG:Debug>:_D>")
diff --git a/java/src/jni/Makefile.in b/java/src/jni/Makefile.in
index 683f872..d0862c3 100644
--- a/java/src/jni/Makefile.in
+++ b/java/src/jni/Makefile.in
@@ -540,6 +540,7 @@ JAVA_PATH_NAME = @JAVA_PATH_NAME@
JAVA_VERSION = @JAVA_VERSION@
JNIFLAGS = @JNIFLAGS@
JUNIT = @JUNIT@
+LARGE_PARALLEL_IO = @LARGE_PARALLEL_IO@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
@@ -587,6 +588,7 @@ PAC_FORTRAN_NATIVE_REAL_KIND = @PAC_FORTRAN_NATIVE_REAL_KIND@
PAC_FORTRAN_NATIVE_REAL_SIZEOF = @PAC_FORTRAN_NATIVE_REAL_SIZEOF@
PAC_FORTRAN_NUM_INTEGER_KINDS = @PAC_FORTRAN_NUM_INTEGER_KINDS@
PARALLEL = @PARALLEL@
+PARALLEL_FILTERED_WRITES = @PARALLEL_FILTERED_WRITES@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROFILING = @PROFILING@
RANLIB = @RANLIB@
@@ -732,29 +734,29 @@ TRACE = perl $(top_srcdir)/bin/trace
# .chklog files are output from those tests.
# *.clog and *.clog2 are from the MPE option.
CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2
-LT_VERS_INTERFACE = 102
+LT_VERS_INTERFACE = 103
LT_VERS_REVISION = 0
-LT_VERS_AGE = 1
-LT_CXX_VERS_INTERFACE = 102
+LT_VERS_AGE = 0
+LT_CXX_VERS_INTERFACE = 103
LT_CXX_VERS_REVISION = 0
LT_CXX_VERS_AGE = 0
LT_F_VERS_INTERFACE = 101
-LT_F_VERS_REVISION = 1
+LT_F_VERS_REVISION = 2
LT_F_VERS_AGE = 1
LT_HL_VERS_INTERFACE = 101
-LT_HL_VERS_REVISION = 0
+LT_HL_VERS_REVISION = 1
LT_HL_VERS_AGE = 1
LT_HL_CXX_VERS_INTERFACE = 101
-LT_HL_CXX_VERS_REVISION = 1
+LT_HL_CXX_VERS_REVISION = 2
LT_HL_CXX_VERS_AGE = 1
LT_HL_F_VERS_INTERFACE = 100
-LT_HL_F_VERS_REVISION = 2
+LT_HL_F_VERS_REVISION = 3
LT_HL_F_VERS_AGE = 0
-LT_JAVA_VERS_INTERFACE = 102
+LT_JAVA_VERS_INTERFACE = 103
LT_JAVA_VERS_REVISION = 0
-LT_JAVA_VERS_AGE = 2
+LT_JAVA_VERS_AGE = 3
LT_TOOLS_VERS_INTERFACE = 101
-LT_TOOLS_VERS_REVISION = 0
+LT_TOOLS_VERS_REVISION = 1
LT_TOOLS_VERS_AGE = 1
# Mark this directory as part of the JNI API
diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c
index afad5d5..ccda0d2 100644
--- a/java/src/jni/exceptionImp.c
+++ b/java/src/jni/exceptionImp.c
@@ -83,11 +83,16 @@ typedef struct H5E_num_t {
} \
jm = ENVPTR->GetMethodID(ENVPAR jc, "<init>", "(Ljava/lang/String;)V"); \
if (jm == NULL) { \
+ printf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \
return JNI_FALSE; \
} \
ex = ENVPTR->NewObjectA (ENVPAR jc, jm, (jvalue*)(args)); \
+ if (ex == NULL) { \
+ printf("THROWEXCEPTION FATAL ERROR: %s: Creation failed\n", (className)); \
+ return JNI_FALSE; \
+ } \
if (ENVPTR->Throw(ENVPAR (jthrowable)ex) < 0) { \
- printf("FATAL ERROR: %s: Throw failed\n", (className)); \
+ printf("THROWEXCEPTION FATAL ERROR: %s: Throw failed\n", (className)); \
return JNI_FALSE; \
} \
return JNI_TRUE; \
@@ -174,13 +179,13 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException
- * Method: getMajorErrorNumber
+ * 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
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber
(JNIEnv *env, jobject obj)
{
H5E_num_t err_nums;
@@ -190,17 +195,17 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber
H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums);
return err_nums.maj_num;
-} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber() */
+} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber() */
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException
- * Method: getMinorErrorNumber
+ * 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
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber
(JNIEnv *env, jobject obj)
{
H5E_num_t err_nums;
@@ -210,7 +215,7 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber
H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums);
return err_nums.min_num;
-} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber() */
+} /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber() */
/*
* Routine to raise particular Java exceptions from C
diff --git a/java/src/jni/exceptionImp.h b/java/src/jni/exceptionImp.h
index 423e537..5873202 100644
--- a/java/src/jni/exceptionImp.h
+++ b/java/src/jni/exceptionImp.h
@@ -55,20 +55,20 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException
- * Method: getMajorErrorNumber
+ * Method: _getMajorErrorNumber
* Signature: ()J
*/
JNIEXPORT jlong JNICALL
-Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMajorErrorNumber
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber
(JNIEnv *env, jobject obj);
/*
* Class: hdf_hdf5lib_exceptions_HDFLibraryException
- * Method: getMinorErrorNumber
+ * Method: _getMinorErrorNumber
* Signature: ()J
*/
JNIEXPORT jlong JNICALL
-Java_hdf_hdf5lib_exceptions_HDF5LibraryException_getMinorErrorNumber
+Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber
(JNIEnv *env, jobject obj);
#ifdef __cplusplus
diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c
index 900316e..c99745d 100644
--- a/java/src/jni/h5Constants.c
+++ b/java/src/jni/h5Constants.c
@@ -643,6 +643,18 @@ Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1WITHOUT_1ATTR_1FLAG(JNIEnv *env, jclas
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_1INFO_1BASIC(JNIEnv *env, jclass cls) { return H5O_INFO_BASIC; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1TIME(JNIEnv *env, jclass cls) { return H5O_INFO_TIME; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1NUM_1ATTRS(JNIEnv *env, jclass cls) { return H5O_INFO_NUM_ATTRS; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1HDR(JNIEnv *env, jclass cls) { return H5O_INFO_HDR; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1META_1SIZE(JNIEnv *env, jclass cls) { return H5O_INFO_META_SIZE; }
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_INFO_ALL; }
+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; }
@@ -1219,6 +1231,8 @@ 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_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; }
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index 26ec4fc..c0dc182 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -49,6 +49,10 @@ extern jobject visit_callback;
/* Local Prototypes */
/********************/
+static herr_t H5AwriteVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
+static herr_t H5AwriteVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
+static herr_t H5AreadVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
+static herr_t H5AreadVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf);
static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data);
@@ -178,7 +182,6 @@ Java_hdf_hdf5lib_H5_H5Aread
} /* 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);
@@ -194,6 +197,323 @@ Java_hdf_hdf5lib_H5_H5Aread
/*
* 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;
+ htri_t isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5AwriteVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ else if (isStr > 0) {
+ status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */
+
+herr_t
+H5AwriteVL_str
+ (JNIEnv *env, hid_t aid, hid_t tid, 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_str: 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)aid, (hid_t)tid, 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;
+}
+
+herr_t
+H5AwriteVL_asstr
+ (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+{
+ char **strs;
+ jstring jstr;
+ jint i;
+ jint n;
+ hid_t sid;
+ hsize_t dims[H5S_MAX_RANK];
+ herr_t status = -1;
+
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+
+ if (strs == NULL) {
+ h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings");
+ } /* end if */
+ else {
+ status = H5Awrite(aid, tid, strs);
+
+ if (status < 0) {
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs);
+ H5Sclose(sid);
+ HDfree(strs);
+ h5JNIFatalError(env, "H5AwriteVL_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 H5AwriteVL_str */
+
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5AreadVL
+ * Signature: (JJJJJ[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;
+ htri_t isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5AreadVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ status = H5AreadVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ else if (isStr > 0) {
+ status = H5AreadVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf);
+ }
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Aread_1VL */
+
+herr_t
+H5AreadVL_asstr
+ (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+{
+ jint i;
+ jint n;
+ hid_t sid;
+ jstring jstr;
+ h5str_t h5str;
+ hvl_t *rdata;
+ hsize_t dims[H5S_MAX_RANK];
+ size_t size;
+ size_t max_len = 0;
+ herr_t status = -1;
+
+ /* Get size of string array */
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ /* we will need to read n number of hvl_t structures */
+ rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+ if (rdata == NULL) {
+ h5JNIFatalError(env, "H5AreadVL_asstr: failed to allocate buff for read");
+ } /* end if */
+ else {
+ status = H5Aread(aid, tid, rdata);
+
+ if (status < 0) {
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata);
+ H5Sclose(sid);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5AreadVL_asstr: failed to read data");
+ } /* end if */
+ else {
+ /* calculate the largest size of all the hvl_t structures read */
+ max_len = 1;
+ for (i=0; i < n; i++) {
+ if ((rdata + i)->len > max_len)
+ max_len = (rdata + i)->len;
+ }
+
+ /* create one malloc to hold largest element */
+ size = H5Tget_size(tid) * max_len;
+ HDmemset(&h5str, 0, sizeof(h5str_t));
+ h5str_new(&h5str, 4 * size);
+
+ if (h5str.s == NULL) {
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata);
+ H5Sclose(sid);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5AreadVL_asstr: failed to allocate buf");
+ } /* end if */
+ else {
+ H5T_class_t tclass = H5Tget_class(tid);
+ /* convert each element to char string */
+ for (i=0; i < n; i++) {
+ h5str.s[0] = '\0';
+ h5str_vlsprintf(&h5str, aid, tid, rdata+i, 0);
+ jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
+ ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
+ } /* end for */
+ h5str_free(&h5str);
+
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata);
+ H5Sclose(sid);
+ HDfree(rdata);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return status;
+}
+
+herr_t
+H5AreadVL_str
+ (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf)
+{
+ char **strs;
+ jstring jstr;
+ jint i;
+ jint n;
+ hid_t sid;
+ hsize_t dims[H5S_MAX_RANK];
+ herr_t status = -1;
+
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ strs =(char**)HDcalloc((size_t)n, sizeof(char*));
+
+ if (strs == NULL) {
+ h5JNIFatalError(env, "H5AreadVL_str: failed to allocate buff for read variable length strings");
+ } /* end if */
+ else {
+ status = H5Aread(aid, tid, strs);
+
+ if (status < 0) {
+ dims[0] = (hsize_t)n;
+ sid = H5Screate_simple(1, dims, NULL);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs);
+ H5Sclose(sid);
+ HDfree(strs);
+ h5JNIFatalError(env, "H5AreadVL_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 H5AreadVL_str */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Aget_space
* Signature: (J)J
*/
@@ -646,7 +966,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx
UNPIN_JAVA_STRING(obj_name, aName);
if (status < 0) {
- h5libraryError(env);
+ h5libraryError(env);
} /* end if */
else {
args[0].z = ainfo.corder_valid;
@@ -682,7 +1002,7 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name
UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName);
if (status < 0) {
- h5libraryError(env);
+ h5libraryError(env);
} /* end if */
else {
args[0].z = ainfo.corder_valid;
@@ -846,8 +1166,12 @@ H5A_iterate_cb
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);
+ if (cb_info_t == NULL) {
+ printf("FATAL ERROR: hdf/hdf5lib/structs/H5A_info_t: Creation failed\n");
+ }
+ else {
+ 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) */
diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h
index 62769fd..f3758eb 100644
--- a/java/src/jni/h5aImp.h
+++ b/java/src/jni/h5aImp.h
@@ -69,6 +69,24 @@ Java_hdf_hdf5lib_H5_H5Aread
/*
* 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);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Aget_space
* Signature: (J)J
*/
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index 9784055..205e9fb 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -56,6 +56,7 @@ extern jobject visit_callback;
static herr_t H5DreadVL_asstr (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_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_asstr (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);
@@ -993,96 +994,6 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1double
/*
* Class: hdf_hdf5lib_H5
- * Method: H5DreadVL
- * Signature: (JJJJJ[Ljava/lang/String;)I
- */
-JNIEXPORT jint JNICALL
-Java_hdf_hdf5lib_H5_H5DreadVL
- (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, "H5DreadVL: buf is NULL");
- } /* end if */
- else {
- isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
-
- if (isVlenStr)
- h5badArgument(env, "H5DreadVL: type is not variable length non-string");
- else
- status = H5DreadVL_asstr(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 else */
-
- return (jint)status;
-} /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */
-
-herr_t
-H5DreadVL_asstr
- (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
-{
- jint i;
- jint n;
- jstring jstr;
- h5str_t h5str;
- hvl_t *rdata;
- size_t size;
- size_t max_len = 0;
- herr_t status = -1;
-
- n = ENVPTR->GetArrayLength(ENVPAR buf);
- rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
- if (rdata == NULL) {
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read");
- } /* end if */
- else {
- status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata);
-
- if (status < 0) {
- H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
- HDfree(rdata);
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data");
- } /* end if */
- else {
- max_len = 1;
- for (i=0; i < n; i++) {
- if ((rdata + i)->len > max_len)
- max_len = (rdata + i)->len;
- }
-
- size = H5Tget_size(tid) * max_len;
- HDmemset(&h5str, 0, sizeof(h5str_t));
- h5str_new(&h5str, 4 * size);
-
- if (h5str.s == NULL) {
- H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
- HDfree(rdata);
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buf");
- } /* end if */
- else {
- for (i=0; i < n; i++) {
- h5str.s[0] = '\0';
- h5str_sprintf(&h5str, did, tid, rdata+i, 0);
- jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
- ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
- } /* end for */
- h5str_free(&h5str);
-
- H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
- HDfree(rdata);
- } /* end else */
- } /* end else */
- } /* end else */
-
- return status;
-}
-
-/*
- * Class: hdf_hdf5lib_H5
* Method: H5Dread_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
@@ -1218,6 +1129,120 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1string */
+/*
+ * Class: hdf_hdf5lib_H5
+ * Method: H5DreadVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DreadVL
+ (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 isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5DreadVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ status = H5DreadVL_asstr(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);
+ }
+ else if (isStr > 0) {
+ 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 else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */
+
+herr_t
+H5DreadVL_asstr
+ (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
+{
+ jint i;
+ jint n;
+ jstring jstr;
+ h5str_t h5str;
+ hvl_t *rdata;
+ size_t size;
+ size_t max_len = 0;
+ herr_t status = -1;
+
+ /* Get size of string array */
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ /* we will need to read n number of hvl_t structures */
+ rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+ if (rdata == NULL) {
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buff for read");
+ } /* end if */
+ else {
+ status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata);
+
+ if (status < 0) {
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to read data");
+ } /* end if */
+ else {
+ /* calculate the largest size of all the hvl_t structures read */
+ max_len = 1;
+ for (i=0; i < n; i++) {
+ if ((rdata + i)->len > max_len)
+ max_len = (rdata + i)->len;
+ }
+
+ /* create one malloc to hold largest element */
+ size = H5Tget_size(tid) * max_len;
+ HDmemset(&h5str, 0, sizeof(h5str_t));
+ h5str_new(&h5str, 4 * size);
+
+ if (h5str.s == NULL) {
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buf");
+ } /* end if */
+ else {
+ H5T_class_t tclass = H5Tget_class(tid);
+ /* convert each element to char string */
+ for (i=0; i < n; i++) {
+ h5str.s[0] = '\0';
+ h5str_vlsprintf(&h5str, did, tid, rdata+i, 0);
+ jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
+ ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
+ } /* end for */
+ h5str_free(&h5str);
+
+ H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
+ HDfree(rdata);
+ } /* end else */
+ } /* end else */
+ } /* end else */
+
+ return status;
+}
+
/**
* Read VLEN data into array of arrays.
* Object[] buf contains VL arrays of data points
@@ -1305,6 +1330,108 @@ H5DreadVL_str
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5DwriteVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DwriteVL
+ (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 isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5DwriteVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ h5unimplemented(env, "H5DwriteVL: VL types, which are not string type, not implemented");
+ status = -1;
+#ifdef notdef
+ status = H5DwriteVL_asstr(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);
+#endif
+ }
+ else if (isStr > 0) {
+ 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 else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */
+
+herr_t
+H5DwriteVL_asstr
+ (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ hvl_t *wdata;
+ jsize size;
+ jint i;
+ jint n;
+
+ /* Get size of string array */
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ wdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+
+ if (wdata == NULL) {
+ h5JNIFatalError(env, "H5DwriteVL_asstr: failed to allocate buff for write");
+ } /* end if */
+ else {
+ for (i = 0; i < n; ++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) {
+ h5str_vlconvert(utf8, did, tid, wdata+i, 0);
+ } /* end if */
+
+ ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
+ ENVPTR->DeleteLocalRef(ENVPAR obj);
+ } /* end if */
+ } /* end for (i = 0; i < size; ++i) */
+
+ status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, wdata);
+
+ /* now free memory*/
+ for (i = 0; i < n; i++) {
+ if(wdata+i) {
+ HDfree(wdata+i);
+ } /* end if */
+ } /* end for */
+ HDfree(wdata);
+
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+
+ return status;
+} /* end H5DwriteVL_asstr */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Dwrite_VLStrings
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
@@ -1347,7 +1474,7 @@ H5DwriteVL_str
wdata = (char**)HDmalloc((size_t)size * sizeof (char*));
if (!wdata) {
- h5JNIFatalError(env, "H5DwriteVL_string: cannot allocate buffer");
+ h5JNIFatalError(env, "H5DwriteVL_str: cannot allocate buffer");
} /* end if */
else {
HDmemset(wdata, 0, (size_t)size * sizeof(char*));
@@ -1433,7 +1560,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
h5str_new(&h5str, 1024);
for (i=0; i<n; i++) {
h5str.s[0] = '\0';
- h5str_sprintf(&h5str, did, tid, ref_data[i], 0);
+ h5str_sprintf(&h5str, did, tid, ref_data[i], 0, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h
index 3cf24fe..1fe71a8 100644
--- a/java/src/jni/h5dImp.h
+++ b/java/src/jni/h5dImp.h
@@ -213,6 +213,15 @@ Java_hdf_hdf5lib_H5_H5DreadVL
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5DwriteVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DwriteVL
+(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Dread_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c
index 24ddcbc..10a02b0 100644
--- a/java/src/jni/h5eImp.c
+++ b/java/src/jni/h5eImp.c
@@ -508,8 +508,12 @@ H5E_walk_cb
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);
+ if (cb_info_t == NULL) {
+ printf("FATAL ERROR: hdf/hdf5lib/structs/H5E_error2_t: Creation failed\n");
+ }
+ else {
+ 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) */
diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c
index ac71845..f1734fd 100644
--- a/java/src/jni/h5lImp.c
+++ b/java/src/jni/h5lImp.c
@@ -574,8 +574,12 @@ H5L_iterate_cb
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);
+ if (cb_info_t == NULL) {
+ printf("FATAL ERROR: hdf/hdf5lib/structs/H5L_info_t: Creation failed\n");
+ }
+ else {
+ status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data);
+ }
} /* end if */
} /* end if */
} /* end if */
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index e8abead..6093e46 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -105,11 +105,11 @@ Java_hdf_hdf5lib_H5_H5Ocopy
/*
* Class: hdf_hdf5lib_H5
* Method: H5Oget_info
- * Signature: (J)Lhdf/hdf5lib/structs/H5O_info_t;
+ * Signature: (JI)Lhdf/hdf5lib/structs/H5O_info_t;
*/
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Oget_1info
- (JNIEnv *env, jclass clss, jlong loc_id)
+ (JNIEnv *env, jclass clss, jlong loc_id, jint fields)
{
herr_t status = -1;
H5O_info_t infobuf;
@@ -119,7 +119,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1info
jobject ihinfobuf2;
jobject ret_obj = NULL;
- status = H5Oget_info((hid_t)loc_id, &infobuf);
+ status = H5Oget_info2((hid_t)loc_id, &infobuf, (unsigned)fields);
if (status < 0) {
h5libraryError(env);
@@ -168,11 +168,11 @@ 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;
+ * Signature: (JLjava/lang/String;IJ)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)
+ (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id)
{
const char *lName;
herr_t status = -1;
@@ -185,7 +185,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- status = H5Oget_info_by_name((hid_t)loc_id, lName, &infobuf, (hid_t)access_id);
+ status = H5Oget_info_by_name2((hid_t)loc_id, lName, &infobuf, (unsigned)fields, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
@@ -237,12 +237,12 @@ 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;
+ * Signature: (JLjava/lang/String;IIJIJ)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)
+ jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id)
{
const char *lName;
herr_t status;
@@ -255,7 +255,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx
PIN_JAVA_STRING(name, lName);
if (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);
+ status = H5Oget_info_by_idx2((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
@@ -372,41 +372,58 @@ H5O_iterate_cb
constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(IIIIJJJJJJ)V");
if (constructor != 0) {
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) {
- // get a reference to the constructor; the name is <init>
- constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(JJ)V");
- if (constructor != 0) {
- 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) {
- // 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) {
- cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args);
-
- status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data);
+ if (hdrinfobuf == NULL) {
+ printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_hdr_info_t: Creation failed\n");
+ }
+ else {
+ 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) {
+ // get a reference to the constructor; the name is <init>
+ constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "<init>", "(JJ)V");
+ if (constructor != 0) {
+ ihinfobuf1 = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args);
+ if (ihinfobuf1 == NULL) {
+ printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n");
+ }
+ else {
+ 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);
+ if (ihinfobuf2 == NULL) {
+ printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n");
+ }
+ else {
+ 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) {
+ // 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) {
+ cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args);
+ if (cb_info_t == NULL) {
+ printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n");
+ }
+ else {
+ status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data);
+ }
+ }
+ }
+ }
}
}
}
@@ -423,12 +440,12 @@ H5O_iterate_cb
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ovisit
- * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I
+ * Signature: (JIILjava/lang/Object;Ljava/lang/Object;I)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)
+ jobject callback_op, jobject op_data, jint fields)
{
herr_t status = -1;
@@ -442,7 +459,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit
h5nullArgument(env, "H5Ovisit: callback_op is NULL");
} /* end if */
else {
- 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);
+ status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields);
if (status < 0)
h5libraryError(env);
@@ -454,12 +471,12 @@ 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
+ * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;IJ)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)
+ jobject callback_op, jobject op_data, jint fields, jlong access_id)
{
herr_t status = -1;
const char *lName;
@@ -478,7 +495,7 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
else {
PIN_JAVA_STRING(name, lName);
if (lName != NULL) {
- 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);
+ status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)op_data, (unsigned)fields, (hid_t)access_id);
UNPIN_JAVA_STRING(name, lName);
diff --git a/java/src/jni/h5oImp.h b/java/src/jni/h5oImp.h
index 224f298..cb8c776 100644
--- a/java/src/jni/h5oImp.h
+++ b/java/src/jni/h5oImp.h
@@ -52,29 +52,29 @@ Java_hdf_hdf5lib_H5_H5Ocopy
/*
* Class: hdf_hdf5lib_H5
* Method: H5Oget_info
- * Signature: (J)Lhdf/hdf5lib/structs/H5O_info_t;
+ * Signature: (JI)Lhdf/hdf5lib/structs/H5O_info_t;
*/
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Oget_1info
-(JNIEnv*, jclass, jlong);
+(JNIEnv*, jclass, jlong, jint fields);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Oget_info_by_name
- * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5O_info_t;
+ * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_info_t;
*/
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name
-(JNIEnv*, jclass, jlong, jstring, jlong);
+(JNIEnv*, jclass, jlong, jstring, jint fields, jlong);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Oget_info_by_idx
- * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5O_info_t;
+ * Signature: (JLjava/lang/String;IIJIJ)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);
+(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jint fields, jlong);
/*
* Class: hdf_hdf5lib_H5
@@ -88,20 +88,20 @@ Java_hdf_hdf5lib_H5_H5Olink
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ovisit
- * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I
+ * Signature: (JIILjava/lang/Object;Ljava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Ovisit
- (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject);
+ (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject, jint);
/*
* Class: hdf_hdf5lib_H5
* Method: H5Ovisit_by_name
- * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I
+ * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;IJ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name
- (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jlong);
+ (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jint, jlong);
/*
* Class: hdf_hdf5lib_H5
diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c
index 49cfeb9..3ff7436 100644
--- a/java/src/jni/h5pImp.c
+++ b/java/src/jni/h5pImp.c
@@ -5204,10 +5204,10 @@ Java_hdf_hdf5lib_H5_H5Pset_1append_1flush
visit_callback = callback_op;
if (op_data == NULL) {
- h5nullArgument(env, "H5Ovisit: op_data is NULL");
+ h5nullArgument(env, "H5Pset_append_flush: op_data is NULL");
} /* end if */
else if (callback_op == NULL) {
- h5nullArgument(env, "H5Ovisit: callback_op is NULL");
+ h5nullArgument(env, "H5Pset_append_flush: callback_op is NULL");
} /* end if */
else {
status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t*)boundary, (H5D_append_cb_t)H5D_append_cb, (void*)op_data);
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index fdabd76..33dca7f 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -21,6 +21,7 @@
extern "C" {
#endif /* __cplusplus */
+#include <jni.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -152,6 +153,513 @@ h5str_append
return HDstrcat(str->s, cstr);
} /* end h5str_append */
+/** print value of a vlen 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_vlconvert
+ (char *str, hid_t container, hid_t tid, hvl_t *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;
+ 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;
+
+ this_str = NULL;
+ this_strlen = 0;
+
+ switch (tclass) {
+ case H5T_COMPOUND:
+ {
+ unsigned i;
+ n = H5Tget_nmembers(tid);
+
+ /* remove compound indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == '{')
+ str++;
+
+ ptr->p = HDcalloc((size_t)1, size);
+ ptr->len = size;
+ for (i = 0; i < n; i++) {
+ offset = H5Tget_member_offset(tid, i);
+ mtid = H5Tget_member_type(tid, i);
+ str += offset;
+ h5str_convert(&str, container, mtid, ptr, 0, expand_data);
+ /* remove compound indicators */
+ if (str[0] == ',')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ H5Tclose(mtid);
+ }
+ /* remove compound indicators */
+ if (str[0] == '}')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ case H5T_ARRAY:
+ {
+ int rank = 0;
+ hsize_t i, dims[H5S_MAX_RANK], total_elmts;
+
+ /* remove array indicators */
+ if (str[0] == '[')
+ str++;
+ if (str[0] == ' ')
+ 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];
+
+ ptr->p = HDcalloc((size_t)total_elmts, size);
+ ptr->len = total_elmts;
+ h5str_convert(&str, container, mtid, ptr, 0, expand_data);
+ H5Tclose(mtid);
+ /* remove array indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == ']')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ default:
+ ptr->len = size;
+ ptr->p = HDcalloc(1, size);
+ this_strlen = h5str_convert(&str, container, tid, ptr, 0, expand_data);
+ break;
+ } /* end switch */
+
+ return this_strlen;
+} /* end h5str_vlconvert */
+
+/** 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_convert
+ (char **str, hid_t container, hid_t tid, hvl_t *ptr, int ptroffset, 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];
+ const char delimiter[] = " ,}]";
+
+ char *token;
+ hid_t mtid = -1;
+ size_t offset;
+ size_t nll;
+ char *this_str = *str;
+ size_t this_strlen;
+ int n;
+ char *cptr = ((char*) ((hvl_t *) ptr)->p) + ptroffset;
+ unsigned char *ucptr = ((unsigned char*) ((hvl_t *) ptr)->p) + ptroffset;
+ 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_strlen = HDstrlen(this_str);
+
+ switch (tclass) {
+ case H5T_FLOAT:
+ token = HDstrtok (this_str, delimiter);
+ if (sizeof(float) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */
+ tmp_float = 0;
+ sscanf(token, "%f", &tmp_float);
+ HDmemcpy(cptr, &tmp_float, sizeof(float));
+ }
+ else if (sizeof(double) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */
+ tmp_double = 0;
+ sscanf(token, "%%lf", &tmp_double);
+ HDmemcpy(cptr, &tmp_double, sizeof(double));
+ }
+#if H5_SIZEOF_LONG_DOUBLE !=0
+ else if (sizeof(long double) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */
+ tmp_ldouble = 0;
+ sscanf(token, "%Lf", &tmp_ldouble);
+ HDmemcpy(cptr, &tmp_ldouble, sizeof(long double));
+ }
+#endif
+ break;
+ case H5T_STRING:
+ {
+ if (this_strlen > 0) {
+ HDstrncpy(cptr, this_str, size);
+ }
+ else {
+ cptr = NULL;
+ }
+ }
+ break;
+ case H5T_INTEGER:
+ token = HDstrtok (this_str, delimiter);
+ if (sizeof(char) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */
+ tmp_uchar = 0;
+ sscanf(token, "%hu", &tmp_uchar);
+ HDmemcpy(cptr, &tmp_uchar, sizeof(unsigned char));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */
+ tmp_char = 0;
+ sscanf(token, "%hd", &tmp_char);
+ HDmemcpy(cptr, &tmp_char, sizeof(char));
+ }
+ }
+ else if (sizeof(int) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */
+ tmp_uint = 0;
+ sscanf(token, "%u", &tmp_uint);
+ HDmemcpy(cptr, &tmp_uint, sizeof(unsigned int));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_INT)) */
+ tmp_int = 0;
+ sscanf(token, "%d", &tmp_int);
+ HDmemcpy(cptr, &tmp_int, sizeof(int));
+ }
+ }
+ else if (sizeof(short) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */
+ tmp_ushort = 0;
+ sscanf(token, "%u", &tmp_ushort);
+ HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */
+ tmp_short = 0;
+ sscanf(token, "%d", &tmp_short);
+ HDmemcpy(&tmp_short, cptr, sizeof(short));
+ }
+ }
+ else if (sizeof(long) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */
+ tmp_ulong = 0;
+ sscanf(token, "%lu", &tmp_ulong);
+ HDmemcpy(cptr, &tmp_ulong, sizeof(unsigned long));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */
+ tmp_long = 0;
+ sscanf(token, "%ld", &tmp_long);
+ HDmemcpy(cptr, &tmp_long, sizeof(long));
+ }
+ }
+ else if (sizeof(long long) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */
+ tmp_ullong = 0;
+ sscanf(token, fmt_ullong, &tmp_ullong);
+ HDmemcpy(cptr, &tmp_ullong, sizeof(unsigned long long));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */
+ tmp_llong = 0;
+ sscanf(token, fmt_llong, &tmp_llong);
+ HDmemcpy(cptr, &tmp_llong, sizeof(long long));
+ }
+ }
+ break;
+ case H5T_COMPOUND:
+ {
+ unsigned i;
+ n = H5Tget_nmembers(tid);
+ /* remove compound indicators */
+ if ((*str)[0] == ' ')
+ (*str)++;
+ if ((*str)[0] == '{')
+ (*str)++;
+
+ for (i = 0; i < n; i++) {
+ offset = H5Tget_member_offset(tid, i);
+ mtid = H5Tget_member_type(tid, i);
+ h5str_convert(str, container, mtid, ptr, offset, expand_data);
+ /* remove compound indicators */
+ if ((*str)[0] == ',')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+ H5Tclose(mtid);
+ }
+ /* remove compound indicators */
+ if ((*str)[0] == '}')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+ }
+ break;
+ case H5T_ENUM:
+ {
+ char enum_name[1024];
+ void *value;
+ if (sizeof(char) == size) {
+ tmp_uchar = 0;
+ value = &tmp_uchar;
+ }
+ else if (sizeof(short) == size) {
+ tmp_ushort = 0;
+ value = &tmp_ushort;
+ }
+ else if (sizeof(long) == size) {
+ tmp_ulong = 0;
+ value = &tmp_ulong;
+ }
+ else if (sizeof(long long) == size) {
+ tmp_ullong = 0;
+ value = &tmp_ullong;
+ }
+ else {
+ tmp_uint = 0;
+ value = &tmp_uint;
+ }
+ token = HDstrtok (this_str, delimiter);
+ H5Tenum_valueof(tid, token, value);
+ HDmemcpy(ucptr, value, size);
+ }
+ break;
+ case H5T_REFERENCE:
+ /* TODO handle reference writing */
+ cptr = NULL;
+ break;
+ case H5T_ARRAY:
+ {
+ int rank = 0;
+ hsize_t i, dims[H5S_MAX_RANK], total_elmts;
+ /* remove array indicators */
+ if ((*str)[0] == '[')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+
+ mtid = H5Tget_super(tid);
+ offset = 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];
+
+ cptr = HDcalloc((size_t)total_elmts, offset);
+ for (i = 0; i < total_elmts; i++) {
+ h5str_convert(str, container, mtid, cptr + (i*offset), offset, expand_data);
+ /* remove array indicators */
+ if ((*str)[0] == ',')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+ }
+ H5Tclose(mtid);
+ /* remove array indicators */
+ if ((*str)[0] == ' ')
+ (*str)++;
+ if ((*str)[0] == ']')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+ }
+ break;
+ case H5T_VLEN:
+ {
+ unsigned int i;
+ mtid = H5Tget_super(tid);
+ offset = H5Tget_size(mtid);
+
+ /* remove vlen indicators */
+ if ((*str)[0] == '{')
+ (*str)++;
+ cptr = HDcalloc(offset, sizeof(hvl_t));
+ for (i = 0; (i*offset) < (int)size; i++) {
+ h5str_convert(str, container, mtid, cptr + (i*offset), offset, expand_data);
+ /* remove vlen indicators */
+ if ((*str)[0] == ',')
+ (*str)++;
+ if ((*str)[0] == ' ')
+ (*str)++;
+ if ((*str)[0] == '}')
+ break;
+ }
+ H5Tclose(mtid);
+ /* remove vlen indicators */
+ if ((*str)[0] == '}')
+ (*str)++;
+ }
+ break;
+
+ default:
+ {
+ /* All other types get copied raw */
+ HDmemcpy(ucptr, this_str, size);
+ }
+ break;
+ } /* end switch */
+
+ return this_strlen;
+} /* end h5str_convert */
+
+/** print value of a vlen 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_vlsprintf
+ (h5str_t *str, hid_t container, hid_t tid, hvl_t *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;
+ 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_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, ((char *) (ptr->p)) + offset, ptr->len, expand_data);
+ if ((i + 1) < n)
+ h5str_append(str, ", ");
+ H5Tclose(mtid);
+ }
+ h5str_append(str, "} ");
+ }
+ 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];
+
+ h5str_sprintf(str, container, mtid, ((char *) (ptr->p)), ptr->len, expand_data);
+ H5Tclose(mtid);
+ h5str_append(str, " ] ");
+ }
+ break;
+ default:
+ this_strlen = h5str_sprintf(str, container, tid, ((char *) (ptr->p)), ptr->len, expand_data);
+ break;
+ } /* end switch */
+
+ return this_strlen;
+} /* end h5str_vlsprintf */
+
/** print value of a data point into string.
Return Value:
On success, the total number of characters printed is returned.
@@ -159,7 +667,7 @@ h5str_append
*/
size_t
h5str_sprintf
- (h5str_t *str, hid_t container, hid_t tid, void *ptr, int expand_data)
+ (h5str_t *str, hid_t container, hid_t tid, void *ptr, int ptr_len, int expand_data)
{
unsigned char tmp_uchar = 0;
char tmp_char = 0;
@@ -182,9 +690,8 @@ h5str_sprintf
char *this_str;
size_t this_strlen;
int n;
- hvl_t *vlptr;
- char *cptr = (char*) ptr;
- unsigned char *ucptr = (unsigned char*) ptr;
+ 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);
@@ -206,20 +713,20 @@ h5str_sprintf
case H5T_FLOAT:
if (sizeof(float) == size) {
/* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */
- HDmemcpy(&tmp_float, ptr, sizeof(float));
+ HDmemcpy(&tmp_float, cptr, 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));
+ HDmemcpy(&tmp_double, cptr, 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));
+ HDmemcpy(&tmp_ldouble, cptr, sizeof(long double));
this_str = (char*)HDmalloc(27);
sprintf(this_str, "%Lf", tmp_ldouble);
}
@@ -256,13 +763,13 @@ h5str_sprintf
if (sizeof(char) == size) {
if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */
- HDmemcpy(&tmp_uchar, ptr, sizeof(unsigned char));
+ HDmemcpy(&tmp_uchar, cptr, 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));
+ HDmemcpy(&tmp_char, cptr, sizeof(char));
this_str = (char*)HDmalloc(7);
sprintf(this_str, "%hhd", tmp_char);
}
@@ -270,13 +777,13 @@ h5str_sprintf
else if (sizeof(int) == size) {
if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_UINT)) */
- HDmemcpy(&tmp_uint, ptr, sizeof(unsigned int));
+ HDmemcpy(&tmp_uint, cptr, 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));
+ HDmemcpy(&tmp_int, cptr, sizeof(int));
this_str = (char*)HDmalloc(14);
sprintf(this_str, "%d", tmp_int);
}
@@ -284,13 +791,13 @@ h5str_sprintf
else if (sizeof(short) == size) {
if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */
- HDmemcpy(&tmp_ushort, ptr, sizeof(unsigned short));
+ HDmemcpy(&tmp_ushort, cptr, 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));
+ HDmemcpy(&tmp_short, cptr, sizeof(short));
this_str = (char*)HDmalloc(9);
sprintf(this_str, "%d", tmp_short);
}
@@ -298,13 +805,13 @@ h5str_sprintf
else if (sizeof(long) == size) {
if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */
- HDmemcpy(&tmp_ulong, ptr, sizeof(unsigned long));
+ HDmemcpy(&tmp_ulong, cptr, 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));
+ HDmemcpy(&tmp_long, cptr, sizeof(long));
this_str = (char*)HDmalloc(23);
sprintf(this_str, "%ld", tmp_long);
}
@@ -312,13 +819,13 @@ h5str_sprintf
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));
+ HDmemcpy(&tmp_ullong, cptr, 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));
+ HDmemcpy(&tmp_llong, cptr, sizeof(long long));
this_str = (char*)HDmalloc(25);
sprintf(this_str, fmt_llong, tmp_llong);
}
@@ -333,8 +840,8 @@ h5str_sprintf
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_sprintf(str, container, mtid, cptr + offset, ptr_len, expand_data);
+ if ((i + 1) < n)
h5str_append(str, ", ");
H5Tclose(mtid);
}
@@ -344,7 +851,7 @@ h5str_sprintf
case H5T_ENUM:
{
char enum_name[1024];
- if (H5Tenum_nameof(tid, ptr, enum_name, sizeof enum_name) >= 0) {
+ if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) {
h5str_append(str, enum_name);
}
else {
@@ -363,7 +870,7 @@ h5str_sprintf
}
break;
case H5T_REFERENCE:
- if (h5str_is_zero(ptr, size)) {
+ if (h5str_is_zero(cptr, size)) {
h5str_append(str, "NULL");
}
else {
@@ -379,9 +886,9 @@ h5str_sprintf
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);
+ region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr);
if (region_obj >= 0) {
- region = H5Rget_region(container, H5R_DATASET_REGION, ptr);
+ region = H5Rget_region(container, H5R_DATASET_REGION, cptr);
if (region >= 0) {
if(expand_data) {
region_type = H5Sget_select_type(region);
@@ -393,7 +900,7 @@ h5str_sprintf
}
}
else {
- if(H5Rget_name(region_obj, H5R_DATASET_REGION, ptr, (char*)ref_name, 1024) >= 0) {
+ if(H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char*)ref_name, 1024) >= 0) {
h5str_append(str, ref_name);
}
@@ -424,8 +931,8 @@ h5str_sprintf
hid_t obj;
this_str = (char*)HDmalloc(64);
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, ptr);
- H5Oget_info(obj, &oi);
+ obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr);
+ H5Oget_info2(obj, &oi, H5O_INFO_ALL);
/* Print object data and close object */
sprintf(this_str, "%u-%lu", (unsigned) oi.type, oi.addr);
@@ -450,31 +957,30 @@ h5str_sprintf
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_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data);
+ if ((i + 1) < total_elmts)
h5str_append(str, ", ");
}
H5Tclose(mtid);
- h5str_append(str, "] ");
+ 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, ", ");
+ {
+ unsigned int i;
+ mtid = H5Tget_super(tid);
+ size = H5Tget_size(mtid);
+
+ h5str_append(str, "{");
+ for (i = 0; i < (int)ptr_len; i++) {
+ h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data);
+ if ((i + 1) < (int)ptr_len)
+ h5str_append(str, ", ");
+ }
+ H5Tclose(mtid);
+ h5str_append(str, "}");
}
- H5Tclose(mtid);
- }
- break;
+ break;
default:
{
@@ -563,7 +1069,7 @@ h5str_print_region_data_blocks
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);
+ h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 0, 1);
if (numindex + 1 < numelem)
h5str_append(str, ", ");
@@ -763,7 +1269,7 @@ h5str_print_region_data_points
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);
+ h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 0, 1);
if (jndx + 1 < npoints)
h5str_append(str, ", ");
@@ -1883,7 +2389,7 @@ h5tools_dump_simple_data
/* Render the data element*/
h5str_new(&buffer, 32 * size);
- bytes_in = h5str_sprintf(&buffer, container, type, memref, 1);
+ bytes_in = h5str_sprintf(&buffer, container, type, memref, 0, 1);
if(i > 0) {
HDfprintf(stream, ", ");
if (line_count >= H5TOOLS_TEXT_BLOCK) {
@@ -1909,116 +2415,6 @@ h5tools_dump_simple_data
/*
* 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 */
-
-/*
- * Class: hdf_hdf5lib_H5
* Method: H5AreadComplex
* Signature: (JJ[Ljava/lang/String;)I
*/
@@ -2059,7 +2455,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex
else {
for (i = 0; i < n; i++) {
h5str.s[0] = '\0';
- h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0);
+ h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */
@@ -2552,7 +2948,7 @@ obj_info_all
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);
+ retVal = H5Oget_info_by_name2(loc_id, name, &object_info, H5O_INFO_ALL, H5P_DEFAULT);
if (retVal < 0) {
*(datainfo->otype+datainfo->count) = -1;
@@ -2591,7 +2987,7 @@ obj_info_max
info_all_t *datainfo = (info_all_t*)op_data;
H5O_info_t object_info;
- retVal = H5Oget_info(loc_id, &object_info);
+ retVal = H5Oget_info2(loc_id, &object_info, H5O_INFO_ALL);
if (retVal < 0) {
*(datainfo->otype+datainfo->count) = -1;
*(datainfo->ltype+datainfo->count) = -1;
diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h
index 434a107..23bc424 100644
--- a/java/src/jni/h5util.h
+++ b/java/src/jni/h5util.h
@@ -39,7 +39,10 @@ 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 size_t h5str_vlsprintf(h5str_t *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data);
+extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int ptrlen, int expand_data);
+extern size_t h5str_vlsconvert(char *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data);
+extern size_t h5str_convert(char **str, hid_t container, hid_t tid, hvl_t *buf, int ptroffset, 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);
@@ -47,24 +50,6 @@ extern int h5str_dump_region_points_data(h5str_t *str, hid_t region, hid_t r
/*
* 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);
-
-/*
- * Class: hdf_hdf5lib_H5
* Method: H5AreadComplex
* Signature: (JJ[Ljava/lang/String;)I
*/