summaryrefslogtreecommitdiffstats
path: root/src/H5Gent.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/H5Gent.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/H5Gent.c')
-rw-r--r--src/H5Gent.c94
1 files changed, 91 insertions, 3 deletions
diff --git a/src/H5Gent.c b/src/H5Gent.c
index a8311f0..f242bad 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -183,8 +183,14 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent)
UINT32DECODE (*pp, ent->cache.slink.lval_offset);
break;
+ case H5G_CACHED_ULINK:
+ UINT32DECODE (*pp, ent->cache.ulink.udata_size);
+ UINT32DECODE (*pp, ent->cache.ulink.udata_offset);
+ UINT32DECODE (*pp, ent->cache.ulink.link_type);
+ break;
default:
- HDabort();
+ /* Error or unknown type. Bail out. */
+ return -1;
}
*pp = p_ret + H5G_SIZEOF_ENTRY(f);
@@ -296,8 +302,15 @@ H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent)
UINT32ENCODE (*pp, ent->cache.slink.lval_offset);
break;
+ case H5G_CACHED_ULINK:
+ UINT32ENCODE (*pp, ent->cache.ulink.udata_size);
+ UINT32ENCODE (*pp, ent->cache.ulink.udata_offset);
+ UINT32ENCODE (*pp, ent->cache.ulink.link_type);
+ break;
+
default:
- HDabort();
+ /* Unknown cached type. Bail out. */
+ return -1;
}
} else {
H5F_ENCODE_LENGTH(f, *pp, 0);
@@ -457,7 +470,24 @@ H5G_ent_convert(H5F_t *f, haddr_t heap_addr, const char *name, const H5O_link_t
break;
default:
- HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type")
+ if(lnk->type < H5L_LINK_UD_MIN)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type")
+
+ {
+ size_t udata_offset = (size_t) (-1); /* Offset to data buffer */
+
+ if(lnk->u.ud.size > 0)
+ {
+ if((size_t)(-1) == (udata_offset = H5HL_insert(f, dxpl_id,
+ heap_addr, lnk->u.ud.size, lnk->u.ud.udata)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write user data to local heap")
+ }
+
+ ent->type = H5G_CACHED_ULINK;
+ ent->cache.ulink.udata_size = lnk->u.ud.size;
+ ent->cache.ulink.udata_offset = udata_offset;
+ ent->cache.ulink.link_type = lnk->type;
+ }
} /* end switch */
/* Set the file for the entry */
@@ -544,6 +574,64 @@ H5G_ent_debug(H5F_t UNUSED *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * str
HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!");
break;
+ case H5G_CACHED_ULINK:
+ if(ent->cache.ulink.link_type == H5L_LINK_EXTERNAL)
+ {
+ HDfprintf (stream, "External Link\n");
+ HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth,
+ "Cached information:");
+ if(ent->cache.ulink.udata_size > 0)
+ {
+ HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
+ "User data offset:",
+ (unsigned long)(ent->cache.ulink.udata_offset));
+ }
+ HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
+ "User data size:",
+ (unsigned long)(ent->cache.ulink.udata_size));
+ if (heap>0 && H5F_addr_defined(heap)) {
+ const H5HL_t *heap_ptr;
+ char * filename;
+ char * pathname;
+
+ heap_ptr = H5HL_protect(ent->file, dxpl_id, heap);
+ lval = H5HL_offset_into(ent->file, heap_ptr, ent->cache.ulink.udata_offset);
+ if(H5Lunpack_elink_val(lval, &filename, &pathname) < 0) return FAIL;
+
+ HDfprintf (stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth,
+ "External link file name:",
+ lval);
+ HDfprintf (stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth,
+ "External link object name:",
+ pathname);
+ H5HL_unprotect(ent->file, dxpl_id, heap_ptr, heap, H5AC__NO_FLAGS_SET);
+ } else {
+ HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given!");
+ }
+ }
+ else
+ {
+ HDfprintf (stream, "User-defined Link\n");
+ HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth,
+ "Cached information:");
+ HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
+ "Link class:",
+ (unsigned long)(ent->cache.ulink.link_type));
+ if(ent->cache.ulink.udata_size > 0)
+ {
+ HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
+ "User data offset:",
+ (unsigned long)(ent->cache.ulink.udata_offset));
+ }
+ HDfprintf (stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth,
+ "User data size:",
+ (unsigned long)(ent->cache.ulink.udata_size));
+ if (heap<=0 || !H5F_addr_defined(heap)) {
+ HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given!");
+ }
+ }
+ break;
+
default:
HDfprintf(stream, "*** Unknown symbol type %d\n", ent->type);
break;