summaryrefslogtreecommitdiffstats
path: root/src/H5Z.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-11-20 13:15:18 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-11-20 13:15:18 (GMT)
commitac48a23e2b72b03d60d4fdf10957ed31beb5b70d (patch)
treeffa3319c694f416086419118f3fc3bc3b1e6fca1 /src/H5Z.c
parent892cc41777c9a104e49ad6d9bac21f085dba6b95 (diff)
downloadhdf5-ac48a23e2b72b03d60d4fdf10957ed31beb5b70d.zip
hdf5-ac48a23e2b72b03d60d4fdf10957ed31beb5b70d.tar.gz
hdf5-ac48a23e2b72b03d60d4fdf10957ed31beb5b70d.tar.bz2
[svn-r6114] Purpose:
Code Cleanup & New Feature Description: H5config.h.in: Removed H5_HAVE_COMPRESSION & H5_HAVE_FILTER_GZIP flags. Added H5_HAVE_FILTER_DEFLATE flag. H5Z.c: H5Zprivate.h: H5Zpublic.h: Switched from using H5_HAVE_COMPRESSION flag in favor of H5_HAVE_FILTER_DEFLATE. Added H5Zunregister & H5Zfilter_avail API functions. Changed a numeric constant (256) to a symbolic constant (H5Z_FILTER_RESERVED). Automatically add the shuffling filter to the list of available filters (when it is enabled). Moved prototypes for H5Z_filter_deflate & H5Z_filter_shuffle from the public header into the private header. H5Zdeflate.c: Switched from using H5_HAVE_COMPRESSION & H5_HAVE_FILTER_GZIP flags in favor of H5_HAVE_FILTER_DEFLATE. Cleaned up formatting & error reporting a bit. H5Zshuffle.c: Rewrote shuffling algorithm to be more efficient. Added error checking & reporting. Added standard Pablo information. Added standard function header comment. Added FUNC_ENTER & FUNC_LEAVE macros. Platforms tested: Tested h5committest {arabica (fortran), eirene (fortran, C++) modi4 (parallel, fortran)} FreeBSD 4.7 (sleipnir)
Diffstat (limited to 'src/H5Z.c')
-rw-r--r--src/H5Z.c133
1 files changed, 129 insertions, 4 deletions
diff --git a/src/H5Z.c b/src/H5Z.c
index 4016481..9c240c3 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -19,10 +19,12 @@
static int interface_initialize_g = 0;
static herr_t H5Z_init_interface (void);
+/* Local variables */
static size_t H5Z_table_alloc_g = 0;
static size_t H5Z_table_used_g = 0;
static H5Z_class_t *H5Z_table_g = NULL;
+/* Local functions */
/*-------------------------------------------------------------------------
@@ -44,9 +46,12 @@ H5Z_init_interface (void)
{
FUNC_ENTER_NOINIT(H5Z_init_interface);
-#ifdef H5_HAVE_FILTER_GZIP
+#ifdef H5_HAVE_FILTER_DEFLATE
H5Z_register (H5Z_FILTER_DEFLATE, "deflate", H5Z_filter_deflate);
-#endif /* H5_HAVE_FILTER_GZIP */
+#endif /* H5_HAVE_FILTER_DEFLATE */
+#ifdef H5_HAVE_FILTER_SHUFFLE
+ H5Z_register (H5Z_FILTER_SHUFFLE, "shuffle", H5Z_filter_shuffle);
+#endif /* H5_HAVE_FILTER_SHUFFLE */
FUNC_LEAVE (SUCCEED);
}
@@ -162,7 +167,7 @@ H5Zregister(H5Z_filter_t id, const char *comment, H5Z_func_t func)
/* Check args */
if (id<0 || id>H5Z_FILTER_MAX)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number");
- if (id<256)
+ if (id<H5Z_FILTER_RESERVED)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters");
if (!func)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no function specified");
@@ -180,7 +185,7 @@ done:
* Function: H5Z_register
*
* Purpose: Same as the public version except this one allows filters
- * to be set for predefined method numbers <256
+ * to be set for predefined method numbers <H5Z_FILTER_RESERVED
*
* Return: Non-negative on success/Negative on failure
*
@@ -235,6 +240,126 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Zunregister
+ *
+ * Purpose: This function unregisters a filter.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 14, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Zunregister(H5Z_filter_t id)
+{
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Zunregister, FAIL);
+ H5TRACE1("e","Zf",id);
+
+ /* Check args */
+ if (id<0 || id>H5Z_FILTER_MAX)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number");
+ if (id<H5Z_FILTER_RESERVED)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters");
+
+ /* Do it */
+ if (H5Z_unregister (id)<0)
+ HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter");
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* end H5Zunregister() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Z_unregister
+ *
+ * Purpose: Same as the public version except this one allows filters
+ * to be unset for predefined method numbers <H5Z_FILTER_RESERVED
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 14, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Z_unregister (H5Z_filter_t id)
+{
+ size_t i; /* Local index variable */
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOINIT(H5Z_unregister);
+
+ assert (id>=0 && id<=H5Z_FILTER_MAX);
+
+ /* Is the filter already registered? */
+ for (i=0; i<H5Z_table_used_g; i++)
+ if (H5Z_table_g[i].id==id)
+ break;
+
+ /* Fail if filter not found */
+ if (i>=H5Z_table_used_g)
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered");
+
+ /* Remove filter from table */
+ /* Don't worry about shrinking table size (for now) */
+ HDmemmove(&H5Z_table_g[i],&H5Z_table_g[i+1],sizeof(H5Z_class_t)*((H5Z_table_used_g-1)-i));
+ H5Z_table_used_g--;
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* end H5Z_unregister() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Zfilter_avail
+ *
+ * Purpose: Check if a filter is available
+ *
+ * Return: Non-negative (TRUE/FALSE) on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 14, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5Zfilter_avail(H5Z_filter_t id)
+{
+ size_t i; /* Local index variable */
+ htri_t ret_value=FALSE; /* Return value */
+
+ FUNC_ENTER_API(H5Zfilter_avail, FAIL);
+ H5TRACE1("b","Zf",id);
+
+ /* Check args */
+ if(id<0 || id>H5Z_FILTER_MAX)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number");
+
+ /* 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 */
+
+done:
+ FUNC_LEAVE (ret_value);
+} /* end H5Zfilter_avail() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Z_append
*
* Purpose: Append another filter to the specified pipeline.