summaryrefslogtreecommitdiffstats
path: root/tools/src/misc
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-06-29 20:06:48 (GMT)
committerGitHub <noreply@github.com>2021-06-29 20:06:48 (GMT)
commit2090a527c13a13c0ea5b59b319b3402d2ef8f578 (patch)
treeb9d6a7744894956cba1e99630f1803c42d2298e4 /tools/src/misc
parent4ff544f9977da3bd54eac03cc124961eea7c4daf (diff)
downloadhdf5-2090a527c13a13c0ea5b59b319b3402d2ef8f578.zip
hdf5-2090a527c13a13c0ea5b59b319b3402d2ef8f578.tar.gz
hdf5-2090a527c13a13c0ea5b59b319b3402d2ef8f578.tar.bz2
Brings the tools getopt(3) replacement into the main library (#803)
* Moves get_option from the tools library to the C library * Adds H5 prefix to get_option call and variables * Renames the H5_get_option long options struct and enum
Diffstat (limited to 'tools/src/misc')
-rw-r--r--tools/src/misc/h5clear.c80
-rw-r--r--tools/src/misc/h5mkgrp.c28
2 files changed, 54 insertions, 54 deletions
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index ac7c0ca..524ad03 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -44,40 +44,40 @@ static hsize_t increment = DEFAULT_INCREMENT;
/*
* Command-line options: only publicize long options
*/
-static const char * s_opts = "hVsmzi*";
-static struct long_options l_opts[] = {{"help", no_arg, 'h'},
- {"hel", no_arg, 'h'},
- {"he", no_arg, 'h'},
- {"version", no_arg, 'V'},
- {"version", no_arg, 'V'},
- {"versio", no_arg, 'V'},
- {"versi", no_arg, 'V'},
- {"vers", no_arg, 'V'},
- {"status", no_arg, 's'},
- {"statu", no_arg, 's'},
- {"stat", no_arg, 's'},
- {"sta", no_arg, 's'},
- {"st", no_arg, 's'},
- {"image", no_arg, 'm'},
- {"imag", no_arg, 'm'},
- {"ima", no_arg, 'm'},
- {"im", no_arg, 'm'},
- {"filesize", no_arg, 'z'},
- {"filesiz", no_arg, 'z'},
- {"filesi", no_arg, 'z'},
- {"files", no_arg, 'z'},
- {"file", no_arg, 'z'},
- {"fil", no_arg, 'z'},
- {"fi", no_arg, 'z'},
- {"increment", optional_arg, 'i'},
- {"incremen", optional_arg, 'i'},
- {"increme", optional_arg, 'i'},
- {"increm", optional_arg, 'i'},
- {"incre", optional_arg, 'i'},
- {"incr", optional_arg, 'i'},
- {"inc", optional_arg, 'i'},
- {"in", optional_arg, 'i'},
- {NULL, 0, '\0'}};
+static const char * s_opts = "hVsmzi*";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'},
+ {"hel", no_arg, 'h'},
+ {"he", no_arg, 'h'},
+ {"version", no_arg, 'V'},
+ {"version", no_arg, 'V'},
+ {"versio", no_arg, 'V'},
+ {"versi", no_arg, 'V'},
+ {"vers", no_arg, 'V'},
+ {"status", no_arg, 's'},
+ {"statu", no_arg, 's'},
+ {"stat", no_arg, 's'},
+ {"sta", no_arg, 's'},
+ {"st", no_arg, 's'},
+ {"image", no_arg, 'm'},
+ {"imag", no_arg, 'm'},
+ {"ima", no_arg, 'm'},
+ {"im", no_arg, 'm'},
+ {"filesize", no_arg, 'z'},
+ {"filesiz", no_arg, 'z'},
+ {"filesi", no_arg, 'z'},
+ {"files", no_arg, 'z'},
+ {"file", no_arg, 'z'},
+ {"fil", no_arg, 'z'},
+ {"fi", no_arg, 'z'},
+ {"increment", optional_arg, 'i'},
+ {"incremen", optional_arg, 'i'},
+ {"increme", optional_arg, 'i'},
+ {"increm", optional_arg, 'i'},
+ {"incre", optional_arg, 'i'},
+ {"incr", optional_arg, 'i'},
+ {"inc", optional_arg, 'i'},
+ {"in", optional_arg, 'i'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -150,7 +150,7 @@ parse_command_line(int argc, const char **argv)
}
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case 'h':
usage(h5tools_getprogname());
@@ -176,12 +176,12 @@ parse_command_line(int argc, const char **argv)
case 'i':
increment_eoa_eof = TRUE;
- if (opt_arg != NULL) {
- if (HDatoi(opt_arg) < 0) {
+ if (H5_optarg != NULL) {
+ if (HDatoi(H5_optarg) < 0) {
usage(h5tools_getprogname());
goto done;
}
- increment = (hsize_t)HDatoi(opt_arg);
+ increment = (hsize_t)HDatoi(H5_optarg);
}
break;
@@ -193,14 +193,14 @@ parse_command_line(int argc, const char **argv)
} /* end while */
/* check for file name to be processed */
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto error;
} /* end if */
- fname_g = HDstrdup(argv[opt_ind]);
+ fname_g = HDstrdup(argv[H5_optind]);
done:
return (0);
diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c
index 516191c..a85ee4d 100644
--- a/tools/src/misc/h5mkgrp.c
+++ b/tools/src/misc/h5mkgrp.c
@@ -22,8 +22,8 @@
int d_status = EXIT_SUCCESS;
/* command-line options: short and long-named parameters */
-static const char * s_opts = "hlpvV";
-static struct long_options l_opts[] = {
+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'}, {"vol-value", require_arg, '1'},
{"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, {NULL, 0, '\0'}};
@@ -140,7 +140,7 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options)
HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t));
/* Parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
/* Display 'help' */
case 'h':
@@ -171,18 +171,18 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options)
case '1':
vol_info.type = VOL_BY_VALUE;
- vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg);
+ vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
custom_fapl = TRUE;
break;
case '2':
vol_info.type = VOL_BY_NAME;
- vol_info.u.name = opt_arg;
+ vol_info.u.name = H5_optarg;
custom_fapl = TRUE;
break;
case '3':
- vol_info.info_string = opt_arg;
+ vol_info.info_string = H5_optarg;
break;
/* Bad command line argument */
@@ -193,33 +193,33 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options)
} /* end while */
/* Check for file name to be processed */
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
/* Retrieve file name */
- options->fname = HDstrdup(argv[opt_ind]);
- opt_ind++;
+ options->fname = HDstrdup(argv[H5_optind]);
+ H5_optind++;
/* Check for group(s) to be created */
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
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 - opt_ind);
+ options->ngroups = (size_t)(argc - H5_optind);
options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *));
/* Retrieve the group names */
curr_group = 0;
- while (opt_ind < argc) {
- options->groups[curr_group] = HDstrdup(argv[opt_ind]);
+ while (H5_optind < argc) {
+ options->groups[curr_group] = HDstrdup(argv[H5_optind]);
curr_group++;
- opt_ind++;
+ H5_optind++;
}
/* Setup a custom fapl for file accesses */