summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5diff/Makefile.am2
-rw-r--r--tools/h5diff/Makefile.in2
-rw-r--r--tools/h5dump/h5dump.c176
-rw-r--r--tools/h5jam/h5unjam.c149
-rw-r--r--tools/lib/h5tools.c267
-rw-r--r--tools/lib/h5tools.h8
6 files changed, 333 insertions, 271 deletions
diff --git a/tools/h5diff/Makefile.am b/tools/h5diff/Makefile.am
index 190c083..05417f5 100644
--- a/tools/h5diff/Makefile.am
+++ b/tools/h5diff/Makefile.am
@@ -43,7 +43,7 @@ TEST_SCRIPT=testh5diff.sh
check_PROGRAMS=$(TEST_PROG)
check_SCRIPTS=$(TEST_SCRIPT) $(TEST_SCRIPT_PARA)
# The parallel test script testph5diff.sh actually depends on testh5diff.sh.
-SCRIPT_DEPEND=h5diff$(EXEEXT) $(H5PDIFF) $(srcdir)/testh5diff.sh
+SCRIPT_DEPEND=h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh
# Source files for the program
h5diff_SOURCES=h5diff_main.c h5diff_common.c
diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in
index 5567ceb..9b46f4e 100644
--- a/tools/h5diff/Makefile.in
+++ b/tools/h5diff/Makefile.in
@@ -456,7 +456,7 @@ TEST_PROG = h5diffgentest
TEST_SCRIPT = testh5diff.sh
check_SCRIPTS = $(TEST_SCRIPT) $(TEST_SCRIPT_PARA)
# The parallel test script testph5diff.sh actually depends on testh5diff.sh.
-SCRIPT_DEPEND = h5diff$(EXEEXT) $(H5PDIFF) $(srcdir)/testh5diff.sh
+SCRIPT_DEPEND = h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh
# Source files for the program
h5diff_SOURCES = h5diff_main.c h5diff_common.c
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 9b304bd..36192e0 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -481,172 +481,6 @@ table_list_free(void)
} /* end table_list_free() */
/*-------------------------------------------------------------------------
- * Function: set_data_output_file
- *
- * Purpose: Open fname as the output file for dataset raw data.
- * Set rawdatastream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
- *
- * Programmer: Albert Cheng, 2000/09/30
- *
- * Modifications:
- * pvn June, 1, 2006. Add a switch for binary output
- *
- *-------------------------------------------------------------------------
- */
-static int
-set_data_output_file(const char *fname, int is_bin)
-{
- int retvalue = FAIL;
- FILE *f; /* temporary holding place for the stream pointer
- * so that rawdatastream is changed only when succeeded */
-
- if (rawdatastream && rawdatastream != stdout) {
- if (HDfclose(rawdatastream))
- HDperror("closing rawdatastream");
- else
- rawdatastream = NULL;
- }
-
- /* First check if filename is string "NULL" */
- if (fname != NULL) {
- /* binary output */
- if (is_bin) {
- if ((f = HDfopen(fname, "wb")) != NULL) {
- rawdatastream = f;
- retvalue = SUCCEED;
- }
- }
- else {
- if ((f = HDfopen(fname, "w")) != NULL) {
- rawdatastream = f;
- retvalue = SUCCEED;
- }
- }
- }
- else {
- rawdatastream = NULL;
- retvalue = SUCCEED;
- }
-
- return retvalue;
-}
-
-/*-------------------------------------------------------------------------
- * Function: set_attr_output_file
- *
- * Purpose: Open fname as the output file for attribute raw data.
- * Set rawattrstream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
- *
- *-------------------------------------------------------------------------
- */
-static int
-set_attr_output_file(const char *fname, int is_bin)
-{
- int retvalue = FAIL;
- FILE *f; /* temporary holding place for the stream pointer
- * so that rawattrstream is changed only when succeeded */
-
- if (rawattrstream && rawattrstream != stdout) {
- if (HDfclose(rawattrstream))
- HDperror("closing rawattrstream");
- else
- rawattrstream = NULL;
- }
-
- /* First check if filename is string "NULL" */
- if (fname != NULL) {
- if ((f = HDfopen(fname, "w")) != NULL) {
- rawattrstream = f;
- retvalue = SUCCEED;
- }
- }
- else {
- rawattrstream = NULL;
- retvalue = SUCCEED;
- }
-
- return retvalue;
-}
-
-/*-------------------------------------------------------------------------
- * Function: set_output_file
- *
- * Purpose: Open fname as the output file for raw output.
- * Set rawoutstream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
- *
- *-------------------------------------------------------------------------
- */
-static int
-set_output_file(const char *fname)
-{
- int retvalue = FAIL;
- FILE *f; /* temporary holding place for the stream pointer
- * so that rawoutstream is changed only when succeeded */
-
- if (rawoutstream && rawoutstream != stdout) {
- if (HDfclose(rawoutstream))
- HDperror("closing rawoutstream");
- else
- rawoutstream = NULL;
- }
- /* First check if filename is string "NULL" */
- if (fname != NULL) {
- if ((f = HDfopen(fname, "w")) != NULL) {
- rawoutstream = f;
- retvalue = SUCCEED;
- }
- }
- else {
- rawoutstream = NULL;
- retvalue = SUCCEED;
- }
-
- return retvalue;
-}
-
-/*-------------------------------------------------------------------------
- * Function: set_error_file
- *
- * Purpose: Open fname as the error output file for dataset raw error.
- * Set rawerrorstream as its file stream.
- *
- * Return: 0 -- succeeded
- * negative -- failed
- *
- *-------------------------------------------------------------------------
- */
-static int
-set_error_file(const char *fname)
-{
- int retvalue = FAIL;
- FILE *f; /* temporary holding place for the stream pointer
- * so that rawerrorstream is changed only when succeeded */
-
- if (rawerrorstream && rawerrorstream != stderr) {
- if (HDfclose(rawerrorstream))
- HDperror("closing rawerrorstream");
- else
- rawerrorstream = NULL;
- }
-
- if ((f = HDfopen(fname, "w")) != NULL) {
- rawerrorstream = f;
- retvalue = SUCCEED;
- }
-
- return retvalue;
-}
-
-/*-------------------------------------------------------------------------
* Function: set_binary_form
*
* Purpose: set the binary form of output by translating from a string input
@@ -1186,7 +1020,7 @@ parse_start:
break;
case 'O':
- if (set_output_file(opt_arg) < 0) {
+ if (h5tools_set_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
@@ -1194,20 +1028,20 @@ parse_start:
case 'o':
if ( bin_output ) {
- if (set_data_output_file(opt_arg, 1) < 0) {
+ if (h5tools_set_data_output_file(opt_arg, 1) < 0) {
usage(h5tools_getprogname());
goto error;
}
}
else {
if(display_attr_data && !display_data) {
- if (set_attr_output_file(opt_arg, 0) < 0) {
+ if (h5tools_set_attr_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
}
if(display_data || display_all) {
- if (set_data_output_file(opt_arg, 0) < 0) {
+ if (h5tools_set_data_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}
@@ -1229,7 +1063,7 @@ parse_start:
}
bin_output = TRUE;
if (outfname!=NULL) {
- if (set_data_output_file(outfname, 1) < 0) {
+ if (h5tools_set_data_output_file(outfname, 1) < 0) {
/* failed to set output file */
usage(h5tools_getprogname());
goto error;
diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c
index 691e2f2..40358c6 100644
--- a/tools/h5jam/h5unjam.c
+++ b/tools/h5jam/h5unjam.c
@@ -27,7 +27,7 @@
hsize_t write_pad( int , hsize_t );
hsize_t compute_pad( hsize_t );
-herr_t copy_to_file( int , int , ssize_t, ssize_t );
+herr_t copy_to_file( FILE *, FILE * , ssize_t, ssize_t );
int do_delete = FALSE;
char *output_file = NULL;
@@ -137,20 +137,28 @@ static int
parse_command_line(int argc, const char *argv[])
{
int opt = FALSE;
-
- /* parse command line options */
+
+ /* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch((char)opt) {
case 'o':
output_file = HDstrdup(opt_arg);
- break;
+ if (output_file)
+ h5tools_set_data_output_file(output_file, 1);
+ break;
case 'i':
input_file = HDstrdup(opt_arg);
- break;
+ if (input_file)
+ h5tools_set_input_file(input_file, 1);
+ break;;
case 'u':
ub_file = HDstrdup(opt_arg);
+ if (ub_file)
+ h5tools_set_output_file(ub_file, 1);
+ else
+ rawoutstream = stdout;
break;
case 'd':
@@ -205,9 +213,6 @@ done:
int
main(int argc, const char *argv[])
{
- int ifid = -1;
- int ufid = -1;
- int h5fid = -1;
void *edata;
H5E_auto2_t func;
hid_t ifile = -1;
@@ -222,24 +227,24 @@ main(int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
+ /* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- /* Initialize h5tools lib */
+ /* Initialize h5tools lib */
h5tools_init();
if(EXIT_FAILURE == parse_command_line(argc, argv))
goto done;
if (input_file == NULL) {
- /* no user block */
+ /* no user block */
error_msg("missing arguemnt for HDF5 file input.\n");
help_ref_msg(stderr);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
-
+
testval = H5Fis_hdf5(input_file);
if (testval <= 0) {
@@ -283,14 +288,7 @@ main(int argc, const char *argv[])
goto done;
}
- ifid = HDopen(input_file,O_RDONLY,0);
- if(ifid < 0) {
- error_msg("unable to open input HDF5 file \"%s\"\n", input_file);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
-
- res = HDfstat(ifid, &sbuf);
+ res = HDfstat(HDfileno(rawinstream), &sbuf);
if(res < 0) {
error_msg("Can't stat file \"%s\"\n", input_file);
h5tools_setstatus(EXIT_FAILURE);
@@ -305,43 +303,15 @@ main(int argc, const char *argv[])
goto done;
}
- if (ub_file == NULL) {
- /* write to sdtout */
- ufid = HDdup(1);
- }
- else {
- ufid = HDopen(ub_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 );
-
- if (ufid < 0) {
- error_msg("unable to open user block file for output\"%s\"\n", ub_file);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- }
-
if (output_file == NULL) {
- h5fid = HDopen(input_file,O_WRONLY, 0);
-
- if (h5fid < 0) {
error_msg("unable to open output HDF5 file \"%s\"\n", input_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
}
- else {
- h5fid = HDopen(output_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 );
-
- if (h5fid < 0) {
- error_msg("unable to open output HDF5 file \"%s\"\n", output_file);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- }
-
- /* copy from 0 to 'usize - 1' into ufid */
+ /* copy from 0 to 'usize - 1' into ufid */
if (!do_delete) {
- if(copy_to_file(ifid, ufid, 0, (ssize_t) usize) < 0) {
+ if(copy_to_file(rawinstream, rawoutstream, 0, (ssize_t) usize) < 0) {
error_msg("unable to copy user block to output file \"%s\"\n", ub_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -349,34 +319,25 @@ main(int argc, const char *argv[])
}
/* copy from usize to end of file into h5fid,
- * starting at end of user block if present
- */
- if(copy_to_file(ifid, h5fid, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) {
+ * starting at end of user block if present */
+ if(copy_to_file(rawinstream, rawdatastream, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) {
error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
-
+
done:
if(input_file)
HDfree(input_file);
+
if(output_file)
HDfree(output_file);
+
if(ub_file) {
HDfree(ub_file);
- if(ufid >= 0)
- status = HDclose(ufid);
- HDassert(status >= 0);
- }
-
- if(h5fid >= 0) {
- status = HDclose(h5fid);
- HDassert(status >= 0);
- }
- if(ifid >= 0) {
- status = HDclose(ifid);
- HDassert(status >= 0);
}
+
+ h5tools_close();
return h5tools_getstatus();
}
@@ -388,54 +349,60 @@ done:
* Returns 0 on success, -1 on failure.
*/
herr_t
-copy_to_file( int infid, int ofid, ssize_t where, ssize_t how_much )
+copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t how_much )
{
static char buf[COPY_BUF_SIZE];
+ off_t where = (off_t)_where;
off_t to;
off_t from;
- ssize_t nchars = -1;
- ssize_t wnchars = -1;
herr_t ret_value = 0;
/* nothing to copy */
if(how_much <= 0)
goto done;
+ /* rewind */
+ HDfseek(infid, 0L, 0);
+
from = where;
to = 0;
-
while(how_much > 0) {
- /* Seek to correct position in input file */
- HDlseek(infid,from,SEEK_SET);
+ size_t bytes_in = 0; /* # of bytes to read */
+ size_t bytes_read = 0; /* # of bytes actually read */
+ size_t bytes_wrote = 0; /* # of bytes written */
- /* Read data to buffer */
if (how_much > COPY_BUF_SIZE)
- nchars = HDread(infid,buf,(unsigned)COPY_BUF_SIZE);
+ bytes_in = COPY_BUF_SIZE;
else
- nchars = HDread(infid,buf,(unsigned)how_much);
- if(nchars < 0) {
+ bytes_in = how_much;
+
+ /* Seek to correct position in input file */
+ HDfseek(infid, from, SEEK_SET);
+
+ /* Read data to buffer */
+ bytes_read = HDfread(buf, (size_t)1, bytes_in, infid);
+ if(0 == bytes_read && HDferror(infid)) {
ret_value = -1;
goto done;
} /* end if */
+ if(0 == bytes_read && HDfeof(infid)) {
+ goto done;
+ } /* end if */
/* Seek to correct position in output file */
- HDlseek(ofid,to,SEEK_SET);
+ HDfseek(ofid, to, SEEK_SET);
/* Update positions/size */
- how_much -= nchars;
- from += nchars;
- to += nchars;
-
- /* Write nchars bytes to output file */
- wnchars = nchars;
- while(nchars > 0) {
- wnchars = HDwrite(ofid,buf,(unsigned)nchars);
- if(wnchars < 0) {
- ret_value = -1;
- goto done;
- } /* end if */
- nchars -= wnchars;
- } /* end while */
+ how_much -= bytes_read;
+ from += bytes_read;
+ to += bytes_read;
+
+ /* Write nchars bytes to output file */
+ bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid);
+ if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */
+ ret_value = -1;
+ goto done;
+ } /* end if */
} /* end while */
done:
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 3e9c43e..d229eec 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -36,10 +36,11 @@ 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 */
+FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */
+FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
int bin_output; /* binary output */
int bin_form; /* binary form */
int region_output; /* region output */
@@ -120,6 +121,8 @@ h5tools_init(void)
rawattrstream = stdout;
if (!rawdatastream)
rawdatastream = stdout;
+ if (!rawinstream)
+ rawinstream = stdin;
if (!rawoutstream)
rawoutstream = stdout;
if (!rawerrorstream)
@@ -172,6 +175,12 @@ h5tools_close(void)
else
rawdatastream = NULL;
}
+ if (rawinstream && rawinstream != stdin) {
+ if (fclose(rawinstream))
+ perror("closing rawinstream");
+ else
+ rawinstream = NULL;
+ }
if (rawoutstream && rawoutstream != stdout) {
if (fclose(rawoutstream))
perror("closing rawoutstream");
@@ -198,6 +207,254 @@ h5tools_close(void)
}
/*-------------------------------------------------------------------------
+ * Function: h5tools_set_data_output_file
+ *
+ * Purpose: Open fname as the output file for dataset raw data.
+ * Set rawdatastream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ * Programmer: Albert Cheng, 2000/09/30
+ *
+ * Modifications:
+ * pvn June, 1, 2006. Add a switch for binary output
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_data_output_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawdatastream is changed only when succeeded */
+
+ if (rawdatastream && rawdatastream != stdout) {
+ if (HDfclose(rawdatastream))
+ HDperror("closing rawdatastream");
+ else
+ rawdatastream = NULL;
+ }
+
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawdatastream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawdatastream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawdatastream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_attr_output_file
+ *
+ * Purpose: Open fname as the output file for attribute raw data.
+ * Set rawattrstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_attr_output_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawattrstream is changed only when succeeded */
+
+ if (rawattrstream && rawattrstream != stdout) {
+ if (HDfclose(rawattrstream))
+ HDperror("closing rawattrstream");
+ else
+ rawattrstream = NULL;
+ }
+
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawattrstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawattrstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawattrstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_input_file
+ *
+ * Purpose: Open fname as the input file for raw input.
+ * Set rawinstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_input_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawinstream is changed only when succeeded */
+
+ if (rawinstream && rawinstream != stdin) {
+ if (HDfclose(rawinstream))
+ HDperror("closing rawinstream");
+ else
+ rawinstream = NULL;
+ }
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "rb")) != NULL) {
+ rawinstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "r")) != NULL) {
+ rawinstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawinstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_output_file
+ *
+ * Purpose: Open fname as the output file for raw output.
+ * Set rawoutstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_output_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawoutstream is changed only when succeeded */
+
+ if (rawoutstream && rawoutstream != stdout) {
+ if (HDfclose(rawoutstream))
+ HDperror("closing rawoutstream");
+ else
+ rawoutstream = NULL;
+ }
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawoutstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawoutstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawoutstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_error_file
+ *
+ * Purpose: Open fname as the error output file for dataset raw error.
+ * Set rawerrorstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_error_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawerrorstream is changed only when succeeded */
+
+ if (rawerrorstream && rawerrorstream != stderr) {
+ if (HDfclose(rawerrorstream))
+ HDperror("closing rawerrorstream");
+ else
+ rawerrorstream = NULL;
+ }
+
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawerrorstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawerrorstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawerrorstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
* Audience: Private
* Chapter: H5Tools Library
* Purpose: Get a FAPL for a driver
@@ -1468,7 +1725,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
* hssize_t npoints is the number of points in the region
*-------------------------------------------------------------------------
*/
-static int
+int
render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container,
int ndims, hid_t type_id, hssize_t npoints)
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 8e5b9c8..47e1f41 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -541,6 +541,7 @@ H5TOOLS_DLLVAR int packed_data_length; /* lengtht of packed bits to display
H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */
H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
+H5TOOLS_DLLVAR FILE *rawinstream; /* input stream for raw input */
H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */
H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */
H5TOOLS_DLLVAR int bin_output; /* binary output */
@@ -558,6 +559,11 @@ H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */
/* Definitions of useful routines */
H5TOOLS_DLL void h5tools_init(void);
H5TOOLS_DLL void h5tools_close(void);
+H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin);
H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
const char *driver, char *drivername, size_t drivername_len);
H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type);
@@ -577,8 +583,6 @@ H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_form
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
-H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
- hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container);
H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,