summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-03-19 04:22:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-03-19 04:22:34 (GMT)
commitaf9a3abb3dcb01e719abf8eba5fd588c20c89d5c (patch)
tree6aa572a2460bc06332c7abedac2af45668a97853
parentbeccb8a0fcb8a380c7cd140852a486885b8e38c0 (diff)
downloadhdf5-af9a3abb3dcb01e719abf8eba5fd588c20c89d5c.zip
hdf5-af9a3abb3dcb01e719abf8eba5fd588c20c89d5c.tar.gz
hdf5-af9a3abb3dcb01e719abf8eba5fd588c20c89d5c.tar.bz2
[svn-r23380] Description:
Review & cleanup code.
-rw-r--r--MANIFEST5
-rw-r--r--src/H5PL.c602
-rw-r--r--src/H5PLpkg.h127
-rw-r--r--src/H5PLprivate.h24
-rw-r--r--src/H5PLpublic.h3
-rw-r--r--src/H5Pocpl.c69
-rw-r--r--src/H5Pprivate.h2
-rw-r--r--src/H5Z.c55
-rw-r--r--src/H5private.h11
-rw-r--r--src/Makefile.am7
-rw-r--r--test/plugin.c5
-rw-r--r--test/test_plugin.sh.in4
12 files changed, 428 insertions, 486 deletions
diff --git a/MANIFEST b/MANIFEST
index f15fa29..e1ab635 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -850,9 +850,8 @@
./src/H5Pstrcpl.c
./src/H5Ptest.c
./src/H5PL.c
-./src/H5PLpkg.c
-./src/H5PLprivate.c
-./src/H5PLpublic.c
+./src/H5PLprivate.h
+./src/H5PLpublic.h
./src/H5R.c
./src/H5Rdeprec.c
./src/H5Rpkg.h
diff --git a/src/H5PL.c b/src/H5PL.c
index 4d18926..4d84f31 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -13,32 +13,127 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#define H5PL_PACKAGE /*suppress error about including H5PLpkg */
+/****************/
+/* Module Setup */
+/****************/
/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5PL_init_interface
+#define H5_INTERFACE_INIT_FUNC H5PL__init_interface
+
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
-#include "H5Dprivate.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
-#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Sprivate.h" /* Dataspace functions */
+#include "H5PLprivate.h" /* Plugin */
#include "H5Zprivate.h" /* Filter pipeline */
-#include "H5PLpkg.h" /* Plugin */
+
+
+/****************/
+/* Local Macros */
+/****************/
#define H5PL_DEFAULT_PATH "/usr:/usr/lib:/usr/local"
-#define H5PL_PATH_SEPERATOR ":"
+#define H5PL_PATH_SEPARATOR ":"
+#define H5PL_MAX_PATH_NUM 16
+
+/****************************/
+/* Macros for supporting
+ * both Windows and Unix */
+/****************************/
+
+/* Handle for dynamic library */
+#ifdef H5_HAVE_WIN32_API
+/* Handle for dynamic library */
+#define H5PL_HANDLE HINSTANCE
+
+/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
+#define H5PL_OPEN_DLIB(S) LoadLibraryEx(TEXT(S), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
+
+/* Get the address of a symbol in dynamic library */
+#define H5PL_GET_LIB_FUNC(H,N) GetProcAddress(H,N)
+
+/* Close dynamic library */
+#define H5PL_CLOSE_LIB(H) FreeLibrary(H)
+
+/* Clear error - nothing to do */
+#define H5PL_CLR_ERROR
+
+#else /* H5_HAVE_WIN32_API */
+/* Handle for dynamic library */
+#define H5PL_HANDLE void *
+
+/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
+#define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_NOW|RTLD_LAZY)
+
+/* Get the address of a symbol in dynamic library */
+#define H5PL_GET_LIB_FUNC(H,N) dlsym(H,N)
+
+/* Close dynamic library */
+#define H5PL_CLOSE_LIB(H) dlclose(H)
+
+/* Clear error */
+#define H5PL_CLR_ERROR dlerror()
+
+#endif /* H5_HAVE_WIN32_API */
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/* Type for the list of info for opened plugin libraries */
+typedef struct H5PL_table_t {
+ H5PL_type_t pl_type; /* plugin type */
+ int pl_id; /* ID for the plugin */
+ H5PL_HANDLE handle; /* plugin handle */
+} H5PL_table_t;
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+static herr_t H5PL__init_path_table(void);
+static htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, void **info);
+static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, void **pl_info);
+static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, void **info);
+static herr_t H5PL__close(H5PL_HANDLE handle);
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Table for opened plugin libraries */
+static size_t H5PL_table_alloc_g = 0;
+static size_t H5PL_table_used_g = 0;
+static H5PL_table_t *H5PL_table_g = NULL;
+
+/* Table of location paths for plugin libraries */
+static char *H5PL_path_table_g[H5PL_MAX_PATH_NUM];
+static size_t H5PL_num_paths_g = 0;
+static htri_t H5PL_path_found_g = FALSE;
+
/*--------------------------------------------------------------------------
NAME
- H5PL_init_interface -- Initialize interface-specific information
+ H5PL__init_interface -- Initialize interface-specific information
USAGE
- herr_t H5PL_init_interface()
-
+ herr_t H5PL__init_interface()
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -46,12 +141,12 @@ DESCRIPTION
--------------------------------------------------------------------------*/
static herr_t
-H5PL_init_interface(void)
+H5PL__init_interface(void)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5PL_init_interface() */
+} /* end H5PL__init_interface() */
/*-------------------------------------------------------------------------
@@ -69,36 +164,32 @@ H5PL_init_interface(void)
* Programmer: Raymond Lu
* 20 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
H5PL_term_interface(void)
{
- void *handle = NULL;
- size_t i = 0;
+ int i = 0;
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_interface_initialize_g) {
+ size_t u; /* Local index variable */
+
/* Close opened dynamic libraries */
- for(i=0; i<H5PL_table_used_g; i++) {
- handle = (H5PL_table_g[i]).handle;
- H5PL_close(handle);
- }
+ for(u = 0; u < H5PL_table_used_g; u++)
+ H5PL__close((H5PL_table_g[u]).handle);
/* Free the table of dynamic libraries */
H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g);
H5PL_table_used_g = H5PL_table_alloc_g = 0;
/* Free the table of search paths */
- for(i = 0; i < num_paths; i++) {
- if(path_table[i])
- path_table[i] = (char *)H5MM_xfree(path_table[i]);
- }
- num_paths = 0;
- path_found = FALSE;
+ for(u = 0; u < H5PL_num_paths_g; u++)
+ if(H5PL_path_table_g[u])
+ H5PL_path_table_g[u] = (char *)H5MM_xfree(H5PL_path_table_g[u]);
+ H5PL_num_paths_g = 0;
+ H5PL_path_found_g = FALSE;
H5_interface_initialize_g = 0;
i = 1;
@@ -107,7 +198,6 @@ H5PL_term_interface(void)
FUNC_LEAVE_NOAPI(i)
} /* end H5PL_term_interface() */
-
/*-------------------------------------------------------------------------
* Function: H5PL_load
@@ -116,91 +206,112 @@ H5PL_term_interface(void)
* and/or loads a dynamic plugin library first among the already
* opened libraries then in the designated location paths.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-NULL on success/NULL on failure
*
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
H5PL_load(H5PL_type_t type, int id)
{
- char *dl_path = NULL;
- char *origin_dl_path = NULL;
- size_t len = 0;
- char *dir = NULL;
- size_t i;
- htri_t found_in_table = FALSE;
- htri_t found_in_path = FALSE;
+ htri_t found; /* Whether the plugin was found */
H5Z_class2_t *plugin_info = NULL;
void *ret_value = NULL;
FUNC_ENTER_NOAPI(NULL)
+ /* Initialize the location paths for dynamic libraries, if they aren't
+ * already set up.
+ */
+ if(FALSE == H5PL_path_found_g)
+ if(H5PL__init_path_table() < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINIT, NULL, "can't initialize search path table")
+
/* Search in the table of already loaded plugin libraries */
- if((found_in_table = H5PL_search_table(type, id, (void **)&plugin_info)) < 0)
+ if((found = H5PL__search_table(type, id, (void **)&plugin_info)) < 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in table failed")
- /* Finish the function if found */
- if(found_in_table && plugin_info) {
- ret_value = (void *)plugin_info;
- HGOTO_DONE(ret_value)
- }
-
- /* Find the location paths for dynamic libraries */
- if(FALSE == path_found) {
- /* Retrieve paths from HDF5_PLUGIN_PATH if the user sets it
- * or from the default paths if it isn't set */
- origin_dl_path = HDgetenv("HDF5_PLUGIN_PATH");
- if(origin_dl_path == NULL) {
- len = HDstrlen(H5PL_DEFAULT_PATH) + 1;
- dl_path = (char *)H5MM_malloc(len*sizeof(char));
- HDstrncpy(dl_path, H5PL_DEFAULT_PATH, len-1);
- dl_path[len-1] = '\0';
- } else {
- len = HDstrlen(origin_dl_path) + 1;
- dl_path = (char *)H5MM_malloc(len*sizeof(char));
- HDstrncpy(dl_path, origin_dl_path, len);
- }
-
- /* Put paths in the path table. They are seperated by ":" */
- dir = HDstrtok(dl_path, H5PL_PATH_SEPERATOR);
- while(dir) {
- path_table[num_paths] = (char *)HDmalloc(HDstrlen(dir) + 1);
- path_table[num_paths][0] = '\0';
- HDstrcat(path_table[num_paths], dir);
- num_paths++;
- dir = HDstrtok(NULL, H5PL_PATH_SEPERATOR);
- }
-
- path_found = TRUE;
- }
-
- /* Iterate through the path table to find the right dynamic libraries */
- for(i=0; i<num_paths; i++) {
- if((found_in_path = H5PL_find(type, id, path_table[i], (void **)&plugin_info)) < 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in paths failed")
-
- /* Finish the function if found */
- if(found_in_path && plugin_info) {
- ret_value = (void *)plugin_info;
- HGOTO_DONE(ret_value)
- }
- }
+ /* If not found, iterate through the path table to find the right dynamic library */
+ if(!found) {
+ size_t i; /* Local index variable */
+
+ for(i = 0; i < H5PL_num_paths_g; i++) {
+ if((found = H5PL__find(type, id, H5PL_path_table_g[i], (void **)&plugin_info)) < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in paths failed")
+
+ /* Break out if found */
+ if(found) {
+ HDassert(plugin_info);
+ break;
+ } /* end if */
+ } /* end for */
+ } /* end if */
+
+ /* Check if we found the plugin */
+ if(found)
+ ret_value = plugin_info;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5PL_load() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PL__init_path_table
+ *
+ * Purpose: Initialize the path table.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * 18 March 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5PL__init_path_table(void)
+{
+ char *dl_path = NULL;
+ char *origin_dl_path;
+ char *dir;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Retrieve paths from HDF5_PLUGIN_PATH if the user sets it
+ * or from the default paths if it isn't set.
+ */
+ origin_dl_path = HDgetenv("HDF5_PLUGIN_PATH");
+ if(NULL == origin_dl_path)
+ dl_path = HDstrdup(H5PL_DEFAULT_PATH);
+ else
+ dl_path = HDstrdup(origin_dl_path);
+ if(NULL == dl_path)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+
+ /* Put paths in the path table. They are separated by ":" */
+ dir = HDstrtok(dl_path, H5PL_PATH_SEPARATOR);
+ while(dir) {
+ if(NULL == (H5PL_path_table_g[H5PL_num_paths_g] = HDstrdup(dir)))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+ H5PL_num_paths_g++;
+ dir = HDstrtok(NULL, H5PL_PATH_SEPARATOR);
+ } /* end while */
+
+ H5PL_path_found_g = TRUE;
done:
if(dl_path)
dl_path = (char *)H5MM_xfree(dl_path);
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5PL__init_path_table() */
/*-------------------------------------------------------------------------
- * Function: H5PL_find
+ * Function: H5PL__find
*
* Purpose: Given a path, this function opens the directory and envokes
* another function to go through all files to find the right
@@ -214,98 +325,91 @@ done:
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
#ifndef H5_HAVE_WIN32_API
-htri_t
-H5PL_find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
+static htri_t
+H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
{
char *pathname = NULL;
DIR *dirp = NULL;
- struct dirent *dp = NULL;
- struct stat my_stat;
- htri_t found_in_dir = FALSE;
+ struct dirent *dp;
htri_t ret_value = FALSE;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
/* Open the directory */
if(!(dirp = HDopendir(dir)))
HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory")
/* Iterates through all entries in the directory to find the right plugin library */
- while ((dp = HDreaddir(dirp)) != NULL) {
- /* The library we are looking for should be called libxxx.so... on Unix
- * or libxxx.xxx.dylib on Mac */
- if(!HDstrncmp(dp->d_name, "lib", (size_t)3) &&
- (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) {
- pathname = (char *)H5MM_malloc(strlen(dir) + strlen(dp->d_name) + 2);
- HDstrncpy(pathname, dir, strlen(dir)+1);
- HDstrcat(pathname, "/");
- HDstrcat(pathname, dp->d_name);
-
- /*fprintf(stderr, "dp->d_name=%s, pathname=%s. ", dp->d_name, pathname);
- fprintf(stderr, "\n");*/
-
- if(HDstat(pathname, &my_stat) == -1)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file: %s", strerror(errno))
-
- /* If it is a directory, skip it */
- if(S_ISDIR(my_stat.st_mode))
- continue;
-
- if((found_in_dir = H5PL_open(plugin_type, pathname, type_id, info)) < 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed")
-
- if(found_in_dir) {
- ret_value = TRUE;
- HGOTO_DONE(ret_value)
- } else
- if(pathname)
- pathname = (char *)H5MM_xfree(pathname);
- }
- }
-
- if(HDclosedir(dirp) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", strerror(errno))
- dirp = NULL;
+ while((dp = HDreaddir(dirp)) != NULL) {
+ /* The library we are looking for should be called libxxx.so... on Unix
+ * or libxxx.xxx.dylib on Mac.
+ */
+ if(!HDstrncmp(dp->d_name, "lib", (size_t)3) &&
+ (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) {
+ h5_stat_t my_stat;
+ htri_t found_in_dir;
+
+ pathname = (char *)H5MM_malloc(HDstrlen(dir) + HDstrlen(dp->d_name) + 2);
+ HDstrncpy(pathname, dir, HDstrlen(dir) + 1);
+ HDstrcat(pathname, "/");
+ HDstrcat(pathname, dp->d_name);
+
+ if(HDstat(pathname, &my_stat) == -1)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file: %s", strerror(errno))
+
+ /* If it is a directory, skip it */
+ if(S_ISDIR(my_stat.st_mode))
+ continue;
+
+ /* Attempt to open the dynamic library as a filter library */
+ if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed")
+ if(found_in_dir) {
+ /* Indicate success */
+ ret_value = TRUE;
+ break;
+ } /* end if */
+ else
+ if(pathname)
+ pathname = (char *)H5MM_xfree(pathname);
+ } /* end if */
+ } /* end while */
done:
+ if(dirp)
+ if(HDclosedir(dirp) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", strerror(errno))
if(pathname)
pathname = (char *)H5MM_xfree(pathname);
- if(dirp)
- HDclosedir(dirp);
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5PL__find() */
#else
-htri_t
-H5PL_find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
+static htri_t
+H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
{
- char *pathname = NULL;
- struct dirent *dp = NULL;
-
WIN32_FIND_DATA fdFile;
- HANDLE hFind = NULL;
-
- htri_t found_in_dir = FALSE;
- htri_t ret_value = FALSE;
+ HANDLE hFind;
+ char *pathname = NULL;
+ htri_t ret_value = FALSE;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
- if((hFind = FindFirstFile(dir, &fdFile)) == INVALID_HANDLE_VALUE) {
- /*fprintf(stderr, "Path not found: [%s]\n", dir);*/
+ if((hFind = FindFirstFile(dir, &fdFile)) == INVALID_HANDLE_VALUE)
HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory")
- }
do {
/* Find first file will always return "."
- * and ".." as the first two directories. */
+ * and ".." as the first two directories.
+ */
if(HDstrcmp(fdFile.cFileName, ".") != 0 && HDstrcmp(fdFile.cFileName, "..") != 0) {
- pathname = (char *)H5MM_malloc(strlen(dir) + strlen(fdFile.cFileName) + 2);
- HDstrncpy(pathname, dir, strlen(dir)+1);
+ htri_t found_in_dir;
+
+ pathname = (char *)H5MM_malloc(HDstrlen(dir) + HDstrlen(fdFile.cFileName) + 2);
+ HDstrncpy(pathname, dir, HDstrlen(dir)+1);
HDstrcat(pathname, "\\");
HDstrcat(pathname, fdFile.cFileName);
@@ -313,35 +417,32 @@ H5PL_find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
if(fdFile.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
continue;
- if((found_in_dir = H5PL_open(plugin_type, pathname, type_id, info)) < 0)
+ if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed")
-
if(found_in_dir) {
- ret_value = TRUE;
- HGOTO_DONE(ret_value)
- } else
+ /* Indicate success */
+ ret_value = TRUE;
+ break;
+ } /* end if */
+ else
if(pathname)
pathname = (char *)H5MM_xfree(pathname);
- }
+ } /* end if */
} while(FindNextFile(hFind, &fdFile)); /* Find the next file. */
- /* Clean things up! */
- FindClose(hFind);
- hFind = NULL;
-
done:
- if(pathname)
- pathname = (char *)H5MM_xfree(pathname);
if(hFind)
FindClose(hFind);
+ if(pathname)
+ pathname = (char *)H5MM_xfree(pathname);
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5PL__find() */
#endif
/*-------------------------------------------------------------------------
- * Function: H5PL_open
+ * Function: H5PL__open
*
* Purpose: Iterates through all files to find the right plugin library.
* It loads the dynamic plugin library and keeps it on the list
@@ -354,131 +455,129 @@ done:
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-htri_t
-H5PL_open(H5PL_type_t pl_type, char *libname, int pl_id, void **pl_info)
+static htri_t
+H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, void **pl_info)
{
H5PL_HANDLE handle = NULL;
- H5Z_class2_t* (*H5PL_get_plugin_info)(void) = NULL;
- H5Z_class2_t *plugin_info = NULL;
htri_t ret_value = FALSE;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
/* There are different reasons why a library can't be open, e.g. wrong architecture.
- * simply continue if we can't open it */
- if(NULL == (handle = H5PL_OPEN_DLIB(libname)))
- /*fprintf(stderr, "not open dl library: %s\n", H5PL_CLR_ERROR);*/
- HGOTO_DONE(ret_value)
-
- H5PL_CLR_ERROR; /*clear error*/
-
- /* Return a handle for the function H5PL_get_plugin_info in the dynamic library.
- * The plugin library is suppose to define this function. */
- if(NULL == (H5PL_get_plugin_info = H5PL_GET_LIB_FUNC(handle, "H5PL_get_plugin_info"))) {
- if(H5PL_close(handle) < 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
- }
-
- /* Envoke H5PL_get_plugin_info to verify this is the right library we are looking for.
- * Move on if it isn't. */
- if(H5PL_get_plugin_info) {
- if(NULL == (plugin_info = (*H5PL_get_plugin_info)())) {
- if(H5PL_close(handle) < 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
- }
-
- if(plugin_info->id == pl_id) {
- (H5PL_table_g[H5PL_table_used_g]).handle = handle;
- (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type;
- (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id;
-/*fprintf(stderr, "%s: H5PL_table_used_g=%d, id=%d, id 2=%d\n", FUNC, H5PL_table_used_g, (H5PL_table_g[H5PL_table_used_g]).pl_id, plugin_info->id);*/
- H5PL_table_used_g++;
-
- *pl_info = (void *)plugin_info;
- ret_value = TRUE;
-
- HGOTO_DONE(ret_value)
- } else if(H5PL_close(handle) < 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
- }
+ * simply continue if we can't open it.
+ */
+ if(NULL == (handle = H5PL_OPEN_DLIB(libname))) {
+ H5PL_CLR_ERROR; /* clear error */
+ } /* end if */
+ else {
+ H5Z_class2_t * (*H5PL_get_plugin_info)(void);
+
+ /* Return a handle for the function H5PL_get_plugin_info in the dynamic library.
+ * The plugin library is suppose to define this function.
+ */
+ if(NULL == (H5PL_get_plugin_info = (H5Z_class2_t *(*)(void))H5PL_GET_LIB_FUNC(handle, "H5PL_get_plugin_info"))) {
+ if(H5PL__close(handle) < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
+ } /* end if */
+ else {
+ H5Z_class2_t *plugin_info;
+
+ /* Invoke H5PL_get_plugin_info to verify this is the right library we are looking for.
+ * Move on if it isn't.
+ */
+ if(NULL == (plugin_info = (*H5PL_get_plugin_info)())) {
+ if(H5PL__close(handle) < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info")
+ } /* end if */
+
+ /* Successfully found plugin library, check if it's the right one */
+ if(plugin_info->id == pl_id) {
+ /* Expand the table if it is too small */
+ if(H5PL_table_used_g >= H5PL_table_alloc_g) {
+ size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g);
+ H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t));
+
+ if(!table)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend dynamic library table")
+
+ H5PL_table_g = table;
+ H5PL_table_alloc_g = n;
+ } /* end if */
+
+ (H5PL_table_g[H5PL_table_used_g]).handle = handle;
+ (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type;
+ (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id;
+ H5PL_table_used_g++;
+
+ /* Set the plugin info to return */
+ *pl_info = (void *)plugin_info;
+
+ /* Indicate success */
+ ret_value = TRUE;
+ } /* end if */
+ else
+ if(H5PL__close(handle) < 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
+ } /* end if */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5PL__open() */
/*-------------------------------------------------------------------------
- * Function: H5PL_search_table
+ * Function: H5PL__search_table
*
* Purpose: Search in the list of already opened dynamic libraries
* to see if the one we are looking for is already opened.
*
* Return: TRUE on success,
* FALSE on not found,
- * negative on failure
+ * Negative on failure
*
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-htri_t
-H5PL_search_table(H5PL_type_t plugin_type, int type_id, void **info)
+static htri_t
+H5PL__search_table(H5PL_type_t plugin_type, int type_id, void **info)
{
- H5Z_class2_t* (*H5PL_get_plugin_info)(void) = NULL;
- H5Z_class2_t *plugin_info = NULL;
size_t i;
htri_t ret_value = FALSE;
- FUNC_ENTER_NOAPI(FAIL)
-
-/*if(0 < H5PL_table_used_g)
-fprintf(stderr, "%s: H5PL_table_used_g=%d, id=%d\n", FUNC, H5PL_table_used_g, (H5PL_table_g[H5PL_table_used_g-1]).pl_id);*/
+ FUNC_ENTER_STATIC
/* Search in the table of already opened dynamic libraries */
- if(0 < H5PL_table_used_g) {
- for(i=0; i<H5PL_table_used_g; i++) {
+ if(H5PL_table_used_g > 0) {
+ for(i = 0; i < H5PL_table_used_g; i++) {
if((plugin_type == (H5PL_table_g[i]).pl_type) && (type_id == (H5PL_table_g[i]).pl_id)) {
- if(NULL == (H5PL_get_plugin_info = H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PL_get_plugin_info")))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PL_get_plugin_info")
+ H5Z_class2_t *(*H5PL_get_plugin_info)(void);
+ H5Z_class2_t *plugin_info;
+ if(NULL == (H5PL_get_plugin_info = (H5Z_class2_t *(*)(void))H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PL_get_plugin_info")))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PL_get_plugin_info")
if(NULL == (plugin_info = (*H5PL_get_plugin_info)()))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
- /*fprintf(stderr, "%s: handle=%p, H5PL_get_plugin_info=%p, plugin_info=%p, id=%d\n", FUNC, (H5PL_table_g[i]).handle, H5PL_get_plugin_info, plugin_info, plugin_info->id);*/
-
*info = (void *)plugin_info;
ret_value = TRUE;
- }
- }
- }
-
- /* Expand the table if it is too small */
- if(H5PL_table_used_g >= H5PL_table_alloc_g) {
- size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5PL_table_alloc_g);
- H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t));
-
- if(!table)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend dynamic library table")
-
- H5PL_table_g = table;
- H5PL_table_alloc_g = n;
+ break;
+ } /* end if */
+ } /* end for */
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5PL__search_table() */
/*-------------------------------------------------------------------------
- * Function: H5PL_close
+ * Function: H5PL__close
*
* Purpose: Closes the handle for dynamic library
*
@@ -487,20 +586,15 @@ done:
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-herr_t
-H5PL_close(H5PL_HANDLE handle)
+static herr_t
+H5PL__close(H5PL_HANDLE handle)
{
- herr_t ret_value = SUCCEED;
+ FUNC_ENTER_STATIC_NOERR
- FUNC_ENTER_NOAPI(FAIL)
-/*fprintf(stderr, "%s: closing. handle=%p\n", FUNC, handle);*/
H5PL_CLOSE_LIB(handle);
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5PL__close() */
diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h
deleted file mode 100644
index 616bd23..0000000
--- a/src/H5PLpkg.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * 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 HDF5 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. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#ifndef H5PL_PACKAGE
-#error "Do not include this file outside the H5PL package!"
-#endif
-
-#ifndef _H5PLpkg_H
-#define _H5PLpkg_H
-
-/* Include private header file */
-#include "H5PLprivate.h"
-
-#define MAX_PATH_NUM 16
-
-/****************************/
-/* Macros for supporting
- * both Windows and Unix */
-/****************************/
-
-/* Handle for dynamic library */
-#ifdef H5_HAVE_WIN32_API
-/* Handle for dynamic library */
-#define H5PL_HANDLE HINSTANCE
-
-/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
-#define H5PL_OPEN_DLIB(S) LoadLibraryEx(TEXT(S), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
-
-/* Get the address of a symbol in dynamic library */
-#define H5PL_GET_LIB_FUNC(H,N) GetProcAddress(H,N)
-
-/* Close dynamic library */
-#define H5PL_CLOSE_LIB(H) FreeLibrary(H)
-
-/* Declare error string */
-#define H5PL_ERROR DWORD dw; char *error
-
-/* Clear error - nothing to do */
-#define H5PL_CLR_ERROR
-
-/* Print error message */
-#define H5PL_CHECK_ERR(R) { \
- if(R==NULL) { \
- dw = GetLastError(); \
- sprintf(error, "%ld", dw); \
- } \
- else error = NULL; \
-}
-
-#else
-/* Handle for dynamic library */
-#define H5PL_HANDLE void *
-
-/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
-#define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_NOW|RTLD_LAZY)
-
-/* Get the address of a symbol in dynamic library */
-#define H5PL_GET_LIB_FUNC(H,N) dlsym(H,N)
-
-/* Close dynamic library */
-#define H5PL_CLOSE_LIB(H) dlclose(H)
-
-/* Declare error string */
-#define H5PL_ERROR char *error
-
-/* Clear error */
-#define H5PL_CLR_ERROR dlerror()
-
-/* Print error message */
-#define H5PL_CHECK_ERR(R) { \
- if(R==NULL) { \
- error = dlerror(); \
- } \
- else error = NULL; \
-}
-
-#endif
-
-/****************************/
-/* Local typedefs */
-/****************************/
-
-/* Type for the list of info for opened plugin libraries */
-typedef struct H5PL_table_t {
- H5PL_type_t pl_type; /* plugin type */
- int pl_id; /* ID for the plugin */
- H5PL_HANDLE handle; /* plugin handle */
-} H5PL_table_t;
-
-/****************************/
-/* Local variables */
-/****************************/
-
-/* Table for opened plugin libraries */
-static size_t H5PL_table_alloc_g = 0;
-static size_t H5PL_table_used_g = 0;
-static H5PL_table_t *H5PL_table_g = NULL;
-
-/* Table of location paths for plugin libraries */
-static char *path_table[MAX_PATH_NUM];
-static size_t num_paths = 0;
-static htri_t path_found = FALSE;
-
-/******************************/
-/* Package Private Prototypes */
-/******************************/
-
-/* Function prototypes for H5PL package scope */
-H5_DLL htri_t H5PL_find(H5PL_type_t plugin_type, int type_id, char *dir, void **info);
-H5_DLL htri_t H5PL_open(H5PL_type_t pl_type, char *libname, int plugin_id, void **pl_info);
-H5_DLL htri_t H5PL_search_table(H5PL_type_t plugin_type, int type_id, void **info);
-H5_DLL herr_t H5PL_close(H5PL_HANDLE handle);
-
-#endif /* _H5PLpkg_H */
-
diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h
index 61cfcda..25fbc51 100644
--- a/src/H5PLprivate.h
+++ b/src/H5PLprivate.h
@@ -26,26 +26,6 @@
/* Private headers needed by this file */
#include "H5private.h" /* Generic Functions */
-#ifdef H5_HAVE_WIN32_API
-/* The following two defines must be before any windows headers are included */
-#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
-#define NOGDI /* Exclude Graphic Display Interface macros */
-
-#ifdef H5_HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#include <windows.h>
-#include <direct.h> /* For _getcwd() */
-#endif /*H5_HAVE_WIN32_API*/
-
-#ifdef H5_HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#ifndef H5_HAVE_WIN32_API
-#include <dirent.h>
-#endif
/**************************/
/* Library Private Macros */
@@ -67,6 +47,6 @@
/***************************************/
/* Internal API routines */
-H5_DLL void* H5PL_load(H5PL_type_t plugin_type, int type_id);
+H5_DLL void *H5PL_load(H5PL_type_t plugin_type, int type_id);
-#endif
+#endif /* _H5PLprivate_H */
diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h
index 4c4a669..65a94cc 100644
--- a/src/H5PLpublic.h
+++ b/src/H5PLpublic.h
@@ -43,4 +43,5 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* _H5PLpublic_H */
+
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index 032162a..d3de509 100644
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -38,10 +38,10 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
-#include "H5PLprivate.h" /* Dynamic plugin */
-#include "H5Zprivate.h" /* Filter pipeline */
#include "H5Opkg.h" /* Object headers */
#include "H5Ppkg.h" /* Property lists */
+#include "H5PLprivate.h" /* Dynamic plugin */
+#include "H5Zprivate.h" /* Filter pipeline */
/****************/
@@ -92,6 +92,9 @@ static herr_t H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size
static herr_t H5P__ocrt_pipeline_dec(const void **_pp, void *value);
static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size);
+/* Local routines */
+static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
+ unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]);
/*********************/
/* Package Variables */
@@ -748,9 +751,9 @@ herr_t
H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
- H5P_genplist_t *plist; /* Property list */
- H5O_pline_t pline; /* Filter pipeline */
- herr_t ret_value=SUCCEED; /* return value */
+ H5P_genplist_t *plist; /* Property list */
+ H5O_pline_t pline; /* Filter pipeline */
+ herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values);
@@ -768,7 +771,7 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Call the private function */
- if(H5P_set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0)
+ if(H5P__set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "failed to call private function")
done:
@@ -777,7 +780,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5P_set_filter
+ * Function: H5P__set_filter
*
* Purpose: Adds the specified FILTER and corresponding properties to the
* end of the data or link output filter pipeline
@@ -798,53 +801,40 @@ done:
* failed; the filter will not participate in the pipeline
* during an H5Dread() of the chunk. If this bit is clear and
* the filter fails then the entire I/O operation fails.
- * If this bit is set but encoding is disabled for a filter,
- * attempting to write will generate an error.
+ * If this bit is set but encoding is disabled for a filter,
+ * attempting to write will generate an error.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
- * Modifications:
- *
- * Raymond Lu
- * Tuesday, October 2, 2001
- * Changed the way to check parameter and set property for
- * generic property list.
- *
- * Neil Fortner
- * Wednesday, May 20, 2009
- * Overloaded to accept gcpl's as well as dcpl's and moved to
- * H5Pocpl.c
- *
*-------------------------------------------------------------------------
*/
-herr_t
-H5P_set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
+static herr_t
+H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
- H5O_pline_t pline; /* Filter pipeline */
- H5Z_class2_t *filter_info = NULL;
- htri_t filter_avail = FALSE; /* Filter availability */
- herr_t ret_value=SUCCEED; /* return value */
+ H5O_pline_t pline; /* Filter pipeline */
+ htri_t filter_avail; /* Filter availability */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
+ /* Check if filter is already available */
if((filter_avail = H5Z_filter_avail(filter)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't check filter availability")
+ /* If filter is not available, try to dynamically load it */
if(!filter_avail) {
- if((filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter)) == NULL)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin")
-/*if(filter_info)
-fprintf(stderr, "%s: filter_info=%p, filter_info->id=%d\n", FUNC, filter_info, filter_info->id);*/
- if (H5Z_register (filter_info)<0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
-
- }
-
-#ifndef TMP
+ H5Z_class2_t *filter_info;
+
+ if(NULL == (filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter)))
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin")
+ if(H5Z_register(filter_info) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
+ } /* end if */
+
/* Get the pipeline property to append to */
if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline")
@@ -856,11 +846,10 @@ fprintf(stderr, "%s: filter_info=%p, filter_info->id=%d\n", FUNC, filter_info, f
/* Put the I/O pipeline information back into the property list */
if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline")
-#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5P_set_filter() */
+} /* end H5P__set_filter() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 2006ced..6560064 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -108,8 +108,6 @@ H5_DLL herr_t H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id,
unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[],
size_t namelen, char name[], unsigned *filter_config);
-H5_DLL herr_t H5P_set_filter(H5P_genplist_t *plist, H5Z_filter_t filter,
- unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]);
/* *SPECIAL* Don't make more of these! -QAK */
H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id);
diff --git a/src/H5Z.c b/src/H5Z.c
index 8e8d80c..bfd0045 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -304,8 +304,6 @@ H5Z_register (const H5Z_class2_t *cls)
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
-/*if(cls)
-fprintf(stderr, "cls=%p, cls->id=%d\n", cls, cls->id);*/
HDassert(cls);
HDassert(cls->id >= 0 && cls->id <= H5Z_FILTER_MAX);
@@ -463,7 +461,7 @@ H5Zfilter_avail(H5Z_filter_t id)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
if((ret_value = H5Z_filter_avail(id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter")
done:
FUNC_LEAVE_API(ret_value)
@@ -480,24 +478,20 @@ done:
* Programmer: Raymond Lu
* 13 February 2013
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
htri_t
H5Z_filter_avail(H5Z_filter_t id)
{
size_t i; /* Local index variable */
- htri_t ret_value=FALSE; /* Return value */
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Is the filter already registered? */
- for(i=0; i<H5Z_table_used_g; i++)
- if(H5Z_table_g[i].id==id) {
- ret_value=TRUE;
- break;
- } /* end if */
+ for(i = 0; i < H5Z_table_used_g; i++)
+ if(H5Z_table_g[i].id == id)
+ HGOTO_DONE(TRUE)
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1122,33 +1116,32 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
}
/* If the filter isn't registered, try to load it dynamically and register it. Otherwise, return failure */
- if ((fclass_idx=H5Z_find_idx(pline->filter[idx].id))<0) {
- H5Z_class2_t *filter_info = NULL;
+ if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) {
+ H5Z_class2_t *filter_info;
- if((filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id))) != NULL) {
- if (H5Z_register(filter_info)<0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
- } else {
+ if(NULL != (filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) {
+ if(H5Z_register(filter_info) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
+ } /* end if */
+ else {
/* Print out the filter name to give more info. But the name is optional for
* the filter */
if(pline->filter[idx].name)
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered",
- pline->filter[idx].name)
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name)
else
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered")
- }
- }
+ } /* end else */
- /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */
- if ((fclass_idx=H5Z_find_idx(pline->filter[idx].id))<0) {
- /* Print out the filter name to give more info. But the name is optional for
- * the filter */
- if(pline->filter[idx].name)
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered",
- pline->filter[idx].name)
- else
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered")
- }
+ /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */
+ if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) {
+ /* Print out the filter name to give more info. But the name is optional for
+ * the filter */
+ if(pline->filter[idx].name)
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name)
+ else
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered")
+ } /* end if */
+ } /* end if */
fclass=&H5Z_table_g[fclass_idx];
#ifdef H5Z_DEBUG
diff --git a/src/H5private.h b/src/H5private.h
index f1f5dbb..78d3d9d 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -149,6 +149,17 @@
# include <io.h>
#endif
+/*
+ * Dynamic library handling. These are needed for dynamically loading I/O
+ * filters and VFDs.
+ */
+#ifdef H5_HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+#ifdef H5_HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
#ifdef H5_HAVE_WIN32_API
/* The following two defines must be before any windows headers are included */
diff --git a/src/Makefile.am b/src/Makefile.am
index 262bdc7..a7f7bd9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,8 +88,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \
H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \
H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \
- H5Pgcpl.c H5Pint.c H5PL.c \
+ H5Pgcpl.c H5Pint.c \
H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \
+ H5PL.c \
H5R.c H5Rdeprec.c \
H5RC.c \
H5RS.c \
@@ -117,7 +118,9 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers
H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \
H5FDmulti.h H5FDsec2.h H5FDstdio.h \
H5Gpublic.h H5Ipublic.h H5Lpublic.h \
- H5MMpublic.h H5Opublic.h H5PLpublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \
+ H5MMpublic.h H5Opublic.h H5Ppublic.h \
+ H5PLpublic.h \
+ H5Rpublic.h H5Spublic.h \
H5Tpublic.h H5Zpublic.h
# install libhdf5.settings in lib directory
diff --git a/test/plugin.c b/test/plugin.c
index debc38b..dd9a1f7 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -791,14 +791,15 @@ main(void)
if(nerrors)
TEST_ERROR
- printf("All dataset tests passed.\n");
+ printf("All plugin tests passed.\n");
h5_cleanup(FILENAME, fapl);
return 0;
error:
nerrors = MAX(1, nerrors);
- printf("***** %d DATASET TEST%s FAILED! *****\n",
+ printf("***** %d PLUGIN TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
return 1;
}
+
diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in
index a881198..c00df8c 100644
--- a/test/test_plugin.sh.in
+++ b/test/test_plugin.sh.in
@@ -24,7 +24,7 @@ TOP_BUILDDIR=@top_builddir@
echo $srcdir
echo $TOP_BUILDDIR
-# Determine backward compatibility options eneabled
+# Determine backward compatibility options enabled
DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@"
nerrors=0
@@ -54,7 +54,7 @@ TESTING() {
}
if test $nerrors -eq 0 ; then
- echo "All Error API tests passed."
+ echo "All Plugin API tests passed."
fi
exit $nerrors