summaryrefslogtreecommitdiffstats
path: root/test/dynlib3.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:12:20 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-04-02 16:12:20 (GMT)
commitb8c258a9700e6633b681891794458e57598d55ae (patch)
tree0ef6436d1bcbaedd58401495488fb6a033750d04 /test/dynlib3.c
parentfc4c7a05f644fe1183bf8e7944dd7f66c9eb9e85 (diff)
downloadhdf5-b8c258a9700e6633b681891794458e57598d55ae.zip
hdf5-b8c258a9700e6633b681891794458e57598d55ae.tar.gz
hdf5-b8c258a9700e6633b681891794458e57598d55ae.tar.bz2
[svn-r23519] I used H5Gcreate instead of H5Gcreate2 in plugin.c. I corrected it and added some real operation in the dummy filter library dynlib3.c.
Tested on jam and koala.
Diffstat (limited to 'test/dynlib3.c')
-rw-r--r--test/dynlib3.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/test/dynlib3.c b/test/dynlib3.c
index d1c57d2..e040052 100644
--- a/test/dynlib3.c
+++ b/test/dynlib3.c
@@ -22,9 +22,12 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <hdf5.h>
#define H5Z_FILTER_DYNLIB3 259
+#define SUFFIX_LEN 8
+#define GROUP_SUFFIX ".h5group"
static size_t H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
@@ -46,16 +49,15 @@ const H5Z_class2_t* H5PL_get_plugin_info(void) {return H5Z_DYNLIB3;}
/*-------------------------------------------------------------------------
* Function: H5Z_filter_dynlib3
*
- * Purpose: A dynlib3 filter method that adds on and subtract from
- * the original value with another value. It will be built
- * as a shared library. plugin.c test will load and use
- * this filter library.
+ * Purpose: A dynlib3 filter method that is used to test groups. It
+ * appends the suffix ".h5group" to each group name during
+ * write and takes it out during read.
*
* Return: Success: Data chunk size
*
* Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Raymond Lu
* 1 April 2013
*
*-------------------------------------------------------------------------
@@ -65,19 +67,36 @@ H5Z_filter_dynlib3(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;
+ size_t ret_value; /* Return value */
/* Check for the correct number of parameters */
if(cd_nelmts>0)
return(0);
if(flags & H5Z_FLAG_REVERSE) { /*read*/
- ;
+ ret_value = *buf_size = nbytes - SUFFIX_LEN;
} else { /*write*/
- ;
+ void *outbuf = NULL; /* Pointer to new buffer */
+ unsigned char *dst; /* Temporary pointer to destination buffer */
+
+ dst=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);
+
+ /* Free input buffer */
+ free(*buf);
+
+ /* Set return values */
+ *buf_size = nbytes + SUFFIX_LEN;
+ *buf = outbuf;
+ outbuf = NULL;
+ ret_value = *buf_size;
} /* end else */
- return nbytes;
+ return ret_value;
}