mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-24 15:25:00 +08:00
[svn-r23549] Description:
More misc. cleanups, but main change is to make an "extern" header file for the plugin interface. Tested on: Mac OSX/64 10.8.3 (amazon)
This commit is contained in:
parent
70e0f8e200
commit
8277409a9b
2
MANIFEST
2
MANIFEST
@ -851,7 +851,7 @@
|
||||
./src/H5Ptest.c
|
||||
./src/H5PL.c
|
||||
./src/H5PLprivate.h
|
||||
./src/H5PLpublic.h
|
||||
./src/H5PLextern.h
|
||||
./src/H5R.c
|
||||
./src/H5Rdeprec.c
|
||||
./src/H5Rpkg.h
|
||||
|
@ -482,7 +482,7 @@ SET (H5PL_SRCS
|
||||
)
|
||||
|
||||
SET (H5PL_HDRS
|
||||
${HDF5_SRC_DIR}/H5PLpublic.h
|
||||
${HDF5_SRC_DIR}/H5PLextern.h
|
||||
)
|
||||
IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SRCS}" )
|
||||
|
||||
|
58
src/H5PL.c
58
src/H5PL.c
@ -61,7 +61,7 @@
|
||||
/* Clear error - nothing to do */
|
||||
#define H5PL_CLR_ERROR
|
||||
|
||||
typedef const H5Z_class2_t *(__cdecl *H5PL_get_filter_info_t)(void);
|
||||
typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void);
|
||||
|
||||
/* Unix support */
|
||||
#else /* H5_HAVE_WIN32_API */
|
||||
@ -84,7 +84,7 @@ typedef const H5Z_class2_t *(__cdecl *H5PL_get_filter_info_t)(void);
|
||||
/* Clear error */
|
||||
#define H5PL_CLR_ERROR dlerror()
|
||||
|
||||
typedef const H5Z_class2_t *(*H5PL_get_filter_info_t)(void);
|
||||
typedef const void *(*H5PL_get_plugin_info_t)(void);
|
||||
#endif /* H5_HAVE_WIN32_API */
|
||||
|
||||
/* Special symbol to indicate no plugin loading */
|
||||
@ -107,9 +107,9 @@ typedef struct H5PL_table_t {
|
||||
/********************/
|
||||
|
||||
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 htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info);
|
||||
static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, const void **pl_info);
|
||||
static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info);
|
||||
static herr_t H5PL__close(H5PL_HANDLE handle);
|
||||
|
||||
|
||||
@ -193,7 +193,7 @@ H5PL_no_plugin(void)
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
|
||||
ret_value = H5PL_no_plugin_g;
|
||||
ret_value = (htri_t)H5PL_no_plugin_g;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -264,12 +264,12 @@ H5PL_term_interface(void)
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
const void *
|
||||
H5PL_load(H5PL_type_t type, int id)
|
||||
{
|
||||
htri_t found; /* Whether the plugin was found */
|
||||
H5Z_class2_t *plugin_info = NULL;
|
||||
void *ret_value = NULL;
|
||||
htri_t found; /* Whether the plugin was found */
|
||||
const void *plugin_info = NULL;
|
||||
const void *ret_value = NULL;
|
||||
|
||||
FUNC_ENTER_NOAPI(NULL)
|
||||
|
||||
@ -281,7 +281,7 @@ H5PL_load(H5PL_type_t type, int id)
|
||||
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINIT, NULL, "can't initialize search path table")
|
||||
|
||||
/* Search in the table of already loaded plugin libraries */
|
||||
if((found = H5PL__search_table(type, id, (void **)&plugin_info)) < 0)
|
||||
if((found = H5PL__search_table(type, id, &plugin_info)) < 0)
|
||||
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in table failed")
|
||||
|
||||
/* If not found, iterate through the path table to find the right dynamic library */
|
||||
@ -289,7 +289,7 @@ H5PL_load(H5PL_type_t type, int id)
|
||||
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)
|
||||
if((found = H5PL__find(type, id, H5PL_path_table_g[i], &plugin_info)) < 0)
|
||||
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in paths failed")
|
||||
|
||||
/* Break out if found */
|
||||
@ -383,7 +383,7 @@ done:
|
||||
*/
|
||||
#ifndef H5_HAVE_WIN32_API
|
||||
static htri_t
|
||||
H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
|
||||
H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info)
|
||||
{
|
||||
char *pathname = NULL;
|
||||
DIR *dirp = NULL;
|
||||
@ -445,7 +445,7 @@ done:
|
||||
} /* end H5PL__find() */
|
||||
#else /* H5_HAVE_WIN32_API */
|
||||
static htri_t
|
||||
H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, void **info)
|
||||
H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info)
|
||||
{
|
||||
WIN32_FIND_DATA fdFile;
|
||||
HANDLE hFind;
|
||||
@ -518,7 +518,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static htri_t
|
||||
H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, void **pl_info)
|
||||
H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const void **pl_info)
|
||||
{
|
||||
H5PL_HANDLE handle = NULL;
|
||||
htri_t ret_value = FALSE;
|
||||
@ -532,22 +532,22 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, void **pl_info)
|
||||
H5PL_CLR_ERROR; /* clear error */
|
||||
} /* end if */
|
||||
else {
|
||||
H5PL_get_filter_info_t get_plugin_info = NULL;
|
||||
H5PL_get_plugin_info_t get_plugin_info = NULL;
|
||||
|
||||
/* Return a handle for the function H5PL_get_plugin_info in the dynamic library.
|
||||
/* Return a handle for the function H5PLget_plugin_info in the dynamic library.
|
||||
* The plugin library is suppose to define this function.
|
||||
*/
|
||||
if(NULL == (get_plugin_info = (H5PL_get_filter_info_t)H5PL_GET_LIB_FUNC(handle, "H5PL_get_plugin_info"))) {
|
||||
if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_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;
|
||||
const H5Z_class2_t *plugin_info;
|
||||
|
||||
/* Invoke H5PL_get_plugin_info to verify this is the right library we are looking for.
|
||||
/* Invoke H5PLget_plugin_info to verify this is the right library we are looking for.
|
||||
* Move on if it isn't.
|
||||
*/
|
||||
if(NULL == (plugin_info = (*get_plugin_info)())) {
|
||||
if(NULL == (plugin_info = (const H5Z_class2_t *)(*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")
|
||||
@ -573,7 +573,7 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, void **pl_info)
|
||||
H5PL_table_used_g++;
|
||||
|
||||
/* Set the plugin info to return */
|
||||
*pl_info = (void *)plugin_info;
|
||||
*pl_info = (const void *)plugin_info;
|
||||
|
||||
/* Indicate success */
|
||||
ret_value = TRUE;
|
||||
@ -605,7 +605,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static htri_t
|
||||
H5PL__search_table(H5PL_type_t plugin_type, int type_id, void **info)
|
||||
H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info)
|
||||
{
|
||||
htri_t ret_value = FALSE;
|
||||
|
||||
@ -617,16 +617,16 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, void **info)
|
||||
|
||||
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)) {
|
||||
H5PL_get_filter_info_t get_plugin_info;
|
||||
H5Z_class2_t *plugin_info;
|
||||
H5PL_get_plugin_info_t get_plugin_info;
|
||||
const H5Z_class2_t *plugin_info;
|
||||
|
||||
if(NULL == (get_plugin_info = (H5PL_get_filter_info_t)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 == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PLget_plugin_info")))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info")
|
||||
|
||||
if(NULL == (plugin_info = (*get_plugin_info)()))
|
||||
if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)()))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info")
|
||||
|
||||
*info = (void *)plugin_info;
|
||||
*info = plugin_info;
|
||||
HGOTO_DONE(TRUE)
|
||||
} /* end if */
|
||||
} /* end for */
|
||||
|
@ -16,22 +16,21 @@
|
||||
* Programmer: Raymond Lu <songyulu@hdfgroup.org>
|
||||
* 13 February 2013
|
||||
*/
|
||||
#ifndef _H5PLpublic_H
|
||||
#define _H5PLpublic_H
|
||||
#ifndef _H5PLextern_H
|
||||
#define _H5PLextern_H
|
||||
|
||||
/* Public headers needed by this file */
|
||||
#include "H5Zpublic.h"
|
||||
/* Include HDF5 header */
|
||||
#include "hdf5.h"
|
||||
|
||||
/****************************/
|
||||
/* Library Public Typedefs */
|
||||
/****************************/
|
||||
/*******************/
|
||||
/* Public Typedefs */
|
||||
/*******************/
|
||||
|
||||
/* Plugin type */
|
||||
typedef enum H5PL_type_t {
|
||||
H5PL_TYPE_ERROR = -1, /*error */
|
||||
H5PL_TYPE_FILTER = 0, /*filter */
|
||||
H5PL_TYPE_VFD = 1, /*virtual file driver */
|
||||
H5PL_TYPE_NONE = 2 /*this must be last! */
|
||||
H5PL_TYPE_NONE = 1 /*this must be last! */
|
||||
} H5PL_type_t;
|
||||
|
||||
|
||||
@ -74,11 +73,12 @@ typedef enum H5PL_type_t {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
H5PLUGIN_DLL H5PL_type_t H5PL_get_plugin_type(void);
|
||||
H5PLUGIN_DLL H5Z_class2_t* H5PL_get_plugin_info(void);
|
||||
H5PLUGIN_DLL H5PL_type_t H5PLget_plugin_type(void);
|
||||
H5PLUGIN_DLL const void *H5PLget_plugin_info(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _H5PLpublic_H */
|
||||
#endif /* _H5PLextern_H */
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef _H5PLprivate_H
|
||||
#define _H5PLprivate_H
|
||||
|
||||
/* Include package's public header */
|
||||
#include "H5PLpublic.h"
|
||||
/* Include package's "external" header */
|
||||
#include "H5PLextern.h"
|
||||
|
||||
/* Private headers needed by this file */
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
@ -46,7 +46,8 @@
|
||||
/***************************************/
|
||||
|
||||
/* Internal API routines */
|
||||
H5_DLL void *H5PL_load(H5PL_type_t plugin_type, int type_id);
|
||||
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 */
|
||||
|
||||
|
@ -752,7 +752,6 @@ 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 */
|
||||
|
||||
FUNC_ENTER_API(FAIL)
|
||||
@ -830,9 +829,9 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
|
||||
|
||||
/* If filter is not available, try to dynamically load it */
|
||||
if(!filter_avail) {
|
||||
H5Z_class2_t *filter_info;
|
||||
const H5Z_class2_t *filter_info;
|
||||
|
||||
if(NULL == (filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter)))
|
||||
if(NULL == (filter_info = (const 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")
|
||||
|
@ -1126,10 +1126,10 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
|
||||
if(H5PL_no_plugin())
|
||||
issue_error = TRUE;
|
||||
else {
|
||||
H5Z_class2_t *filter_info;
|
||||
const H5Z_class2_t *filter_info;
|
||||
|
||||
/* Try loading the filter */
|
||||
if(NULL != (filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) {
|
||||
if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) {
|
||||
/* Register the filter we loaded */
|
||||
if(H5Z_register(filter_info) < 0)
|
||||
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
|
||||
|
@ -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 \
|
||||
H5PLpublic.h \
|
||||
H5PLextern.h \
|
||||
H5Rpublic.h H5Spublic.h \
|
||||
H5Tpublic.h H5Zpublic.h
|
||||
|
||||
|
@ -616,7 +616,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 \
|
||||
H5PLpublic.h \
|
||||
H5PLextern.h \
|
||||
H5Rpublic.h H5Spublic.h \
|
||||
H5Tpublic.h H5Zpublic.h
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "H5MMpublic.h" /* Memory management */
|
||||
#include "H5Opublic.h" /* Object headers */
|
||||
#include "H5Ppublic.h" /* Property lists */
|
||||
#include "H5PLpublic.h" /* Plugin */
|
||||
#include "H5Rpublic.h" /* References */
|
||||
#include "H5Spublic.h" /* Dataspaces */
|
||||
#include "H5Tpublic.h" /* Datatypes */
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5PLextern.h"
|
||||
|
||||
#define H5Z_FILTER_DYNLIB1 257
|
||||
|
||||
@ -38,8 +38,8 @@ const H5Z_class2_t H5Z_DYNLIB1[1] = {{
|
||||
(H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */
|
||||
}};
|
||||
|
||||
H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB1;}
|
||||
H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Z_filter_dynlib1
|
||||
@ -63,34 +63,35 @@ H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts,
|
||||
const unsigned int *cd_values, size_t nbytes,
|
||||
size_t *buf_size, void **buf)
|
||||
{
|
||||
int *int_ptr=(int *)*buf; /* Pointer to the data values */
|
||||
size_t buf_left=*buf_size; /* Amount of data buffer left to process */
|
||||
int add_on = 0;
|
||||
int *int_ptr = (int *)*buf; /* Pointer to the data values */
|
||||
size_t buf_left = *buf_size; /* Amount of data buffer left to process */
|
||||
int add_on = 0;
|
||||
|
||||
/* Check for the correct number of parameters */
|
||||
if(cd_nelmts==0)
|
||||
if(cd_nelmts == 0)
|
||||
return(0);
|
||||
|
||||
/* Check that permanent parameters are set correctly */
|
||||
if(cd_values[0]<0 || cd_values[0]>9)
|
||||
if(cd_values[0] > 9)
|
||||
return(0);
|
||||
|
||||
add_on = cd_values[0];
|
||||
add_on = (int)cd_values[0];
|
||||
|
||||
if(flags & H5Z_FLAG_REVERSE) { /*read*/
|
||||
/* Substract the "add on" value to all the data values */
|
||||
while(buf_left>0) {
|
||||
while(buf_left > 0) {
|
||||
*int_ptr++ -= add_on;
|
||||
buf_left -= sizeof(int);
|
||||
} /* end while */
|
||||
} /* end if */
|
||||
else { /*write*/
|
||||
/* Add the "add on" value to all the data values */
|
||||
while(buf_left>0) {
|
||||
while(buf_left > 0) {
|
||||
*int_ptr++ += add_on;
|
||||
buf_left -= sizeof(int);
|
||||
} /* end while */
|
||||
} /* end else */
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
} /* end H5Z_filter_dynlib1() */
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5PLextern.h"
|
||||
|
||||
#define H5Z_FILTER_DYNLIB2 258
|
||||
#define MULTIPLIER 3
|
||||
@ -39,8 +39,8 @@ const H5Z_class2_t H5Z_DYNLIB2[1] = {{
|
||||
(H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */
|
||||
}};
|
||||
|
||||
H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB2;}
|
||||
H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB2;}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Z_filter_dynlib2
|
||||
@ -64,29 +64,28 @@ H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts,
|
||||
const unsigned int *cd_values, size_t nbytes,
|
||||
size_t *buf_size, void **buf)
|
||||
{
|
||||
int *int_ptr=(int *)*buf; /* Pointer to the data values */
|
||||
size_t buf_left=*buf_size; /* Amount of data buffer left to process */
|
||||
int *int_ptr = (int *)*buf; /* Pointer to the data values */
|
||||
size_t buf_left = *buf_size; /* Amount of data buffer left to process */
|
||||
|
||||
/* Check for the correct number of parameters */
|
||||
if(cd_nelmts>0)
|
||||
if(cd_nelmts > 0)
|
||||
return(0);
|
||||
|
||||
if(flags & H5Z_FLAG_REVERSE) { /*read*/
|
||||
/* Divide the original value with MULTIPLIER */
|
||||
while(buf_left>0) {
|
||||
*int_ptr /= MULTIPLIER;
|
||||
*int_ptr++;
|
||||
while(buf_left > 0) {
|
||||
*int_ptr++ /= MULTIPLIER;
|
||||
buf_left -= sizeof(int);
|
||||
} /* end while */
|
||||
} /* end if */
|
||||
else { /*write*/
|
||||
/* Multiply the original value with MULTIPLIER */
|
||||
while(buf_left>0) {
|
||||
*int_ptr *= MULTIPLIER;
|
||||
*int_ptr++;
|
||||
while(buf_left > 0) {
|
||||
*int_ptr++ *= MULTIPLIER;
|
||||
buf_left -= sizeof(int);
|
||||
} /* end while */
|
||||
} /* end else */
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
} /* end H5Z_filter_dynlib2() */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5PLextern.h"
|
||||
|
||||
#define H5Z_FILTER_DYNLIB3 259
|
||||
#define SUFFIX_LEN 8
|
||||
@ -41,8 +41,8 @@ const H5Z_class2_t H5Z_DYNLIB3[1] = {{
|
||||
(H5Z_func_t)H5Z_filter_dynlib3, /* The actual filter function */
|
||||
}};
|
||||
|
||||
H5PL_type_t H5PL_get_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB3;}
|
||||
H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
|
||||
const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB3;}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Z_filter_dynlib3
|
||||
@ -68,23 +68,24 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts,
|
||||
size_t ret_value; /* Return value */
|
||||
|
||||
/* Check for the correct number of parameters */
|
||||
if(cd_nelmts>0)
|
||||
if(cd_nelmts > 0)
|
||||
return(0);
|
||||
|
||||
if(flags & H5Z_FLAG_REVERSE) { /*read*/
|
||||
ret_value = *buf_size = nbytes - SUFFIX_LEN;
|
||||
} else { /*write*/
|
||||
} /* end if */
|
||||
else { /*write*/
|
||||
void *outbuf = NULL; /* Pointer to new buffer */
|
||||
unsigned char *dst; /* Temporary pointer to destination buffer */
|
||||
|
||||
dst=outbuf=malloc(nbytes+SUFFIX_LEN);
|
||||
dst = (unsigned char *)(outbuf = malloc(nbytes + SUFFIX_LEN));
|
||||
|
||||
/* Copy raw data */
|
||||
memcpy((void*)dst, (void*)(*buf), nbytes);
|
||||
|
||||
/* Append suffix to raw data for storage */
|
||||
dst += nbytes;
|
||||
memcpy((void*)dst, (void*)GROUP_SUFFIX, SUFFIX_LEN);
|
||||
memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN);
|
||||
|
||||
/* Free input buffer */
|
||||
free(*buf);
|
||||
@ -97,4 +98,5 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts,
|
||||
} /* end else */
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
} /* H5Z_filter_dynlib3() */
|
||||
|
||||
|
@ -34,9 +34,6 @@
|
||||
#define H5Z_FILTER_DYNLIB2 258
|
||||
#define H5Z_FILTER_DYNLIB3 259
|
||||
|
||||
/* Bzip2 filter */
|
||||
#define H5Z_FILTER_BZIP2 307
|
||||
|
||||
const char *FILENAME[] = {
|
||||
"plugin",
|
||||
NULL
|
||||
@ -45,7 +42,6 @@ const char *FILENAME[] = {
|
||||
|
||||
/* Dataset names for testing filters */
|
||||
#define DSET_DEFLATE_NAME "deflate"
|
||||
#define DSET_BZIP2_NAME "bzip2"
|
||||
#define DSET_DYNLIB1_NAME "dynlib1"
|
||||
#define DSET_DYNLIB2_NAME "dynlib2"
|
||||
|
||||
@ -156,7 +152,8 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
*/
|
||||
TESTING(" filters (write)");
|
||||
|
||||
for(i=n=0; i<size[0]; i++) {
|
||||
n = 0;
|
||||
for(i=0; i<size[0]; i++) {
|
||||
for(j=0; j<size[1]; j++) {
|
||||
points[i][j] = (int)(n++);
|
||||
}
|
||||
@ -309,8 +306,6 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
|
||||
points_dynlib1[i][j] = points[i][j];
|
||||
} else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) {
|
||||
points_dynlib2[i][j] = points[i][j];
|
||||
} else if(!HDstrcmp(name, DSET_BZIP2_NAME)) {
|
||||
points_bzip2[i][j] = points[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -344,7 +339,7 @@ error:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filters_for_datasets(hid_t file, hid_t fapl)
|
||||
test_filters_for_datasets(hid_t file)
|
||||
{
|
||||
hid_t dc; /* Dataset creation property list ID */
|
||||
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
|
||||
@ -474,7 +469,7 @@ error:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_read_with_filters(hid_t file, hid_t fapl)
|
||||
test_read_with_filters(hid_t file)
|
||||
{
|
||||
hid_t dset; /* Dataset ID */
|
||||
|
||||
@ -489,7 +484,7 @@ test_read_with_filters(hid_t file, hid_t fapl)
|
||||
|
||||
if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
if(test_read_data(dset, points_deflate) < 0) TEST_ERROR
|
||||
if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR
|
||||
|
||||
if(H5Dclose(dset) < 0) TEST_ERROR
|
||||
|
||||
@ -508,7 +503,7 @@ test_read_with_filters(hid_t file, hid_t fapl)
|
||||
|
||||
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
if(test_read_data(dset, points_dynlib1) < 0) TEST_ERROR
|
||||
if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR
|
||||
|
||||
if(H5Dclose(dset) < 0) TEST_ERROR
|
||||
|
||||
@ -520,7 +515,7 @@ test_read_with_filters(hid_t file, hid_t fapl)
|
||||
|
||||
if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
if(test_read_data(dset, points_dynlib2) < 0) TEST_ERROR
|
||||
if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR
|
||||
|
||||
if(H5Dclose(dset) < 0) TEST_ERROR
|
||||
|
||||
@ -544,7 +539,7 @@ error:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_filters_for_groups(hid_t file, hid_t fapl)
|
||||
test_filters_for_groups(hid_t file)
|
||||
{
|
||||
hid_t gcpl, gid, group;
|
||||
int i;
|
||||
@ -595,9 +590,9 @@ error:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_groups_with_filters(hid_t file, hid_t fapl)
|
||||
test_groups_with_filters(hid_t file)
|
||||
{
|
||||
hid_t gcpl, gid, group;
|
||||
hid_t gid, group;
|
||||
int i;
|
||||
char gname[256];
|
||||
|
||||
@ -689,10 +684,10 @@ main(void)
|
||||
TEST_ERROR
|
||||
|
||||
/* Test dynamically loaded filters for chunked dataset */
|
||||
nerrors += (test_filters_for_datasets(file, my_fapl) < 0 ? 1 : 0);
|
||||
nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0);
|
||||
|
||||
/* Test dynamically loaded filters for groups */
|
||||
nerrors += (test_filters_for_groups(file, my_fapl) < 0 ? 1 : 0);
|
||||
nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0);
|
||||
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR
|
||||
@ -713,10 +708,10 @@ main(void)
|
||||
TEST_ERROR
|
||||
|
||||
/* Read the data with filters */
|
||||
nerrors += (test_read_with_filters(file, fapl) < 0 ? 1 : 0);
|
||||
nerrors += (test_read_with_filters(file) < 0 ? 1 : 0);
|
||||
|
||||
/* Open the groups with filters */
|
||||
nerrors += (test_groups_with_filters(file, fapl) < 0 ? 1 : 0);
|
||||
nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0);
|
||||
|
||||
if(H5Fclose(file) < 0)
|
||||
TEST_ERROR
|
||||
|
Loading…
Reference in New Issue
Block a user