summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack/h5repack_main.c
diff options
context:
space:
mode:
authorJordan Henderson <jhenderson@hdfgroup.org>2017-03-10 15:11:49 (GMT)
committerJordan Henderson <jhenderson@hdfgroup.org>2017-03-10 15:11:49 (GMT)
commitc3663d13d5becf8b3eaed18679f2349bd6ab971a (patch)
tree342f53c024764475c96e156c86ea515aa80f8bf0 /tools/src/h5repack/h5repack_main.c
parent281c24a5a91b16eaf498e5dd5af783773c228758 (diff)
parent56e5b4ed05fb3bad51c226ec5b567871a45e0bce (diff)
downloadhdf5-c3663d13d5becf8b3eaed18679f2349bd6ab971a.zip
hdf5-c3663d13d5becf8b3eaed18679f2349bd6ab971a.tar.gz
hdf5-c3663d13d5becf8b3eaed18679f2349bd6ab971a.tar.bz2
Merge pull request #2 in ~JHENDERSON/hdf5 from HDFFV/hdf5:develop to feature/parallel_filters
* commit '56e5b4ed05fb3bad51c226ec5b567871a45e0bce': (112 commits) updated AM_SILENT_RULES syntax Added a check for AM_SILENT_RULES before enabling it. Fix alignment Fix vds tests Correct result code for strings test Add extension to filename HDFFV-10128 fix string compare and add tests Description: Only format changes: mostly tabs vs. spaces Platforms tested: Linux/64 (jelly) - very minor Lowercase math and set CMake commands Added "flush" and "refresh" to testflushrefresh.sh error output so it's easier to see where errors in the script occur. Misc. small cleanups to sync against incoming page buffering changes. Update CMake formatting Update CMake files and formatting Normalize against incoming page buffering changes. HDFFV-10120 verify nozlib checking with tools tests cmake non-code typo Correct issues from pull request reviews. Corrected version of 4b5e05c084f93c35dae946c2c9e814d565a613b0: Fix some more signed -> unsigned value issues with cache data structures, also misc. style cleanups. All to align w/incoming page_buffering changes. Revert "Fix some more signed -> unsigned value issues with cache data structures, also" Added virtual to list ...
Diffstat (limited to 'tools/src/h5repack/h5repack_main.c')
-rw-r--r--tools/src/h5repack/h5repack_main.c425
1 files changed, 208 insertions, 217 deletions
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 657e1a9..1807056 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -52,8 +52,8 @@ static struct long_options l_opts[] = {
{ "metadata_block_size", require_arg, 'M' },
{ "threshold", require_arg, 't' },
{ "alignment", require_arg, 'a' },
- { "infile", require_arg, 'i' }, /* -i for backward compability */
- { "outfile", require_arg, 'o' }, /* -o for backward compability */
+ { "infile", require_arg, 'i' }, /* -i for backward compability */
+ { "outfile", require_arg, 'o' }, /* -o for backward compability */
{ "fs_strategy", require_arg, 'S' },
{ "fs_threshold", require_arg, 'T' },
{ "enable-error-stack", no_arg, 'E' },
@@ -208,14 +208,12 @@ static void usage(const char *prog) {
* Programmer: Quincey Koziol
* Saturday, 31. January 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static void leave(int ret) {
- h5tools_close();
-
- HDexit(ret);
+static void leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
}
/*-------------------------------------------------------------------------
@@ -231,11 +229,10 @@ static void leave(int ret) {
*
*-------------------------------------------------------------------------
*/
-
static
-int read_info(const char *filename, pack_opt_t *options) {
-
- char stype[10];
+int read_info(const char *filename, pack_opt_t *options)
+{
+ char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char comp_info[1024];
FILE *fp = NULL;
char c;
@@ -368,210 +365,204 @@ done:
*
*-------------------------------------------------------------------------
*/
-
static
-int parse_command_line(int argc, const char **argv, pack_opt_t* options) {
-
- int opt;
- int ret_value = 0;
-
- /* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch ((char) opt) {
-
- /* -i for backward compability */
- case 'i':
- infile = opt_arg;
- has_i_o = 1;
- break;
-
- /* -o for backward compability */
- case 'o':
- outfile = opt_arg;
- has_i_o = 1;
- break;
-
- case 'h':
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
- goto done;
-
- case 'V':
- print_version(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
- goto done;
-
- case 'v':
- options->verbose = 1;
- break;
-
- case 'f':
- /* parse the -f filter option */
- if (h5repack_addfilter(opt_arg, options) < 0) {
- error_msg("in parsing filter\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- break;
-
- case 'l':
- /* parse the -l layout option */
- if (h5repack_addlayout(opt_arg, options) < 0) {
- error_msg("in parsing layout\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- break;
-
- case 'm':
- options->min_comp = HDstrtoull(opt_arg , NULL, 0);
- if ((int) options->min_comp <= 0) {
- error_msg("invalid minimum compress size <%s>\n", opt_arg);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- break;
-
- case 'e':
- ret_value = read_info(opt_arg, options);
- if (ret_value < 0)
- goto done;
- break;
-
- case 'n':
- options->use_native = 1;
- break;
-
- case 'L':
- options->latest = TRUE;
- break;
-
- case 'c':
- 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( opt_arg );
- if (options->grp_indexed > 0)
- options->latest = TRUE; /* must use latest format */
- break;
-
- case 's':
- {
- int idx = 0;
- int ssize = 0;
- char *msgPtr = HDstrchr( opt_arg, ':');
- options->latest = TRUE; /* must use latest format */
- if (msgPtr == NULL) {
- ssize = HDatoi( opt_arg );
- for (idx = 0; idx < 5; idx++)
- options->msg_size[idx] = ssize;
- }
- else {
- char msgType[10];
- HDstrcpy(msgType, msgPtr + 1);
- msgPtr[0] = '\0';
- ssize = HDatoi( opt_arg );
- if (HDstrncmp(msgType, "dspace",6) == 0) {
- options->msg_size[0] = ssize;
- }
- else if (HDstrncmp(msgType, "dtype", 5) == 0) {
- options->msg_size[1] = ssize;
- }
- else if (HDstrncmp(msgType, "fill", 4) == 0) {
- options->msg_size[2] = ssize;
- }
- else if (HDstrncmp(msgType, "pline", 5) == 0) {
- options->msg_size[3] = ssize;
- }
- else if (HDstrncmp(msgType, "attr", 4) == 0) {
- options->msg_size[4] = ssize;
- }
- }
- }
- break;
-
- case 'u':
- options->ublock_filename = opt_arg;
- break;
-
- case 'b':
- options->ublock_size = (hsize_t) HDatol( opt_arg );
- break;
-
- case 'M':
- options->meta_block_size = (hsize_t) HDatol( opt_arg );
- break;
-
- case 't':
- options->threshold = (hsize_t) HDatol( opt_arg );
- break;
-
- case 'a':
- options->alignment = HDstrtoull(opt_arg , NULL, 0);
- if (options->alignment < 1) {
- error_msg("invalid alignment size\n", opt_arg);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- break;
-
- case 'S':
- {
- char strategy[MAX_NC_NAME];
-
- HDstrcpy(strategy, opt_arg);
- if (!HDstrcmp(strategy, "ALL_PERSIST"))
- options->fs_strategy = H5F_FILE_SPACE_ALL_PERSIST;
- else if (!HDstrcmp(strategy, "ALL"))
- options->fs_strategy = H5F_FILE_SPACE_ALL;
- else if (!HDstrcmp(strategy, "AGGR_VFD"))
- options->fs_strategy = H5F_FILE_SPACE_AGGR_VFD;
- else if (!HDstrcmp(strategy, "VFD"))
- options->fs_strategy = H5F_FILE_SPACE_VFD;
- else {
- error_msg("invalid file space management strategy\n", opt_arg);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- }
- break;
-
- case 'T':
- options->fs_threshold = (hsize_t) HDatol( opt_arg );
- break;
-
- case 'E':
- enable_error_stack = TRUE;
- break;
+int parse_command_line(int argc, const char **argv, pack_opt_t* options)
+{
+ int opt;
+ int ret_value = 0;
+
+ /* parse command line options */
+ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char) opt) {
+
+ /* -i for backward compability */
+ case 'i':
+ infile = opt_arg;
+ has_i_o = 1;
+ break;
+
+ /* -o for backward compability */
+ case 'o':
+ outfile = opt_arg;
+ has_i_o = 1;
+ break;
+
+ case 'h':
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ ret_value = -1;
+ goto done;
- default:
- break;
- } /* switch */
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ ret_value = -1;
+ goto done;
+
+ case 'v':
+ options->verbose = 1;
+ break;
+ case 'f':
+ /* parse the -f filter option */
+ if (h5repack_addfilter(opt_arg, options) < 0) {
+ error_msg("in parsing filter\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'l':
+ /* parse the -l layout option */
+ if (h5repack_addlayout(opt_arg, options) < 0) {
+ error_msg("in parsing layout\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'm':
+ options->min_comp = HDstrtoull(opt_arg , NULL, 0);
+ if ((int) options->min_comp <= 0) {
+ error_msg("invalid minimum compress size <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'e':
+ ret_value = read_info(opt_arg, options);
+ if (ret_value < 0)
+ goto done;
+ break;
+
+ case 'n':
+ options->use_native = 1;
+ break;
+
+ case 'L':
+ options->latest = TRUE;
+ break;
+
+ case 'c':
+ 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( opt_arg );
+ if (options->grp_indexed > 0)
+ options->latest = TRUE; /* must use latest format */
+ break;
+
+ case 's':
+ {
+ int idx = 0;
+ int ssize = 0;
+ char *msgPtr = HDstrchr( opt_arg, ':');
+ options->latest = TRUE; /* must use latest format */
+ if (msgPtr == NULL) {
+ ssize = HDatoi( opt_arg );
+ for (idx = 0; idx < 5; idx++)
+ options->msg_size[idx] = ssize;
+ }
+ else {
+ char msgType[10];
+
+ HDstrcpy(msgType, msgPtr + 1);
+ msgPtr[0] = '\0';
+ ssize = HDatoi( opt_arg );
+ if (HDstrncmp(msgType, "dspace",6) == 0)
+ options->msg_size[0] = ssize;
+ else if (HDstrncmp(msgType, "dtype", 5) == 0)
+ options->msg_size[1] = ssize;
+ else if (HDstrncmp(msgType, "fill", 4) == 0)
+ options->msg_size[2] = ssize;
+ else if (HDstrncmp(msgType, "pline", 5) == 0)
+ options->msg_size[3] = ssize;
+ else if (HDstrncmp(msgType, "attr", 4) == 0)
+ options->msg_size[4] = ssize;
+ }
+ }
+ break;
+
+ case 'u':
+ options->ublock_filename = opt_arg;
+ break;
+
+ case 'b':
+ options->ublock_size = (hsize_t) HDatol( opt_arg );
+ break;
+
+ case 'M':
+ options->meta_block_size = (hsize_t) HDatol( opt_arg );
+ break;
+
+ case 't':
+ options->threshold = (hsize_t) HDatol( opt_arg );
+ break;
+
+ case 'a':
+ options->alignment = HDstrtoull(opt_arg , NULL, 0);
+ if (options->alignment < 1) {
+ error_msg("invalid alignment size\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ break;
+
+ case 'S':
+ {
+ char strategy[MAX_NC_NAME];
+
+ HDstrcpy(strategy, opt_arg);
+ if(!HDstrcmp(strategy, "ALL_PERSIST"))
+ options->fs_strategy = H5F_FILE_SPACE_ALL_PERSIST;
+ else if(!HDstrcmp(strategy, "ALL"))
+ options->fs_strategy = H5F_FILE_SPACE_ALL;
+ else if(!HDstrcmp(strategy, "AGGR_VFD"))
+ options->fs_strategy = H5F_FILE_SPACE_AGGR_VFD;
+ else if(!HDstrcmp(strategy, "VFD"))
+ options->fs_strategy = H5F_FILE_SPACE_VFD;
+ else {
+ error_msg("invalid file space management strategy\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+ }
+ break;
+
+ case 'T':
+ options->fs_threshold = (hsize_t) HDatol( opt_arg );
+ break;
+
+ case 'E':
+ enable_error_stack = TRUE;
+ break;
+
+ default:
+ break;
+ } /* switch */
} /* while */
if (has_i_o == 0) {
- /* check for file names to be processed */
- if (argc <= opt_ind || argv[opt_ind + 1] == NULL) {
- error_msg("missing file names\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
+ /* check for file names to be processed */
+ if (argc <= opt_ind || argv[opt_ind + 1] == NULL) {
+ error_msg("missing file names\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
done:
- return ret_value;
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -591,16 +582,16 @@ done:
*
*-------------------------------------------------------------------------
*/
-int main(int argc, const char **argv) {
+int main(int argc, const char **argv)
+{
+ pack_opt_t options; /*the global options */
H5E_auto2_t func;
H5E_auto2_t tools_func;
void *edata;
void *tools_edata;
- pack_opt_t options; /*the global options */
-
- h5tools_setprogname(PROGRAMNAME);
- h5tools_setstatus(EXIT_SUCCESS);
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
@@ -653,12 +644,12 @@ int main(int argc, const char **argv) {
}
/* pack it */
- h5tools_setstatus(h5repack(infile, outfile, &options));
+ h5tools_setstatus(h5repack(infile, outfile, &options));
done:
- /* free tables */
- h5repack_end(&options);
+ /* free tables */
+ h5repack_end(&options);
- leave(h5tools_getstatus());
+ leave(h5tools_getstatus());
}