summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-10-27 20:06:28 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-10-27 20:06:28 (GMT)
commitf08f9340a7cfb323f3565e63b1cfe0604e02b4e5 (patch)
tree8ff4202ed3f3dfa379c2f68dfafba220f80268e0 /tools
parent64e96385de36e41834c7d7de23083ee8b250a579 (diff)
downloadhdf5-f08f9340a7cfb323f3565e63b1cfe0604e02b4e5.zip
hdf5-f08f9340a7cfb323f3565e63b1cfe0604e02b4e5.tar.gz
hdf5-f08f9340a7cfb323f3565e63b1cfe0604e02b4e5.tar.bz2
[svn-r15969]
Introduced a new feature in the tools library regarding command line parsing In the definition of arguments, an "*" means that the switch can or can not have an optional argument. This "*" is put in the code regarding the letter definition, and it is transparent to the user (e.g b* instead of the previous b: ), where ":" notes a required argument after the letter (and no ":" or "*" notes no argument, mandatory) Used for the h5dump binary option -b It can be now 1) -b (defaults to NATIVE) 2) - b NATIVE 3) - b FILE 4) -b LE 5) -b BE Note: the keyword NATIVE replaces MEMORY This feature (-b with no argument) was tested with the sequence of h5dump to binary (NATIVE) then h5import to generate an HDF5 file from the binary file and h5diff to compare the 2 HDF5 files Tested: windows, linux
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c50
-rw-r--r--tools/h5dump/testh5dump.sh.in16
-rw-r--r--tools/lib/h5tools_utils.c27
-rw-r--r--tools/testfiles/tnofilename.ddl4
4 files changed, 67 insertions, 30 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 5caea1c..056a5b2 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -386,7 +386,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:F:s:S:Aq:z:m:";
+static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h' },
@@ -493,7 +493,7 @@ static struct long_options l_opts[] = {
{ "onlyattr", no_arg, 'A' },
{ "escape", no_arg, 'e' },
{ "noindex", no_arg, 'y' },
- { "binary", require_arg, 'b' },
+ { "binary", optional_arg, 'b' },
{ "form", require_arg, 'F' },
{ "sort_by", require_arg, 'q' },
{ "sort_order", require_arg, 'z' },
@@ -683,10 +683,10 @@ usage(const char *prog)
fprintf(stdout, " number of dimensions in the dataspace being queried\n");
fprintf(stdout, " U - is a URI reference (as defined in [IETF RFC 2396],\n");
fprintf(stdout, " updated by [IETF RFC 2732])\n");
- fprintf(stdout, " B - is the form of binary output: MEMORY for a memory type, FILE for the\n");
+ fprintf(stdout, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
fprintf(stdout, " file type, LE or BE for pre-existing little or big endian types.\n");
fprintf(stdout, " Must be used with -o (output file) and it is recommended that\n");
- fprintf(stdout, " -d (dataset) is used\n");
+ fprintf(stdout, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
fprintf(stdout, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
fprintf(stdout, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
fprintf(stdout, "\n");
@@ -3220,7 +3220,7 @@ set_binary_form(const char *form)
{
int bform=-1;
- if (strcmp(form,"MEMORY")==0) /* native form */
+ if (strcmp(form,"NATIVE")==0) /* native form */
bform = 0;
else if (strcmp(form,"FILE")==0) /* file type form */
bform = 1;
@@ -3998,23 +3998,29 @@ parse_start:
case 'b':
- if ( ( bin_form = set_binary_form(opt_arg)) < 0){
- /* failed to set binary form */
- usage(progname);
- leave(EXIT_FAILURE);
- }
- bin_output = TRUE;
- if (outfname!=NULL) {
- if (set_output_file(outfname, 1) < 0){
- /* failed to set output file */
- usage(progname);
- leave(EXIT_FAILURE);
- }
-
- last_was_dset = FALSE;
- }
-
- break;
+ if ( opt_arg != NULL)
+ {
+ if ( ( bin_form = set_binary_form(opt_arg)) < 0)
+ {
+ /* failed to set binary form */
+ usage(progname);
+ leave(EXIT_FAILURE);
+ }
+ }
+ bin_output = TRUE;
+ if (outfname!=NULL)
+ {
+ if (set_output_file(outfname, 1) < 0)
+ {
+ /* failed to set output file */
+ usage(progname);
+ leave(EXIT_FAILURE);
+ }
+
+ last_was_dset = FALSE;
+ }
+
+ break;
case 'q':
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 9c36594..990ef2a 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -463,22 +463,30 @@ TOOLTEST tvms.ddl tvms.h5
# test for binary output
TOOLTEST1 tbin1.ddl -d integer -o $TESTDIR/out1.bin -b LE tbinary.h5
-TOOLTEST1 tbin2.ddl -d float -o $TESTDIR/out2.bin -b BE tbinary.h5
-# the MEMORY test can be validated with h5import/h5diff
-TOOLTEST1 tbin3.ddl -d integer -o $TESTDIR/out3.bin -b MEMORY tbinary.h5
+# NATIVE default. the NATIVE test can be validated with h5import/h5diff
+TOOLTEST1 tbin1.ddl -d integer -o $TESTDIR/out1.bin -b tbinary.h5
+IMPORTTEST $TESTDIR/out1.bin -c out3.h5import -o $TESTDIR/out1.h5
+DIFFTEST tbinary.h5 $TESTDIR/out1.h5 /integer /integer
+
+TOOLTEST1 tbin2.ddl -b BE -d float -o $TESTDIR/out2.bin tbinary.h5
+
+# the NATIVE test can be validated with h5import/h5diff
+TOOLTEST1 tbin3.ddl -d integer -o $TESTDIR/out3.bin -b NATIVE tbinary.h5
IMPORTTEST $TESTDIR/out3.bin -c out3.h5import -o $TESTDIR/out3.h5
DIFFTEST tbinary.h5 $TESTDIR/out3.h5 /integer /integer
-TOOLTEST1 tbin4.ddl -d double -o $TESTDIR/out4.bin -b FILE tbinary.h5
+TOOLTEST1 tbin4.ddl -d double -b FILE -o $TESTDIR/out4.bin tbinary.h5
# Clean up binary output files
if test -z "$HDF5_NOCLEANUP"; then
rm -f $TESTDIR/out[1-4].bin
+ rm -f $TESTDIR/out1.h5
rm -f $TESTDIR/out3.h5
fi
+
# test for dataset region references
TOOLTEST tdatareg.ddl tdatareg.h5
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index a221465..46b425b 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -120,7 +120,9 @@ warn_msg(const char *progname, const char *fmt, ...)
* Programmer: Bill Wendling
* Friday, 5. January 2001
*
- * Modifications:
+ * Modifications: Pedro Vicente
+ * October, 27 2008
+ * Wilcard "*" argument type
*
*-------------------------------------------------------------------------
*/
@@ -230,12 +232,33 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
}
sp = 1;
- } else {
+ }
+
+ /* wildcard argument */
+ else if (*cp == '*')
+ {
+ /* check the next argument */
+ opt_ind++;
+ /* we do have an extra argument, check if not last */
+ if ( argv[opt_ind][0] != '-' && (opt_ind+1) < argc )
+ {
+ opt_arg = argv[opt_ind++];
+ }
+ else
+ {
+ opt_arg = NULL;
+ }
+ }
+
+ else
+ {
/* set up to look at next char in token, next time */
if (argv[opt_ind][++sp] == '\0') {
/* no more in current token, so setup next token */
opt_ind++;
sp = 1;
+
+
}
opt_arg = NULL;
diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl
index 756b88f..5b5854d 100644
--- a/tools/testfiles/tnofilename.ddl
+++ b/tools/testfiles/tnofilename.ddl
@@ -58,10 +58,10 @@ usage: h5dump [OPTIONS] file
number of dimensions in the dataspace being queried
U - is a URI reference (as defined in [IETF RFC 2396],
updated by [IETF RFC 2732])
- B - is the form of binary output: MEMORY for a memory type, FILE for the
+ B - is the form of binary output: NATIVE for a memory type, FILE for the
file type, LE or BE for pre-existing little or big endian types.
Must be used with -o (output file) and it is recommended that
- -d (dataset) is used
+ -d (dataset) is used. B is an optional argument, defaults to NATIVE
Q - is the sort index type. It can be "creation_order" or "name" (default)
Z - is the sort order type. It can be "descending" or "ascending" (default)