diff options
Diffstat (limited to 'src/H5PL.c')
-rw-r--r-- | src/H5PL.c | 83 |
1 files changed, 63 insertions, 20 deletions
@@ -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. |