From 5be5a4d83274bbfd4a82795cc14beb0209d18a36 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 5 Mar 2015 11:09:22 -0500 Subject: [svn-r26365] HDFFV-8520: Add plugin control APIs. Update windows WiX packaging. h5committested --- CMakeInstallation.cmake | 12 +++---- MANIFEST | 2 ++ src/CMakeLists.txt | 1 + src/H5PL.c | 83 ++++++++++++++++++++++++++++++++----------- src/H5PLextern.h | 12 ------- src/H5PLprivate.h | 15 ++------ src/Makefile.am | 2 +- src/Makefile.in | 2 +- src/hdf5.h | 3 +- test/plugin.c | 93 +++++++++++++++++++++++++++++++++++++++++++++---- 10 files changed, 165 insertions(+), 60 deletions(-) diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index f5c2dda..1df5311 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -363,6 +363,8 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set(CPACK_WIX_PROPERTY_ARPCOMMENTS "HDF5 (Hierarchical Data Format 5) Software Library and Utilities") set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "${HDF5_PACKAGE_URL}") set(CPACK_WIX_PROPERTY_ARPHELPLINK "${HDF5_PACKAGE_BUGREPORT}") + + set(CPACK_WIX_PATCH_FILE "${HDF_RESOURCES_DIR}/patch.xml") elseif (APPLE) list (APPEND CPACK_GENERATOR "DragNDrop") set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) @@ -455,14 +457,10 @@ The HDF5 data model, file format, API, library, and tools are open and distribut if (HDF5_PACKAGE_EXTLIBS) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;libraries;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;headers;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;configinstall;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;ALL;/") endif (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) if (SZIP_FOUND AND SZIP_USE_EXTERNAL) - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;libraries;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;headers;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;configinstall;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;ALL;/") endif (SZIP_FOUND AND SZIP_USE_EXTERNAL) endif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") endif (HDF5_PACKAGE_EXTLIBS) @@ -474,6 +472,8 @@ The HDF5 data model, file format, API, library, and tools are open and distribut cpack_add_component_group(Runtime) + cpack_add_component_group(Documents) + cpack_add_component_group(Development EXPANDED DESCRIPTION "All of the tools you'll need to develop HDF5 applications" diff --git a/MANIFEST b/MANIFEST index cd8133c..0d715d9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -847,6 +847,7 @@ ./src/H5Ptest.c ./src/H5PL.c ./src/H5PLprivate.h +./src/H5PLpublic.h ./src/H5PLextern.h ./src/H5R.c ./src/H5Rdeprec.c @@ -2400,6 +2401,7 @@ ./config/cmake/HDF5Macros.cmake ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/mccacheinit.cmake +./config/cmake/patch.xml ./config/cmake/PkgInfo.in ./config/cmake/README.txt.cmake.in ./config/cmake/userblockTest.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9e7195..999420c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -482,6 +482,7 @@ set (H5PL_SRCS set (H5PL_HDRS ${HDF5_SRC_DIR}/H5PLextern.h + ${HDF5_SRC_DIR}/H5PLpublic.h ) IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SRCS}" ) diff --git a/src/H5PL.c b/src/H5PL.c index 1806ea6..619dd84 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -97,6 +97,7 @@ typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); typedef const void *(*H5PL_get_plugin_info_t)(void); #endif /* H5_HAVE_WIN32_API */ +/* Whether to preload pathnames for plugin libraries */ #define H5PL_DEFAULT_PATH H5_DEFAULT_PLUGINDIR /* Special symbol to indicate no plugin loading */ @@ -149,8 +150,8 @@ static char *H5PL_path_table_g[H5PL_MAX_PATH_NUM]; static size_t H5PL_num_paths_g = 0; static hbool_t H5PL_path_found_g = FALSE; -/* Whether to preload pathnames for plugin libraries */ -static hbool_t H5PL_no_plugin_g = FALSE; +/* Enable all plugin libraries */ +static unsigned int H5PL_plugin_g = H5PL_ALL_PLUGIN; /*-------------------------------------------------------------------------- @@ -177,7 +178,7 @@ H5PL__init_interface(void) if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) { /* Special symbal "::" means no plugin during data reading. */ if(!HDstrcmp(preload_path, H5PL_NO_PLUGIN)) - H5PL_no_plugin_g = TRUE; + H5PL_plugin_g = 0; } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -185,31 +186,68 @@ H5PL__init_interface(void) /*------------------------------------------------------------------------- - * Function: H5PL_no_plugin + * Function: H5PLset_loading_state * - * Purpose: Quick way for filter module to query whether to load plugin + * Purpose: Control the loading of dynamic plugin types. * - * Return: TRUE: No plugin loading during data reading + * This function will not allow plugin types if the pathname from the HDF5_PLUGIN_PRELOAD + * environment variable is set to the special "::" string. * - * FALSE: Load plugin during data reading + * plugin bit = 0, will prevent the use of that dynamic plugin type. + * plugin bit = 1, will allow the use of that dynamic plugin type. * - * Programmer: Raymond Lu - * 20 February 2013 + * H5PL_TYPE_FILTER changes just dynamic filters + * A H5PL_ALL_PLUGIN will enable all dynamic plugin types + * A zero value will disable all dynamic plugin types + * + * Return: Non-negative or success * *------------------------------------------------------------------------- */ -htri_t -H5PL_no_plugin(void) +herr_t +H5PLset_loading_state(unsigned int plugin_type) { - htri_t ret_value; + char *preload_path; + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "Iu", plugin_type); + /* change the bit value of the requested plugin type(s) */ + H5PL_plugin_g = plugin_type; + /* check if special ENV variable is set and disable all plugin types */ + if(NULL != (preload_path = HDgetenv("HDF5_PLUGIN_PRELOAD"))) { + /* Special symbol "::" means no plugin during data reading. */ + if(!HDstrcmp(preload_path, H5PL_NO_PLUGIN)) + H5PL_plugin_g = 0; + } +done: + FUNC_LEAVE_API(ret_value) +} /* end H5PLset_loading_state() */ - FUNC_ENTER_NOAPI(FAIL) - ret_value = (htri_t)H5PL_no_plugin_g; +/*------------------------------------------------------------------------- + * Function: H5PLget_loading_state + * + * Purpose: Query state of the loading of dynamic plugin types. + * + * This function will return the state of the global flag. + * + * Return: Zero if all plugin types are disabled, negative if all + * plugin types are enabled, positive if one or more of the plugin types are enabled. + * + *------------------------------------------------------------------------- + */ +herr_t +H5PLget_loading_state(unsigned int* plugin_type) +{ + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) + + if(plugin_type) + *plugin_type = H5PL_plugin_g; + done: + FUNC_LEAVE_API(ret_value) +} /* end H5PLget_loading_state() */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5PL_no_plugin() */ /*------------------------------------------------------------------------- @@ -285,9 +323,14 @@ H5PL_load(H5PL_type_t type, int id) FUNC_ENTER_NOAPI(NULL) - /* Check for "no plugins" indicated" */ - if(H5PL_no_plugin_g) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin filter '%d' is not available", id) + switch (type) { + case H5PL_TYPE_FILTER: + if((H5PL_plugin_g & H5PL_FILTER_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin filter '%d' is not available", id) + break; + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin '%d' is not valid", id) + } /* Initialize the location paths for dynamic libraries, if they aren't * already set up. diff --git a/src/H5PLextern.h b/src/H5PLextern.h index 8ad19e7..3264435 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -22,18 +22,6 @@ /* Include HDF5 header */ #include "hdf5.h" -/*******************/ -/* Public Typedefs */ -/*******************/ - -/* Plugin type */ -typedef enum H5PL_type_t { - H5PL_TYPE_ERROR = -1, /*error */ - H5PL_TYPE_FILTER = 0, /*filter */ - H5PL_TYPE_NONE = 1 /*this must be last! */ -} H5PL_type_t; - - /* plugins always export */ #if defined (_MSC_VER) /* MSVC Compiler Case */ #define H5PLUGIN_DLL __declspec(dllexport) diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 587a51b..77e115b 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -19,18 +19,8 @@ #ifndef _H5PLprivate_H #define _H5PLprivate_H -/* Keep the following in sync with the package's "external" header */ - -/*******************/ -/* Public Typedefs */ -/*******************/ - -/* Plugin type */ -typedef enum H5PL_type_t { - H5PL_TYPE_ERROR = -1, /*error */ - H5PL_TYPE_FILTER = 0, /*filter */ - H5PL_TYPE_NONE = 1 /*this must be last! */ -} H5PL_type_t; +/* Include package's public header */ +#include "H5PLpublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ @@ -57,7 +47,6 @@ typedef enum H5PL_type_t { /* Internal API routines */ H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id); -H5_DLL htri_t H5PL_no_plugin(void); #endif /* _H5PLprivate_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 4b55144..2df095e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -119,7 +119,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5FDmulti.h H5FDsec2.h H5FDstdio.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h \ - H5PLextern.h \ + H5PLextern.h H5PLpublic.h \ H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h diff --git a/src/Makefile.in b/src/Makefile.in index 52f64f9..1776f27 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -822,7 +822,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5FDmulti.h H5FDsec2.h H5FDstdio.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h \ - H5PLextern.h \ + H5PLextern.h H5PLpublic.h \ H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h diff --git a/src/hdf5.h b/src/hdf5.h index a37329d..7a10507 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -33,7 +33,8 @@ #include "H5Lpublic.h" /* Links */ #include "H5MMpublic.h" /* Memory management */ #include "H5Opublic.h" /* Object headers */ -#include "H5Ppublic.h" /* Property lists */ +#include "H5Ppublic.h" /* Property lists */ +#include "H5PLpublic.h" /* Plugins */ #include "H5Rpublic.h" /* References */ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ diff --git a/test/plugin.c b/test/plugin.c index 86bc952..3707411 100644 --- a/test/plugin.c +++ b/test/plugin.c @@ -456,14 +456,14 @@ error: } /*------------------------------------------------------------------------- - * Function: test_read_with_filters + * Function: test_read_with_filters * - * Purpose: Tests reading dataset created with dynamically loaded filters + * Purpose: Tests reading dataset created with dynamically loaded filters * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 14 March 2013 * *------------------------------------------------------------------------- @@ -471,7 +471,7 @@ error: static herr_t test_read_with_filters(hid_t file) { - hid_t dset; /* Dataset ID */ + hid_t dset; /* Dataset ID */ /*---------------------------------------------------------- * STEP 1: Test deflation by itself. @@ -526,6 +526,76 @@ error: } /*------------------------------------------------------------------------- + * Function: test_noread_data + * + * Purpose: Tests not reading data + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_noread_data(hid_t dataset, int *origin_data) +{ + int check[DSET_DIM1][DSET_DIM2]; + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ + int *data_p = origin_data; + size_t i, j; /* Local index variables */ + + /* Read the dataset back */ + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) >= 0) + TEST_ERROR; + + PASSED(); + return 0; + +error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: test_noread_with_filters + * + * Purpose: Tests reading dataset created with dynamically loaded filters disabled + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_noread_with_filters(hid_t file) +{ + hid_t dset; /* Dataset ID */ + int plugin_state; /* status of plugins */ + TESTING("Testing DYNLIB1 filter with plugins disabled"); + + /* disable filter plugin */ + if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR + plugin_state = plugin_state & ~H5PL_FILTER_PLUGIN; + if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR + + if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR + + if(test_noread_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR + + if(H5Dclose(dset) < 0) TEST_ERROR + + /* re-enable filter plugin */ + plugin_state = plugin_state | H5PL_FILTER_PLUGIN; + if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR + + return 0; + +error: + /* re-enable filter plugin */ + plugin_state = plugin_state | H5PL_FILTER_PLUGIN; + if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR + return -1; +} + +/*------------------------------------------------------------------------- * Function: test_filters_for_groups * * Purpose: Tests creating group with dynamically loaded filters @@ -713,6 +783,17 @@ main(void) /* Open the groups with filters */ nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0); + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + fapl = h5_fileaccess(); + + /* Reopen the file for testing data reading */ + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + + /* Read the data with disabled filters */ + nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0); + if(H5Fclose(file) < 0) TEST_ERROR -- cgit v0.12