From e8b030363999befa548b94ac5c505d170540aebc Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Sat, 26 Feb 2022 19:07:39 -0600 Subject: 1.10 Fix tools incompatibility (#1449) * fix tools incompatibility with get_option #1443 * Fix get_option function * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- hl/tools/h5watch/h5watch.c | 60 ++++----- tools/lib/h5tools_utils.c | 165 ++++++++++++++++++++++++ tools/lib/h5tools_utils.h | 47 +++++++ tools/src/h5copy/h5copy.c | 48 +++---- tools/src/h5diff/h5diff_common.c | 84 ++++++------- tools/src/h5dump/h5dump.c | 172 +++++++++++++------------- tools/src/h5dump/h5dump_ddl.c | 4 +- tools/src/h5format_convert/h5format_convert.c | 22 ++-- tools/src/h5jam/h5jam.c | 16 +-- tools/src/h5jam/h5unjam.c | 16 +-- tools/src/h5perf/pio_perf.c | 72 +++++------ tools/src/h5perf/sio_perf.c | 92 +++++++------- tools/src/h5repack/h5repack_main.c | 132 ++++++++++---------- tools/src/h5stat/h5stat.c | 58 ++++----- tools/src/misc/h5clear.c | 16 +-- tools/src/misc/h5mkgrp.c | 26 ++-- tools/test/h5jam/getub.c | 16 +-- tools/test/h5jam/tellub.c | 12 +- tools/test/perform/pio_standalone.c | 57 +++++---- tools/test/perform/pio_standalone.h | 11 +- tools/test/perform/sio_standalone.c | 57 +++++---- tools/test/perform/sio_standalone.h | 11 +- tools/test/perform/zip_perf.c | 30 ++--- 23 files changed, 722 insertions(+), 502 deletions(-) diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index bfb0115..aae670a 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -58,27 +58,27 @@ static void parse_command_line(int argc, const char *const *argv); * 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 = "?"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, - {"dim", no_arg, 'd'}, {"di", no_arg, 'd'}, - {"label", no_arg, 'l'}, {"labe", no_arg, 'l'}, - {"lab", no_arg, 'l'}, {"la", no_arg, 'l'}, - {"simple", no_arg, 'S'}, {"simpl", no_arg, 'S'}, - {"simp", no_arg, 'S'}, {"sim", no_arg, 'S'}, - {"si", no_arg, 'S'}, {"hexdump", no_arg, 'x'}, - {"hexdum", no_arg, 'x'}, {"hexdu", no_arg, 'x'}, - {"hexd", no_arg, 'x'}, {"hex", no_arg, 'x'}, - {"width", require_arg, 'w'}, {"widt", require_arg, 'w'}, - {"wid", require_arg, 'w'}, {"wi", require_arg, 'w'}, - {"polling", require_arg, 'p'}, {"pollin", require_arg, 'p'}, - {"polli", require_arg, 'p'}, {"poll", require_arg, 'p'}, - {"pol", require_arg, 'p'}, {"po", require_arg, 'p'}, - {"fields", require_arg, 'f'}, {"field", require_arg, 'f'}, - {"fiel", require_arg, 'f'}, {"fie", require_arg, 'f'}, - {"fi", require_arg, 'f'}, {"version", no_arg, 'V'}, - {"versio", no_arg, 'V'}, {"versi", no_arg, 'V'}, - {"vers", no_arg, 'V'}, {"ver", no_arg, 'V'}, - {"ve", no_arg, 'V'}, {NULL, 0, '\0'}}; +static const char * s_opts = "?"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, + {"dim", no_arg, 'd'}, {"di", no_arg, 'd'}, + {"label", no_arg, 'l'}, {"labe", no_arg, 'l'}, + {"lab", no_arg, 'l'}, {"la", no_arg, 'l'}, + {"simple", no_arg, 'S'}, {"simpl", no_arg, 'S'}, + {"simp", no_arg, 'S'}, {"sim", no_arg, 'S'}, + {"si", no_arg, 'S'}, {"hexdump", no_arg, 'x'}, + {"hexdum", no_arg, 'x'}, {"hexdu", no_arg, 'x'}, + {"hexd", no_arg, 'x'}, {"hex", no_arg, 'x'}, + {"width", require_arg, 'w'}, {"widt", require_arg, 'w'}, + {"wid", require_arg, 'w'}, {"wi", require_arg, 'w'}, + {"polling", require_arg, 'p'}, {"pollin", require_arg, 'p'}, + {"polli", require_arg, 'p'}, {"poll", require_arg, 'p'}, + {"pol", require_arg, 'p'}, {"po", require_arg, 'p'}, + {"fields", require_arg, 'f'}, {"field", require_arg, 'f'}, + {"fiel", require_arg, 'f'}, {"fie", require_arg, 'f'}, + {"fi", require_arg, 'f'}, {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, {"ver", no_arg, 'V'}, + {"ve", no_arg, 'V'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: doprint() @@ -677,7 +677,7 @@ parse_command_line(int argc, const char *const *argv) } /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case '?': case 'h': /* --help */ @@ -691,7 +691,7 @@ parse_command_line(int argc, const char *const *argv) break; case 'w': /* --width=N */ - g_display_width = (int)HDstrtol(H5_optarg, NULL, 0); + g_display_width = (int)HDstrtol(opt_arg, NULL, 0); if (g_display_width < 0) { usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -711,8 +711,8 @@ parse_command_line(int argc, const char *const *argv) break; case 'p': /* --polling=N */ - /* g_polling_interval = HDstrtod(H5_optarg, NULL); */ - if ((tmp = (int)HDstrtol(H5_optarg, NULL, 10)) <= 0) { + /* g_polling_interval = HDstrtod(opt_arg, NULL); */ + if ((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { usage(h5tools_getprogname()); leave(EXIT_FAILURE); } @@ -721,7 +721,7 @@ parse_command_line(int argc, const char *const *argv) case 'f': /* --fields= */ if (g_list_of_fields == NULL) { - if ((g_list_of_fields = HDstrdup(H5_optarg)) == NULL) { + if ((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); leave(EXIT_FAILURE); } @@ -729,7 +729,7 @@ parse_command_line(int argc, const char *const *argv) else { char *str; - if ((str = HDstrdup(H5_optarg)) == NULL) { + if ((str = HDstrdup(opt_arg)) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); leave(EXIT_FAILURE); } @@ -751,7 +751,7 @@ parse_command_line(int argc, const char *const *argv) } /* check for object to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing dataset name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -821,7 +821,7 @@ main(int argc, char *argv[]) /* parse command line options */ parse_command_line(argc, (const char *const *)argv); - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing dataset name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -845,7 +845,7 @@ main(int argc, char *argv[]) * then there must have been something wrong with the file (perhaps it * doesn't exist). */ - if ((fname = HDstrdup(argv[H5_optind])) == NULL) { + if ((fname = HDstrdup(argv[opt_ind])) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 36333ec..8b138e7 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -29,6 +29,10 @@ unsigned h5tools_nCols = 80; static int h5tools_d_status = 0; static const char *h5tools_progname = "h5tools"; +/* ``get_option'' variables */ +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char *opt_arg; /*flag argument (or value) */ /* * The output functions need a temporary buffer to hold a piece of the @@ -158,6 +162,167 @@ help_ref_msg(FILE *output) HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n", h5tools_getprogname()); } +/*------------------------------------------------------------------------- + * Function: get_option + * + * Purpose: Determine the command-line options a user specified. We can + * accept both short and long type command-lines. + * + * Return: Success: The short valued "name" of the command line + * parameter or EOF if there are no more + * parameters to process. + * + * Failure: A question mark. + *------------------------------------------------------------------------- + */ +int +get_option(int argc, const char *const *argv, const char *opts, const struct long_options *l_opts) +{ + static int sp = 1; /* character index in current token */ + int optchar = '?'; /* option character passed back to user */ + + if (sp == 1) { + /* check for more flag-like tokens */ + if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { + return EOF; + } + else if (HDstrcmp(argv[opt_ind], "--") == 0) { + opt_ind++; + return EOF; + } + } + + if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { + /* long command line option */ + int i; + const char ch = '='; + char * arg = HDstrdup(&argv[opt_ind][2]); + size_t arg_len = 0; + + opt_arg = strchr(&argv[opt_ind][2], ch); + arg_len = HDstrlen(&argv[opt_ind][2]); + if (opt_arg) { + arg_len -= HDstrlen(opt_arg); + opt_arg++; /* skip the equal sign */ + } + arg[arg_len] = 0; + + for (i = 0; l_opts && l_opts[i].name; i++) { + if (HDstrcmp(arg, l_opts[i].name) == 0) { + /* we've found a matching long command line flag */ + optchar = l_opts[i].shortval; + + if (l_opts[i].has_arg != no_arg) { + if (opt_arg == NULL) { + if (l_opts[i].has_arg != optional_arg) { + if (opt_ind < (argc - 1)) + if (argv[opt_ind + 1][0] != '-') + opt_arg = argv[++opt_ind]; + } + else if (l_opts[i].has_arg == require_arg) { + if (opt_err) + HDfprintf(rawerrorstream, "%s: option required for \"--%s\" flag\n", argv[0], + arg); + + optchar = '?'; + } + } + } + else { + if (opt_arg) { + if (opt_err) + HDfprintf(rawerrorstream, "%s: no option required for \"%s\" flag\n", argv[0], + arg); + + optchar = '?'; + } + } + break; + } + } + + if (l_opts[i].name == NULL) { + /* exhausted all of the l_opts we have and still didn't match */ + if (opt_err) + HDfprintf(rawerrorstream, "%s: unknown option \"%s\"\n", argv[0], arg); + + optchar = '?'; + } + + opt_ind++; + sp = 1; + + HDfree(arg); + } + else { + register char *cp; /* pointer into current token */ + + /* short command line option */ + optchar = argv[opt_ind][sp]; + + if (optchar == ':' || (cp = HDstrchr(opts, optchar)) == 0) { + if (opt_err) + HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n", argv[0], optchar); + + /* if no chars left in this token, move to next token */ + if (argv[opt_ind][++sp] == '\0') { + opt_ind++; + sp = 1; + } + return '?'; + } + + if (*++cp == ':') { + /* if a value is expected, get it */ + if (argv[opt_ind][sp + 1] != '\0') { + /* flag value is rest of current token */ + opt_arg = &argv[opt_ind++][sp + 1]; + } + else if (++opt_ind >= argc) { + if (opt_err) + HDfprintf(rawerrorstream, "%s: value expected for option \"%c\"\n", argv[0], optchar); + + optchar = '?'; + } + else { + /* flag value is next token */ + opt_arg = argv[opt_ind++]; + } + + sp = 1; + } + /* wildcard argument */ + else if (*cp == '*') { + /* check the next argument */ + opt_ind++; + /* we do have an extra argument, check if not last */ + if ((opt_ind + 1) < argc) { + if (argv[opt_ind][0] != '-') { + opt_arg = argv[opt_ind++]; + } + else { + opt_arg = NULL; + } + } + 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; + } + } + + /* return the current flag character found */ + return optchar; +} + /***************************************************************************** * * Function: parse_tuple() diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index fed4b52..b54ed85 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -40,6 +40,53 @@ H5TOOLS_DLLVAR FILE *overflow_file; H5TOOLS_DLLVAR hsize_t H5TOOLS_MALLOCSIZE; /* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */ H5TOOLS_DLLVAR hsize_t H5TOOLS_BUFSIZE; +/* + * begin get_option section + */ +H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */ +H5TOOLS_DLLVAR int opt_ind; /* token pointer */ +H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */ + +/* + * get_option determines which options are specified on the command line and + * returns a pointer to any arguments possibly associated with the option in + * the ``opt_arg'' variable. get_option returns the shortname equivalent of + * the option. The long options are specified in the following way: + * + * struct long_options foo[] = { + * { "filename", require_arg, 'f' }, + * { "append", no_arg, 'a' }, + * { "width", require_arg, 'w' }, + * { NULL, 0, 0 } + * }; + * + * Long named options can have arguments specified as either: + * + * ``--param=arg'' or ``--param arg'' + * + * Short named options can have arguments specified as either: + * + * ``-w80'' or ``-w 80'' + * + * and can have more than one short named option specified at one time: + * + * -aw80 + * + * in which case those options which expect an argument need to come at the + * end. + */ +typedef struct long_options { + const char *name; /* name of the long option */ + int has_arg; /* whether we should look for an arg */ + char shortval; /* the shortname equivalent of long arg + * this gets returned from get_option */ +} long_options; + +H5TOOLS_DLL int get_option(int argc, const char *const *argv, const char *opt, + const struct long_options *l_opt); +/* + * end get_option section + */ /*struct taken from the dumper. needed in table struct*/ typedef struct obj_t { diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index 6f10fee..933e230 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -19,23 +19,23 @@ #define PROGRAMNAME "h5copy" /* command-line options: short and long-named parameters */ -static const char * s_opts = "d:f:hi:o:ps:vVE"; -static struct h5_long_options l_opts[] = {{"destination", require_arg, 'd'}, - {"flag", require_arg, 'f'}, - {"help", no_arg, 'h'}, - {"input", require_arg, 'i'}, - {"output", require_arg, 'o'}, - {"parents", no_arg, 'p'}, - {"source", require_arg, 's'}, - {"verbose", no_arg, 'v'}, - {"version", no_arg, 'V'}, - {"enable-error-stack", no_arg, 'E'}, - {NULL, 0, '\0'}}; -char * fname_src = NULL; -char * fname_dst = NULL; -char * oname_src = NULL; -char * oname_dst = NULL; -char * str_flag = NULL; +static const char * s_opts = "d:f:hi:o:ps:vVE"; +static struct long_options l_opts[] = {{"destination", require_arg, 'd'}, + {"flag", require_arg, 'f'}, + {"help", no_arg, 'h'}, + {"input", require_arg, 'i'}, + {"output", require_arg, 'o'}, + {"parents", no_arg, 'p'}, + {"source", require_arg, 's'}, + {"verbose", no_arg, 'v'}, + {"version", no_arg, 'V'}, + {"enable-error-stack", no_arg, 'E'}, + {NULL, 0, '\0'}}; +char * fname_src = NULL; +char * fname_dst = NULL; +char * oname_src = NULL; +char * oname_dst = NULL; +char * str_flag = NULL; /*------------------------------------------------------------------------- * Function: leave @@ -242,19 +242,19 @@ main(int argc, char *argv[]) } /* end if */ /* parse command line options */ - while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'd': - oname_dst = HDstrdup(H5_optarg); + oname_dst = HDstrdup(opt_arg); break; case 'f': /* validate flag */ - if (parse_flag(H5_optarg, &flag) < 0) { + if (parse_flag(opt_arg, &flag) < 0) { usage(); leave(EXIT_FAILURE); } - str_flag = HDstrdup(H5_optarg); + str_flag = HDstrdup(opt_arg); break; case 'h': @@ -263,11 +263,11 @@ main(int argc, char *argv[]) break; case 'i': - fname_src = HDstrdup(H5_optarg); + fname_src = HDstrdup(opt_arg); break; case 'o': - fname_dst = HDstrdup(H5_optarg); + fname_dst = HDstrdup(opt_arg); break; case 'p': @@ -275,7 +275,7 @@ main(int argc, char *argv[]) break; case 's': - oname_src = HDstrdup(H5_optarg); + oname_src = HDstrdup(opt_arg); break; case 'V': diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index c7060e9..9e1b6ed 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -25,24 +25,24 @@ static int check_d_input(const char *); * Command-line options: The user can specify short or long-named * parameters. */ -static const char * s_opts = "hVrv*qn:d:p:NcelxE:A:S"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, - {"version", no_arg, 'V'}, - {"report", no_arg, 'r'}, - {"verbose", optional_arg, 'v'}, - {"quiet", no_arg, 'q'}, - {"count", require_arg, 'n'}, - {"delta", require_arg, 'd'}, - {"relative", require_arg, 'p'}, - {"nan", no_arg, 'N'}, - {"compare", no_arg, 'c'}, - {"use-system-epsilon", no_arg, 'e'}, - {"follow-symlinks", no_arg, 'l'}, - {"no-dangling-links", no_arg, 'x'}, - {"exclude-path", require_arg, 'E'}, - {"exclude-attribute", require_arg, 'A'}, - {"enable-error-stack", no_arg, 'S'}, - {NULL, 0, '\0'}}; +static const char * s_opts = "hVrv*qn:d:p:NcelxE:A:S"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"report", no_arg, 'r'}, + {"verbose", optional_arg, 'v'}, + {"quiet", no_arg, 'q'}, + {"count", require_arg, 'n'}, + {"delta", require_arg, 'd'}, + {"relative", require_arg, 'p'}, + {"nan", no_arg, 'N'}, + {"compare", no_arg, 'c'}, + {"use-system-epsilon", no_arg, 'e'}, + {"follow-symlinks", no_arg, 'l'}, + {"no-dangling-links", no_arg, 'x'}, + {"exclude-path", require_arg, 'E'}, + {"exclude-attribute", require_arg, 'A'}, + {"enable-error-stack", no_arg, 'S'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: check_options @@ -226,7 +226,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const exclude_attr_head = NULL; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { default: usage(); @@ -250,20 +250,20 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const * special check for short opt */ if (!strcmp(argv[i], "-v")) { - if (H5_optarg != NULL) - H5_optind--; + if (opt_arg != NULL) + opt_ind--; opts->mode_verbose_level = 0; break; } else if (!strncmp(argv[i], "-v", (size_t)2)) { - if (H5_optarg != NULL) - H5_optind--; + if (opt_arg != NULL) + opt_ind--; opts->mode_verbose_level = atoi(&argv[i][2]); break; } else { - if (H5_optarg != NULL) - opts->mode_verbose_level = HDatoi(H5_optarg); + if (opt_arg != NULL) + opts->mode_verbose_level = HDatoi(opt_arg); else opts->mode_verbose_level = 0; } @@ -302,7 +302,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const } /* init */ - exclude_node->obj_path = H5_optarg; + exclude_node->obj_path = opt_arg; exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; exclude_prev = exclude_head; @@ -330,7 +330,7 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const } /* init */ - exclude_attr_node->obj_path = H5_optarg; + exclude_attr_node->obj_path = opt_arg; exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN; exclude_attr_prev = exclude_attr_head; @@ -350,23 +350,23 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const case 'd': opts->delta_bool = 1; - if (check_d_input(H5_optarg) == -1) { - HDprintf("<-d %s> is not a valid option\n", H5_optarg); + if (check_d_input(opt_arg) == -1) { + HDprintf("<-d %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->delta = HDatof(H5_optarg); + opts->delta = HDatof(opt_arg); /* do not check against default, the DBL_EPSILON is being replaced by user */ break; case 'p': opts->percent_bool = 1; - if (check_p_input(H5_optarg) == -1) { - HDprintf("<-p %s> is not a valid option\n", H5_optarg); + if (check_p_input(opt_arg) == -1) { + HDprintf("<-p %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->percent = HDatof(H5_optarg); + opts->percent = HDatof(opt_arg); /* -p 0 is the same as default */ if (H5_DBL_ABS_EQUAL(opts->percent, 0.0)) @@ -375,12 +375,12 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const case 'n': opts->count_bool = 1; - if (check_n_input(H5_optarg) == -1) { - HDprintf("<-n %s> is not a valid option\n", H5_optarg); + if (check_n_input(opt_arg) == -1) { + HDprintf("<-n %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->count = HDstrtoull(H5_optarg, NULL, 0); + opts->count = HDstrtoull(opt_arg, NULL, 0); break; case 'N': @@ -409,15 +409,15 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const opts->exclude_attr = exclude_attr_head; /* check for file names to be processed */ - if (argc <= H5_optind || argv[H5_optind + 1] == NULL) { + if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { error_msg("missing file names\n"); usage(); h5diff_exit(EXIT_FAILURE); } - *fname1 = argv[H5_optind]; - *fname2 = argv[H5_optind + 1]; - *objname1 = argv[H5_optind + 2]; + *fname1 = argv[opt_ind]; + *fname2 = argv[opt_ind + 1]; + *objname1 = argv[opt_ind + 2]; H5TOOLS_DEBUG("file1 = %s", *fname1); H5TOOLS_DEBUG("file2 = %s", *fname2); @@ -428,8 +428,8 @@ parse_command_line(int argc, const char *const *argv, const char **fname1, const } H5TOOLS_DEBUG("objname1 = %s", *objname1); - if (argv[H5_optind + 3] != NULL) { - *objname2 = argv[H5_optind + 3]; + if (argv[opt_ind + 3] != NULL) { + *objname2 = argv[opt_ind + 3]; } else { *objname2 = *objname1; diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index dfab35d..1134ecb 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -77,51 +77,51 @@ struct handler_t { */ /* The following initialization makes use of C language concatenating */ /* "xxx" "yyy" into "xxxyyy". */ -static const char * s_opts = "a:b*c:d:ef:g:hik:l:m:n*o*pq:rs:t:uvw:xyz:A*BCD:E*F:G:HM:N:O*RS:VX:"; -static struct h5_long_options l_opts[] = {{"attribute", require_arg, 'a'}, - {"binary", optional_arg, 'b'}, - {"count", require_arg, 'c'}, - {"dataset", require_arg, 'd'}, - {"escape", no_arg, 'e'}, - {"filedriver", require_arg, 'f'}, - {"group", require_arg, 'g'}, - {"help", no_arg, 'h'}, - {"object-ids", no_arg, 'i'}, - {"block", require_arg, 'k'}, - {"soft-link", require_arg, 'l'}, - {"format", require_arg, 'm'}, - {"contents", optional_arg, 'n'}, - {"output", optional_arg, 'o'}, - {"properties", no_arg, 'p'}, - {"sort_by", require_arg, 'q'}, - {"string", no_arg, 'r'}, - {"start", require_arg, 's'}, - {"datatype", require_arg, 't'}, - {"use-dtd", no_arg, 'u'}, - {"vds-view-first-missing", no_arg, 'v'}, - {"width", require_arg, 'w'}, - {"xml", no_arg, 'x'}, - {"noindex", no_arg, 'y'}, - {"sort_order", require_arg, 'z'}, - {"onlyattr", optional_arg, 'A'}, - {"superblock", no_arg, 'B'}, - {"boot-block", no_arg, 'B'}, - {"no-compact-subset", no_arg, 'C'}, - {"xml-dtd", require_arg, 'D'}, - {"enable-error-stack", optional_arg, 'E'}, - {"form", require_arg, 'F'}, - {"vds-gap-size", require_arg, 'G'}, - {"header", no_arg, 'H'}, - {"packed-bits", require_arg, 'M'}, - {"any_path", require_arg, 'N'}, - {"ddl", optional_arg, 'O'}, - {"region", no_arg, 'R'}, - {"stride", require_arg, 'S'}, - {"version", no_arg, 'V'}, - {"xml-ns", require_arg, 'X'}, - {"s3-cred", require_arg, '$'}, - {"hdfs-attrs", require_arg, '#'}, - {NULL, 0, '\0'}}; +static const char * s_opts = "a:b*c:d:ef:g:hik:l:m:n*o*pq:rs:t:uvw:xyz:A*BCD:E*F:G:HM:N:O*RS:VX:"; +static struct long_options l_opts[] = {{"attribute", require_arg, 'a'}, + {"binary", optional_arg, 'b'}, + {"count", require_arg, 'c'}, + {"dataset", require_arg, 'd'}, + {"escape", no_arg, 'e'}, + {"filedriver", require_arg, 'f'}, + {"group", require_arg, 'g'}, + {"help", no_arg, 'h'}, + {"object-ids", no_arg, 'i'}, + {"block", require_arg, 'k'}, + {"soft-link", require_arg, 'l'}, + {"format", require_arg, 'm'}, + {"contents", optional_arg, 'n'}, + {"output", optional_arg, 'o'}, + {"properties", no_arg, 'p'}, + {"sort_by", require_arg, 'q'}, + {"string", no_arg, 'r'}, + {"start", require_arg, 's'}, + {"datatype", require_arg, 't'}, + {"use-dtd", no_arg, 'u'}, + {"vds-view-first-missing", no_arg, 'v'}, + {"width", require_arg, 'w'}, + {"xml", no_arg, 'x'}, + {"noindex", no_arg, 'y'}, + {"sort_order", require_arg, 'z'}, + {"onlyattr", optional_arg, 'A'}, + {"superblock", no_arg, 'B'}, + {"boot-block", no_arg, 'B'}, + {"no-compact-subset", no_arg, 'C'}, + {"xml-dtd", require_arg, 'D'}, + {"enable-error-stack", optional_arg, 'E'}, + {"form", require_arg, 'F'}, + {"vds-gap-size", require_arg, 'G'}, + {"header", no_arg, 'H'}, + {"packed-bits", require_arg, 'M'}, + {"any_path", require_arg, 'N'}, + {"ddl", optional_arg, 'O'}, + {"region", no_arg, 'R'}, + {"stride", require_arg, 'S'}, + {"version", no_arg, 'V'}, + {"xml-ns", require_arg, 'X'}, + {"s3-cred", require_arg, '$'}, + {"hdfs-attrs", require_arg, '#'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: leave @@ -821,7 +821,7 @@ parse_command_line(int argc, const char *const *argv) } /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { parse_start: switch ((char)opt) { case 'R': @@ -835,8 +835,8 @@ parse_start: case 'n': dump_opts.display_fi = TRUE; last_was_dset = FALSE; - if (H5_optarg != NULL) - h5trav_set_verbose(HDatoi(H5_optarg)); + if (opt_arg != NULL) + h5trav_set_verbose(HDatoi(opt_arg)); break; case 'p': dump_opts.display_dcpl = TRUE; @@ -853,8 +853,8 @@ parse_start: last_was_dset = FALSE; break; case 'A': - if (H5_optarg != NULL) { - if (0 == HDatoi(H5_optarg)) + if (opt_arg != NULL) { + if (0 == HDatoi(opt_arg)) dump_opts.include_attrs = FALSE; } else { @@ -878,7 +878,7 @@ parse_start: goto done; break; case 'w': { - int sh5tools_nCols = HDatoi(H5_optarg); + int sh5tools_nCols = HDatoi(opt_arg); if (sh5tools_nCols <= 0) h5tools_nCols = 65535; @@ -892,7 +892,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_paths; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); break; } @@ -904,7 +904,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_attributes; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); break; } @@ -916,7 +916,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_datasets; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); hand[i].subset_info = parse_subset_params(hand[i].obj); last_dset = &hand[i]; break; @@ -925,7 +925,7 @@ parse_start: last_was_dset = TRUE; break; case 'f': - driver_name_g = H5_optarg; + driver_name_g = opt_arg; break; case 'g': dump_opts.display_all = 0; @@ -933,7 +933,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_groups; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); break; } @@ -945,7 +945,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_links; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); break; } @@ -957,7 +957,7 @@ parse_start: for (i = 0; i < argc; i++) if (!hand[i].func) { hand[i].func = handle_datatypes; - hand[i].obj = HDstrdup(H5_optarg); + hand[i].obj = HDstrdup(opt_arg); break; } @@ -965,7 +965,7 @@ parse_start: break; case 'O': - if (h5tools_set_output_file(H5_optarg, 0) < 0) { + if (h5tools_set_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); goto error; } @@ -973,20 +973,20 @@ parse_start: case 'o': if (bin_output) { - if (h5tools_set_data_output_file(H5_optarg, 1) < 0) { + if (h5tools_set_data_output_file(opt_arg, 1) < 0) { usage(h5tools_getprogname()); goto error; } } else { if (dump_opts.display_attr_data && !dump_opts.display_data) { - if (h5tools_set_attr_output_file(H5_optarg, 0) < 0) { + if (h5tools_set_attr_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); goto error; } } if (dump_opts.display_data || dump_opts.display_all) { - if (h5tools_set_data_output_file(H5_optarg, 0) < 0) { + if (h5tools_set_data_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); goto error; } @@ -995,12 +995,12 @@ parse_start: dump_opts.usingdasho = TRUE; last_was_dset = FALSE; - outfname_g = H5_optarg; + outfname_g = opt_arg; break; case 'b': - if (H5_optarg != NULL) { - if ((bin_form = set_binary_form(H5_optarg)) < 0) { + if (opt_arg != NULL) { + if ((bin_form = set_binary_form(opt_arg)) < 0) { /* failed to set binary form */ usage(h5tools_getprogname()); goto error; @@ -1019,7 +1019,7 @@ parse_start: break; case 'q': - if ((sort_by = set_sort_by(H5_optarg)) < 0) { + if ((sort_by = set_sort_by(opt_arg)) < 0) { /* failed to set "sort by" form */ usage(h5tools_getprogname()); goto error; @@ -1027,7 +1027,7 @@ parse_start: break; case 'z': - if ((sort_order = set_sort_order(H5_optarg)) < 0) { + if ((sort_order = set_sort_order(opt_arg)) < 0) { /* failed to set "sort order" form */ usage(h5tools_getprogname()); goto error; @@ -1039,7 +1039,7 @@ parse_start: error_msg("option \"-%c\" can only be used after --dataset option\n", opt); goto error; } - if (parse_mask_list(H5_optarg) != SUCCEED) { + if (parse_mask_list(opt_arg) != SUCCEED) { usage(h5tools_getprogname()); goto error; } @@ -1049,7 +1049,7 @@ parse_start: dump_opts.display_vds_first = TRUE; break; case 'G': - dump_opts.vds_gap_size = HDatoi(H5_optarg); + dump_opts.vds_gap_size = HDatoi(opt_arg); if (dump_opts.vds_gap_size < 0) { usage(h5tools_getprogname()); goto error; @@ -1076,13 +1076,13 @@ parse_start: case 'D': /* specify alternative XML DTD or schema */ /* To Do: check format of this value? */ - xml_dtd_uri_g = H5_optarg; + xml_dtd_uri_g = opt_arg; h5tools_nCols = 0; break; case 'm': /* specify alternative floating point printing format */ - fp_format = H5_optarg; + fp_format = opt_arg; h5tools_nCols = 0; break; @@ -1093,10 +1093,10 @@ parse_start: usage(h5tools_getprogname()); goto error; } - if (HDstrcmp(H5_optarg, ":") == 0) + if (HDstrcmp(opt_arg, ":") == 0) xmlnsprefix = ""; else - xmlnsprefix = H5_optarg; + xmlnsprefix = opt_arg; h5tools_nCols = 0; break; /** end XML parameters **/ @@ -1142,33 +1142,33 @@ parse_start: HDfree(s->start.data); s->start.data = NULL; } - parse_hsize_list(H5_optarg, &s->start); + parse_hsize_list(opt_arg, &s->start); break; case 'S': if (s->stride.data) { HDfree(s->stride.data); s->stride.data = NULL; } - parse_hsize_list(H5_optarg, &s->stride); + parse_hsize_list(opt_arg, &s->stride); break; case 'c': if (s->count.data) { HDfree(s->count.data); s->count.data = NULL; } - parse_hsize_list(H5_optarg, &s->count); + parse_hsize_list(opt_arg, &s->count); break; case 'k': if (s->block.data) { HDfree(s->block.data); s->block.data = NULL; } - parse_hsize_list(H5_optarg, &s->block); + parse_hsize_list(opt_arg, &s->block); break; default: goto end_collect; } - } while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF); + } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); end_collect: last_was_dset = FALSE; @@ -1181,8 +1181,8 @@ end_collect: /** end subsetting parameters **/ case 'E': - if (H5_optarg != NULL) - enable_error_stack = HDatoi(H5_optarg); + if (opt_arg != NULL) + enable_error_stack = HDatoi(opt_arg); else enable_error_stack = 1; break; @@ -1198,7 +1198,7 @@ end_collect: case '$': #ifdef H5_HAVE_ROS3_VFD - if (h5tools_parse_ros3_fapl_tuple(H5_optarg, ',', &ros3_fa_g) < 0) { + if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) { error_msg("failed to parse S3 VFD credential info\n"); usage(h5tools_getprogname()); free_handler(hand, argc); @@ -1215,7 +1215,7 @@ end_collect: case '#': #ifdef H5_HAVE_LIBHDFS - if (h5tools_parse_hdfs_fapl_tuple(H5_optarg, ',', &hdfs_fa_g) < 0) { + if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) { error_msg("failed to parse HDFS VFD configuration info\n"); usage(h5tools_getprogname()); free_handler(hand, argc); @@ -1239,7 +1239,7 @@ end_collect: parse_end: /* check for file name to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; @@ -1331,7 +1331,7 @@ main(int argc, char *argv[]) } } - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); @@ -1376,8 +1376,8 @@ main(int argc, char *argv[]) } } /* driver name defined */ - while (H5_optind < argc) { - fname = HDstrdup(argv[H5_optind++]); + while (opt_ind < argc) { + fname = HDstrdup(argv[opt_ind++]); fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 8d5a4a8..3a9a939 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -1264,7 +1264,7 @@ dump_fcontents(hid_t fid) { PRINTSTREAM(rawoutstream, "%s %s\n", FILE_CONTENTS, BEGIN); - /* special case of unamed types in root group */ + /* special case of unnamed types in root group */ if (unamedtype) { unsigned u; @@ -1933,7 +1933,7 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe, char name[128]; if (!type_table->objs[idx].recorded) { - /* unamed datatype */ + /* unnamed datatype */ HDsprintf(name, "/#" H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno); if (!HDstrcmp(name, real_name)) diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 479d6d4..508ea65 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -38,11 +38,11 @@ static int verbose_g = 0; * Command-line options: The user can specify short or long-named * parameters. */ -static const char * s_opts = "hVvd:n"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"version", no_arg, 'V'}, - {"verbose", no_arg, 'v'}, {"dname", require_arg, 'd'}, - {"noop", no_arg, 'n'}, {"enable-error-stack", no_arg, 'E'}, - {NULL, 0, '\0'}}; +static const char * s_opts = "hVvd:n"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"version", no_arg, 'V'}, + {"verbose", no_arg, 'v'}, {"dname", require_arg, 'd'}, + {"noop", no_arg, 'n'}, {"enable-error-stack", no_arg, 'E'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -106,7 +106,7 @@ parse_command_line(int argc, const char *const *argv) } /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'h': usage(h5tools_getprogname()); @@ -123,11 +123,11 @@ parse_command_line(int argc, const char *const *argv) break; case 'd': /* -d dname */ - if (H5_optarg != NULL && *H5_optarg) - dname_g = HDstrdup(H5_optarg); + if (opt_arg != NULL && *opt_arg) + dname_g = HDstrdup(opt_arg); if (dname_g == NULL) { h5tools_setstatus(EXIT_FAILURE); - error_msg("No dataset name\n", H5_optarg); + error_msg("No dataset name\n", opt_arg); usage(h5tools_getprogname()); goto error; } @@ -150,14 +150,14 @@ parse_command_line(int argc, const char *const *argv) } /* switch */ } /* while */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); goto error; } - fname_g = HDstrdup(argv[H5_optind]); + fname_g = HDstrdup(argv[opt_ind]); return 0; diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index c3dfa8e..35e61c5 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -34,10 +34,10 @@ char *ub_file = NULL; * 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 = "hi:u:o:c:V"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'}, - {"u", require_arg, 'u'}, {"o", require_arg, 'o'}, - {"clobber", no_arg, 'c'}, {NULL, 0, '\0'}}; +static const char * s_opts = "hi:u:o:c:V"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'}, + {"u", require_arg, 'u'}, {"o", require_arg, 'o'}, + {"clobber", no_arg, 'c'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -109,16 +109,16 @@ parse_command_line(int argc, const char *const *argv) int opt = FALSE; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'o': - output_file = HDstrdup(H5_optarg); + output_file = HDstrdup(opt_arg); break; case 'i': - input_file = HDstrdup(H5_optarg); + input_file = HDstrdup(opt_arg); break; case 'u': - ub_file = HDstrdup(H5_optarg); + ub_file = HDstrdup(opt_arg); break; case 'c': do_clobber = TRUE; diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c index 38f0a0c..001e48f 100644 --- a/tools/src/h5jam/h5unjam.c +++ b/tools/src/h5jam/h5unjam.c @@ -35,10 +35,10 @@ char *ub_file = NULL; * 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 = "hu:i:o:d:V"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'}, - {"u", require_arg, 'u'}, {"o", require_arg, 'o'}, - {"delete", no_arg, 'd'}, {NULL, 0, '\0'}}; +static const char * s_opts = "hu:i:o:d:V"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'}, + {"u", require_arg, 'u'}, {"o", require_arg, 'o'}, + {"delete", no_arg, 'd'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -97,23 +97,23 @@ parse_command_line(int argc, const char *const *argv) int opt = FALSE; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'o': - output_file = HDstrdup(H5_optarg); + output_file = HDstrdup(opt_arg); if (output_file) h5tools_set_data_output_file(output_file, 1); break; case 'i': - input_file = HDstrdup(H5_optarg); + input_file = HDstrdup(opt_arg); if (input_file) h5tools_set_input_file(input_file, 1); break; ; case 'u': - ub_file = HDstrdup(H5_optarg); + ub_file = HDstrdup(opt_arg); if (ub_file) h5tools_set_output_file(ub_file, 1); else diff --git a/tools/src/h5perf/pio_perf.c b/tools/src/h5perf/pio_perf.c index 560512c..01165bb 100644 --- a/tools/src/h5perf/pio_perf.c +++ b/tools/src/h5perf/pio_perf.c @@ -129,31 +129,31 @@ static const char *s_opts = "a:A:B:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; #else static const char *s_opts = "a:A:bB:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:"; #endif /* 1 */ -static struct h5_long_options l_opts[] = {{"align", require_arg, 'a'}, - {"api", require_arg, 'A'}, +static struct long_options l_opts[] = {{"align", require_arg, 'a'}, + {"api", require_arg, 'A'}, #if 0 /* a sighting of the elusive binary option */ { "binary", no_arg, 'b' }, #endif /* 0 */ - {"block-size", require_arg, 'B'}, - {"chunk", no_arg, 'c'}, - {"collective", no_arg, 'C'}, - {"debug", require_arg, 'D'}, - {"geometry", no_arg, 'g'}, - {"help", no_arg, 'h'}, - {"interleaved", require_arg, 'I'}, - {"max-num-processes", require_arg, 'P'}, - {"min-num-processes", require_arg, 'p'}, - {"max-xfer-size", require_arg, 'X'}, - {"min-xfer-size", require_arg, 'x'}, - {"num-bytes", require_arg, 'e'}, - {"num-dsets", require_arg, 'd'}, - {"num-files", require_arg, 'F'}, - {"num-iterations", require_arg, 'i'}, - {"output", require_arg, 'o'}, - {"threshold", require_arg, 'T'}, - {"write-only", require_arg, 'w'}, - {NULL, 0, '\0'}}; + {"block-size", require_arg, 'B'}, + {"chunk", no_arg, 'c'}, + {"collective", no_arg, 'C'}, + {"debug", require_arg, 'D'}, + {"geometry", no_arg, 'g'}, + {"help", no_arg, 'h'}, + {"interleaved", require_arg, 'I'}, + {"max-num-processes", require_arg, 'P'}, + {"min-num-processes", require_arg, 'p'}, + {"max-xfer-size", require_arg, 'X'}, + {"min-xfer-size", require_arg, 'x'}, + {"num-bytes", require_arg, 'e'}, + {"num-dsets", require_arg, 'd'}, + {"num-files", require_arg, 'F'}, + {"num-iterations", require_arg, 'i'}, + {"output", require_arg, 'o'}, + {"threshold", require_arg, 'T'}, + {"write-only", require_arg, 'w'}, + {NULL, 0, '\0'}}; struct options { long io_types; /* bitmask of which I/O types to test */ @@ -1305,13 +1305,13 @@ parse_command_line(int argc, const char *const *argv) cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ cl_opts->verify = FALSE; /* No Verify data correctness by default */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'a': - cl_opts->h5_alignment = parse_size_directive(H5_optarg); + cl_opts->h5_alignment = parse_size_directive(opt_arg); break; case 'A': { - const char *end = H5_optarg; + const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; @@ -1351,7 +1351,7 @@ parse_command_line(int argc, const char *const *argv) break; #endif /* 0 */ case 'B': - cl_opts->blk_size = (size_t)parse_size_directive(H5_optarg); + cl_opts->blk_size = (size_t)parse_size_directive(opt_arg); break; case 'c': /* Turn on chunked HDF5 dataset creation */ @@ -1361,10 +1361,10 @@ parse_command_line(int argc, const char *const *argv) cl_opts->collective = 1; break; case 'd': - cl_opts->num_dsets = atoi(H5_optarg); + cl_opts->num_dsets = atoi(opt_arg); break; case 'D': { - const char *end = H5_optarg; + const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; @@ -1421,40 +1421,40 @@ parse_command_line(int argc, const char *const *argv) break; case 'e': - cl_opts->num_bpp = parse_size_directive(H5_optarg); + cl_opts->num_bpp = parse_size_directive(opt_arg); break; case 'F': - cl_opts->num_files = HDatoi(H5_optarg); + cl_opts->num_files = HDatoi(opt_arg); break; case 'g': cl_opts->dim2d = 1; break; case 'i': - cl_opts->num_iters = HDatoi(H5_optarg); + cl_opts->num_iters = HDatoi(opt_arg); break; case 'I': cl_opts->interleaved = 1; break; case 'o': - cl_opts->output_file = H5_optarg; + cl_opts->output_file = opt_arg; break; case 'p': - cl_opts->min_num_procs = HDatoi(H5_optarg); + cl_opts->min_num_procs = HDatoi(opt_arg); break; case 'P': - cl_opts->max_num_procs = HDatoi(H5_optarg); + cl_opts->max_num_procs = HDatoi(opt_arg); break; case 'T': - cl_opts->h5_threshold = parse_size_directive(H5_optarg); + cl_opts->h5_threshold = parse_size_directive(opt_arg); break; case 'w': cl_opts->h5_write_only = TRUE; break; case 'x': - cl_opts->min_xfer_size = (size_t)parse_size_directive(H5_optarg); + cl_opts->min_xfer_size = (size_t)parse_size_directive(opt_arg); break; case 'X': - cl_opts->max_xfer_size = (size_t)parse_size_directive(H5_optarg); + cl_opts->max_xfer_size = (size_t)parse_size_directive(opt_arg); break; case 'h': case '?': diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c index 625f313..c979e7a 100644 --- a/tools/src/h5perf/sio_perf.c +++ b/tools/src/h5perf/sio_perf.c @@ -97,35 +97,35 @@ static const char *progname = "h5perf_serial"; * It seems that only the options that accept additional information * such as dataset size (-e) require the colon next to it. */ -static const char * s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; -static struct h5_long_options l_opts[] = {{"align", require_arg, 'a'}, - {"api", require_arg, 'A'}, +static const char * s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:"; +static struct long_options l_opts[] = {{"align", require_arg, 'a'}, + {"api", require_arg, 'A'}, #if 0 /* a sighting of the elusive binary option */ { "binary", no_arg, 'b' }, #endif /* 0 */ - {"block-size", require_arg, 'B'}, - {"chunk", no_arg, 'c'}, - {"collective", no_arg, 'C'}, - {"debug", require_arg, 'D'}, - {"file-driver", require_arg, 'v'}, - {"geometry", no_arg, 'g'}, - {"help", no_arg, 'h'}, - {"interleaved", require_arg, 'I'}, - {"max-num-processes", require_arg, 'P'}, - {"min-num-processes", require_arg, 'p'}, - {"max-xfer-size", require_arg, 'X'}, - {"min-xfer-size", require_arg, 'x'}, - {"num-bytes", require_arg, 'e'}, - {"num-dsets", require_arg, 'd'}, - {"num-files", require_arg, 'F'}, - {"num-iterations", require_arg, 'i'}, - {"order", require_arg, 'r'}, - {"output", require_arg, 'o'}, - {"extendable", no_arg, 't'}, - {"threshold", require_arg, 'T'}, - {"write-only", require_arg, 'w'}, - {NULL, 0, '\0'}}; + {"block-size", require_arg, 'B'}, + {"chunk", no_arg, 'c'}, + {"collective", no_arg, 'C'}, + {"debug", require_arg, 'D'}, + {"file-driver", require_arg, 'v'}, + {"geometry", no_arg, 'g'}, + {"help", no_arg, 'h'}, + {"interleaved", require_arg, 'I'}, + {"max-num-processes", require_arg, 'P'}, + {"min-num-processes", require_arg, 'p'}, + {"max-xfer-size", require_arg, 'X'}, + {"min-xfer-size", require_arg, 'x'}, + {"num-bytes", require_arg, 'e'}, + {"num-dsets", require_arg, 'd'}, + {"num-files", require_arg, 'F'}, + {"num-iterations", require_arg, 'i'}, + {"order", require_arg, 'r'}, + {"output", require_arg, 'o'}, + {"extendable", no_arg, 't'}, + {"threshold", require_arg, 'T'}, + {"write-only", require_arg, 'w'}, + {NULL, 0, '\0'}}; struct options { long io_types; /* bitmask of which I/O types to test */ @@ -857,19 +857,19 @@ parse_command_line(int argc, const char *const *argv) cl_opts->h5_extendable = FALSE; /* Use extendable dataset */ cl_opts->verify = FALSE; /* No Verify data correctness by default */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'a': - cl_opts->h5_alignment = parse_size_directive(H5_optarg); + cl_opts->h5_alignment = parse_size_directive(opt_arg); break; case 'G': - cl_opts->page_size = parse_size_directive(H5_optarg); + cl_opts->page_size = parse_size_directive(opt_arg); break; case 'b': - cl_opts->page_buffer_size = parse_size_directive(H5_optarg); + cl_opts->page_buffer_size = parse_size_directive(opt_arg); break; case 'A': { - const char *end = H5_optarg; + const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; @@ -907,7 +907,7 @@ parse_command_line(int argc, const char *const *argv) /* Turn on chunked HDF5 dataset creation */ cl_opts->h5_use_chunks = 1; { - const char *end = H5_optarg; + const char *end = opt_arg; int j = 0; while (end && *end != '\0') { @@ -934,7 +934,7 @@ parse_command_line(int argc, const char *const *argv) break; case 'D': { - const char *end = H5_optarg; + const char *end = opt_arg; while (end && *end != '\0') { char buf[10]; @@ -990,7 +990,7 @@ parse_command_line(int argc, const char *const *argv) break; case 'e': { - const char *end = H5_optarg; + const char *end = opt_arg; int j = 0; while (end && *end != '\0') { @@ -1017,38 +1017,38 @@ parse_command_line(int argc, const char *const *argv) break; case 'i': - cl_opts->num_iters = HDatoi(H5_optarg); + cl_opts->num_iters = HDatoi(opt_arg); break; case 'o': - cl_opts->output_file = H5_optarg; + cl_opts->output_file = opt_arg; break; case 'T': - cl_opts->h5_threshold = parse_size_directive(H5_optarg); + cl_opts->h5_threshold = parse_size_directive(opt_arg); break; case 'v': - if (!HDstrcasecmp(H5_optarg, "sec2")) { + if (!HDstrcasecmp(opt_arg, "sec2")) { cl_opts->vfd = sec2; } - else if (!HDstrcasecmp(H5_optarg, "stdio")) { + else if (!HDstrcasecmp(opt_arg, "stdio")) { cl_opts->vfd = stdio; } - else if (!HDstrcasecmp(H5_optarg, "core")) { + else if (!HDstrcasecmp(opt_arg, "core")) { cl_opts->vfd = core; } - else if (!HDstrcasecmp(H5_optarg, "split")) { + else if (!HDstrcasecmp(opt_arg, "split")) { cl_opts->vfd = split; } - else if (!HDstrcasecmp(H5_optarg, "multi")) { + else if (!HDstrcasecmp(opt_arg, "multi")) { cl_opts->vfd = multi; } - else if (!HDstrcasecmp(H5_optarg, "family")) { + else if (!HDstrcasecmp(opt_arg, "family")) { cl_opts->vfd = family; } - else if (!HDstrcasecmp(H5_optarg, "direct")) { + else if (!HDstrcasecmp(opt_arg, "direct")) { cl_opts->vfd = direct; } else { - HDfprintf(stderr, "sio_perf: invalid --api option %s\n", H5_optarg); + HDfprintf(stderr, "sio_perf: invalid --api option %s\n", opt_arg); HDexit(EXIT_FAILURE); } break; @@ -1059,7 +1059,7 @@ parse_command_line(int argc, const char *const *argv) cl_opts->h5_extendable = TRUE; break; case 'x': { - const char *end = H5_optarg; + const char *end = opt_arg; int j = 0; while (end && *end != '\0') { @@ -1086,7 +1086,7 @@ parse_command_line(int argc, const char *const *argv) break; case 'r': { - const char *end = H5_optarg; + const char *end = opt_arg; int j = 0; while (end && *end != '\0') { diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 04a87b9..8ab9637 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -31,38 +31,38 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXW"; -static struct h5_long_options l_opts[] = {{"alignment", require_arg, 'a'}, - {"block", require_arg, 'b'}, - {"compact", require_arg, 'c'}, - {"indexed", require_arg, 'd'}, - {"file", require_arg, 'e'}, - {"filter", require_arg, 'f'}, - {"help", no_arg, 'h'}, - {"infile", require_arg, 'i'}, /* for backward compability */ - {"low", require_arg, 'j'}, - {"high", require_arg, 'k'}, - {"layout", require_arg, 'l'}, - {"minimum", require_arg, 'm'}, - {"native", no_arg, 'n'}, - {"outfile", require_arg, 'o'}, /* for backward compability */ - {"sort_by", require_arg, 'q'}, - {"ssize", require_arg, 's'}, - {"threshold", require_arg, 't'}, - {"ublock", require_arg, 'u'}, - {"verbose", no_arg, 'v'}, - {"sort_order", require_arg, 'z'}, - {"enable-error-stack", no_arg, 'E'}, - {"fs_pagesize", require_arg, 'G'}, - {"latest", no_arg, 'L'}, - {"metadata_block_size", require_arg, 'M'}, - {"fs_persist", require_arg, 'P'}, - {"fs_strategy", require_arg, 'S'}, - {"fs_threshold", require_arg, 'T'}, - {"version", no_arg, 'V'}, - {"merge", no_arg, 'X'}, - {"prune", no_arg, 'W'}, - {NULL, 0, '\0'}}; +static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXW"; +static struct long_options l_opts[] = {{"alignment", require_arg, 'a'}, + {"block", require_arg, 'b'}, + {"compact", require_arg, 'c'}, + {"indexed", require_arg, 'd'}, + {"file", require_arg, 'e'}, + {"filter", require_arg, 'f'}, + {"help", no_arg, 'h'}, + {"infile", require_arg, 'i'}, /* for backward compability */ + {"low", require_arg, 'j'}, + {"high", require_arg, 'k'}, + {"layout", require_arg, 'l'}, + {"minimum", require_arg, 'm'}, + {"native", no_arg, 'n'}, + {"outfile", require_arg, 'o'}, /* for backward compability */ + {"sort_by", require_arg, 'q'}, + {"ssize", require_arg, 's'}, + {"threshold", require_arg, 't'}, + {"ublock", require_arg, 'u'}, + {"verbose", no_arg, 'v'}, + {"sort_order", require_arg, 'z'}, + {"enable-error-stack", no_arg, 'E'}, + {"fs_pagesize", require_arg, 'G'}, + {"latest", no_arg, 'L'}, + {"metadata_block_size", require_arg, 'M'}, + {"fs_persist", require_arg, 'P'}, + {"fs_strategy", require_arg, 'S'}, + {"fs_threshold", require_arg, 'T'}, + {"version", no_arg, 'V'}, + {"merge", no_arg, 'X'}, + {"prune", no_arg, 'W'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -462,18 +462,18 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) int ret_value = 0; /* parse command line options */ - while (EOF != (opt = H5_get_option(argc, argv, s_opts, l_opts))) { + while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { switch ((char)opt) { /* -i for backward compatibility */ case 'i': - infile = H5_optarg; + infile = opt_arg; has_i++; break; /* -o for backward compatibility */ case 'o': - outfile = H5_optarg; + outfile = opt_arg; has_o++; break; @@ -495,7 +495,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) case 'f': /* parse the -f filter option */ - if (h5repack_addfilter(H5_optarg, options) < 0) { + if (h5repack_addfilter(opt_arg, options) < 0) { error_msg("in parsing filter\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -505,7 +505,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) case 'l': /* parse the -l layout option */ - if (h5repack_addlayout(H5_optarg, options) < 0) { + if (h5repack_addlayout(opt_arg, options) < 0) { error_msg("in parsing layout\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -514,9 +514,9 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'm': - options->min_comp = HDstrtoull(H5_optarg, NULL, 0); + options->min_comp = HDstrtoull(opt_arg, NULL, 0); if ((int)options->min_comp <= 0) { - error_msg("invalid minimum compress size <%s>\n", H5_optarg); + error_msg("invalid minimum compress size <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -524,8 +524,8 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'e': - if ((ret_value = read_info(H5_optarg, options)) < 0) { - error_msg("failed to read from repack options file <%s>\n", H5_optarg); + if ((ret_value = read_info(opt_arg, options)) < 0) { + error_msg("failed to read from repack options file <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -541,7 +541,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'j': - bound = HDatoi(H5_optarg); + bound = HDatoi(opt_arg); if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing low bound\n"); h5tools_setstatus(EXIT_FAILURE); @@ -552,7 +552,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'k': - bound = HDatoi(H5_optarg); + bound = HDatoi(opt_arg); if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing high bound\n"); h5tools_setstatus(EXIT_FAILURE); @@ -571,13 +571,13 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'c': - options->grp_compact = HDatoi(H5_optarg); + options->grp_compact = HDatoi(opt_arg); if (options->grp_compact > 0) options->latest = TRUE; /* must use latest format */ break; case 'd': - options->grp_indexed = HDatoi(H5_optarg); + options->grp_indexed = HDatoi(opt_arg); if (options->grp_indexed > 0) options->latest = TRUE; /* must use latest format */ break; @@ -585,10 +585,10 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) case 's': { int idx = 0; int ssize = 0; - char *msgPtr = HDstrchr(H5_optarg, ':'); + char *msgPtr = HDstrchr(opt_arg, ':'); options->latest = TRUE; /* must use latest format */ if (msgPtr == NULL) { - ssize = HDatoi(H5_optarg); + ssize = HDatoi(opt_arg); for (idx = 0; idx < 5; idx++) options->msg_size[idx] = ssize; } @@ -597,7 +597,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) HDstrcpy(msgType, msgPtr + 1); msgPtr[0] = '\0'; - ssize = HDatoi(H5_optarg); + ssize = HDatoi(opt_arg); if (!HDstrncmp(msgType, "dspace", 6)) options->msg_size[0] = ssize; else if (!HDstrncmp(msgType, "dtype", 5)) @@ -612,25 +612,25 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) } break; case 'u': - options->ublock_filename = H5_optarg; + options->ublock_filename = opt_arg; break; case 'b': - options->ublock_size = (hsize_t)HDatol(H5_optarg); + options->ublock_size = (hsize_t)HDatol(opt_arg); break; case 'M': - options->meta_block_size = (hsize_t)HDatol(H5_optarg); + options->meta_block_size = (hsize_t)HDatol(opt_arg); break; case 't': - options->threshold = (hsize_t)HDatol(H5_optarg); + options->threshold = (hsize_t)HDatol(opt_arg); break; case 'a': - options->alignment = HDstrtoull(H5_optarg, NULL, 0); + options->alignment = HDstrtoull(opt_arg, NULL, 0); if (options->alignment < 1) { - error_msg("invalid alignment size\n", H5_optarg); + error_msg("invalid alignment size\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -640,7 +640,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) case 'S': { char strategy[MAX_NC_NAME]; - HDstrcpy(strategy, H5_optarg); + HDstrcpy(strategy, opt_arg); if (!HDstrcmp(strategy, "FSM_AGGR")) options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; else if (!HDstrcmp(strategy, "PAGE")) @@ -650,7 +650,7 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) else if (!HDstrcmp(strategy, "NONE")) options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; else { - error_msg("invalid file space management strategy\n", H5_optarg); + error_msg("invalid file space management strategy\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -661,29 +661,29 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) } break; case 'P': - options->fs_persist = HDatoi(H5_optarg); + options->fs_persist = HDatoi(opt_arg); if (options->fs_persist == 0) /* To distinguish the "specified" zero value */ options->fs_persist = -1; break; case 'T': - options->fs_threshold = HDatol(H5_optarg); + options->fs_threshold = HDatol(opt_arg); if (options->fs_threshold == 0) /* To distinguish the "specified" zero value */ options->fs_threshold = -1; break; case 'G': - options->fs_pagesize = HDstrtoll(H5_optarg, NULL, 0); + options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0); if (options->fs_pagesize == 0) /* To distinguish the "specified" zero value */ options->fs_pagesize = -1; break; case 'q': - if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(H5_optarg))) { - error_msg("failed to set sort by form <%s>\n", H5_optarg); + if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) { + error_msg("failed to set sort by form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -691,8 +691,8 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) break; case 'z': - if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(H5_optarg))) { - error_msg("failed to set sort order form <%s>\n", H5_optarg); + if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) { + error_msg("failed to set sort order form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -710,9 +710,9 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) /* If neither -i nor -o given, get in and out files positionally */ if (0 == (has_i + has_o)) { - if (argv[H5_optind] != NULL && argv[H5_optind + 1] != NULL) { - infile = argv[H5_optind]; - outfile = argv[H5_optind + 1]; + if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { + infile = argv[opt_ind]; + outfile = argv[opt_ind + 1]; if (!HDstrcmp(infile, outfile)) { error_msg("file names cannot be the same\n"); diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index bb0f0a0..d36c348 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -171,23 +171,23 @@ struct handler_t { static const char *s_opts = "Aa:Ddm:EFfhGgl:sSTO:Vw:H:"; /* e.g. "filemetadata" has to precede "file"; "groupmetadata" has to precede "group" etc. */ -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, - {"filemetadata", no_arg, 'F'}, - {"groupmetadata", no_arg, 'G'}, - {"links", require_arg, 'l'}, - {"dsetmetadata", no_arg, 'D'}, - {"dims", require_arg, 'm'}, - {"dtypemetadata", no_arg, 'T'}, - {"object", require_arg, 'O'}, - {"version", no_arg, 'V'}, - {"attribute", no_arg, 'A'}, - {"enable-error-stack", no_arg, 'E'}, - {"numattrs", require_arg, 'a'}, - {"freespace", no_arg, 's'}, - {"summary", no_arg, 'S'}, - {"s3-cred", require_arg, 'w'}, - {"hdfs-attrs", require_arg, 'H'}, - {NULL, 0, '\0'}}; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"filemetadata", no_arg, 'F'}, + {"groupmetadata", no_arg, 'G'}, + {"links", require_arg, 'l'}, + {"dsetmetadata", no_arg, 'D'}, + {"dims", require_arg, 'm'}, + {"dtypemetadata", no_arg, 'T'}, + {"object", require_arg, 'O'}, + {"version", no_arg, 'V'}, + {"attribute", no_arg, 'A'}, + {"enable-error-stack", no_arg, 'E'}, + {"numattrs", require_arg, 'a'}, + {"freespace", no_arg, 's'}, + {"summary", no_arg, 'S'}, + {"s3-cred", require_arg, 'w'}, + {"hdfs-attrs", require_arg, 'H'}, + {NULL, 0, '\0'}}; static void leave(int ret) @@ -831,7 +831,7 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re struct handler_t *hand = NULL; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'h': usage(h5tools_getprogname()); @@ -870,8 +870,8 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re break; case 'l': - if (H5_optarg) { - sgroups_threshold = HDatoi(H5_optarg); + if (opt_arg) { + sgroups_threshold = HDatoi(opt_arg); if (sgroups_threshold < 1) { error_msg("Invalid threshold for small groups\n"); goto error; @@ -893,8 +893,8 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re break; case 'm': - if (H5_optarg) { - sdsets_threshold = HDatoi(H5_optarg); + if (opt_arg) { + sdsets_threshold = HDatoi(opt_arg); if (sdsets_threshold < 1) { error_msg("Invalid threshold for small datasets\n"); goto error; @@ -916,8 +916,8 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re break; case 'a': - if (H5_optarg) { - sattrs_threshold = HDatoi(H5_optarg); + if (opt_arg) { + sattrs_threshold = HDatoi(opt_arg); if (sattrs_threshold < 1) { error_msg("Invalid threshold for small # of attributes\n"); goto error; @@ -957,7 +957,7 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re /* Store object names */ for (u = 0; u < hand->obj_count; u++) - if (NULL == (hand->obj[u] = HDstrdup(H5_optarg))) { + if (NULL == (hand->obj[u] = HDstrdup(opt_arg))) { error_msg("unable to allocate memory for object name\n"); goto error; } /* end if */ @@ -965,7 +965,7 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re case 'w': #ifdef H5_HAVE_ROS3_VFD - if (h5tools_parse_ros3_fapl_tuple(H5_optarg, ',', &ros3_fa) < 0) { + if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) { error_msg("failed to parse S3 VFD credential info\n"); goto error; } @@ -979,7 +979,7 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re case 'H': #ifdef H5_HAVE_LIBHDFS - if (h5tools_parse_hdfs_fapl_tuple(H5_optarg, ',', &hdfs_fa) < 0) { + if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) { error_msg("failed to parse HDFS VFD configuration info\n"); goto error; } @@ -998,7 +998,7 @@ parse_command_line(int argc, const char *const *argv, struct handler_t **hand_re } /* end while */ /* check for file name to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; @@ -1722,7 +1722,7 @@ main(int argc, char *argv[]) } } - fname = argv[H5_optind]; + fname = argv[opt_ind]; /* Check for filename given */ if (fname) { diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c index 15c170d..60e2e63 100644 --- a/tools/src/misc/h5clear.c +++ b/tools/src/misc/h5clear.c @@ -44,8 +44,8 @@ static hsize_t increment = DEFAULT_INCREMENT; /* * Command-line options: only publicize long options */ -static const char * s_opts = "hVsmzi*"; -static struct h5_long_options l_opts[] = { +static const char * s_opts = "hVsmzi*"; +static struct long_options l_opts[] = { {"help", no_arg, 'h'}, {"version", no_arg, 'V'}, {"status", no_arg, 's'}, {"image", no_arg, 'm'}, {"filesize", no_arg, 'z'}, {"increment", optional_arg, 'i'}, {NULL, 0, '\0'}}; @@ -121,7 +121,7 @@ parse_command_line(int argc, const char *const *argv) } /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'h': usage(h5tools_getprogname()); @@ -147,12 +147,12 @@ parse_command_line(int argc, const char *const *argv) case 'i': increment_eoa_eof = TRUE; - if (H5_optarg != NULL) { - if (HDatoi(H5_optarg) < 0) { + if (opt_arg != NULL) { + if (HDatoi(opt_arg) < 0) { usage(h5tools_getprogname()); goto done; } - increment = (hsize_t)HDatoi(H5_optarg); + increment = (hsize_t)HDatoi(opt_arg); } break; @@ -164,14 +164,14 @@ parse_command_line(int argc, const char *const *argv) } /* end while */ /* check for file name to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); goto error; } /* end if */ - fname_g = HDstrdup(argv[H5_optind]); + fname_g = HDstrdup(argv[opt_ind]); done: return (0); diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c index 1942216..9b0d8f0 100644 --- a/tools/src/misc/h5mkgrp.c +++ b/tools/src/misc/h5mkgrp.c @@ -22,10 +22,10 @@ int d_status = EXIT_SUCCESS; /* command-line options: short and long-named parameters */ -static const char * s_opts = "hlpvV"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"latest", no_arg, 'l'}, - {"parents", no_arg, 'p'}, {"verbose", no_arg, 'v'}, - {"version", no_arg, 'V'}, {NULL, 0, '\0'}}; +static const char * s_opts = "hlpvV"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"latest", no_arg, 'l'}, + {"parents", no_arg, 'p'}, {"verbose", no_arg, 'v'}, + {"version", no_arg, 'V'}, {NULL, 0, '\0'}}; /* Command line parameter settings */ typedef struct mkgrp_opt_t { @@ -124,7 +124,7 @@ parse_command_line(int argc, const char *const *argv, mkgrp_opt_t *options) } /* Parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { /* Display 'help' */ case 'h': @@ -161,33 +161,33 @@ parse_command_line(int argc, const char *const *argv, mkgrp_opt_t *options) } /* end while */ /* Check for file name to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); } /* Retrieve file name */ - options->fname = HDstrdup(argv[H5_optind]); - H5_optind++; + options->fname = HDstrdup(argv[opt_ind]); + opt_ind++; /* Check for group(s) to be created */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing group name(s)\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); } /* Allocate space for the group name pointers */ - options->ngroups = (size_t)(argc - H5_optind); + options->ngroups = (size_t)(argc - opt_ind); options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *)); /* Retrieve the group names */ curr_group = 0; - while (H5_optind < argc) { - options->groups[curr_group] = HDstrdup(argv[H5_optind]); + while (opt_ind < argc) { + options->groups[curr_group] = HDstrdup(argv[opt_ind]); curr_group++; - H5_optind++; + opt_ind++; } return 0; diff --git a/tools/test/h5jam/getub.c b/tools/test/h5jam/getub.c index 4e67e98..562a6b9 100644 --- a/tools/test/h5jam/getub.c +++ b/tools/test/h5jam/getub.c @@ -21,9 +21,9 @@ void parse_command_line(int argc, const char *const *argv); #define PROGRAM_NAME "getub" char *nbytes = NULL; -static const char * s_opts = "c:"; /* add more later ? */ -static struct h5_long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */ - {NULL, 0, '\0'}}; +static const char * s_opts = "c:"; /* add more later ? */ +static struct long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */ + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -57,10 +57,10 @@ parse_command_line(int argc, const char *const *argv) int opt; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'c': - nbytes = HDstrdup(H5_optarg); + nbytes = HDstrdup(opt_arg); break; case '?': default: @@ -69,7 +69,7 @@ parse_command_line(int argc, const char *const *argv) } /* end switch */ } /* end while */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); HDexit(EXIT_FAILURE); @@ -100,13 +100,13 @@ main(int argc, char *argv[]) goto error; } /* end if */ - if (argc <= (H5_optind)) { + if (argc <= (opt_ind)) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; } /* end if */ - filename = HDstrdup(argv[H5_optind]); + filename = HDstrdup(argv[opt_ind]); size = 0; if (EOF == (res = HDsscanf(nbytes, "%u", &size))) { diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index 5272bd4..90e1072 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.c @@ -24,8 +24,8 @@ * 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 = "h"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}}; +static const char * s_opts = "h"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -61,7 +61,7 @@ parse_command_line(int argc, const char *const *argv) int opt; /* parse command line options */ - while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'h': usage(h5tools_getprogname()); @@ -75,7 +75,7 @@ parse_command_line(int argc, const char *const *argv) } /* check for file name to be processed */ - if (argc <= H5_optind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); @@ -118,14 +118,14 @@ main(int argc, char *argv[]) /* enable error reporting if command line option */ h5tools_error_report(); - if (argc <= (H5_optind)) { + if (argc <= (opt_ind)) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); goto done; } - ifname = HDstrdup(argv[H5_optind]); + ifname = HDstrdup(argv[opt_ind]); testval = H5Fis_hdf5(ifname); diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c index 9ea47d6..b4680a4 100644 --- a/tools/test/perform/pio_standalone.c +++ b/tools/test/perform/pio_standalone.c @@ -22,26 +22,31 @@ /* global variables */ int nCols = 80; +/* ``get_option'' variables */ +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char *opt_arg; /*flag argument (or value) */ + int -get_option(int argc, char **argv, const char *opts, const struct h5_long_options *l_opts) +get_option(int argc, const char *const *argv, const char *opts, const struct long_options *l_opts) { static int sp = 1; /* character index in current token */ int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ - if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') { + if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; } - else if (HDstrcmp(argv[H5_optind], "--") == 0) { - H5_optind++; + else if (HDstrcmp(argv[opt_ind], "--") == 0) { + opt_ind++; return EOF; } } - if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') { + if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ - const char *arg = &argv[H5_optind][2]; + const char *arg = &argv[opt_ind][2]; int i; for (i = 0; l_opts && l_opts[i].name; i++) { @@ -53,13 +58,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { - H5_optarg = &arg[len + 1]; + opt_arg = &arg[len + 1]; } - else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') { - H5_optarg = argv[++H5_optind]; + else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { + opt_arg = argv[++opt_ind]; } else if (l_opts[i].has_arg == require_arg) { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; @@ -67,13 +72,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options } else { if (arg[len] == '=') { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } - H5_optarg = NULL; + opt_arg = NULL; } break; @@ -82,29 +87,29 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (l_opts[i].name == NULL) { /* exhausted all of the l_opts we have and still didn't match */ - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); opt_opt = '?'; } - H5_optind++; + opt_ind++; sp = 1; } else { register char *cp; /* pointer into current token */ /* short command line option */ - opt_opt = argv[H5_optind][sp]; + opt_opt = argv[opt_ind][sp]; if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ - if (argv[H5_optind][++sp] == '\0') { - H5_optind++; + if (argv[opt_ind][++sp] == '\0') { + opt_ind++; sp = 1; } @@ -113,32 +118,32 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (*++cp == ':') { /* if a value is expected, get it */ - if (argv[H5_optind][sp + 1] != '\0') { + if (argv[opt_ind][sp + 1] != '\0') { /* flag value is rest of current token */ - H5_optarg = &argv[H5_optind++][sp + 1]; + opt_arg = &argv[opt_ind++][sp + 1]; } - else if (++H5_optind >= argc) { - if (H5_opterr) + else if (++opt_ind >= argc) { + if (opt_err) HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; } else { /* flag value is next token */ - H5_optarg = argv[H5_optind++]; + opt_arg = argv[opt_ind++]; } sp = 1; } else { /* set up to look at next char in token, next time */ - if (argv[H5_optind][++sp] == '\0') { + if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ - H5_optind++; + opt_ind++; sp = 1; } - H5_optarg = NULL; + opt_arg = NULL; } } diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h index 5cc9a63..1b83e21 100644 --- a/tools/test/perform/pio_standalone.h +++ b/tools/test/perform/pio_standalone.h @@ -465,9 +465,9 @@ extern char * strdup(const char *s); /** From h5tools_utils.h **/ -H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */ -H5_DLLVAR int H5_optind; /* token pointer */ -H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */ +extern int opt_err; /* getoption prints errors if this is on */ +extern int opt_ind; /* token pointer */ +extern const char *opt_arg; /* flag argument (or value) */ enum h5_arg_level { no_arg = 0, /* doesn't take an argument */ @@ -475,7 +475,7 @@ enum h5_arg_level { optional_arg /* argument is optional */ }; -struct h5_long_options { +struct long_options { const char * name; /* Name of the long option */ enum h5_arg_level has_arg; /* Whether we should look for an arg */ char shortval; /* The shortname equivalent of long arg @@ -483,8 +483,7 @@ struct h5_long_options { */ }; -extern int H5_get_option(int argc, const char *const *argv, const char *opt, - const struct h5_long_options *l_opt); +extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt); extern int nCols; /*max number of columns for outputting */ diff --git a/tools/test/perform/sio_standalone.c b/tools/test/perform/sio_standalone.c index ace6b7e..21a2fb5 100644 --- a/tools/test/perform/sio_standalone.c +++ b/tools/test/perform/sio_standalone.c @@ -22,26 +22,31 @@ /* global variables */ int nCols = 80; +/* ``get_option'' variables */ +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char *opt_arg; /*flag argument (or value) */ + int -get_option(int argc, char **argv, const char *opts, const struct h5_long_options *l_opts) +get_option(int argc, const char *const *argv, const char *opts, const struct long_options *l_opts) { static int sp = 1; /* character index in current token */ int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ - if (H5_optind >= argc || argv[H5_optind][0] != '-' || argv[H5_optind][1] == '\0') { + if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; } - else if (HDstrcmp(argv[H5_optind], "--") == 0) { - H5_optind++; + else if (HDstrcmp(argv[opt_ind], "--") == 0) { + opt_ind++; return EOF; } } - if (sp == 1 && argv[H5_optind][0] == '-' && argv[H5_optind][1] == '-') { + if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ - const char *arg = &argv[H5_optind][2]; + const char *arg = &argv[opt_ind][2]; int i; for (i = 0; l_opts && l_opts[i].name; i++) { @@ -53,13 +58,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (l_opts[i].has_arg != no_arg) { if (arg[len] == '=') { - H5_optarg = &arg[len + 1]; + opt_arg = &arg[len + 1]; } - else if (H5_optind < (argc - 1) && argv[H5_optind + 1][0] != '-') { - H5_optarg = argv[++H5_optind]; + else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') { + opt_arg = argv[++opt_ind]; } else if (l_opts[i].has_arg == require_arg) { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); opt_opt = '?'; @@ -67,13 +72,13 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options } else { if (arg[len] == '=') { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } - H5_optarg = NULL; + opt_arg = NULL; } break; @@ -82,29 +87,29 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (l_opts[i].name == NULL) { /* exhausted all of the l_opts we have and still didn't match */ - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); opt_opt = '?'; } - H5_optind++; + opt_ind++; sp = 1; } else { register char *cp; /* pointer into current token */ /* short command line option */ - opt_opt = argv[H5_optind][sp]; + opt_opt = argv[opt_ind][sp]; if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { - if (H5_opterr) + if (opt_err) HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ - if (argv[H5_optind][++sp] == '\0') { - H5_optind++; + if (argv[opt_ind][++sp] == '\0') { + opt_ind++; sp = 1; } @@ -113,32 +118,32 @@ get_option(int argc, char **argv, const char *opts, const struct h5_long_options if (*++cp == ':') { /* if a value is expected, get it */ - if (argv[H5_optind][sp + 1] != '\0') { + if (argv[opt_ind][sp + 1] != '\0') { /* flag value is rest of current token */ - H5_optarg = &argv[H5_optind++][sp + 1]; + opt_arg = &argv[opt_ind++][sp + 1]; } - else if (++H5_optind >= argc) { - if (H5_opterr) + else if (++opt_ind >= argc) { + if (opt_err) HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; } else { /* flag value is next token */ - H5_optarg = argv[H5_optind++]; + opt_arg = argv[opt_ind++]; } sp = 1; } else { /* set up to look at next char in token, next time */ - if (argv[H5_optind][++sp] == '\0') { + if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ - H5_optind++; + opt_ind++; sp = 1; } - H5_optarg = NULL; + opt_arg = NULL; } } diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h index 2fc644f..cadc00d 100644 --- a/tools/test/perform/sio_standalone.h +++ b/tools/test/perform/sio_standalone.h @@ -480,9 +480,9 @@ extern char * strdup(const char *s); /** From h5tools_utils.h **/ -H5_DLLVAR int H5_opterr; /* getoption prints errors if this is on */ -H5_DLLVAR int H5_optind; /* token pointer */ -H5_DLLVAR const char *H5_optarg; /* flag argument (or value) */ +extern int opt_err; /* getoption prints errors if this is on */ +extern int opt_ind; /* token pointer */ +extern const char *opt_arg; /* flag argument (or value) */ enum h5_arg_level { no_arg = 0, /* doesn't take an argument */ @@ -490,7 +490,7 @@ enum h5_arg_level { optional_arg /* argument is optional */ }; -struct h5_long_options { +struct long_options { const char * name; /* Name of the long option */ enum h5_arg_level has_arg; /* Whether we should look for an arg */ char shortval; /* The shortname equivalent of long arg @@ -498,8 +498,7 @@ struct h5_long_options { */ }; -extern int H5_get_option(int argc, const char *const *argv, const char *opt, - const struct h5_long_options *l_opt); +extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt); extern int nCols; /*max number of columns for outputting */ diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 5db97d1..4c7da15 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -64,15 +64,15 @@ static void error(const char *fmt, ...); static void compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); /* commandline options : long and short form */ -static const char * s_opts = "hB:b:c:p:rs:0123456789"; -static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, - {"compressability", require_arg, 'c'}, - {"file-size", require_arg, 's'}, - {"max-buffer-size", require_arg, 'B'}, - {"min-buffer-size", require_arg, 'b'}, - {"prefix", require_arg, 'p'}, - {"random-test", no_arg, 'r'}, - {NULL, 0, '\0'}}; +static const char * s_opts = "hB:b:c:p:rs:0123456789"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"compressability", require_arg, 'c'}, + {"file-size", require_arg, 's'}, + {"max-buffer-size", require_arg, 'B'}, + {"min-buffer-size", require_arg, 'b'}, + {"prefix", require_arg, 'p'}, + {"random-test", no_arg, 'r'}, + {NULL, 0, '\0'}}; /* * Function: error @@ -500,7 +500,7 @@ main(int argc, char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) > 0) { + while ((opt = get_option(argc, (const char *const *)argv, s_opts, l_opts)) > 0) { switch ((char)opt) { case '0': case '1': @@ -515,13 +515,13 @@ main(int argc, char *argv[]) compress_level = opt - '0'; break; case 'B': - max_buf_size = parse_size_directive(H5_optarg); + max_buf_size = parse_size_directive(opt_arg); break; case 'b': - min_buf_size = parse_size_directive(H5_optarg); + min_buf_size = parse_size_directive(opt_arg); break; case 'c': - compress_percent = (int)HDstrtol(H5_optarg, NULL, 10); + compress_percent = (int)HDstrtol(opt_arg, NULL, 10); if (compress_percent < 0) compress_percent = 0; @@ -530,13 +530,13 @@ main(int argc, char *argv[]) break; case 'p': - option_prefix = H5_optarg; + option_prefix = opt_arg; break; case 'r': random_test = TRUE; break; case 's': - file_size = parse_size_directive(H5_optarg); + file_size = parse_size_directive(opt_arg); break; case '?': usage(); -- cgit v0.12