Merge pull request #395 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop

* commit '1e0ecb4481e226239c1fd51bd214bd7e7490805d':
  Fix typo deletion
  HDFFV-10143 Update new feature section.
  HDFFV-10143 clean up format and function return
  HDFFV-10143 Add plugin APIs to Java interface
  Update with checks for index bounds
  Update tools issues
  HDFFV-10143 fix use before set
  HDFFV-10143 surround will fail with try block
  HDFFV-10143 typo cleanup
  HDFFV-10143 typo removed
  Fix code error and use H5PL_MAX_PATH_NUM in test
  HDFFV-10143 Cleanup due to comments
  HDFFV-10143 remove debugging output
  HDFFV-10143 change h5PLget to use buffer like H5Iget_name
  HDFFV-10143 change put to replace and add const
  Remove redundant code
  HDFFV-10143 Use Windows A version of ExpandEnvironmentStrings
  HDFFV-10143 Fix initial issues from review
  Remove duplicated paths, add new paths
  HDFFV-10143 add APIs to manipulate plugin path table
This commit is contained in:
Allen Byrne 2017-04-05 13:28:37 -05:00
commit 60167ae875
13 changed files with 1239 additions and 388 deletions

View File

@ -801,6 +801,7 @@
./src/H5PBprivate.h
./src/H5PL.c
./src/H5PLmodule.h
./src/H5PLpkg.h
./src/H5PLprivate.h
./src/H5PLpublic.h
./src/H5PLextern.h

View File

@ -137,7 +137,6 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
/usr/lib/java/jre/lib/{libarch}
/usr/lib64/java/jre/lib/{libarch}
/usr/lib/jvm/jre/lib/{libarch}
/usr/lib64/jvm/jre/lib/{libarch}
/usr/local/lib/java/jre/lib/{libarch}
/usr/local/share/java/jre/lib/{libarch}
/usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
@ -152,6 +151,9 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
/usr/lib/jvm/default-java/jre/lib/{libarch}
/usr/lib/jvm/default-java/jre/lib
/usr/lib/jvm/default-java/lib
# Arch Linux specific paths for default JVM
/usr/lib/jvm/default/jre/lib/{libarch}
/usr/lib/jvm/default/lib/{libarch}
# Ubuntu specific paths for default JVM
/usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
/usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
@ -197,14 +199,11 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
/usr/lib64/java/include
/usr/local/lib/java/include
/usr/lib/jvm/java/include
/usr/lib64/jvm/java/include
/usr/lib/jvm/java-6-sun/include
/usr/lib/jvm/java-1.5.0-sun/include
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
/usr/lib/jvm/java-6-openjdk/include
/usr/lib/jvm/java-7-openjdk/include
/usr/lib/jvm/java-7-openjdk-i386/include
/usr/lib/jvm/java-7-openjdk-amd64/include
/usr/lib64/jvm/java-7-openjdk/include
/usr/lib64/jvm/java-7-openjdk-amd64/include
/usr/lib/jvm/java-8-openjdk-{libarch}/include # ubuntu 15.10
@ -216,6 +215,8 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
/opt/sun-jdk-1.5.0.04/include
# Debian specific path for default JVM
/usr/lib/jvm/default-java/include
# Arch specific path for default JVM
/usr/lib/jvm/default/include
# OpenBSD specific path for default JVM
/usr/local/jdk-1.7.0/include
/usr/local/jdk-1.6.0/include

View File

