diff options
Diffstat (limited to 'src/H5Z.c')
-rw-r--r-- | src/H5Z.c | 89 |
1 files changed, 72 insertions, 17 deletions
@@ -26,6 +26,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ +#include "H5PLprivate.h" /* Plugins */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5Zpkg.h" /* Data filters */ @@ -450,7 +451,6 @@ done: htri_t H5Zfilter_avail(H5Z_filter_t id) { - size_t i; /* Local index variable */ htri_t ret_value=FALSE; /* Return value */ FUNC_ENTER_API(FAIL) @@ -459,13 +459,9 @@ H5Zfilter_avail(H5Z_filter_t 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 */ + + if((ret_value = H5Z_filter_avail(id)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter") done: FUNC_LEAVE_API(ret_value) @@ -473,6 +469,36 @@ done: /*------------------------------------------------------------------------- + * Function: H5Z_filter_avail + * + * Purpose: Private function to check if a filter is available + * + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * + * Programmer: Raymond Lu + * 13 February 2013 + * + *------------------------------------------------------------------------- + */ +htri_t +H5Z_filter_avail(H5Z_filter_t id) +{ + size_t i; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Is the filter already registered? */ + for(i = 0; i < H5Z_table_used_g; i++) + if(H5Z_table_g[i].id == id) + HGOTO_DONE(TRUE) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Z_filter_avail() */ + + +/*------------------------------------------------------------------------- * Function: H5Z_prelude_callback * * Purpose: Makes a dataset creation "prelude" callback for the "can_apply" @@ -1088,16 +1114,45 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, failed |= (unsigned)1 << idx; continue;/*filter excluded*/ } - if ((fclass_idx=H5Z_find_idx(pline->filter[idx].id))<0) { - /* Print out the filter name to give more info. But the name is optional for - * the filter */ - if(pline->filter[idx].name) - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", - pline->filter[idx].name) - else - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered") - } + /* If the filter isn't registered and the application doesn't + * indicate no plugin through HDF5_PRELOAD_PLUG (using the symbol "::"), + * try to load it dynamically and register it. Otherwise, return failure + */ + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { + hbool_t issue_error = FALSE; + + /* Check for "no plugins" indicated" */ + if(H5PL_no_plugin()) + issue_error = TRUE; + else { + const H5Z_class2_t *filter_info; + + /* Try loading the filter */ + 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") + + /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + issue_error = TRUE; + } /* end if */ + else + issue_error = TRUE; + } /* end else */ + + /* Check for error */ + if(issue_error) { + /* Print out the filter name to give more info. But the name is optional for + * the filter */ + if(pline->filter[idx].name) + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name) + else + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered") + } /* end if */ + } /* end if */ + fclass=&H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG fstats=&H5Z_stat_table_g[fclass_idx]; |