From dc1343a0d3300ae537adbdc4c0b8f342f37e09e4 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Fri, 18 May 2012 15:44:39 -0500 Subject: [svn-r22380] - attribute and object exist callbacks should be part of get structs - fix bug in passing req parameter - free location in H5Rdereference - add datatype close callback - H5VL_CREATE_LINK_XXX should be H5VL_LINK_CREATE_XXX --- src/H5A.c | 8 +++- src/H5Gdeprec.c | 8 ++-- src/H5L.c | 6 +-- src/H5Lexternal.c | 2 +- src/H5O.c | 4 +- src/H5R.c | 4 ++ src/H5T.c | 2 +- src/H5VL.c | 77 +++++++++++++++++++++++++++------- src/H5VLdummy.c | 3 +- src/H5VLnative.c | 121 +++++++++++++++++++++++++++++++----------------------- src/H5VLprivate.h | 1 + src/H5VLpublic.h | 33 +++++++-------- 12 files changed, 172 insertions(+), 97 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 6cc3682..3017e7f 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -251,6 +251,10 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -2576,7 +2580,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* get the attribute info through the VOL */ - if(H5VL_object_generic(obj_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, NULL, &ret_value) < 0) + if(H5VL_attr_get(obj_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -2625,7 +2629,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* get the attribute info through the VOL */ - if(H5VL_object_generic(loc_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, location, &ret_value) < 0) + if(H5VL_attr_get(loc_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, location, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") done: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index a05736b..0873c37 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -337,7 +337,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_HARD_LINK, H5L_SAME_LOC, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, H5L_SAME_LOC, new_name, lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ @@ -347,7 +347,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_SOFT_LINK, cur_loc_id, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, cur_loc_id, new_name, lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ @@ -396,7 +396,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_HARD_LINK, new_loc_id, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name, lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ @@ -411,7 +411,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_SOFT_LINK, new_loc_id, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, new_loc_id, new_name, lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else if */ diff --git a/src/H5L.c b/src/H5L.c index a31a657..301fe11 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -433,7 +433,7 @@ H5Lcreate_soft(const char *link_target, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_SOFT_LINK, link_loc_id, link_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, link_loc_id, link_name, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") @@ -494,7 +494,7 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_HARD_LINK, new_loc_id, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") @@ -561,7 +561,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_UD_LINK, link_loc_id, link_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, link_loc_id, link_name, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index c57edd9..03fd174 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -595,7 +595,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_UD_LINK, link_loc_id, link_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, link_loc_id, link_name, lcpl_id, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") diff --git a/src/H5O.c b/src/H5O.c index 7fef729..f054232 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -444,7 +444,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_CREATE_HARD_LINK, new_loc_id, new_name, + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") @@ -558,7 +558,7 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* change the ref count through the VOL */ - if(H5VL_object_generic(loc_id, H5VL_OBJECT_EXISTS, H5_REQUEST_NULL, name, lapl_id, &ret_value) < 0) + if(H5VL_object_get(loc_id, H5VL_OBJECT_EXISTS, H5_REQUEST_NULL, name, lapl_id, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: diff --git a/src/H5R.c b/src/H5R.c index 7ae5e33..30b44ac 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -535,6 +535,10 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Rdereference2() */ diff --git a/src/H5T.c b/src/H5T.c index 4a68dd1..3345b43 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1731,7 +1731,7 @@ H5Tclose(hid_t type_id) /* if this is a named datatype, go through the VOL layer */ if (H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)) { - if(H5VL_object_close(type_id, H5_REQUEST_NULL) < 0) + if(H5VL_datatype_close(type_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to free datatype") } else { diff --git a/src/H5VL.c b/src/H5VL.c index 893de13..c45ebb9 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -759,12 +759,16 @@ H5VL_attr_get(hid_t uid, H5VL_attr_get_t get_type, hid_t req, ...) { H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ + H5I_type_t id_type; /* Type of ID */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) + id_type = H5I_get_type(uid); /* Check id */ - if(H5I_ATTR_PUBLIC != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && + H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && + H5I_ATTR_PUBLIC != id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ @@ -774,7 +778,7 @@ H5VL_attr_get(hid_t uid, H5VL_attr_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->attr_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method") - va_start (arguments, get_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->attr_cls.get)(id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -785,7 +789,7 @@ H5VL_attr_get(hid_t uid, H5VL_attr_get_t get_type, hid_t req, ...) H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ hid_t *ret_id; - va_start (arguments, get_type); + va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); if(H5T_committed((H5T_t *)H5I_object_verify(*ret_id, H5I_DATATYPE))) { @@ -1010,6 +1014,44 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Positive + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(hid_t uid, hid_t req) +{ + H5VL_id_wrapper_t *id_wrapper; /* wrapper object of the datatype to be closed */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL close callback exists */ + if(NULL == id_wrapper->vol_plugin->datatype_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype close' method") + + /* call the corresponding VOL close callback */ + if((ret_value = (id_wrapper->vol_plugin->datatype_cls.close)(id_wrapper->obj_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_close() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_dataset_create * * Purpose: Creates a dataset through the VOL @@ -1302,7 +1344,7 @@ H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->dataset_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method") - va_start (arguments, get_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->dataset_cls.get)(id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -1313,7 +1355,7 @@ H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, hid_t req, ...) H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ hid_t *ret_id; - va_start (arguments, get_type); + va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); if(H5T_committed((H5T_t *)H5I_object_verify(*ret_id, H5I_DATATYPE))) { @@ -1571,7 +1613,7 @@ H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") - va_start(arguments, get_type); + va_start(arguments, req); if((ret_value = (id_wrapper->vol_plugin->file_cls.get)(id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -1619,7 +1661,7 @@ H5VL_file_generic(hid_t uid, H5VL_file_generic_t generic_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->file_cls.generic) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file generic' method") - va_start (arguments, generic_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->file_cls.generic)(id_wrapper->obj_id, generic_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "generic failed") @@ -1762,12 +1804,17 @@ H5VL_group_open(hid_t loc_id, const char *name, hid_t gapl_id, hid_t req) the location of the object */ /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, name, gapl_id, req) < 0) + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, gapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ if((ret_value = H5VL_object_open_by_loc(loc_id, location, gapl_id, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + + if (NULL != location) { + free (location); + location = NULL; + } } else { /* call the corresponding VOL open callback */ @@ -1826,7 +1873,7 @@ H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->group_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") - va_start (arguments, get_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->group_cls.get) (id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -1910,7 +1957,7 @@ H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char * FUNC_ENTER_NOAPI(FAIL) /* unwrap the target high level ID if the creation call is H5Lcreate_hard */ - if(H5VL_CREATE_HARD_LINK == create_type) { + if(H5VL_LINK_CREATE_HARD == create_type) { H5P_genplist_t *plist; /* Property list pointer */ hid_t cur_id; @@ -2061,7 +2108,7 @@ H5VL_link_get(hid_t uid, H5VL_link_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->link_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method") - va_start (arguments, get_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->link_cls.get) (id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -2258,7 +2305,7 @@ H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->object_cls.lookup) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method") - va_start (arguments, lookup_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->object_cls.lookup)(id_wrapper->obj_id, lookup_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed") @@ -2306,7 +2353,7 @@ H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, hid_t req, ...) if(NULL == id_wrapper->vol_plugin->object_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") - va_start (arguments, get_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->object_cls.get)(id_wrapper->obj_id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") @@ -2353,7 +2400,7 @@ H5VL_object_generic(hid_t uid, H5VL_object_generic_t generic_type, hid_t req, .. if(NULL == id_wrapper->vol_plugin->object_cls.generic) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object generic' method") - va_start (arguments, generic_type); + va_start (arguments, req); if((ret_value = (id_wrapper->vol_plugin->object_cls.generic)(id_wrapper->obj_id, generic_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "generic failed") @@ -2363,7 +2410,7 @@ H5VL_object_generic(hid_t uid, H5VL_object_generic_t generic_type, hid_t req, .. H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ hid_t *ret_id; - va_start (arguments, generic_type); + va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index 4a0b40e..b32c487 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -74,7 +74,8 @@ H5VL_class_t H5VL_dummy_g = { }, { /* datatype_cls */ NULL, /* commit */ - NULL /* open */ + NULL, /* open */ + NULL /* close */ }, { /* dataset_cls */ NULL, /* create */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 7052b8d..edd8d1c 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -128,7 +128,8 @@ H5VL_class_t H5VL_native_g = { }, { /* datatype_cls */ H5VL_native_datatype_commit, /* commit */ - H5VL_native_datatype_open /* open */ + H5VL_native_datatype_open, /* open */ + H5VL_native_object_close /* close */ }, { /* dataset_cls */ H5VL_native_dataset_create, /* create */ @@ -493,23 +494,50 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_list arguments) +H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_list arguments) { H5A_t *attr; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - switch (get_type) { + /* H5Aexists/exists_by_name */ + case H5VL_ATTR_EXISTS: + { + char *name = va_arg (arguments, char *); + void *location = va_arg (arguments, void *); + htri_t *ret = va_arg (arguments, htri_t *); + H5G_loc_t loc; + + if(H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if(NULL == location) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O_attr_exists(loc.oloc, name, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } + else { + H5G_loc_t *obj_loc = (H5G_loc_t *)location; + /* Check if the attribute exists */ + if((*ret = H5O_attr_exists(obj_loc->oloc, name, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + + if(H5G_loc_free(obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + } + break; + } /* H5Aget_space */ case H5VL_ATTR_GET_SPACE: { hid_t *ret_id = va_arg (arguments, hid_t *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if((*ret_id = H5A_get_space(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") break; @@ -519,6 +547,10 @@ H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, { hid_t *ret_id = va_arg (arguments, hid_t *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if((*ret_id = H5A_get_type(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") break; @@ -528,6 +560,10 @@ H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, { hid_t *ret_id = va_arg (arguments, hid_t *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if((*ret_id = H5A_get_create_plist(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") @@ -540,6 +576,10 @@ H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, size_t buf_size = va_arg (arguments, size_t); char *buf = va_arg (arguments, char *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* Call private function in turn */ if(0 > (*ret_val = H5A_get_name(attr, buf_size, buf))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") @@ -551,6 +591,10 @@ H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, { H5A_info_t *ainfo = va_arg (arguments, H5A_info_t *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if(H5A_get_info(attr, ainfo) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") @@ -560,6 +604,10 @@ H5VL_native_attr_get(hid_t attr_id, H5VL_attr_get_t get_type, hid_t UNUSED req, { hsize_t *ret = va_arg (arguments, hsize_t *); + /* check arguments */ + if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* Set return value */ *ret = attr->shared->data_size; break; @@ -2021,7 +2069,7 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); switch (create_type) { - case H5VL_CREATE_HARD_LINK: + case H5VL_LINK_CREATE_HARD: { H5G_loc_t cur_loc; H5G_loc_t link_loc; @@ -2064,7 +2112,7 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const } break; } - case H5VL_CREATE_SOFT_LINK: + case H5VL_LINK_CREATE_SOFT: { char *target_name; H5G_loc_t link_loc; /* Group location for new link */ @@ -2081,7 +2129,7 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") break; } - case H5VL_CREATE_UD_LINK: + case H5VL_LINK_CREATE_UD: { H5G_loc_t link_loc; /* Group location for new link */ H5L_type_t link_type; @@ -2560,33 +2608,6 @@ H5VL_native_object_generic(hid_t loc_id, H5VL_object_generic_t generic_type, hid break; } - /* H5Aexists/exists_by_name */ - case H5VL_ATTR_EXISTS: - { - char *name = va_arg (arguments, char *); - void *location = va_arg (arguments, void *); - htri_t *ret = va_arg (arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - if(NULL == location) { /* H5Aexists */ - /* Check if the attribute exists */ - if((*ret = H5O_attr_exists(loc.oloc, name, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } - else { - H5G_loc_t *obj_loc = (H5G_loc_t *)location; - /* Check if the attribute exists */ - if((*ret = H5O_attr_exists(obj_loc->oloc, name, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - - if(H5G_loc_free(obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - } - break; - } /* H5Aopen_by_idx */ case H5VL_ATTR_OPEN_BY_IDX: { @@ -2654,22 +2675,6 @@ H5VL_native_object_generic(hid_t loc_id, H5VL_object_generic_t generic_type, hid break; } - /* H5Oexists_by_name */ - case H5VL_OBJECT_EXISTS: - { - char *name = va_arg (arguments, char *); - hid_t lapl_id = va_arg (arguments, hid_t); - htri_t *ret = va_arg (arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Check if the object exists */ - if((*ret = H5G_loc_exists(&loc, name, lapl_id, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) - break; - } /* H5Oset_comment */ case H5VL_OBJECT_SET_COMMENT: { @@ -2744,6 +2749,18 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t UNUSED req, v HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") switch (get_type) { + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: + { + char *name = va_arg (arguments, char *); + hid_t lapl_id = va_arg (arguments, hid_t); + htri_t *ret = va_arg (arguments, htri_t *); + + /* Check if the object exists */ + if((*ret = H5G_loc_exists(&loc, name, lapl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) + break; + } /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ case H5VL_OBJECT_GET_INFO: { diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 84e21fd..da977a7 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -75,6 +75,7 @@ H5_DLL herr_t H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, hid_t req H5_DLL herr_t H5VL_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req); H5_DLL hid_t H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t req); +H5_DLL herr_t H5VL_datatype_close(hid_t type_id, hid_t req); H5_DLL hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req); H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 047ba99..baf0629 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -28,12 +28,13 @@ /* types for all attr get API routines */ typedef enum H5VL_attr_get_t { - H5VL_ATTR_GET_SPACE = 0, /* dataspace */ - H5VL_ATTR_GET_TYPE = 1, /* datatype */ - H5VL_ATTR_GET_ACPL = 2, /* creation property list */ - H5VL_ATTR_GET_NAME = 3, /* access property list */ - H5VL_ATTR_GET_STORAGE_SIZE = 4, /* storage size */ - H5VL_ATTR_GET_INFO = 5 /* offset */ + H5VL_ATTR_EXISTS = 0, /* H5Aexists */ + H5VL_ATTR_GET_SPACE = 1, /* dataspace */ + H5VL_ATTR_GET_TYPE = 2, /* datatype */ + H5VL_ATTR_GET_ACPL = 3, /* creation property list */ + H5VL_ATTR_GET_NAME = 4, /* access property list */ + H5VL_ATTR_GET_STORAGE_SIZE = 5, /* storage size */ + H5VL_ATTR_GET_INFO = 6 /* offset */ } H5VL_attr_get_t; /* types for all dataset get API routines */ @@ -78,9 +79,9 @@ typedef enum H5VL_group_get_t { /* link create types for VOL */ typedef enum H5VL_link_create_type_t { - H5VL_CREATE_HARD_LINK = 0, - H5VL_CREATE_SOFT_LINK = 1, - H5VL_CREATE_UD_LINK = 2 + H5VL_LINK_CREATE_HARD = 0, + H5VL_LINK_CREATE_SOFT = 1, + H5VL_LINK_CREATE_UD = 2 } H5VL_link_create_type_t; /* types for all link get API routines */ @@ -94,22 +95,21 @@ typedef enum H5VL_link_get_t { /* types for all object general operations */ typedef enum H5VL_object_generic_t { H5VL_ATTR_DELETE_BY_IDX = 0, /* H5Adelete_by_idx */ - H5VL_ATTR_EXISTS = 1, /* H5Aexists */ H5VL_ATTR_OPEN_BY_IDX = 2, /* H5Aopen_by_idx */ H5VL_ATTR_RENAME = 3, /* H5Arename */ H5VL_OBJECT_CHANGE_REF_COUNT = 4, /* H5Oincr/decr_refcount */ - H5VL_OBJECT_EXISTS = 5, /* H5Oexists(_by_name) */ H5VL_OBJECT_SET_COMMENT = 6, /* H5Oset_comment(_by_name) */ H5VL_REF_CREATE = 7 /* H5Rcreate */ } H5VL_object_generic_t; /* types for all object get API routines */ typedef enum H5VL_object_get_t { - H5VL_OBJECT_GET_INFO = 0, /*object info */ - H5VL_OBJECT_GET_COMMENT = 1, /*object comment */ - H5VL_REF_GET_REGION = 2, /*dataspace of region */ - H5VL_REF_GET_TYPE = 3, /*type of object */ - H5VL_REF_GET_NAME = 4 /*object name */ + H5VL_OBJECT_EXISTS = 0, /* H5Oexists_by_name) */ + H5VL_OBJECT_GET_INFO = 1, /*object info */ + H5VL_OBJECT_GET_COMMENT = 2, /*object comment */ + H5VL_REF_GET_REGION = 3, /*dataspace of region */ + H5VL_REF_GET_TYPE = 4, /*type of object */ + H5VL_REF_GET_NAME = 5 /*object name */ } H5VL_object_get_t; /* types for all object lookup API routines */ @@ -140,6 +140,7 @@ typedef struct H5VL_datatype_class_t { herr_t (*commit)(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req); hid_t (*open) (hid_t loc_id, const char * name, hid_t tapl_id, hid_t req); + herr_t (*close) (hid_t type_id, hid_t req); }H5VL_datatype_class_t; /* H5D routines */ -- cgit v0.12