@ -7202,6 +7202,78 @@ public class H5 implements java.io.Serializable {
**/
public synchronized static native int H5PLget_loading_state() throws HDF5LibraryException;
/**
* H5PLappend inserts the plugin path at the end of the table.
*
* @param plugin_path
* IN: Path for location of filter plugin libraries.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native void H5PLappend(String plugin_path) throws HDF5LibraryException;
/**
* H5PLprepend inserts the plugin path at the beginning of the table.
*
* @param plugin_path
* IN: Path for location of filter plugin libraries.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native void H5PLprepend(String plugin_path) throws HDF5LibraryException;
/**
* H5PLreplace replaces the plugin path at the specified index.
*
* @param plugin_path
* IN: Path for location of filter plugin libraries.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native void H5PLreplace(String plugin_path, int index) throws HDF5LibraryException;
/**
* H5PLinsert inserts the plugin path at the specified index.
*
* @param plugin_path
* IN: Path for location of filter plugin libraries.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native void H5PLinsert(String plugin_path, int index) throws HDF5LibraryException;
/**
* H5PLremove removes the plugin path at the specified index.
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native void H5PLremove(int index) throws HDF5LibraryException;
/**
* H5PLget retrieves the plugin path at the specified index.
*
* @return the current path at the index in plugin path table
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native String H5PLget(int index) throws HDF5LibraryException;
/**
* H5PLsize retrieves the size of the current list of plugin paths.
*
* @return the current number of paths in the plugin path table
*
* @exception HDF5LibraryException
* - Error from the HDF-5 Library.
**/
public synchronized static native int H5PLsize() throws HDF5LibraryException;
// ////////////////////////////////////////////////////////////
// //
// H5R: HDF5 1.8 Reference API Functions //

View File

@ -61,6 +61,167 @@ Java_hdf_hdf5lib_H5_H5PLget_1loading_1state
return (jint)plugin_type;
} /* end Java_hdf_hdf5lib_H5_H5PLget_1loading_1state */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLappend
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLappend
(JNIEnv *env, jclass clss, jobjectArray plugin_path)
{
char *aName;
herr_t retVal = -1;
PIN_JAVA_STRING(plugin_path, aName);
if (aName != NULL) {
retVal = H5PLappend(aName);
UNPIN_JAVA_STRING(plugin_path, aName);
if (retVal < 0)
h5libraryError(env);
}
} /* end Java_hdf_hdf5lib_H5_H5PLappend */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLprepend
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLprepend
(JNIEnv *env, jclass clss, jobjectArray plugin_path)
{
char *aName;
herr_t retVal = -1;
PIN_JAVA_STRING(plugin_path, aName);
if (aName != NULL) {
retVal = H5PLprepend(aName);
UNPIN_JAVA_STRING(plugin_path, aName);
if (retVal < 0)
h5libraryError(env);
}
} /* end Java_hdf_hdf5lib_H5_H5PLprepend */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLreplace
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLreplace
(JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index)
{
char *aName;
herr_t retVal = -1;
PIN_JAVA_STRING(plugin_path, aName);
if (aName != NULL) {
retVal = H5PLreplace(aName, index);
UNPIN_JAVA_STRING(plugin_path, aName);
if (retVal < 0)
h5libraryError(env);
}
} /* end Java_hdf_hdf5lib_H5_H5PLreplace */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLinsert
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLinsert
(JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index)
{
char *aName;
herr_t retVal = -1;
PIN_JAVA_STRING(plugin_path, aName);
if (aName != NULL) {
retVal = H5PLinsert(aName, index);
UNPIN_JAVA_STRING(plugin_path, aName);
if (retVal < 0)
h5libraryError(env);
}
} /* end Java_hdf_hdf5lib_H5_H5PLinsert */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLremove
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLremove
(JNIEnv *env, jclass clss, jint index)
{
if (H5PLremove(index) < 0)
h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5PLremove */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLget
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5PLget
(JNIEnv *env, jclass clss, jint index)
{
char *aName;
jstring str = NULL;
ssize_t buf_size;
/* get the length of the name */
buf_size = H5PLget(index, NULL, 0);
if (buf_size <= 0) {
h5badArgument(env, "H5PLget: buf_size <= 0");
} /* end if */
else {
buf_size++; /* add extra space for the null terminator */
aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size);
if (aName == NULL) {
h5outOfMemory(env, "H5PLget: malloc failed");
} /* end if */
else {
buf_size = H5PLget(index, aName, (size_t)buf_size);
if (buf_size < 0) {
h5libraryError(env);
} /* end if */
else {
str = ENVPTR->NewStringUTF(ENVPAR aName);
}
HDfree(aName);
}
}
return str;
} /* end Java_hdf_hdf5lib_H5_H5PLget */
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLsize
* Signature: (V)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5PLsize
(JNIEnv *env, jclass clss)
{
int retVal = -1;
retVal = H5PLsize();
if (retVal < 0)
h5libraryError(env);
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5PLsize */
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */

View File

@ -41,6 +41,69 @@ JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5PLget_1loading_1state
(JNIEnv *, jclass);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLappend
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLappend
(JNIEnv *, jclass, jobjectArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLprepend
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLprepend
(JNIEnv *, jclass, jobjectArray);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLreplace
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLreplace
(JNIEnv *, jclass, jobjectArray, jint);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLinsert
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLinsert
(JNIEnv *, jclass, jobjectArray, jint);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLremove
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5PLremove
(JNIEnv *, jclass, jint);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLget
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_hdf_hdf5lib_H5_H5PLget
(JNIEnv *, jclass, jint);
/*
* Class: hdf_hdf5lib_H5
* Method: H5PLsize
* Signature: (V)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5PLsize
(JNIEnv *, jclass);
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */

View File

@ -633,13 +633,14 @@ JUnit version 4.11
.testH5Ocomment_clear
.testH5Ocopy_cur_not_exists
.TestH5PLplugins
.TestH5PLpaths
.testH5Zfilter_avail
.testH5Zunregister_predefined
.testH5Zget_filter_info
Time: XXXX
OK (637 tests)
OK (638 tests)
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Fopen(): can't set access and transfer property lists

View File

@ -69,6 +69,36 @@ public class TestH5PL {
}
}
@Test
public void TestH5PLpaths() {
try {
int original_entries = H5.H5PLsize();
H5.H5PLappend("path_one");
int plugin_entries = H5.H5PLsize();
assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+1) == plugin_entries);
H5.H5PLprepend("path_two");
plugin_entries = H5.H5PLsize();
assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
H5.H5PLinsert("path_three", original_entries);
plugin_entries = H5.H5PLsize();
assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+3) == plugin_entries);
String first_path = H5.H5PLget(original_entries);
assertTrue("First path was : "+first_path + " ",first_path.compareToIgnoreCase("path_three")==0);
H5.H5PLreplace("path_four", original_entries);
first_path = H5.H5PLget(original_entries);
assertTrue("First path changed to : "+first_path + " ",first_path.compareToIgnoreCase("path_four")==0);
H5.H5PLremove(original_entries);
first_path = H5.H5PLget(original_entries);
assertTrue("First path now : "+first_path + " ",first_path.compareToIgnoreCase("path_two")==0);
plugin_entries = H5.H5PLsize();
assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
}
catch (Throwable err) {
err.printStackTrace();
fail("TestH5PLpaths " + err);
}
}
@Ignore
public void TestH5PLdlopen() {
long file_id = -1;

View File

@ -77,11 +77,15 @@ New Features
The page buffering layer in the HDF5 library absorbs small accesses to
the file system. Each page in memory corresponds to a page allocated in
the file. Access to the file system is then performed as a single page
or multiple of pages, if they are contiguous. This ensures that small
or multiple of pages, if they are contiguous. This ensures that small
accesses to the file system are avoided while providing another caching
layer for improved I/O performance. This feature works in conjunction
with the paged aggregation feature.
- Filter plugin API added to access the table of paths to search for a
library. Java interface expanded with wrappers for the new functions.
(HDFFV-10143 ADB 2017/04/04)
Parallel Library:
-----------------
-
@ -139,7 +143,7 @@ Bug Fixes since HDF5-1.10.0-patch1 release
(HDFFV-9940 VC 2016/07/03, 2016/07/06)
- (a) Throw an error instead of assertion when v1 btree level hits the 1 byte limit.
(b) Modifications to better handle error recovery when conversion by
(b) Modifications to better handle error recovery when conversion by
h5format_convert fails.
(HDFFV-9434 VC 2016/05/29)
@ -172,6 +176,13 @@ Bug Fixes since HDF5-1.10.0-patch1 release
- h5repack now correctly parses the command line filter options.
(HDFFV-10046 ADB 2017/01/24)
- h5diff correctly indicates error when it cannot read data due
to an unavailable filter plugin.
(HDFFV-9994 ADB 2017/01/18)
- h5repack allows the --enable-error-stack option on the command line.
(HDFFV-775 ADB 2016/08/08)
High-Level APIs:
------
-

View File

@ -520,6 +520,7 @@ set (H5PL_SOURCES
set (H5PL_HDRS
${HDF5_SRC_DIR}/H5PLextern.h
${HDF5_SRC_DIR}/H5PLpkg.h
${HDF5_SRC_DIR}/H5PLpublic.h
)
IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SOURCES}" )

View File

@ -25,15 +25,33 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5MMprivate.h" /* Memory management */
#include "H5PLprivate.h" /* Plugin */
#include "H5PLpkg.h" /* Plugin */
#include "H5Zprivate.h" /* Filter pipeline */
/****************/
/* Local Macros */
/****************/
#define H5PL_MAX_PATH_NUM 16
#ifdef H5_HAVE_WIN32_API
#define H5PL_EXPAND_ENV_VAR { \
long bufCharCount; \
char *tempbuf; \
if(NULL == (tempbuf = (char *)H5MM_malloc(H5PL_EXPAND_BUFFER_SIZE))) \
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path") \
if((bufCharCount = ExpandEnvironmentStringsA(dl_path, tempbuf, H5PL_EXPAND_BUFFER_SIZE)) > H5PL_EXPAND_BUFFER_SIZE) { \
tempbuf = (char *)H5MM_xfree(tempbuf); \
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long") \
} \
if(bufCharCount == 0) { \
tempbuf = (char *)H5MM_xfree(tempbuf); \
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "failed to expand path") \
} \
dl_path = (char *)H5MM_xfree(dl_path); \
dl_path = tempbuf; \
}
#else
#define H5PL_EXPAND_ENV_VAR
#endif /* H5_HAVE_WIN32_API */
/****************************/
/* Macros for supporting
@ -389,6 +407,244 @@ done:
} /* end H5PL_load() */
/*-------------------------------------------------------------------------
* Function: H5PLappend
*
* Purpose: Insert a plugin path at the end of the list.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
herr_t
H5PLappend(const char* plugin_path)
{
herr_t ret_value = SUCCEED; /* Return value */
char *dl_path = NULL;
FUNC_ENTER_API(FAIL)
if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
if(NULL == plugin_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
if(NULL == (dl_path = H5MM_strdup(plugin_path)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
H5PL_EXPAND_ENV_VAR
H5PL_path_table_g[H5PL_num_paths_g] = dl_path;
H5PL_num_paths_g++;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLappend() */
/*-------------------------------------------------------------------------
* Function: H5PLprepend
*
* Purpose: Insert a plugin path at the beginning of the list.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
herr_t
H5PLprepend(const char* plugin_path)
{
herr_t ret_value = SUCCEED; /* Return value */
char *dl_path = NULL;
unsigned int plindex;
FUNC_ENTER_API(FAIL)
if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
if(NULL == plugin_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
if(NULL == (dl_path = H5MM_strdup(plugin_path)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
H5PL_EXPAND_ENV_VAR
for (plindex = (unsigned int)H5PL_num_paths_g; plindex > 0; plindex--)
H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex - 1];
H5PL_path_table_g[0] = dl_path;
H5PL_num_paths_g++;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLprepend() */
/*-------------------------------------------------------------------------
* Function: H5PLreplace
*
* Purpose: Replace the path at the specified index.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
herr_t
H5PLreplace(const char* plugin_path, unsigned int index)
{
herr_t ret_value = SUCCEED; /* Return value */
char *dl_path = NULL;
FUNC_ENTER_API(FAIL)
if(NULL == plugin_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
if(index >= H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "index path out of bounds for table")
if(NULL == (dl_path = H5MM_strdup(plugin_path)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
H5PL_EXPAND_ENV_VAR
if(H5PL_path_table_g[index])
H5PL_path_table_g[index] = (char *)H5MM_xfree(H5PL_path_table_g[index]);
H5PL_path_table_g[index] = dl_path;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLreplace() */
/*-------------------------------------------------------------------------
* Function: H5PLinsert
*
* Purpose: Insert a plugin path at the specified index, moving other paths after the index.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
herr_t
H5PLinsert(const char* plugin_path, unsigned int index)
{
herr_t ret_value = SUCCEED; /* Return value */
char *dl_path = NULL;
unsigned int plindex;
FUNC_ENTER_API(FAIL)
if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
if(NULL == plugin_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
if(index >= H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "index path out of bounds for table")
if(NULL == (dl_path = H5MM_strdup(plugin_path)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
H5PL_EXPAND_ENV_VAR
for(plindex = (unsigned int)H5PL_num_paths_g; plindex > index; plindex--)
H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex - 1];
H5PL_path_table_g[index] = dl_path;
H5PL_num_paths_g++;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLinsert() */
/*-------------------------------------------------------------------------
* Function: H5PLremove
*
* Purpose: Remove the plugin path at the specifed index and compacting the list.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
herr_t
H5PLremove(unsigned int index)
{
herr_t ret_value = SUCCEED; /* Return value */
unsigned int plindex;
FUNC_ENTER_API(FAIL)
if(H5PL_num_paths_g == 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "no directories in table")
if(index >= H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "index path out of bounds for table")
if(NULL == H5PL_path_table_g[index])
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no directory path at index")
H5PL_path_table_g[index] = (char *)H5MM_xfree(H5PL_path_table_g[index]);
H5PL_num_paths_g--;
for(plindex = index; plindex < (unsigned int)H5PL_num_paths_g; plindex++)
H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex + 1];
H5PL_path_table_g[H5PL_num_paths_g] = NULL;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLremove() */
/*-------------------------------------------------------------------------
* Function: H5PLget
*
* Purpose: Query the plugin path at the specified index.
*
* Return: Success: The length of path.
*
* If `pathname' is non-NULL then write up to `size' bytes into that
* buffer and always return the length of the pathname.
* Otherwise `size' is ignored and the function does not store the pathname,
* just returning the number of characters required to store the pathname.
* If an error occurs then the buffer pointed to by `pathname' (NULL or non-NULL)
* is unchanged and the function returns a negative value.
* If a zero is returned for the name's length, then there is no pathname
* associated with the index.
*
*-------------------------------------------------------------------------
*/
ssize_t
H5PLget(unsigned int index, char *pathname/*out*/, size_t size)
{
ssize_t ret_value = 0; /* Return value */
ssize_t len = 0; /* Length of pathname */
char *dl_path = NULL;
FUNC_ENTER_API(FAIL)
if(H5PL_num_paths_g == 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "no directories in table")
if(index >= H5PL_MAX_PATH_NUM)
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "index path out of bounds for table")
if(NULL == (dl_path = H5PL_path_table_g[index]))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no directory path at index")
len = HDstrlen(dl_path);
if(pathname) {
HDstrncpy(pathname, dl_path, MIN((size_t)(len + 1), size));
if((size_t)len >= size)
pathname[size - 1] = '\0';
} /* end if */
/* Set return value */
ret_value = len;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5PLget() */
/*-------------------------------------------------------------------------
* Function: H5PLsize
*
* Purpose: Query the size of the current list of plugin paths.
*
* Return: Non-negative or success.
*
*-------------------------------------------------------------------------
*/
unsigned int
H5PLsize(void)
{
return (unsigned int)H5PL_num_paths_g;
} /* end H5PLsize() */
/*-------------------------------------------------------------------------
* Function: H5PL__init_path_table
*
@ -422,25 +678,7 @@ H5PL__init_path_table(void)
if(NULL == dl_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
#ifdef H5_HAVE_WIN32_API
else { /* Expand windows env var*/
long bufCharCount;
char *tempbuf;
if(NULL == (tempbuf = (char *)H5MM_malloc(H5PL_EXPAND_BUFFER_SIZE)))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path")
if((bufCharCount = ExpandEnvironmentStrings(dl_path, tempbuf, H5PL_EXPAND_BUFFER_SIZE)) > H5PL_EXPAND_BUFFER_SIZE) {
tempbuf = (char *)H5MM_xfree(tempbuf);
HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long")
}
if(bufCharCount == 0) {
tempbuf = (char *)H5MM_xfree(tempbuf);
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "failed to expand path")
}
dl_path = (char *)H5MM_xfree(dl_path);
dl_path = H5MM_strdup(tempbuf);
tempbuf = (char *)H5MM_xfree(tempbuf);
}
#endif /* H5_HAVE_WIN32_API */
H5PL_EXPAND_ENV_VAR
/* Put paths in the path table. They are separated by ":" */
dir = HDstrtok(dl_path, H5PL_PATH_SEPARATOR);

50
src/H5PLpkg.h Normal file
View File

@ -0,0 +1,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if !(defined H5PL_FRIEND || defined H5PL_MODULE)
#error "Do not include this file outside the H5PL package!"
#endif
#ifndef _H5PLpkg_H
#define _H5PLpkg_H
/* Include private header file */
#include "H5PLprivate.h" /* Filter functions */
/* Other private headers needed by this file */
/**************************/
/* Package Private Macros */
/**************************/
#define H5PL_MAX_PATH_NUM 16
/****************************/
/* Package Private Typedefs */
/****************************/
/*****************************/
/* Package Private Variables */
/*****************************/
/******************************/
/* Package Private Prototypes */
/******************************/
#endif /* _H5PLpkg_H */

View File

@ -44,6 +44,13 @@ extern "C" {
/* plugin state */
H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_type);
H5_DLL herr_t H5PLget_loading_state(unsigned int* plugin_type/*out*/);
H5_DLL herr_t H5PLappend(const char* plugin_path);
H5_DLL herr_t H5PLprepend(const char* plugin_path);
H5_DLL herr_t H5PLreplace(const char* plugin_path, unsigned int index);
H5_DLL herr_t H5PLinsert(const char* plugin_path, unsigned int index);
H5_DLL herr_t H5PLremove(unsigned int index);
H5_DLL ssize_t H5PLget(unsigned int index, char *pathname/*out*/, size_t size);
H5_DLL unsigned int H5PLsize(void);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff