diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-10-29 20:11:51 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2008-10-29 20:11:51 (GMT) |
commit | 8f00f520ffc4a07aed58ae7c1cb75aefea832f6d (patch) | |
tree | 5cdc7b00115f889cbfae37b0e3bb39fe21afd7e0 /tools/lib | |
parent | 61af8db951144e0795165df6a198a6ba4bbafef3 (diff) | |
download | hdf5-8f00f520ffc4a07aed58ae7c1cb75aefea832f6d.zip hdf5-8f00f520ffc4a07aed58ae7c1cb75aefea832f6d.tar.gz hdf5-8f00f520ffc4a07aed58ae7c1cb75aefea832f6d.tar.bz2 |
[svn-r15991] Merge with 1.8 rev 15969
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: linux
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_utils.c | 27 |
1 files changed, 25 insertions, 2 deletions
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; |