summaryrefslogtreecommitdiffstats
path: root/src/H5Gstab.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-08-02 23:41:53 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-08-02 23:41:53 (GMT)
commit3e755623cb24eb37c19fa645d74dc46948318253 (patch)
tree66e0a3807f37d50a8d6e5f3469864c604cd837c6 /src/H5Gstab.c
parent71a4d0e9c48c4e02e5384cd3f6e38a2a530e9d22 (diff)
downloadhdf5-3e755623cb24eb37c19fa645d74dc46948318253.zip
hdf5-3e755623cb24eb37c19fa645d74dc46948318253.tar.gz
hdf5-3e755623cb24eb37c19fa645d74dc46948318253.tar.bz2
[svn-r12528] Added User-Defined links to the library.
Users can create external links using H5L_create_external(). These links point to an object in another HDF5 file. Users can alter the behavior of external links or create new kinds of links by registering callbacks using the H5L interface. Added tests, tools support, etc. Also a number of other, minor changes have been made (some restructuring of the H5L interface, for instance). Additional documentation and examples are forthcoming.
Diffstat (limited to 'src/H5Gstab.c')
-rw-r--r--src/H5Gstab.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 651ddf3..926aa0e 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -608,8 +608,11 @@ H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata)
udata->lnk->ctime = 0;
udata->lnk->name = H5MM_xstrdup(udata->name);
- /* Object is a symbolic link */
- if(H5G_CACHED_SLINK == ent->type) {
+ /* Object is a symbolic or user-defined link */
+ switch(ent->type)
+ {
+ case H5G_CACHED_SLINK:
+ {
const char *s; /* Pointer to link value */
const H5HL_t *heap; /* Pointer to local heap for group */
@@ -628,14 +631,47 @@ H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata)
/* Set link type */
udata->lnk->type = H5L_LINK_SOFT;
- } /* end if */
- else {
+ }
+ break;
+
+ case H5G_CACHED_ULINK:
+ {
+ void * s; /* Pointer to heap value */
+ const H5HL_t *heap; /* Pointer to local heap for group */
+ size_t data_size; /* Size of user link data */
+
+ /* Lock the local heap */
+ if(NULL == (heap = H5HL_protect(udata->file, udata->dxpl_id, udata->heap_addr)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value")
+
+ data_size =ent->cache.ulink.udata_size;
+
+ if(data_size > 0)
+ {
+ s = H5HL_offset_into(udata->file, heap, ent->cache.ulink.udata_offset);
+
+ /* Allocate space for the user data and copy it from the heap */
+ udata->lnk->u.ud.udata = H5MM_malloc(data_size);
+ HDmemcpy(udata->lnk->u.ud.udata, s, data_size);
+ } /* end if */
+
+ /* Release the local heap */
+ if(H5HL_unprotect(udata->file, udata->dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value")
+
+ /* Set link size and type */
+ udata->lnk->u.ud.size = data_size;
+ udata->lnk->type = ent->cache.ulink.link_type;
+ }
+ break;
+
+ default:
/* Set address of object */
udata->lnk->u.hard.addr = ent->header;
/* Set link type */
udata->lnk->type = H5L_LINK_HARD;
- } /* end else */
+ } /* end switch */
} /* end if */
done:
@@ -697,3 +733,4 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_lookup() */
+