diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-21 20:22:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-11-21 20:22:11 (GMT) |
commit | e9262d7320615d78d32d777a416e34b01072191f (patch) | |
tree | 8c42f6d8e4519fbeaf66138f3c6337479e49e3e8 /src | |
parent | 102170c3bfc6fa3583f960ba970eb612567b1c05 (diff) | |
download | hdf5-e9262d7320615d78d32d777a416e34b01072191f.zip hdf5-e9262d7320615d78d32d777a416e34b01072191f.tar.gz hdf5-e9262d7320615d78d32d777a416e34b01072191f.tar.bz2 |
[svn-r12963] Description:
Refactor internal code that retrieves the object's type to use the new
H5O_type_t (which only definitions for object types, instead of links as well)
instead of the older H5G_obj_t (which included links, etc.)
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 10 | ||||
-rw-r--r-- | src/H5Doh.c | 2 | ||||
-rw-r--r-- | src/H5G.c | 84 | ||||
-rw-r--r-- | src/H5Gcompact.c | 7 | ||||
-rw-r--r-- | src/H5Gdense.c | 9 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 7 | ||||
-rw-r--r-- | src/H5Glink.c | 17 | ||||
-rw-r--r-- | src/H5Goh.c | 2 | ||||
-rw-r--r-- | src/H5Gpkg.h | 1 | ||||
-rw-r--r-- | src/H5Gstab.c | 27 | ||||
-rw-r--r-- | src/H5L.c | 10 | ||||
-rw-r--r-- | src/H5O.c | 158 | ||||
-rw-r--r-- | src/H5Opkg.h | 2 | ||||
-rw-r--r-- | src/H5Oprivate.h | 4 | ||||
-rw-r--r-- | src/H5R.c | 23 | ||||
-rw-r--r-- | src/H5Tcommit.c | 16 | ||||
-rw-r--r-- | src/H5Toh.c | 2 |
17 files changed, 298 insertions, 83 deletions
@@ -533,6 +533,7 @@ H5Dopen(hid_t loc_id, const char *name) H5G_loc_t dset_loc; /* Object location of dataset */ H5G_name_t path; /* Dataset group hier. path */ H5O_loc_t oloc; /* Dataset object location */ + H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; @@ -557,7 +558,9 @@ H5Dopen(hid_t loc_id, const char *name) loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, dxpl_id) != H5G_DATASET) + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* Open the dataset */ @@ -611,6 +614,7 @@ H5Dopen_expand(hid_t loc_id, const char *name, hid_t dapl_id) H5G_loc_t dset_loc; /* Object location of dataset */ H5G_name_t path; /* Dataset group hier. path */ H5O_loc_t oloc; /* Dataset object location */ + H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; @@ -642,7 +646,9 @@ H5Dopen_expand(hid_t loc_id, const char *name, hid_t dapl_id) loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, dxpl_id) != H5G_DATASET) + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* Open the dataset */ diff --git a/src/H5Doh.c b/src/H5Doh.c index 6781e25..042d9c5 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -59,7 +59,7 @@ static H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id); /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{ - H5G_DATASET, /* object type */ + H5O_TYPE_DATASET, /* object type */ "dataset", /* object name, for debugging */ H5O_dset_get_copy_file_udata, /* get 'copy file' user data */ H5O_dset_free_copy_file_udata, /* free 'copy file' user data */ @@ -229,7 +229,7 @@ H5Gcreate(hid_t loc_id, const char *name, size_t size_hint) insertion_loc.oloc = &insert_oloc; H5G_loc_reset(&insertion_loc); if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to locate insertion point") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate insertion point") insert_loc_valid=TRUE; file = insertion_loc.oloc->file; @@ -379,8 +379,9 @@ H5Gopen(hid_t loc_id, const char *name) H5G_loc_t grp_loc; /* Location used to open group */ H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ + H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ - hid_t ret_value = FAIL; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Gopen, FAIL) H5TRACE2("i","is",loc_id,name); @@ -402,7 +403,9 @@ H5Gopen(hid_t loc_id, const char *name) loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&grp_oloc, H5AC_dxpl_id) != H5G_GROUP) + if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") /* Open the group */ @@ -454,8 +457,9 @@ H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id) H5G_loc_t grp_loc; /* Location used to open group */ H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ + H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ - hid_t ret_value=FAIL; /* Return value */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5Gopen_expand, FAIL); H5TRACE3("i","isi",loc_id,name,gapl_id); @@ -484,7 +488,9 @@ H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id) loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&grp_oloc, H5AC_dxpl_id) != H5G_GROUP) + if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") /* Open the group */ @@ -567,6 +573,7 @@ herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { H5G_loc_t loc; /* Location of object */ + H5O_type_t obj_type; /* Type of object at location */ herr_t ret_value; FUNC_ENTER_API(H5Gget_num_objs, FAIL) @@ -575,8 +582,10 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, H5AC_ind_dxpl_id) != H5G_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") if(!num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer") @@ -608,6 +617,7 @@ H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { H5G_loc_t loc; /* Object location */ + H5O_type_t obj_type; /* Type of object at location */ H5G_obj_t ret_value; FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN) @@ -616,8 +626,10 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") - if(H5O_obj_type(loc.oloc, H5AC_ind_dxpl_id) != H5G_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") /* Call internal function*/ if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_dxpl_id)) == H5G_UNKNOWN) @@ -1512,6 +1524,48 @@ H5G_fileof(H5G_t *grp) /*------------------------------------------------------------------------- + * Function: H5G_map_obj_type + * + * Purpose: Maps the object type to the older "group" object type + * + * Return: Object type (can't fail) + * + * Programmer: Quincey Koziol + * Tuesday, November 21, 2006 + * + *------------------------------------------------------------------------- + */ +H5G_obj_t +H5G_map_obj_type(H5O_type_t obj_type) +{ + H5G_obj_t ret_value; /* Return value */ + + /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_map_obj_type) + + /* Map object type to older "group" object type */ + switch(obj_type) { + case H5O_TYPE_GROUP: + ret_value = H5G_GROUP; + break; + + case H5O_TYPE_DATASET: + ret_value = H5G_DATASET; + break; + + case H5O_TYPE_NAMED_DATATYPE: + ret_value = H5G_TYPE; + break; + + default: + ret_value = H5G_UNKNOWN; + } /* end switch */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_map_obj_type() */ + + +/*------------------------------------------------------------------------- * Function: H5G_get_objinfo_cb * * Purpose: Callback for retrieving info about an object. This routine @@ -1553,10 +1607,14 @@ H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char UNUSED *name, const H5O_ * a hard link, follow it and get info on the object */ if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_type_t obj_type; /* Type of object */ + /* Get object type */ - statbuf->type = H5O_obj_type(obj_loc->oloc, udata->dxpl_id); - if(statbuf->type == H5G_UNKNOWN) - H5E_clear_stack(NULL); /* clear any errors resulting from checking type */ + if(H5O_obj_type(obj_loc->oloc, &obj_type, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type") + + /* Map object type to older group object type */ + statbuf->type = H5G_map_obj_type(obj_type); /* Get basic info for object */ statbuf->objno[0] = (unsigned long)(obj_loc->oloc->addr); @@ -1577,7 +1635,7 @@ H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char UNUSED *name, const H5O_ } /* end if */ /* Get object header information */ - if(H5O_get_info(obj_loc->oloc, &(statbuf->ohdr), udata->dxpl_id) < 0) + if(H5O_get_stat(obj_loc->oloc, &(statbuf->ohdr), udata->dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object header information") } /* end if */ } /* end if */ diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index c005815..7e7266a 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -295,13 +295,18 @@ H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *l ret_value = H5G_UDLINK; else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ /* Build temporary object location */ tmp_oloc.file = oloc->file; tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; /* Get the type of the object */ - if((ret_value = H5O_obj_type(&tmp_oloc, dxpl_id)) == H5G_UNKNOWN) + if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") + + /* Map to group object type */ + if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") } else { HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") diff --git a/src/H5Gdense.c b/src/H5Gdense.c index e495076..7e93605 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -1281,15 +1281,20 @@ H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, ret_value = H5G_LINK; else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ + else if(ltable.lnks[idx].type == H5L_TYPE_HARD) { H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ /* Build temporary object location */ tmp_oloc.file = f; tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; /* Get the type of the object */ - if((ret_value = H5O_obj_type(&tmp_oloc, dxpl_id)) == H5G_UNKNOWN) + if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") + + /* Map to group object type */ + if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") } else { HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index b780b0d..3178159 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -457,6 +457,7 @@ ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { H5G_loc_t loc; /* Object location */ + H5O_type_t obj_type; /* Type of object at location */ ssize_t ret_value; FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL) @@ -465,8 +466,10 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, H5AC_ind_dxpl_id) != H5G_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a group") /* Call internal function */ if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5L_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC_ind_dxpl_id)) < 0) diff --git a/src/H5Glink.c b/src/H5Glink.c index e984a91..de8e7aa 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -753,7 +753,7 @@ H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, const char *lnk_name, H5L_type_t lnk_type, haddr_t lnk_addr) { H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ - H5G_obj_t obj_type; /* Type of link/object being deleted */ + H5G_obj_t grp_obj_type; /* Type of link/object being deleted */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_link_name_replace, FAIL) @@ -766,20 +766,25 @@ H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, case H5L_TYPE_HARD: { H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ /* Build temporary object location */ tmp_oloc.file = file; tmp_oloc.addr = lnk_addr; /* Get the type of the object */ - if(H5G_UNKNOWN == (obj_type = H5O_obj_type(&tmp_oloc, dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to determine object type") + if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") + + /* Map to group object type */ + if(H5G_UNKNOWN == (grp_obj_type = H5G_map_obj_type(obj_type))) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") } break; case H5L_TYPE_SOFT: /* Get the object's type */ - obj_type = H5G_LINK; + grp_obj_type = H5G_LINK; break; default: /* User-defined link */ @@ -787,13 +792,13 @@ H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") /* Get the object's type */ - obj_type = H5G_UDLINK; + grp_obj_type = H5G_UDLINK; } /* end switch */ /* Search the open IDs and replace names for unlinked object */ if(grp_full_path_r) { obj_path_r = H5G_build_fullpath_refstr_str(grp_full_path_r, lnk_name); - if(H5G_name_replace(obj_type, file, obj_path_r, + if(H5G_name_replace(grp_obj_type, file, obj_path_r, NULL, NULL, NULL, H5G_NAME_DELETE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") } /* end if */ diff --git a/src/H5Goh.c b/src/H5Goh.c index d1d25b3..853dc7c 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -60,7 +60,7 @@ static H5O_loc_t *H5O_group_get_oloc(hid_t obj_id); /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_GROUP[1] = {{ - H5G_GROUP, /* object type */ + H5O_TYPE_GROUP, /* object type */ "group", /* object name, for debugging */ NULL, /* get 'copy file' user data */ NULL, /* free 'copy file' user data */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 06941a0..8b23cd5 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -363,6 +363,7 @@ H5_DLL herr_t H5G_traverse_special(const H5G_loc_t *grp_loc, H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id); +H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); /******************************/ /* Package Private Prototypes */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 76cefe1..c617d6e 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -696,9 +696,9 @@ static herr_t H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata; - H5O_loc_t tmp_oloc; /* Temporary object location */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_stab_get_type_by_idx_cb) + FUNC_ENTER_NOAPI_NOINIT(H5G_stab_get_type_by_idx_cb) /* Sanity check */ HDassert(ent); @@ -711,16 +711,25 @@ H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata) break; default: - /* Build temporary object location */ - tmp_oloc.file = udata->common.f; - HDassert(H5F_addr_defined(ent->header)); - tmp_oloc.addr = ent->header; - - udata->type = H5O_obj_type(&tmp_oloc, udata->common.dxpl_id); + { + H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ + + /* Build temporary object location */ + tmp_oloc.file = udata->common.f; + HDassert(H5F_addr_defined(ent->header)); + tmp_oloc.addr = ent->header; + + /* Get the type of the object */ + if(H5O_obj_type(&tmp_oloc, &obj_type, udata->common.dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + udata->type = H5G_map_obj_type(obj_type); + } break; } /* end switch */ - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_get_type_by_idx_cb */ @@ -2343,8 +2343,14 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, /* Get object type */ switch(lnk->type) { case H5L_TYPE_HARD: - if(H5G_UNKNOWN == (type = H5O_obj_type(obj_loc->oloc, udata->dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type to move") + { + H5O_type_t obj_type; /* Type of object at location */ + + if(H5O_obj_type(obj_loc->oloc, &obj_type, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(H5G_UNKNOWN == (type = H5G_map_obj_type(obj_type))) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "unknown object type to move") + } break; case H5L_TYPE_SOFT: @@ -146,7 +146,8 @@ static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *typ static herr_t H5O_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_protect_t prot, hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id); static const H5O_obj_class_t *H5O_obj_class(H5O_loc_t *loc, hid_t dxpl_id); -static H5G_obj_t H5O_obj_type_real(H5O_t *oh); +static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); +static herr_t H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id); /*********************/ /* Package Variables */ @@ -265,7 +266,7 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) /* Find the object's location */ if(H5G_loc_find(&loc, name, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Open the object */ @@ -564,6 +565,68 @@ done: /*------------------------------------------------------------------------- + * Function: H5Oget_info + * + * Purpose: Retrieve information about an object. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 21 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t obj_loc; /* Location used to open object */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Oopen, FAIL) + H5TRACE3("i","isi",loc_id,name,lapl_id); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Set up opened object location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, name, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Get the information about the object */ + if(H5O_get_info(obj_loc.oloc, oinfo, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + +done: + if(loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info() */ + + +/*------------------------------------------------------------------------- * Function: H5O_open_by_loc * * Purpose: Opens an object and returns an ID given its group loction. @@ -590,7 +653,7 @@ H5O_open_by_loc(H5G_loc_t *obj_loc, hid_t dxpl_id) if(NULL == (obj_class = H5O_obj_class(obj_loc->oloc, dxpl_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") - /* Call the object's 'open' routine */ + /* Call the object class's 'open' routine */ HDassert(obj_class->open); if((ret_value = obj_class->open(obj_loc, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") @@ -3044,7 +3107,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_get_info + * Function: H5O_get_stat * * Purpose: Retrieve information about an object header * @@ -3057,7 +3120,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_get_info(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id) +H5O_get_stat(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header information */ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ @@ -3066,7 +3129,7 @@ H5O_get_info(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5O_get_info, FAIL) + FUNC_ENTER_NOAPI(H5O_get_stat, FAIL) /* Check args */ HDassert(loc); @@ -3099,7 +3162,7 @@ done: HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_info() */ +} /* end H5O_get_stat() */ /*------------------------------------------------------------------------- @@ -3378,7 +3441,7 @@ done: /*------------------------------------------------------------------------- * Function: H5O_obj_type * - * Purpose: Returns the type of object pointed to by `loc'. + * Purpose: Retrieves the type of object pointed to by `loc'. * * Return: Success: An object type defined in H5Gpublic.h * Failure: H5G_UNKNOWN @@ -3388,25 +3451,25 @@ done: * *------------------------------------------------------------------------- */ -H5G_obj_t -H5O_obj_type(H5O_loc_t *loc, hid_t dxpl_id) +herr_t +H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header for location */ - H5G_obj_t ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5O_obj_type, H5G_UNKNOWN) + FUNC_ENTER_NOAPI(H5O_obj_type, FAIL) /* Load the object header */ if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, H5G_UNKNOWN, "unable to load object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") - /* Test whether entry qualifies as a particular type of object */ - if((ret_value = H5O_obj_type_real(oh)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type") + /* Retrieve the type of the object */ + if(H5O_obj_type_real(oh, obj_type) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") done: if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) != SUCCEED) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, H5G_UNKNOWN, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_obj_type() */ @@ -3417,7 +3480,7 @@ done: * * Purpose: Returns the type of object pointed to by `oh'. * - * Return: Success: An object type defined in H5Gpublic.h + * Return: Success: An object type defined in H5Opublic.h * Failure: H5G_UNKNOWN * * Programmer: Quincey Koziol @@ -3425,23 +3488,24 @@ done: * *------------------------------------------------------------------------- */ -static H5G_obj_t -H5O_obj_type_real(H5O_t *oh) +static herr_t +H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type) { const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5G_obj_t ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_obj_type_real) /* Sanity check */ HDassert(oh); + HDassert(obj_type); /* Look up class for object header */ if(NULL == (obj_class = H5O_obj_class_real(oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5G_UNKNOWN, "unable to determine object type") + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object type") - /* Set return value */ - ret_value = obj_class->type; + /* Set object type */ + *obj_type = obj_class->type; done: FUNC_LEAVE_NOAPI(ret_value) @@ -3758,10 +3822,10 @@ H5O_mesg_hash(unsigned type_id, H5F_t *f, const void *mesg) /* JAMES: revisit this! Some messages don't use as much space as they say * they need. Quincey may have fixed this. */ - if((buf = HDmalloc(buf_size)) == NULL) + if((buf = H5MM_calloc(buf_size)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5O_HASH_UNDEF, "can't allocate buffer for message"); - HDmemset(buf, 0, buf_size); + /* Encode message into temporary buffer */ if(H5O_encode(f, buf, mesg, type_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, H5O_HASH_UNDEF, "can't encode OH message"); @@ -3779,11 +3843,51 @@ H5O_mesg_hash(unsigned type_id, H5F_t *f, const void *mesg) if(hash == H5O_HASH_UNDEF) hash = (uint32_t) 1; + /* Set return value */ ret_value = hash; done: if(buf) - HDfree(buf); + HDfree(buf); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mesg_hash() */ + +/*------------------------------------------------------------------------- + * Function: H5O_get_info + * + * Purpose: Retrieve the information for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 21 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5O_get_info, FAIL) + + /* Check args */ + HDassert(oloc); + HDassert(oinfo); + + /* Get the object header information */ + if(NULL == (oh = H5AC_protect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + + +done: + if(oh && H5AC_unprotect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_info() */ + diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 074c902..907208b 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -202,7 +202,7 @@ typedef struct { /* Class for types of objects in file */ typedef struct H5O_obj_class_t { - H5G_obj_t type; /*object type on disk */ + H5O_type_t type; /*object type on disk */ const char *name; /*for debugging */ void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 6570344..c068359 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -408,10 +408,10 @@ H5_DLL htri_t H5O_is_shared(unsigned type_id, const void *mesg); H5_DLL herr_t H5O_set_share(H5F_t *f, H5O_shared_t *share, unsigned type_id, void *mesg); H5_DLL herr_t H5O_reset_share(H5F_t *f, unsigned type_id, void *mesg); -H5_DLL herr_t H5O_get_info(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id); +H5_DLL herr_t H5O_get_stat(H5O_loc_t *loc, H5O_stat_t *ostat, hid_t dxpl_id); H5_DLL herr_t H5O_iterate(const H5O_loc_t *loc, unsigned type_id, H5O_operator_t op, void *op_data, hid_t dxpl_id); -H5_DLL H5G_obj_t H5O_obj_type(H5O_loc_t *loc, hid_t dxpl_id); +H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id); H5_DLL uint32_t H5O_mesg_hash(unsigned type_id, H5F_t *f, const void *mesg); /* Object copying routines */ @@ -340,7 +340,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re H5O_loc_t oloc; /* Object location */ H5G_name_t path; /* Path of object */ H5G_loc_t loc; /* Group location */ - int oid_type; /* type of object being dereferenced */ + H5O_type_t obj_type; /* Type of object */ hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT(H5R_dereference) @@ -402,10 +402,13 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re loc.oloc = &oloc; loc.path = &path; + /* Get the type of the object */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object type") + /* Open the object */ - oid_type = H5O_obj_type(&oloc, dxpl_id); - switch(oid_type) { - case H5G_GROUP: + switch(obj_type) { + case H5O_TYPE_GROUP: { H5G_t *group; /* Pointer to group to open */ @@ -420,7 +423,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re } /* end case */ break; - case H5G_TYPE: + case H5O_TYPE_NAMED_DATATYPE: { H5T_t *type; /* Pointer to datatype to open */ @@ -435,7 +438,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re } /* end case */ break; - case H5G_DATASET: + case H5O_TYPE_DATASET: { H5D_t *dset; /* Pointer to dataset to open */ @@ -662,6 +665,7 @@ static H5G_obj_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref) { H5O_loc_t oloc; /* Object location */ + H5O_type_t obj_type; /* Type of object */ const uint8_t *p; /* Pointer to OID to store */ H5G_obj_t ret_value; /* Return value */ @@ -718,8 +722,11 @@ H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_r if(H5O_link(&oloc, 0, dxpl_id) <= 0) HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, H5G_UNKNOWN, "dereferencing deleted object") - /* Get the OID type */ - ret_value = H5O_obj_type(&oloc, dxpl_id); + /* Get the object type */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object type") + + ret_value = H5G_map_obj_type(obj_type); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index f8a13fa..5a5beb5 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -105,7 +105,7 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id) insertion_loc.oloc = &insert_oloc; H5G_loc_reset(&insertion_loc); if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to locate insertion point") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate insertion point") insert_loc_valid = TRUE; file = insertion_loc.oloc->file; @@ -446,6 +446,7 @@ H5Topen(hid_t loc_id, const char *name) H5G_loc_t loc; H5G_name_t path; /* Datatype group hier. path */ H5O_loc_t oloc; /* Datatype object location */ + H5O_type_t obj_type; /* Type of object at location */ H5G_loc_t type_loc; /* Group object for datatype */ hbool_t obj_found = FALSE; /* Object at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ @@ -474,8 +475,10 @@ H5Topen(hid_t loc_id, const char *name) obj_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, dxpl_id) != H5G_TYPE) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype") + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_NAMED_DATATYPE) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") /* Open it */ if((type = H5T_open(&type_loc, dxpl_id)) == NULL) @@ -520,6 +523,7 @@ H5Topen_expand(hid_t loc_id, const char *name, hid_t tapl_id) H5G_loc_t loc; H5G_name_t path; /* Datatype group hier. path */ H5O_loc_t oloc; /* Datatype object location */ + H5O_type_t obj_type; /* Type of object at location */ H5G_loc_t type_loc; /* Group object for datatype */ hbool_t obj_found = FALSE; /* Object at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ @@ -555,8 +559,10 @@ H5Topen_expand(hid_t loc_id, const char *name, hid_t tapl_id) obj_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, dxpl_id) != H5G_TYPE) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype") + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_NAMED_DATATYPE) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") /* Open it */ if((type = H5T_open(&type_loc, dxpl_id)) == NULL) diff --git a/src/H5Toh.c b/src/H5Toh.c index bfca641..2137a8a 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -62,7 +62,7 @@ static H5O_loc_t *H5O_dtype_get_oloc(hid_t obj_id); /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ - H5G_TYPE, /* object type */ + H5O_TYPE_NAMED_DATATYPE, /* object type */ "named datatype", /* object name, for debugging */ NULL, /* get 'copy file' user data */ NULL, /* free 'copy file' user data */ |