summaryrefslogtreecommitdiffstats
path: root/tools/h5ls/h5ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5ls/h5ls.c')
-rw-r--r--tools/h5ls/h5ls.c386
1 files changed, 192 insertions, 194 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 6337231..3e335e9 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -176,7 +176,7 @@ static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
static void
usage (void)
{
- HDfprintf(stderr, "\
+ HDfprintf(rawerrorstream, "\
usage: %s [OPTIONS] [OBJECTS...]\n\
OPTIONS\n\
-h, -?, --help Print a usage message and exit\n\
@@ -301,7 +301,7 @@ display_string(FILE *stream, const char *s, hbool_t escape_spaces)
break;
default:
if (isprint((int)*s)) {
- if (stream) putc(*s, stream);
+ if (stream) HDfputc(*s, stream);
nprint++;
} else {
if (stream) {
@@ -359,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;
}
@@ -388,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;
}
@@ -506,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;
}
@@ -549,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));
@@ -595,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, ")");
}
}
}
@@ -674,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;
@@ -731,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);
@@ -756,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)) {
@@ -785,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;
}
@@ -818,15 +818,15 @@ 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));
HDfree(name);
@@ -836,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;
}
@@ -876,9 +876,9 @@ display_enum_type(hid_t type, int ind)
nmembs = H5Tget_nmembers(type);
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:
@@ -912,25 +912,25 @@ 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)));
}
}
@@ -941,8 +941,8 @@ display_enum_type(hid_t type, int ind)
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;
}
@@ -1038,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;
}
@@ -1071,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));
}
@@ -1108,11 +1108,11 @@ 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("\")");
+ HDfprintf(rawoutstream, "\n%*s(tag = \"", ind, "");
+ display_string(rawoutstream, tag, FALSE);
+ HDfprintf(rawoutstream, "\")");
HDfree(tag);
}
return TRUE;
@@ -1141,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);
@@ -1177,17 +1177,17 @@ display_array_type(hid_t type, int ind)
/* 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);
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);
@@ -1235,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;
@@ -1269,7 +1269,7 @@ display_type(hid_t type, int ind)
/* Bad data type */
if (type<0) {
- printf("<ERROR>");
+ HDfprintf(rawoutstream, "<ERROR>");
return;
}
@@ -1278,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 */
@@ -1300,7 +1300,7 @@ 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);
}
@@ -2267,7 +2267,7 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
HDfree(dims);
}
else {
- h5tools_str_append(buffer, " [SCALAR]\n", stdout);
+ h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream);
}
@@ -2504,18 +2504,18 @@ dump_dataset_values(hid_t dset)
/* Print all the values. */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Data:\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ 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(stdout, info, &ctx, dset, -1, NULL) < 0) {
+ 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(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
}
H5Tclose(f_type);
- HDfprintf(stdout, "\n");
+ HDfprintf(rawoutstream, "\n");
h5tools_str_close(&buffer);
}
@@ -2579,7 +2579,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
case H5S_SCALAR:
/* scalar dataspace */
h5tools_str_append(&buffer, " scalar\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
case H5S_SIMPLE:
@@ -2590,19 +2590,19 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
nelmts *= size[i];
}
h5tools_str_append(&buffer, "}\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
case H5S_NULL:
/* null dataspace */
h5tools_str_append(&buffer, " null\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
default:
/* Unknown dataspace type */
h5tools_str_append(&buffer, " unknown\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
break;
} /* end switch */
@@ -2611,7 +2611,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
h5tools_str_append(&buffer, " Type: ");
print_type(&buffer, type, 15);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
/* Data */
outputformat = *info;
@@ -2627,7 +2627,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
else {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Data:\n");
- h5tools_render_element(stdout, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0);
+ 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 ";
@@ -2684,7 +2684,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
ctx.need_prefix = TRUE;
ctx.indent_level = 2;
ctx.cur_column = curr_pos;
- h5tools_dump_mem(stdout, info, &ctx, attr, p_type, space, buf);
+ h5tools_dump_mem(rawoutstream, info, &ctx, attr, p_type, space, buf);
}
/* Reclaim any VL memory, if necessary */
@@ -2694,14 +2694,14 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
HDfree(buf);
H5Tclose(p_type);
} /* end if */
- HDfprintf(stdout, "\n");
+ HDfprintf(rawoutstream, "\n");
H5Sclose(space);
H5Tclose(type);
H5Aclose(attr);
}
else {
- HDfprintf(stdout, "\n");
+ HDfprintf(rawoutstream, "\n");
}
h5tools_str_close(&buffer);
@@ -2746,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;
@@ -2812,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) {
@@ -2862,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 */
@@ -2903,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)
@@ -2956,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;
}
@@ -2986,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 */
@@ -3012,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 */
@@ -3020,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. */
@@ -3034,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) {
@@ -3048,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 */
@@ -3064,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);
}
@@ -3084,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;
@@ -3122,7 +3120,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
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:
@@ -3137,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;
}
@@ -3174,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;
@@ -3198,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;
}
@@ -3244,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 */
@@ -3284,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 */
@@ -3296,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) {
- HDfprintf(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. */
@@ -3424,14 +3422,14 @@ is_valid_args(void)
if(recursive_g && grp_literal_g)
{
- HDfprintf(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)
{
- HDfprintf(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;
}
@@ -3712,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 */
@@ -3727,7 +3725,7 @@ main(int argc, const char *argv[])
} /* end while */
if(file < 0) {
- HDfprintf(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;
@@ -3740,7 +3738,7 @@ main(int argc, const char *argv[])
iter.base_len -= oname[iter.base_len-1] == '/';
x = oname;
if(NULL == (oname = HDstrdup(oname))) {
- HDfprintf(stderr, "memory allocation failed\n");
+ HDfprintf(rawerrorstream, "memory allocation failed\n");
leave(EXIT_FAILURE);
}
*x = '\0';
@@ -3774,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 */