summaryrefslogtreecommitdiffstats
path: root/src/H5PLpkg.h
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-03-15 21:25:30 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-03-15 21:25:30 (GMT)
commitf6f202dc71e0837c2bb721cb8fc8c6dd6ddded3a (patch)
tree612841344942f5f35baef5964c9405be6b7e94aa /src/H5PLpkg.h
parent7f44286aa57f7b67c47608022c1a48dfd71c98ad (diff)
downloadhdf5-f6f202dc71e0837c2bb721cb8fc8c6dd6ddded3a.zip
hdf5-f6f202dc71e0837c2bb721cb8fc8c6dd6ddded3a.tar.gz
hdf5-f6f202dc71e0837c2bb721cb8fc8c6dd6ddded3a.tar.bz2
[svn-r23359] I added some macros and refactoring the code to prepare for Windows support.
Tested on koala.
Diffstat (limited to 'src/H5PLpkg.h')
-rw-r--r--src/H5PLpkg.h71
1 files changed, 68 insertions, 3 deletions
diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h
index dae4c59..6ab0aa9 100644
--- a/src/H5PLpkg.h
+++ b/src/H5PLpkg.h
@@ -26,6 +26,69 @@
#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 H5PLG_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_ERR dlerror()
+
+/* Print error message */
+#define H5PL_CHECK_ERR(R) { \
+ if(R==NULL) { \
+ error = dlerror(); \
+ } \
+ else error = NULL; \
+}
+
+#endif
+
+/****************************/
/* Local typedefs */
/****************************/
@@ -33,7 +96,7 @@
typedef struct H5PL_table_t {
H5PL_type_t pl_type; /* plugin type */
int pl_id; /* ID for the plugin */
- void *handle; /* plugin handle */
+ H5PL_HANDLE handle; /* plugin handle */
} H5PL_table_t;
/****************************/
@@ -55,8 +118,10 @@ static htri_t path_found = FALSE;
/******************************/
/* Function prototypes for H5PL package scope */
-htri_t H5PL_find(H5PL_type_t plugin_type, int type_id, char *dir, void **info);
-htri_t H5PL_search_table(H5PL_type_t plugin_type, int type_id, void **info);
+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 */