summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-03-18 00:07:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-03-18 00:07:50 (GMT)
commitb0138a0cb0a7a327600ab57affb754ff1167d44b (patch)
treea1fe26467646e4f702d29577b3667292358259d1
parente433e6c4a977a977ed460670b3fb4c7214849488 (diff)
downloadhdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.zip
hdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.tar.gz
hdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.tar.bz2
[svn-r1144] Added support for object references to groups.
-rw-r--r--src/H5G.c73
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5R.c11
3 files changed, 73 insertions, 12 deletions
diff --git a/src/H5G.c b/src/H5G.c
index b75f20f..ad87ccb 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1348,6 +1348,7 @@ H5G_isa(H5G_entry_t *ent)
* Monday, January 5, 1998
*
* Modifications:
+ * Modified to call H5G_open_oid - QAK - 3/17/99
*
*-------------------------------------------------------------------------
*/
@@ -1356,7 +1357,7 @@ H5G_open(H5G_entry_t *loc, const char *name)
{
H5G_t *grp = NULL;
H5G_t *ret_value = NULL;
- H5O_stab_t mesg;
+ H5G_entry_t ent; /*dataset symbol table entry */
FUNC_ENTER(H5G_open, NULL);
@@ -1365,29 +1366,77 @@ H5G_open(H5G_entry_t *loc, const char *name)
assert(name && *name);
/* Open the object, making sure it's a group */
- if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ if (H5G_find(loc, name, NULL, &ent/*out*/) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
+ }
+ /* Open the group object */
+ if ((grp=H5G_open_oid(&ent)) ==NULL) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found");
}
- if (H5G_find(loc, name, NULL, &(grp->ent)/*out*/) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
+ ret_value = grp;
+
+done:
+ if (!ret_value && grp) {
+ H5MM_xfree(grp);
}
+ FUNC_LEAVE(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_open_oid
+ *
+ * Purpose: Opens an existing group. The group should eventually be
+ * closed by calling H5G_close().
+ *
+ * Return: Success: Ptr to a new group.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, March 17, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5G_t *
+H5G_open_oid(H5G_entry_t *ent)
+{
+ H5G_t *grp = NULL;
+ H5G_t *ret_value = NULL;
+ H5O_stab_t mesg;
+
+ FUNC_ENTER(H5G_open_oid, NULL);
+
+ /* Check args */
+ assert(ent);
+
+ /* Open the object, making sure it's a group */
+ if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ }
+
+ /* Copy over the symbol table information if it's provided */
+ HDmemcpy(&(grp->ent),ent,sizeof(H5G_entry_t));
+
+ /* Grab the object header */
if (H5O_open(&(grp->ent)) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
}
if (NULL==H5O_read (&(grp->ent), H5O_STAB, 0, &mesg)) {
- H5O_close(&(grp->ent));
- HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group");
+ H5O_close(&(grp->ent));
+ HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group");
}
grp->nref = 1;
ret_value = grp;
- done:
+done:
if (!ret_value && grp) {
- H5MM_xfree(grp);
+ H5MM_xfree(grp);
}
FUNC_LEAVE(ret_value);
-}
+} /* end H5G_open_oid() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index c805f7a..3920d55 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -119,6 +119,7 @@ __DLL__ H5F_t *H5G_fileof(H5G_t *grp);
__DLL__ H5G_t *H5G_create(H5G_entry_t *loc, const char *name,
size_t size_hint);
__DLL__ H5G_t *H5G_open(H5G_entry_t *loc, const char *name);
+__DLL__ H5G_t *H5G_open_oid(H5G_entry_t *ent);
__DLL__ H5G_t *H5G_reopen(H5G_t *grp);
__DLL__ herr_t H5G_close(H5G_t *grp);
__DLL__ H5G_t *H5G_rootof(H5F_t *f);
diff --git a/src/H5R.c b/src/H5R.c
index 70a624e..8662924 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -330,6 +330,7 @@ static hid_t
H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
{
H5D_t *dataset; /* Pointer to dataset to open */
+ H5G_t *group; /* Pointer to group to open */
H5G_entry_t ent; /* Symbol table entry */
uint8_t *p; /* Pointer to OID to store */
intn oid_type; /* type of object being dereferenced */
@@ -401,6 +402,16 @@ H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
oid_type=H5G_get_type(&ent);
switch(oid_type) {
case H5G_GROUP:
+ if ((group=H5G_open_oid(&ent)) == NULL) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ }
+
+ /* Create an atom for the dataset */
+ if ((ret_value = H5I_register(H5I_GROUP, group)) < 0) {
+ H5G_close(group);
+ HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL,
+ "can't register group");
+ }
break;
case H5G_TYPE: