summaryrefslogtreecommitdiffstats
path: root/tools/h5ls
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-03-02 14:21:13 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-03-02 14:21:13 (GMT)
commit68d93b7f4e458ace2ac255c1c7d9dd8873132b51 (patch)
tree5e8429affabf4e90eee15cc85119820b3afc36a8 /tools/h5ls
parentc714d9ef43e8b442bd271867c7afab0487fc0c0a (diff)
downloadhdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.zip
hdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.tar.gz
hdf5-68d93b7f4e458ace2ac255c1c7d9dd8873132b51.tar.bz2
[svn-r22013] HDFFV-7560:
Merge 1.8 and h5dump/tools and tests based on tools library from trunk. Reduced warnings. HDFFV-7949: Remove duplicated functions in h5ls Tested: local linux,h5committest
Diffstat (limited to 'tools/h5ls')
-rw-r--r--tools/h5ls/h5ls.c1869
1 files changed, 1541 insertions, 328 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 66e588f..7315796 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -27,12 +27,86 @@
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
+#include "h5tools_dump.h"
#include "h5trav.h"
/* Name of tool */
#define PROGRAMNAME "h5ls"
#define NAME_BUF_SIZE 2048
+/*
+ * Alternative formating for data dumped by H5LS
+ *
+ * This table only affects H5LS output.
+ */
+static h5tool_format_t ls_dataformat = {
+ 0, /*raw */
+
+ "", /*fmt_raw */
+ "%d", /*fmt_int */
+ "%u", /*fmt_uint */
+ "%hhd", /*fmt_schar */
+ "%u", /*fmt_uchar */
+ "%d", /*fmt_short */
+ "%u", /*fmt_ushort */
+ "%ld", /*fmt_long */
+ "%lu", /*fmt_ulong */
+ NULL, /*fmt_llong */
+ NULL, /*fmt_ullong */
+ "%g", /*fmt_double */
+ "%g", /*fmt_float */
+
+ 0, /*ascii */
+ 0, /*str_locale */
+ 0, /*str_repeat */
+
+ "[", /*arr_pre */
+ ",", /*arr_sep */
+ "]", /*arr_suf */
+ 1, /*arr_linebreak */
+
+ "", /*cmpd_name */
+ ",", /*cmpd_sep */
+ "{", /*cmpd_pre */
+ "}", /*cmpd_suf */
+ "", /*cmpd_end */
+
+ ",", /*vlen_sep */
+ "(", /*vlen_pre */
+ ")", /*vlen_suf */
+ "", /*vlen_end */
+
+ "%s", /*elmt_fmt */
+ ",", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
+
+ HSIZE_T_FORMAT, /*idx_n_fmt */
+ ",", /*idx_sep */
+ "(%s)", /*idx_fmt */
+
+ 65535, /*line_ncols *//*standard default columns */
+ 0, /*line_per_line */
+ "", /*line_pre */
+ "%s", /*line_1st */
+ "%s", /*line_cont */
+ "", /*line_suf */
+ "", /*line_sep */
+ 1, /*line_multi_new */
+ "", /*line_indent */
+
+ 0, /*skip_first */
+
+ 0, /*obj_hidefileno */
+ "-%lu:"H5_PRINTF_HADDR_FMT, /*obj_format */
+
+ 0, /*dset_hidefileno */
+ "DSET-%s ", /*dset_format */
+ "%sBlk%lu: ", /*dset_blockformat_pre */
+ "%sPt%lu: ", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 1, /*array indices */
+ 1 /*escape non printable characters */
+};
/* Struct to pass through to visitors */
typedef struct {
@@ -81,6 +155,7 @@ static struct dispatch_t {
}
static void display_type(hid_t type, int ind);
+static void print_type(h5tools_str_t *buffer, hid_t type, int ind);
static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
@@ -101,7 +176,7 @@ static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
static void
usage (void)
{
- fprintf(stderr, "\
+ HDfprintf(rawerrorstream, "\
usage: %s [OPTIONS] [OBJECTS...]\n\
OPTIONS\n\
-h, -?, --help Print a usage message and exit\n\
@@ -188,49 +263,49 @@ display_string(FILE *stream, const char *s, hbool_t escape_spaces)
for (/*void*/; s && *s; s++) {
switch (*s) {
case '"':
- if (stream) fprintf(stream, "\\\"");
+ if (stream) HDfprintf(stream, "\\\"");
nprint += 2;
break;
case '\\':
- if (stream) fprintf(stream, "\\\\");
+ if (stream) HDfprintf(stream, "\\\\");
nprint += 2;
break;
case '\b':
- if (stream) fprintf(stream, "\\b");
+ if (stream) HDfprintf(stream, "\\b");
nprint += 2;
break;
case '\f':
- if (stream) fprintf(stream, "\\f");
+ if (stream) HDfprintf(stream, "\\f");
nprint += 2;
break;
case '\n':
- if (stream) fprintf(stream, "\\n");
+ if (stream) HDfprintf(stream, "\\n");
nprint += 2;
break;
case '\r':
- if (stream) fprintf(stream, "\\r");
+ if (stream) HDfprintf(stream, "\\r");
nprint += 2;
break;
case '\t':
- if (stream) fprintf(stream, "\\t");
+ if (stream) HDfprintf(stream, "\\t");
nprint += 2;
break;
case ' ':
if (escape_spaces) {
- if (stream) fprintf(stream, "\\ ");
+ if (stream) HDfprintf(stream, "\\ ");
nprint += 2;
} else {
- if (stream) fprintf(stream, " ");
+ if (stream) HDfprintf(stream, " ");
nprint++;
}
break;
default:
if (isprint((int)*s)) {
- if (stream) putc(*s, stream);
+ if (stream) HDfputc(*s, stream);
nprint++;
} else {
if (stream) {
- fprintf(stream, "\\%03o", *((const unsigned char*)s));
+ HDfprintf(stream, "\\%03o", *((const unsigned char*)s));
}
nprint += 4;
}
@@ -284,7 +359,7 @@ display_obj_name(FILE *stream, const iter_t *iter, const char *oname,
} /* end else */
n = display_string(stream, last_sep, TRUE);
} /* end else */
- printf("%*s ", MAX(0, (24 - n)), s);
+ HDfprintf(rawoutstream, "%*s ", MAX(0, (24 - n)), s);
return TRUE;
}
@@ -313,97 +388,97 @@ static hbool_t
display_native_type(hid_t type, int UNUSED ind)
{
if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) {
- printf("native signed char");
+ HDfprintf(rawoutstream, "native signed char");
} else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) {
- printf("native unsigned char");
+ HDfprintf(rawoutstream, "native unsigned char");
} else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) {
- printf("native int");
+ HDfprintf(rawoutstream, "native int");
} else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) {
- printf("native unsigned int");
+ HDfprintf(rawoutstream, "native unsigned int");
} else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) {
- printf("native short");
+ HDfprintf(rawoutstream, "native short");
} else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) {
- printf("native unsigned short");
+ HDfprintf(rawoutstream, "native unsigned short");
} else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) {
- printf("native long");
+ HDfprintf(rawoutstream, "native long");
} else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) {
- printf("native unsigned long");
+ HDfprintf(rawoutstream, "native unsigned long");
} else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) {
- printf("native long long");
+ HDfprintf(rawoutstream, "native long long");
} else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) {
- printf("native unsigned long long");
+ HDfprintf(rawoutstream, "native unsigned long long");
} else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) {
- printf("native float");
+ HDfprintf(rawoutstream, "native float");
} else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) {
- printf("native double");
+ HDfprintf(rawoutstream, "native double");
#if H5_SIZEOF_LONG_DOUBLE !=0
} else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) {
- printf("native long double");
+ HDfprintf(rawoutstream, "native long double");
#endif
} else if (H5Tequal(type, H5T_NATIVE_INT8)==TRUE) {
- printf("native int8_t");
+ HDfprintf(rawoutstream, "native int8_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT8)==TRUE) {
- printf("native uint8_t");
+ HDfprintf(rawoutstream, "native uint8_t");
} else if (H5Tequal(type, H5T_NATIVE_INT16)==TRUE) {
- printf("native int16_t");
+ HDfprintf(rawoutstream, "native int16_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT16)==TRUE) {
- printf("native uint16_t");
+ HDfprintf(rawoutstream, "native uint16_t");
} else if (H5Tequal(type, H5T_NATIVE_INT32)==TRUE) {
- printf("native int32_t");
+ HDfprintf(rawoutstream, "native int32_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT32)==TRUE) {
- printf("native uint32_t");
+ HDfprintf(rawoutstream, "native uint32_t");
} else if (H5Tequal(type, H5T_NATIVE_INT64)==TRUE) {
- printf("native int64_t");
+ HDfprintf(rawoutstream, "native int64_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT64)==TRUE) {
- printf("native uint64_t");
+ HDfprintf(rawoutstream, "native uint64_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8)==TRUE) {
- printf("native int_least8_t");
+ HDfprintf(rawoutstream, "native int_least8_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8)==TRUE) {
- printf("native uint_least8_t");
+ HDfprintf(rawoutstream, "native uint_least8_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16)==TRUE) {
- printf("native int_least16_t");
+ HDfprintf(rawoutstream, "native int_least16_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16)==TRUE) {
- printf("native uint_least16_t");
+ HDfprintf(rawoutstream, "native uint_least16_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32)==TRUE) {
- printf("native int_least32_t");
+ HDfprintf(rawoutstream, "native int_least32_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32)==TRUE) {
- printf("native uint_least32_t");
+ HDfprintf(rawoutstream, "native uint_least32_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64)==TRUE) {
- printf("native int_least64_t");
+ HDfprintf(rawoutstream, "native int_least64_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64)==TRUE) {
- printf("native uint_least64_t");
+ HDfprintf(rawoutstream, "native uint_least64_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_FAST8)==TRUE) {
- printf("native int_fast8_t");
+ HDfprintf(rawoutstream, "native int_fast8_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8)==TRUE) {
- printf("native uint_fast8_t");
+ HDfprintf(rawoutstream, "native uint_fast8_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_FAST16)==TRUE) {
- printf("native int_fast16_t");
+ HDfprintf(rawoutstream, "native int_fast16_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16)==TRUE) {
- printf("native uint_fast16_t");
+ HDfprintf(rawoutstream, "native uint_fast16_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_FAST32)==TRUE) {
- printf("native int_fast32_t");
+ HDfprintf(rawoutstream, "native int_fast32_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32)==TRUE) {
- printf("native uint_fast32_t");
+ HDfprintf(rawoutstream, "native uint_fast32_t");
} else if (H5Tequal(type, H5T_NATIVE_INT_FAST64)==TRUE) {
- printf("native int_fast64_t");
+ HDfprintf(rawoutstream, "native int_fast64_t");
} else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64)==TRUE) {
- printf("native uint_fast64_t");
+ HDfprintf(rawoutstream, "native uint_fast64_t");
} else if (H5Tequal(type, H5T_NATIVE_B8)==TRUE) {
- printf("native 8-bit field");
+ HDfprintf(rawoutstream, "native 8-bit field");
} else if (H5Tequal(type, H5T_NATIVE_B16)==TRUE) {
- printf("native 16-bit field");
+ HDfprintf(rawoutstream, "native 16-bit field");
} else if (H5Tequal(type, H5T_NATIVE_B32)==TRUE) {
- printf("native 32-bit field");
+ HDfprintf(rawoutstream, "native 32-bit field");
} else if (H5Tequal(type, H5T_NATIVE_B64)==TRUE) {
- printf("native 64-bit field");
+ HDfprintf(rawoutstream, "native 64-bit field");
} else if (H5Tequal(type, H5T_NATIVE_HSIZE)==TRUE) {
- printf("native hsize_t");
+ HDfprintf(rawoutstream, "native hsize_t");
} else if (H5Tequal(type, H5T_NATIVE_HSSIZE)==TRUE) {
- printf("native hssize_t");
+ HDfprintf(rawoutstream, "native hssize_t");
} else if (H5Tequal(type, H5T_NATIVE_HERR)==TRUE) {
- printf("native herr_t");
+ HDfprintf(rawoutstream, "native herr_t");
} else if (H5Tequal(type, H5T_NATIVE_HBOOL)==TRUE) {
- printf("native hbool_t");
+ HDfprintf(rawoutstream, "native hbool_t");
} else {
return FALSE;
}
@@ -431,13 +506,13 @@ static hbool_t
display_ieee_type(hid_t type, int UNUSED ind)
{
if (H5Tequal(type, H5T_IEEE_F32BE)==TRUE) {
- printf("IEEE 32-bit big-endian float");
+ HDfprintf(rawoutstream, "IEEE 32-bit big-endian float");
} else if (H5Tequal(type, H5T_IEEE_F32LE)==TRUE) {
- printf("IEEE 32-bit little-endian float");
+ HDfprintf(rawoutstream, "IEEE 32-bit little-endian float");
} else if (H5Tequal(type, H5T_IEEE_F64BE)==TRUE) {
- printf("IEEE 64-bit big-endian float");
+ HDfprintf(rawoutstream, "IEEE 64-bit big-endian float");
} else if (H5Tequal(type, H5T_IEEE_F64LE)==TRUE) {
- printf("IEEE 64-bit little-endian float");
+ HDfprintf(rawoutstream, "IEEE 64-bit little-endian float");
} else {
return FALSE;
}
@@ -474,7 +549,7 @@ display_precision(hid_t type, int ind)
* and offset on the following line. Also display the padding
* information. */
if (8*H5Tget_size(type)!=(prec=H5Tget_precision(type))) {
- printf("\n%*s(%lu bit%s of precision beginning at bit %lu)",
+ HDfprintf(rawoutstream, "\n%*s(%lu bit%s of precision beginning at bit %lu)",
ind, "", (unsigned long)prec, 1==prec?"":"s",
(unsigned long)H5Tget_offset(type));
@@ -520,20 +595,20 @@ display_precision(hid_t type, int ind)
}
}
if (plsb_s || pmsb_s) {
- printf("\n%*s(", ind, "");
+ HDfprintf(rawoutstream, "\n%*s(", ind, "");
if (plsb_s) {
nbits = H5Tget_offset(type);
- printf("%lu %s bit%s at bit 0",
+ HDfprintf(rawoutstream, "%lu %s bit%s at bit 0",
(unsigned long)nbits, plsb_s, 1==nbits?"":"s");
}
- if (plsb_s && pmsb_s) printf(", ");
+ if (plsb_s && pmsb_s) HDfprintf(rawoutstream, ", ");
if (pmsb_s) {
nbits = 8*H5Tget_size(type)-(H5Tget_offset(type)+prec);
- printf("%lu %s bit%s at bit %lu",
+ HDfprintf(rawoutstream, "%lu %s bit%s at bit %lu",
(unsigned long)nbits, pmsb_s, 1==nbits?"":"s",
(unsigned long)(8*H5Tget_size(type)-nbits));
}
- printf(")");
+ HDfprintf(rawoutstream, ")");
}
}
}
@@ -599,7 +674,7 @@ display_int_type(hid_t type, int ind)
/* Print size, order, and sign on first line, precision and padding
* information on the subsequent lines */
- printf("%lu-bit%s%s integer",
+ HDfprintf(rawoutstream, "%lu-bit%s%s integer",
(unsigned long)(8*H5Tget_size(type)), order_s, sign_s);
display_precision(type, ind);
return TRUE;
@@ -656,7 +731,7 @@ display_float_type(hid_t type, int ind)
/* Print size and byte order on first line, precision and padding on
* subsequent lines. */
- printf("%lu-bit%s floating-point",
+ HDfprintf(rawoutstream, "%lu-bit%s floating-point",
(unsigned long)(8*H5Tget_size(type)), order_s);
display_precision(type, ind);
@@ -681,13 +756,13 @@ display_float_type(hid_t type, int ind)
;
break;
}
- printf("\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "",
+ HDfprintf(rawoutstream, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "",
(unsigned long)msize, 1==msize?"":"s", (unsigned long)mpos,
norm_s);
- printf("\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)",
+ HDfprintf(rawoutstream, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)",
ind, "", (unsigned long)esize, 1==esize?"":"s",
(unsigned long)epos, (unsigned long)ebias);
- printf("\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos);
+ HDfprintf(rawoutstream, "\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos);
/* Display internal padding */
if (1+esize+msize<H5Tget_precision(type)) {
@@ -710,7 +785,7 @@ display_float_type(hid_t type, int ind)
;
break;
}
- printf("\n%*s(internal padding bits are %s)", ind, "", pad_s);
+ HDfprintf(rawoutstream, "\n%*s(internal padding bits are %s)", ind, "", pad_s);
}
return TRUE;
}
@@ -743,17 +818,17 @@ display_cmpd_type(hid_t type, int ind)
unsigned i; /* miscellaneous counters */
if (H5T_COMPOUND!=H5Tget_class(type)) return FALSE;
- printf("struct {");
+ HDfprintf(rawoutstream, "struct {");
nmembs=H5Tget_nmembers(type);
for (i=0; i<nmembs; i++) {
/* Name and offset */
name = H5Tget_member_name(type, i);
- printf("\n%*s\"", ind+4, "");
- n = display_string(stdout, name, FALSE);
- printf("\"%*s +%-4lu ", MAX(0, 16-n), "",
+ HDfprintf(rawoutstream, "\n%*s\"", ind+4, "");
+ n = display_string(rawoutstream, name, FALSE);
+ HDfprintf(rawoutstream, "\"%*s +%-4lu ", MAX(0, 16-n), "",
(unsigned long)H5Tget_member_offset(type, i));
- free(name);
+ HDfree(name);
/* Member's type */
subtype = H5Tget_member_type(type, i);
@@ -761,7 +836,7 @@ display_cmpd_type(hid_t type, int ind)
H5Tclose(subtype);
}
size = H5Tget_size(type);
- printf("\n%*s} %lu byte%s",
+ HDfprintf(rawoutstream, "\n%*s} %lu byte%s",
ind, "", (unsigned long)size, 1==size?"":"s");
return TRUE;
}
@@ -799,11 +874,11 @@ display_enum_type(hid_t type, int ind)
if (H5T_ENUM!=H5Tget_class(type)) return FALSE;
nmembs = H5Tget_nmembers(type);
- assert(nmembs>0);
+ HDassert(nmembs>0);
super = H5Tget_super(type);
- printf("enum ");
+ HDfprintf(rawoutstream, "enum ");
display_type(super, ind+4);
- printf(" {");
+ HDfprintf(rawoutstream, " {");
/* Determine what data type to use for the native values. To simplify
* things we entertain three possibilities:
@@ -822,8 +897,8 @@ display_enum_type(hid_t type, int ind)
}
/* Get the names and raw values of all members */
- name = calloc(nmembs, sizeof(char*));
- value = (unsigned char *)calloc(nmembs, MAX(H5Tget_size(type), dst_size));
+ name = HDcalloc(nmembs, sizeof(char*));
+ value = (unsigned char *)HDcalloc(nmembs, MAX(H5Tget_size(type), dst_size));
for (i=0; i<nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
H5Tget_member_value(type, i, value+i*H5Tget_size(type));
@@ -837,37 +912,37 @@ display_enum_type(hid_t type, int ind)
/* Print members */
for (i=0; i<nmembs; i++) {
- printf("\n%*s", ind+4, "");
- nchars = display_string(stdout, name[i], TRUE);
- printf("%*s = ", MAX(0, 16-nchars), "");
+ HDfprintf(rawoutstream, "\n%*s", ind+4, "");
+ nchars = display_string(rawoutstream, name[i], TRUE);
+ HDfprintf(rawoutstream, "%*s = ", MAX(0, 16-nchars), "");
if (native<0) {
- printf("0x");
+ HDfprintf(rawoutstream, "0x");
for (j=0; j<dst_size; j++)
- printf("%02x", value[i*dst_size+j]);
+ HDfprintf(rawoutstream, "%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;
- HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"u",
+ HDfprintf(rawoutstream,"%"H5_PRINTF_LL_WIDTH"u",
*((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".*/
copy = value+i*dst_size;
- HDfprintf(stdout,"%"H5_PRINTF_LL_WIDTH"d",
+ HDfprintf(rawoutstream,"%"H5_PRINTF_LL_WIDTH"d",
*((long long*)((void*)copy)));
}
}
/* Release resources */
- for (i=0; i<nmembs; i++) free(name[i]);
- free(name);
- free(value);
+ for (i=0; i<nmembs; i++) HDfree(name[i]);
+ HDfree(name);
+ HDfree(value);
H5Tclose(super);
- if (0==nmembs) printf("\n%*s <empty>", ind+4, "");
- printf("\n%*s}", ind, "");
+ if (0==nmembs) HDfprintf(rawoutstream, "\n%*s <empty>", ind+4, "");
+ HDfprintf(rawoutstream, "\n%*s}", ind, "");
return TRUE;
}
@@ -963,11 +1038,11 @@ display_string_type(hid_t type, int UNUSED ind)
}
if (H5Tis_variable_str(type)) {
- printf("variable-length");
+ HDfprintf(rawoutstream, "variable-length");
} else {
- printf("%lu-byte", (unsigned long)H5Tget_size(type));
+ HDfprintf(rawoutstream, "%lu-byte", (unsigned long)H5Tget_size(type));
}
- printf(" %s %s string", pad_s, cset_s);
+ HDfprintf(rawoutstream, " %s %s string", pad_s, cset_s);
return TRUE;
}
@@ -996,11 +1071,11 @@ display_reference_type(hid_t type, int UNUSED ind)
if (H5T_REFERENCE!=H5Tget_class(type)) return FALSE;
if (H5Tequal(type, H5T_STD_REF_OBJ)==TRUE) {
- printf("object reference");
+ HDfprintf(rawoutstream, "object reference");
} else if (H5Tequal(type, H5T_STD_REF_DSETREG)==TRUE) {
- printf("dataset region reference");
+ HDfprintf(rawoutstream, "dataset region reference");
} else {
- printf("%lu-byte unknown reference",
+ HDfprintf(rawoutstream, "%lu-byte unknown reference",
(unsigned long)H5Tget_size(type));
}
@@ -1033,12 +1108,12 @@ display_opaque_type(hid_t type, int ind)
if (H5T_OPAQUE!=H5Tget_class(type)) return FALSE;
size = H5Tget_size(type);
- printf("%lu-byte opaque type", (unsigned long)size);
+ HDfprintf(rawoutstream, "%lu-byte opaque type", (unsigned long)size);
if ((tag=H5Tget_tag(type))) {
- printf("\n%*s(tag = \"", ind, "");
- display_string(stdout, tag, FALSE);
- printf("\")");
- free(tag);
+ HDfprintf(rawoutstream, "\n%*s(tag = \"", ind, "");
+ display_string(rawoutstream, tag, FALSE);
+ HDfprintf(rawoutstream, "\")");
+ HDfree(tag);
}
return TRUE;
}
@@ -1066,7 +1141,7 @@ display_vlen_type(hid_t type, int ind)
if (H5T_VLEN!=H5Tget_class(type)) return FALSE;
- printf("variable length of\n%*s", ind+4, "");
+ HDfprintf(rawoutstream, "variable length of\n%*s", ind+4, "");
super = H5Tget_super(type);
display_type(super, ind+4);
H5Tclose(super);
@@ -1097,22 +1172,22 @@ display_array_type(hid_t type, int ind)
if (H5T_ARRAY!=H5Tget_class(type)) return FALSE;
ndims = H5Tget_array_ndims(type);
if (ndims) {
- dims = (hsize_t *)malloc(ndims*sizeof(dims[0]));
+ dims = (hsize_t *)HDmalloc(ndims*sizeof(dims[0]));
H5Tget_array_dims2(type, dims);
/* Print dimensions */
for (i=0; i<ndims; i++)
- HDfprintf(stdout, "%s%Hu" , i?",":"[", dims[i]);
- putchar(']');
+ HDfprintf(rawoutstream, "%s%Hu" , i?",":"[", dims[i]);
+ HDfputc(']', rawoutstream);
- free(dims);
+ HDfree(dims);
} else {
- fputs(" [SCALAR]", stdout);
+ HDfputs(" [SCALAR]", rawoutstream);
}
/* Print parent type */
- putchar(' ');
+ HDfputc(' ', rawoutstream);
super = H5Tget_super(type);
display_type(super, ind+4);
H5Tclose(super);
@@ -1160,7 +1235,7 @@ display_bitfield_type(hid_t type, int ind)
order_s = "";
}
- printf("%lu-bit%s bitfield",
+ HDfprintf(rawoutstream, "%lu-bit%s bitfield",
(unsigned long)(8*H5Tget_size(type)), order_s);
display_precision(type, ind);
return TRUE;
@@ -1194,7 +1269,7 @@ display_type(hid_t type, int ind)
/* Bad data type */
if (type<0) {
- printf("<ERROR>");
+ HDfprintf(rawoutstream, "<ERROR>");
return;
}
@@ -1203,10 +1278,10 @@ display_type(hid_t type, int ind)
H5O_info_t oi;
if(H5Oget_info(type, &oi) >= 0)
- printf("shared-%lu:"H5_PRINTF_HADDR_FMT" ",
+ HDfprintf(rawoutstream, "shared-%lu:"H5_PRINTF_HADDR_FMT" ",
oi.fileno, oi.addr);
else
- printf("shared ");
+ HDfprintf(rawoutstream, "shared ");
} /* end if */
/* Print the type */
@@ -1225,7 +1300,1092 @@ display_type(hid_t type, int ind)
return;
/* Unknown type */
- printf("%lu-byte class-%u unknown",
+ HDfprintf(rawoutstream, "%lu-byte class-%u unknown",
+ (unsigned long)H5Tget_size(type), (unsigned)data_class);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_string
+ *
+ * Purpose: Print a string value by escaping unusual characters. If
+ * STREAM is null then we only count how large the output would
+ * be.
+ *
+ * Return: Number of characters printed.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
+{
+ int nprint=0;
+
+ for (/*void*/; s && *s; s++) {
+ switch (*s) {
+ case '"':
+ h5tools_str_append(buffer, "\\\"");
+ nprint += 2;
+ break;
+ case '\\':
+ h5tools_str_append(buffer, "\\\\");
+ nprint += 2;
+ break;
+ case '\b':
+ h5tools_str_append(buffer, "\\b");
+ nprint += 2;
+ break;
+ case '\f':
+ h5tools_str_append(buffer, "\\f");
+ nprint += 2;
+ break;
+ case '\n':
+ h5tools_str_append(buffer, "\\n");
+ nprint += 2;
+ break;
+ case '\r':
+ h5tools_str_append(buffer, "\\r");
+ nprint += 2;
+ break;
+ case '\t':
+ h5tools_str_append(buffer, "\\t");
+ nprint += 2;
+ break;
+ case ' ':
+ if (escape_spaces) {
+ h5tools_str_append(buffer, "\\ ");
+ nprint += 2;
+ }
+ else {
+ h5tools_str_append(buffer, " ");
+ nprint++;
+ }
+ break;
+ default:
+ if (isprint((int)*s)) {
+ h5tools_str_append(buffer, "%c", *s);
+ nprint++;
+ } else {
+ h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s));
+ nprint += 4;
+ }
+ break;
+ }
+ }
+ return nprint;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_obj_name
+ *
+ * Purpose: Print an object name and another string.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 6, 2007
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
+ const char *s)
+{
+ static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */
+ const char *name = fullname; /* Pointer to buffer for printing */
+ int n;
+
+ if(show_file_name_g)
+ sprintf(fullname, "%s/%s", iter->fname, oname + iter->name_start);
+ else
+ name = oname + iter->name_start;
+
+ /* Print the object name, either full name or base name */
+ if(fullname_g)
+ n = print_string(buffer, name, TRUE);
+ else {
+ const char *last_sep; /* The location of the last group separator */
+
+ /* Find the last component of the path name */
+ if(NULL == (last_sep = HDstrrchr(name, '/')))
+ last_sep = name;
+ else {
+ last_sep++;
+ } /* end else */
+ n = print_string(buffer, last_sep, TRUE);
+ } /* end else */
+ h5tools_str_append(buffer, "%*s ", MAX(0, (24 - n)), s);
+
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_native_type
+ *
+ * Purpose: Prints the name of a native C data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 1999-06-11
+ * Added the C9x types, but we still prefer to display the types
+ * from the C language itself (like `int' vs. `int32_t').
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_native_type(h5tools_str_t *buffer, hid_t type, int UNUSED 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 H5_SIZEOF_LONG_DOUBLE !=0
+ } 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 {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_ieee_type
+ *
+ * Purpose: Print the name of an IEEE floating-point data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_ieee_type(h5tools_str_t *buffer, hid_t type, int UNUSED 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 TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_precision
+ *
+ * Purpose: Prints information on the next line about precision and
+ * padding if the precision is less than the total data type
+ * size.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+print_precision(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ size_t prec; /* precision */
+ H5T_pad_t plsb, pmsb; /* lsb and msb padding */
+ const char *plsb_s=NULL; /* lsb padding string */
+ const char *pmsb_s=NULL; /* msb padding string */
+ size_t nbits; /* number of bits */
+
+ /* If the precision is less than the total size then show the precision
+ * and offset on the following line. Also display the padding
+ * information. */
+ if (8*H5Tget_size(type)!=(prec=H5Tget_precision(type))) {
+ h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)",
+ ind, "", (unsigned long)prec, 1==prec?"":"s",
+ (unsigned long)H5Tget_offset(type));
+
+ H5Tget_pad(type, &plsb, &pmsb);
+ if (H5Tget_offset(type)>0) {
+ switch (plsb) {
+ case H5T_PAD_ZERO:
+ plsb_s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ plsb_s = "one";
+ break;
+ case H5T_PAD_BACKGROUND:
+ plsb_s = "bkg";
+ break;
+ case H5T_PAD_ERROR:
+ case H5T_NPAD:
+ plsb_s = "unknown";
+ break;
+ default:
+ ;
+ break;
+ }
+ }
+ if (H5Tget_offset(type)+prec<8*H5Tget_size(type)) {
+ switch (pmsb) {
+ case H5T_PAD_ZERO:
+ pmsb_s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ pmsb_s = "one";
+ break;
+ case H5T_PAD_BACKGROUND:
+ pmsb_s = "bkg";
+ break;
+ case H5T_PAD_ERROR:
+ case H5T_NPAD:
+ pmsb_s = "unknown";
+ break;
+ default:
+ ;
+ break;
+ }
+ }
+ if (plsb_s || pmsb_s) {
+ h5tools_str_append(buffer, "\n%*s(", ind, "");
+ if (plsb_s) {
+ nbits = H5Tget_offset(type);
+ h5tools_str_append(buffer, "%lu %s bit%s at bit 0",
+ (unsigned long)nbits, plsb_s, 1==nbits?"":"s");
+ }
+ if (plsb_s && pmsb_s) h5tools_str_append(buffer, ", ");
+ if (pmsb_s) {
+ nbits = 8*H5Tget_size(type)-(H5Tget_offset(type)+prec);
+ h5tools_str_append(buffer, "%lu %s bit%s at bit %lu",
+ (unsigned long)nbits, pmsb_s, 1==nbits?"":"s",
+ (unsigned long)(8*H5Tget_size(type)-nbits));
+ }
+ h5tools_str_append(buffer, ")");
+ }
+ }
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_int_type
+ *
+ * Purpose: Print the name of an integer data type. Common information
+ * like number of bits, byte order, and sign scheme appear on
+ * the first line. Additional information might appear in
+ * parentheses on the following lines.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_int_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ H5T_order_t order; /* byte order value */
+ const char *order_s=NULL; /* byte order string */
+ H5T_sign_t sign; /* sign scheme value */
+ const char *sign_s=NULL; /* sign scheme string */
+
+ if (H5T_INTEGER!=H5Tget_class(type)) return FALSE;
+
+ /* Byte order */
+ if (H5Tget_size(type)>1) {
+ 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 = "";
+ }
+
+ /* Sign */
+ 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";
+ }
+
+ /* Print size, order, and sign on first line, precision and padding
+ * information on the subsequent lines */
+ h5tools_str_append(buffer, "%lu-bit%s%s integer",
+ (unsigned long)(8*H5Tget_size(type)), order_s, sign_s);
+ print_precision(buffer, type, ind);
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_float_type
+ *
+ * Purpose: Print info about a floating point data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ H5T_order_t order; /* byte order value */
+ const char *order_s=NULL; /* byte order string */
+ size_t spos; /* sign bit position */
+ size_t esize, epos; /* exponent size and position */
+ size_t msize, mpos; /* significand size and position */
+ size_t ebias; /* exponent bias */
+ H5T_norm_t norm; /* significand normalization */
+ const char *norm_s=NULL; /* normalization string */
+ H5T_pad_t pad; /* internal padding value */
+ const char *pad_s=NULL; /* internal padding string */
+
+ if (H5T_FLOAT!=H5Tget_class(type)) return FALSE;
+
+ /* Byte order */
+ if (H5Tget_size(type)>1) {
+ 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 = "";
+ }
+
+ /* Print size and byte order on first line, precision and padding on
+ * subsequent lines. */
+ h5tools_str_append(buffer, "%lu-bit%s floating-point",
+ (unsigned long)(8*H5Tget_size(type)), order_s);
+ print_precision(buffer, type, ind);
+
+ /* Print sizes, locations, and other information about each field */
+ H5Tget_fields (type, &spos, &epos, &esize, &mpos, &msize);
+ ebias = H5Tget_ebias(type);
+ norm = H5Tget_norm(type);
+ switch (norm) {
+ case H5T_NORM_IMPLIED:
+ norm_s = ", msb implied";
+ break;
+ case H5T_NORM_MSBSET:
+ norm_s = ", msb always set";
+ break;
+ case H5T_NORM_NONE:
+ norm_s = ", no normalization";
+ break;
+ case H5T_NORM_ERROR:
+ norm_s = ", unknown normalization";
+ break;
+ default:
+ ;
+ break;
+ }
+ h5tools_str_append(buffer, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "",
+ (unsigned long)msize, 1==msize?"":"s", (unsigned long)mpos,
+ norm_s);
+ h5tools_str_append(buffer, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)",
+ ind, "", (unsigned long)esize, 1==esize?"":"s",
+ (unsigned long)epos, (unsigned long)ebias);
+ h5tools_str_append(buffer, "\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos);
+
+ /* Display internal padding */
+ if (1+esize+msize<H5Tget_precision(type)) {
+ pad = H5Tget_inpad(type);
+ switch (pad) {
+ case H5T_PAD_ZERO:
+ pad_s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ pad_s = "one";
+ break;
+ case H5T_PAD_BACKGROUND:
+ pad_s = "bkg";
+ break;
+ case H5T_PAD_ERROR:
+ case H5T_NPAD:
+ pad_s = "unknown";
+ break;
+ default:
+ ;
+ break;
+ }
+ h5tools_str_append(buffer, "\n%*s(internal padding bits are %s)", ind, "", pad_s);
+ }
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_cmpd_type
+ *
+ * Purpose: Print info about a compound data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ char *name=NULL; /* member name */
+ size_t size; /* total size of type in bytes */
+ hid_t subtype; /* member data type */
+ unsigned nmembs; /* number of members */
+ int n; /* miscellaneous counters */
+ unsigned i; /* miscellaneous counters */
+
+ if (H5T_COMPOUND!=H5Tget_class(type)) return FALSE;
+ h5tools_str_append(buffer, "struct {");
+ nmembs=H5Tget_nmembers(type);
+ for (i=0; i<nmembs; i++) {
+
+ /* Name and offset */
+ name = H5Tget_member_name(type, i);
+ h5tools_str_append(buffer, "\n%*s\"", ind+4, "");
+ n = print_string(buffer, name, FALSE);
+ h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16-n), "",
+ (unsigned long)H5Tget_member_offset(type, i));
+ HDfree(name);
+
+ /* Member's type */
+ subtype = H5Tget_member_type(type, i);
+ print_type(buffer, subtype, ind+4);
+ H5Tclose(subtype);
+ }
+ size = H5Tget_size(type);
+ h5tools_str_append(buffer, "\n%*s} %lu byte%s",
+ ind, "", (unsigned long)size, 1==size?"":"s");
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_enum_type
+ *
+ * Purpose: Print info about an enumeration data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, December 23, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ char **name=NULL; /* member names */
+ unsigned char *value=NULL; /* value array */
+ unsigned char *copy = NULL; /* a pointer to value array */
+ unsigned nmembs; /* number of members */
+ int nchars; /* number of output characters */
+ hid_t super; /* enum base integer type */
+ hid_t native=-1; /* native integer data type */
+ size_t dst_size; /* destination value type size */
+ unsigned i; /* miscellaneous counters */
+ size_t j;
+
+ if (H5T_ENUM!=H5Tget_class(type)) return FALSE;
+ nmembs = H5Tget_nmembers(type);
+ HDassert(nmembs>0);
+ super = H5Tget_super(type);
+ h5tools_str_append(buffer, "enum ");
+ print_type(buffer, super, ind+4);
+ h5tools_str_append(buffer, " {");
+
+ /* Determine what data type to use for the native values. To simplify
+ * things we entertain three possibilities:
+ * 1. long long -- the largest native signed integer
+ * 2. unsigned long long -- the largest native unsigned integer
+ * 3. raw format */
+ if (H5Tget_size(type)<=sizeof(long long)) {
+ dst_size = sizeof(long long);
+ if (H5T_SGN_NONE==H5Tget_sign(type)) {
+ native = H5T_NATIVE_ULLONG;
+ } else {
+ native = H5T_NATIVE_LLONG;
+ }
+ } else {
+ dst_size = H5Tget_size(type);
+ }
+
+ /* Get the names and raw values of all members */
+ name = HDcalloc(nmembs, sizeof(char*));
+ value = (unsigned char *)HDcalloc(nmembs, MAX(H5Tget_size(type), dst_size));
+ for (i=0; i<nmembs; i++) {
+ name[i] = H5Tget_member_name(type, i);
+ H5Tget_member_value(type, i, value+i*H5Tget_size(type));
+ }
+
+ /* Convert values to native data type */
+ if (native>0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
+
+ /* Sort members by increasing value */
+ /*not implemented yet*/
+
+ /* Print members */
+ for (i=0; i<nmembs; i++) {
+ h5tools_str_append(buffer, "\n%*s", ind+4, "");
+ nchars = print_string(buffer, name[i], TRUE);
+ h5tools_str_append(buffer, "%*s = ", MAX(0, 16-nchars), "");
+
+ if (native<0) {
+ 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".*/
+ copy = value+i*dst_size;
+ h5tools_str_append(buffer, "%"H5_PRINTF_LL_WIDTH"d",
+ *((long long*)((void*)copy)));
+ }
+ }
+
+ /* Release resources */
+ for (i=0; i<nmembs; i++) HDfree(name[i]);
+ HDfree(name);
+ HDfree(value);
+ H5Tclose(super);
+
+ if (0==nmembs) h5tools_str_append(buffer, "\n%*s <empty>", ind+4, "");
+ h5tools_str_append(buffer, "\n%*s}", ind, "");
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_string_type
+ *
+ * Purpose: Print information about a string data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_string_type(h5tools_str_t *buffer, hid_t type, int UNUSED ind)
+{
+ H5T_str_t pad;
+ const char *pad_s=NULL;
+ H5T_cset_t cset;
+ const char *cset_s=NULL;
+
+ if (H5T_STRING!=H5Tget_class(type)) return FALSE;
+
+ /* Padding */
+ pad = H5Tget_strpad(type);
+ switch (pad) {
+ case H5T_STR_NULLTERM:
+ pad_s = "null-terminated";
+ break;
+ case H5T_STR_NULLPAD:
+ pad_s = "null-padded";
+ break;
+ case H5T_STR_SPACEPAD:
+ pad_s = "space-padded";
+ break;
+ case H5T_STR_RESERVED_3:
+ case H5T_STR_RESERVED_4:
+ case H5T_STR_RESERVED_5:
+ case H5T_STR_RESERVED_6:
+ case H5T_STR_RESERVED_7:
+ case H5T_STR_RESERVED_8:
+ case H5T_STR_RESERVED_9:
+ case H5T_STR_RESERVED_10:
+ case H5T_STR_RESERVED_11:
+ case H5T_STR_RESERVED_12:
+ case H5T_STR_RESERVED_13:
+ case H5T_STR_RESERVED_14:
+ case H5T_STR_RESERVED_15:
+ case H5T_STR_ERROR:
+ pad_s = "unknown-format";
+ break;
+ default:
+ ;
+ break;
+ }
+
+ /* Character set */
+ cset = H5Tget_cset(type);
+ switch (cset) {
+ case H5T_CSET_ASCII:
+ cset_s = "ASCII";
+ break;
+ case H5T_CSET_UTF8:
+ cset_s = "UTF-8";
+ break;
+ case H5T_CSET_RESERVED_2:
+ case H5T_CSET_RESERVED_3:
+ case H5T_CSET_RESERVED_4:
+ case H5T_CSET_RESERVED_5:
+ case H5T_CSET_RESERVED_6:
+ case H5T_CSET_RESERVED_7:
+ case H5T_CSET_RESERVED_8:
+ case H5T_CSET_RESERVED_9:
+ case H5T_CSET_RESERVED_10:
+ case H5T_CSET_RESERVED_11:
+ case H5T_CSET_RESERVED_12:
+ case H5T_CSET_RESERVED_13:
+ case H5T_CSET_RESERVED_14:
+ case H5T_CSET_RESERVED_15:
+ case H5T_CSET_ERROR:
+ cset_s = "unknown-character-set";
+ break;
+ default:
+ ;
+ break;
+ }
+
+ if (H5Tis_variable_str(type)) {
+ h5tools_str_append(buffer, "variable-length");
+ }
+ else {
+ h5tools_str_append(buffer, "%lu-byte", (unsigned long)H5Tget_size(type));
+ }
+ h5tools_str_append(buffer, " %s %s string", pad_s, cset_s);
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_reference_type
+ *
+ * Purpose: Prints information about a reference data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 1999-06-04
+ * Knows about object and dataset region references.
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_reference_type(h5tools_str_t *buffer, hid_t type, int UNUSED ind)
+{
+ if (H5T_REFERENCE!=H5Tget_class(type)) return FALSE;
+
+ 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));
+ }
+
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_opaque_type
+ *
+ * Purpose: Prints information about an opaque data type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 7, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ char *tag;
+ size_t size;
+
+ if (H5T_OPAQUE!=H5Tget_class(type)) return FALSE;
+
+ size = H5Tget_size(type);
+ h5tools_str_append(buffer, "%lu-byte opaque type", (unsigned long)size);
+ if ((tag=H5Tget_tag(type))) {
+ h5tools_str_append(buffer, "\n%*s(tag = \"", ind, "");
+ print_string(buffer, tag, FALSE);
+ h5tools_str_append(buffer, "\")");
+ HDfree(tag);
+ }
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_vlen_type
+ *
+ * Purpose: Print information about a variable-length type
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE
+ *
+ * Programmer: Robb Matzke
+ * Friday, December 1, 2000
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ hid_t super;
+
+ if (H5T_VLEN!=H5Tget_class(type)) return FALSE;
+
+ h5tools_str_append(buffer, "variable length of\n%*s", ind+4, "");
+ super = H5Tget_super(type);
+ print_type(buffer, super, ind+4);
+ H5Tclose(super);
+ return TRUE;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Purpose: Print information about an array type
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE
+ *
+ * Programmer: Robb Matzke
+ * Thursday, January 31, 2002
+ *
+ * Modifications:
+ *---------------------------------------------------------------------------
+ */
+static hbool_t
+print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ hid_t super;
+ int ndims, i;
+ hsize_t *dims=NULL;
+
+ if (H5T_ARRAY!=H5Tget_class(type)) return FALSE;
+ ndims = H5Tget_array_ndims(type);
+ if (ndims) {
+ dims = (hsize_t *)HDmalloc(ndims*sizeof(dims[0]));
+ H5Tget_array_dims2(type, dims);
+
+ /* Print dimensions */
+ for (i=0; i<ndims; i++)
+ h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT , i?",":"[", dims[i]);
+ h5tools_str_append(buffer, "]");
+
+ HDfree(dims);
+ }
+ else {
+ h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream);
+ }
+
+
+ /* Print parent type */
+ h5tools_str_append(buffer, " ");
+ super = H5Tget_super(type);
+ print_type(buffer, super, ind+4);
+ H5Tclose(super);
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_bitfield_type
+ *
+ * Purpose: Print information about a bitfield type.
+ *
+ * Return: Success: TRUE
+ *
+ * Failure: FALSE, nothing printed
+ *
+ * Programmer: Pedro Vicente
+ * Tuesday, May 20, 2003
+ *
+ * Modifications:
+ * Robb Matzke, LLNL 2003-06-05
+ * Generalized Pedro's original if/then/else. Also display
+ * precision/offset information.
+ *-------------------------------------------------------------------------
+ */
+static hbool_t
+print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ H5T_order_t order; /* byte order value */
+ const char *order_s=NULL; /* byte order string */
+
+ if (H5T_BITFIELD!=H5Tget_class(type)) return FALSE;
+ if (H5Tget_size(type)>1) {
+ 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 = "";
+ }
+
+ h5tools_str_append(buffer, "%lu-bit%s bitfield",
+ (unsigned long)(8*H5Tget_size(type)), order_s);
+ print_precision(buffer, type, ind);
+ return TRUE;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: print_type
+ *
+ * Purpose: Prints a data type definition. The definition is printed
+ * without any leading space or trailing line-feed (although
+ * there might be line-feeds inside the type definition). The
+ * first line is assumed to have IND characters before it on
+ * the same line (printed by the caller).
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 5, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 1999-06-11
+ * Prints the OID of shared data types.
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+print_type(h5tools_str_t *buffer, hid_t type, int ind)
+{
+ H5T_class_t data_class = H5Tget_class(type);
+
+ /* Bad data type */
+ if (type<0) {
+ h5tools_str_append(buffer,"<ERROR>");
+ return;
+ }
+
+ /* Shared? If so then print the type's OID */
+ if(H5Tcommitted(type)) {
+ H5O_info_t oi;
+
+ if(H5Oget_info(type, &oi) >= 0)
+ h5tools_str_append(buffer,"shared-%lu:"H5_PRINTF_HADDR_FMT" ",
+ oi.fileno, oi.addr);
+ else
+ h5tools_str_append(buffer,"shared ");
+ } /* end if */
+
+ /* Print the type */
+ if((!simple_output_g && 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) ||
+ print_reference_type(buffer, type, ind) ||
+ print_vlen_type(buffer, type, ind) ||
+ print_array_type(buffer, type, ind) ||
+ print_opaque_type(buffer, type, ind) ||
+ print_bitfield_type(buffer, type, ind))
+ return;
+
+ /* Unknown type */
+ h5tools_str_append(buffer,"%lu-byte class-%u unknown",
(unsigned long)H5Tget_size(type), (unsigned)data_class);
}
@@ -1249,98 +2409,115 @@ display_type(hid_t type, int ind)
static void
dump_dataset_values(hid_t dset)
{
+ char string_prefix[64];
+ static char fmt_double[16];
+ static char fmt_float[16];
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ 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);
- h5tool_format_t info;
- char string_prefix[64];
- static char fmt_double[16], fmt_float[16];
- /* Set to all default values and then override */
- memset(&info, 0, sizeof info);
+ HDmemset(&ctx, 0, sizeof(ctx));
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ outputformat = *info;
+ outputformat.line_1st = NULL;
if (simple_output_g) {
- info.idx_fmt = "";
- info.line_ncols = 65535; /*something big*/
- info.line_per_line = 1;
- info.line_multi_new = 0;
- info.line_pre = " ";
- info.line_cont = " ";
-
- info.arr_pre = "";
- info.arr_suf = "";
- info.arr_sep = " ";
-
- if (label_g)
- {
- info.cmpd_pre = "{";
- info.cmpd_suf = "}";
- }
- else
- {
- info.cmpd_pre = "";
- info.cmpd_suf = "";
+ outputformat.idx_fmt = "";
+ outputformat.line_per_line = 1;
+ outputformat.line_multi_new = 0;
+ outputformat.line_pre = " ";
+ outputformat.line_cont = " ";
+
+ outputformat.arr_pre = "";
+ outputformat.arr_suf = "";
+ outputformat.arr_sep = " ";
+
+ if (!label_g) {
+ outputformat.cmpd_pre = "";
+ outputformat.cmpd_suf = "";
}
- info.cmpd_sep = " ";
+ outputformat.cmpd_sep = " ";
- if (label_g) info.cmpd_name = "%s=";
+ if (label_g) outputformat.cmpd_name = "%s=";
- info.elmt_suf1 = " ";
- info.str_locale = ESCAPE_HTML;
+ outputformat.elmt_suf1 = " ";
+ outputformat.str_locale = ESCAPE_HTML;
- } else {
- info.idx_fmt = "(%s)";
+ }
+ else {
if (no_line_wrap_g) {
- info.line_ncols = 65535;
- info.line_per_line = 1;
+ outputformat.line_per_line = 1;
}
- else
- info.line_ncols = width_g;
- info.line_multi_new = 1;
- if (label_g) info.cmpd_name = "%s=";
- info.line_pre = " %s ";
- info.line_cont = " %s ";
- info.str_repeat = 8;
+ else {
+ outputformat.line_ncols = width_g;
+ }
+ if (label_g) outputformat.cmpd_name = "%s=";
+ outputformat.line_pre = " %s ";
+ outputformat.line_cont = " %s ";
+ outputformat.str_repeat = 8;
+
+ outputformat.arr_pre = NULL;
+ outputformat.arr_suf = NULL;
+ outputformat.arr_sep = NULL;
+
+ outputformat.cmpd_pre = NULL;
+ outputformat.cmpd_suf = NULL;
+ outputformat.cmpd_sep = NULL;
+
+ outputformat.vlen_sep = NULL;
+ outputformat.vlen_pre = NULL;
+ outputformat.vlen_suf = NULL;
+ outputformat.vlen_end = NULL;
}
-
+ outputformat.arr_linebreak = 0;
/* Floating point types should display full precision */
sprintf(fmt_float, "%%1.%dg", FLT_DIG);
- info.fmt_float = fmt_float;
+ outputformat.fmt_float = fmt_float;
sprintf(fmt_double, "%%1.%dg", DBL_DIG);
- info.fmt_double = fmt_double;
-
- info.dset_format = "DSET-%s ";
- info.dset_hidefileno = 0;
-
- info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
- info.obj_hidefileno = 0;
-
- info.dset_blockformat_pre = "%sBlk%lu: ";
- info.dset_ptformat_pre = "%sPt%lu: ";
-
- info.line_indent = "";
+ outputformat.fmt_double = fmt_double;
if (hexdump_g) {
/* Print all data in hexadecimal format if the `-x' or `--hexdump'
* command line switch was given. */
- info.raw = TRUE;
- } else if (string_g && 1==size && H5T_INTEGER==H5Tget_class(f_type)) {
+ 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. */
- info.ascii = TRUE;
- info.elmt_suf1 = "";
- info.elmt_suf2 = "";
- strcpy(string_prefix, info.line_pre);
+ outputformat.ascii = TRUE;
+ outputformat.elmt_suf1 = "";
+ outputformat.elmt_suf2 = "";
+ strcpy(string_prefix, outputformat.line_pre);
strcat(string_prefix, "\"");
- info.line_pre = string_prefix;
- info.line_suf = "\"";
+ outputformat.line_pre = string_prefix;
+ outputformat.line_suf = "\"";
}
+ info = &outputformat;
+ ctx.indent_level = 2;
+ ctx.cur_column = curr_pos;
/* Print all the values. */
- printf(" Data:\n");
- if (h5tools_dump_dset(stdout, &info, dset, -1, NULL, -1) < 0)
- printf(" Unable to print data.\n");
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Data:\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ ctx.need_prefix = TRUE;
+ ctx.cur_column = curr_pos;
+ if (h5tools_dump_dset(rawoutstream, info, &ctx, dset, -1, NULL) < 0) {
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Unable to print data.");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ }
H5Tclose(f_type);
+
+ HDfprintf(rawoutstream, "\n");
+
+ h5tools_str_close(&buffer);
}
@@ -1364,18 +2541,32 @@ static herr_t
list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
void UNUSED *op_data)
{
- hid_t attr, space, type, p_type;
- hsize_t size[H5S_MAX_RANK], nelmts = 1;
- int ndims, i, n;
- size_t need;
- hsize_t temp_need;
- void *buf;
- h5tool_format_t info;
- H5S_class_t space_type;
-
- printf(" Attribute: ");
- n = display_string(stdout, attr_name, TRUE);
- printf("%*s", MAX(0, (9 - n)), "");
+ hid_t attr = -1;
+ hid_t space = -1;
+ hid_t type = -1;
+ hid_t p_type = -1;
+ hsize_t size[H5S_MAX_RANK];
+ hsize_t nelmts = 1;
+ hsize_t temp_need;
+ size_t need;
+ int ndims;
+ int i;
+ int n;
+ void *buf;
+ H5S_class_t space_type;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t *info = &ls_dataformat;
+ h5tool_format_t outputformat;
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Attribute: ");
+
+ n = print_string(&buffer, attr_name, TRUE);
if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
space = H5Aget_space(attr);
@@ -1387,74 +2578,89 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
switch(space_type) {
case H5S_SCALAR:
/* scalar dataspace */
- puts(" scalar");
+ h5tools_str_append(&buffer, " scalar\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
case H5S_SIMPLE:
/* simple dataspace */
- printf(" {");
+ h5tools_str_append(&buffer, " {");
for (i=0; i<ndims; i++) {
- HDfprintf(stdout, "%s%Hu", i?", ":"", size[i]);
+ h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i?", ":"", size[i]);
nelmts *= size[i];
}
- puts("}");
+ h5tools_str_append(&buffer, "}\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
case H5S_NULL:
/* null dataspace */
- puts(" null");
+ h5tools_str_append(&buffer, " null\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
default:
/* Unknown dataspace type */
- puts(" unknown");
+ h5tools_str_append(&buffer, " unknown\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
} /* end switch */
/* Data type */
- printf(" Type: ");
- display_type(type, 15);
- putchar('\n');
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Type: ");
+ print_type(&buffer, type, 15);
+ h5tools_str_append(&buffer, "\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
/* Data */
- memset(&info, 0, sizeof info);
- info.line_multi_new = 1;
+ outputformat = *info;
+
if(nelmts < 5) {
- info.idx_fmt = "";
- info.line_1st = " Data: ";
- info.line_pre = " ";
- info.line_cont = " ";
- info.str_repeat = 8;
+ outputformat.idx_fmt = "";
+ outputformat.line_1st = " Data: ";
+ outputformat.line_pre = " ";
+ outputformat.line_cont = " ";
+ outputformat.str_repeat = 8;
- } else {
- printf(" Data:\n");
- info.idx_fmt = "(%s)";
- info.line_pre = " %s ";
- info.line_cont = " %s ";
- info.str_repeat = 8;
+ }
+ else {
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Data:\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ outputformat.line_1st = NULL;
+ outputformat.line_pre = " %s ";
+ outputformat.line_cont = " %s ";
+ outputformat.str_repeat = 8;
}
- info.line_ncols = width_g;
+ outputformat.line_ncols = width_g;
if(label_g)
- info.cmpd_name = "%s=";
+ outputformat.cmpd_name = "%s=";
if(string_g && 1==H5Tget_size(type) &&
H5T_INTEGER==H5Tget_class(type)) {
- info.ascii = TRUE;
- info.elmt_suf1 = "";
- info.elmt_suf2 = "";
- info.idx_fmt = "(%s)";
- info.line_pre = " %s \"";
- info.line_suf = "\"";
+ outputformat.ascii = TRUE;
+ outputformat.elmt_suf1 = "";
+ outputformat.elmt_suf2 = "";
+ outputformat.line_pre = " %s \"";
+ outputformat.line_suf = "\"";
} /* end if */
- /* values of reference type formats */
- info.dset_format = "DSET-%s ";
- info.dset_hidefileno = 1;
- info.dset_blockformat_pre = "%sBlk%lu: ";
- info.dset_ptformat_pre = "%sPt%lu: ";
- info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
- info.obj_hidefileno = 0;
+ outputformat.arr_pre = NULL;
+ outputformat.arr_suf = NULL;
+ outputformat.arr_sep = NULL;
+
+ outputformat.cmpd_pre = NULL;
+ outputformat.cmpd_suf = NULL;
+ outputformat.cmpd_sep = NULL;
+
+ outputformat.vlen_sep = NULL;
+ outputformat.vlen_pre = NULL;
+ outputformat.vlen_suf = NULL;
+ outputformat.vlen_end = NULL;
+
+ info = &outputformat;
if(hexdump_g)
p_type = H5Tcopy(type);
@@ -1470,26 +2676,35 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
vl_data = TRUE;
temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- assert(temp_need == (hsize_t)((size_t)temp_need));
+ HDassert(temp_need == (hsize_t)((size_t)temp_need));
need = (size_t)temp_need;
- buf = malloc(need);
- assert(buf);
- if(H5Aread(attr, p_type, buf) >= 0)
- h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1);
+ buf = HDmalloc(need);
+ HDassert(buf);
+ if(H5Aread(attr, p_type, buf) >= 0) {
+ ctx.need_prefix = TRUE;
+ ctx.indent_level = 2;
+ ctx.cur_column = curr_pos;
+ h5tools_dump_mem(rawoutstream, info, &ctx, attr, p_type, space, buf);
+ }
/* Reclaim any VL memory, if necessary */
if (vl_data)
H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
- free(buf);
+ HDfree(buf);
H5Tclose(p_type);
} /* end if */
+ HDfprintf(rawoutstream, "\n");
H5Sclose(space);
H5Tclose(type);
H5Aclose(attr);
- } else
- putchar('\n');
+ }
+ else {
+ HDfprintf(rawoutstream, "\n");
+ }
+
+ h5tools_str_close(&buffer);
return 0;
}
@@ -1531,16 +2746,16 @@ dataset_list1(hid_t dset)
ndims = H5Sget_simple_extent_dims(space, cur_size, max_size);
printf (" {");
for (i=0; i<ndims; i++) {
- HDfprintf (stdout, "%s%Hu", i?", ":"", cur_size[i]);
+ HDfprintf (rawoutstream, "%s%Hu", i?", ":"", cur_size[i]);
if (max_size[i]==H5S_UNLIMITED) {
- HDfprintf (stdout, "/%s", "Inf");
+ HDfprintf (rawoutstream, "/%s", "Inf");
} else if (max_size[i]!=cur_size[i] || verbose_g>0) {
- HDfprintf(stdout, "/%Hu", max_size[i]);
+ HDfprintf(rawoutstream, "/%Hu", max_size[i]);
}
}
- if (space_type==H5S_SCALAR) printf("SCALAR");
- else if (space_type==H5S_NULL) printf("NULL");
- putchar('}');
+ if (space_type==H5S_SCALAR) HDfprintf(rawoutstream, "SCALAR");
+ else if (space_type==H5S_NULL) HDfprintf(rawoutstream, "NULL");
+ HDfputc('}', rawoutstream);
H5Sclose (space);
return 0;
@@ -1597,48 +2812,46 @@ dataset_list2(hid_t dset, const char UNUSED *name)
hsize_t chsize[64]; /* chunk size in elements */
ndims = H5Pget_chunk(dcpl, NELMTS(chsize), chsize/*out*/);
- printf(" %-10s {", "Chunks:");
+ HDfprintf(rawoutstream, " %-10s {", "Chunks:");
total = H5Tget_size(type);
for (i=0; i<ndims; i++) {
- printf("%s%lu", i?", ":"", (unsigned long)(chsize[i]));
+ HDfprintf(rawoutstream, "%s%lu", i?", ":"", (unsigned long)(chsize[i]));
total *= chsize[i];
}
- printf("} %lu bytes\n", (unsigned long)total);
+ HDfprintf(rawoutstream, "} %lu bytes\n", (unsigned long)total);
}
/* Print total raw storage size */
total = H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
used = H5Dget_storage_size(dset);
tclass = H5Tget_class(type);
- printf(" %-10s ", "Storage:");
+ HDfprintf(rawoutstream, " %-10s ", "Storage:");
switch (tclass)
{
case H5T_VLEN:
- printf("information not available");
+ HDfprintf(rawoutstream, "information not available");
break;
case H5T_REFERENCE:
if ( H5Tequal(type, H5T_STD_REF_DSETREG))
{
- printf("information not available");
+ HDfprintf(rawoutstream, "information not available");
}
break;
default:
- printf("%lu logical byte%s, %lu allocated byte%s",
+ HDfprintf(rawoutstream, "%lu logical byte%s, %lu allocated byte%s",
(unsigned long)total, 1==total?"":"s",
(unsigned long)used, 1==used?"":"s");
if (used>0)
{
utilization = (total*100.0)/used;
- printf(", %1.2f%% utilization", utilization);
+ HDfprintf(rawoutstream, ", %1.2f%% utilization", utilization);
}
-
}
-
- putchar('\n');
+ HDfputc('\n', rawoutstream);
/* Print information about external strorage */
if((nf = H5Pget_external_count(dcpl)) > 0) {
@@ -1647,37 +2860,37 @@ dataset_list2(hid_t dset, const char UNUSED *name)
n = display_string(NULL, f_name, TRUE);
max_len = MAX(max_len, n);
} /* end for */
- printf(" %-10s %d external file%s\n",
+ HDfprintf(rawoutstream, " %-10s %d external file%s\n",
"Extern:", nf, 1==nf?"":"s");
- printf(" %4s %10s %10s %10s %s\n",
+ HDfprintf(rawoutstream, " %4s %10s %10s %10s %s\n",
"ID", "DSet-Addr", "File-Addr", "Bytes", "File");
- printf(" %4s %10s %10s %10s ",
+ HDfprintf(rawoutstream, " %4s %10s %10s %10s ",
"----", "----------", "----------", "----------");
- for (i=0; i<max_len; i++) putchar('-');
- putchar('\n');
+ for (i=0; i<max_len; i++) HDfputc('-', rawoutstream);
+ HDfputc('\n', rawoutstream);
for (i=0, total=0; i<nf; i++) {
if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size)<0) {
- HDfprintf(stdout,
+ HDfprintf(rawoutstream,
" #%03d %10Hu %10s %10s ***ERROR*** %s\n",
i, total, "", "",
i+1<nf?"Following addresses are incorrect":"");
} else if (H5S_UNLIMITED==f_size) {
- HDfprintf(stdout, " #%03d %10Hu %10Hu %10s ",
+ HDfprintf(rawoutstream, " #%03d %10Hu %10Hu %10s ",
i, total, (hsize_t)f_offset, "INF");
- display_string(stdout, f_name, TRUE);
+ display_string(rawoutstream, f_name, TRUE);
} else {
- HDfprintf(stdout, " #%03d %10Hu %10Hu %10Hu ",
+ HDfprintf(rawoutstream, " #%03d %10Hu %10Hu %10Hu ",
i, total, (hsize_t)f_offset, f_size);
- display_string(stdout, f_name, TRUE);
+ display_string(rawoutstream, f_name, TRUE);
}
- putchar('\n');
+ HDfputc('\n', rawoutstream);
total += f_size;
}
- printf(" %4s %10s %10s %10s ",
+ HDfprintf(rawoutstream, " %4s %10s %10s %10s ",
"----", "----------", "----------", "----------");
for (i=0; i<max_len; i++)
- putchar('-');
- putchar('\n');
+ HDfputc('-', rawoutstream);
+ HDfputc('\n', rawoutstream);
} /* end if */
/* Print information about raw data filters */
@@ -1688,20 +2901,20 @@ dataset_list2(hid_t dset, const char UNUSED *name)
cd_values, sizeof(f_name), f_name, NULL);
f_name[sizeof(f_name) - 1] = '\0';
sprintf(s, "Filter-%d:", i);
- printf(" %-10s %s-%u %s {", s,
+ HDfprintf(rawoutstream, " %-10s %s-%u %s {", s,
(f_name[0] ? f_name : "method"),
(unsigned)filt_id,
((filt_flags & H5Z_FLAG_OPTIONAL) ? "OPT" : ""));
for(cd_num = 0; cd_num < cd_nelmts; cd_num++)
- printf("%s%u", (cd_num ? ", " : ""), cd_values[cd_num]);
- printf("}\n");
+ HDfprintf(rawoutstream, "%s%u", (cd_num ? ", " : ""), cd_values[cd_num]);
+ HDfprintf(rawoutstream, "}\n");
} /* end for */
} /* end if */
/* Print data type */
- printf(" %-10s ", "Type:");
+ HDfprintf(rawoutstream, " %-10s ", "Type:");
display_type(type, 15);
- printf("\n");
+ HDfprintf(rawoutstream, "\n");
/* Print address information */
if(address_g)
@@ -1741,9 +2954,9 @@ static herr_t
datatype_list2(hid_t type, const char UNUSED *name)
{
if (verbose_g>0) {
- printf(" %-10s ", "Type:");
+ HDfprintf(rawoutstream, " %-10s ", "Type:");
display_type(type, 15);
- printf("\n");
+ HDfprintf(rawoutstream, "\n");
}
return 0;
}
@@ -1771,24 +2984,24 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
/* Print the link's name, either full name or base name */
if(!iter->symlink_target)
- display_obj_name(stdout, iter, name, "");
+ display_obj_name(rawoutstream, iter, name, "");
/* Check object information */
if(oinfo->type < 0 || oinfo->type >= H5O_TYPE_NTYPES) {
- printf("Unknown type(%d)", (int)oinfo->type);
+ HDfprintf(rawoutstream, "Unknown type(%d)", (int)oinfo->type);
obj_type = H5O_TYPE_UNKNOWN;
}
if(iter->symlink_target)
- fputc('{', stdout);
+ HDfputc('{', rawoutstream);
if(obj_type >= 0 && dispatch_g[obj_type].name)
- fputs(dispatch_g[obj_type].name, stdout);
+ HDfputs(dispatch_g[obj_type].name, rawoutstream);
/* Check if we've seen this object before */
if(first_seen) {
- printf(", same as ");
- display_string(stdout, first_seen, TRUE);
+ HDfprintf(rawoutstream, ", same as ");
+ display_string(rawoutstream, first_seen, TRUE);
if(!iter->symlink_target)
- printf("\n");
+ HDfprintf(rawoutstream, "\n");
} /* end if */
else {
hid_t obj = (-1); /* ID of object opened */
@@ -1797,7 +3010,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
* then return right away.
*/
if(obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
- printf(" *ERROR*\n");
+ HDfprintf(rawoutstream, " *ERROR*\n");
goto done;
} /* end if */
@@ -1805,7 +3018,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
if(obj_type >= 0 && dispatch_g[obj_type].list1)
(dispatch_g[obj_type].list1)(obj);
if(!iter->symlink_target || (verbose_g > 0))
- putchar('\n');
+ HDfputc('\n', rawoutstream);
/* Show detailed information about the object, beginning with information
* which is common to all objects. */
@@ -1819,8 +3032,8 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
/* Object location & reference count */
- printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr);
- printf(" %-10s %u\n", "Links:", (unsigned)oinfo->rc);
+ HDfprintf(rawoutstream, " %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr);
+ HDfprintf(rawoutstream, " %-10s %u\n", "Links:", (unsigned)oinfo->rc);
/* Modification time */
if(oinfo->mtime > 0) {
@@ -1833,7 +3046,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
tm = HDlocaltime(&(oinfo->mtime));
if(tm) {
HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
- printf(" %-10s %s\n", "Modified:", buf);
+ HDfprintf(rawoutstream, " %-10s %s\n", "Modified:", buf);
} /* end if */
} /* end if */
@@ -1849,9 +3062,9 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
cmt_bufsize = H5Oget_comment(obj, comment, cmt_bufsize);
if(cmt_bufsize > 0) {
comment[cmt_bufsize] = 0;
- printf(" %-10s \"", "Comment:");
- display_string(stdout, comment, FALSE);
- puts("\"");
+ HDfprintf(rawoutstream, " %-10s \"", "Comment:");
+ display_string(rawoutstream, comment, FALSE);
+ HDfputs("\"\n", rawoutstream);
} /* end if */
HDfree(comment);
}
@@ -1869,7 +3082,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
done:
if(iter->symlink_target) {
- fputs("}\n", stdout);
+ HDfputs("}\n", rawoutstream);
iter->symlink_target = FALSE;
}
return 0;
@@ -1900,21 +3113,21 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
h5tool_link_info_t lnk_info;
/* init linkinfo struct */
- memset(&lnk_info, 0, sizeof(h5tool_link_info_t));
+ HDmemset(&lnk_info, 0, sizeof(h5tool_link_info_t));
/* if verbose, make H5tools_get_symlink_info() display more */
if (verbose_g)
lnk_info.opt.msg_mode=1;
/* Print the link's name, either full name or base name */
- display_obj_name(stdout, iter, name, "");
+ display_obj_name(rawoutstream, iter, name, "");
switch(linfo->type) {
case H5L_TYPE_SOFT:
ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_symlink_g);
/* lnk_info.trg_path is malloced in H5tools_get_symlink_info()
* so it will be freed via buf later */
- buf = lnk_info.trg_path;
+ buf = (char*)lnk_info.trg_path;
/* error */
if (ret < 0)
goto done;
@@ -1922,18 +3135,18 @@ 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;
- HDfputs("Soft Link {", stdout);
- HDfputs(buf, stdout);
- HDfputc('}', stdout);
+ HDfputs("Soft Link {", rawoutstream);
+ HDfputs(buf, rawoutstream);
+ HDfputc('}', rawoutstream);
if(follow_symlink_g)
{
hbool_t orig_grp_literal = grp_literal_g;
- HDfputc(' ', stdout);
+ HDfputc(' ', rawoutstream);
/* Check if we have already seen this softlink */
if(symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf))
{
- HDfputs("{Already Visited}\n", stdout);
+ HDfputs("{Already Visited}\n", rawoutstream);
goto done;
}
@@ -1959,7 +3172,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
grp_literal_g = orig_grp_literal;
}
else
- HDfputc('\n', stdout);
+ HDfputc('\n', rawoutstream);
break;
@@ -1972,7 +3185,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_link);
/* lnk_info.trg_path is malloced in H5tools_get_symlink_info()
* so it will be freed via buf later */
- buf = lnk_info.trg_path;
+ buf = (char*)lnk_info.trg_path;
/* error */
if (ret < 0)
goto done;
@@ -1983,25 +3196,25 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0)
goto done;
- HDfputs("External Link {", stdout);
- HDfputs(filename, stdout);
- HDfputc('/', stdout);
+ HDfputs("External Link {", rawoutstream);
+ HDfputs(filename, rawoutstream);
+ HDfputc('/', rawoutstream);
if(*path != '/')
- HDfputc('/', stdout);
- HDfputs(path, stdout);
- HDfputc('}', stdout);
+ HDfputc('/', rawoutstream);
+ HDfputs(path, rawoutstream);
+ HDfputc('}', rawoutstream);
/* Recurse through the external link */
/* keep the follow_elink_g for backward compatibility with -E */
if(follow_link)
{
hbool_t orig_grp_literal = grp_literal_g;
- HDfputc(' ', stdout);
+ HDfputc(' ', rawoutstream);
/* Check if we have already seen this elink */
if(symlink_is_visited(iter->symlink_list, linfo->type, filename, path))
{
- HDfputs("{Already Visited}\n", stdout);
+ HDfputs("{Already Visited}\n", rawoutstream);
goto done;
}
@@ -2029,13 +3242,13 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
grp_literal_g = orig_grp_literal;
}
else
- HDfputc('\n', stdout);
+ HDfputc('\n', rawoutstream);
}
break;
default:
- HDfputs("UD Link {cannot follow UD links}\n", stdout);
+ HDfputs("UD Link {cannot follow UD links}\n", rawoutstream);
break;
} /* end switch */
@@ -2069,11 +3282,11 @@ visit_obj(hid_t file, const char *oname, iter_t *iter)
/* Retrieve info for object to list */
if(H5Oget_info_by_name(file, oname, &oi, H5P_DEFAULT) < 0) {
if(iter->symlink_target) {
- HDfputs("{**NOT FOUND**}\n", stdout);
+ HDfputs("{**NOT FOUND**}\n", rawoutstream);
iter->symlink_target = FALSE;
}
else
- display_obj_name(stdout, iter, oname, "**NOT FOUND**");
+ display_obj_name(rawoutstream, iter, oname, "**NOT FOUND**");
return -1;
} /* end if */
@@ -2081,7 +3294,7 @@ visit_obj(hid_t file, const char *oname, iter_t *iter)
if(H5O_TYPE_GROUP == oi.type && !grp_literal_g) {
/* Get ID for group */
if(!iter->symlink_target && (iter->gid = H5Gopen2(file, oname, H5P_DEFAULT)) < 0) {
- fprintf(stderr, "%s: unable to open '%s' as group\n", iter->fname, oname);
+ HDfprintf(rawerrorstream, "%s: unable to open '%s' as group\n", iter->fname, oname);
return 0; /* Previously "continue", when this code was in main().
* We don't "continue" here in order to close the file
* and free the file name properly. */
@@ -2137,8 +3350,8 @@ get_width(void)
/* Try to get it from the COLUMNS environment variable first since it's
* value is sometimes wrong. */
- if ((s=getenv("COLUMNS")) && *s && isdigit((int)*s))
- width = (int)strtol(s, NULL, 0);
+ if ((s=HDgetenv("COLUMNS")) && *s && isdigit((int)*s))
+ width = (int)HDstrtol(s, NULL, 0);
#if defined(H5_HAVE_STRUCT_VIDEOCONFIG) && defined(H5_HAVE__GETVIDEOCONFIG)
{
@@ -2209,14 +3422,14 @@ is_valid_args(void)
if(recursive_g && grp_literal_g)
{
- fprintf(stderr, "Error: 'recursive' option not compatible with 'group info' option!\n\n");
+ 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)
{
- fprintf(stderr, "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n");
+ HDfprintf(rawerrorstream, "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n");
ret = FALSE;
goto out;
}
@@ -2245,7 +3458,7 @@ leave(int ret)
{
h5tools_close();
- exit(ret);
+ HDexit(ret);
}
@@ -2497,7 +3710,7 @@ main(int argc, const char *argv[])
if(file >= 0) {
if(verbose_g)
- printf("Opened \"%s\" with %s driver.\n", fname, drivername);
+ HDfprintf(rawoutstream, "Opened \"%s\" with %s driver.\n", fname, drivername);
break; /*success*/
} /* end if */
@@ -2512,7 +3725,7 @@ main(int argc, const char *argv[])
} /* end while */
if(file < 0) {
- fprintf(stderr, "%s: unable to open file\n", argv[argno-1]);
+ HDfprintf(rawerrorstream, "%s: unable to open file\n", argv[argno-1]);
HDfree(fname);
err_exit = 1;
continue;
@@ -2525,7 +3738,7 @@ main(int argc, const char *argv[])
iter.base_len -= oname[iter.base_len-1] == '/';
x = oname;
if(NULL == (oname = HDstrdup(oname))) {
- fprintf(stderr, "memory allocation failed\n");
+ HDfprintf(rawerrorstream, "memory allocation failed\n");
leave(EXIT_FAILURE);
}
*x = '\0';
@@ -2559,7 +3772,7 @@ main(int argc, const char *argv[])
if(HDstrcmp(oname, root_name)) {
/* Check the type of link given */
if(H5Lget_info(file, oname, &li, H5P_DEFAULT) < 0) {
- display_obj_name(stdout, &iter, oname, "**NOT FOUND**");
+ display_obj_name(rawoutstream, &iter, oname, "**NOT FOUND**");
leave(EXIT_FAILURE);
} /* end if */
} /* end if */