summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c82
1 files changed, 56 insertions, 26 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index a0288a0..217ef06 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -36,6 +36,7 @@ hid_t H5tools_ERR_CLS_g = -1;
hid_t H5E_tools_g = -1;
hid_t H5E_tools_min_id_g = -1;
int compound_data;
+FILE *rawattrstream; /* should initialize to stdout but gcc moans about it */
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
FILE *rawoutstream; /* should initialize to stdout but gcc moans about it */
FILE *rawerrorstream; /* should initialize to stderr but gcc moans about it */
@@ -115,6 +116,8 @@ h5tools_init(void)
H5tools_ERR_STACK_g = H5Ecreate_stack();
H5TOOLS_INIT_ERROR()
+ if (!rawattrstream)
+ rawattrstream = stdout;
if (!rawdatastream)
rawdatastream = stdout;
if (!rawoutstream)
@@ -150,9 +153,19 @@ h5tools_close(void)
H5E_auto2_t tools_func;
void *tools_edata;
if (h5tools_init_g) {
+ /* special case where only data is output to stdout */
+ if((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
+ HDfprintf(rawdatastream, "\n");
+
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
if(tools_func!=NULL)
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
+ if (rawattrstream && rawattrstream != stdout) {
+ if (fclose(rawattrstream))
+ perror("closing rawattrstream");
+ else
+ rawattrstream = NULL;
+ }
if (rawdatastream && rawdatastream != stdout) {
if (fclose(rawdatastream))
perror("closing rawdatastream");
@@ -569,6 +582,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
size_t templength = 0;
int i, indentlevel = 0;
+ if (stream == NULL)
+ return;
+
if (!ctx->need_prefix)
return;
@@ -577,9 +593,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -603,23 +619,26 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
the prefix is printed one indentation level before */
if (info->pindex) {
for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&str, 0, info->line_indent), stream);
}
}
- if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
- else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
- else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ }
+ else if (secnum && info->line_cont) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ }
+ else {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ }
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
@@ -658,6 +677,9 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
size_t templength = 0;
int i, indentlevel = 0;
+ if (stream == NULL)
+ return;
+
if (!ctx->need_prefix)
return;
@@ -666,9 +688,9 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -692,23 +714,26 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
the prefix is printed one indentation level before */
if (info->pindex) {
for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&str, 0, info->line_indent), stream);
}
}
- if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
- else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
- else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ }
+ else if (secnum && info->line_cont) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ }
+ else {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ }
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
@@ -762,6 +787,9 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
int secnum; /*section sequence number */
int multiline; /*datum was multiline */
+ if (stream == NULL)
+ return dimension_break;
+
s = h5tools_str_fmt(buffer, 0, "%s");
/*
@@ -866,12 +894,12 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
@@ -1022,12 +1050,12 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
@@ -1212,7 +1240,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_REFERENCE:
{
- if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ if (size == H5R_DSET_REG_REF_BUF_SIZE) {
+ /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
if (region_output) {
/* region data */
hid_t region_id, region_space;
@@ -1236,7 +1265,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
}
} /* end if (region_output... */
}
- else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ else if (size == H5R_OBJ_REF_BUF_SIZE) {
+ /* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */
;
}
}