diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2014-06-17 22:26:28 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2014-06-17 22:26:28 (GMT) |
commit | 99ceb100fe1d24ccd7a01b8b3139aa5efadab4b1 (patch) | |
tree | 66effb31440590b0a2144c6466ca45dad7842aae /tools | |
parent | 611d2c89afa02204e6321849d24aed26878097f0 (diff) | |
download | hdf5-99ceb100fe1d24ccd7a01b8b3139aa5efadab4b1.zip hdf5-99ceb100fe1d24ccd7a01b8b3139aa5efadab4b1.tar.gz hdf5-99ceb100fe1d24ccd7a01b8b3139aa5efadab4b1.tar.bz2 |
[svn-r25309] Bring revisions #24783 - #24851 from trunk to revise_chunks.
Tested on jam, koala, ostrich, platypus.
Diffstat (limited to 'tools')
27 files changed, 208 insertions, 168 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 0dfe7c9..27820ae 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS) #----------------------------------------------------------------------------- @@ -15,32 +15,32 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib) # If testing was NOT enabled, then we need to build the tools library # -------------------------------------------------------------------- if (NOT BUILD_TESTING) - ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/lib) + add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/lib) endif (NOT BUILD_TESTING) #-- Add the h5diff and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5diff) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5diff) #-- Add the h5ls executable -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5ls) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5ls) #-- Misc Executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/misc) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/misc) #-- Add the h5import and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5import) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5import) #-- h5Repack executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5repack) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5repack) #-- Add the h5dump and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5jam) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5jam) #-- Add the h5copy and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5copy) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5copy) #-- Add the h5stat and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5stat) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5stat) #-- Add the h5dump and test executables -ADD_SUBDIRECTORY (${HDF5_TOOLS_SOURCE_DIR}/h5dump) +add_subdirectory (${HDF5_TOOLS_SOURCE_DIR}/h5dump) diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index 66cbae6..e5a1a9f 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5COPY) #----------------------------------------------------------------------------- diff --git a/tools/h5copy/CMakeTests.cmake b/tools/h5copy/CMakeTests.cmake index 34976fe..77399a8 100644 --- a/tools/h5copy/CMakeTests.cmake +++ b/tools/h5copy/CMakeTests.cmake @@ -19,7 +19,7 @@ ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.out ) - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") foreach (listfiles ${LIST_HDF5_TEST_FILES} ${LIST_OTHER_TEST_FILES}) GET_FILENAME_COMPONENT(fname "${listfiles}" NAME) diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index f660c12..5620968 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5DIFF) #----------------------------------------------------------------------------- diff --git a/tools/h5diff/CMakeTests.cmake b/tools/h5diff/CMakeTests.cmake index 8bae2ca..19a5fe4 100644 --- a/tools/h5diff/CMakeTests.cmake +++ b/tools/h5diff/CMakeTests.cmake @@ -234,7 +234,7 @@ ) # Make testfiles dir under build dir - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") # # copy test files from source to build dir diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 387c4bf..1a46586 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5DUMP) #----------------------------------------------------------------------------- diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake index 433faa3..bb2a37e 100644 --- a/tools/h5dump/CMakeTests.cmake +++ b/tools/h5dump/CMakeTests.cmake @@ -307,7 +307,7 @@ ) # make test dir - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") # # copy test files from source dir to test dir @@ -326,8 +326,8 @@ foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) if (WIN32 AND NOT CYGWIN) - FILE (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} TEST_STREAM) - FILE (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") + file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} TEST_STREAM) + file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") else (WIN32 AND NOT CYGWIN) add_custom_command ( TARGET h5dump @@ -373,8 +373,8 @@ ) if (WIN32 AND NOT CYGWIN) - FILE (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp TEST_STREAM) - FILE (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") + file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp TEST_STREAM) + file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") else (WIN32 AND NOT CYGWIN) add_custom_command ( TARGET h5dump diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 32dff55..36a3a9e 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5IMPORT) #----------------------------------------------------------------------------- diff --git a/tools/h5import/CMakeTests.cmake b/tools/h5import/CMakeTests.cmake index 2adbdde..5c5b4de 100644 --- a/tools/h5import/CMakeTests.cmake +++ b/tools/h5import/CMakeTests.cmake @@ -61,7 +61,7 @@ textpfe.h5 ) - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") foreach (conf_file ${HDF5_REFERENCE_CONF_FILES}) set (dest "${PROJECT_BINARY_DIR}/testfiles/${conf_file}") #message (STATUS " Copying ${conf_file}") diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index a10ef24..74c67b9 100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -863,11 +863,11 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) hid_t handle; hsize_t dims[1]; char str[1024]; - char c; + int c; int i = 0; int j; - int nlines = 0; - int line; + hsize_t nlines = 0; + hsize_t line; /*------------------------------------------------------------------------- * get number of lines in the input file @@ -877,9 +877,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) while (!HDfeof(strm)) { c = HDfgetc(strm); - if (c == 10) { /* eol */ + if (c == 10) /* eol */ nlines++; - } } if (!nlines) @@ -944,7 +943,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) while (!HDfeof(strm)) { c = HDfgetc(strm); - str[i] = c; + str[i] = (char)c; i++; @@ -1012,7 +1011,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) char *str3 = NULL; char str[1024] = ""; int j; - int line; + hsize_t line; /*------------------------------------------------------------------------- * read file and generate an HDF5 dataset @@ -1079,7 +1078,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) str2 = NULL; str3 = NULL; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING[%d]={%s}\n", line, str1); + printf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1); #endif /* process string to remove the first and last quote char */ str2 = strchr(str1, '"'); @@ -1108,7 +1107,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) hsize_t count[1] = { 1 }; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING[%d] store %s\n", line, str2); + printf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2); #endif if ((fspace_id = H5Dget_space(dset_id)) < 0) goto out; diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt index b12544f..b0d5ac8 100644 --- a/tools/h5jam/CMakeLists.txt +++ b/tools/h5jam/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5JAM) #----------------------------------------------------------------------------- diff --git a/tools/h5jam/CMakeTests.cmake b/tools/h5jam/CMakeTests.cmake index 4b71d7f..fb64313 100644 --- a/tools/h5jam/CMakeTests.cmake +++ b/tools/h5jam/CMakeTests.cmake @@ -20,7 +20,7 @@ twithub513.h5 ) - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) set (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_file}") #message (STATUS " Copying ${h5_file}") diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index 3aff2b4..776eaeb 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -26,9 +26,6 @@ void parse_command_line (int argc, const char *argv[]); -#define TRUE 1 -#define FALSE 0 - /* Name of tool */ #define PROGRAMNAME "getub" char *nbytes = NULL; @@ -79,21 +76,21 @@ usage (const char *prog) void parse_command_line (int argc, const char *argv[]) { - int opt = FALSE; + int opt; /* parse command line options */ while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { switch ((char) opt) - { - case 'c': - nbytes = HDstrdup (opt_arg); - break; - case '?': - default: - usage (h5tools_getprogname()); - exit (EXIT_FAILURE); - } + { + case 'c': + nbytes = HDstrdup (opt_arg); + break; + case '?': + default: + usage (h5tools_getprogname()); + exit (EXIT_FAILURE); + } } if (argc <= opt_ind) diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c index ca3d86c..9636597 100644 --- a/tools/h5jam/h5jamgentest.c +++ b/tools/h5jam/h5jamgentest.c @@ -28,7 +28,9 @@ #include "hdf5.h" #include "H5private.h" +/* not used yet #define UBTXT1 "u0.txt" +*/ #define UBTXT2 "u10.txt" #define UBTXT3 "u511.txt" #define UBTXT4 "u512.txt" @@ -69,24 +71,7 @@ char pattern[11] = "abcdefghij"; #define BUF_SIZE 1024 -#define LENSTR 50 -#define LENSTR2 11 - -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 - -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 - -#define DIM1 20 -#define DIM2 10 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 -#define RANK 2 - /* Element selection information */ -#define POINT1_NPOINTS 10 typedef enum{ RED, @@ -106,22 +91,10 @@ typedef struct s1_t { /* 1-D array datatype */ #define ARRAY1_RANK 1 -#define ARRAY1_DIM1 4 - -/* 3-D array datatype */ -#define ARRAY2_RANK 3 -#define ARRAY2_DIM1 3 -#define ARRAY2_DIM2 4 -#define ARRAY2_DIM3 5 /* 2-D array datatype */ -#define ARRAY3_RANK 2 -#define ARRAY3_DIM1 6 #define ARRAY3_DIM2 3 -/* VL string datatype name */ -#define VLSTR_TYPE "vl_string_type" - /* A UD link traversal function. Shouldn't actually be called. */ static hid_t UD_traverse(const char UNUSED * link_name, hid_t UNUSED cur_group, const void UNUSED * udata, size_t UNUSED udata_size, hid_t UNUSED lapl_id) diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c index 0169d71..b4f87af 100644 --- a/tools/h5jam/tellub.c +++ b/tools/h5jam/tellub.c @@ -24,9 +24,6 @@ #include "h5tools.h" #include "h5tools_utils.h" -#define TRUE 1 -#define FALSE 0 - /* Name of tool */ #define PROGRAMNAME "tellub" @@ -85,21 +82,21 @@ usage (const char *prog) static void parse_command_line (int argc, const char *argv[]) { - int opt = FALSE; + int opt; /* parse command line options */ while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { switch ((char) opt) - { - case 'h': - usage (h5tools_getprogname()); - exit (EXIT_SUCCESS); - case '?': - default: - usage (h5tools_getprogname()); - exit (EXIT_FAILURE); - } + { + case 'h': + usage (h5tools_getprogname()); + exit (EXIT_SUCCESS); + case '?': + default: + usage (h5tools_getprogname()); + exit (EXIT_FAILURE); + } } /* check for file name to be processed */ diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index b351268..5220087 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5LS) #----------------------------------------------------------------------------- diff --git a/tools/h5ls/CMakeTests.cmake b/tools/h5ls/CMakeTests.cmake index eb68d79..b739130 100644 --- a/tools/h5ls/CMakeTests.cmake +++ b/tools/h5ls/CMakeTests.cmake @@ -92,7 +92,7 @@ ${HDF5_TOOLS_SRC_DIR}/testfiles/tvldtypes2be.ls ) - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") # copy the list of test files foreach (listfiles ${LIST_HDF5_TEST_FILES} ${LIST_OTHER_TEST_FILES}) diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 4625607..4d26c0c 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5REPACK) #----------------------------------------------------------------------------- @@ -54,7 +54,7 @@ if (BUILD_TESTING) add_definitions (${HDF5_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SRC_DIR}/dynlib1.c) + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${LIB_TYPE} dynlib_rpk.c) TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} " " " ") target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) H5_SET_LIB_OPTIONS ( @@ -65,7 +65,7 @@ if (BUILD_TESTING) ) # make plugins dir - FILE (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") #----------------------------------------------------------------------------- # Copy plugin library to a plugins folder #----------------------------------------------------------------------------- diff --git a/tools/h5repack/dynlib_rpk.c b/tools/h5repack/dynlib_rpk.c new file mode 100644 index 0000000..1ccc33a --- /dev/null +++ b/tools/h5repack/dynlib_rpk.c @@ -0,0 +1,97 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Programmer: Raymond Lu + * 13 February 2013 + * + * Purpose: Tests the plugin module (H5PL) + */ + +#include <stdlib.h> +#include <stdio.h> +#include "H5PLextern.h" + +#define H5Z_FILTER_DYNLIB1 257 + +static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_DYNLIB1[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIB1, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} + +/*------------------------------------------------------------------------- + * Function: H5Z_filter_dynlib1 + * + * Purpose: A dynlib1 filter method that adds on and subtract from + * the original value with another value. It will be built + * as a shared library. plugin.c test will load and use + * this filter library. + * + * Return: Success: Data chunk size + * + * Failure: 0 + * + * Programmer: Raymond Lu + * 29 March 2013 + * + *------------------------------------------------------------------------- + */ +static size_t +H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int add_on = 0; + + /* Check for the correct number of parameters */ + if(cd_nelmts == 0) + return(0); + + /* Check that permanent parameters are set correctly */ + if(cd_values[0] > 9) + return(0); + + add_on = (int)cd_values[0]; + + if(flags & H5Z_FLAG_REVERSE) { /*read*/ + /* Substract the "add on" value to all the data values */ + while(buf_left > 0) { + *int_ptr++ -= add_on; + buf_left -= sizeof(int); + } /* end while */ + } /* end if */ + else { /*write*/ + /* Add the "add on" value to all the data values */ + while(buf_left > 0) { + *int_ptr++ += add_on; + buf_left -= sizeof(int); + } /* end while */ + } /* end else */ + + return nbytes; +} /* end H5Z_filter_dynlib1() */ + diff --git a/tools/h5stat/CMakeLists.txt b/tools/h5stat/CMakeLists.txt index d182a45..82f0ffb 100644 --- a/tools/h5stat/CMakeLists.txt +++ b/tools/h5stat/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_H5STAT) #----------------------------------------------------------------------------- diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index 5569b6f..83df182 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_LIB) #----------------------------------------------------------------------------- diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index ab21bfd..884a85d 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1096,7 +1096,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, char * grp2_path = ""; char * obj1_fullpath = NULL; char * obj2_fullpath = NULL; - h5trav_type_t objtype; diff_args_t argdata; size_t idx1 = 0; size_t idx2 = 0; @@ -1163,7 +1162,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, { if( table->objs[i].flags[0] && table->objs[i].flags[1]) { - objtype = table->objs[i].type; /* make full path for obj1 */ obj1_fullpath = (char*)HDcalloc (HDstrlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char)); HDstrcpy(obj1_fullpath, grp1_path); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index fca3096..d0a4a76 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -21,13 +21,15 @@ * local typedefs *------------------------------------------------------------------------- */ +typedef struct trav_addr_path_t { + haddr_t addr; + char *path; +} trav_addr_path_t; + typedef struct trav_addr_t { size_t nalloc; size_t nused; - struct { - haddr_t addr; - char *path; - } *objs; + trav_addr_path_t *objs; } trav_addr_t; typedef struct { @@ -132,7 +134,7 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path) /* Allocate space if necessary */ if(visited->nused == visited->nalloc) { visited->nalloc = MAX(1, visited->nalloc * 2);; - visited->objs = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0])); + visited->objs = (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t)); } /* end if */ /* Append it */ @@ -194,14 +196,15 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, /* Create the full path name for the link */ if(udata->is_absolute) { size_t base_len = HDstrlen(udata->base_grp_name); - size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1; + size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1; + size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1; - if(NULL == (new_name = (char*)HDmalloc(base_len + add_slash + HDstrlen(path) + 1))) + if(NULL == (new_name = (char*)HDmalloc(new_name_len))) return(H5_ITER_ERROR); - HDstrcpy(new_name, udata->base_grp_name); - if (add_slash) - new_name[base_len] = '/'; - HDstrcpy(new_name + base_len + add_slash, path); + if(add_slash) + HDsnprintf(new_name, new_name_len, "%s/%s", udata->base_grp_name, path); + else + HDsnprintf(new_name, new_name_len, "%s%s", udata->base_grp_name, path); full_name = new_name; } /* end if */ else @@ -216,7 +219,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, if(new_name) HDfree(new_name); return(H5_ITER_ERROR); - } + } /* end if */ /* If the object has multiple links, add it to the list of addresses * already visited, if it isn't there already @@ -231,7 +234,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, if(new_name) HDfree(new_name); return(H5_ITER_ERROR); - } + } /* end if */ } /* end if */ else { /* Make 'visit link' callback */ @@ -240,7 +243,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, if(new_name) HDfree(new_name); return(H5_ITER_ERROR); - } + } /* end if */ } /* end else */ if(new_name) @@ -730,7 +733,7 @@ trav_table_add(trav_table_t *table, if(table->nobjs == table->size) { table->size = MAX(1, table->size * 2); - table->objs = (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); + table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); } /* end if */ new_obj = table->nobjs++; @@ -774,7 +777,7 @@ trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path) /* allocate space if necessary */ if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) { table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2); - table->objs[i].links = (trav_link_t*)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); + table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); } /* end if */ /* insert it */ @@ -1168,31 +1171,21 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, * * Date: September 5, 2008 * - * Modified: - * Jonathan Kim - * - Moved from h5ls.c to share among tools. (Sep 16, 2010) - * - Renamed from elink_trav_add to symlink_visit_add for both soft and - * external links. (May 25, 2010) - * - Add type parameter to distingush between soft and external link for - * sure, which prevent from mixing up visited link when the target names - * are same between the soft and external link, as code marks with the - * target name. (May 25,2010) - * *------------------------------------------------------------------------- */ herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path) { size_t idx; /* Index of address to use */ - void *tmp_ptr; /* Allocate space if necessary */ - if(visited->nused == visited->nalloc) - { + if(visited->nused == visited->nalloc) { + void *tmp_ptr; + visited->nalloc = MAX(1, visited->nalloc * 2); - if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0])))) + if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t)))) return -1; - visited->objs = tmp_ptr; + visited->objs = (symlink_trav_path_t *)tmp_ptr; } /* end if */ /* Append it */ @@ -1202,22 +1195,19 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co visited->objs[idx].file = NULL; visited->objs[idx].path = NULL; - if (type == H5L_TYPE_EXTERNAL) - { - if(NULL == (visited->objs[idx].file = HDstrdup(file))) - { + if(type == H5L_TYPE_EXTERNAL) { + if(NULL == (visited->objs[idx].file = HDstrdup(file))) { visited->nused--; return -1; - } - } + } /* end if */ + } /* end if */ - if(NULL == (visited->objs[idx].path = HDstrdup(path))) - { + if(NULL == (visited->objs[idx].path = HDstrdup(path))) { visited->nused--; - if (visited->objs[idx].file) + if(visited->objs[idx].file) HDfree (visited->objs[idx].file); return -1; - } + } /* end if */ return 0; } /* end symlink_visit_add() */ @@ -1235,16 +1225,6 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co * * Date: September 5, 2008 * - * Modified: - * Jonathan Kim - * - Moved from h5ls.c to share among tools. (Sep 16, 2010) - * - Renamed from elink_trav_visited to symlink_is_visited for both soft and - * external links. (May 25, 2010) - * - Add type parameter to distingush between soft and external link for - * sure, which prevent from mixing up visited link when the target names - * are same between the soft and external link, as code marks with the - * target name. (May 25,2010) - * *------------------------------------------------------------------------- */ hbool_t @@ -1253,21 +1233,19 @@ symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, c size_t u; /* Local index variable */ /* Look for symlink */ - for(u = 0; u < visited->nused; u++) - { + for(u = 0; u < visited->nused; u++) { /* Check for symlink values already in array */ /* check type and path pair to distingush between symbolic links */ - if ((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) - { + if((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) { /* if external link, file need to be matched as well */ - if (visited->objs[u].type == H5L_TYPE_EXTERNAL) - { - if (!HDstrcmp(visited->objs[u].file, file)) - return (TRUE); - } + if(visited->objs[u].type == H5L_TYPE_EXTERNAL) + if(!HDstrcmp(visited->objs[u].file, file)) + return(TRUE); + return (TRUE); - } - } + } /* end if */ + } /* end for */ + /* Didn't find symlink */ return(FALSE); } /* end symlink_is_visited() */ diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 3548c6b..352a9e5 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -51,14 +51,16 @@ typedef enum { /* Struct to keep track of symbolic link targets visited. * Functions: symlink_visit_add() and symlink_is_visited() */ +typedef struct symlink_trav_path_t { + H5L_type_t type; + char *file; + char *path; +} symlink_trav_path_t; + typedef struct symlink_trav_t { size_t nalloc; size_t nused; - struct { - H5L_type_t type; - char *file; - char *path; - } *objs; + symlink_trav_path_t *objs; hbool_t dangle_link; } symlink_trav_t; diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt index 833e7e5..ed8c315 100644 --- a/tools/misc/CMakeLists.txt +++ b/tools/misc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.10) +cmake_minimum_required (VERSION 2.8.11) PROJECT (HDF5_TOOLS_MISC) #----------------------------------------------------------------------------- diff --git a/tools/misc/CMakeTests.cmake b/tools/misc/CMakeTests.cmake index a935c2b..468ff3a 100644 --- a/tools/misc/CMakeTests.cmake +++ b/tools/misc/CMakeTests.cmake @@ -58,7 +58,7 @@ ) # make test dir - FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") foreach (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) set (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_mkgrp_file}") diff --git a/tools/misc/h5repart_gentest.c b/tools/misc/h5repart_gentest.c index 8420da5..f7d9a73 100644 --- a/tools/misc/h5repart_gentest.c +++ b/tools/misc/h5repart_gentest.c @@ -23,7 +23,6 @@ #include "hdf5.h" #include "H5private.h" -#define KB 1024 #define FAMILY_NUMBER 4 #define FAMILY_SIZE 1024 #define FILENAME "family_file%05d.h5" |