diff options
Diffstat (limited to 'tools/src')
-rw-r--r-- | tools/src/h5repack/h5repack.c | 36 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_copy.c | 24 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_main.c | 323 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_verify.c | 9 |
4 files changed, 185 insertions, 207 deletions
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index ef2085c..c79db1c 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -77,27 +77,29 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { * *------------------------------------------------------------------------- */ -int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest, - H5F_file_space_type_t strategy, hsize_t threshold) { - int k, n; - - HDmemset(options, 0, sizeof(pack_opt_t)); - options->min_comp = 0; - options->verbose = verbose; - options->latest = latest; - options->layout_g = H5D_LAYOUT_ERROR; - - for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { - options->filter_g[n].filtn = -1; - options->filter_g[n].cd_nelmts = 0; - for (k = 0; k < CD_VALUES; k++) - options->filter_g[n].cd_values[k] = 0; - } +int +h5repack_init(pack_opt_t *options, int verbose, hbool_t latest, + H5F_file_space_type_t strategy, hsize_t threshold) +{ + int k, n; + + HDmemset(options, 0, sizeof(pack_opt_t)); + options->min_comp = 0; + options->verbose = verbose; + options->latest = latest; + options->layout_g = H5D_LAYOUT_ERROR; + + for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { + options->filter_g[n].filtn = -1; + options->filter_g[n].cd_nelmts = 0; + for (k = 0; k < CD_VALUES; k++) + options->filter_g[n].cd_values[k] = 0; + } options->fs_strategy = strategy; options->fs_threshold = threshold; - return (options_table_init(&(options->op_tbl))); + return (options_table_init(&(options->op_tbl))); } /*------------------------------------------------------------------------- diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 547f61a..1519053 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -84,28 +84,18 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t * * Date: October, 23, 2003 * - * Modification: - * Peter Cao, June 13, 2007 - * Add "-L, --latest" and other options to pack a file with the latest file format - * - * Peter Cao, September 25, 2007 - * Copy user block when repacking a file - * - * Pedro Vicente, August 20, 2008 - * Add a user block to file if requested - * *------------------------------------------------------------------------- */ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fidin; - hid_t fidout = -1; - trav_table_t *travt = NULL; - hsize_t ub_size = 0; /* size of user block */ - hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ - hid_t fapl = H5P_DEFAULT; /* file access property list ID */ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t fidin; + hid_t fidout = -1; + trav_table_t *travt = NULL; + hsize_t ub_size = 0; /* size of user block */ + hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ + hid_t fapl = H5P_DEFAULT; /* file access property list ID */ /*------------------------------------------------------------------------- * open input file diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 50ff83f..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,13 +208,11 @@ static void usage(const char *prog) { * Programmer: Quincey Koziol * Saturday, 31. January 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ -static void leave(int ret) { +static void leave(int ret) +{ h5tools_close(); - HDexit(ret); } @@ -231,10 +229,9 @@ static void leave(int ret) { * *------------------------------------------------------------------------- */ - static -int read_info(const char *filename, pack_opt_t *options) { - +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; @@ -368,10 +365,9 @@ done: * *------------------------------------------------------------------------- */ - static -int parse_command_line(int argc, const char **argv, pack_opt_t* options) { - +int parse_command_line(int argc, const char **argv, pack_opt_t* options) +{ int opt; int ret_value = 0; @@ -379,185 +375,180 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* 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; + /* -i for backward compability */ + case 'i': + infile = opt_arg; + has_i_o = 1; + break; - case 'v': - options->verbose = 1; - break; + /* -o for backward compability */ + case 'o': + outfile = opt_arg; + has_i_o = 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); + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); 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); + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); ret_value = -1; goto done; - } - break; - case 'e': - ret_value = read_info(opt_arg, options); - if (ret_value < 0) - goto done; - break; + case 'v': + options->verbose = 1; + 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 '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 'd': - options->grp_indexed = HDatoi( opt_arg ); - if (options->grp_indexed > 0) - options->latest = TRUE; /* must use latest format */ - 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 '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; + 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; } - 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; + 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 if (HDstrncmp(msgType, "attr", 4) == 0) { - options->msg_size[4] = 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; + break; - case 'b': - options->ublock_size = (hsize_t) HDatol( opt_arg ); - break; + case 'u': + options->ublock_filename = opt_arg; + break; - case 'M': - options->meta_block_size = (hsize_t) HDatol( opt_arg ); - break; + case 'b': + options->ublock_size = (hsize_t) HDatol( opt_arg ); + break; - case 't': - options->threshold = (hsize_t) HDatol( opt_arg ); - break; + case 'M': + options->meta_block_size = (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 't': + options->threshold = (hsize_t) HDatol( opt_arg ); + 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); + 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; + 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 'T': + options->fs_threshold = (hsize_t) HDatol( opt_arg ); + break; - case 'E': - enable_error_stack = TRUE; - break; + case 'E': + enable_error_stack = TRUE; + break; - default: - break; + default: + break; } /* switch */ - } /* while */ if (has_i_o == 0) { @@ -591,14 +582,14 @@ 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); diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index 6765c49..58dea03 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -39,11 +39,6 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil * Programmer: Pedro Vicente, pvn@hdfgroup.org * * Date: December 19, 2003 - * Modified: December, 19, 2007 (exactly 4 years later :-) ) - * Separate into 3 cases - * 1) no filter input, get all datasets and compare DCPLs. TO DO - * 2) filter input on selected datasets, get each one trough OBJ and match - * 3) filter input on all datasets, get all objects and match * *------------------------------------------------------------------------- */ @@ -51,8 +46,8 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fidin = -1; /* file ID for input file*/ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t fidin = -1; /* file ID for input file*/ hid_t fidout = -1; /* file ID for output file*/ hid_t did = -1; /* dataset ID */ hid_t pid = -1; /* dataset creation property list ID */ |