summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-02 19:07:17 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-07-02 19:07:17 (GMT)
commit072919b9d7fa341c1a886fb92841efa444f0ffae (patch)
tree923d02f3a1f8aebdbe5d7cd385e888f57b658931 /tools/h5dump
parentb02d857a99888d795a148b84d951a73672f4b311 (diff)
downloadhdf5-072919b9d7fa341c1a886fb92841efa444f0ffae.zip
hdf5-072919b9d7fa341c1a886fb92841efa444f0ffae.tar.gz
hdf5-072919b9d7fa341c1a886fb92841efa444f0ffae.tar.bz2
[svn-r8790] Purpose:
Description: the original code that showed a name for HARDLINK was reassigning that name to a name made in the dump traversal (made by concatenation by nested objects) Solution: removed this reassigmnet now the name showed after HARDLINK is always the first name found for that object (this object is printed once interely; subsequent printings show the word HARDLINK and the first name ) Platforms tested: linux AIX solaris Misc. update:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dump.c13
-rw-r--r--tools/h5dump/h5dumpgentest.c278
2 files changed, 165 insertions, 126 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index cfc4955..931f283 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -1232,7 +1232,7 @@ dump_selected_attr(hid_t loc_id, const char *name)
dump_oid(attr_id);
if (display_data || display_attr_data)
- dump_data(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai);
H5Tclose(type);
H5Sclose(space);
@@ -1510,10 +1510,7 @@ dump_all(hid_t group, const char *name, void * op_data)
goto done;
} else {
dset_table->objs[i].displayed = 1;
- strcat(tmp, "/");
- strcat(tmp, name);
- free(dset_table->objs[i].objname);
- dset_table->objs[i].objname = HDstrdup(tmp);
+
}
}
@@ -1643,8 +1640,7 @@ dump_group(hid_t gid, const char *name)
indentation(indent);
printf("%s \"%s\"\n", HARDLINK, group_table->objs[i].objname);
} else {
- free(group_table->objs[i].objname);
- group_table->objs[i].objname = HDstrdup(prefix);
+
group_table->objs[i].displayed = 1;
H5Aiterate(gid, NULL, dump_attr, NULL);
H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype);
@@ -2874,8 +2870,7 @@ handle_datasets(hid_t fid, char *dset, void *data)
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
} else {
- free(dset_table->objs[idx].objname);
- dset_table->objs[idx].objname = HDstrdup(dset);
+
dset_table->objs[idx].displayed = 1;
dump_dataset(dsetid, dset, sset);
}
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index fdd4e5a..806f3db 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -77,7 +77,7 @@
#define FILE45 "tnullspace.h5"
#define FILE46 "tfcontents1.h5"
#define FILE47 "tfcontents2.h5"
-
+#define FILE48 "tfvalues.h5"
/*-------------------------------------------------------------------------
@@ -4359,6 +4359,41 @@ static void gent_named_dtype_attr(void)
/*-------------------------------------------------------------------------
+ * Function: gent_null_space
+ *
+ * Purpose: generates dataset and attribute of null dataspace
+ *-------------------------------------------------------------------------
+ */
+static void gent_null_space(void)
+{
+ hid_t fid, root, dataset, space, attr;
+ int dset_buf = 10;
+ int point = 4;
+
+ fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ root = H5Gopen (fid, "/");
+
+ /* null space */
+ space = H5Screate(H5S_NULL);
+
+ /* dataset */
+ dataset = H5Dcreate(fid, "dset", H5T_STD_I32BE, space, H5P_DEFAULT);
+ /* nothing should be written */
+ H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf);
+
+ /* attribute */
+ attr = H5Acreate (root, "attr", H5T_NATIVE_UINT, space, H5P_DEFAULT);
+ H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */
+
+ H5Dclose(dataset);
+ H5Aclose(attr);
+ H5Gclose(root);
+ H5Sclose(space);
+ H5Fclose(fid);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: make_dset
*
* Purpose: utility function to create and write a dataset in LOC_ID
@@ -4550,16 +4585,16 @@ static void gent_filters(void)
*-------------------------------------------------------------------------
*/
#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE)
- /* remove the filters from the dcpl */
- ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
- assert(ret>=0);
+ /* remove the filters from the dcpl */
+ ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
+ assert(ret>=0);
- /* set szip data */
- ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
- assert(ret>=0);
+ /* set szip data */
+ ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
+ assert(ret>=0);
- ret=make_dset(fid,"szip",sid,dcpl,buf1);
- assert(ret>=0);
+ ret=make_dset(fid,"szip",sid,dcpl,buf1);
+ assert(ret>=0);
#endif
/*-------------------------------------------------------------------------
@@ -4630,10 +4665,10 @@ static void gent_filters(void)
#endif
#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_SZIP_CAN_ENCODE)
- szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK;
- /* set szip data */
- ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
- assert(ret>=0);
+ szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK;
+ /* set szip data */
+ ret=H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block);
+ assert(ret>=0);
#endif
#if defined (H5_HAVE_FILTER_DEFLATE)
@@ -4677,8 +4712,6 @@ static void gent_filters(void)
ret=H5Premove_filter(dcpl,H5Z_FILTER_ALL);
assert(ret>=0);
-
-
/*-------------------------------------------------------------------------
* make an external dataset
*-------------------------------------------------------------------------
@@ -4686,59 +4719,11 @@ static void gent_filters(void)
make_external(fid);
/*-------------------------------------------------------------------------
- * make datasets with fill value combinations
- * H5D_FILL_TIME_IFSET
- *-------------------------------------------------------------------------
- */
- ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
- assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
- ret=make_dset(fid,"fill_time_ifset",sid,dcpl,buf1);
- assert(ret>=0);
-
-/*-------------------------------------------------------------------------
- * H5D_FILL_TIME_ALLOC
- *-------------------------------------------------------------------------
- */
- ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC);
- assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
- ret=make_dset(fid,"fill_time_alloc",sid,dcpl,buf1);
- assert(ret>=0);
-
-/*-------------------------------------------------------------------------
- * H5D_FILL_TIME_NEVER
- *-------------------------------------------------------------------------
- */
- ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER);
- assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
- ret=make_dset(fid,"fill_time_never",sid,dcpl,buf1);
- assert(ret>=0);
-
-/*-------------------------------------------------------------------------
* H5D_ALLOC_TIME_EARLY
*-------------------------------------------------------------------------
*/
-
- ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
- assert(ret>=0);
-
ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
ret=make_dset(fid,"alloc_time_early",sid,dcpl,buf1);
assert(ret>=0);
@@ -4748,10 +4733,6 @@ static void gent_filters(void)
*/
ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR);
assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
ret=make_dset(fid,"alloc_time_incr",sid,dcpl,buf1);
assert(ret>=0);
@@ -4761,10 +4742,6 @@ static void gent_filters(void)
*/
ret=H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE);
assert(ret>=0);
-
- ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
- assert(ret>=0);
-
ret=make_dset(fid,"alloc_time_late",sid,dcpl,buf1);
assert(ret>=0);
@@ -4891,6 +4868,7 @@ static void gent_filters(void)
assert(ret>=0);
}
+
/*-------------------------------------------------------------------------
* Function: myfilter
*
@@ -4947,57 +4925,78 @@ set_local_myfilter(hid_t dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id)
*
*-------------------------------------------------------------------------
*/
+/*-------------------------------------------------------------------------
+ * Function: gent_fcontents
+ *
+ * Purpose: generate several files to list its contents
+ *
+ *-------------------------------------------------------------------------
+ */
static void gent_fcontents(void)
{
hid_t fid; /* file id */
hid_t gid1; /* group ID */
- hid_t gid2; /* group ID */
- hid_t gid3; /* group ID */
hid_t tid; /* datatype ID */
hsize_t dims[1]={4};
int buf[4]={1,2,3,4};
int ret;
-
+
+
/* create a file */
fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
assert(fid>=0);
+
write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf);
+
/*-------------------------------------------------------------------------
* links
*-------------------------------------------------------------------------
*/
- /* soft link to "dset" */
- ret=H5Glink (fid, H5G_LINK_SOFT, "dset", "softlink");
+
+ /* hard link to "dset" */
+ gid1 = H5Gcreate (fid, "/g1", 0);
+ H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset1");
+ H5Gclose(gid1);
+
+
+ /* hard link to "dset" */
+ gid1 = H5Gcreate (fid, "/g2", 0);
+ H5Glink (gid1, H5G_LINK_HARD, "/dset", "dset2");
+ H5Gclose(gid1);
+
+
+ /* hard link to "g2" */
+ gid1 = H5Gopen(fid, "/g1");
+ H5Glink (gid1, H5G_LINK_HARD, "/g2", "g1.1");
+ H5Gclose(gid1);
+
+
+ /* hard link to "dset" */
+ ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset3");
assert(ret>=0);
+
/* hard link to "dset" */
- ret=H5Glink (fid, H5G_LINK_HARD, "dset", "dset1");
+ ret=H5Glink (fid, H5G_LINK_HARD, "/dset", "dset4");
assert(ret>=0);
+
/* soft link to itself */
ret=H5Glink (fid, H5G_LINK_SOFT, "mylink", "mylink");
assert(ret>=0);
-/*-------------------------------------------------------------------------
- * groups
- *-------------------------------------------------------------------------
- */
- gid1 = H5Gcreate(fid,"g1",0);
- gid2 = H5Gcreate(gid1,"g2",0);
- gid3 = H5Gcreate(gid2,"g3",0);
- write_dset(gid3,1,dims,"dset",H5T_NATIVE_INT,buf);
- ret = H5Gclose(gid1);
- assert(ret>=0);
- ret = H5Gclose(gid2);
- assert(ret>=0);
- ret = H5Gclose(gid3);
+
+ /* soft link to "dset" */
+ ret=H5Glink (fid, H5G_LINK_SOFT, "/dset", "softlink");
assert(ret>=0);
+
+
/*-------------------------------------------------------------------------
- * datatypes
+ * datatypes
*-------------------------------------------------------------------------
*/
tid=H5Tcopy(H5T_NATIVE_INT);
@@ -5006,6 +5005,7 @@ static void gent_fcontents(void)
ret=H5Tclose(tid);
assert(ret>=0);
+
/* no name datatype */
tid=H5Tcopy(H5T_NATIVE_INT);
ret=H5Tcommit(fid, "mytype2", tid);
@@ -5016,61 +5016,105 @@ static void gent_fcontents(void)
ret=H5Tclose(tid);
assert(ret>=0);
+
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
+
ret=H5Fclose(fid);
assert(ret>=0);
+
/* create a file for the bootblock test */
fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
assert(fid>=0);
+
ret=H5Fclose(fid);
assert(ret>=0);
}
+/*-------------------------------------------------------------------------
+ * Function: gent_fvalues
+ *
+ * Purpose: generate a file for the fill values test
+ *
+ *-------------------------------------------------------------------------
+ */
+static void gent_fvalues(void)
+{
+ hid_t fid; /* file id */
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ hsize_t dims[1]={4};
+ int buf[4]={1,2,3,4};
+ int ret, fillval = -99;
+ /* create a file */
+ fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(fid>=0);
+
+ /* create a space */
+ sid = H5Screate_simple(1, dims, NULL);
+
+ /* create a dataset creation property list; the same DCPL is used for all dsets */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+
+/*-------------------------------------------------------------------------
+ * make datasets with fill value combinations
+ * H5D_FILL_TIME_IFSET
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET);
+ assert(ret>=0);
+
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+ ret=make_dset(fid,"fill_time_ifset",sid,dcpl,buf);
+ assert(ret>=0);
+/*-------------------------------------------------------------------------
+ * H5D_FILL_TIME_ALLOC
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC);
+ assert(ret>=0);
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
+
+ ret=make_dset(fid,"fill_time_alloc",sid,dcpl,buf);
+ assert(ret>=0);
/*-------------------------------------------------------------------------
- * Function: gent_null_space
- *
- * Purpose: generates dataset and attribute of null dataspace
+ * H5D_FILL_TIME_NEVER
*-------------------------------------------------------------------------
*/
-static void gent_null_space(void)
-{
- hid_t fid, root, dataset, space, attr;
- int dset_buf = 10;
- int point = 4;
-
- fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- root = H5Gopen (fid, "/");
-
- /* null space */
- space = H5Screate(H5S_NULL);
+ ret=H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER);
+ assert(ret>=0);
- /* dataset */
- dataset = H5Dcreate(fid, "dset", H5T_STD_I32BE, space, H5P_DEFAULT);
- /* nothing should be written */
- H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf);
+ ret=H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval);
+ assert(ret>=0);
- /* attribute */
- attr = H5Acreate (root, "attr", H5T_NATIVE_UINT, space, H5P_DEFAULT);
- H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */
+ ret=make_dset(fid,"fill_time_never",sid,dcpl,buf);
+ assert(ret>=0);
- H5Dclose(dataset);
- H5Aclose(attr);
- H5Gclose(root);
- H5Sclose(space);
- H5Fclose(fid);
+/*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ ret=H5Sclose(sid);
+ assert(ret>=0);
+ ret=H5Pclose(dcpl);
+ assert(ret>=0);
+ ret=H5Fclose(fid);
+ assert(ret>=0);
}
+
/*-------------------------------------------------------------------------
* Function: main
*