summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-09-12 12:05:05 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-09-12 12:05:05 (GMT)
commit801f6a504c1092aa7abb12983ee56a783759ae68 (patch)
tree8f981a7ba69d4bf8adcac728dcfbde285dd9a688 /tools
parente5fa6451ca4a36b9ae87ff8c59b81d66cad6157c (diff)
downloadhdf5-801f6a504c1092aa7abb12983ee56a783759ae68.zip
hdf5-801f6a504c1092aa7abb12983ee56a783759ae68.tar.gz
hdf5-801f6a504c1092aa7abb12983ee56a783759ae68.tar.bz2
[svn-r27763] Merges from trunk:
- tools: 27238, 27252, 27267, 27656 - inline markup: 27278 - bin/bbrelease: 27280, 27283, 27624 - h5vers: 27475 - C++ Doxygen: 27494-6 - FUNC_ENTER macro bug: 27581 - H5is_library_threadsafe: 27587, 27601 - release_docs: 27597 - Autotools freshening: 27641, 27653, 27675, 27686, 27692, 27699, 27722 27731, 27734, 27752 - MANIFEST comments: 27642 Tested on: ostrich & koala various combinations of --enable-threadsafe
Diffstat (limited to 'tools')
-rw-r--r--tools/h5ls/h5ls.c412
-rw-r--r--tools/h5repack/h5repack_parse.c956
-rw-r--r--tools/lib/h5tools_str.c29
3 files changed, 706 insertions, 691 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 3f897df..3609071 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -156,6 +156,8 @@ static struct dispatch_t {
}
static void print_type(h5tools_str_t *buffer, hid_t type, int ind);
+static hbool_t print_int_type(h5tools_str_t *buffer, hid_t type, int ind);
+static hbool_t print_float_type(h5tools_str_t *buffer, hid_t type, int ind);
static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
@@ -295,7 +297,7 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
if (escape_spaces) {
if (buffer) h5tools_str_append(buffer, "\\ ");
nprint += 2;
- }
+ }
else {
if (buffer) h5tools_str_append(buffer, " ");
nprint++;
@@ -305,7 +307,7 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
if (isprint((int)*s)) {
if (buffer) h5tools_str_append(buffer, "%c", *s);
nprint++;
- }
+ }
else {
if (buffer) h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s));
nprint += 4;
@@ -386,102 +388,106 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
*-------------------------------------------------------------------------
*/
static hbool_t
-print_native_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
+print_native_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) {
- h5tools_str_append(buffer, "native signed char");
- } else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) {
- h5tools_str_append(buffer, "native unsigned char");
- } else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) {
- h5tools_str_append(buffer, "native int");
- } else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) {
- h5tools_str_append(buffer, "native unsigned int");
- } else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) {
- h5tools_str_append(buffer, "native short");
- } else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) {
- h5tools_str_append(buffer, "native unsigned short");
- } else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) {
- h5tools_str_append(buffer, "native long");
- } else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) {
- h5tools_str_append(buffer, "native unsigned long");
- } else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) {
- h5tools_str_append(buffer, "native long long");
- } else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) {
- h5tools_str_append(buffer, "native unsigned long long");
- } else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) {
- h5tools_str_append(buffer, "native float");
- } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) {
- h5tools_str_append(buffer, "native double");
+ if(!simple_output_g) {
+ if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) {
+ h5tools_str_append(buffer, "native signed char");
+ } else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) {
+ h5tools_str_append(buffer, "native unsigned char");
+ } else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) {
+ h5tools_str_append(buffer, "native int");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) {
+ h5tools_str_append(buffer, "native unsigned int");
+ } else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) {
+ h5tools_str_append(buffer, "native short");
+ } else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) {
+ h5tools_str_append(buffer, "native unsigned short");
+ } else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) {
+ h5tools_str_append(buffer, "native long");
+ } else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) {
+ h5tools_str_append(buffer, "native unsigned long");
+ } else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) {
+ h5tools_str_append(buffer, "native long long");
+ } else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) {
+ h5tools_str_append(buffer, "native unsigned long long");
+ } else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) {
+ h5tools_str_append(buffer, "native float");
+ } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) {
+ h5tools_str_append(buffer, "native double");
#if H5_SIZEOF_LONG_DOUBLE !=0
- } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) {
- h5tools_str_append(buffer, "native long double");
+ } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) {
+ h5tools_str_append(buffer, "native long double");
#endif
- } else if (H5Tequal(type, H5T_NATIVE_INT8)==TRUE) {
- h5tools_str_append(buffer, "native int8_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT8)==TRUE) {
- h5tools_str_append(buffer, "native uint8_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT16)==TRUE) {
- h5tools_str_append(buffer, "native int16_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT16)==TRUE) {
- h5tools_str_append(buffer, "native uint16_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT32)==TRUE) {
- h5tools_str_append(buffer, "native int32_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT32)==TRUE) {
- h5tools_str_append(buffer, "native uint32_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT64)==TRUE) {
- h5tools_str_append(buffer, "native int64_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT64)==TRUE) {
- h5tools_str_append(buffer, "native uint64_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8)==TRUE) {
- h5tools_str_append(buffer, "native int_least8_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8)==TRUE) {
- h5tools_str_append(buffer, "native uint_least8_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16)==TRUE) {
- h5tools_str_append(buffer, "native int_least16_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16)==TRUE) {
- h5tools_str_append(buffer, "native uint_least16_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32)==TRUE) {
- h5tools_str_append(buffer, "native int_least32_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32)==TRUE) {
- h5tools_str_append(buffer, "native uint_least32_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64)==TRUE) {
- h5tools_str_append(buffer, "native int_least64_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64)==TRUE) {
- h5tools_str_append(buffer, "native uint_least64_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_FAST8)==TRUE) {
- h5tools_str_append(buffer, "native int_fast8_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8)==TRUE) {
- h5tools_str_append(buffer, "native uint_fast8_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_FAST16)==TRUE) {
- h5tools_str_append(buffer, "native int_fast16_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16)==TRUE) {
- h5tools_str_append(buffer, "native uint_fast16_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_FAST32)==TRUE) {
- h5tools_str_append(buffer, "native int_fast32_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32)==TRUE) {
- h5tools_str_append(buffer, "native uint_fast32_t");
- } else if (H5Tequal(type, H5T_NATIVE_INT_FAST64)==TRUE) {
- h5tools_str_append(buffer, "native int_fast64_t");
- } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64)==TRUE) {
- h5tools_str_append(buffer, "native uint_fast64_t");
- } else if (H5Tequal(type, H5T_NATIVE_B8)==TRUE) {
- h5tools_str_append(buffer, "native 8-bit field");
- } else if (H5Tequal(type, H5T_NATIVE_B16)==TRUE) {
- h5tools_str_append(buffer, "native 16-bit field");
- } else if (H5Tequal(type, H5T_NATIVE_B32)==TRUE) {
- h5tools_str_append(buffer, "native 32-bit field");
- } else if (H5Tequal(type, H5T_NATIVE_B64)==TRUE) {
- h5tools_str_append(buffer, "native 64-bit field");
- } else if (H5Tequal(type, H5T_NATIVE_HSIZE)==TRUE) {
- h5tools_str_append(buffer, "native hsize_t");
- } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)==TRUE) {
- h5tools_str_append(buffer, "native hssize_t");
- } else if (H5Tequal(type, H5T_NATIVE_HERR)==TRUE) {
- h5tools_str_append(buffer, "native herr_t");
- } else if (H5Tequal(type, H5T_NATIVE_HBOOL)==TRUE) {
- h5tools_str_append(buffer, "native hbool_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT8)==TRUE) {
+ h5tools_str_append(buffer, "native int8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT8)==TRUE) {
+ h5tools_str_append(buffer, "native uint8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT16)==TRUE) {
+ h5tools_str_append(buffer, "native int16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT16)==TRUE) {
+ h5tools_str_append(buffer, "native uint16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT32)==TRUE) {
+ h5tools_str_append(buffer, "native int32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT32)==TRUE) {
+ h5tools_str_append(buffer, "native uint32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT64)==TRUE) {
+ h5tools_str_append(buffer, "native int64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT64)==TRUE) {
+ h5tools_str_append(buffer, "native uint64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8)==TRUE) {
+ h5tools_str_append(buffer, "native int_least8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8)==TRUE) {
+ h5tools_str_append(buffer, "native uint_least8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16)==TRUE) {
+ h5tools_str_append(buffer, "native int_least16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16)==TRUE) {
+ h5tools_str_append(buffer, "native uint_least16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32)==TRUE) {
+ h5tools_str_append(buffer, "native int_least32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32)==TRUE) {
+ h5tools_str_append(buffer, "native uint_least32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64)==TRUE) {
+ h5tools_str_append(buffer, "native int_least64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64)==TRUE) {
+ h5tools_str_append(buffer, "native uint_least64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_FAST8)==TRUE) {
+ h5tools_str_append(buffer, "native int_fast8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8)==TRUE) {
+ h5tools_str_append(buffer, "native uint_fast8_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_FAST16)==TRUE) {
+ h5tools_str_append(buffer, "native int_fast16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16)==TRUE) {
+ h5tools_str_append(buffer, "native uint_fast16_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_FAST32)==TRUE) {
+ h5tools_str_append(buffer, "native int_fast32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32)==TRUE) {
+ h5tools_str_append(buffer, "native uint_fast32_t");
+ } else if (H5Tequal(type, H5T_NATIVE_INT_FAST64)==TRUE) {
+ h5tools_str_append(buffer, "native int_fast64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64)==TRUE) {
+ h5tools_str_append(buffer, "native uint_fast64_t");
+ } else if (H5Tequal(type, H5T_NATIVE_B8)==TRUE) {
+ h5tools_str_append(buffer, "native 8-bit field");
+ } else if (H5Tequal(type, H5T_NATIVE_B16)==TRUE) {
+ h5tools_str_append(buffer, "native 16-bit field");
+ } else if (H5Tequal(type, H5T_NATIVE_B32)==TRUE) {
+ h5tools_str_append(buffer, "native 32-bit field");
+ } else if (H5Tequal(type, H5T_NATIVE_B64)==TRUE) {
+ h5tools_str_append(buffer, "native 64-bit field");
+ } else if (H5Tequal(type, H5T_NATIVE_HSIZE)==TRUE) {
+ h5tools_str_append(buffer, "native hsize_t");
+ } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)==TRUE) {
+ h5tools_str_append(buffer, "native hssize_t");
+ } else if (H5Tequal(type, H5T_NATIVE_HERR)==TRUE) {
+ h5tools_str_append(buffer, "native herr_t");
+ } else if (H5Tequal(type, H5T_NATIVE_HBOOL)==TRUE) {
+ h5tools_str_append(buffer, "native hbool_t");
+ } else {
+ return print_int_type(buffer, type, ind);
+ }
} else {
- return FALSE;
+ return print_int_type(buffer, type, ind);
}
return TRUE;
}
@@ -504,22 +510,22 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
*-------------------------------------------------------------------------
*/
static hbool_t
-print_ieee_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
+print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind)
{
if (H5Tequal(type, H5T_IEEE_F32BE)==TRUE) {
h5tools_str_append(buffer, "IEEE 32-bit big-endian float");
- }
+ }
else if (H5Tequal(type, H5T_IEEE_F32LE)==TRUE) {
h5tools_str_append(buffer, "IEEE 32-bit little-endian float");
- }
+ }
else if (H5Tequal(type, H5T_IEEE_F64BE)==TRUE) {
h5tools_str_append(buffer, "IEEE 64-bit big-endian float");
- }
+ }
else if (H5Tequal(type, H5T_IEEE_F64LE)==TRUE) {
h5tools_str_append(buffer, "IEEE 64-bit little-endian float");
- }
+ }
else {
- return FALSE;
+ return print_float_type(buffer, type, ind);
}
return TRUE;
}
@@ -651,17 +657,17 @@ print_int_type(h5tools_str_t *buffer, hid_t type, int ind)
order = H5Tget_order(type);
if (H5T_ORDER_LE==order) {
order_s = " little-endian";
- }
+ }
else if (H5T_ORDER_BE==order) {
order_s = " big-endian";
- }
+ }
else if (H5T_ORDER_VAX==order) {
order_s = " mixed-endian";
- }
+ }
else {
order_s = " unknown-byte-order";
}
- }
+ }
else {
order_s = "";
}
@@ -670,14 +676,14 @@ print_int_type(h5tools_str_t *buffer, hid_t type, int ind)
if ((sign=H5Tget_sign(type))>=0) {
if (H5T_SGN_NONE==sign) {
sign_s = " unsigned";
- }
+ }
else if (H5T_SGN_2==sign) {
sign_s = "";
- }
+ }
else {
sign_s = " unknown-sign";
}
- }
+ }
else {
sign_s = " unknown-sign";
}
@@ -728,17 +734,17 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
order = H5Tget_order(type);
if (H5T_ORDER_LE==order) {
order_s = " little-endian";
- }
+ }
else if (H5T_ORDER_BE==order) {
order_s = " big-endian";
- }
+ }
else if (H5T_ORDER_VAX==order) {
order_s = " mixed-endian";
- }
+ }
else {
order_s = " unknown-byte-order";
}
- }
+ }
else {
order_s = "";
}
@@ -950,13 +956,13 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, "0x");
for(j = 0; j < dst_size; j++)
h5tools_str_append(buffer, "%02x", value[i*dst_size+j]);
- }
+ }
else if(H5T_SGN_NONE == H5Tget_sign(native)) {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
copy = value + i * dst_size;
h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long*)((void*)copy)));
- }
+ }
else {
/*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
*strangely, unless use another pointer "copy".*/
@@ -1075,7 +1081,7 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
if (H5Tis_variable_str(type)) {
h5tools_str_append(buffer, "variable-length");
- }
+ }
else {
h5tools_str_append(buffer, "%lu-byte", (unsigned long)H5Tget_size(type));
}
@@ -1109,10 +1115,10 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
if (H5Tequal(type, H5T_STD_REF_OBJ)==TRUE) {
h5tools_str_append(buffer, "object reference");
- }
+ }
else if (H5Tequal(type, H5T_STD_REF_DSETREG)==TRUE) {
h5tools_str_append(buffer, "dataset region reference");
- }
+ }
else {
h5tools_str_append(buffer, "%lu-byte unknown reference",
(unsigned long)H5Tget_size(type));
@@ -1221,7 +1227,7 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, "]");
HDfree(dims);
- }
+ }
else
h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream);
@@ -1325,10 +1331,8 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind)
} /* end if */
/* Print the type */
- if((!simple_output_g && print_native_type(buffer, type, ind)) ||
+ if(print_native_type(buffer, type, ind) ||
print_ieee_type(buffer, type, ind) ||
- print_int_type(buffer, type, ind) ||
- print_float_type(buffer, type, ind) ||
print_cmpd_type(buffer, type, ind) ||
print_enum_type(buffer, type, ind) ||
print_string_type(buffer, type, ind) ||
@@ -1372,7 +1376,7 @@ dump_dataset_values(hid_t dset)
h5tools_context_t ctx; /* print context */
h5tool_format_t outputformat;
h5tool_format_t *info = &ls_dataformat;
-
+
hid_t f_type = H5Dget_type(dset);
size_t size = H5Tget_size(f_type);
@@ -1403,7 +1407,7 @@ dump_dataset_values(hid_t dset)
outputformat.elmt_suf1 = " ";
outputformat.str_locale = ESCAPE_HTML;
- }
+ }
else {
if (no_line_wrap_g) {
outputformat.line_per_line = 1;
@@ -1423,7 +1427,7 @@ dump_dataset_values(hid_t dset)
outputformat.cmpd_pre = NULL;
outputformat.cmpd_suf = NULL;
outputformat.cmpd_sep = NULL;
-
+
outputformat.vlen_sep = NULL;
outputformat.vlen_pre = NULL;
outputformat.vlen_suf = NULL;
@@ -1440,7 +1444,7 @@ dump_dataset_values(hid_t dset)
/* Print all data in hexadecimal format if the `-x' or `--hexdump'
* command line switch was given. */
outputformat.raw = TRUE;
- }
+ }
else if (string_g && 1==size && H5T_INTEGER==H5Tget_class(f_type)) {
/* Print 1-byte integer data as an ASCI character string instead of
* integers if the `-s' or `--string' command-line option was given. */
@@ -1470,7 +1474,7 @@ dump_dataset_values(hid_t dset)
H5Tclose(f_type);
h5tools_str_close(&buffer);
-
+
PRINTVALSTREAM(rawoutstream, "\n");
}
@@ -1518,7 +1522,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Attribute: ");
-
+
print_string(&buffer, attr_name, TRUE);
if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
@@ -1577,7 +1581,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain
outputformat.line_cont = " ";
outputformat.str_repeat = 8;
- }
+ }
else {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Data:\n");
@@ -1608,7 +1612,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain
outputformat.cmpd_pre = NULL;
outputformat.cmpd_suf = NULL;
outputformat.cmpd_sep = NULL;
-
+
outputformat.vlen_sep = NULL;
outputformat.vlen_pre = NULL;
outputformat.vlen_suf = NULL;
@@ -1652,7 +1656,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain
H5Sclose(space);
H5Tclose(type);
H5Aclose(attr);
- }
+ }
h5tools_str_close(&buffer);
PRINTVALSTREAM(rawoutstream, "\n");
@@ -1709,7 +1713,7 @@ dataset_list1(hid_t dset)
h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", cur_size[i]);
if (max_size[i]==H5S_UNLIMITED) {
h5tools_str_append(&buffer, "/%s", "Inf");
- }
+ }
else if (max_size[i]!=cur_size[i] || verbose_g>0) {
h5tools_str_append(&buffer, "/"HSIZE_T_FORMAT, max_size[i]);
}
@@ -1756,6 +1760,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
size_t cd_nelmts; /* filter client number of values */
size_t cd_num; /* filter client data counter */
char f_name[256]; /* filter/file name */
+ char dset_name[256]; /* filter/file name */
char s[64]; /* temporary string buffer */
off_t f_offset; /* offset in external file */
hsize_t f_size; /* bytes used in external file */
@@ -1765,6 +1770,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
double utilization; /* percent utilization of storage */
H5T_class_t tclass; /* datatype class identifier */
int i;
+ H5D_layout_t stl;
hsize_t curr_pos = 0; /* total data element position */
h5tools_str_t buffer; /* string into which to render */
h5tools_context_t ctx; /* print context */
@@ -1780,20 +1786,71 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
space = H5Dget_space(dset);
type = H5Dget_type(dset);
- /* Print information about chunked storage */
- if (H5D_CHUNKED==H5Pget_layout(dcpl)) {
- hsize_t chsize[64]; /* chunk size in elements */
-
- ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize/*out*/);
- h5tools_str_append(&buffer, " %-10s {", "Chunks:");
- total = H5Tget_size(type);
- for (i=0; i<ndims; i++) {
- h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", chsize[i]);
- total *= chsize[i];
- }
- h5tools_str_append(&buffer, "} "HSIZE_T_FORMAT" bytes\n", total);
+ stl = H5Pget_layout(dcpl);
+ switch (stl) {
+ case H5D_CHUNKED:
+ {
+ hsize_t chsize[64]; /* chunk size in elements */
+
+ ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize/*out*/);
+ h5tools_str_append(&buffer, " %-10s {", "Chunks:");
+ total = H5Tget_size(type);
+ for (i=0; i<ndims; i++) {
+ h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", chsize[i]);
+ total *= chsize[i];
+ }
+ h5tools_str_append(&buffer, "} "HSIZE_T_FORMAT" bytes\n", total);
+ }
+ break;
+ case H5D_COMPACT:
+ break;
+ case H5D_CONTIGUOUS:
+ /* Print information about external storage */
+ if((nf = H5Pget_external_count(dcpl)) > 0) {
+ for(i = 0, max_len = 0; i < nf; i++) {
+ if(H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL) < 0)
+ continue;
+ n = print_string(NULL, f_name, TRUE);
+ max_len = MAX(max_len, n);
+ } /* end for */
+ h5tools_str_append(&buffer, " %-10s %d external file%s\n",
+ "Extern:", nf, 1==nf?"":"s");
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n",
+ "ID", "DSet-Addr", "File-Addr", "Bytes", "File");
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s ",
+ "----", "----------", "----------", "----------");
+ for (i=0; i<max_len; i++) h5tools_str_append(&buffer, "-");
+ h5tools_str_append(&buffer, "\n");
+ for (i=0, total=0; i<nf; i++) {
+ if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size)<0) {
+ h5tools_str_append(&buffer,
+ " #%03d %10"H5_PRINTF_LL_WIDTH"u %10s %10s ***ERROR*** %s\n",
+ i, total, "", "",
+ i+1<nf?"Following addresses are incorrect":"");
+ }
+ else if (H5S_UNLIMITED==f_size) {
+ h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10s ",
+ i, total, (hsize_t)f_offset, "INF");
+ print_string(&buffer, f_name, TRUE);
+ }
+ else {
+ h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u ",
+ i, total, (hsize_t)f_offset, f_size);
+ print_string(&buffer, f_name, TRUE);
+ }
+ h5tools_str_append(&buffer, "\n");
+ total += f_size;
+ }
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s ",
+ "----", "----------", "----------", "----------");
+ for (i=0; i<max_len; i++)
+ h5tools_str_append(&buffer, "-");
+ h5tools_str_append(&buffer, "\n");
+ } /* end if */
+ break;
+ default:
+ break;
}
-
/* Print total raw storage size */
total = (hsize_t)H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
used = H5Dget_storage_size(dset);
@@ -1837,49 +1894,6 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
h5tools_str_append(&buffer, "\n");
- /* Print information about external strorage */
- if((nf = H5Pget_external_count(dcpl)) > 0) {
- for(i = 0, max_len = 0; i < nf; i++) {
- if(H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL) < 0)
- continue;
- n = print_string(NULL, f_name, TRUE);
- max_len = MAX(max_len, n);
- } /* end for */
- h5tools_str_append(&buffer, " %-10s %d external file%s\n",
- "Extern:", nf, 1==nf?"":"s");
- h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n",
- "ID", "DSet-Addr", "File-Addr", "Bytes", "File");
- h5tools_str_append(&buffer, " %4s %10s %10s %10s ",
- "----", "----------", "----------", "----------");
- for (i=0; i<max_len; i++) h5tools_str_append(&buffer, "-");
- h5tools_str_append(&buffer, "\n");
- for (i=0, total=0; i<nf; i++) {
- if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size)<0) {
- h5tools_str_append(&buffer,
- " #%03d %10"H5_PRINTF_LL_WIDTH"u %10s %10s ***ERROR*** %s\n",
- i, total, "", "",
- i+1<nf?"Following addresses are incorrect":"");
- }
- else if (H5S_UNLIMITED==f_size) {
- h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10s ",
- i, total, (hsize_t)f_offset, "INF");
- print_string(&buffer, f_name, TRUE);
- }
- else {
- h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u ",
- i, total, (hsize_t)f_offset, f_size);
- print_string(&buffer, f_name, TRUE);
- }
- h5tools_str_append(&buffer, "\n");
- total += f_size;
- }
- h5tools_str_append(&buffer, " %4s %10s %10s %10s ",
- "----", "----------", "----------", "----------");
- for (i=0; i<max_len; i++)
- h5tools_str_append(&buffer, "-");
- h5tools_str_append(&buffer, "\n");
- } /* end if */
-
/* Print information about raw data filters */
if((nf = H5Pget_nfilters(dcpl)) > 0) {
for(i = 0; i < nf; i++) {
@@ -2186,7 +2200,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
h5tools_str_append(&buffer, " ");
/* Check if we have already seen this softlink */
- if(symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf))
+ if(symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf))
{
h5tools_str_append(&buffer, "{Already Visited}\n");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
@@ -2195,7 +2209,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
/* Add this link to the list of seen softlinks */
- if(symlink_visit_add(iter->symlink_list, linfo->type, NULL, buf) < 0)
+ if(symlink_visit_add(iter->symlink_list, linfo->type, NULL, buf) < 0)
goto done;
/* Adjust user data to specify that we are operating on the
@@ -2207,7 +2221,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
if(!recursive_g)
grp_literal_g = TRUE;
/* Recurse through the soft link */
- if(visit_obj(iter->fid, name, iter) < 0)
+ if(visit_obj(iter->fid, name, iter) < 0)
{
grp_literal_g = orig_grp_literal;
goto done;
@@ -2240,7 +2254,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
else if (no_dangling_link_g && ret == 0)
iter->symlink_list->dangle_link = TRUE;
- if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0)
+ if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0)
goto done;
h5tools_str_append(&buffer, "External Link {");
@@ -2261,7 +2275,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
h5tools_str_append(&buffer, " ");
/* Check if we have already seen this elink */
- if(symlink_is_visited(iter->symlink_list, linfo->type, filename, path))
+ if(symlink_is_visited(iter->symlink_list, linfo->type, filename, path))
{
h5tools_str_append(&buffer, "{Already Visited}\n");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
@@ -2270,7 +2284,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
/* Add this link to the list of seen elinks */
- if(symlink_visit_add(iter->symlink_list, linfo->type, filename, path) < 0)
+ if(symlink_visit_add(iter->symlink_list, linfo->type, filename, path) < 0)
{
goto done;
}
@@ -2320,7 +2334,7 @@ done:
*
* Purpose: Begins iteration on an object
*
- * Return:
+ * Return:
* Success: 0
* Failure: -1
*
@@ -2479,7 +2493,7 @@ get_width(void)
*
* Purpose: check if command line arguments are valid
*
- * Return:
+ * Return:
* Success: TRUE (1)
* Failure: FALSE (0)
*
@@ -2487,19 +2501,19 @@ get_width(void)
* Jonathan Kim (06/15/2010)
*
*-------------------------------------------------------------------------*/
-static hbool_t
+static hbool_t
is_valid_args(void)
{
hbool_t ret = TRUE;
- if(recursive_g && grp_literal_g)
+ if(recursive_g && grp_literal_g)
{
HDfprintf(rawerrorstream, "Error: 'recursive' option not compatible with 'group info' option!\n\n");
ret = FALSE;
goto out;
}
- if(no_dangling_link_g && !follow_symlink_g)
+ if(no_dangling_link_g && !follow_symlink_g)
{
HDfprintf(rawerrorstream, "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n");
ret = FALSE;
@@ -2877,7 +2891,7 @@ main(int argc, const char *argv[])
if(x)
HDfree(oname);
- for(u=0; u < symlink_list.nused; u++)
+ for(u=0; u < symlink_list.nused; u++)
{
if (symlink_list.objs[u].type == H5L_TYPE_EXTERNAL)
HDfree(symlink_list.objs[u].file);
@@ -2885,7 +2899,7 @@ main(int argc, const char *argv[])
HDfree(symlink_list.objs[u].path);
}
HDfree(symlink_list.objs);
-
+
/* if no-dangling-links option specified and dangling link found */
if (no_dangling_link_g && iter.symlink_list->dangle_link)
err_exit = 1;
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index 8a297a7..1d71c13 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -47,473 +47,473 @@
obj_list_t* parse_filter(const char *str,
- int *n_objs,
- filter_info_t *filt,
- pack_opt_t *options,
- int *is_glb)
+ int *n_objs,
+ filter_info_t *filt,
+ pack_opt_t *options,
+ int *is_glb)
{
- unsigned i, u;
- char c;
- size_t len=HDstrlen(str);
- int j, m, n, k, l, p, r, q, end_obj=-1, no_param=0;
- char sobj[MAX_NC_NAME];
- char scomp[10];
- char stype[5];
- char smask[3];
- obj_list_t* obj_list=NULL;
- unsigned pixels_per_block;
-
-
- /* initialize compression info */
- HDmemset(filt,0,sizeof(filter_info_t));
- *is_glb = 0;
-
- /* check for the end of object list and number of objects */
- for ( i = 0, n = 0; i < len; i++)
- {
- c = str[i];
- if ( c==':' )
- {
- end_obj=i;
- }
- if ( c==',' )
- {
- n++;
- }
- }
-
- if (end_obj==-1) /* missing : */
- {
- /* apply to all objects */
- options->all_filter=1;
- *is_glb = 1;
- }
-
- n++;
- obj_list = (obj_list_t*) HDmalloc(n*sizeof(obj_list_t));
- if (obj_list==NULL)
- {
- error_msg("could not allocate object list\n");
- return NULL;
- }
- *n_objs=n;
-
- /* get object list */
- for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++)
- {
- c = str[j];
- sobj[k] = c;
- if ( c==',' || j==end_obj-1)
- {
- if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
- HDstrcpy(obj_list[n].obj,sobj);
- HDmemset(sobj,0,sizeof(sobj));
- n++;
- k=-1;
- }
- }
- /* nothing after : */
- if (end_obj+1==(int)len)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("input Error: Invalid compression type in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
-
-
- /* get filter additional parameters */
- m=0;
- for ( i=end_obj+1, k=0, j=0; i<len; i++,k++)
- {
- c = str[i];
- scomp[k]=c;
- if ( c=='=' || i==len-1)
- {
- if ( c=='=') /*one more parameter */
- {
- scomp[k]='\0'; /*cut space */
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- * szip has the format SZIP=<pixels per block,coding>
- * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
- * example SZIP=8,NN
- *-------------------------------------------------------------------------
- */
- if (HDstrcmp(scomp,"SZIP")==0)
- {
- l=-1; /* mask index check */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- if (str[u]==',')
- {
- stype[m]='\0'; /* end digit of szip */
- l=0; /* start EC or NN search */
- u++; /* skip ',' */
- }
- c = str[u];
- if (!isdigit(c) && l==-1)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("compression parameter not digit in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- if (l==-1)
- stype[m]=c;
- else
- {
- smask[l]=c;
- l++;
- if (l==2)
- {
- smask[l]='\0';
- i=len-1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
- if (HDstrcmp(smask,"NN")==0)
- filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK;
- else if (HDstrcmp(smask,"EC")==0)
- filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
- else
- {
- error_msg("szip mask must be 'NN' or 'EC' \n");
- HDexit(EXIT_FAILURE);
- }
-
-
- }
- }
-
- } /* u */
- } /*if */
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- * scaleoffset has the format SOFF=<scale_factor,scale_type>
- * scale_type can be
- * integer datatype, H5Z_SO_INT (IN)
- * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
- * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
- * for integer datatypes, scale_factor denotes Minimum Bits
- * for float datatypes, scale_factor denotes decimal scale factor
- * examples
- * SOFF=31,IN
- * SOFF=3,DF
- *-------------------------------------------------------------------------
- */
-
- else if (HDstrcmp(scomp,"SOFF")==0)
- {
- l=-1; /* mask index check */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- if (str[u]==',')
- {
- stype[m]='\0'; /* end digit */
- l=0; /* start 'IN' , 'DS', or 'ES' search */
- u++; /* skip ',' */
- }
- c = str[u];
- if (!isdigit(c) && l==-1)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("compression parameter is not a digit in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- if (l==-1)
- stype[m]=c;
- else
- {
- smask[l]=c;
- l++;
- if (l==2)
- {
- smask[l]='\0';
- i=len-1; /* end */
- (*n_objs)--; /* we counted an extra ',' */
- if (HDstrcmp(smask,"IN")==0)
- filt->cd_values[j++]=H5Z_SO_INT;
- else if (HDstrcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE)
- filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
- else
- {
- error_msg("scale type must be 'IN' or 'DS' \n");
- HDexit(EXIT_FAILURE);
- }
-
- }
- }
-
- } /* u */
- } /*if */
- /*-------------------------------------------------------------------------
- * User Defined
- * has the format UD=<filter_number,cd_value_count,value_1[,value_2,...,value_N]>
- * BZIP2 example
- * UD=307,1,9
- *-------------------------------------------------------------------------
- */
-
- else if (HDstrcmp(scomp,"UD")==0)
- {
- l=-1; /* filter number index check */
- p=-1; /* CD_VAL count check */
- r=-1; /* CD_VAL check */
- for ( m=0,q=0,u=i+1; u<len; u++,m++,q++)
- {
- if (str[u]==',')
- {
- stype[q]='\0'; /* end digit */
- if (l==-1)
- {
- filt->filtn=atoi(stype);
- l=0;
- }
- else if (p==-1)
- {
- filt->cd_nelmts=atoi(stype);
- p=0;
- }
- else
- r=0;
- q=0;
- u++; /* skip ',' */
- }
- c = str[u];
- if (!isdigit(c) && l==-1)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("filter number parameter is not a digit in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- stype[q]=c;
- if (l==0 && p==0)
- {
- if (r==0)
- filt->cd_values[j++]=atoi(stype);
- }
-
- } /* u */
-
- stype[q]='\0';
- } /*if */
-
-
- /*-------------------------------------------------------------------------
- * all other filters
- *-------------------------------------------------------------------------
- */
-
- else
- {
- /* here we could have 1 or 2 digits */
- for ( m=0,u=i+1; u<len; u++,m++)
- {
- c = str[u];
- if (!isdigit(c)){
- if (obj_list) HDfree(obj_list);
- error_msg("compression parameter is not a digit in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- stype[m]=c;
- } /* u */
-
- stype[m]='\0';
- } /*if */
-
-
-
- filt->cd_values[j++]=atoi(stype);
- i+=m; /* jump */
- }
- else if (i==len-1)
- { /*no more parameters */
- scomp[k+1]='\0';
- no_param=1;
- }
-
- /*-------------------------------------------------------------------------
- * translate from string to filter symbol
- *-------------------------------------------------------------------------
- */
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE
- *-------------------------------------------------------------------------
- */
- if (HDstrcmp(scomp,"NONE")==0)
- {
- filt->filtn=H5Z_FILTER_NONE;
- filt->cd_nelmts = 0;
- }
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"GZIP")==0)
- {
- filt->filtn=H5Z_FILTER_DEFLATE;
- filt->cd_nelmts = 1;
- if (no_param)
- { /*no more parameters, GZIP must have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("missing compression parameter in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"SZIP")==0)
- {
- filt->filtn=H5Z_FILTER_SZIP;
- filt->cd_nelmts = 2;
- if (no_param)
- { /*no more parameters, SZIP must have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("missing compression parameter in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"SHUF")==0)
- {
- filt->filtn=H5Z_FILTER_SHUFFLE;
- filt->cd_nelmts = 0;
- if (m>0)
- { /*shuffle does not have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("extra parameter in SHUF <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"FLET")==0)
- {
- filt->filtn=H5Z_FILTER_FLETCHER32;
- filt->cd_nelmts = 0;
- if (m>0)
- { /*shuffle does not have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("extra parameter in FLET <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"NBIT")==0)
- {
- filt->filtn=H5Z_FILTER_NBIT;
- filt->cd_nelmts = 0;
- if (m>0)
- { /*nbit does not have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("extra parameter in NBIT <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"SOFF")==0)
- {
- filt->filtn=H5Z_FILTER_SCALEOFFSET;
- filt->cd_nelmts = 2;
- if (no_param)
- { /*no more parameters, SOFF must have parameter */
- if (obj_list) HDfree(obj_list);
- error_msg("missing compression parameter in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- /*-------------------------------------------------------------------------
- * User Defined Filter
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(scomp,"UD")==0)
- {
- if (filt->cd_nelmts != j)
- { /* parameters does not match count */
- if (obj_list) HDfree(obj_list);
- error_msg("incorrect number of compression parameters in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- else {
- if (obj_list) HDfree(obj_list);
- error_msg("invalid filter type in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- }
- } /*i*/
-
- /*-------------------------------------------------------------------------
- * check valid parameters
- *-------------------------------------------------------------------------
- */
-
- switch (filt->filtn)
- {
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
-
- case H5Z_FILTER_DEFLATE:
- if (filt->cd_values[0]>9 )
- {
- if (obj_list) HDfree(obj_list);
- error_msg("invalid compression parameter in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
-
- case H5Z_FILTER_SZIP:
- pixels_per_block=filt->cd_values[0];
- if ((pixels_per_block%2)==1)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("pixels_per_block is not even in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
- {
- if (obj_list) HDfree(obj_list);
- error_msg("pixels_per_block is too large in <%s>\n",str);
- HDexit(EXIT_FAILURE);
- }
- if ( (HDstrcmp(smask,"NN")!=0) && (HDstrcmp(smask,"EC")!=0) )
- {
- if (obj_list) HDfree(obj_list);
- error_msg("szip mask must be 'NN' or 'EC' \n");
- HDexit(EXIT_FAILURE);
- }
- break;
- default:
- break;
-
-
- };
-
- return obj_list;
+ unsigned i, u;
+ char c;
+ size_t len=HDstrlen(str);
+ int j, m, n, k, l, p, r, q, end_obj=-1, no_param=0;
+ char sobj[MAX_NC_NAME];
+ char scomp[10];
+ char stype[6];
+ char smask[3];
+ obj_list_t* obj_list=NULL;
+ unsigned pixels_per_block;
+
+
+ /* initialize compression info */
+ HDmemset(filt,0,sizeof(filter_info_t));
+ *is_glb = 0;
+
+ /* check for the end of object list and number of objects */
+ for ( i = 0, n = 0; i < len; i++)
+ {
+ c = str[i];
+ if ( c==':' )
+ {
+ end_obj=i;
+ }
+ if ( c==',' )
+ {
+ n++;
+ }
+ }
+
+ if (end_obj==-1) /* missing : */
+ {
+ /* apply to all objects */
+ options->all_filter=1;
+ *is_glb = 1;
+ }
+
+ n++;
+ obj_list = (obj_list_t*) HDmalloc(n*sizeof(obj_list_t));
+ if (obj_list==NULL)
+ {
+ error_msg("could not allocate object list\n");
+ return NULL;
+ }
+ *n_objs=n;
+
+ /* get object list */
+ for ( j = 0, k = 0, n = 0; j < end_obj; j++, k++)
+ {
+ c = str[j];
+ sobj[k] = c;
+ if ( c==',' || j==end_obj-1)
+ {
+ if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
+ HDstrcpy(obj_list[n].obj,sobj);
+ HDmemset(sobj,0,sizeof(sobj));
+ n++;
+ k=-1;
+ }
+ }
+ /* nothing after : */
+ if (end_obj+1==(int)len)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("input Error: Invalid compression type in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+
+
+ /* get filter additional parameters */
+ m=0;
+ for ( i=end_obj+1, k=0, j=0; i<len; i++,k++)
+ {
+ c = str[i];
+ scomp[k]=c;
+ if ( c=='=' || i==len-1)
+ {
+ if ( c=='=') /*one more parameter */
+ {
+ scomp[k]='\0'; /*cut space */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ * szip has the format SZIP=<pixels per block,coding>
+ * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
+ * example SZIP=8,NN
+ *-------------------------------------------------------------------------
+ */
+ if (HDstrcmp(scomp,"SZIP")==0)
+ {
+ l=-1; /* mask index check */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ if (str[u]==',')
+ {
+ stype[m]='\0'; /* end digit of szip */
+ l=0; /* start EC or NN search */
+ u++; /* skip ',' */
+ }
+ c = str[u];
+ if (!isdigit(c) && l==-1)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("compression parameter not digit in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ if (l==-1)
+ stype[m]=c;
+ else
+ {
+ smask[l]=c;
+ l++;
+ if (l==2)
+ {
+ smask[l]='\0';
+ i=len-1; /* end */
+ (*n_objs)--; /* we counted an extra ',' */
+ if (HDstrcmp(smask,"NN")==0)
+ filt->cd_values[j++]=H5_SZIP_NN_OPTION_MASK;
+ else if (HDstrcmp(smask,"EC")==0)
+ filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
+ else
+ {
+ error_msg("szip mask must be 'NN' or 'EC' \n");
+ HDexit(EXIT_FAILURE);
+ }
+
+
+ }
+ }
+
+ } /* u */
+ } /*if */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ * scaleoffset has the format SOFF=<scale_factor,scale_type>
+ * scale_type can be
+ * integer datatype, H5Z_SO_INT (IN)
+ * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
+ * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
+ * for integer datatypes, scale_factor denotes Minimum Bits
+ * for float datatypes, scale_factor denotes decimal scale factor
+ * examples
+ * SOFF=31,IN
+ * SOFF=3,DF
+ *-------------------------------------------------------------------------
+ */
+
+ else if (HDstrcmp(scomp,"SOFF")==0)
+ {
+ l=-1; /* mask index check */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ if (str[u]==',')
+ {
+ stype[m]='\0'; /* end digit */
+ l=0; /* start 'IN' , 'DS', or 'ES' search */
+ u++; /* skip ',' */
+ }
+ c = str[u];
+ if (!isdigit(c) && l==-1)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ if (l==-1)
+ stype[m]=c;
+ else
+ {
+ smask[l]=c;
+ l++;
+ if (l==2)
+ {
+ smask[l]='\0';
+ i=len-1; /* end */
+ (*n_objs)--; /* we counted an extra ',' */
+ if (HDstrcmp(smask,"IN")==0)
+ filt->cd_values[j++]=H5Z_SO_INT;
+ else if (HDstrcmp(smask,"DS")==H5Z_SO_FLOAT_DSCALE)
+ filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
+ else
+ {
+ error_msg("scale type must be 'IN' or 'DS' \n");
+ HDexit(EXIT_FAILURE);
+ }
+
+ }
+ }
+
+ } /* u */
+ } /*if */
+ /*-------------------------------------------------------------------------
+ * User Defined
+ * has the format UD=<filter_number,cd_value_count,value_1[,value_2,...,value_N]>
+ * BZIP2 example
+ * UD=307,1,9
+ *-------------------------------------------------------------------------
+ */
+
+ else if (HDstrcmp(scomp,"UD")==0)
+ {
+ l=-1; /* filter number index check */
+ p=-1; /* CD_VAL count check */
+ r=-1; /* CD_VAL check */
+ for ( m=0,q=0,u=i+1; u<len; u++,m++,q++)
+ {
+ if (str[u]==',')
+ {
+ stype[q]='\0'; /* end digit */
+ if (l==-1)
+ {
+ filt->filtn=atoi(stype);
+ l=0;
+ }
+ else if (p==-1)
+ {
+ filt->cd_nelmts=atoi(stype);
+ p=0;
+ }
+ else
+ r=0;
+ q=0;
+ u++; /* skip ',' */
+ }
+ c = str[u];
+ if (!isdigit(c) && l==-1)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("filter number parameter is not a digit in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ stype[q]=c;
+ if (l==0 && p==0)
+ {
+ if (r==0)
+ filt->cd_values[j++]=atoi(stype);
+ }
+
+ } /* u */
+
+ stype[q]='\0';
+ } /*if */
+
+
+ /*-------------------------------------------------------------------------
+ * all other filters
+ *-------------------------------------------------------------------------
+ */
+
+ else
+ {
+ /* here we could have 1 or 2 digits */
+ for ( m=0,u=i+1; u<len; u++,m++)
+ {
+ c = str[u];
+ if (!isdigit(c)){
+ if (obj_list) HDfree(obj_list);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ stype[m]=c;
+ } /* u */
+
+ stype[m]='\0';
+ } /*if */
+
+
+
+ filt->cd_values[j++]=atoi(stype);
+ i+=m; /* jump */
+ }
+ else if (i==len-1)
+ { /*no more parameters */
+ scomp[k+1]='\0';
+ no_param=1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * translate from string to filter symbol
+ *-------------------------------------------------------------------------
+ */
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NONE
+ *-------------------------------------------------------------------------
+ */
+ if (HDstrcmp(scomp,"NONE")==0)
+ {
+ filt->filtn=H5Z_FILTER_NONE;
+ filt->cd_nelmts = 0;
+ }
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"GZIP")==0)
+ {
+ filt->filtn=H5Z_FILTER_DEFLATE;
+ filt->cd_nelmts = 1;
+ if (no_param)
+ { /*no more parameters, GZIP must have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("missing compression parameter in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"SZIP")==0)
+ {
+ filt->filtn=H5Z_FILTER_SZIP;
+ filt->cd_nelmts = 2;
+ if (no_param)
+ { /*no more parameters, SZIP must have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("missing compression parameter in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"SHUF")==0)
+ {
+ filt->filtn=H5Z_FILTER_SHUFFLE;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*shuffle does not have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("extra parameter in SHUF <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"FLET")==0)
+ {
+ filt->filtn=H5Z_FILTER_FLETCHER32;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*shuffle does not have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("extra parameter in FLET <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"NBIT")==0)
+ {
+ filt->filtn=H5Z_FILTER_NBIT;
+ filt->cd_nelmts = 0;
+ if (m>0)
+ { /*nbit does not have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("extra parameter in NBIT <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"SOFF")==0)
+ {
+ filt->filtn=H5Z_FILTER_SCALEOFFSET;
+ filt->cd_nelmts = 2;
+ if (no_param)
+ { /*no more parameters, SOFF must have parameter */
+ if (obj_list) HDfree(obj_list);
+ error_msg("missing compression parameter in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * User Defined Filter
+ *-------------------------------------------------------------------------
+ */
+ else if (HDstrcmp(scomp,"UD")==0)
+ {
+ if (filt->cd_nelmts != j)
+ { /* parameters does not match count */
+ if (obj_list) HDfree(obj_list);
+ error_msg("incorrect number of compression parameters in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ else {
+ if (obj_list) HDfree(obj_list);
+ error_msg("invalid filter type in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+ } /*i*/
+
+ /*-------------------------------------------------------------------------
+ * check valid parameters
+ *-------------------------------------------------------------------------
+ */
+
+ switch (filt->filtn)
+ {
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
+
+ case H5Z_FILTER_DEFLATE:
+ if (filt->cd_values[0]>9 )
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("invalid compression parameter in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
+
+ case H5Z_FILTER_SZIP:
+ pixels_per_block=filt->cd_values[0];
+ if ((pixels_per_block%2)==1)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("pixels_per_block is not even in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("pixels_per_block is too large in <%s>\n",str);
+ HDexit(EXIT_FAILURE);
+ }
+ if ( (HDstrcmp(smask,"NN")!=0) && (HDstrcmp(smask,"EC")!=0) )
+ {
+ if (obj_list) HDfree(obj_list);
+ error_msg("szip mask must be 'NN' or 'EC' \n");
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ default:
+ break;
+
+
+ };
+
+ return obj_list;
}
@@ -540,9 +540,9 @@ obj_list_t* parse_filter(const char *str,
*-------------------------------------------------------------------------
*/
obj_list_t* parse_layout(const char *str,
- int *n_objs,
- pack_info_t *pack, /* info about layout needed */
- pack_opt_t *options)
+ int *n_objs,
+ pack_info_t *pack, /* info about layout needed */
+ pack_opt_t *options)
{
obj_list_t* obj_list=NULL;
unsigned i;
@@ -636,10 +636,10 @@ obj_list_t* parse_layout(const char *str,
if ( pack->layout==H5D_CHUNKED )
{
- /*-------------------------------------------------------------------------
- * get chunk info
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * get chunk info
+ *-------------------------------------------------------------------------
+ */
k=0;
if (j>(int)len)
@@ -656,11 +656,11 @@ obj_list_t* parse_layout(const char *str,
k++; /*increment sdim index */
if (!isdigit(c) && c!='x'
- && c!='N' && c!='O' && c!='N' && c!='E'
- ){
+ && c!='N' && c!='O' && c!='N' && c!='E'
+ ){
if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> Not a valid character in <%s>\n",
- sdim,str);
+ sdim,str);
HDexit(EXIT_FAILURE);
}
@@ -673,7 +673,7 @@ obj_list_t* parse_layout(const char *str,
if (pack->chunk.chunk_lengths[c_index]==0) {
if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> conversion to number in <%s>\n",
- sdim,str);
+ sdim,str);
HDexit(EXIT_FAILURE);
}
c_index++;
@@ -691,7 +691,7 @@ obj_list_t* parse_layout(const char *str,
if (pack->chunk.chunk_lengths[c_index]==0){
if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> conversion to number in <%s>\n",
- sdim,str);
+ sdim,str);
HDexit(EXIT_FAILURE);
}
pack->chunk.rank=c_index+1;
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 4def001..e2bb9cd 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -57,6 +57,7 @@ typedef struct H5LD_memb_t {
static char *h5tools_escape(char *s, size_t size);
static hbool_t h5tools_str_is_zero(const void *_mem, size_t size);
static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
+void h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx);
/*-------------------------------------------------------------------------
* Function: h5tools_str_close
@@ -153,16 +154,16 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap);
HDva_end(ap);
- /* Note: HDvsnprintf() behaves differently on Windows as Unix, when
- * buffer is smaller than source string. On Unix, this function
- * returns length of the source string and copy string upto the
- * buffer size with NULL at the end of the buffer. However on
- * Windows with the same condition, this function returns -1 and
+ /* Note: HDvsnprintf() behaves differently on Windows as Unix, when
+ * buffer is smaller than source string. On Unix, this function
+ * returns length of the source string and copy string upto the
+ * buffer size with NULL at the end of the buffer. However on
+ * Windows with the same condition, this function returns -1 and
* doesn't add NULL at the end of the buffer.
* Because of this different return results, the strlen of the new string
* is used to handle when HDvsnprintf() returns -1 on Windows due
* to lack of buffer size, so try one more time after realloc more
- * buffer size before return NULL.
+ * buffer size before return NULL.
*/
if (nchars < 0) {
/* failure, such as bad format */
@@ -289,7 +290,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
if (HDstrchr(fmt, '%')) {
size_t n = sizeof(_temp);
if (str->len - start + 1 > n) {
- n = str->len - start + 1;
+ n = str->len - start + 1;
temp = (char*)HDmalloc(n);
HDassert(temp);
}
@@ -677,15 +678,15 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
*
* PVN, 28 March 2006
* added H5T_NATIVE_LDOUBLE case
- *
+ *
* Vailin Choi; August 2010
* Modified to handle printing of selected compound fields for h5watch.
*
* Raymond Lu, 2011-09-01
* CLANG compiler complained about the line (about 800):
* tempint = (tempint >> packed_data_offset) & packed_data_mask;
- * The right shift may cause undefined behavior if PACKED_DATA_OFFSET is
- * 32-bit or more. For every kind of native integers, I changed the code
+ * The right shift may cause undefined behavior if PACKED_DATA_OFFSET is
+ * 32-bit or more. For every kind of native integers, I changed the code
* to make it zero if PACKED_DATA_OFFSET is greater than or equal to the
* size of integer.
*-------------------------------------------------------------------------
@@ -1436,14 +1437,14 @@ h5tools_str_is_zero(const void *_mem, size_t size)
*
* Purpose: replace all occurrences of substring.
*
- * Return: char *
+ * Return: char *
*
* Programmer: Peter Cao
* March 8, 2012
*
* Notes:
- * Applications need to call free() to free the memoery allocated for
- * the return string
+ * Applications need to call free() to free the memoery allocated for
+ * the return string
*
*-------------------------------------------------------------------------
*/
@@ -1476,6 +1477,6 @@ h5tools_str_replace ( const char *string, const char *substr, const char *replac
head = newstr + (tok - oldstr) + HDstrlen( replacement );
HDfree (oldstr);
}
-
+
return newstr;
}