summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-08-28 15:02:54 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-08-28 15:02:54 (GMT)
commitea343ef85416b42f68f28fb1024702c6726f7eea (patch)
treed5c401bf83f7f5578df06c54f9fd9fb198732ed2 /tools
parenteb16d8bc2b2f37c7a1d75fe7bf5258eba21515b2 (diff)
downloadhdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.zip
hdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.tar.gz
hdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.tar.bz2
[svn-r14115] Description:
Remove all plain calls to H5Gopen() from source, replacing them with either H5Gopen2(). Add test for H5Gopen1(). Reformatted several pieces of code, to clean them up. Tested on: FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (kagiso) Linux/64 2.6 (smirom) Solaris/32 5.10 (linew) Mac OS X/32 10.4.10 (amazon)
Diffstat (limited to 'tools')
-rw-r--r--tools/h5diff/h5diffgentest.c2
-rw-r--r--tools/h5dump/h5dump.c448
-rw-r--r--tools/h5dump/h5dumpgentest.c74
-rwxr-xr-xtools/h5import/h5import.c4
-rw-r--r--tools/h5jam/h5jamgentest.c8
-rw-r--r--tools/h5ls/h5ls.c64
-rw-r--r--tools/h5repack/h5repack.h4
-rw-r--r--tools/h5repack/h5repack_copy.c1067
-rw-r--r--tools/h5repack/h5repack_list.c49
-rw-r--r--tools/h5repack/h5repack_refs.c744
-rw-r--r--tools/h5repack/h5repack_verify.c4
-rw-r--r--tools/h5repack/h5repacktst.c4
-rw-r--r--tools/h5stat/h5stat.c2
-rw-r--r--tools/lib/h5diff.c23
-rw-r--r--tools/lib/h5diff_attr.c2
-rw-r--r--tools/lib/h5diff_dset.c2
-rw-r--r--tools/lib/h5trav.c2
17 files changed, 1205 insertions, 1298 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 12acd77..fa3ec77 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -629,7 +629,7 @@ int test_attributes(const char *file,
/* Create groups */
gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen(fid, "/");
+ root_id = H5Gopen2(fid, "/", H5P_DEFAULT);
/*-------------------------------------------------------------------------
* write a series of attributes on the dataset, group, and root group
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index ac4c1d2..ec89210 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -28,10 +28,12 @@ const char *progname = "h5dump";
/* Macros for displaying objects */
#define begin_obj(obj,name,begin) \
- if (name) \
- printf("%s \"%s\" %s\n", (obj), (name), (begin)); \
- else \
- printf("%s %s\n", (obj), (begin));
+ do { \
+ if (name) \
+ printf("%s \"%s\" %s\n", (obj), (name), (begin)); \
+ else \
+ printf("%s %s\n", (obj), (begin)); \
+ } while(0);
#define end_obj(obj,end) \
if(HDstrlen(end)) { \
@@ -1294,99 +1296,95 @@ dump_selected_attr(hid_t loc_id, const char *name)
dump_header_format->attributeblockbegin);
H5Gget_objinfo(loc_id, obj_name, FALSE, &statbuf);
- switch (statbuf.type) {
- case H5G_GROUP:
- if ((oid = H5Gopen(loc_id, obj_name)) < 0) {
- indentation(COL);
- error_msg(progname, "unable to open group \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
- return FAIL;
- }
- break;
+ switch(statbuf.type) {
+ case H5G_GROUP:
+ if((oid = H5Gopen2(loc_id, obj_name, H5P_DEFAULT)) < 0) {
+ indentation(COL);
+ error_msg(progname, "unable to open group \"%s\"\n", obj_name);
+ end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
- case H5G_DATASET:
- if ((oid = H5Dopen(loc_id, obj_name)) < 0) {
- indentation(COL);
- error_msg(progname, "unable to open dataset \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
- return FAIL;
- }
- break;
+ case H5G_DATASET:
+ if((oid = H5Dopen(loc_id, obj_name)) < 0) {
+ indentation(COL);
+ error_msg(progname, "unable to open dataset \"%s\"\n", obj_name);
+ end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
- case H5G_TYPE:
- if ((oid = H5Topen(loc_id, obj_name)) < 0) {
- indentation(COL);
- error_msg(progname, "unable to open datatype \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
- return FAIL;
- }
- break;
+ case H5G_TYPE:
+ if((oid = H5Topen(loc_id, obj_name)) < 0) {
+ indentation(COL);
+ error_msg(progname, "unable to open datatype \"%s\"\n", obj_name);
+ end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
- default:
- indentation(COL);
- error_msg(progname, "unable to open unknown \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
- return FAIL;
- }
+ default:
+ indentation(COL);
+ error_msg(progname, "unable to open unknown \"%s\"\n", obj_name);
+ end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end switch */
- if ((attr_id = H5Aopen_name(oid, attr_name)) >= 0) {
- type = H5Aget_type(attr_id);
- space = H5Aget_space(attr_id);
- dump_datatype(type);
- dump_dataspace(space);
+ if((attr_id = H5Aopen_name(oid, attr_name)) >= 0) {
+ type = H5Aget_type(attr_id);
+ space = H5Aget_space(attr_id);
+ dump_datatype(type);
+ dump_dataspace(space);
- if (display_oid)
- dump_oid(attr_id);
+ if(display_oid)
+ dump_oid(attr_id);
- if (display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai);
+ if(display_data || display_attr_data)
+ dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai);
- H5Tclose(type);
- H5Sclose(space);
- H5Aclose(attr_id);
- end_obj(dump_header_format->attributeend,
+ H5Tclose(type);
+ H5Sclose(space);
+ H5Aclose(attr_id);
+ end_obj(dump_header_format->attributeend,
dump_header_format->attributeblockend);
} else {
- indentation(COL);
+ indentation(COL);
error_msg(progname, "unable to open attribute \"%s\"\n", obj_name);
- end_obj(dump_header_format->attributeend,
- dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
- }
-
- switch (statbuf.type) {
- case H5G_GROUP:
- if (H5Gclose(oid) < 0) {
+ end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
d_status = EXIT_FAILURE;
- return FAIL;
}
- break;
- case H5G_DATASET:
- if (H5Dclose(oid) < 0) {
- d_status = EXIT_FAILURE;
- return FAIL;
- }
- break;
+ switch(statbuf.type) {
+ case H5G_GROUP:
+ if(H5Gclose(oid) < 0) {
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
- case H5G_TYPE:
- if (H5Tclose(oid) < 0) {
- d_status = EXIT_FAILURE;
- return FAIL;
- }
- break;
- default:
- d_status = EXIT_FAILURE;
- return FAIL;
- }
+ case H5G_DATASET:
+ if(H5Dclose(oid) < 0) {
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
+
+ case H5G_TYPE:
+ if(H5Tclose(oid) < 0) {
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end if */
+ break;
+
+ default:
+ d_status = EXIT_FAILURE;
+ return FAIL;
+ } /* end switch */
free(obj_name);
return SUCCEED;
@@ -1542,130 +1540,124 @@ dump_all(hid_t group, const char *name, void * op_data)
break;
}
case H5G_UDLINK:
- {
indentation(indent);
switch(linfo.type) {
- case H5L_TYPE_EXTERNAL:
- {
- char *targbuf;
-
- targbuf = HDmalloc(statbuf.linklen);
- HDassert(targbuf);
- if(!doxml) {
- begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin);
- } /* end if */
+ case H5L_TYPE_EXTERNAL:
+ {
+ char *targbuf;
- if(H5Lget_val(group, name, targbuf, statbuf.linklen, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get external link value\n");
- d_status = EXIT_FAILURE;
- ret = FAIL;
- } else {
- const char *filename;
- const char *targname;
+ targbuf = HDmalloc(statbuf.linklen);
+ HDassert(targbuf);
+ if(!doxml)
+ begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin);
- if(H5Lunpack_elink_val(targbuf, statbuf.linklen, NULL, &filename, &targname) < 0) {
- error_msg(progname, "unable to unpack external link value\n");
- d_status = EXIT_FAILURE;
- ret = FAIL;
+ if(H5Lget_val(group, name, targbuf, statbuf.linklen, H5P_DEFAULT) < 0) {
+ error_msg(progname, "unable to get external link value\n");
+ d_status = EXIT_FAILURE;
+ ret = FAIL;
} else {
- if (!doxml) {
- indentation(indent + COL);
- printf("LINKCLASS %d\n", linfo.type);
- 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);
- }
+ const char *filename;
+ const char *targname;
+
+ if(H5Lunpack_elink_val(targbuf, statbuf.linklen, NULL, &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.type);
+ indentation(indent + COL);
+ printf("TARGETFILE \"%s\"\n", filename);
+ indentation(indent + COL);
+ printf("TARGETPATH \"%s\"\n", targname);
+ }
+ /* XML */
+ else {
+ 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;
+ 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);
+ begin_obj(dump_header_format->udlinkbegin, name, dump_header_format->udlinkblockbegin);
indentation(indent + COL);
}
- if (!doxml) {
+ if (!doxml)
printf("LINKCLASS %d\n", linfo.type);
- }
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.type, /* LinkClass */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(t_obj_path);
+ 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.type, /* 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);
+ end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend);
}
}
break;
- }
+
case H5G_GROUP:
- if ((obj = H5Gopen(group, name)) < 0) {
+ if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
error_msg(progname, "unable to dump group \"%s\"\n", name);
d_status = EXIT_FAILURE;
ret = FAIL;
@@ -1689,7 +1681,6 @@ dump_all(hid_t group, const char *name, void * op_data)
/* Close group */
H5Gclose(obj);
}
-
break;
case H5G_DATASET:
@@ -3173,29 +3164,27 @@ handle_groups(hid_t fid, char *group, void UNUSED * data)
{
hid_t gid;
- if ((gid = H5Gopen(fid, group)) < 0) {
- begin_obj(dump_header_format->groupbegin, group,
- dump_header_format->groupblockbegin);
+ if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) {
+ begin_obj(dump_header_format->groupbegin, group, dump_header_format->groupblockbegin);
indentation(COL);
error_msg(progname, "unable to open group \"%s\"\n", group);
- end_obj(dump_header_format->groupend,
- dump_header_format->groupblockend);
+ end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
d_status = EXIT_FAILURE;
} else {
size_t new_len = HDstrlen(group) + 1;
- if (prefix_len <= new_len) {
+ if(prefix_len <= new_len) {
prefix_len = new_len;
prefix = HDrealloc(prefix, prefix_len);
- }
+ } /* end if */
HDstrcpy(prefix, group);
dump_group(gid, group);
- if (H5Gclose(gid) < 0)
+ if(H5Gclose(gid) < 0)
d_status = EXIT_FAILURE;
- }
-}
+ } /* end else */
+} /* end handle_groups() */
/*-------------------------------------------------------------------------
* Function: handle_links
@@ -3797,32 +3786,31 @@ main(int argc, const char *argv[])
init_ref_path_table(fid); /* Insert the root group into the ref. path table */
H5Giterate(fid, (const char *)"/", NULL, fill_ref_path_table, (void *)"");
- if (doxml) {
- /* initialize XML */
+ if(doxml) {
+ /* initialize XML */
- /* reset prefix! */
- HDstrcpy(prefix, "");
+ /* reset prefix! */
+ HDstrcpy(prefix, "");
- /* make sure the URI is initialized to something */
- if (xml_dtd_uri == NULL) {
- if (useschema) {
- xml_dtd_uri = DEFAULT_XSD;
+ /* make sure the URI is initialized to something */
+ if (xml_dtd_uri == NULL) {
+ if (useschema) {
+ xml_dtd_uri = DEFAULT_XSD;
+ } else {
+ xml_dtd_uri = DEFAULT_DTD;
+ xmlnsprefix = "";
+ }
} else {
- xml_dtd_uri = DEFAULT_DTD;
- xmlnsprefix = "";
- }
- } else {
- if (useschema && strcmp(xmlnsprefix,"")) {
- error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
- leave(EXIT_FAILURE);
+ if (useschema && strcmp(xmlnsprefix,"")) {
+ error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
+ leave(EXIT_FAILURE);
+ }
}
}
- }
/* find all shared objects */
if(init_objs(fid, &info, &group_table, &dset_table, &type_table) < 0) {
- error_msg(progname, "internal error (file %s:line %d)\n",
- __FILE__, __LINE__);
+ error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
d_status = EXIT_FAILURE;
goto done;
}
@@ -3882,42 +3870,40 @@ main(int argc, const char *argv[])
dump_fcpl(fid);
}
- if (display_all) {
- if ((gid = H5Gopen(fid, "/")) < 0) {
+ if(display_all) {
+ if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg(progname, "unable to open root group\n");
d_status = EXIT_FAILURE;
} else {
- dump_function_table->dump_group_function(gid, "/");
+ dump_function_table->dump_group_function(gid, "/");
}
- if (H5Gclose(gid) < 0) {
+ if(H5Gclose(gid) < 0) {
error_msg(progname, "unable to close root group\n");
d_status = EXIT_FAILURE;
}
} else {
- if (doxml) {
/* Note: this option is not supported for XML */
- error_msg(progname, "internal error (file %s:line %d)\n",
- __FILE__, __LINE__);
+ if(doxml) {
+ error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
d_status = EXIT_FAILURE;
- goto done;
- }
+ goto done;
+ } /* end if */
- for (i = 0; i < argc; i++)
- if (hand[i].func)
+ for(i = 0; i < argc; i++)
+ if(hand[i].func)
hand[i].func(fid, hand[i].obj, hand[i].subset_info);
}
if (!doxml) {
- end_obj(dump_header_format->fileend,
- dump_header_format->fileblockend);
+ end_obj(dump_header_format->fileend, dump_header_format->fileblockend);
} else {
- printf("</%sHDF5-File>\n", xmlnsprefix);
+ printf("</%sHDF5-File>\n", xmlnsprefix);
}
done:
if (H5Fclose(fid) < 0)
- d_status = EXIT_FAILURE;
+ d_status = EXIT_FAILURE;
free_handler(hand, argc);
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 321a15d..38b1f27 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -225,7 +225,8 @@ typedef struct s1_t {
/* "File 51" macros */
#define F51_MAX_NAME_LEN ((64*1024)+1024)
-static void gent_group(void)
+static void
+gent_group(void)
{
hid_t fid, group;
@@ -270,7 +271,8 @@ static void gent_group(void)
H5Fclose(fid);
}
-static void gent_dataset(void)
+static void
+gent_dataset(void)
{
hid_t fid, dataset, space;
hsize_t dims[2];
@@ -309,7 +311,8 @@ static void gent_dataset(void)
H5Fclose(fid);
}
-static void gent_dataset2(void)
+static void
+gent_dataset2(void)
{
hid_t fid, dataset, space, create_plist;
hsize_t dims[2];
@@ -356,7 +359,8 @@ static void gent_dataset2(void)
}
-static void gent_attribute(void)
+static void
+gent_attribute(void)
{
hid_t fid, root, space, attr, type;
hsize_t dims[2];
@@ -367,7 +371,7 @@ static void gent_attribute(void)
int point = 100;
fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- root = H5Gopen (fid, "/");
+ root = H5Gopen2(fid, "/", H5P_DEFAULT);
/* attribute 1 */
dims[0] = 24;
@@ -426,7 +430,7 @@ static void gent_softlink(void)
hid_t fid, root;
fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- root = H5Gopen (fid, "/");
+ root = H5Gopen2(fid, "/", H5P_DEFAULT);
H5Glink (root, H5L_TYPE_SOFT, "somevalue", "slink1");
H5Glink (root, H5L_TYPE_SOFT, "linkvalue", "slink2");
@@ -472,7 +476,7 @@ static void gent_hardlink(void)
H5Glink (group, H5L_TYPE_HARD, "/dset1", "dset3");
H5Gclose(group);
- group = H5Gopen(fid, "/g1");
+ group = H5Gopen2(fid, "/g1", H5P_DEFAULT);
H5Glink (group, H5L_TYPE_HARD, "/g2", "g1.1");
H5Gclose(group);
@@ -921,7 +925,7 @@ static void gent_all(void)
H5Gclose(group);
/* root attributes */
- group = H5Gopen (fid, "/");
+ group = H5Gopen2(fid, "/", H5P_DEFAULT);
dims[0] = 10;
space = H5Screate_simple(1, dims, NULL);
@@ -941,7 +945,7 @@ static void gent_all(void)
H5Gclose(group);
- group = H5Gopen (fid, "/g1/g1.1");
+ group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT);
/* dset1.1.1 */
dims[0] = 10; dims[1] = 10;
@@ -988,11 +992,11 @@ static void gent_all(void)
H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT);
/* soft link */
- group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
+ group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT);
H5Glink (group, H5L_TYPE_SOFT, "somevalue", "slink");
H5Gclose(group);
- group = H5Gopen (fid, "/g2");
+ group = H5Gopen2(fid, "/g2", H5P_DEFAULT);
/* dset2.1 */
dims[0] = 10;
@@ -1238,7 +1242,7 @@ static void gent_many(void)
H5Sclose(space);
H5Gclose(group);
- group = H5Gopen(fid, "/g3");
+ group = H5Gopen2(fid, "/g3", H5P_DEFAULT);
H5Glink (group, H5L_TYPE_HARD, "/g4/dset2", "link3");
H5Gclose(group);
@@ -1261,7 +1265,7 @@ static void gent_many(void)
H5Sclose(space);
H5Gclose(group);
- group = H5Gopen(fid, "/g5");
+ group = H5Gopen2(fid, "/g5", H5P_DEFAULT);
H5Glink (group, H5L_TYPE_SOFT, "/g6/dset3", "slink4");
H5Gclose(group);
H5Pclose(create_plist);
@@ -2937,7 +2941,7 @@ void gent_split_file(void)
fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT);
fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
- root = H5Gopen(fid, "/");
+ root = H5Gopen2(fid, "/", H5P_DEFAULT);
atype = H5Tcopy(H5T_C_S1);
H5Tset_size(atype, strlen(meta) + 1);
@@ -3112,7 +3116,7 @@ static void gent_vlstr(void)
H5Tcommit(fid1, "vl_string_type", tid1);
/* Create an group attribute of VL string type */
- root = H5Gopen(fid1, "/");
+ root = H5Gopen2(fid1, "/", H5P_DEFAULT);
dataspace = H5Screate(H5S_SCALAR);
att = H5Acreate(root, "test_scalar", tid1, dataspace, H5P_DEFAULT);
@@ -4094,7 +4098,7 @@ static void gent_attr_all(void)
/* Create groups */
group_id = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
group2_id = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen(fid, "/");
+ root_id = H5Gopen2(fid, "/", H5P_DEFAULT);
/*-------------------------------------------------------------------------
* write a series of attributes on the dataset, group
@@ -4497,7 +4501,7 @@ static void gent_null_space(void)
int point = 4;
fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- root = H5Gopen (fid, "/");
+ root = H5Gopen2(fid, "/", H5P_DEFAULT);
/* null space */
space = H5Screate(H5S_NULL);
@@ -5017,7 +5021,7 @@ static void gent_fcontents(void)
/* hard link to "g2" */
- gid1 = H5Gopen(fid, "/g1");
+ gid1 = H5Gopen2(fid, "/g1", H5P_DEFAULT);
H5Glink (gid1, H5L_TYPE_HARD, "/g2", "g1.1");
H5Gclose(gid1);
@@ -5626,7 +5630,8 @@ gent_binary(void)
#define GB4LL ((unsigned long_long) 4*1024*1024*1024)
#define DIM_4GB (GB4LL + 10)
-static void gent_bigdims(void)
+static void
+gent_bigdims(void)
{
hid_t fid;
hid_t did;
@@ -5727,27 +5732,28 @@ out:
*
*-------------------------------------------------------------------------
*/
-static void gent_hyperslab(void)
+static void
+gent_hyperslab(void)
{
- hid_t fid; /* file id */
- hsize_t dims[2] = {32,4097}; /* big enough data size to force a second stripmine read */
- double *buf;
- int i, ret;
+ hid_t fid; /* file id */
+ hsize_t dims[2] = {32,4097}; /* big enough data size to force a second stripmine read */
+ double *buf;
+ int i, ret;
- buf = malloc(32 * 4097 * sizeof(double) );
- for (i = 0; i < 32 * 4097; i++)
- buf[i] = 1;
+ buf = malloc(32 * 4097 * sizeof(double) );
+ for (i = 0; i < 32 * 4097; i++)
+ buf[i] = 1;
- /* create a file */
- fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(fid>=0);
+ /* create a file */
+ fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(fid>=0);
- write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf);
+ write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf);
- ret=H5Fclose(fid);
- assert(ret>=0);
+ ret=H5Fclose(fid);
+ assert(ret>=0);
- free(buf);
+ free(buf);
}
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index b494a67..1babd9e 100755
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -852,7 +852,7 @@ processStrData(FILE **strm, struct Input *in, hid_t file_id)
j = 0;
handle = file_id;
while(j < in->path.count - 1) {
- if((group_id = H5Gopen(handle, in->path.group[j])) < 0) {
+ if((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) {
group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(; j < in->path.count - 1; j++)
group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@@ -2444,7 +2444,7 @@ process(struct Options *opt)
j = 0;
handle = file_id;
while(j < in->path.count - 1) {
- if((group_id = H5Gopen(handle, in->path.group[j])) < 0) {
+ if((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) {
group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (; j < in->path.count - 1; j++)
group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c
index d0c1283..fe31658 100644
--- a/tools/h5jam/h5jamgentest.c
+++ b/tools/h5jam/h5jamgentest.c
@@ -203,7 +203,7 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
H5Gclose(group);
/* root attributes */
- group = H5Gopen(fid, "/");
+ group = H5Gopen2(fid, "/", H5P_DEFAULT);
dims[0] = 10;
space = H5Screate_simple(1, dims, NULL);
@@ -223,7 +223,7 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
H5Gclose(group);
- group = H5Gopen (fid, "/g1/g1.1");
+ group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT);
/* dset1.1.1 */
dims[0] = 10; dims[1] = 10;
@@ -270,11 +270,11 @@ gent_ub(const char * filename, size_t ub_size, size_t ub_fill)
H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT);
/* soft link */
- group = H5Gopen (fid, "/g1/g1.2/g1.2.1");
+ group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT);
H5Glink (group, H5L_TYPE_SOFT, "somevalue", "slink");
H5Gclose(group);
- group = H5Gopen (fid, "/g2");
+ group = H5Gopen2(fid, "/g2", H5P_DEFAULT);
/* dset2.1 */
dims[0] = 10;
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index a362250..f127f3f 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -62,7 +62,7 @@ static struct {
/* Information about how to display each type of object */
static struct dispatch_t {
const char *name;
- hid_t (*open)(hid_t loc, const char *name);
+ hid_t (*open)(hid_t loc, const char *name, hid_t apl_id);
herr_t (*close)(hid_t obj);
herr_t (*list1)(hid_t obj);
herr_t (*list2)(hid_t obj, const char *name);
@@ -1728,11 +1728,11 @@ datatype_list2(hid_t type, const char UNUSED *name)
*-------------------------------------------------------------------------
*/
static hid_t
-slink_open(hid_t location, const char *name)
+slink_open(hid_t location, const char *name, hid_t UNUSED apl_id)
{
H5G_stat_t statbuf;
- if (H5Gget_objinfo(location, name, FALSE, &statbuf) < 0)
+ if(H5Gget_objinfo(location, name, FALSE, &statbuf) < 0)
return -1;
if(statbuf.type == H5G_LINK) { /* Soft link */
@@ -1771,7 +1771,7 @@ slink_open(hid_t location, const char *name)
*-------------------------------------------------------------------------
*/
static hid_t
-udlink_open(hid_t location, const char *name)
+udlink_open(hid_t location, const char *name, hid_t UNUSED apl_id)
{
H5L_info_t linfo;
char * buf = NULL;
@@ -1789,7 +1789,8 @@ udlink_open(hid_t location, const char *name)
if(H5Lget_val(location, name, buf, linfo.u.val_size, H5P_DEFAULT) < 0)
goto error;
- if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &filename, &path) < 0) goto error;
+ if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &filename, &path) < 0)
+ goto error;
HDfputs("file: ", stdout);
HDfputs(filename, stdout);
HDfputs(" path: ", stdout);
@@ -1879,17 +1880,16 @@ list (hid_t group, const char *name, void *_iter)
/* Open the object. Not all objects can be opened. If this is the case
* then return right away. */
- if (sb.type>=0 &&
- (NULL==dispatch_g[sb.type].open ||
- (obj=(dispatch_g[sb.type].open)(group, name))<0)) {
+ if(sb.type >= 0 &&
+ (NULL == dispatch_g[sb.type].open ||
+ (obj = (dispatch_g[sb.type].open)(group, name, H5P_DEFAULT)) < 0)) {
printf(" *ERROR*\n");
goto done;
- }
+ } /* end if */
/* List the first line of information for the object. */
- if (sb.type>=0 && dispatch_g[sb.type].list1) {
+ if(sb.type >= 0 && dispatch_g[sb.type].list1)
(dispatch_g[sb.type].list1)(obj);
- }
putchar('\n');
/* Show detailed information about the object, beginning with information
@@ -2120,9 +2120,9 @@ main (int argc, const char *argv[])
h5tools_init();
/* Build display table */
- DISPATCH(H5G_DATASET, "Dataset", H5Dopen, H5Dclose, dataset_list1, dataset_list2);
- DISPATCH(H5G_GROUP, "Group", H5Gopen, H5Gclose, NULL, group_list2);
- DISPATCH(H5G_TYPE, "Type", H5Topen, H5Tclose, NULL, datatype_list2);
+ DISPATCH(H5G_DATASET, "Dataset", H5Dopen2, H5Dclose, dataset_list1, dataset_list2);
+ DISPATCH(H5G_GROUP, "Group", H5Gopen2, H5Gclose, NULL, group_list2);
+ DISPATCH(H5G_TYPE, "Type", H5Topen2, H5Tclose, NULL, datatype_list2);
DISPATCH(H5G_LINK, "-> ", slink_open, NULL, NULL, NULL);
DISPATCH(H5G_UDLINK, "-> ", udlink_open, NULL, NULL, NULL);
@@ -2317,30 +2317,31 @@ main (int argc, const char *argv[])
fprintf(stderr, "%s: unable to open file\n", argv[argno-1]);
continue;
}
- if (oname) oname++;
- if (!oname || !*oname) oname = root_name;
+ if(oname)
+ oname++;
+ if(!oname || !*oname)
+ oname = root_name;
/* Open the object and display it's information */
- if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 &&
- H5G_GROUP==sb.type && !grp_literal_g) {
- /* Specified name is a group. List the complete contents of the
- * group. */
+ if(H5Gget_objinfo(file, oname, TRUE, &sb) >= 0 && H5G_GROUP == sb.type && !grp_literal_g) {
+ /* Specified name is a group. List the complete contents of the group. */
sym_insert(&sb, oname);
- iter.container = container = fix_name(show_file_name_g?fname:"", oname);
+ iter.container = container = fix_name((show_file_name_g ? fname : ""), oname);
+
/* list root attributes */
- if (verbose_g>0)
- {
- if ((root=H5Gopen(file, "/"))<0)
- leave(1);
- H5Aiterate(root, NULL, list_attr, NULL);
- if (H5Gclose(root)<0)
- leave(1);
- }
+ if(verbose_g > 0) {
+ if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0)
+ leave(1);
+ H5Aiterate(root, NULL, list_attr, NULL);
+ if(H5Gclose(root) < 0)
+ leave(1);
+ } /* end if */
+
/* list */
H5Giterate(file, oname, NULL, list, &iter);
free(container);
- } else if ((root=H5Gopen(file, "/"))<0) {
+ } else if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) {
leave(1); /*major problem!*/
} else {
@@ -2348,7 +2349,8 @@ main (int argc, const char *argv[])
* container for the object is everything up to the base name. */
iter.container = show_file_name_g ? fname : "/";
list(root, oname, &iter);
- if (H5Gclose(root)<0) leave(1);
+ if(H5Gclose(root) < 0)
+ leave(1);
}
H5Fclose(file);
free(fname);
diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h
index f8f642b..d986cc0 100644
--- a/tools/h5repack/h5repack.h
+++ b/tools/h5repack/h5repack.h
@@ -174,10 +174,6 @@ int apply_filters(const char* name, /* object name from traverse list */
pack_opt_t *options, /* repack options */
int *has_filter); /* (OUT) object NAME has a filter */
-int has_filter(hid_t dcpl_id,
- H5Z_filter_t filtnin);
-
-
int can_read(const char* name, /* object name from traverse list */
hid_t dcpl_id, /* dataset creation property list */
pack_opt_t *options); /* repack options */
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index e9a89e2..f32d15d 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -281,566 +281,547 @@ int do_copy_objects(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- 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 gcpl_id=-1; /* group creation property list */
- 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 f_space_id=-1; /* file space ID */
- hid_t ftype_id=-1; /* file type ID */
- hid_t wtype_id=-1; /* read/write type ID */
- size_t msize; /* size of type */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dsize_in; /* input dataset size before filter */
- hsize_t dsize_out; /* output dataset size after filter */
- int apply_s; /* flag for apply filter to small dataset sizes */
- int apply_f; /* flag for apply filter to return error on H5Dcreate */
- double per; /* percent utilization of storage */
- void *buf=NULL; /* buffer for raw data */
- void *sm_buf=NULL; /* buffer for raw data */
- int has_filter; /* current object has a filter */
- unsigned i;
- int is_ref=0;
+ 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 gcpl_id=-1; /* group creation property list */
+ 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 f_space_id=-1; /* file space ID */
+ hid_t ftype_id=-1; /* file type ID */
+ hid_t wtype_id=-1; /* read/write type ID */
+ size_t msize; /* size of type */
+ hsize_t nelmts; /* number of elements in dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ hsize_t dsize_in; /* input dataset size before filter */
+ hsize_t dsize_out; /* output dataset size after filter */
+ int apply_s; /* flag for apply filter to small dataset sizes */
+ int apply_f; /* flag for apply filter to return error on H5Dcreate */
+ double per; /* percent utilization of storage */
+ void *buf=NULL; /* buffer for raw data */
+ void *sm_buf=NULL; /* buffer for raw data */
+ int has_filter; /* current object has a filter */
+ unsigned i;
+ int is_ref=0;
-/*-------------------------------------------------------------------------
- * copy the suppplied object list
- *-------------------------------------------------------------------------
- */
-
- if (options->verbose) {
- printf("-----------------------------------------\n");
- printf(" Type Filter (Ratio) Name\n");
- printf("-----------------------------------------\n");
- }
-
- for ( i = 0; i < travt->nobjs; i++)
- {
-
- buf = NULL;
-
- switch ( travt->objs[i].type )
- {
-/*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- case H5G_GROUP:
- if (options->verbose)
- printf(FORMAT_OBJ,"group",travt->objs[i].name );
-
- if (options->grp_compact>0 || options->grp_indexed>0) {
- /* Set up group creation property list */
- if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
- goto error;
-
- if(H5Pset_link_phase_change(gcpl_id, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0)
- goto error;
-
- if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
- goto error;
- }
- else {
- if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
- }
-
- if((grp_in = H5Gopen (fidin,travt->objs[i].name))<0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * copy attrs
+ /*-------------------------------------------------------------------------
+ * copy the suppplied object list
*-------------------------------------------------------------------------
*/
- if (copy_attr(grp_in,grp_out,options)<0)
- goto error;
- if (gcpl_id>0) {
- if (H5Pclose(gcpl_id)<0)
- goto error;
- }
- if (H5Gclose(grp_out)<0)
- goto error;
- if (H5Gclose(grp_in)<0)
- goto error;
-
-
- break;
-
-/*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- case H5G_DATASET:
+ if (options->verbose) {
+ printf("-----------------------------------------\n");
+ printf(" Type Filter (Ratio) Name\n");
+ printf("-----------------------------------------\n");
+ }
- has_filter = 0;
+ for ( i = 0; i < travt->nobjs; i++) {
+
+ buf = NULL;
+ switch ( travt->objs[i].type ) {
+ /*-------------------------------------------------------------------------
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5G_GROUP:
+ if (options->verbose)
+ printf(FORMAT_OBJ,"group",travt->objs[i].name );
+
+ if (options->grp_compact>0 || options->grp_indexed>0) {
+ /* Set up group creation property list */
+ if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ goto error;
+
+ if(H5Pset_link_phase_change(gcpl_id, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0)
+ goto error;
+
+ if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
+ goto error;
+ }
+ else {
+ if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+ }
+
+ if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(grp_in,grp_out,options)<0)
+ goto error;
+
+ if (gcpl_id>0) {
+ if (H5Pclose(gcpl_id)<0)
+ goto error;
+ }
+ if (H5Gclose(grp_out)<0)
+ goto error;
+ if (H5Gclose(grp_in)<0)
+ goto error;
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_DATASET
+ *-------------------------------------------------------------------------
+ */
+ case H5G_DATASET:
+
+ has_filter = 0;
+
+ /* early detection of references */
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
+ goto error;
+ if ((ftype_id=H5Dget_type (dset_in))<0)
+ goto error;
+ if (H5T_REFERENCE==H5Tget_class(ftype_id))
+ is_ref=1;
+ if (H5Tclose(ftype_id)<0)
+ goto error;
+ if (H5Dclose(dset_in)<0)
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * check if we should use H5Ocopy or not
+ * if there is a request for filters/layout, we read/write the object
+ * otherwise we do a copy using H5Ocopy
+ *-------------------------------------------------------------------------
+ */
+ if (options->op_tbl->nelems
+ ||
+ options->all_filter==1 || options->all_layout==1
+ || is_ref
+ )
+ {
+ int j;
+
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
+ goto error;
+ if ((f_space_id=H5Dget_space(dset_in))<0)
+ goto error;
+ if ((ftype_id=H5Dget_type (dset_in))<0)
+ goto error;
+ if ((dcpl_id=H5Dget_create_plist(dset_in))<0)
+ goto error;
+ if ((dcpl_out = H5Pcopy (dcpl_id))<0)
+ goto error;
+ if ( (rank=H5Sget_simple_extent_ndims(f_space_id))<0)
+ goto error;
+ HDmemset(dims, 0, sizeof dims);
+ if ( H5Sget_simple_extent_dims(f_space_id,dims,NULL)<0)
+ goto error;
+ nelmts=1;
+ for (j=0; j<rank; j++)
+ nelmts*=dims[j];
+
+ if (options->use_native==1)
+ wtype_id = h5tools_get_native_type(ftype_id);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+
+ if ((msize=H5Tget_size(wtype_id))==0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
+ *-------------------------------------------------------------------------
+ */
+ if (h5tools_canreadf((travt->objs[i].name),dcpl_id)==1)
+ {
+ apply_s=1;
+ apply_f=1;
+
+ /*-------------------------------------------------------------------------
+ * references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ * in a second traversal of the output file
+ *-------------------------------------------------------------------------
+ */
+ if (H5T_REFERENCE!=H5Tget_class(wtype_id))
+ {
+ /* get the storage size of the input dataset */
+ dsize_in=H5Dget_storage_size(dset_in);
+
+ /* check for datasets too small */
+ if (nelmts*msize < options->threshold )
+ apply_s=0;
+
+ /* apply the filter */
+ if (apply_s) {
+ if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options,&has_filter)<0)
+ goto error;
+ }
+
+ /*-------------------------------------------------------------------------
+ * create the output dataset;
+ * disable error checking in case the dataset cannot be created with the
+ * modified dcpl; in that case use the original instead
+ *-------------------------------------------------------------------------
+ */
+ H5E_BEGIN_TRY {
+ dset_out=H5Dcreate(fidout,travt->objs[i].name,wtype_id,f_space_id,dcpl_out);
+ } H5E_END_TRY;
+ if (dset_out==FAIL)
+ {
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,wtype_id,f_space_id,dcpl_id))<0)
+ goto error;
+ apply_f=0;
+ }
+
+ /*-------------------------------------------------------------------------
+ * read/write
+ *-------------------------------------------------------------------------
+ */
+ if (nelmts)
+ {
+ size_t need = (size_t)(nelmts*msize); /* bytes needed */
+ if ( need < H5TOOLS_MALLOCSIZE )
+ buf = HDmalloc(need);
+
+ if (buf != NULL )
+ {
+ if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+ if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+ }
+
+ else /* possibly not enough memory, read/write by hyperslabs */
+ {
+ size_t p_type_nbytes = msize; /*size of memory type */
+ hsize_t p_nelmts = nelmts; /*total selected elmts */
+ hsize_t elmtno; /*counter */
+ int carry; /*counter carry value */
+ unsigned int vl_data = 0; /*contains VL datatypes */
+
+ /* stripmine info */
+ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
+ hsize_t sm_nbytes; /*bytes per stripmine */
+ hsize_t sm_nelmts; /*elements per stripmine*/
+ hid_t sm_space; /*stripmine data space */
+
+ /* hyperslab info */
+ hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */
+ hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */
+ hsize_t hs_nelmts; /*elements in request */
+ hsize_t zero[8]; /*vector of zeros */
+ int k;
+
+ /* check if we have VL data in the dataset's datatype */
+ if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
+ /*
+ * determine the strip mine size and allocate a buffer. The strip mine is
+ * a hyperslab whose size is manageable.
+ */
+ sm_nbytes = p_type_nbytes;
+
+ for (k = rank; k > 0; --k) {
+ sm_size[k - 1] = MIN(dims[k - 1], H5TOOLS_BUFSIZE / sm_nbytes);
+ sm_nbytes *= sm_size[k - 1];
+ assert(sm_nbytes > 0);
+ }
+ sm_buf = HDmalloc((size_t)sm_nbytes);
+
+ sm_nelmts = sm_nbytes / p_type_nbytes;
+ sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+
+ /* the stripmine loop */
+ memset(hs_offset, 0, sizeof hs_offset);
+ memset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
+ {
+ /* calculate the hyperslab size */
+ if (rank > 0)
+ {
+ for (k = 0, hs_nelmts = 1; k < rank; k++)
+ {
+ hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]);
+ hs_nelmts *= hs_size[k];
+ }
+
+ if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL)<0)
+ goto error;
+ if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL)<0)
+ goto error;
+ }
+ else
+ {
+ H5Sselect_all(f_space_id);
+ H5Sselect_all(sm_space);
+ hs_nelmts = 1;
+ } /* rank */
+
+ /* read/write */
+ if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
+ goto error;
+ if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
+ goto error;
+
+ /* reclaim any VL memory, if necessary */
+ if(vl_data)
+ H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf);
+
+ /* calculate the next hyperslab offset */
+ for (k = rank, carry = 1; k > 0 && carry; --k)
+ {
+ hs_offset[k - 1] += hs_size[k - 1];
+ if (hs_offset[k - 1] == dims[k - 1])
+ hs_offset[k - 1] = 0;
+ else
+ carry = 0;
+ } /* k */
+ } /* elmtno */
+
+ H5Sclose(sm_space);
+ /* free */
+ if (sm_buf!=NULL)
+ {
+ HDfree(sm_buf);
+ sm_buf=NULL;
+ }
+ } /* hyperslab read */
+ }/*nelmts*/
+
+ /*-------------------------------------------------------------------------
+ * amount of compression used
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose)
+ {
+ if (apply_s && apply_f)
+ {
+ /* get the storage size of the input dataset */
+ dsize_out=H5Dget_storage_size(dset_out);
+ PER((hssize_t)dsize_in,(hssize_t)dsize_out);
+ print_dataset_info(dcpl_out,travt->objs[i].name,per*100.0);
+ }
+ else
+ print_dataset_info(dcpl_id,travt->objs[i].name,0.0);
+
+ /* print a message that the filter was not applied
+ (in case there was a filter)
+ */
+ if ( has_filter && apply_s == 0 )
+ printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n",
+ travt->objs[i].name,
+ (int)options->threshold);
+
+ if ( has_filter && apply_f == 0 )
+ printf(" <warning: could not apply the filter to %s>\n",
+ travt->objs[i].name);
+
+ } /* verbose */
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(dset_in,dset_out,options)<0)
+ goto error;
+
+ /*close */
+ if (H5Dclose(dset_out)<0)
+ goto error;
+
+ }/*!H5T_REFERENCE*/
+ }/*h5tools_canreadf*/
+
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id)<0)
+ goto error;
+ if (H5Tclose(wtype_id)<0)
+ goto error;
+ if (H5Pclose(dcpl_id)<0)
+ goto error;
+ if (H5Pclose(dcpl_out)<0)
+ goto error;
+ if (H5Sclose(f_space_id)<0)
+ goto error;
+ if (H5Dclose(dset_in)<0)
+ goto error;
+
+ }
+ /*-------------------------------------------------------------------------
+ * we do not have request for filter/chunking use H5Ocopy instead
+ *-------------------------------------------------------------------------
+ */
+ else
+ {
+ hid_t pid;
+
+ /* create property to pass copy options */
+ if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ goto error;
+
+ /* set options for object copy */
+ if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * do the copy
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Ocopy(fidin, /* Source file or group identifier */
+ travt->objs[i].name, /* Name of the source object to be copied */
+ fidout, /* Destination file or group identifier */
+ travt->objs[i].name, /* Name of the destination object */
+ pid, /* Properties which apply to the copy */
+ H5P_DEFAULT)<0) /* Properties which apply to the new hard link */
+ goto error;
+
+ /* close property */
+ if (H5Pclose(pid)<0)
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * copy attrs manually
+ *-------------------------------------------------------------------------
+ */
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
+ goto error;
+ if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0)
+ goto error;
+ if (copy_attr(dset_in,dset_out,options)<0)
+ goto error;
+ if (H5Dclose(dset_in)<0)
+ goto error;
+ if (H5Dclose(dset_out)<0)
+ goto error;
+
+ } /* end do we have request for filter/chunking */
+
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_TYPE
+ *-------------------------------------------------------------------------
+ */
+ case H5G_TYPE:
+
+ if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
+ goto error;
+
+ if ((type_out = H5Tcopy(type_in))<0)
+ goto error;
+
+ if ((H5Tcommit(fidout,travt->objs[i].name,type_out))<0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(type_in,type_out,options)<0)
+ goto error;
+
+ if (H5Tclose(type_in)<0)
+ goto error;
+ if (H5Tclose(type_out)<0)
+ goto error;
+
+ if (options->verbose)
+ printf(FORMAT_OBJ,"type",travt->objs[i].name );
+
+ break;
+
+
+ /*-------------------------------------------------------------------------
+ * 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:
+ {
+ 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 );
+
+ }
+ break;
+
+ default:
+ goto error;
+ } /* switch */
- /* early detection of references */
- if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
- goto error;
- if ((ftype_id=H5Dget_type (dset_in))<0)
- goto error;
- if (H5T_REFERENCE==H5Tget_class(ftype_id))
- {
- is_ref=1;
- }
- if (H5Tclose(ftype_id)<0)
- goto error;
- if (H5Dclose(dset_in)<0)
- goto error;
-
-
-/*-------------------------------------------------------------------------
- * check if we should use H5Ocopy or not
- * if there is a request for filters/layout, we read/write the object
- * otherwise we do a copy using H5Ocopy
- *-------------------------------------------------------------------------
- */
- if (options->op_tbl->nelems
- ||
- options->all_filter==1 || options->all_layout==1
- || is_ref
- )
- {
- int j;
-
- if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
- goto error;
- if ((f_space_id=H5Dget_space(dset_in))<0)
- goto error;
- if ((ftype_id=H5Dget_type (dset_in))<0)
- goto error;
- if ((dcpl_id=H5Dget_create_plist(dset_in))<0)
- goto error;
- if ((dcpl_out = H5Pcopy (dcpl_id))<0)
- goto error;
- if ( (rank=H5Sget_simple_extent_ndims(f_space_id))<0)
- goto error;
- HDmemset(dims, 0, sizeof dims);
- if ( H5Sget_simple_extent_dims(f_space_id,dims,NULL)<0)
- goto error;
- nelmts=1;
- for (j=0; j<rank; j++)
- nelmts*=dims[j];
-
- if (options->use_native==1)
- wtype_id = h5tools_get_native_type(ftype_id);
- else
- wtype_id = H5Tcopy(ftype_id);
-
- if ((msize=H5Tget_size(wtype_id))==0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *-------------------------------------------------------------------------
- */
- if (h5tools_canreadf((travt->objs[i].name),dcpl_id)==1)
- {
- apply_s=1;
- apply_f=1;
-
- /*-------------------------------------------------------------------------
- * references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- * in a second traversal of the output file
- *-------------------------------------------------------------------------
- */
- if (H5T_REFERENCE==H5Tget_class(wtype_id))
- {
- ;
- }
- else /* H5T_REFERENCE */
- {
- /* get the storage size of the input dataset */
- dsize_in=H5Dget_storage_size(dset_in);
-
- /* check for datasets too small */
- if (nelmts*msize < options->threshold )
- apply_s=0;
-
- /* apply the filter */
- if (apply_s){
- if (apply_filters(travt->objs[i].name,rank,dims,dcpl_out,options,&has_filter)<0)
- goto error;
- }
-
- /*-------------------------------------------------------------------------
- * create the output dataset;
- * disable error checking in case the dataset cannot be created with the
- * modified dcpl; in that case use the original instead
- *-------------------------------------------------------------------------
- */
- H5E_BEGIN_TRY {
- dset_out=H5Dcreate(fidout,travt->objs[i].name,wtype_id,f_space_id,dcpl_out);
- } H5E_END_TRY;
- if (dset_out==FAIL)
- {
- if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,wtype_id,f_space_id,dcpl_id))<0)
- goto error;
- apply_f=0;
- }
-
- /*-------------------------------------------------------------------------
- * read/write
- *-------------------------------------------------------------------------
- */
- if (nelmts)
- {
- size_t need = (size_t)(nelmts*msize); /* bytes needed */
- if ( need < H5TOOLS_MALLOCSIZE )
- buf = HDmalloc(need);
-
- if (buf != NULL )
- {
- if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- goto error;
- if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- goto error;
- }
-
- else /* possibly not enough memory, read/write by hyperslabs */
-
- {
- size_t p_type_nbytes = msize; /*size of memory type */
- hsize_t p_nelmts = nelmts; /*total selected elmts */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
- unsigned int vl_data = 0; /*contains VL datatypes */
-
- /* stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
- hsize_t sm_nbytes; /*bytes per stripmine */
- hsize_t sm_nelmts; /*elements per stripmine*/
- hid_t sm_space; /*stripmine data space */
-
- /* hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */
- hsize_t hs_nelmts; /*elements in request */
- hsize_t zero[8]; /*vector of zeros */
- int k;
-
- /* check if we have VL data in the dataset's datatype */
- if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- /*
- * determine the strip mine size and allocate a buffer. The strip mine is
- * a hyperslab whose size is manageable.
- */
- sm_nbytes = p_type_nbytes;
-
- for (k = rank; k > 0; --k) {
- sm_size[k - 1] = MIN(dims[k - 1], H5TOOLS_BUFSIZE / sm_nbytes);
- sm_nbytes *= sm_size[k - 1];
- assert(sm_nbytes > 0);
- }
- sm_buf = HDmalloc((size_t)sm_nbytes);
-
- sm_nelmts = sm_nbytes / p_type_nbytes;
- sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
-
- /* the stripmine loop */
- memset(hs_offset, 0, sizeof hs_offset);
- memset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
- {
- /* calculate the hyperslab size */
- if (rank > 0)
- {
- for (k = 0, hs_nelmts = 1; k < rank; k++)
- {
- hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]);
- hs_nelmts *= hs_size[k];
- }
-
- if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL)<0)
- goto error;
- if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL)<0)
- goto error;
- }
- else
- {
- H5Sselect_all(f_space_id);
- H5Sselect_all(sm_space);
- hs_nelmts = 1;
- } /* rank */
-
- /* read/write */
- if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
- goto error;
- if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0)
- goto error;
-
- /* reclaim any VL memory, if necessary */
- if(vl_data)
- H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf);
-
- /* calculate the next hyperslab offset */
- for (k = rank, carry = 1; k > 0 && carry; --k)
- {
- hs_offset[k - 1] += hs_size[k - 1];
- if (hs_offset[k - 1] == dims[k - 1])
- hs_offset[k - 1] = 0;
- else
- carry = 0;
- } /* k */
- } /* elmtno */
-
- H5Sclose(sm_space);
/* free */
- if (sm_buf!=NULL)
+ if (buf!=NULL)
{
- HDfree(sm_buf);
- sm_buf=NULL;
+ HDfree(buf);
+ buf=NULL;
}
- } /* hyperslab read */
- }/*nelmts*/
-
+
+ } /* i */
+
/*-------------------------------------------------------------------------
- * amount of compression used
- *-------------------------------------------------------------------------
- */
- if (options->verbose)
- {
- if (apply_s && apply_f)
- {
- /* get the storage size of the input dataset */
- dsize_out=H5Dget_storage_size(dset_out);
- PER((hssize_t)dsize_in,(hssize_t)dsize_out);
- print_dataset_info(dcpl_out,travt->objs[i].name,per*100.0);
- }
- else
- print_dataset_info(dcpl_id,travt->objs[i].name,0.0);
-
- /* print a message that the filter was not applied
- (in case there was a filter)
- */
- if ( has_filter && apply_s == 0 )
- printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n",
- travt->objs[i].name,
- (int)options->threshold);
-
- if ( has_filter && apply_f == 0 )
- printf(" <warning: could not apply the filter to %s>\n",
- travt->objs[i].name);
-
- } /* verbose */
-
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(dset_in,dset_out,options)<0)
- goto error;
-
- /*close */
- if (H5Dclose(dset_out)<0)
- goto error;
-
- }/*H5T_REFERENCE*/
- }/*h5tools_canreadf*/
-
-
- /*-------------------------------------------------------------------------
- * close
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
*-------------------------------------------------------------------------
*/
- if (H5Tclose(ftype_id)<0)
- goto error;
- if (H5Tclose(wtype_id)<0)
- goto error;
- if (H5Pclose(dcpl_id)<0)
- goto error;
- if (H5Pclose(dcpl_out)<0)
- goto error;
- if (H5Sclose(f_space_id)<0)
- goto error;
- if (H5Dclose(dset_in)<0)
- goto error;
-
- }
- /*-------------------------------------------------------------------------
- * we do not have request for filter/chunking use H5Ocopy instead
- *-------------------------------------------------------------------------
- */
- else
- {
- hid_t pid;
-
- /* create property to pass copy options */
- if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- goto error;
-
- /* set options for object copy */
- if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
- goto error;
-
- /*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------
- */
-
- if (H5Ocopy(fidin, /* Source file or group identifier */
- travt->objs[i].name, /* Name of the source object to be copied */
- fidout, /* Destination file or group identifier */
- travt->objs[i].name, /* Name of the destination object */
- pid, /* Properties which apply to the copy */
- H5P_DEFAULT)<0) /* Properties which apply to the new hard link */
- goto error;
-
- /* close property */
- if (H5Pclose(pid)<0)
- goto error;
-
-
- /*-------------------------------------------------------------------------
- * copy attrs manually
- *-------------------------------------------------------------------------
- */
- if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
- goto error;
- if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0)
- goto error;
- if (copy_attr(dset_in,dset_out,options)<0)
- goto error;
- if (H5Dclose(dset_in)<0)
- goto error;
- if (H5Dclose(dset_out)<0)
- goto error;
-
-
- } /* end do we have request for filter/chunking */
-
-
- break;
-
-/*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
- case H5G_TYPE:
-
- if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
- goto error;
-
- if ((type_out = H5Tcopy(type_in))<0)
- goto error;
-
- if ((H5Tcommit(fidout,travt->objs[i].name,type_out))<0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(type_in,type_out,options)<0)
- goto error;
-
- if (H5Tclose(type_in)<0)
- goto error;
- if (H5Tclose(type_out)<0)
- goto error;
-
- if (options->verbose)
- printf(FORMAT_OBJ,"type",travt->objs[i].name );
- break;
-
-
-/*-------------------------------------------------------------------------
- * 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:
- {
- if(H5Lcopy(fidin, travt->objs[i].name,fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
goto error;
- if (options->verbose)
- printf(FORMAT_OBJ,"link",travt->objs[i].name );
-
- }
- break;
-
- default:
- goto error;
- } /* switch */
-
- /* free */
- if (buf!=NULL)
- {
- HDfree(buf);
- buf=NULL;
- }
-
- } /* i */
-
-/*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- *-------------------------------------------------------------------------
- */
-
- if ((grp_out = H5Gopen(fidout,"/"))<0)
- goto error;
-
- if ((grp_in = H5Gopen(fidin,"/"))<0)
- goto error;
+ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
+ goto error;
- if (copy_attr(grp_in,grp_out,options)<0)
- goto error;
+ if (copy_attr(grp_in,grp_out,options)<0)
+ goto error;
- if (H5Gclose(grp_out)<0)
- goto error;
- if (H5Gclose(grp_in)<0)
- goto error;
+ if (H5Gclose(grp_out)<0)
+ goto error;
+ if (H5Gclose(grp_in)<0)
+ goto error;
- return 0;
+ return 0;
error:
- H5E_BEGIN_TRY {
- H5Gclose(grp_in);
- H5Gclose(grp_out);
- H5Pclose(dcpl_id);
- H5Pclose(gcpl_id);
- H5Sclose(f_space_id);
- H5Dclose(dset_in);
- H5Dclose(dset_out);
- H5Tclose(ftype_id);
- H5Tclose(wtype_id);
- H5Tclose(type_in);
- H5Tclose(type_out);
- /* free */
- if (buf!=NULL)
- {
- HDfree(buf);
- buf=NULL;
- }
- if (sm_buf!=NULL)
- {
- HDfree(sm_buf);
- sm_buf=NULL;
- }
- } H5E_END_TRY;
- return -1;
-
+ H5E_BEGIN_TRY {
+ H5Gclose(grp_in);
+ H5Gclose(grp_out);
+ H5Pclose(dcpl_id);
+ H5Pclose(gcpl_id);
+ H5Sclose(f_space_id);
+ H5Dclose(dset_in);
+ H5Dclose(dset_out);
+ H5Tclose(ftype_id);
+ H5Tclose(wtype_id);
+ H5Tclose(type_in);
+ H5Tclose(type_out);
+ } H5E_END_TRY;
+ /* free */
+ if (buf!=NULL)
+ HDfree(buf);
+ if (sm_buf!=NULL)
+ HDfree(sm_buf);
+ return -1;
}
@@ -848,9 +829,9 @@ error:
* Function: copy_attr
*
* Purpose: copy attributes located in LOC_IN, which is obtained either from
- * loc_id = H5Gopen( fid, name);
- * loc_id = H5Dopen( fid, name);
- * loc_id = H5Topen( fid, name);
+ * loc_id = H5Gopen2( fid, name);
+ * loc_id = H5Dopen2( fid, name);
+ * loc_id = H5Topen2( fid, name);
*
* Return: 0, ok, -1 no
*
diff --git a/tools/h5repack/h5repack_list.c b/tools/h5repack/h5repack_list.c
index 3de8101..78b8858 100644
--- a/tools/h5repack/h5repack_list.c
+++ b/tools/h5repack/h5repack_list.c
@@ -165,52 +165,3 @@ out:
return -1;
}
-
-
-/*-------------------------------------------------------------------------
- * Function: print_objlist
- *
- * Purpose: print list of objects in file
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 23, 2003
- *
- *-------------------------------------------------------------------------
- */
-void print_objlist(const char *filename,
- int nobjects,
- trav_info_t *info )
-{
- int i;
-
- printf("File <%s>: # of entries = %d\n", filename, nobjects );
- for ( i = 0; i < nobjects; i++)
- {
- switch ( info[i].type )
- {
- case H5G_GROUP:
- printf(" %-10s %s\n", "group", info[i].name );
- break;
- case H5G_DATASET:
- printf(" %-10s %s\n", "dataset", info[i].name );
- break;
- case H5G_TYPE:
- printf(" %-10s %s\n", "datatype", info[i].name );
- break;
- 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 538c99f..71e42bb 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -53,406 +53,390 @@ int do_copy_refobjs(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- hid_t grp_in=(-1); /* read group ID */
- hid_t grp_out=(-1); /* write 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 dcpl_id=(-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 */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
- unsigned int i, j;
- int k;
+ hid_t grp_in=(-1); /* read group ID */
+ hid_t grp_out=(-1); /* write 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 dcpl_id=(-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 */
+ hsize_t nelmts; /* number of elements in dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ unsigned int i, j;
+ int k;
-/*-------------------------------------------------------------------------
- * browse
- *-------------------------------------------------------------------------
- */
-
- for ( i = 0; i < travt->nobjs; i++)
- {
- switch ( travt->objs[i].type )
- {
- /*-------------------------------------------------------------------------
- * H5G_GROUP
- *-------------------------------------------------------------------------
- */
- case H5G_GROUP:
-
- /*-------------------------------------------------------------------------
- * copy referenced objects in attributes
- *-------------------------------------------------------------------------
- */
-
- if ((grp_out=H5Gopen(fidout,travt->objs[i].name))<0)
- goto error;
-
- if((grp_in = H5Gopen (fidin,travt->objs[i].name))<0)
- goto error;
-
- if (copy_refs_attr(grp_in,grp_out,options,travt,fidout)<0)
- goto error;
-
- if (H5Gclose(grp_out)<0)
- goto error;
- if (H5Gclose(grp_in)<0)
- goto error;
-
-
-
-
- /*-------------------------------------------------------------------------
- * check for hard links
+ /*-------------------------------------------------------------------------
+ * browse
*-------------------------------------------------------------------------
*/
- if (travt->objs[i].nlinks)
- {
- for ( j=0; j<travt->objs[i].nlinks; j++)
+ for ( i = 0; i < travt->nobjs; i++)
{
- H5Glink(fidout,
- H5G_LINK_HARD,
- travt->objs[i].name,
- travt->objs[i].links[j].new_name);
+ switch ( travt->objs[i].type )
+ {
+ /*-------------------------------------------------------------------------
+ * H5G_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5G_GROUP:
+
+ /*-------------------------------------------------------------------------
+ * copy referenced objects in attributes
+ *-------------------------------------------------------------------------
+ */
+
+ if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ goto error;
+
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ goto error;
+
+ if (copy_refs_attr(grp_in,grp_out,options,travt,fidout) < 0)
+ goto error;
+
+ if (H5Gclose(grp_out) < 0)
+ goto error;
+ if (H5Gclose(grp_in) < 0)
+ goto error;
+
+
+ /*-------------------------------------------------------------------------
+ * check for hard links
+ *-------------------------------------------------------------------------
+ */
+
+ if(travt->objs[i].nlinks)
+ for(j = 0; j < travt->objs[i].nlinks; j++)
+ H5Glink(fidout, H5G_LINK_HARD, travt->objs[i].name, travt->objs[i].links[j].new_name);
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_DATASET
+ *-------------------------------------------------------------------------
+ */
+ case H5G_DATASET:
+
+ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
+ goto error;
+ if ((space_id=H5Dget_space(dset_in))<0)
+ goto error;
+ if ((ftype_id=H5Dget_type (dset_in))<0)
+ goto error;
+ if ((dcpl_id=H5Dget_create_plist(dset_in))<0)
+ goto error;
+ if ( (rank=H5Sget_simple_extent_ndims(space_id))<0)
+ goto error;
+ if ( H5Sget_simple_extent_dims(space_id,dims,NULL)<0)
+ goto error;
+ nelmts=1;
+ for (k=0; k<rank; k++)
+ nelmts*=dims[k];
+
+ if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
+ goto error;
+
+ if ((msize=H5Tget_size(mtype_id))==0)
+ goto error;
+ /*-------------------------------------------------------------------------
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
+ *-------------------------------------------------------------------------
+ */
+ if (h5tools_canreadf((NULL),dcpl_id)==1)
+ {
+ /*-------------------------------------------------------------------------
+ * test for a valid output dataset
+ *-------------------------------------------------------------------------
+ */
+ dset_out = FAIL;
+
+ /*-------------------------------------------------------------------------
+ * object references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tequal(mtype_id, H5T_STD_REF_OBJ))
+ {
+ H5G_obj_t1 obj_type;
+ hid_t refobj_id;
+ hobj_ref_t *refbuf=NULL; /* buffer for object references */
+ hobj_ref_t *buf=NULL;
+ const char* refname;
+ unsigned u;
+
+ /*-------------------------------------------------------------------------
+ * read to memory
+ *-------------------------------------------------------------------------
+ */
+
+ if (nelmts)
+ {
+ buf=(void *) HDmalloc((unsigned)(nelmts*msize));
+ if ( buf==NULL){
+ printf( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+
+ if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0)
+ goto error;
+ refbuf=HDcalloc((unsigned)nelmts,msize);
+ if ( refbuf==NULL){
+ printf( "cannot allocate memory\n" );
+ goto error;
+ }
+ for ( u=0; u<nelmts; u++)
+ {
+ H5E_BEGIN_TRY {
+ if ((refobj_id = H5Rdereference(dset_in,H5R_OBJECT,&buf[u]))<0)
+ continue;
+ } H5E_END_TRY;
+ /* get the name. a valid name could only occur in the
+ second traversal of the file */
+ if ((refname=MapIdToName(refobj_id,travt))!=NULL)
+ {
+ /* create the reference, -1 parameter for objects */
+ if (H5Rcreate(&refbuf[u],fidout,refname,H5R_OBJECT,-1)<0)
+ goto error;
+ if (options->verbose)
+ printf("object <%s> object reference created to <%s>\n",
+ travt->objs[i].name,
+ refname);
+ }/*refname*/
+ close_obj(obj_type,refobj_id);
+ }/* u */
+ }/*nelmts*/
+
+ /*-------------------------------------------------------------------------
+ * create/write dataset/close
+ *-------------------------------------------------------------------------
+ */
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
+ goto error;
+ if (nelmts) {
+ if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0)
+ goto error;
+ }
+
+ if (buf)
+ free(buf);
+ if (refbuf)
+ free(refbuf);
+
+ }/*H5T_STD_REF_OBJ*/
+
+ /*-------------------------------------------------------------------------
+ * dataset region references
+ *-------------------------------------------------------------------------
+ */
+ else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG))
+ {
+ H5G_obj_t1 obj_type;
+ hid_t refobj_id;
+ hdset_reg_ref_t *refbuf=NULL; /* input buffer for region references */
+ hdset_reg_ref_t *buf=NULL; /* output buffer */
+ const char* refname;
+ unsigned u;
+
+ /*-------------------------------------------------------------------------
+ * read input to memory
+ *-------------------------------------------------------------------------
+ */
+ if (nelmts)
+ {
+ buf=(void *) HDmalloc((unsigned)(nelmts*msize));
+ if ( buf==NULL){
+ printf( "cannot read into memory\n" );
+ goto error;
+ }
+ if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
+ goto error;
+ if ((obj_type = H5Rget_obj_type(dset_in,H5R_DATASET_REGION,buf))<0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * create output
+ *-------------------------------------------------------------------------
+ */
+
+ refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */
+ if ( refbuf==NULL){
+ printf( "cannot allocate memory\n" );
+ goto error;
+ }
+ for ( u=0; u<nelmts; u++)
+ {
+ H5E_BEGIN_TRY {
+ if ((refobj_id = H5Rdereference(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
+ continue;
+ } H5E_END_TRY;
+
+ /* get the name. a valid name could only occur in the
+ second traversal of the file */
+ if ((refname=MapIdToName(refobj_id,travt))!=NULL)
+ {
+ hid_t region_id; /* region id of the referenced dataset */
+ if ((region_id = H5Rget_region(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
+ goto error;
+ /* create the reference, we need the space_id */
+ if (H5Rcreate(&refbuf[u],fidout,refname,H5R_DATASET_REGION,region_id)<0)
+ goto error;
+ if (H5Sclose(region_id)<0)
+ goto error;
+ if (options->verbose)
+ printf("object <%s> region reference created to <%s>\n",
+ travt->objs[i].name,
+ refname);
+ }/*refname*/
+ close_obj(obj_type,refobj_id);
+ }/* u */
+ }/*nelmts*/
+
+ /*-------------------------------------------------------------------------
+ * create/write dataset/close
+ *-------------------------------------------------------------------------
+ */
+ if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
+ goto error;
+ if (nelmts) {
+ if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0)
+ goto error;
+ }
+
+ if (buf)
+ free(buf);
+ if (refbuf)
+ free(refbuf);
+ } /* H5T_STD_REF_DSETREG */
+
+
+ /*-------------------------------------------------------------------------
+ * not references, open previously created object in 1st traversal
+ *-------------------------------------------------------------------------
+ */
+ else
+ {
+ if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0)
+ goto error;
+ }
+
+ assert(dset_out!=FAIL);
+
+ /*-------------------------------------------------------------------------
+ * copy referenced objects in attributes
+ *-------------------------------------------------------------------------
+ */
+ if (copy_refs_attr(dset_in,dset_out,options,travt,fidout)<0)
+ goto error;
+
+ /*-------------------------------------------------------------------------
+ * check for hard links
+ *-------------------------------------------------------------------------
+ */
+ if(travt->objs[i].nlinks)
+ for(j = 0; j < travt->objs[i].nlinks; j++)
+ H5Glink(fidout, H5G_LINK_HARD, travt->objs[i].name, travt->objs[i].links[j].new_name);
+
+ if(H5Dclose(dset_out)<0)
+ goto error;
+
+ }/*can_read*/
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Tclose(ftype_id)<0)
+ goto error;
+ if (H5Tclose(mtype_id)<0)
+ goto error;
+ if (H5Pclose(dcpl_id)<0)
+ goto error;
+ if (H5Sclose(space_id)<0)
+ goto error;
+ if (H5Dclose(dset_in)<0)
+ goto error;
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_TYPE
+ *-------------------------------------------------------------------------
+ */
+ case H5G_TYPE:
+
+ if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
+ goto error;
+
+ if (H5Tclose(type_in)<0)
+ goto error;
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5G_LINK
+ *-------------------------------------------------------------------------
+ */
+
+ case H5G_LINK:
+
+ /*nothing to do */
+ break;
+
+ default:
+
+ break;
+ }
}
- }
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_DATASET
- *-------------------------------------------------------------------------
- */
- case H5G_DATASET:
- if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0)
- goto error;
- if ((space_id=H5Dget_space(dset_in))<0)
- goto error;
- if ((ftype_id=H5Dget_type (dset_in))<0)
- goto error;
- if ((dcpl_id=H5Dget_create_plist(dset_in))<0)
- goto error;
- if ( (rank=H5Sget_simple_extent_ndims(space_id))<0)
- goto error;
- if ( H5Sget_simple_extent_dims(space_id,dims,NULL)<0)
- goto error;
- nelmts=1;
- for (k=0; k<rank; k++)
- nelmts*=dims[k];
-
- if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
- goto error;
-
- if ((msize=H5Tget_size(mtype_id))==0)
- goto error;
-/*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
- *-------------------------------------------------------------------------
- */
- if (h5tools_canreadf((NULL),dcpl_id)==1)
- {
-/*-------------------------------------------------------------------------
- * test for a valid output dataset
- *-------------------------------------------------------------------------
- */
- dset_out = FAIL;
-
-/*-------------------------------------------------------------------------
- * object references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- *-------------------------------------------------------------------------
- */
- if (H5Tequal(mtype_id, H5T_STD_REF_OBJ))
- {
- H5G_obj_t1 obj_type;
- hid_t refobj_id;
- hobj_ref_t *refbuf=NULL; /* buffer for object references */
- hobj_ref_t *buf=NULL;
- const char* refname;
- unsigned u;
-
- /*-------------------------------------------------------------------------
- * read to memory
- *-------------------------------------------------------------------------
- */
-
- if (nelmts)
- {
- buf=(void *) HDmalloc((unsigned)(nelmts*msize));
- if ( buf==NULL){
- printf( "cannot read into memory\n" );
- goto error;
- }
- if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- goto error;
- if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0)
- goto error;
- refbuf=HDcalloc((unsigned)nelmts,msize);
- if ( refbuf==NULL){
- printf( "cannot allocate memory\n" );
- goto error;
- }
- for ( u=0; u<nelmts; u++)
- {
- H5E_BEGIN_TRY {
- if ((refobj_id = H5Rdereference(dset_in,H5R_OBJECT,&buf[u]))<0)
- continue;
- } H5E_END_TRY;
- /* get the name. a valid name could only occur in the
- second traversal of the file */
- if ((refname=MapIdToName(refobj_id,travt))!=NULL)
- {
- /* create the reference, -1 parameter for objects */
- if (H5Rcreate(&refbuf[u],fidout,refname,H5R_OBJECT,-1)<0)
- goto error;
- if (options->verbose)
- printf("object <%s> object reference created to <%s>\n",
- travt->objs[i].name,
- refname);
- }/*refname*/
- close_obj(obj_type,refobj_id);
- }/* u */
- }/*nelmts*/
/*-------------------------------------------------------------------------
- * create/write dataset/close
- *-------------------------------------------------------------------------
- */
- if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
- goto error;
- if (nelmts) {
- if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0)
- goto error;
- }
-
- if (buf)
- free(buf);
- if (refbuf)
- free(refbuf);
-
- }/*H5T_STD_REF_OBJ*/
-
-/*-------------------------------------------------------------------------
- * dataset region references
- *-------------------------------------------------------------------------
- */
- else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG))
- {
- H5G_obj_t1 obj_type;
- hid_t refobj_id;
- hdset_reg_ref_t *refbuf=NULL; /* input buffer for region references */
- hdset_reg_ref_t *buf=NULL; /* output buffer */
- const char* refname;
- unsigned u;
-
- /*-------------------------------------------------------------------------
- * read input to memory
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
+ * it must be done last, because the attributes might contain references to
+ * objects in the object list
*-------------------------------------------------------------------------
*/
- if (nelmts)
- {
- buf=(void *) HDmalloc((unsigned)(nelmts*msize));
- if ( buf==NULL){
- printf( "cannot read into memory\n" );
- goto error;
- }
- if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0)
- goto error;
- if ((obj_type = H5Rget_obj_type(dset_in,H5R_DATASET_REGION,buf))<0)
- goto error;
- /*-------------------------------------------------------------------------
- * create output
- *-------------------------------------------------------------------------
- */
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
+ goto error;
- refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */
- if ( refbuf==NULL){
- printf( "cannot allocate memory\n" );
- goto error;
- }
- for ( u=0; u<nelmts; u++)
- {
- H5E_BEGIN_TRY {
- if ((refobj_id = H5Rdereference(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
- continue;
- } H5E_END_TRY;
+ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
+ goto error;
- /* get the name. a valid name could only occur in the
- second traversal of the file */
- if ((refname=MapIdToName(refobj_id,travt))!=NULL)
- {
- hid_t region_id; /* region id of the referenced dataset */
- if ((region_id = H5Rget_region(dset_in,H5R_DATASET_REGION,&buf[u]))<0)
+ if (copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0)
goto error;
- /* create the reference, we need the space_id */
- if (H5Rcreate(&refbuf[u],fidout,refname,H5R_DATASET_REGION,region_id)<0)
+
+ if (H5Gclose(grp_out) < 0)
goto error;
- if (H5Sclose(region_id)<0)
+ if (H5Gclose(grp_in) < 0)
goto error;
- if (options->verbose)
- printf("object <%s> region reference created to <%s>\n",
- travt->objs[i].name,
- refname);
- }/*refname*/
- close_obj(obj_type,refobj_id);
- }/* u */
- }/*nelmts*/
-
- /*-------------------------------------------------------------------------
- * create/write dataset/close
- *-------------------------------------------------------------------------
- */
- if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0)
- goto error;
- if (nelmts) {
- if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0)
- goto error;
- }
-
- if (buf)
- free(buf);
- if (refbuf)
- free(refbuf);
- } /* H5T_STD_REF_DSETREG */
-
-
-/*-------------------------------------------------------------------------
- * not references, open previously created object in 1st traversal
- *-------------------------------------------------------------------------
- */
- else
- {
- if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0)
- goto error;
- }
- assert(dset_out!=FAIL);
-
-/*-------------------------------------------------------------------------
- * copy referenced objects in attributes
- *-------------------------------------------------------------------------
- */
- if (copy_refs_attr(dset_in,dset_out,options,travt,fidout)<0)
- goto error;
-
-/*-------------------------------------------------------------------------
- * check for hard links
- *-------------------------------------------------------------------------
- */
- if (travt->objs[i].nlinks)
- {
- for ( j=0; j<travt->objs[i].nlinks; j++){
- H5Glink(fidout,
- H5G_LINK_HARD,
- travt->objs[i].name,
- travt->objs[i].links[j].new_name);
- }
- }
-
- if (H5Dclose(dset_out)<0)
- goto error;
-
- }/*can_read*/
-
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
-
- if (H5Tclose(ftype_id)<0)
- goto error;
- if (H5Tclose(mtype_id)<0)
- goto error;
- if (H5Pclose(dcpl_id)<0)
- goto error;
- if (H5Sclose(space_id)<0)
- goto error;
- if (H5Dclose(dset_in)<0)
- goto error;
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_TYPE
- *-------------------------------------------------------------------------
- */
- case H5G_TYPE:
-
- if ((type_in = H5Topen (fidin,travt->objs[i].name))<0)
- goto error;
-
- if (H5Tclose(type_in)<0)
- goto error;
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5G_LINK
- *-------------------------------------------------------------------------
- */
-
- case H5G_LINK:
-
- /*nothing to do */
- break;
-
- default:
-
- break;
- }
- }
-
-
-
-/*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- * it must be done last, because the attributes might contain references to
- * objects in the object list
- *-------------------------------------------------------------------------
- */
-
- if ((grp_out = H5Gopen(fidout,"/"))<0)
- goto error;
-
- if ((grp_in = H5Gopen(fidin,"/"))<0)
- goto error;
-
- if (copy_refs_attr(grp_in,grp_out,options,travt,fidout)<0)
- goto error;
-
- if (H5Gclose(grp_out)<0)
- goto error;
- if (H5Gclose(grp_in)<0)
- goto error;
-
- return 0;
+ return 0;
error:
- H5E_BEGIN_TRY {
- H5Gclose(grp_in);
- H5Gclose(grp_out);
- H5Pclose(dcpl_id);
- H5Sclose(space_id);
- H5Dclose(dset_in);
- H5Dclose(dset_out);
- H5Tclose(ftype_id);
- H5Tclose(mtype_id);
- H5Tclose(type_in);
- } H5E_END_TRY;
- return -1;
-
+ H5E_BEGIN_TRY {
+ H5Gclose(grp_in);
+ H5Gclose(grp_out);
+ H5Pclose(dcpl_id);
+ H5Sclose(space_id);
+ H5Dclose(dset_in);
+ H5Dclose(dset_out);
+ H5Tclose(ftype_id);
+ H5Tclose(mtype_id);
+ H5Tclose(type_in);
+ } H5E_END_TRY;
+ return -1;
}
@@ -461,7 +445,7 @@ error:
*
* Purpose: duplicate all referenced HDF5 located in attributes
* relative to LOC_IN, which is obtained either from
- * loc_id = H5Gopen( fid, name);
+ * loc_id = H5Gopen2( fid, name, H5P_DEFAULT);
* loc_id = H5Dopen( fid, name);
* loc_id = H5Topen( fid, name);
*
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index 049e059..6c02e92 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -34,8 +34,8 @@ extern char *progname;
*-------------------------------------------------------------------------
*/
-int has_filter(hid_t dcpl_id,
- H5Z_filter_t filtnin)
+static int
+has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
{
int nfilters; /* number of filters */
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 3328c70..b8c7948 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -1570,7 +1570,7 @@ int make_all_objects(hid_t loc_id)
*-------------------------------------------------------------------------
*/
group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen(loc_id, "/");
+ root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT);
/*-------------------------------------------------------------------------
* H5G_TYPE
@@ -1645,7 +1645,7 @@ int make_attributes(hid_t loc_id)
*-------------------------------------------------------------------------
*/
group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- root_id = H5Gopen(loc_id, "/");
+ root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT);
/*-------------------------------------------------------------------------
* write a series of attributes on the dataset, group, and root group
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 8f29519..280023e 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -476,7 +476,7 @@ group_stats(hid_t group, const char *name, const char *fullname,
iter->group_ohdr_info.total_size += oi->hdr.space.total;
iter->group_ohdr_info.free_size += oi->hdr.space.free;
- gid = H5Gopen(group, name);
+ gid = H5Gopen2(group, name, H5P_DEFAULT);
assert(gid > 0);
/* Get number of links in this group */
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 4b354b6..dc32b9e 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -1010,33 +1010,34 @@ hsize_t diff (hid_t file1_id,
*/
case H5G_GROUP:
- ret = HDstrcmp(path1,path2);
+ ret = HDstrcmp(path1, path2);
/* if "path1" != "path2" then the groups are "different" */
- nfound = (ret!=0) ? 1 : 0;
+ nfound = (ret != 0) ? 1 : 0;
- if (print_objname(options,nfound))
- do_print_objname ("group", path1, path2);
+ if(print_objname(options, nfound))
+ do_print_objname("group", path1, path2);
/* always print the number of differences found in verbose mode */
- if (options->m_verbose)
+ if(options->m_verbose)
print_found(nfound);
- if ((grp1_id = H5Gopen(file1_id, path1))<0)
+ if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
goto out;
- if ((grp2_id = H5Gopen(file2_id, path2))<0)
+ if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0)
goto out;
+
/*-------------------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a referenced object
*-------------------------------------------------------------------------
*/
- if (path1)
- nfound += diff_attr(grp1_id,grp2_id,path1,path2,options);
+ if(path1)
+ nfound += diff_attr(grp1_id, grp2_id, path1, path2, options);
- if ( H5Gclose(grp1_id)<0)
+ if(H5Gclose(grp1_id) < 0)
goto out;
- if ( H5Gclose(grp2_id)<0)
+ if(H5Gclose(grp2_id) < 0)
goto out;
break;
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 37bef3e..ab089cb 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -22,7 +22,7 @@
*
* Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are
* obtained either from
- * loc_id = H5Gopen( fid, name);
+ * loc_id = H5Gopen2( fid, name, H5P_DEFAULT);
* loc_id = H5Dopen( fid, name);
* loc_id = H5Topen( fid, name);
*
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index c714d45..b5a2872 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -25,7 +25,7 @@
*
*-------------------------------------------------------------------------
*/
-void
+static void
print_size (int rank, hsize_t *dims)
{
int i;
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 456b56b..c824b3d 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -340,7 +340,7 @@ static hssize_t get_nnames( hid_t loc_id, const char *group_name )
hsize_t nobjs = 0;
/* Open the group */
- if((gid = H5Gopen(loc_id, group_name)) < 0)
+ if((gid = H5Gopen2(loc_id, group_name, H5P_DEFAULT)) < 0)
return(-1);
/* Retrieve the number of objects in it */