summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2006-06-28 19:34:08 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2006-06-28 19:34:08 (GMT)
commit7637b679337e4f8e6b260f6f94477ebd65622b5e (patch)
tree6b325ae157cb6c4110c46aa9d81384de6372cf24
parent95a106f9fd78ce39ece6fef5e44de540b6bcd7a1 (diff)
downloadhdf5-7637b679337e4f8e6b260f6f94477ebd65622b5e.zip
hdf5-7637b679337e4f8e6b260f6f94477ebd65622b5e.tar.gz
hdf5-7637b679337e4f8e6b260f6f94477ebd65622b5e.tar.bz2
[svn-r12444] Purpose:
new feature Description: added support for h5dump to dump binary data using the file type format added one test to the test script that tests this Solution: Platforms tested: mir shanti copper Misc. update:
-rw-r--r--MANIFEST1
-rw-r--r--tools/h5dump/h5dump.c53
-rw-r--r--tools/h5dump/testh5dump.sh.in3
-rw-r--r--tools/lib/h5tools.c4
-rw-r--r--tools/lib/h5tools.h4
-rw-r--r--tools/testfiles/tbin2.ddl11
-rw-r--r--tools/testfiles/tnofilename.ddl1
7 files changed, 68 insertions, 9 deletions
diff --git a/MANIFEST b/MANIFEST
index 89cb160..b53d9a7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1075,6 +1075,7 @@
./tools/testfiles/tldouble.h5
./tools/testfiles/tvms.h5
./tools/testfiles/tbin.ddl
+./tools/testfiles/tbin2.ddl
# Expected output from h5ls tests
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 7bf0ba3..ca21773 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -52,13 +52,10 @@ const char *progname = "h5dump";
int d_status = EXIT_SUCCESS;
static int unamedtype = 0; /* shared data type with no name */
-static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
-
+static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
static size_t prefix_len = 1024;
-static char *prefix;
-
-static const char *driver = NULL; /* The driver to open the file with. */
-
+static char *prefix;
+static const char *driver = NULL; /* The driver to open the file with. */
static const h5dump_header_t *dump_header_format;
/* things to display or which are set via command line parameters */
@@ -351,7 +348,7 @@ struct handler_t {
* parameters. The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b:s:S:A";
+static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b:F:s:S:A";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
@@ -601,6 +598,7 @@ usage(const char *prog)
fprintf(stdout, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
fprintf(stdout, " -o F, --output=F Output raw data into file F\n");
fprintf(stdout, " -b F Output raw data into file F in binary form (use with -d)\n");
+ fprintf(stdout, " -F T Form of binary output (T can be NA for native type or DI for the disk file type)\n");
fprintf(stdout, " -t P, --datatype=P Print the specified named data type\n");
fprintf(stdout, " -w N, --width=N Set the number of columns of output\n");
fprintf(stdout, " -x, --xml Output in XML using Schema\n");
@@ -2702,6 +2700,35 @@ set_output_file(const char *fname, int is_bin)
return -1;
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: set_binary_form
+ *
+ * Purpose:
+ *
+ * Return:
+ *
+ * Programmer: Pedro Vicente Nunes
+ * June 28, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+set_binary_form(const char *form)
+{
+ int bform=-1;
+
+ if (strcmp(form,"NA")==0) /* native form */
+ bform = 0;
+ else if (strcmp(form,"DI")==0) /* file type form */
+ bform = 1;
+
+ return bform;
+}
+
/*-------------------------------------------------------------------------
* Function: handle_attributes
*
@@ -3276,6 +3303,16 @@ parse_start:
last_was_dset = FALSE;
break;
+ case 'F':
+ if ( ( bin_form = set_binary_form(opt_arg)) < 0){
+ /* failed to set binary form */
+ usage(progname);
+ leave(EXIT_FAILURE);
+ }
+
+ last_was_dset = FALSE;
+ break;
+
/** begin XML parameters **/
case 'x':
/* select XML output */
@@ -6051,3 +6088,5 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name)
HDstrcat(HDstrcat(*prfx, "/"), name);
} /* end add_prefix */
+
+
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index f390110..1505b9f 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -323,6 +323,9 @@ TOOLTEST tvms.ddl tvms.h5
# test for binary output
TOOLTEST tbin.ddl -d integer -b out.bin test1.h5
+# test for binary output using a file type form -F DI
+TOOLTEST tbin2.ddl -d integer -b out2.bin -F DI test1.h5
+
if test $nerrors -eq 0 ; then
echo "All $DUMPER tests passed."
fi
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 7fcfd3c..24d9f7e 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -47,6 +47,8 @@
int compound_data;
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
int bin_output; /* binary output */
+int bin_form; /* binary form */
+
/* local prototypes */
static int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem);
@@ -1194,7 +1196,7 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _
if (p_type < 0) {
f_type = H5Dget_type(dset);
- if (info->raw)
+ if (info->raw || bin_form == 1 )
p_type = H5Tcopy(f_type);
else
p_type = h5tools_get_native_type(f_type);
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 861c474..91f238f 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -353,7 +353,9 @@ struct subset_t {
};
extern FILE *rawdatastream; /* output stream for raw data */
-extern int bin_output; /* binary output */
+extern int bin_output; /* binary output */
+extern int bin_form; /* binary form */
+
/* Strings for output */
diff --git a/tools/testfiles/tbin2.ddl b/tools/testfiles/tbin2.ddl
new file mode 100644
index 0000000..2c17692
--- /dev/null
+++ b/tools/testfiles/tbin2.ddl
@@ -0,0 +1,11 @@
+#############################
+Expected output for 'h5dump -d integer -b out2.bin -F DI test1.h5'
+#############################
+HDF5 "test1.h5" {
+DATASET "integer" {
+ DATATYPE H5T_STD_I32LE
+ DATASPACE SIMPLE { ( 2 ) / ( 2 ) }
+ DATA {
+ }
+}
+}
diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl
index 2b9107a..4716a25 100644
--- a/tools/testfiles/tnofilename.ddl
+++ b/tools/testfiles/tnofilename.ddl
@@ -21,6 +21,7 @@ usage: h5dump [OPTIONS] file
-l P, --soft-link=P Print the value(s) of the specified soft link
-o F, --output=F Output raw data into file F
-b F Output raw data into file F in binary form (use with -d)
+ -F T Form of binary output (T can be NA for native type or DI for the disk file type)
-t P, --datatype=P Print the specified named data type
-w N, --width=N Set the number of columns of output
-x, --xml Output in XML using Schema