summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/h5diff/h5diffgentest.c34
-rw-r--r--tools/h5dump/h5dump.c202
-rw-r--r--tools/h5dump/h5dump.h10
-rw-r--r--tools/h5dump/h5dumpgentest.c151
-rw-r--r--tools/h5dump/testh5dump.sh.in4
-rwxr-xr-xtools/h5dump/testh5dumpxml.sh.in2
-rw-r--r--tools/h5jam/h5jam.c1
-rw-r--r--tools/h5jam/h5jamgentest.c345
-rw-r--r--tools/h5ls/h5ls.c65
-rwxr-xr-xtools/h5ls/testh5ls.sh4
-rw-r--r--tools/h5repack/h5repack_copy.c56
-rw-r--r--tools/h5repack/h5repack_list.c3
-rw-r--r--tools/h5repack/h5repack_refs.c6
-rw-r--r--tools/h5repack/testh5repack_dset.c2
-rw-r--r--tools/h5repack/testh5repack_main.c1
-rw-r--r--tools/h5repack/testh5repack_make.c19
-rw-r--r--tools/lib/h5diff.c85
-rw-r--r--tools/lib/h5diff_util.c2
-rw-r--r--tools/lib/h5tools.c162
-rw-r--r--tools/lib/h5tools_ref.c6
-rw-r--r--tools/lib/h5trav.c58
-rw-r--r--tools/misc/h5stat.c3
-rw-r--r--tools/testfiles/file3.h5bin3184 -> 3512 bytes
-rw-r--r--tools/testfiles/tall-1.ddl8
-rw-r--r--tools/testfiles/tall-2.ls2
-rw-r--r--tools/testfiles/tall-2A.ddl8
-rw-r--r--tools/testfiles/tall-2A.h5.xml24
-rw-r--r--tools/testfiles/tall-2B.ddl8
-rw-r--r--tools/testfiles/tall.h5bin11440 -> 9744 bytes
-rw-r--r--tools/testfiles/tall.h5.xml24
-rw-r--r--tools/testfiles/tcontents.ddl4
-rw-r--r--tools/testfiles/textlink.h5bin0 -> 1264 bytes
-rw-r--r--tools/testfiles/textlink.h5.xml10
-rw-r--r--tools/testfiles/tfcontents1.h5bin8424 -> 6696 bytes
-rw-r--r--tools/testfiles/tfcontents2.h5bin976 -> 792 bytes
-rw-r--r--tools/testfiles/tmany.h5bin15160 -> 18896 bytes
-rw-r--r--tools/testfiles/tmany.h5.xml44
-rw-r--r--tools/testfiles/tudlink-1.ddl13
-rw-r--r--tools/testfiles/tudlink-1.ls5
-rw-r--r--tools/testfiles/tudlink-2.ddl9
-rw-r--r--tools/testfiles/tudlink.h5bin0 -> 1120 bytes
-rw-r--r--tools/testfiles/tudlink.h5.xml10
-rw-r--r--tools/testfiles/twithub.h5bin10820 -> 8852 bytes
-rw-r--r--tools/testfiles/twithub513.h5bin12560 -> 10920 bytes
44 files changed, 886 insertions, 504 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 11459a4..1811b9d 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -42,6 +42,26 @@
#define FILE8 "file8.h5"
+#define MY_LINKCLASS 187
+/* A UD link traversal function. Shouldn't actually be called. */
+static hid_t UD_traverse(UNUSED const char * link_name, UNUSED hid_t cur_group,
+ UNUSED void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id)
+{
+return -1;
+}
+const H5L_link_class_t UD_link_class[1] = {{
+ H5L_LINK_CLASS_T_VERS, /* H5L_link_class_t version */
+ MY_LINKCLASS, /* Link type id number */
+ "UD link class", /* name for debugging */
+ NULL, /* Creation callback */
+ NULL, /* Move/rename callback */
+ NULL, /* Copy callback */
+ UD_traverse, /* The actual traversal function */
+ NULL, /* Deletion callback */
+ NULL /* Query callback */
+}};
+
+
/*-------------------------------------------------------------------------
* Function: write_attr
*
@@ -2153,7 +2173,7 @@ int test_basic(const char *file1,
* Function: test_basic
*
* Purpose: Compare different HDF5 types (H5G_obj_t):
- * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
+ * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK, H5G_UDLINK
*
*-------------------------------------------------------------------------
*/
@@ -2222,8 +2242,16 @@ int test_types(const char *file1,
*-------------------------------------------------------------------------
*/
- status = H5Glink(fid1, H5G_LINK_SOFT, "g1", "l1");
- status = H5Glink(fid1, H5G_LINK_SOFT, "g2", "l2");
+ status = H5Glink(fid1, H5L_LINK_SOFT, "g1", "l1");
+ status = H5Glink(fid1, H5L_LINK_SOFT, "g2", "l2");
+
+/*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+ H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
+ H5Lregister(UD_link_class);
+ H5Lcreate_ud(fid1, "ud_link", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* Close
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 4bd388a..7a49950 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -271,6 +271,10 @@ static const h5dump_header_t standardformat = {
"", /*dataend */
SOFTLINK, /*softlinkbegin */
"", /*softlinkend */
+ EXTLINK, /*extlinkbegin */
+ "", /*extlinkend */
+ UDLINK, /*udlinkbegin */
+ "", /*udlinkend */
SUBSET, /*subsettingbegin */
"", /*subsettingend */
START, /*startbegin */
@@ -300,6 +304,10 @@ static const h5dump_header_t standardformat = {
"}", /*datablockend */
"{", /*softlinkblockbegin */
"}", /*softlinkblockend */
+ "{", /*extlinkblockbegin */
+ "}", /*extlinkblockend */
+ "{", /*udlinkblockbegin */
+ "}", /*udlinkblockend */
"{", /*strblockbegin */
"}", /*strblockend */
"{", /*enumblockbegin */
@@ -1398,6 +1406,7 @@ dump_all(hid_t group, const char *name, void * op_data)
hid_t obj;
char *obj_path = NULL; /* Full path of object */
H5G_stat_t statbuf;
+ H5L_linkinfo_t linfo; /* Link information */
herr_t ret = SUCCEED;
/* Stat the object */
@@ -1407,6 +1416,12 @@ dump_all(hid_t group, const char *name, void * op_data)
ret = FAIL;
goto done;
} /* end if */
+ if(H5Lget_linkinfo(group, name, &linfo, H5P_DEFAULT) < 0) {
+ error_msg(progname, "unable to get object information\n");
+ d_status = EXIT_FAILURE;
+ ret = FAIL;
+ goto done;
+ } /* end if */
if (*(int *)op_data != H5G_UNKNOWN && statbuf.type != *(int *) op_data)
goto done;
@@ -1433,7 +1448,7 @@ dump_all(hid_t group, const char *name, void * op_data)
indentation(indent + COL);
}
- if (H5Gget_linkval(group, name, statbuf.linklen, targbuf) < 0) {
+ if (H5Lget_linkval(group, name, statbuf.linklen, targbuf, H5P_DEFAULT) < 0) {
error_msg(progname, "unable to get link value\n");
d_status = EXIT_FAILURE;
ret = FAIL;
@@ -1516,7 +1531,128 @@ dump_all(hid_t group, const char *name, void * op_data)
HDfree(targbuf);
break;
}
+ case H5G_UDLINK:
+ {
+ indentation(indent);
+ switch(linfo.linkclass)
+ {
+ case H5L_LINK_EXTERNAL:
+ {
+ char *targbuf;
+ char *filename;
+ char *targname;
+ targbuf = HDmalloc(statbuf.linklen);
+ HDassert(targbuf);
+ if (!doxml) {
+ begin_obj(dump_header_format->extlinkbegin, name,
+ dump_header_format->extlinkblockbegin);
+ }
+ if (H5Lget_linkval(group, name, statbuf.linklen, targbuf, H5P_DEFAULT) < 0) {
+ error_msg(progname, "unable to get external link value\n");
+ d_status = EXIT_FAILURE;
+ ret = FAIL;
+ } else {
+ if(H5Lunpack_elink_val(targbuf, &filename, &targname) < 0) {
+ error_msg(progname, "unable to unpack external link value\n");
+ d_status = EXIT_FAILURE;
+ ret = FAIL;
+ } else {
+ if (!doxml) {
+ indentation(indent + COL);
+ printf("LINKCLASS %d\n", linfo.linkclass);
+ indentation(indent + COL);
+ printf("TARGETFILE \"%s\"\n", filename);
+ indentation(indent + COL);
+ printf("TARGETPATH \"%s\"\n", targname);
+ }
+ else /* XML */
+ {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_filename = xml_escape_the_name(filename);
+ char *t_targname = xml_escape_the_name(targname);
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
+ xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
+
+ printf("<%sExternalLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetFilename=\"%s\" "
+ "TargetPath=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ filename, /* TargetFilename */
+ targname, /* TargetPath*/
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_filename);
+ HDfree(t_targname);
+ HDfree(t_obj_path);
+ }
+ }
+ }
+ if (!doxml) {
+ end_obj(dump_header_format->extlinkend,
+ dump_header_format->extlinkblockend);
+ }
+ HDfree(targbuf);
+ }
+ break;
+ default:
+ if (!doxml) {
+ begin_obj(dump_header_format->udlinkbegin, name,
+ dump_header_format->udlinkblockbegin);
+ indentation(indent + COL);
+ }
+ if (!doxml) {
+ printf("LINKCLASS %d\n", linfo.linkclass);
+ }
+ else /* XML */
+ {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ char *t_obj_path = xml_escape_the_name(obj_path);
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1);
+ xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1);
+ printf("<%sUserDefined LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "LinkClass=\"%d\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />\n",
+ xmlnsprefix,
+ t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ linfo.linkclass, /* LinkClass */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_obj_path);
+ }
+ if (!doxml) {
+ indentation(indent);
+ end_obj(dump_header_format->udlinkend,
+ dump_header_format->udlinkblockend);
+ }
+ }
+ break;
+ }
case H5G_GROUP:
if ((obj = H5Gopen(group, name)) < 0) {
error_msg(progname, "unable to dump group \"%s\"\n", name);
@@ -2003,7 +2139,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_ai)
/* Print all the values. */
if (obj_data == DATASET_DATA) {
- hid_t f_type = H5Dget_type(obj_id);
+ hid_t f_type = H5Dget_type(obj_id);
char string_prefix[64];
h5tool_format_t string_dataformat;
@@ -2683,7 +2819,7 @@ set_output_file(const char *fname, int is_bin)
else
rawdatastream = NULL;
}
-
+
/* binary output */
if (is_bin)
{
@@ -2699,7 +2835,7 @@ set_output_file(const char *fname, int is_bin)
return 0;
}
}
-
+
return -1;
}
@@ -3044,7 +3180,7 @@ handle_groups(hid_t fid, char *group, void UNUSED * data)
/*-------------------------------------------------------------------------
* Function: handle_links
*
- * Purpose: Handle the links from the command.
+ * Purpose: Handle soft or UD links from the command.
*
* Return: void
*
@@ -3059,18 +3195,24 @@ static void
handle_links(hid_t fid, char *links, void UNUSED * data)
{
H5G_stat_t statbuf;
+ H5L_linkinfo_t linfo;
+ char * elink_file;
+ char * elink_path;
if (H5Gget_objinfo(fid, links, FALSE, &statbuf) < 0) {
error_msg(progname, "unable to get obj info from \"%s\"\n", links);
d_status = EXIT_FAILURE;
- } else if (statbuf.type == H5G_LINK) {
+ } else if (H5Lget_linkinfo(fid, links, &linfo, H5P_DEFAULT) < 0) {
+ error_msg(progname, "unable to get link info from \"%s\"\n", links);
+ d_status = EXIT_FAILURE;
+ } else if (statbuf.type == H5G_LINK) { /* Soft link */
char *buf = HDmalloc(statbuf.linklen);
begin_obj(dump_header_format->softlinkbegin, links,
dump_header_format->softlinkblockbegin);
indentation(COL);
- if (H5Gget_linkval(fid, links, statbuf.linklen, buf) >= 0) {
+ if (H5Lget_linkval(fid, links, statbuf.linklen, buf, H5P_DEFAULT) >= 0) {
printf("LINKTARGET \"%s\"\n", buf);
} else {
error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n",
@@ -3080,7 +3222,45 @@ handle_links(hid_t fid, char *links, void UNUSED * data)
end_obj(dump_header_format->softlinkend,
dump_header_format->softlinkblockend);
-
+ HDfree(buf);
+ } else if (statbuf.type == H5G_UDLINK) { /* User-defined link */
+ char *buf = HDmalloc(statbuf.linklen);
+ begin_obj(dump_header_format->udlinkbegin, links,
+ dump_header_format->udlinkblockbegin);
+ indentation(COL);
+ switch(linfo.linkclass) {
+ case H5L_LINK_EXTERNAL:
+ begin_obj(dump_header_format->extlinkbegin, links,
+ dump_header_format->extlinkblockbegin);
+ if (H5Lget_linkval(fid, links, statbuf.linklen, buf, H5P_DEFAULT) >= 0) {
+ if(H5Lunpack_elink_val(buf, &elink_file, &elink_path)>=0) {
+ indentation(COL);
+ printf("LINKCLASS %d\n", linfo.linkclass);
+ indentation(COL);
+ printf("TARGETFILE \"%s\"\n", elink_file);
+ indentation(COL);
+ printf("TARGETPATH \"%s\"\n", elink_path);
+ } else {
+ error_msg(progname, "h5dump error: unable to unpack external link value for \"%s\"\n",
+ links);
+ d_status = EXIT_FAILURE;
+ }
+ } else {
+ error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n",
+ links);
+ d_status = EXIT_FAILURE;
+ }
+ end_obj(dump_header_format->extlinkend,
+ dump_header_format->extlinkblockend);
+ break;
+ default:
+ begin_obj(dump_header_format->udlinkbegin, links,
+ dump_header_format->udlinkblockbegin);
+ indentation(COL);
+ printf("LINKCLASS %d\n", linfo.linkclass);
+ end_obj(dump_header_format->udlinkend,
+ dump_header_format->udlinkblockend);
+ }
HDfree(buf);
} else {
error_msg(progname, "\"%s\" is not a link\n", links);
@@ -5054,7 +5234,8 @@ xml_dump_group(hid_t gid, const char *name)
H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
xtype = H5G_LINK;
H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
-
+ xtype = H5G_UDLINK;
+ H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
}
free(t_name);
free(grpxid);
@@ -5114,7 +5295,8 @@ xml_dump_group(hid_t gid, const char *name)
H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
xtype = H5G_LINK;
H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
-
+ xtype = H5G_UDLINK;
+ H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
}
indent -= COL;
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index dbc5de9..08aa527 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -45,6 +45,8 @@
#define S_SIMPLE "SIMPLE"
#define S_NULL "NULL"
#define SOFTLINK "SOFTLINK"
+#define EXTLINK "EXTERNAL_LINK"
+#define UDLINK "USERDEFINED_LINK"
#define STORAGELAYOUT "STORAGELAYOUT"
#define START "START"
#define STRIDE "STRIDE"
@@ -91,6 +93,10 @@ typedef struct h5dump_header_t {
const char *dataend;
const char *softlinkbegin;
const char *softlinkend;
+ const char *extlinkbegin;
+ const char *extlinkend;
+ const char *udlinkbegin;
+ const char *udlinkend;
const char *subsettingbegin;
const char *subsettingend;
const char *startbegin;
@@ -120,6 +126,10 @@ typedef struct h5dump_header_t {
const char *datablockend;
const char *softlinkblockbegin;
const char *softlinkblockend;
+ const char *extlinkblockbegin;
+ const char *extlinkblockend;
+ const char *udlinkblockbegin;
+ const char *udlinkblockend;
const char *strblockbegin;
const char *strblockend;
const char *enumblockbegin;
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 89652f2..3a5272a 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -79,7 +79,8 @@
#define FILE50 "taindices.h5"
#define FILE51 "tlonglinks.h5"
#define FILE52 "tldouble.h5"
-
+#define FILE53 "textlink.h5"
+#define FILE54 "tudlink.h5"
@@ -120,6 +121,27 @@ const H5Z_class_t H5Z_MYFILTER[1] = {{
}};
+/* A UD link traversal function. Shouldn't actually be called. */
+static hid_t UD_traverse(UNUSED const char * link_name, UNUSED hid_t cur_group,
+ UNUSED void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id)
+{
+return -1;
+}
+
+#define MY_LINKCLASS 187
+
+const H5L_link_class_t UD_link_class[1] = {{
+ H5L_LINK_CLASS_T_VERS, /* H5L_link_class_t version */
+ MY_LINKCLASS, /* Link type id number */
+ "UD link class", /* name for debugging */
+ NULL, /* Creation callback */
+ NULL, /* Move/rename callback */
+ NULL, /* Copy callback */
+ UD_traverse, /* The actual traversal function */
+ NULL, /* Deletion callback */
+ NULL /* Query callback */
+}};
+
#define LENSTR 50
#define LENSTR2 11
@@ -403,8 +425,8 @@ static void gent_softlink(void)
fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
root = H5Gopen (fid, "/");
- H5Glink (root, H5G_LINK_SOFT, "somevalue", "slink1");
- H5Glink (root, H5G_LINK_SOFT, "linkvalue", "slink2");
+ H5Glink (root, H5L_LINK_SOFT, "somevalue", "slink1");
+ H5Glink (root, H5L_LINK_SOFT, "linkvalue", "slink2");
H5Gclose(root);
H5Fclose(fid);
@@ -441,19 +463,48 @@ static void gent_hardlink(void)
H5Dclose(dataset);
group = H5Gcreate (fid, "/g1", 0);
- H5Glink (group, H5G_LINK_HARD, "/dset1", "dset2");
+ H5Glink (group, H5L_LINK_HARD, "/dset1", "dset2");
H5Gclose(group);
group = H5Gcreate (fid, "/g2", 0);
- H5Glink (group, H5G_LINK_HARD, "/dset1", "dset3");
+ H5Glink (group, H5L_LINK_HARD, "/dset1", "dset3");
H5Gclose(group);
group = H5Gopen(fid, "/g1");
- H5Glink (group, H5G_LINK_HARD, "/g2", "g1.1");
+ H5Glink (group, H5L_LINK_HARD, "/g2", "g1.1");
H5Gclose(group);
H5Fclose(fid);
}
+static void gent_extlink(void)
+{
+ hid_t fid;
+
+ /* This external link will dangle, but that's okay */
+ fid = H5Fcreate(FILE53, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_external("filename", "objname", fid, "extlink1", H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_external("anotherfile", "anotherobj", fid, "extlink2", H5P_DEFAULT, H5P_DEFAULT);
+
+ H5Fclose(fid);
+}
+
+static void gent_udlink(void)
+{
+ hid_t fid;
+ char buf[4];
+
+ H5Lregister(UD_link_class);
+
+ /* This ud link will dangle, but that's okay */
+ fid = H5Fcreate(FILE54, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ H5Lcreate_ud(fid, "udlink1", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+ strcpy(buf, "foo");
+ H5Lcreate_ud(fid, "udlink2", MY_LINKCLASS, buf, 4, H5P_DEFAULT, H5P_DEFAULT);
+
+ H5Fclose(fid);
+}
+
+
/*
/
/ | \ \
@@ -830,9 +881,9 @@ static void gent_compound_dt2(void) { /* test compound data type */
/ : g1 g2 attr1 attr2
g1 : g1.1 g1.2
g1.1 : dset1.1.1(attr1, attr2) dset1.1.2
-g1.2 : g1.2.1
+g1.2 : g1.2.1 extlink
g1.2.1 : slink
-g2 : dset2.1 dset2.2
+g2 : dset2.1 dset2.2 udlink
*/
@@ -926,9 +977,12 @@ float dset2_1[10], dset2_2[3][5];
H5Gclose(group);
+ /* external link */
+ H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT);
+
/* soft link */
group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
- H5Glink (group, H5G_LINK_SOFT, "somevalue", "slink");
+ H5Glink (group, H5L_LINK_SOFT, "somevalue", "slink");
H5Gclose(group);
group = H5Gopen (fid, "/g2");
@@ -956,6 +1010,10 @@ float dset2_1[10], dset2_2[3][5];
H5Gclose(group);
+ /* user-defined link */
+ H5Lregister(UD_link_class);
+ H5Lcreate_ud(fid, "/g2/udlink", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+
H5Fclose(fid);
}
@@ -981,8 +1039,8 @@ hid_t fid, group;
group = H5Gcreate (fid, "/g2", 0);
H5Gclose(group);
- H5Glink(fid, H5G_LINK_HARD, "/g2", "/g1/g1.1");
- H5Glink(fid, H5G_LINK_HARD, "/g1", "/g2/g2.1");
+ H5Glink(fid, H5L_LINK_HARD, "/g2", "/g1/g1.1");
+ H5Glink(fid, H5L_LINK_HARD, "/g1", "/g2/g2.1");
H5Fclose(fid);
}
@@ -1001,10 +1059,10 @@ hid_t fid, group;
H5Gclose(group);
/* create path from object at /g1 to object at /g2 and name it g1.1 */
- H5Glink (fid, H5G_LINK_HARD, "/g2", "/g1/g1.1");
+ H5Glink (fid, H5L_LINK_HARD, "/g2", "/g1/g1.1");
/* create path from object at /g2 to object at /g1 and name it g2.1 */
- H5Glink (fid, H5G_LINK_SOFT, "/g1", "/g2/g2.1");
+ H5Glink (fid, H5L_LINK_SOFT, "/g1", "/g2/g2.1");
H5Fclose(fid);
@@ -1012,13 +1070,13 @@ hid_t fid, group;
/*
/
- | | | \ \ \
- g1 g2 g3 g4 g5 g6
- / \ | | \ \ \
- g1.1 g1.2 slink2 link3 dset2 slink4 dset3
- | | (g1) (dset2) (dset3)
- dset1 link1
- (dset1)
+ | | | \ \ \ \ \
+ g1 g2 g3 g4 g5 g6 g7 g8
+ / \ | | \ \ \ \ \
+ g1.1 g1.2 slink2 link3 dset2 slink4 dset3 slink5 elink
+ | | (g1) (dset2) (dset3) (elink) udlink
+ dset1 link1 slink6
+ (dset1) (udlink)
*/
static void gent_many(void) {
@@ -1043,6 +1101,7 @@ static void gent_many(void) {
hsize_t dim[4];
int idx[4] = {0,1,2,3}; /* normal indicies */
const int perm[4] = {0,1,2,3}; /* the 0'th and the 3'rd indices are permuted */
+ herr_t ret;
fid = H5Fcreate(FILE12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1150,11 +1209,11 @@ static void gent_many(void) {
H5Gclose(group);
group = H5Gcreate (fid, "/g1/g1.2", 0);
- H5Glink (group, H5G_LINK_HARD, "/g1/g1.1/dset1", "link1");
+ H5Glink (group, H5L_LINK_HARD, "/g1/g1.1/dset1", "link1");
H5Gclose(group);
group = H5Gcreate (fid, "/g2", 0);
- H5Glink (group, H5G_LINK_SOFT, "/g1", "slink2");
+ H5Glink (group, H5L_LINK_SOFT, "/g1", "slink2");
H5Gclose(group);
group = H5Gcreate (fid, "/g3", 0);
@@ -1178,7 +1237,7 @@ static void gent_many(void) {
H5Gclose(group);
group = H5Gopen(fid, "/g3");
- H5Glink (group, H5G_LINK_HARD, "/g4/dset2", "link3");
+ H5Glink (group, H5L_LINK_HARD, "/g4/dset2", "link3");
H5Gclose(group);
group = H5Gcreate (fid, "/g5", 0);
@@ -1201,10 +1260,26 @@ static void gent_many(void) {
H5Gclose(group);
group = H5Gopen(fid, "/g5");
- H5Glink (group, H5G_LINK_SOFT, "/g6/dset3", "slink4");
+ H5Glink (group, H5L_LINK_SOFT, "/g6/dset3", "slink4");
H5Gclose(group);
H5Pclose(create_plist);
+ group = H5Gcreate (fid, "/g7", 0);
+ H5Gclose(group);
+ group = H5Gcreate (fid, "/g8", 0);
+ H5Gclose(group);
+
+ /* Create dangling external and UD links */
+ H5Lcreate_external("somefile", "somepath", fid, "/g8/elink", H5P_DEFAULT, H5P_DEFAULT);
+ H5Lregister(UD_link_class);
+ H5Lcreate_ud(fid, "/g8/udlink", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Create links to external and UD links */
+ ret= H5Glink (fid, H5L_LINK_SOFT, "/g8/elink", "/g7/slink5");
+ HDassert(ret >= 0);
+ ret= H5Glink (fid, H5L_LINK_SOFT, "/g8/udlink", "/g7/slink6");
+ HDassert(ret >= 0);
+
H5Fclose(fid);
}
@@ -4927,42 +5002,48 @@ static void gent_fcontents(void)
/* hard link to "dset" */
gid1 = H5Gcreate (fid, "/g1", 0);
- H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset1");
+ H5Glink (gid1, H5L_LINK_HARD, "/dset", "dset1");
H5Gclose(gid1);
/* hard link to "dset" */
gid1 = H5Gcreate (fid, "/g2", 0);
- H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset2");
+ H5Glink (gid1, H5L_LINK_HARD, "/dset", "dset2");
H5Gclose(gid1);
/* hard link to "g2" */
gid1 = H5Gopen(fid, "/g1");
- H5Glink (gid1, H5G_LINK_HARD, "/g2", "g1.1");
+ H5Glink (gid1, H5L_LINK_HARD, "/g2", "g1.1");
H5Gclose(gid1);
/* hard link to "dset" */
- ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset3");
+ ret=H5Glink (fid, H5L_LINK_HARD, "/dset", "dset3");
assert(ret>=0);
/* hard link to "dset" */
- ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset4");
+ ret=H5Glink (fid, H5L_LINK_HARD, "/dset", "dset4");
assert(ret>=0);
/* soft link to itself */
- ret=H5Glink (fid, H5G_LINK_SOFT, "mylink", "mylink");
+ ret=H5Glink (fid, H5L_LINK_SOFT, "mylink", "mylink");
assert(ret>=0);
/* soft link to "dset" */
- ret=H5Glink (fid, H5G_LINK_SOFT, "/dset", "softlink");
+ ret=H5Glink (fid, H5L_LINK_SOFT, "/dset", "softlink");
assert(ret>=0);
+ /* dangling external link */
+ ret=H5Lcreate_external("fname", "oname", fid, "extlink", H5P_DEFAULT, H5P_DEFAULT);
+ assert(ret>=0);
+ /* dangling udlink */
+ ret=H5Lcreate_ud(fid, "udlink", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+ assert(ret>=0);
/*-------------------------------------------------------------------------
* datatypes
@@ -5397,11 +5478,11 @@ static void gent_longlinks(void)
objname[F51_MAX_NAME_LEN] = '\0';
/* Create hard link to existing object */
- assert(H5Glink2(fid, "grp1", H5G_LINK_HARD, fid, objname) >= 0);
+ assert(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT) >= 0);
/* Create soft link to existing object */
objname[0] = 'b';
- assert(H5Glink2(fid, "grp1", H5G_LINK_SOFT, fid, objname) >= 0);
+ assert(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT) >= 0);
/* Create group with long name in existing group */
gid2=H5Gcreate(gid, objname, (size_t)0);
@@ -5444,7 +5525,7 @@ static int gent_ldouble(void)
if ((tid = H5Tcopy(H5T_NATIVE_LDOUBLE))<0)
goto error;
- if ((size = H5Tget_size(tid))<0)
+ if ((size = H5Tget_size(tid))==0)
goto error;
if ((did = H5Dcreate(fid, "dset", tid, sid, H5P_DEFAULT))<0)
@@ -5483,6 +5564,8 @@ int main(void)
gent_softlink();
gent_dataset();
gent_hardlink();
+ gent_extlink();
+ gent_udlink();
gent_compound_dt();
gent_all();
gent_loop();
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 783634c..3f40976 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -125,10 +125,12 @@ TOOLTEST tattr-3.ddl --header -a /attr2 --attribute=/attr tattr.h5
# test for displaying attributes in shared datatype (also in group and dataset)
TOOLTEST tnamed_dtype_attr.ddl tnamed_dtype_attr.h5
-# test for displaying soft links
+# test for displaying soft links and user-defined links
TOOLTEST tslink-1.ddl tslink.h5
+TOOLTEST tudlink-1.ddl tudlink.h5
# test for displaying the selected link
TOOLTEST tslink-2.ddl -l slink2 tslink.h5
+TOOLTEST tudlink-2.ddl -l udlink2 tudlink.h5
# tests for hard links
TOOLTEST thlink-1.ddl thlink.h5
diff --git a/tools/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in
index 21db71a..490832e 100755
--- a/tools/h5dump/testh5dumpxml.sh.in
+++ b/tools/h5dump/testh5dumpxml.sh.in
@@ -118,6 +118,8 @@ TOOLTEST tcompound_complex.h5.xml --xml tcompound_complex.h5
TOOLTEST tobjref.h5.xml --xml tobjref.h5
TOOLTEST topaque.h5.xml --xml topaque.h5
TOOLTEST tslink.h5.xml --xml tslink.h5
+TOOLTEST tudlink.h5.xml --xml tudlink.h5
+TOOLTEST textlink.h5.xml --xml textlink.h5
TOOLTEST tstr.h5.xml --xml tstr.h5
TOOLTEST tstr2.h5.xml --xml tstr2.h5
TOOLTEST tref.h5.xml --xml tref.h5
diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c
index 5e4d885..afa9ffa 100644
--- a/tools/h5jam/h5jam.c
+++ b/tools/h5jam/h5jam.c
@@ -15,7 +15,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
-
#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c
index a3a99ca..dd80c29 100644
--- a/tools/h5jam/h5jamgentest.c
+++ b/tools/h5jam/h5jamgentest.c
@@ -65,6 +65,8 @@ char pattern[11] = "abcdefghij";
*/
+#define BUF_SIZE 1024
+
#define LENSTR 50
#define LENSTR2 11
@@ -118,158 +120,63 @@ typedef struct s1_t {
/* VL string datatype name */
#define VLSTR_TYPE "vl_string_type"
+/* A UD link traversal function. Shouldn't actually be called. */
+static hid_t UD_traverse(const char * link_name, hid_t cur_group, void * udata, size_t udata_size, hid_t lapl_id)
+{
+return -1;
+}
+#define MY_LINKCLASS 187
+const H5L_link_class_t UD_link_class[1] = {{
+ H5L_LINK_CLASS_T_VERS, /* H5L_link_class_t version */
+ MY_LINKCLASS, /* Link type id number */
+ "UD link class", /* name for debugging */
+ NULL, /* Creation callback */
+ NULL, /* Move/rename callback */
+ UD_traverse, /* The actual traversal function */
+ NULL, /* Deletion callback */
+ NULL /* Query callback */
+}};
+
-/*
+
+/* gent_ub
+ with no ub, identical to gent_all from h5dumpgentest.c
+
+ FILENAME is the name of the file to create
+ UB_SIZE is the size the buffer should be
+ UB_FILL characters will be set to the PATTERN array,
+ the rest of the user block will be NULL.
/ : g1 g2 attr1 attr2
g1 : g1.1 g1.2
g1.1 : dset1.1.1(attr1, attr2) dset1.1.2
-g1.2 : g1.2.1
+g1.2 : g1.2.1 extlink
g1.2.1 : slink
-g2 : dset2.1 dset2.2
+g2 : dset2.1 dset2.2 udlink
*/
-
-static void gent_all(void) {
-hid_t fid, group, attr, dataset, space;
-hsize_t dims[2];
-int data[2][2], dset1[10][10], dset2[20];
-char buf[60];
-int i, j;
-float dset2_1[10], dset2_2[3][5];
-
- fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* create groups */
- group = H5Gcreate (fid, "/g1", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g2", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.1", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.2", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.2/g1.2.1", 0);
- H5Gclose(group);
-
- /* root attributes */
- group = H5Gopen (fid, "/");
-
- dims[0] = 10;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "abcdefghi");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- dims[0] = 2; dims[1] = 2;
- space = H5Screate_simple(2, dims, NULL);
- attr = H5Acreate (group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT);
- data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3;
- H5Awrite(attr, H5T_NATIVE_INT, data);
- H5Sclose(space);
- H5Aclose(attr);
-
- H5Gclose(group);
-
- group = H5Gopen (fid, "/g1/g1.1");
-
- /* dset1.1.1 */
- dims[0] = 10; dims[1] = 10;
- space = H5Screate_simple(2, dims, NULL);
- dataset = H5Dcreate(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT);
- for (i = 0; i < 10; i++)
- for (j = 0; j < 10; j++)
- dset1[i][j] = j*i;
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1);
- H5Sclose(space);
-
- /* attributes of dset1.1.1 */
- dims[0] = 27;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "1st attribute of dset1.1.1");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- dims[0] = 27;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "2nd attribute of dset1.1.1");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- H5Dclose(dataset);
-
- /* dset1.1.2 */
- dims[0] = 20;
- space = H5Screate_simple(1, dims, NULL);
- dataset = H5Dcreate(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT);
- for (i = 0; i < 20; i++)
- dset2[i] = i;
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2);
- H5Sclose(space);
- H5Dclose(dataset);
-
- H5Gclose(group);
-
- /* soft link */
- group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
- H5Glink (group, H5G_LINK_SOFT, "somevalue", "slink");
- H5Gclose(group);
-
- group = H5Gopen (fid, "/g2");
-
- /* dset2.1 */
- dims[0] = 10;
- space = H5Screate_simple(1, dims, NULL);
- dataset = H5Dcreate(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT);
- for (i = 0; i < 10; i++)
- dset2_1[i] = (float)(i*0.1+1);
- H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1);
- H5Sclose(space);
- H5Dclose(dataset);
-
- /* dset2.2 */
- dims[0] = 3; dims[1] = 5;
- space = H5Screate_simple(2, dims, NULL);
- dataset = H5Dcreate(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT);
- for (i = 0; i < 3; i++)
- for (j = 0; j < 5; j++)
- dset2_2[i][j] = (float)((i+1)*j*0.1);
- H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2);
- H5Sclose(space);
- H5Dclose(dataset);
-
- H5Gclose(group);
-
- H5Fclose(fid);
-
-}
-
-static void gent_withub(void) {
+static void gent_ub(const char * filename, int ub_size, int ub_fill) {
hid_t fid, group, attr, dataset, space;
hid_t create_plist;
hsize_t dims[2];
int data[2][2], dset1[10][10], dset2[20];
-char buf[512];
+char buf[BUF_SIZE];
int i, j;
-unsigned u;
float dset2_1[10], dset2_2[3][5];
int fd;
char *bp;
- create_plist = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_userblock(create_plist,(hsize_t)512);
- fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT);
+ if(ub_size > 0)
+ {
+ create_plist = H5Pcreate(H5P_FILE_CREATE);
+ H5Pset_userblock(create_plist,(hsize_t)ub_size);
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT);
+ }
+ else
+ {
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ }
/* create groups */
group = H5Gcreate (fid, "/g1", 0);
@@ -351,153 +258,12 @@ char *bp;
H5Gclose(group);
- /* soft link */
- group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
- H5Glink (group, H5G_LINK_SOFT, "somevalue", "slink");
- H5Gclose(group);
-
- group = H5Gopen (fid, "/g2");
-
- /* dset2.1 */
- dims[0] = 10;
- space = H5Screate_simple(1, dims, NULL);
- dataset = H5Dcreate(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT);
- for (i = 0; i < 10; i++)
- dset2_1[i] = (float)(i*0.1+1);
- H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1);
- H5Sclose(space);
- H5Dclose(dataset);
-
- /* dset2.2 */
- dims[0] = 3; dims[1] = 5;
- space = H5Screate_simple(2, dims, NULL);
- dataset = H5Dcreate(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT);
- for (i = 0; i < 3; i++)
- for (j = 0; j < 5; j++)
- dset2_2[i][j] = (float)((i+1)*j*0.1);
- H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2);
- H5Sclose(space);
- H5Dclose(dataset);
-
- H5Gclose(group);
-
- H5Fclose(fid);
-
-
- fd = HDopen(FILE8,O_RDWR, 0);
- if (fd < 0) {
- /* panic */
- }
- /* fill buf with pattern */
- memset(buf,'\0',512);
- bp = buf;
- for (u = 0; u < strlen(pattern); u++) {
- *bp++ = pattern[u%10];
- }
-
- HDwrite(fd,buf,512);
-
- close(fd);
-}
-
-static void gent_withub513(void) {
-hid_t fid, group, attr, dataset, space;
-hid_t create_plist;
-hsize_t dims[2];
-int data[2][2], dset1[10][10], dset2[20];
-char buf[1023];
-int i, j;
-float dset2_1[10], dset2_2[3][5];
-int fd;
-char *bp;
-
- create_plist = H5Pcreate(H5P_FILE_CREATE);
- H5Pset_userblock(create_plist,(hsize_t)1024);
- fid = H5Fcreate(FILE9, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT);
-
- /* create groups */
- group = H5Gcreate (fid, "/g1", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g2", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.1", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.2", 0);
- H5Gclose(group);
-
- group = H5Gcreate (fid, "/g1/g1.2/g1.2.1", 0);
- H5Gclose(group);
-
- /* root attributes */
- group = H5Gopen (fid, "/");
-
- dims[0] = 10;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "abcdefghi");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- dims[0] = 2; dims[1] = 2;
- space = H5Screate_simple(2, dims, NULL);
- attr = H5Acreate (group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT);
- data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3;
- H5Awrite(attr, H5T_NATIVE_INT, data);
- H5Sclose(space);
- H5Aclose(attr);
-
- H5Gclose(group);
-
- group = H5Gopen (fid, "/g1/g1.1");
-
- /* dset1.1.1 */
- dims[0] = 10; dims[1] = 10;
- space = H5Screate_simple(2, dims, NULL);
- dataset = H5Dcreate(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT);
- for (i = 0; i < 10; i++)
- for (j = 0; j < 10; j++)
- dset1[i][j] = j*i;
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1);
- H5Sclose(space);
-
- /* attributes of dset1.1.1 */
- dims[0] = 27;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "1st attribute of dset1.1.1");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- dims[0] = 27;
- space = H5Screate_simple(1, dims, NULL);
- attr = H5Acreate (dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT);
- sprintf(buf, "2nd attribute of dset1.1.1");
- H5Awrite(attr, H5T_NATIVE_SCHAR, buf);
- H5Sclose(space);
- H5Aclose(attr);
-
- H5Dclose(dataset);
-
- /* dset1.1.2 */
- dims[0] = 20;
- space = H5Screate_simple(1, dims, NULL);
- dataset = H5Dcreate(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT);
- for (i = 0; i < 20; i++)
- dset2[i] = i;
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2);
- H5Sclose(space);
- H5Dclose(dataset);
-
- H5Gclose(group);
+ /* external link */
+ H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT);
/* soft link */
group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
- H5Glink (group, H5G_LINK_SOFT, "somevalue", "slink");
+ H5Glink (group, H5L_LINK_SOFT, "somevalue", "slink");
H5Gclose(group);
group = H5Gopen (fid, "/g2");
@@ -525,23 +291,32 @@ char *bp;
H5Gclose(group);
+ /* user-defined link */
+ H5Lregister(UD_link_class);
+ H5Lcreate_ud(fid, "/g2/udlink", MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT);
+
H5Fclose(fid);
+ /* If a user block is being used, write to it here */
+ if(ub_size > 0)
+ {
+ HDassert(ub_size < BUF_SIZE);
- fd = HDopen(FILE9,O_RDWR, 0);
+ fd = HDopen(filename,O_RDWR, 0);
if (fd < 0) {
/* panic */
}
/* fill buf with pattern */
- memset(buf,'\0',1024);
+ memset(buf,'\0',ub_size);
bp = buf;
- for (i = 0; i < 513; i++) {
+ for (i = 0; i < ub_fill; i++) {
*bp++ = pattern[i%10];
}
- HDwrite(fd,buf,1024);
+ HDwrite(fd,buf,ub_size);
close(fd);
+ }
}
static void
@@ -636,9 +411,9 @@ create_binfile(UBBIN4,512);
create_binfile(UBBIN5,513);
*/
- gent_all();
- gent_withub();
- gent_withub513();
+ gent_ub(FILE7, 0, 0);
+ gent_ub(FILE8, 512, strlen(pattern));
+ gent_ub(FILE9, 1024, 513);
return 0;
}
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index d279ea3..9a51ce2 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -1710,7 +1710,7 @@ datatype_list2(hid_t type, const char UNUSED *name)
/*-------------------------------------------------------------------------
- * Function: link_open
+ * Function: slink_open
*
* Purpose: This gets called to open a symbolic link. Since symbolic
* links don't correspond to actual objects we simply print the
@@ -1729,11 +1729,11 @@ datatype_list2(hid_t type, const char UNUSED *name)
*-------------------------------------------------------------------------
*/
static hid_t
-link_open(hid_t location, const char *name)
+slink_open(hid_t location, const char *name)
{
char buf[64];
- if (H5Gget_linkval (location, name, sizeof(buf), buf)<0) return -1;
+ if (H5Lget_linkval (location, name, sizeof(buf), buf, H5P_DEFAULT)<0) return -1;
if (NULL==HDmemchr(buf, 0, sizeof(buf))) {
strcpy(buf+sizeof(buf)-4, "...");
}
@@ -1741,6 +1741,59 @@ link_open(hid_t location, const char *name)
return 0;
}
+/*-------------------------------------------------------------------------
+ * Function: udlink_open
+ *
+ * Purpose: This gets called to open a user-defined link. Since these
+ * links don't correspond to actual objects we simply print a message
+ * and return failure.
+ *
+ * Return: Success: 0 - an invalid object but successful return
+ * of this function.
+ *
+ * Failure: -1
+ *
+ * Programmer: James Laird
+ * Tuesday, June 6, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+udlink_open(hid_t location, const char *name)
+{
+ H5L_linkinfo_t linfo;
+ char * buf = NULL;
+ char * filename = NULL;
+ char * path = NULL;
+
+ if(H5Lget_linkinfo(location, name, &linfo, H5P_DEFAULT) < 0) return -1;
+
+ switch(linfo.linkclass)
+ {
+ /* For external links, try to display info for the object it points to */
+ case H5L_LINK_EXTERNAL:
+ if ((buf = HDmalloc(linfo.u.link_size))==NULL) goto error;
+ if (H5Lget_linkval (location, name, sizeof(buf), buf, H5P_DEFAULT)<0) goto error;
+
+ if(H5Lunpack_elink_val(buf, &filename, &path) < 0) goto error;
+ fputs("file: ", stdout);
+ fputs(filename, stdout);
+ fputs(" path: ", stdout);
+ fputs(path, stdout);
+ break;
+
+ default:
+ fputs("cannot follow UD links", stdout);
+ }
+ return 0;
+
+error:
+ if(buf)
+ HDfree(buf);
+ return -1;
+}
/*-------------------------------------------------------------------------
@@ -1828,7 +1881,7 @@ list (hid_t group, const char *name, void *_iter)
/* Show detailed information about the object, beginning with information
* which is common to all objects. */
- if (verbose_g>0 && H5G_LINK!=sb.type) {
+ if (verbose_g>0 && H5G_LINK!=sb.type && H5G_UDLINK!=sb.type) {
if (sb.type>=0)
H5Aiterate(obj, NULL, list_attr, NULL);
printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", sb.fileno[0], objno);
@@ -2063,7 +2116,9 @@ main (int argc, const char *argv[])
NULL, group_list2);
DISPATCH(H5G_TYPE, "Type", H5Topen, H5Tclose,
NULL, datatype_list2);
- DISPATCH(H5G_LINK, "-> ", link_open, NULL,
+ DISPATCH(H5G_LINK, "-> ", slink_open, NULL,
+ NULL, NULL);
+ DISPATCH(H5G_UDLINK, "-> ", udlink_open, NULL,
NULL, NULL);
#if 0
diff --git a/tools/h5ls/testh5ls.sh b/tools/h5ls/testh5ls.sh
index 37581f7..c9aa901 100755
--- a/tools/h5ls/testh5ls.sh
+++ b/tools/h5ls/testh5ls.sh
@@ -118,6 +118,10 @@ TOOLTEST tdset-1.ls -w80 -r -d tdset.h5
# test for displaying soft links
TOOLTEST tslink-1.ls -w80 -r tslink.h5
+# test for displaying external and user-defined links
+TOOLTEST textlink-1.ls -w80 -r textlink.h5
+TOOLTEST tudlink-1.ls -w80 -r tudlink.h5
+
# tests for hard links
TOOLTEST thlink-1.ls -w80 thlink.h5
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index dee6c3f..e59b6d0 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -264,17 +264,17 @@ int do_copy_objects(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- hid_t grp_in; /* group ID */
- hid_t grp_out; /* group ID */
- hid_t dset_in; /* read dataset ID */
- hid_t dset_out; /* write dataset ID */
- hid_t type_in; /* named type ID */
- hid_t type_out; /* named type ID */
- hid_t dcpl_id; /* dataset creation property list ID */
- hid_t dcpl_out; /* dataset creation property list ID */
- hid_t space_id; /* space ID */
- hid_t ftype_id; /* file data type ID */
- hid_t mtype_id; /* memory data type ID */
+ hid_t grp_in=-1; /* group ID */
+ hid_t grp_out=-1; /* group ID */
+ hid_t dset_in=-1; /* read dataset ID */
+ hid_t dset_out=-1; /* write dataset ID */
+ hid_t type_in=-1; /* named type ID */
+ hid_t type_out=-1; /* named type ID */
+ hid_t dcpl_id=-1; /* dataset creation property list ID */
+ hid_t dcpl_out=-1; /* dataset creation property list ID */
+ hid_t space_id=-1; /* space ID */
+ hid_t ftype_id=-1; /* file data type ID */
+ hid_t mtype_id=-1; /* memory data type ID */
size_t msize; /* memory size of memory type */
void *buf=NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
@@ -561,30 +561,18 @@ int do_copy_objects(hid_t fidin,
/*-------------------------------------------------------------------------
* H5G_LINK
+ * H5G_UDLINK
+ *
+ * Only handles external links; H5Lcopy will fail for other UD link types
+ * since we don't have creation or copy callbacks for them.
*-------------------------------------------------------------------------
*/
case H5G_LINK:
+ case H5G_UDLINK:
{
- H5G_stat_t statbuf;
- char *targbuf=NULL;
-
- if (H5Gget_objinfo(fidin,travt->objs[i].name,FALSE,&statbuf)<0)
- goto error;
-
- targbuf = malloc(statbuf.linklen);
-
- if (H5Gget_linkval(fidin,travt->objs[i].name,statbuf.linklen,targbuf)<0)
- goto error;
-
- if (H5Glink(fidout,
- H5G_LINK_SOFT,
- targbuf, /* current name of object */
- travt->objs[i].name /* new name of object */
- )<0)
- goto error;
-
- free(targbuf);
+ if(H5Lcopy(fidin, travt->objs[i].name,fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto error;
if (options->verbose)
printf(FORMAT_OBJ,"link",travt->objs[i].name );
@@ -592,6 +580,14 @@ int do_copy_objects(hid_t fidin,
}
break;
+/*-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
+ */
+ {
+
+ }
+ break;
+
default:
goto error;
}
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c
index 05156d4..5622811 100644
--- a/tools/h5repack/h5repack_list.c
+++ b/tools/h5repack/h5repack_list.c
@@ -198,6 +198,9 @@ void print_objlist(const char *filename,
case H5G_LINK:
printf(" %-10s %s\n", "link", info[i].name );
break;
+ case H5G_UDLINK:
+ printf(" %-10s %s\n", "User defined link", info[i].name );
+ break;
default:
printf(" %-10s %s\n", "User defined object", info[i].name );
break;
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 6e3156b..4884e04 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -93,7 +93,7 @@ int do_copy_refobjs(hid_t fidin,
for ( j=0; j<travt->objs[i].nlinks; j++)
{
H5Glink(fidout,
- H5G_LINK_HARD,
+ H5L_LINK_HARD,
travt->objs[i].name,
travt->objs[i].links[j].new_name);
}
@@ -339,7 +339,7 @@ int do_copy_refobjs(hid_t fidin,
{
for ( j=0; j<travt->objs[i].nlinks; j++){
H5Glink(fidout,
- H5G_LINK_HARD,
+ H5L_LINK_HARD,
travt->objs[i].name,
travt->objs[i].links[j].new_name);
}
@@ -384,10 +384,12 @@ int do_copy_refobjs(hid_t fidin,
/*-------------------------------------------------------------------------
* H5G_LINK
+ * H5G_UDLINK
*-------------------------------------------------------------------------
*/
case H5G_LINK:
+ case H5G_UDLINK:
/*nothing to do */
break;
diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c
index c345028..ca0f0ca 100644
--- a/tools/h5repack/testh5repack_dset.c
+++ b/tools/h5repack/testh5repack_dset.c
@@ -128,7 +128,7 @@ void write_dset_in(hid_t loc_id,
/* create hard link */
- status = H5Glink(loc_id, H5G_LINK_HARD, "string", "string_link");
+ status = H5Glink(loc_id, H5L_LINK_HARD, "string", "string_link");
/*-------------------------------------------------------------------------
* H5T_BITFIELD
diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c
index 58a7c2a..5299cd4 100644
--- a/tools/h5repack/testh5repack_main.c
+++ b/tools/h5repack/testh5repack_main.c
@@ -1170,7 +1170,6 @@ if (szip_can_encode) {
SKIPPED();
#endif
-
/*-------------------------------------------------------------------------
* end
*-------------------------------------------------------------------------
diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c
index 43b68b1..a74d466 100644
--- a/tools/h5repack/testh5repack_make.c
+++ b/tools/h5repack/testh5repack_make.c
@@ -259,7 +259,14 @@ int make_all_objects(hid_t loc_id)
*-------------------------------------------------------------------------
*/
- H5Glink(loc_id, H5G_LINK_SOFT, "dset", "link");
+ H5Glink(loc_id, H5L_LINK_SOFT, "dset", "link");
+
+/*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+ /* Create an external link. Other UD links are not supported by h5repack */
+ H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* write a series of datasetes
@@ -350,11 +357,11 @@ int make_hlinks(hid_t loc_id)
if (write_dset(loc_id,2,dims,"dset",H5T_NATIVE_INT,buf)<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link1 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link1 to dset")<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link2 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link2 to dset")<0)
return -1;
- if (H5Glink(loc_id, H5G_LINK_HARD, "dset", "link3 to dset")<0)
+ if (H5Glink(loc_id, H5L_LINK_HARD, "dset", "link3 to dset")<0)
return -1;
@@ -370,9 +377,9 @@ int make_hlinks(hid_t loc_id)
if ((group3_id = H5Gcreate(group2_id,"g3",0))<0)
return -1;
- if (H5Glink2(loc_id, "g1", H5G_LINK_HARD, group2_id, "link1 to g1")<0)
+ if (H5Glink2(loc_id, "g1", H5L_LINK_HARD, group2_id, "link1 to g1")<0)
return -1;
- if (H5Glink2(group1_id, "g2", H5G_LINK_HARD, group3_id, "link1 to g2")<0)
+ if (H5Glink2(group1_id, "g2", H5L_LINK_HARD, group3_id, "link1 to g2")<0)
return -1;
H5Gclose(group1_id);
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index e8c546e..4fed814 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -870,6 +870,7 @@ hsize_t diff_compare (hid_t file1_id,
* H5G_DATASET Object is a dataset
* H5G_TYPE Object is a named data type
* H5G_LINK Object is a symbolic link
+ * H5G_UDLINK Object is a user-defined link
*
* Return: Number of differences found
*
@@ -1067,6 +1068,90 @@ hsize_t diff (hid_t file1_id,
}
break;
+ /*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+ case H5G_UDLINK:
+ {
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+ H5L_linkinfo_t li1;
+ H5L_linkinfo_t li2;
+
+ if (H5Lget_linkinfo (file1_id, path1, &li1, H5P_DEFAULT) < 0)
+ goto out;
+ if (H5Lget_linkinfo (file1_id, path1, &li2, H5P_DEFAULT) < 0)
+ goto out;
+
+ /* Only external links will have a query function registered */
+ if(li1.linkclass == H5L_LINK_EXTERNAL && li2.linkclass == H5L_LINK_EXTERNAL)
+ {
+ buf1 = HDmalloc (li1.u.link_size);
+ buf2 = HDmalloc (li2.u.link_size);
+
+ if (H5Lget_linkval (file1_id, path1, li1.u.link_size, buf1, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ if (H5Lget_linkval (file2_id, path2, li2.u.link_size, buf2, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+
+ /* If the buffers are the same size, compare them */
+ if(li1.u.link_size == li2.u.link_size)
+ {
+ if (H5Lget_linkval (file1_id, path1, li1.u.link_size, buf1, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ if (H5Lget_linkval (file2_id, path2, li2.u.link_size, buf2, H5P_DEFAULT) < 0)
+ {
+ HDfree (buf1); HDfree (buf2);
+ goto out;
+ }
+ ret = HDmemcmp (buf1, buf2, li1.u.link_size);
+ }
+ else
+ ret = 1;
+
+ /* if "buf1" != "buf2" then the links are "different" */
+ nfound = (ret != 0) ? 1 : 0;
+
+ if (print_objname (options, nfound))
+ parallel_print("External Link: <%s> and <%s>\n", path1, path2);
+ }
+ else
+ {
+ /* If one or both of these links isn't an external link, we can only
+ * compare information from H5Lget_linkinfo since we don't have a query
+ * function registered for them. */
+
+ /* If the link classes or the buffer length are not the
+ * same, the links are "different"
+ */
+ if((li1.linkclass != li2.linkclass) || (li1.u.link_size != li2.u.link_size))
+ nfound = 1;
+ else
+ nfound = 0;
+
+ if (print_objname (options, nfound))
+ parallel_print("User-defined Link: <%s> and <%s>\n", path1, path2);
+ }
+
+ /* always print the number of differences found in verbose mode */
+ if (options->m_verbose)
+ print_found(nfound);
+
+ HDfree (buf1);
+ HDfree (buf2);
+ }
+ break;
+
default:
nfound = 0;
if (options->m_verbose)
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index c2c0659..4997c0c 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -269,6 +269,8 @@ get_type(int type)
return("H5G_TYPE");
case H5G_LINK:
return("H5G_LINK");
+ case H5G_UDLINK:
+ return("H5G_UDLINK");
default:
return("user defined type");
}
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index a4ccf63..cb62c71 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -594,12 +594,12 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
/* Setup */
memset(&buffer, 0, sizeof(h5tools_str_t));
size = H5Tget_size(type);
-
+
if (info->line_ncols > 0)
ncols = info->line_ncols;
-
+
h5tools_simple_prefix(stream, info, ctx, (hsize_t)0, 0);
-
+
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
/* Render the element */
h5tools_str_reset(&buffer);
@@ -1340,7 +1340,7 @@ void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
*
*-------------------------------------------------------------------------
*/
-static
+static
int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
{
unsigned char *mem = (unsigned char*)_mem;
@@ -1349,7 +1349,7 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
size = H5Tget_size(tid);
- for (i = 0; i < nelmts; i++)
+ for (i = 0; i < nelmts; i++)
{
if (render_bin_output(stream,tid,mem + i * size)<0)
{
@@ -1357,7 +1357,7 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
return FAIL;
}
}
-
+
return SUCCEED;
}
@@ -1377,7 +1377,7 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem)
*
*-------------------------------------------------------------------------
*/
-static
+static
int render_bin_output(FILE *stream, hid_t tid, void *_mem)
{
#if 0
@@ -1407,88 +1407,88 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
}
#endif
-
+
size = H5Tget_size(tid);
-
- if (H5Tequal(tid, H5T_NATIVE_FLOAT))
+
+ if (H5Tequal(tid, H5T_NATIVE_FLOAT))
{
memcpy(&tempfloat, mem, sizeof(float));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%g ", tempfloat);
#else
- if (1 != fwrite(&tempfloat, size, 1, stream))
+ if (1 != fwrite(&tempfloat, size, 1, stream))
return FAIL;
#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_DOUBLE))
+ }
+ else if (H5Tequal(tid, H5T_NATIVE_DOUBLE))
{
memcpy(&tempdouble, mem, sizeof(double));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%g ", tempdouble);
#else
- if (1 != fwrite(&tempdouble, size, 1, stream))
+ if (1 != fwrite(&tempdouble, size, 1, stream))
return FAIL;
#endif
- }
+ }
#if H5_SIZEOF_LONG_DOUBLE !=0
- else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE))
+ else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE))
{
memcpy(&templdouble, mem, sizeof(long double));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%Lf ", templdouble);
#else
- if (1 != fwrite(&templdouble, size, 1, stream))
+ if (1 != fwrite(&templdouble, size, 1, stream))
return FAIL;
#endif
}
#endif
- else if (H5T_STRING == H5Tget_class(tid))
+ else if (H5T_STRING == H5Tget_class(tid))
{
unsigned int i;
H5T_str_t pad;
char *s;
-
+
pad = H5Tget_strpad(tid);
-
- if(H5Tis_variable_str(tid))
+
+ if(H5Tis_variable_str(tid))
{
s = *(char**)mem;
if(s!=NULL)
size = HDstrlen(s);
}
- else
+ else
{
s = mem;
size = H5Tget_size(tid);
}
- for (i=0; i<size && (s[i] || pad!=H5T_STR_NULLTERM); i++)
+ for (i=0; i<size && (s[i] || pad!=H5T_STR_NULLTERM); i++)
{
memcpy(&tempuchar, &s[i], sizeof(unsigned char));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%d", tempuchar);
#else
- if (1 != fwrite(&tempuchar, size, 1, stream))
+ if (1 != fwrite(&tempuchar, size, 1, stream))
return FAIL;
#endif
} /* i */
}
- else if (H5Tequal(tid, H5T_NATIVE_INT))
+ else if (H5Tequal(tid, H5T_NATIVE_INT))
{
memcpy(&tempint, mem, sizeof(int));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%d ", tempint);
#else
- if (1 != fwrite(&tempint, size, 1, stream))
+ if (1 != fwrite(&tempint, size, 1, stream))
return FAIL;
#endif
}
- else if (H5Tequal(tid, H5T_NATIVE_UINT))
+ else if (H5Tequal(tid, H5T_NATIVE_UINT))
{
memcpy(&tempuint, mem, sizeof(unsigned int));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%u ", tempuint);
#else
- if (1 != fwrite(&tempuint, size, 1, stream))
+ if (1 != fwrite(&tempuint, size, 1, stream))
return FAIL;
#endif
}
@@ -1498,17 +1498,17 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%d ", tempschar);
#else
- if (1 != fwrite(&tempschar, size, 1, stream))
+ if (1 != fwrite(&tempschar, size, 1, stream))
return FAIL;
#endif
- }
+ }
else if (H5Tequal(tid, H5T_NATIVE_UCHAR))
{
memcpy(&tempuchar, mem, sizeof(unsigned char));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%u ", tempuchar);
#else
- if (1 != fwrite(&tempuchar, size, 1, stream))
+ if (1 != fwrite(&tempuchar, size, 1, stream))
return FAIL;
#endif
}
@@ -1518,7 +1518,7 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%d ", tempshort);
#else
- if (1 != fwrite(&tempshort, size, 1, stream))
+ if (1 != fwrite(&tempshort, size, 1, stream))
return FAIL;
#endif
}
@@ -1528,7 +1528,7 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%u ", tempushort);
#else
- if (1 != fwrite(&tempushort, size, 1, stream))
+ if (1 != fwrite(&tempushort, size, 1, stream))
return FAIL;
#endif
}
@@ -1538,27 +1538,27 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%ld ", templong);
#else
- if (1 != fwrite(&templong, size, 1, stream))
+ if (1 != fwrite(&templong, size, 1, stream))
return FAIL;
#endif
- }
+ }
else if (H5Tequal(tid, H5T_NATIVE_ULONG))
{
memcpy(&tempulong, mem, sizeof(unsigned long));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%lu ", tempulong);
#else
- if (1 != fwrite(&tempulong, size, 1, stream))
+ if (1 != fwrite(&tempulong, size, 1, stream))
return FAIL;
#endif
- }
+ }
else if (H5Tequal(tid, H5T_NATIVE_LLONG))
{
memcpy(&templlong, mem, sizeof(long_long));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, fmt_llong, templlong);
#else
- if (1 != fwrite(&templlong, size, 1, stream))
+ if (1 != fwrite(&templlong, size, 1, stream))
return FAIL;
#endif
}
@@ -1568,29 +1568,29 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, fmt_ullong, tempullong);
#else
- if (1 != fwrite(&tempullong, size, 1, stream))
+ if (1 != fwrite(&tempullong, size, 1, stream))
return FAIL;
#endif
}
- else if (H5Tequal(tid, H5T_NATIVE_HSSIZE))
+ else if (H5Tequal(tid, H5T_NATIVE_HSSIZE))
{
- if (sizeof(hssize_t) == sizeof(int))
+ if (sizeof(hssize_t) == sizeof(int))
{
memcpy(&tempint, mem, sizeof(int));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%d ", tempint);
#else
- if (1 != fwrite(&tempint, size, 1, stream))
+ if (1 != fwrite(&tempint, size, 1, stream))
return FAIL;
#endif
}
- else if (sizeof(hssize_t) == sizeof(long))
+ else if (sizeof(hssize_t) == sizeof(long))
{
memcpy(&templong, mem, sizeof(long));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%ld ", templong);
#else
- if (1 != fwrite(&templong, size, 1, stream))
+ if (1 != fwrite(&templong, size, 1, stream))
return FAIL;
#endif
}
@@ -1600,30 +1600,30 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, fmt_llong, templlong);
#else
- if (1 != fwrite(&templlong, size, 1, stream))
+ if (1 != fwrite(&templlong, size, 1, stream))
return FAIL;
#endif
}
- }
- else if (H5Tequal(tid, H5T_NATIVE_HSIZE))
+ }
+ else if (H5Tequal(tid, H5T_NATIVE_HSIZE))
{
- if (sizeof(hsize_t) == sizeof(int))
+ if (sizeof(hsize_t) == sizeof(int))
{
memcpy(&tempuint, mem, sizeof(unsigned int));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%u ", tempuint);
#else
- if (1 != fwrite(&tempuint, size, 1, stream))
+ if (1 != fwrite(&tempuint, size, 1, stream))
return FAIL;
#endif
}
- else if (sizeof(hsize_t) == sizeof(long))
+ else if (sizeof(hsize_t) == sizeof(long))
{
memcpy(&tempulong, mem, sizeof(unsigned long));
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%lu ", tempulong);
#else
- if (1 != fwrite(&tempulong, size, 1, stream))
+ if (1 != fwrite(&tempulong, size, 1, stream))
return FAIL;
#endif
}
@@ -1633,57 +1633,57 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, fmt_ullong, tempullong);
#else
- if (1 != fwrite(&tempullong, size, 1, stream))
+ if (1 != fwrite(&tempullong, size, 1, stream))
return FAIL;
#endif
}
}
- else if (H5Tget_class(tid) == H5T_COMPOUND)
+ else if (H5Tget_class(tid) == H5T_COMPOUND)
{
unsigned j;
hid_t memb;
unsigned nmembs;
size_t offset;
-
+
nmembs = H5Tget_nmembers(tid);
-
- for (j = 0; j < nmembs; j++)
+
+ for (j = 0; j < nmembs; j++)
{
offset = H5Tget_member_offset(tid, j);
memb = H5Tget_member_type(tid, j);
-
+
if (render_bin_output(stream,memb,mem + offset)<0)
return FAIL;
-
+
H5Tclose(memb);
}
}
- else if (H5Tget_class(tid) == H5T_ENUM)
+ else if (H5Tget_class(tid) == H5T_ENUM)
{
unsigned int i;
- if (1==size)
+ if (1==size)
{
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "0x%02x", mem[0]);
#else
- if (1 != fwrite(&mem[0], size, 1, stream))
+ if (1 != fwrite(&mem[0], size, 1, stream))
return FAIL;
#endif
- }
- else
+ }
+ else
{
for (i = 0; i < size; i++)
{
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%s%02x", i?":":"", mem[i]);
#else
- if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
+ if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
return FAIL;
#endif
} /*i*/
}/*else 1 */
}
- else if (H5Tget_class(tid) == H5T_ARRAY)
+ else if (H5Tget_class(tid) == H5T_ARRAY)
{
int k, ndims;
hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts;
@@ -1703,63 +1703,63 @@ int render_bin_output(FILE *stream, hid_t tid, void *_mem)
temp_nelmts *= dims[k];
nelmts = (size_t)temp_nelmts;
}
-
+
/* dump the array element */
- for (i = 0; i < nelmts; i++)
+ for (i = 0; i < nelmts; i++)
{
if (render_bin_output(stream,memb,mem + i * size)<0)
return FAIL;
}
-
+
H5Tclose(memb);
}
- else if (H5Tget_class(tid) == H5T_VLEN)
+ else if (H5Tget_class(tid) == H5T_VLEN)
{
unsigned int i;
hsize_t nelmts;
hid_t memb;
-
+
/* get the VL sequences's base datatype for each element */
memb = H5Tget_super(tid);
size = H5Tget_size(memb);
-
+
/* Get the number of sequence elements */
nelmts = ((hvl_t *)mem)->len;
-
- for (i = 0; i < nelmts; i++)
+
+ for (i = 0; i < nelmts; i++)
{
/* dump the array element */
if (render_bin_output(stream,memb,((char *)(((hvl_t *)mem)->p)) + i * size)<0)
return FAIL;
- }
+ }
H5Tclose(memb);
}
- else
+ else
{
size_t i;
- if (1==size)
+ if (1==size)
{
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "0x%02x", mem[0]);
#else
- if (1 != fwrite(&mem[0], size, 1, stream))
+ if (1 != fwrite(&mem[0], size, 1, stream))
return FAIL;
#endif
- }
- else
+ }
+ else
{
for (i = 0; i < size; i++)
{
#ifdef DEBUG_H5DUMP_BIN
fprintf(stream, "%s%02x", i?":":"", mem[i]);
#else
- if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
+ if (1 != fwrite(&mem[i], sizeof(char), 1, stream))
return FAIL;
#endif
} /*i*/
}/*else 1 */
}
-
+
return SUCCEED;
}
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index f49cb07..5d6cfae 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -171,6 +171,12 @@ ref_path_table_lookup(const char *thepath)
if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0)
/* fatal error ? */
return HADDR_UNDEF;
+ } else if(sb.type == H5G_UDLINK)
+ {
+ /* UD links can't be followed, so they always "dangle" like
+ * soft links.
+ */
+ return HADDR_UNDEF;
} /* end if */
objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long)));
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index f5c6e91..2ff927c 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -462,7 +462,7 @@ static int traverse( hid_t loc_id,
*/
case H5G_LINK:
- {
+ {
/* increment */
inserted_objs++;
@@ -489,9 +489,60 @@ static int traverse( hid_t loc_id,
break;
+ /*-------------------------------------------------------------------------
+ * H5G_UDLINK
+ *-------------------------------------------------------------------------
+ */
+
+ case H5G_UDLINK:
+ {
+ H5L_linkinfo_t linkbuf;
+
+ /* increment */
+ inserted_objs++;
+
+ /* add object to table */
+ trav_table_add(HADDR_UNDEF, path, H5G_UDLINK, table );
+
+ /* Get type of link */
+ H5E_BEGIN_TRY {
+
+ /* get link class info */
+ H5Lget_linkinfo( loc_id, path, &linkbuf, H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ if(linkbuf.linkclass == H5L_LINK_EXTERNAL)
+ {
+ if (statbuf.linklen>0)
+ {
+ char *targbuf;
+ char *objname;
+
+ targbuf = HDmalloc(statbuf.linklen);
+ assert(targbuf);
+ H5Gget_linkval(loc_id,path,statbuf.linklen,targbuf);
+ H5Lunpack_elink_val(targbuf, NULL, &objname);
+ if (print)
+ printf(" %-10s %s -> %s %s\n", "ext link", path, targbuf, objname);
+ free(targbuf);
+ }
+ else
+ {
+ if (print)
+ printf(" %-10s %s ->\n", "udlink", path);
+ }
+ }
+ else /* Unknown user-defined type */
+ {
+ if (print)
+ printf(" %-10s %s ->\n", "UD link type", path);
+ }
+ }
+ break;
+
default:
- HDfprintf(stderr, "traverse: Unknown object!\n");
+ HDfprintf(stderr, "traverse: Unknown object %d!\n", type); /* JAMES */
return (-1);
break;
@@ -548,6 +599,9 @@ void h5trav_printinfo(int nobjs, trav_info_t *travi)
case H5G_LINK:
printf(" %-10s %s\n", "link", travi[i].name );
break;
+ case H5G_UDLINK:
+ printf(" %-10s %s\n", "User defined link", travi[i].name );
+ break;
default:
printf(" %-10s %s\n", "User defined object", travi[i].name );
break;
diff --git a/tools/misc/h5stat.c b/tools/misc/h5stat.c
index 4855e68..5d0f23b 100644
--- a/tools/misc/h5stat.c
+++ b/tools/misc/h5stat.c
@@ -608,7 +608,8 @@ printf("walk: fullname = %s\n", fullname);
break;
case H5G_LINK:
- /* Gather statistics about this type of object */
+ case H5G_UDLINK:
+ /* Gather statistics about links and UD links */
iter->uniq_links++;
break;
diff --git a/tools/testfiles/file3.h5 b/tools/testfiles/file3.h5
index 4750ce9..a9eff83 100644
--- a/tools/testfiles/file3.h5
+++ b/tools/testfiles/file3.h5
Binary files differ
diff --git a/tools/testfiles/tall-1.ddl b/tools/testfiles/tall-1.ddl
index 2fd5494..6069293 100644
--- a/tools/testfiles/tall-1.ddl
+++ b/tools/testfiles/tall-1.ddl
@@ -64,6 +64,11 @@ GROUP "/" {
}
}
GROUP "g1.2" {
+ EXTERNAL_LINK "extlink" {
+ LINKCLASS 64
+ TARGETFILE "somefile"
+ TARGETPATH "somepath"
+}
GROUP "g1.2.1" {
SOFTLINK "slink" {
LINKTARGET "somevalue"
@@ -88,6 +93,9 @@ GROUP "/" {
(2,0): 0, 0.3, 0.6, 0.9, 1.2
}
}
+ USERDEFINED_LINK "udlink" {
+ LINKCLASS 187
+ }
}
}
}
diff --git a/tools/testfiles/tall-2.ls b/tools/testfiles/tall-2.ls
index e1b0bcf..5513214 100644
--- a/tools/testfiles/tall-2.ls
+++ b/tools/testfiles/tall-2.ls
@@ -15,6 +15,7 @@
Data:
(0) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
/g1/g1.2 Group
+/g1/g1.2/extlink -> file: somefile path: somepath
/g1/g1.2/g1.2.1 Group
/g1/g1.2/g1.2.1/slink -> somevalue
/g2 Group
@@ -25,3 +26,4 @@
Data:
(0,0) 0, 0.1, 0.2, 0.3, 0.4, 0, 0.2, 0.4, 0.6, 0.8, 0, 0.3, 0.6, 0.9,
(2,4) 1.2
+/g2/udlink -> cannot follow UD links
diff --git a/tools/testfiles/tall-2A.ddl b/tools/testfiles/tall-2A.ddl
index 604c307..b16feb8 100644
--- a/tools/testfiles/tall-2A.ddl
+++ b/tools/testfiles/tall-2A.ddl
@@ -48,6 +48,11 @@ GROUP "/" {
}
}
GROUP "g1.2" {
+ EXTERNAL_LINK "extlink" {
+ LINKCLASS 64
+ TARGETFILE "somefile"
+ TARGETPATH "somepath"
+}
GROUP "g1.2.1" {
SOFTLINK "slink" {
LINKTARGET "somevalue"
@@ -64,6 +69,9 @@ GROUP "/" {
DATATYPE H5T_IEEE_F32BE
DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) }
}
+ USERDEFINED_LINK "udlink" {
+ LINKCLASS 187
+ }
}
}
}
diff --git a/tools/testfiles/tall-2A.h5.xml b/tools/testfiles/tall-2A.h5.xml
index e83f0b3..586afb5 100644
--- a/tools/testfiles/tall-2A.h5.xml
+++ b/tools/testfiles/tall-2A.h5.xml
@@ -3,7 +3,7 @@ Expected output for 'h5dump --xml -A tall.h5'
#############################
<?xml version="1.0" encoding="UTF-8"?>
<hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd">
-<hdf5:RootGroup OBJ-XID="xid_928" H5Path="/">
+<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/">
<hdf5:Attribute Name="attr1">
<hdf5:Dataspace>
<hdf5:SimpleDataspace Ndims="1">
@@ -40,9 +40,9 @@ Expected output for 'h5dump --xml -A tall.h5'
</hdf5:DataFromFile>
</hdf5:Data>
</hdf5:Attribute>
- <hdf5:Group Name="g1" OBJ-XID="xid_1576" H5Path="/g1" Parents="xid_928" H5ParentPaths="/" >
- <hdf5:Group Name="g1.1" OBJ-XID="xid_3200" H5Path="/g1/g1.1" Parents="xid_1576" H5ParentPaths="/g1" >
- <hdf5:Dataset Name="dset1.1.1" OBJ-XID="xid_5200" H5Path= "/g1/g1.1/dset1.1.1" Parents="xid_3200" H5ParentPaths="/g1/g1.1">
+ <hdf5:Group Name="g1" OBJ-XID="xid_792" H5Path="/g1" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Group Name="g1.1" OBJ-XID="xid_2512" H5Path="/g1/g1.1" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Dataset Name="dset1.1.1" OBJ-XID="xid_5432" H5Path= "/g1/g1.1/dset1.1.1" Parents="xid_2512" H5ParentPaths="/g1/g1.1">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -102,7 +102,7 @@ Expected output for 'h5dump --xml -A tall.h5'
<hdf5:NoData/>
</hdf5:Data>
</hdf5:Dataset>
- <hdf5:Dataset Name="dset1.1.2" OBJ-XID="xid_5800" H5Path= "/g1/g1.1/dset1.1.2" Parents="xid_3200" H5ParentPaths="/g1/g1.1">
+ <hdf5:Dataset Name="dset1.1.2" OBJ-XID="xid_8272" H5Path= "/g1/g1.1/dset1.1.2" Parents="xid_2512" H5ParentPaths="/g1/g1.1">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -126,14 +126,15 @@ Expected output for 'h5dump --xml -A tall.h5'
</hdf5:Data>
</hdf5:Dataset>
</hdf5:Group>
- <hdf5:Group Name="g1.2" OBJ-XID="xid_4176" H5Path="/g1/g1.2" Parents="xid_1576" H5ParentPaths="/g1" >
- <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4824" H5Path="/g1/g1.2/g1.2.1" Parents="xid_4176" H5ParentPaths="/g1/g1.2" >
- <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4824" H5ParentPaths="/g1/g1.2/g1.2.1" />
+ <hdf5:Group Name="g1.2" OBJ-XID="xid_3536" H5Path="/g1/g1.2" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4232" H5Path="/g1/g1.2/g1.2.1" Parents="xid_3536" H5ParentPaths="/g1/g1.2" >
+ <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4232" H5ParentPaths="/g1/g1.2/g1.2.1" />
</hdf5:Group>
+ <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3536" H5ParentPaths="/g1/g1.2" />
</hdf5:Group>
</hdf5:Group>
- <hdf5:Group Name="g2" OBJ-XID="xid_2552" H5Path="/g2" Parents="xid_928" H5ParentPaths="/" >
- <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_8520" H5Path= "/g2/dset2.1" Parents="xid_2552" H5ParentPaths="/g2">
+ <hdf5:Group Name="g2" OBJ-XID="xid_1816" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_8872" H5Path= "/g2/dset2.1" Parents="xid_1816" H5ParentPaths="/g2">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -156,7 +157,7 @@ Expected output for 'h5dump --xml -A tall.h5'
<hdf5:NoData/>
</hdf5:Data>
</hdf5:Dataset>
- <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9120" H5Path= "/g2/dset2.2" Parents="xid_2552" H5ParentPaths="/g2">
+ <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9472" H5Path= "/g2/dset2.2" Parents="xid_1816" H5ParentPaths="/g2">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -180,6 +181,7 @@ Expected output for 'h5dump --xml -A tall.h5'
<hdf5:NoData/>
</hdf5:Data>
</hdf5:Dataset>
+ <hdf5:UserDefined LinkName="udlink" OBJ-XID="xid_18446744073709551612" H5SourcePath="/g2/udlink" LinkClass="187" Parents="xid_1816" H5ParentPaths="/g2" />
</hdf5:Group>
</hdf5:RootGroup>
</hdf5:HDF5-File>
diff --git a/tools/testfiles/tall-2B.ddl b/tools/testfiles/tall-2B.ddl
index 4969987..002156e 100644
--- a/tools/testfiles/tall-2B.ddl
+++ b/tools/testfiles/tall-2B.ddl
@@ -44,6 +44,11 @@ GROUP "/" {
}
}
GROUP "g1.2" {
+ EXTERNAL_LINK "extlink" {
+ LINKCLASS 64
+ TARGETFILE "somefile"
+ TARGETPATH "somepath"
+}
GROUP "g1.2.1" {
SOFTLINK "slink" {
LINKTARGET "somevalue"
@@ -60,6 +65,9 @@ GROUP "/" {
DATATYPE H5T_IEEE_F32BE
DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) }
}
+ USERDEFINED_LINK "udlink" {
+ LINKCLASS 187
+ }
}
}
}
diff --git a/tools/testfiles/tall.h5 b/tools/testfiles/tall.h5
index 2bc4993..0ed5ed2 100644
--- a/tools/testfiles/tall.h5
+++ b/tools/testfiles/tall.h5
Binary files differ
diff --git a/tools/testfiles/tall.h5.xml b/tools/testfiles/tall.h5.xml
index 22e6f51..ce740fe 100644
--- a/tools/testfiles/tall.h5.xml
+++ b/tools/testfiles/tall.h5.xml
@@ -3,7 +3,7 @@ Expected output for 'h5dump --xml tall.h5'
#############################
<?xml version="1.0" encoding="UTF-8"?>
<hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd">
-<hdf5:RootGroup OBJ-XID="xid_928" H5Path="/">
+<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/">
<hdf5:Attribute Name="attr1">
<hdf5:Dataspace>
<hdf5:SimpleDataspace Ndims="1">
@@ -40,9 +40,9 @@ Expected output for 'h5dump --xml tall.h5'
</hdf5:DataFromFile>
</hdf5:Data>
</hdf5:Attribute>
- <hdf5:Group Name="g1" OBJ-XID="xid_1576" H5Path="/g1" Parents="xid_928" H5ParentPaths="/" >
- <hdf5:Group Name="g1.1" OBJ-XID="xid_3200" H5Path="/g1/g1.1" Parents="xid_1576" H5ParentPaths="/g1" >
- <hdf5:Dataset Name="dset1.1.1" OBJ-XID="xid_5200" H5Path= "/g1/g1.1/dset1.1.1" Parents="xid_3200" H5ParentPaths="/g1/g1.1">
+ <hdf5:Group Name="g1" OBJ-XID="xid_792" H5Path="/g1" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Group Name="g1.1" OBJ-XID="xid_2512" H5Path="/g1/g1.1" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Dataset Name="dset1.1.1" OBJ-XID="xid_5432" H5Path= "/g1/g1.1/dset1.1.1" Parents="xid_2512" H5ParentPaths="/g1/g1.1">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -113,7 +113,7 @@ Expected output for 'h5dump --xml tall.h5'
</hdf5:DataFromFile>
</hdf5:Data>
</hdf5:Dataset>
- <hdf5:Dataset Name="dset1.1.2" OBJ-XID="xid_5800" H5Path= "/g1/g1.1/dset1.1.2" Parents="xid_3200" H5ParentPaths="/g1/g1.1">
+ <hdf5:Dataset Name="dset1.1.2" OBJ-XID="xid_8272" H5Path= "/g1/g1.1/dset1.1.2" Parents="xid_2512" H5ParentPaths="/g1/g1.1">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -139,14 +139,15 @@ Expected output for 'h5dump --xml tall.h5'
</hdf5:Data>
</hdf5:Dataset>
</hdf5:Group>
- <hdf5:Group Name="g1.2" OBJ-XID="xid_4176" H5Path="/g1/g1.2" Parents="xid_1576" H5ParentPaths="/g1" >
- <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4824" H5Path="/g1/g1.2/g1.2.1" Parents="xid_4176" H5ParentPaths="/g1/g1.2" >
- <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4824" H5ParentPaths="/g1/g1.2/g1.2.1" />
+ <hdf5:Group Name="g1.2" OBJ-XID="xid_3536" H5Path="/g1/g1.2" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4232" H5Path="/g1/g1.2/g1.2.1" Parents="xid_3536" H5ParentPaths="/g1/g1.2" >
+ <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4232" H5ParentPaths="/g1/g1.2/g1.2.1" />
</hdf5:Group>
+ <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3536" H5ParentPaths="/g1/g1.2" />
</hdf5:Group>
</hdf5:Group>
- <hdf5:Group Name="g2" OBJ-XID="xid_2552" H5Path="/g2" Parents="xid_928" H5ParentPaths="/" >
- <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_8520" H5Path= "/g2/dset2.1" Parents="xid_2552" H5ParentPaths="/g2">
+ <hdf5:Group Name="g2" OBJ-XID="xid_1816" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_8872" H5Path= "/g2/dset2.1" Parents="xid_1816" H5ParentPaths="/g2">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -171,7 +172,7 @@ Expected output for 'h5dump --xml tall.h5'
</hdf5:DataFromFile>
</hdf5:Data>
</hdf5:Dataset>
- <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9120" H5Path= "/g2/dset2.2" Parents="xid_2552" H5ParentPaths="/g2">
+ <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9472" H5Path= "/g2/dset2.2" Parents="xid_1816" H5ParentPaths="/g2">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -199,6 +200,7 @@ Expected output for 'h5dump --xml tall.h5'
</hdf5:DataFromFile>
</hdf5:Data>
</hdf5:Dataset>
+ <hdf5:UserDefined LinkName="udlink" OBJ-XID="xid_18446744073709551612" H5SourcePath="/g2/udlink" LinkClass="187" Parents="xid_1816" H5ParentPaths="/g2" />
</hdf5:Group>
</hdf5:RootGroup>
</hdf5:HDF5-File>
diff --git a/tools/testfiles/tcontents.ddl b/tools/testfiles/tcontents.ddl
index 43afb9d..935ff8c 100644
--- a/tools/testfiles/tcontents.ddl
+++ b/tools/testfiles/tcontents.ddl
@@ -3,11 +3,12 @@ Expected output for 'h5dump -n tfcontents1.h5'
#############################
HDF5 "tfcontents1.h5" {
FILE_CONTENTS {
- datatype /#5696
+ datatype /#6056
dataset /dset
dataset /dset3 -> /dset
dataset /dset4 -> /dset
dataset /dsetmytype2
+ ext link /extlink -> fname oname
group /g1
dataset /g1/dset1 -> /dset
group /g1/g1.1
@@ -16,5 +17,6 @@ FILE_CONTENTS {
link /mylink -> mylink
datatype /mytype
link /softlink -> /dset
+ UD link type /udlink ->
}
}
diff --git a/tools/testfiles/textlink.h5 b/tools/testfiles/textlink.h5
new file mode 100644
index 0000000..a851011
--- /dev/null
+++ b/tools/testfiles/textlink.h5
Binary files differ
diff --git a/tools/testfiles/textlink.h5.xml b/tools/testfiles/textlink.h5.xml
new file mode 100644
index 0000000..fe6f68a
--- /dev/null
+++ b/tools/testfiles/textlink.h5.xml
@@ -0,0 +1,10 @@
+#############################
+Expected output for 'h5dump --xml textlink.h5'
+#############################
+<?xml version="1.0" encoding="UTF-8"?>
+<hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd">
+<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/">
+ <hdf5:ExternalLink LinkName="extlink1" OBJ-XID="xid_18446744073709551614" H5SourcePath="/extlink1" TargetFilename="filename" TargetPath="objname" Parents="xid_96" H5ParentPaths="/" />
+ <hdf5:ExternalLink LinkName="extlink2" OBJ-XID="xid_18446744073709551613" H5SourcePath="/extlink2" TargetFilename="anotherfile" TargetPath="anotherobj" Parents="xid_96" H5ParentPaths="/" />
+</hdf5:RootGroup>
+</hdf5:HDF5-File>
diff --git a/tools/testfiles/tfcontents1.h5 b/tools/testfiles/tfcontents1.h5
index a7cf2d3..8b043fb 100644
--- a/tools/testfiles/tfcontents1.h5
+++ b/tools/testfiles/tfcontents1.h5
Binary files differ
diff --git a/tools/testfiles/tfcontents2.h5 b/tools/testfiles/tfcontents2.h5
index 216a885..1df0779 100644
--- a/tools/testfiles/tfcontents2.h5
+++ b/tools/testfiles/tfcontents2.h5
Binary files differ
diff --git a/tools/testfiles/tmany.h5 b/tools/testfiles/tmany.h5
index 271f13a..0422f93 100644
--- a/tools/testfiles/tmany.h5
+++ b/tools/testfiles/tmany.h5
Binary files differ
diff --git a/tools/testfiles/tmany.h5.xml b/tools/testfiles/tmany.h5.xml
index 60ccb08..1f7fa70 100644
--- a/tools/testfiles/tmany.h5.xml
+++ b/tools/testfiles/tmany.h5.xml
@@ -3,10 +3,10 @@ Expected output for 'h5dump --xml tmany.h5'
#############################
<?xml version="1.0" encoding="UTF-8"?>
<hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd">
-<hdf5:RootGroup OBJ-XID="xid_696" H5Path="/">
- <hdf5:Group Name="g1" OBJ-XID="xid_1344" H5Path="/g1" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:Group Name="g1.1" OBJ-XID="xid_2320" H5Path="/g1/g1.1" Parents="xid_1344" H5ParentPaths="/g1" >
- <hdf5:Dataset Name="dset1" OBJ-XID="xid_2696" H5Path= "/g1/g1.1/dset1" Parents="xid_2320" H5ParentPaths="/g1/g1.1">
+<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/">
+ <hdf5:Group Name="g1" OBJ-XID="xid_792" H5Path="/g1" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Group Name="g1.1" OBJ-XID="xid_1816" H5Path="/g1/g1.1" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Dataset Name="dset1" OBJ-XID="xid_2840" H5Path= "/g1/g1.1/dset1" Parents="xid_1816" H5ParentPaths="/g1/g1.1">
<hdf5:StorageLayout>
<hdf5:ChunkedLayout Ndims="1">
<hdf5:ChunkDimension DimSize="2" />
@@ -265,17 +265,17 @@ Expected output for 'h5dump --xml tmany.h5'
</hdf5:Data>
</hdf5:Dataset>
</hdf5:Group>
- <hdf5:Group Name="g1.2" OBJ-XID="xid_5832" H5Path="/g1/g1.2" Parents="xid_1344" H5ParentPaths="/g1" >
- <hdf5:Dataset Name="link1" OBJ-XID="xid_2696-1" H5Path="/g1/g1.2/link1" Parents="xid_5832" H5ParentPaths="/g1/g1.2">
- <hdf5:DatasetPtr OBJ-XID="xid_2696" H5Path="/g1/g1.2/link1"/>
+ <hdf5:Group Name="g1.2" OBJ-XID="xid_6040" H5Path="/g1/g1.2" Parents="xid_792" H5ParentPaths="/g1" >
+ <hdf5:Dataset Name="link1" OBJ-XID="xid_2840-1" H5Path="/g1/g1.2/link1" Parents="xid_6040" H5ParentPaths="/g1/g1.2">
+ <hdf5:DatasetPtr OBJ-XID="xid_2840" H5Path="/g1/g1.2/link1"/>
</hdf5:Dataset>
</hdf5:Group>
</hdf5:Group>
- <hdf5:Group Name="g2" OBJ-XID="xid_6808" H5Path="/g2" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:SoftLink LinkName="slink2" OBJ-XID="xid_1344" H5SourcePath="/g2/slink2" TargetPath="/g1" TargetObj="xid_1344" Parents="xid_6808" H5ParentPaths="/g2" />
+ <hdf5:Group Name="g2" OBJ-XID="xid_6520" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:SoftLink LinkName="slink2" OBJ-XID="xid_792" H5SourcePath="/g2/slink2" TargetPath="/g1" TargetObj="xid_792" Parents="xid_6520" H5ParentPaths="/g2" />
</hdf5:Group>
- <hdf5:Group Name="g3" OBJ-XID="xid_7784" H5Path="/g3" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:Dataset Name="link3" OBJ-XID="xid_8480" H5Path= "/g3/link3" Parents="xid_7784" H5ParentPaths="/g3">
+ <hdf5:Group Name="g3" OBJ-XID="xid_10160" H5Path="/g3" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Dataset Name="link3" OBJ-XID="xid_11552" H5Path= "/g3/link3" Parents="xid_10160" H5ParentPaths="/g3">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -311,16 +311,16 @@ Expected output for 'h5dump --xml tmany.h5'
</hdf5:Data>
</hdf5:Dataset>
</hdf5:Group>
- <hdf5:Group Name="g4" OBJ-XID="xid_8432" H5Path="/g4" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:Dataset Name="dset2" OBJ-XID="xid_8480-2" H5Path="/g4/dset2" Parents="xid_8432" H5ParentPaths="/g4">
- <hdf5:DatasetPtr OBJ-XID="xid_8480" H5Path="/g4/dset2"/>
+ <hdf5:Group Name="g4" OBJ-XID="xid_10856" H5Path="/g4" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Dataset Name="dset2" OBJ-XID="xid_11552-2" H5Path="/g4/dset2" Parents="xid_10856" H5ParentPaths="/g4">
+ <hdf5:DatasetPtr OBJ-XID="xid_11552" H5Path="/g4/dset2"/>
</hdf5:Dataset>
</hdf5:Group>
- <hdf5:Group Name="g5" OBJ-XID="xid_10248" H5Path="/g5" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:SoftLink LinkName="slink4" OBJ-XID="xid_10944" H5SourcePath="/g5/slink4" TargetPath="/g6/dset3" TargetObj="xid_10944" Parents="xid_10248" H5ParentPaths="/g5" />
+ <hdf5:Group Name="g5" OBJ-XID="xid_8512" H5Path="/g5" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:SoftLink LinkName="slink4" OBJ-XID="xid_15872" H5SourcePath="/g5/slink4" TargetPath="/g6/dset3" TargetObj="xid_15872" Parents="xid_8512" H5ParentPaths="/g5" />
</hdf5:Group>
- <hdf5:Group Name="g6" OBJ-XID="xid_10896" H5Path="/g6" Parents="xid_696" H5ParentPaths="/" >
- <hdf5:Dataset Name="dset3" OBJ-XID="xid_10944" H5Path= "/g6/dset3" Parents="xid_10896" H5ParentPaths="/g6">
+ <hdf5:Group Name="g6" OBJ-XID="xid_8560" H5Path="/g6" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:Dataset Name="dset3" OBJ-XID="xid_15872" H5Path= "/g6/dset3" Parents="xid_8560" H5ParentPaths="/g6">
<hdf5:StorageLayout>
<hdf5:ContiguousLayout/>
</hdf5:StorageLayout>
@@ -356,5 +356,13 @@ Expected output for 'h5dump --xml tmany.h5'
</hdf5:Data>
</hdf5:Dataset>
</hdf5:Group>
+ <hdf5:Group Name="g7" OBJ-XID="xid_12688" H5Path="/g7" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:SoftLink LinkName="slink5" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g7/slink5" TargetPath="/g8/elink" Parents="xid_12688" H5ParentPaths="/g7" />
+ <hdf5:SoftLink LinkName="slink6" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g7/slink6" TargetPath="/g8/udlink" Parents="xid_12688" H5ParentPaths="/g7" />
+ </hdf5:Group>
+ <hdf5:Group Name="g8" OBJ-XID="xid_720" H5Path="/g8" Parents="xid_96" H5ParentPaths="/" >
+ <hdf5:ExternalLink LinkName="elink" OBJ-XID="xid_18446744073709551612" H5SourcePath="/g8/elink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_720" H5ParentPaths="/g8" />
+ <hdf5:UserDefined LinkName="udlink" OBJ-XID="xid_18446744073709551611" H5SourcePath="/g8/udlink" LinkClass="187" Parents="xid_720" H5ParentPaths="/g8" />
+ </hdf5:Group>
</hdf5:RootGroup>
</hdf5:HDF5-File>
diff --git a/tools/testfiles/tudlink-1.ddl b/tools/testfiles/tudlink-1.ddl
new file mode 100644
index 0000000..5f76c40
--- /dev/null
+++ b/tools/testfiles/tudlink-1.ddl
@@ -0,0 +1,13 @@
+#############################
+Expected output for 'h5dump tudlink.h5'
+#############################
+HDF5 "tudlink.h5" {
+GROUP "/" {
+ USERDEFINED_LINK "udlink1" {
+ LINKCLASS 187
+ }
+ USERDEFINED_LINK "udlink2" {
+ LINKCLASS 187
+ }
+}
+}
diff --git a/tools/testfiles/tudlink-1.ls b/tools/testfiles/tudlink-1.ls
new file mode 100644
index 0000000..e83fce7
--- /dev/null
+++ b/tools/testfiles/tudlink-1.ls
@@ -0,0 +1,5 @@
+#############################
+ output for 'h5ls -w80 -r tudlink.h5'
+#############################
+/udlink1 -> cannot follow UD links
+/udlink2 -> cannot follow UD links
diff --git a/tools/testfiles/tudlink-2.ddl b/tools/testfiles/tudlink-2.ddl
new file mode 100644
index 0000000..9ae3a54
--- /dev/null
+++ b/tools/testfiles/tudlink-2.ddl
@@ -0,0 +1,9 @@
+#############################
+Expected output for 'h5dump -l udlink2 tudlink.h5'
+#############################
+HDF5 "tudlink.h5" {
+USERDEFINED_LINK "udlink2" {
+ USERDEFINED_LINK "udlink2" {
+ LINKCLASS 187
+}
+}
diff --git a/tools/testfiles/tudlink.h5 b/tools/testfiles/tudlink.h5
new file mode 100644
index 0000000..3b10447
--- /dev/null
+++ b/tools/testfiles/tudlink.h5
Binary files differ
diff --git a/tools/testfiles/tudlink.h5.xml b/tools/testfiles/tudlink.h5.xml
new file mode 100644
index 0000000..aa5fb6c
--- /dev/null
+++ b/tools/testfiles/tudlink.h5.xml
@@ -0,0 +1,10 @@
+#############################
+Expected output for 'h5dump --xml tudlink.h5'
+#############################
+<?xml version="1.0" encoding="UTF-8"?>
+<hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd">
+<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/">
+ <hdf5:UserDefined LinkName="udlink1" OBJ-XID="xid_18446744073709551614" H5SourcePath="/udlink1" LinkClass="187" Parents="xid_96" H5ParentPaths="/" />
+ <hdf5:UserDefined LinkName="udlink2" OBJ-XID="xid_18446744073709551613" H5SourcePath="/udlink2" LinkClass="187" Parents="xid_96" H5ParentPaths="/" />
+</hdf5:RootGroup>
+</hdf5:HDF5-File>
diff --git a/tools/testfiles/twithub.h5 b/tools/testfiles/twithub.h5
index 105319f..2176034 100644
--- a/tools/testfiles/twithub.h5
+++ b/tools/testfiles/twithub.h5
Binary files differ
diff --git a/tools/testfiles/twithub513.h5 b/tools/testfiles/twithub513.h5
index 8b6a2e2..fbb872a 100644
--- a/tools/testfiles/twithub513.h5
+++ b/tools/testfiles/twithub513.h5
Binary files differ