diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump.c | 52 | ||||
-rw-r--r-- | tools/h5tools.c | 6 | ||||
-rw-r--r-- | tools/h5tools.h | 1 |
3 files changed, 57 insertions, 2 deletions
diff --git a/tools/h5dump.c b/tools/h5dump.c index c87a74f..886737b 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -223,7 +223,8 @@ h5dump [-h] [-bb] [-header] [-v] [-V] [-a <names>] [-d <names>] [-g <names>]\n\ -a <names> Display the specified attribute(s).\n\ -d <names> Display the specified dataset(s).\n\ -g <names> Display the specified group(s) and all the members.\n\ - -l <names> Displays the value(s) of the specified soft link(s).\n\ + -l <names> Display the value(s) of the specified soft link(s).\n\ + -o <fname> Display the raw data of datasets to a separate Output file <fname>.\n\ -t <names> Display the specified named data type(s).\n\ -w <number> Display the information with the specified maximum number of columns.\n\ \n\ @@ -1315,6 +1316,34 @@ dump_data(hid_t obj_id, int obj_data) } /*------------------------------------------------------------------------- + * Function: set_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: + * + *----------------------------------------------------------------------- + */ +int +set_output_file(char *fname) +{ + FILE *f; /* temporary holding place for the stream pointer */ + /* so that rawdatastream is changed only when succeeded */ + + if (f = fopen(fname, "w")){ + rawdatastream = f; + return 0; + }else + return -1; +} + +/*------------------------------------------------------------------------- * Function: main * * Purpose: HDF5 dumper @@ -1325,6 +1354,8 @@ dump_data(hid_t obj_id, int obj_data) * Programmer: Ruey-Hsia Li * * Modifications: + * Albert Cheng, 2000/09/30 + * Add the -o option--output file for datasets raw data * *-----------------------------------------------------------------------*/ int @@ -1379,6 +1410,20 @@ main(int argc, char *argv[]) * since curr_arg starts at 1 */ newwidth = curr_arg; + } else if (!strcmp(argv[curr_arg], "-o")) { + /* a separate output file for dataset raw data */ + if (argc == curr_arg){ + /* missing <fname> */ + usage(); + free(opts); + exit(1); + } + if (set_output_file(argv[curr_arg+1]) < 0){ + /* failed to set output file */ + usage(); + free(opts); + exit(1); + } } else if (!strcmp(argv[curr_arg], "-xml")) { dump_header_format = &xmlformat; } else if (strcmp(argv[curr_arg],"-a") && @@ -1698,6 +1743,11 @@ done: if (H5Fclose(fid) < 0) d_status = 1; + if (rawdatastream != stdout) + if (fclose(rawdatastream)) + perror("fclose"); + + free(group_table->objs); free(dset_table->objs); free(type_table->objs); diff --git a/tools/h5tools.c b/tools/h5tools.c index d4ece5c..197fc2f 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -23,6 +23,7 @@ int indent = 0; int compound_data=0; int nCols = 80; +FILE *rawdatastream = NULL; /* should be stdout but linux gcc moans about it*/ int print_data(hid_t oid, hid_t _p_type, int obj_data); @@ -1734,7 +1735,10 @@ h5dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type, H5Sclose(f_space); /* Print the data */ - status = h5dump_simple_dset(stream, info, dset, p_type, indentlevel); + /* a kludge because linux gcc does not accept the initialization with sdtout */ + if (!rawdatastream) + rawdatastream=stdout; + status = h5dump_simple_dset(rawdatastream, info, dset, p_type, indentlevel); if (p_type!=_p_type) H5Tclose(p_type); return status; } diff --git a/tools/h5tools.h b/tools/h5tools.h index 51256c4..ffda022 100644 --- a/tools/h5tools.h +++ b/tools/h5tools.h @@ -399,6 +399,7 @@ void init_prefix(char **temp, int); extern int indent; extern void indentation(int); extern int nCols; +extern FILE *rawdatastream; /* output stream for raw data */ /* taken from h5dump.h*/ |