summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-07-25 22:17:48 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-07-25 22:17:48 (GMT)
commitdd27fe612cf9c80d223939a46a96202eaf81f60d (patch)
tree0deae7b9c4824be7e84aa7e232a529a9ae125c60 /tools
parentc04144fb39b6d7a489c37e89ac8a0240991026a6 (diff)
downloadhdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.zip
hdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.tar.gz
hdf5-dd27fe612cf9c80d223939a46a96202eaf81f60d.tar.bz2
[svn-r22602]
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/h5tools.c355
-rw-r--r--tools/lib/h5tools.h3
-rw-r--r--tools/lib/h5tools_dump.c4
-rw-r--r--tools/lib/h5tools_str.c873
4 files changed, 639 insertions, 596 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 24aa81a..c7ff2d3 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1064,37 +1064,6 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
}
/*-------------------------------------------------------------------------
- * Function: do_bin_output
- *
- * Purpose: Dump memory buffer to a binary file stream
- *
- * Return: Success: SUCCEED
- * Failure: FAIL
- *-------------------------------------------------------------------------
- */
-int
-do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
-{
- HERR_INIT(int, SUCCEED)
- unsigned char *mem = (unsigned char*)_mem;
- size_t size; /* datum size */
- hsize_t i; /* element counter */
-
- if((size = H5Tget_size(tid)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
-
- for (i = 0; i < nelmts; i++) {
- if (render_bin_output(stream, container, tid, mem + i * size) < 0) {
- HDfprintf(err_stream,"\nError in writing binary stream\n");
- return FAIL;
- }
- }
-
-CATCH
- return ret_value;
-}
-
-/*-------------------------------------------------------------------------
* Function: render_bin_output
*
* Purpose: Write one element of memory buffer to a binary file stream
@@ -1103,6 +1072,8 @@ CATCH
* Failure: FAIL
*-------------------------------------------------------------------------
*/
+
+#ifdef DEBUG_H5DUMP_BIN
int
render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
{
@@ -1124,44 +1095,27 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
#if H5_SIZEOF_LONG_DOUBLE !=0
long double templdouble;
#endif
-#ifdef DEBUG_H5DUMP_BIN
static char fmt_llong[8], fmt_ullong[8];
if (!fmt_llong[0]) {
HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
}
-#endif
if((size = H5Tget_size(tid)) == 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
if (H5Tequal(tid, H5T_NATIVE_FLOAT)) {
HDmemcpy(&tempfloat, mem, sizeof(float));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%g ", tempfloat);
-#else
- if (1 != HDfwrite(&tempfloat, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) {
HDmemcpy(&tempdouble, mem, sizeof(double));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%g ", tempdouble);
-#else
- if (1 != HDfwrite(&tempdouble, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
#if H5_SIZEOF_LONG_DOUBLE !=0
else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) {
HDmemcpy(&templdouble, mem, sizeof(long double));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%Lf ", templdouble);
-#else
- if (1 != HDfwrite(&templdouble, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
#endif
else if (H5T_STRING == H5Tget_class(tid)) {
@@ -1183,160 +1137,75 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
}
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%d", tempuchar);
-#else
- if (1 != HDfwrite(&tempuchar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
} /* i */
}
else if (H5Tequal(tid, H5T_NATIVE_INT)) {
HDmemcpy(&tempint, mem, sizeof(int));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%d ", tempint);
-#else
- if (1 != HDfwrite(&tempint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_UINT)) {
HDmemcpy(&tempuint, mem, sizeof(unsigned int));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%u ", tempuint);
-#else
- if (1 != HDfwrite(&tempuint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) {
HDmemcpy(&tempschar, mem, sizeof(char));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%d ", tempschar);
-#else
- if (1 != HDfwrite(&tempschar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) {
HDmemcpy(&tempuchar, mem, sizeof(unsigned char));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%u ", tempuchar);
-#else
- if (1 != HDfwrite(&tempuchar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_SHORT)) {
HDmemcpy(&tempshort, mem, sizeof(short));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%d ", tempshort);
-#else
- if (1 != HDfwrite(&tempshort, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_USHORT)) {
HDmemcpy(&tempushort, mem, sizeof(unsigned short));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%u ", tempushort);
-#else
- if (1 != HDfwrite(&tempushort, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_LONG)) {
HDmemcpy(&templong, mem, sizeof(long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%ld ", templong);
-#else
- if (1 != HDfwrite(&templong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_ULONG)) {
HDmemcpy(&tempulong, mem, sizeof(unsigned long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%lu ", tempulong);
-#else
- if (1 != HDfwrite(&tempulong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_LLONG)) {
HDmemcpy(&templlong, mem, sizeof(long long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, fmt_llong, templlong);
-#else
- if (1 != HDfwrite(&templlong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) {
HDmemcpy(&tempullong, mem, sizeof(unsigned long long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, fmt_ullong, tempullong);
-#else
- if (1 != HDfwrite(&tempullong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) {
if (sizeof(hssize_t) == sizeof(int)) {
HDmemcpy(&tempint, mem, sizeof(int));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%d ", tempint);
-#else
- if (1 != HDfwrite(&tempint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (sizeof(hssize_t) == sizeof(long)) {
HDmemcpy(&templong, mem, sizeof(long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%ld ", templong);
-#else
- if (1 != HDfwrite(&templong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else {
HDmemcpy(&templlong, mem, sizeof(long long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, fmt_llong, templlong);
-#else
- if (1 != HDfwrite(&templlong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
}
else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) {
if (sizeof(hsize_t) == sizeof(int)) {
HDmemcpy(&tempuint, mem, sizeof(unsigned int));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%u ", tempuint);
-#else
- if (1 != HDfwrite(&tempuint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else if (sizeof(hsize_t) == sizeof(long)) {
HDmemcpy(&tempulong, mem, sizeof(unsigned long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%lu ", tempulong);
-#else
- if (1 != HDfwrite(&tempulong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else {
HDmemcpy(&tempullong, mem, sizeof(unsigned long long));
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, fmt_ullong, tempullong);
-#else
- if (1 != HDfwrite(&tempullong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
}
else if (H5Tget_class(tid) == H5T_COMPOUND) {
@@ -1360,21 +1229,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
else if (H5Tget_class(tid) == H5T_ENUM) {
unsigned int i;
if (1 == size) {
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "0x%02x", mem[0]);
-#else
- if (1 != HDfwrite(&mem[0], size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else {
for (i = 0; i < size; i++) {
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%s%02x", i?":":"", mem[i]);
-#else
- if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
} /*i*/
}/*else 1 */
}
@@ -1450,21 +1309,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
else {
size_t i;
if (1 == size) {
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "0x%02x", mem[0]);
-#else
- if (1 != HDfwrite(&mem[0], size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
}
else {
for (i = 0; i < size; i++) {
-#ifdef DEBUG_H5DUMP_BIN
HDfprintf(stream, "%s%02x", i?":":"", mem[i]);
-#else
- if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
} /*i*/
}/*else 1 */
}
@@ -1472,6 +1321,190 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
CATCH
return ret_value;
}
+#else
+int
+render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts)
+{
+ HERR_INIT(int, SUCCEED)
+ 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)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+
+ if((type_class = H5Tget_class(tid)) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
+
+ 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 = HDfwrite(mem, 1, bytes_in, stream);
+
+ if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream)))
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+
+ 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 = _mem + block_index * size;
+
+ if (H5Tis_variable_str(tid)) {
+ s = *(char**) mem;
+ if (s != NULL)
+ size = HDstrlen(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 != HDfwrite(&tempuchar, size, 1, stream))
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+ } /* i */
+ } /* 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 = H5Tget_nmembers(tid);
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = _mem + block_index * size;
+ for (j = 0; j < nmembs; j++) {
+ offset = H5Tget_member_offset(tid, j);
+ memb = H5Tget_member_type(tid, j);
+
+ if (render_bin_output(stream, container, memb, mem + offset, 1) < 0)
+ return FAIL;
+
+ H5Tclose(memb);
+ }
+ }
+ }
+ 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);
+ HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+
+ /* 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 = _mem + block_index * size;
+ /* dump the array element */
+ if (render_bin_output(stream, container, memb, mem, nelmts) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
+ }
+ 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 = _mem + block_index * size;
+ /* Get the number of sequence elements */
+ nelmts = ((hvl_t *) mem)->len;
+
+ /* dump the array element */
+ if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
+ }
+ H5Tclose(memb);
+ }
+ break;
+ case H5T_REFERENCE:
+ {
+ if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ if (region_output) {
+ /* region data */
+ hid_t region_id, region_space;
+ H5S_sel_type region_type;
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = _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)
+ render_bin_output_region_points(region_space, region_id, stream, container);
+ else
+ render_bin_output_region_blocks(region_space, region_id, stream, container);
+ H5Sclose(region_space);
+ } /* end if (region_space >= 0) */
+ H5Dclose(region_id);
+ } /* end if (region_id >= 0) */
+ }
+ } /* end if (region_output... */
+ }
+ else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ ;
+ }
+ }
+ break;
+ default:
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = _mem + block_index * size;
+ if (size != HDfwrite(mem, sizeof(char), size, stream))
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
+ }
+ break;
+ }
+
+CATCH
+ return ret_value;
+}
+#endif
/*-------------------------------------------------------------------------
* Audience: Public
@@ -1552,12 +1585,8 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
- for (numindex = 0; numindex < numelem; numindex++) {
-
- render_bin_output(stream, container, type_id,
- ((char*)region_buf + numindex * type_size));
- /* Render the region data element end */
- } /* end for (jndx = 0; jndx < numelem; jndx++) */
+ render_bin_output(stream, container, type_id, (char*)region_buf, numelem);
+ /* Render the region data element end */
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
done:
@@ -1684,12 +1713,10 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
- for (jndx = 0; jndx < npoints; jndx++) {
- if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
+ HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
- render_bin_output(stream, container, type_id, ((char*)region_buf + jndx * type_size));
- } /* end for (jndx = 0; jndx < npoints; jndx++) */
+ render_bin_output(stream, container, type_id, (char*)region_buf, npoints);
done:
HDfree(region_buf);
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 0f4b271..3e3a4cf 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -560,8 +560,7 @@ H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *i
H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
-H5TOOLS_DLL int do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
-H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem);
+H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 0c0a49f..c2add9a 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -282,7 +282,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
/* binary dump */
if (bin_output) {
- do_bin_output(rawdatastream, rawoutstream, container, nelmts, type, _mem);
+ if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) {
+ HDfprintf(rawoutstream,"\nError in writing binary stream\n");
+ }
} /* end if */
else {
/* setup */
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 0de126d..1646351 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -693,6 +693,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
unsigned nmembs;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
+ H5T_class_t type_class;
/*
* some tempvars to store the value before we append it to the string to
@@ -729,480 +730,494 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
}
}
}
- else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- float tempfloat;
+ else {
+ if((type_class = H5Tget_class(type)) < 0)
+ return NULL;
+ switch (type_class) {
+ case H5T_FLOAT:
+ if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
+ float tempfloat;
- HDmemcpy(&tempfloat, vp, sizeof(float));
- h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
- }
- else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- double tempdouble;
+ HDmemcpy(&tempfloat, vp, sizeof(float));
+ h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
+ double tempdouble;
- HDmemcpy(&tempdouble, vp, sizeof(double));
- h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
+ HDmemcpy(&tempdouble, vp, sizeof(double));
+ h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
#if H5_SIZEOF_LONG_DOUBLE !=0
- }
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
- long double templdouble;
+ }
+ else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
+ long double templdouble;
- HDmemcpy(&templdouble, vp, sizeof(long double));
- h5tools_str_append(str, "%Lf", templdouble);
+ HDmemcpy(&templdouble, vp, sizeof(long double));
+ h5tools_str_append(str, "%Lf", templdouble);
#endif
- }
- else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
- H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, (char) (*ucp_vp));
- }
- else if (H5T_STRING == H5Tget_class(type)) {
- unsigned int i;
- char quote = '\0';
- char *s;
-
- quote = '\0';
- if (H5Tis_variable_str(type)) {
- /* cp_vp is the pointer into the struct where a `char*' is stored. So we have
- * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
- s = *(char**) cp_vp;
- if (s != NULL)
- size = HDstrlen(s);
- }
- else {
- s = cp_vp;
- size = H5Tget_size(type);
- }
- pad = H5Tget_strpad(type);
-
- /* Check for NULL pointer for string */
- if (s == NULL) {
- h5tools_str_append(str, "NULL");
- }
- else {
- for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
- int j = 1;
-
- /*
- * Count how many times the next character repeats. If the
- * threshold is zero then that means it can repeat any number
- * of times.
- */
- if (info->str_repeat > 0)
- while (i + j < size && s[i] == s[i + j])
- j++;
-
- /*
- * Print the opening quote. If the repeat count is high enough to
- * warrant printing the number of repeats instead of enumerating
- * the characters, then make sure the character to be repeated is
- * in it's own quote.
- */
- if (info->str_repeat > 0 && j > info->str_repeat) {
- if (quote)
- h5tools_str_append(str, "%c", quote);
-
- quote = '\'';
- h5tools_str_append(str, "%s%c", i ? " " : "", quote);
}
- else if (!quote) {
- quote = '"';
- h5tools_str_append(str, "%s%c", i ? " " : "", quote);
- }
-
- /* Print the character */
- h5tools_print_char(str, info, s[i]);
+ break;
+ case H5T_STRING:
+ {
+ unsigned int i;
+ char quote = '\0';
+ char *s;
- /* Print the repeat count */
- if (info->str_repeat && j > info->str_repeat) {
+ quote = '\0';
+ if (H5Tis_variable_str(type)) {
+ /* cp_vp is the pointer into the struct where a `char*' is stored. So we have
+ * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
+ s = *(char**) cp_vp;
+ if (s != NULL) size = HDstrlen(s);
+ }
+ else {
+ s = cp_vp;
+ size = H5Tget_size(type);
+ }
+ pad = H5Tget_strpad(type);
+
+ /* Check for NULL pointer for string */
+ if (s == NULL) {
+ h5tools_str_append(str, "NULL");
+ }
+ else {
+ for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
+ int j = 1;
+
+ /*
+ * Count how many times the next character repeats. If the
+ * threshold is zero then that means it can repeat any number
+ * of times.
+ */
+ if (info->str_repeat > 0) while (i + j < size && s[i] == s[i + j])
+ j++;
+
+ /*
+ * Print the opening quote. If the repeat count is high enough to
+ * warrant printing the number of repeats instead of enumerating
+ * the characters, then make sure the character to be repeated is
+ * in it's own quote.
+ */
+ if (info->str_repeat > 0 && j > info->str_repeat) {
+ if (quote) h5tools_str_append(str, "%c", quote);
+
+ quote = '\'';
+ h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ }
+ else if (!quote) {
+ quote = '"';
+ h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ }
+
+ /* Print the character */
+ h5tools_print_char(str, info, s[i]);
+
+ /* Print the repeat count */
+ if (info->str_repeat && j > info->str_repeat) {
#ifdef REPEAT_VERBOSE
- h5tools_str_append(str, "%c repeats %d times", quote, j - 1);
+ h5tools_str_append(str, "%c repeats %d times", quote, j - 1);
#else
- h5tools_str_append(str, "%c*%d", quote, j - 1);
+ h5tools_str_append(str, "%c*%d", quote, j - 1);
#endif /* REPEAT_VERBOSE */
- quote = '\0';
- i += j - 1;
- }
+ quote = '\0';
+ i += j - 1;
+ }
- }
+ }
- if (quote)
- h5tools_str_append(str, "%c", quote);
+ if (quote) h5tools_str_append(str, "%c", quote);
- if (i == 0)
- /*empty string*/
- h5tools_str_append(str, "\"\"");
- } /* end else */
- }
- else if (H5Tequal(type, H5T_NATIVE_INT)) {
- HDmemcpy(&tempint, vp, sizeof(int));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(int))
- tempint = 0;
- else
- tempint = (tempint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
- }
- else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned int))
- tempuint = 0;
- else
- tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
- }
- else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- signed char tempchar;
- HDmemcpy(&tempchar, cp_vp, sizeof(char));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(char))
- tempchar = 0;
- else
- tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
- }
+ if (i == 0)
+ /*empty string*/
+ h5tools_str_append(str, "\"\"");
+ } /* end else */
+ }
+ break;
+ case H5T_INTEGER:
+ if (H5Tequal(type, H5T_NATIVE_INT)) {
+ HDmemcpy(&tempint, vp, sizeof(int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(int))
+ tempint = 0;
+ else
+ tempint = (tempint >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_UINT)) {
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned int))
+ tempuint = 0;
+ else
+ tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
+ }
+ else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) {
+ h5tools_print_char(str, info, (char) (*ucp_vp));
+ }
+ else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
+ signed char tempchar;
+ HDmemcpy(&tempchar, cp_vp, sizeof(char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(char))
+ tempchar = 0;
+ else
+ tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
+ }
#ifdef H5_VMS
- h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar);
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar);
#else
- h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
#endif
- }
- else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- unsigned char tempuchar;
- HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned char))
- tempuchar = 0;
- else
- tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
- }
- else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- short tempshort;
-
- HDmemcpy(&tempshort, vp, sizeof(short));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(short))
- tempshort = 0;
- else
- tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
- }
- else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- unsigned short tempushort;
-
- HDmemcpy(&tempushort, vp, sizeof(unsigned short));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned short))
- tempushort = 0;
- else
- tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
- }
- else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- HDmemcpy(&templong, vp, sizeof(long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(long))
- templong = 0;
- else
- templong = (templong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- HDmemcpy(&tempulong, vp, sizeof(unsigned long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned long))
- tempulong = 0;
- else
- tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
- }
- else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- HDmemcpy(&templlong, vp, sizeof(long long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(long long))
- templlong = 0;
- else
- templlong = (templlong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned long long))
- tempullong = 0;
- else
- tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
- }
- else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
- if (sizeof(hssize_t) == sizeof(int)) {
- HDmemcpy(&tempint, vp, sizeof(int));
- h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
- }
- else if (sizeof(hssize_t) == sizeof(long)) {
- HDmemcpy(&templong, vp, sizeof(long));
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
- }
- else {
- HDmemcpy(&templlong, vp, sizeof(long long));
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- }
- else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
- if (sizeof(hsize_t) == sizeof(int)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
- }
- else if (sizeof(hsize_t) == sizeof(long)) {
- HDmemcpy(&tempulong, vp, sizeof(long));
- h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
- }
- else {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
- h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
- }
- }
- else if (H5Tget_class(type) == H5T_COMPOUND) {
- unsigned j;
-
- nmembs = H5Tget_nmembers(type);
- h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
+ }
+ else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
+ unsigned char tempuchar;
+ HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned char))
+ tempuchar = 0;
+ else
+ tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
+ short tempshort;
+
+ HDmemcpy(&tempshort, vp, sizeof(short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(short))
+ tempshort = 0;
+ else
+ tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
+ unsigned short tempushort;
+
+ HDmemcpy(&tempushort, vp, sizeof(unsigned short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned short))
+ tempushort = 0;
+ else
+ tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_LONG)) {
+ HDmemcpy(&templong, vp, sizeof(long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long))
+ templong = 0;
+ else
+ templong = (templong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
+ HDmemcpy(&tempulong, vp, sizeof(unsigned long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long))
+ tempulong = 0;
+ else
+ tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
+ HDmemcpy(&templlong, vp, sizeof(long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long long))
+ templlong = 0;
+ else
+ templlong = (templlong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
+ HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long long))
+ tempullong = 0;
+ else
+ tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
+ }
+ else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
+ if (sizeof(hssize_t) == sizeof(int)) {
+ HDmemcpy(&tempint, vp, sizeof(int));
+ h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
+ }
+ else if (sizeof(hssize_t) == sizeof(long)) {
+ HDmemcpy(&templong, vp, sizeof(long));
+ h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
+ }
+ else {
+ HDmemcpy(&templlong, vp, sizeof(long long));
+ h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
+ }
+ }
+ else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
+ if (sizeof(hsize_t) == sizeof(int)) {
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
+ h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
+ }
+ else if (sizeof(hsize_t) == sizeof(long)) {
+ HDmemcpy(&tempulong, vp, sizeof(long));
+ h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
+ }
+ else {
+ HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
+ h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
+ }
+ }
+ break;
+ case H5T_COMPOUND:
+ {
+ unsigned j;
- ctx->indent_level++;
+ nmembs = H5Tget_nmembers(type);
+ h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
- for (j = 0; j < nmembs; j++) {
- if (j)
- h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK));
- else
- h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+ ctx->indent_level++;
- if(info->arr_linebreak)
- h5tools_str_indent(str, info, ctx);
-
- /* The name */
- name = H5Tget_member_name(type, j);
- h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
- HDfree(name);
+ for (j = 0; j < nmembs; j++) {
+ if (j)
+ h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK));
+ else
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
- /* The value */
- offset = H5Tget_member_offset(type, j);
- memb = H5Tget_member_type(type, j);
+ if (info->arr_linebreak) h5tools_str_indent(str, info, ctx);
- h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx);
+ /* The name */
+ name = H5Tget_member_name(type, j);
+ h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
+ HDfree(name);
- H5Tclose(memb);
- }
- ctx->indent_level--;
+ /* The value */
+ offset = H5Tget_member_offset(type, j);
+ memb = H5Tget_member_type(type, j);
+ h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx);
- if(info->arr_linebreak) {
- h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
- h5tools_str_indent(str, info, ctx);
- }
- h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+ H5Tclose(memb);
+ }
+ ctx->indent_level--;
- }
- else if (H5Tget_class(type) == H5T_ENUM) {
- char enum_name[1024];
+ if (info->arr_linebreak) {
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+ h5tools_str_indent(str, info, ctx);
+ }
+ h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
- if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) {
- h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
- }
- else {
- size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
- h5tools_str_append(str, "0x%02x", ucp_vp[0]);
- }
- else {
- for (i = 0; i < n; i++)
- h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
- }
- }
- }
- else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
- }
- else {
- h5tools_str_sprint_region(str, info, container, vp);
- }
- }
- else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
- /*
- * Object references -- show the type and OID of the referenced
- * object.
- */
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
- }
- else {
- H5O_info_t oi;
- const char *path;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
- H5Oget_info(obj, &oi);
-
- /* Print object type and close object */
- switch (oi.type) {
- case H5O_TYPE_GROUP:
- h5tools_str_append(str, H5_TOOLS_GROUP);
- break;
-
- case H5O_TYPE_DATASET:
- h5tools_str_append(str, H5_TOOLS_DATASET);
+ }
break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ case H5T_ENUM:
+ {
+ char enum_name[1024];
+
+ if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) {
+ h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
+ }
+ else {
+ size_t i;
+ n = H5Tget_size(type);
+ if (1 == n) {
+ h5tools_str_append(str, "0x%02x", ucp_vp[0]);
+ }
+ else {
+ for (i = 0; i < n; i++)
+ h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
+ }
+ }
+ }
break;
-
- default:
- h5tools_str_append(str, "%u-", (unsigned) oi.type);
+ case H5T_REFERENCE:
+ if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
+ h5tools_str_append(str, "NULL");
+ }
+ else {
+ h5tools_str_sprint_region(str, info, container, vp);
+ }
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
+ /*
+ * Object references -- show the type and OID of the referenced
+ * object.
+ */
+ if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
+ h5tools_str_append(str, "NULL");
+ }
+ else {
+ H5O_info_t oi;
+ const char *path;
+
+ obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
+ H5Oget_info(obj, &oi);
+
+ /* Print object type and close object */
+ switch (oi.type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ default:
+ h5tools_str_append(str, "%u-", (unsigned) oi.type);
+ break;
+ } /* end switch */
+ H5Oclose(obj);
+
+ /* Print OID */
+ if (info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, oi.addr);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
+
+ /* Print name */
+ path = lookup_ref_path(*(haddr_t *) vp);
+ if (path) {
+ h5tools_str_append(str, " ");
+ h5tools_str_append(str, path);
+ h5tools_str_append(str, " ");
+ } /* end if */
+ } /* end else */
+ }
break;
- } /* end switch */
- H5Oclose(obj);
-
- /* Print OID */
- if (info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
- else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
-
- /* Print name */
- path = lookup_ref_path(*(haddr_t *) vp);
- if (path) {
- h5tools_str_append(str, " ");
- h5tools_str_append(str, path);
- h5tools_str_append(str, " ");
- } /* end if */
- } /* end else */
- }
- else if (H5Tget_class(type) == H5T_ARRAY) {
- int k, ndims;
- hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
- static int is_next_arry_elmt = 0;
-
- /* Get the array's base datatype for each element */
- memb = H5Tget_super(type);
- size = H5Tget_size(memb);
- ndims = H5Tget_array_ndims(type);
- H5Tget_array_dims2(type, dims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* Calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++) {
- temp_nelmts = nelmts;
- temp_nelmts *= dims[k];
- HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts));
- nelmts = (size_t) temp_nelmts;
- }
- /* Print the opening bracket */
- h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));
-
- ctx->indent_level++;
-
- for (i = 0; i < nelmts; i++) {
- if (i)
- h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
-
- if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
- h5tools_str_append(str, "%s", "\n");
- h5tools_str_indent(str, info, ctx);
-
- } /* end if */
- else if (i && info->arr_sep) {
- /* if next element begin, add next line with indent */
- if (is_next_arry_elmt) {
- is_next_arry_elmt = 0;
-
- h5tools_str_append(str, "%s", "\n ");
- h5tools_str_indent(str, info, ctx);
-
+ case H5T_ARRAY:
+ {
+ int k, ndims;
+ hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
+ static int is_next_arry_elmt = 0;
+
+ /* Get the array's base datatype for each element */
+ memb = H5Tget_super(type);
+ size = H5Tget_size(memb);
+ ndims = H5Tget_array_ndims(type);
+ H5Tget_array_dims2(type, dims);
+ HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+
+ /* Calculate the number of array elements */
+ for (k = 0, nelmts = 1; k < ndims; k++) {
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts));
+ nelmts = (size_t) temp_nelmts;
+ }
+ /* Print the opening bracket */
+ h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));
+
+ ctx->indent_level++;
+
+ for (i = 0; i < nelmts; i++) {
+ if (i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
+
+ if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
+ h5tools_str_append(str, "%s", "\n");
+ h5tools_str_indent(str, info, ctx);
+
+ } /* end if */
+ else if (i && info->arr_sep) {
+ /* if next element begin, add next line with indent */
+ if (is_next_arry_elmt) {
+ is_next_arry_elmt = 0;
+
+ h5tools_str_append(str, "%s", "\n ");
+ h5tools_str_indent(str, info, ctx);
+
+ }
+ /* otherwise just add space */
+ else
+ h5tools_str_append(str, " ");
+
+ } /* end else if */
+
+ /* Dump values in an array element */
+ is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */
+ h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx);
+ } /* end for */
+
+ ctx->indent_level--;
+
+ /* Print the closing bracket */
+ h5tools_str_append(str, "%s", OPT(info->arr_suf, "]"));
+ is_next_arry_elmt = 1; /* set for begining of next array element */
+ H5Tclose(memb);
}
- /* otherwise just add space */
- else
- h5tools_str_append(str, " ");
-
- } /* end else if */
-
- /* Dump values in an array element */
- is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */
- h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx);
- } /* end for */
-
- ctx->indent_level--;
-
- /* Print the closing bracket */
- h5tools_str_append(str, "%s", OPT(info->arr_suf, "]"));
- is_next_arry_elmt = 1; /* set for begining of next array element */
- H5Tclose(memb);
- }
- else if (H5Tget_class(type) == H5T_VLEN) {
- unsigned int i;
+ break;
+ case H5T_VLEN:
+ {
+ unsigned int i;
- /* Get the VL sequences's base datatype for each element */
- memb = H5Tget_super(type);
- size = H5Tget_size(memb);
+ /* Get the VL sequences's base datatype for each element */
+ memb = H5Tget_super(type);
+ size = H5Tget_size(memb);
- /* Print the opening bracket */
- h5tools_str_append(str, "%s", OPT(info->vlen_pre, "("));
+ /* Print the opening bracket */
+ h5tools_str_append(str, "%s", OPT(info->vlen_pre, "("));
- /* Get the number of sequence elements */
- nelmts = ((hvl_t *) cp_vp)->len;
+ /* Get the number of sequence elements */
+ nelmts = ((hvl_t *) cp_vp)->len;
- for (i = 0; i < nelmts; i++) {
- if (i)
- h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK));
+ for (i = 0; i < nelmts; i++) {
+ if (i) h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK));
#ifdef LATER
- /* Need to fix so VL data breaks at correct location on end of line -QAK */
- if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) {
- int x;
+ /* Need to fix so VL data breaks at correct location on end of line -QAK */
+ if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) {
+ int x;
- h5tools_str_append(str, "%s", "\n");
+ h5tools_str_append(str, "%s", "\n");
- /* need to indent some more here */
- if (ctx->indent_level >= 0)
- h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
+ /* need to indent some more here */
+ if (ctx->indent_level >= 0)
+ h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
- for (x = 0; x < ctx->indent_level + 1; x++)
- h5tools_str_append(str,"%s",OPT(info->line_indent,""));
- } /* end if */
+ for (x = 0; x < ctx->indent_level + 1; x++)
+ h5tools_str_append(str,"%s",OPT(info->line_indent,""));
+ } /* end if */
#endif /* LATER */
- ctx->indent_level++;
+ ctx->indent_level++;
- /* Dump the array element */
- h5tools_str_sprint(str, info, container, memb,
- ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx);
+ /* Dump the array element */
+ h5tools_str_sprint(str, info, container, memb, ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx);
- ctx->indent_level--;
- } /* end for */
+ ctx->indent_level--;
+ } /* end for */
- h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")"));
- H5Tclose(memb);
- }
- else {
- /* All other types get printed as hexadecimal */
- size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
- h5tools_str_append(str, "0x%02x", ucp_vp[0]);
- }
- else {
- for (i = 0; i < n; i++)
- h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
- }
- }
+ h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")"));
+ H5Tclose(memb);
+ }
+ break;
+ default:
+ {
+ /* All other types get printed as hexadecimal */
+ size_t i;
+ n = H5Tget_size(type);
+ if (1 == n) {
+ h5tools_str_append(str, "0x%02x", ucp_vp[0]);
+ }
+ else {
+ for (i = 0; i < n; i++)
+ h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
+ }
+ }
+ break;
+ } /* end switch */
+ }
return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
}