summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2002-03-29 23:01:30 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2002-03-29 23:01:30 (GMT)
commit5e5889822117f79de83b1e399b73c2cc664db10f (patch)
tree04b23ec6168bf33b293fa809d625a2f48266f9a0 /tools
parentc6b201b25debf34ff0d49ddf80ece394b8c581d5 (diff)
downloadhdf5-5e5889822117f79de83b1e399b73c2cc664db10f.zip
hdf5-5e5889822117f79de83b1e399b73c2cc664db10f.tar.gz
hdf5-5e5889822117f79de83b1e399b73c2cc664db10f.tar.bz2
[svn-r5122] Purpose:
Fix and Code Removal Description: Back ported fix for the problem with >1024byte object names in the h5dumper. Removed the testfiles which were HDF4 specific. Solution: Changed the way the object name was being allocated from a static array size to a dynamically allocated address... Platforms tested: Linux
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c100
-rw-r--r--tools/h5dump/h5dumptst.c22
-rwxr-xr-xtools/h5dump/testh5dump.sh3
-rw-r--r--tools/lib/h5tools_utils.c186
-rw-r--r--tools/lib/h5tools_utils.h2
-rw-r--r--tools/testfiles/Expected/anno_test.h5bin4096 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/gr_typ_test.h5bin5296 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/grnameclash_test.h5bin11192 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/image_attr_test.h5bin5164 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/ras24il.h5bin5266 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/ras_24_test.h5bin8199 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/ras_8_test.h5bin4196 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/sds_attr.h5bin14048 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/sds_attr_test.h5bin8736 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/sds_dim_test.h5bin14032 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/sds_typ_test.h5bin10624 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/sdsnameclash_test.h5bin11840 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tall.hdfbin2969 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tattr.hdfbin783 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tcompound.hdfbin875 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tcompound2.hdfbin915 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tdset.hdfbin6747 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tdset2.hdfbin8943 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tgroup.hdfbin666 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/thlink.hdfbin619 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tloop.hdfbin375 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tmany.hdfbin4680 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tslink.hdfbin315 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tstr.hdfbin1429 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/tstr2.hdfbin4103 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vdata_test.h5bin6402 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vdnameclash_test.h5bin25332 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vg_all_test.h5bin26786 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vg_hl_test.h5bin6400 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vg_loop_test.h5bin6400 -> 0 bytes
-rw-r--r--tools/testfiles/Expected/vgnameclash_test.h5bin6344 -> 0 bytes
-rw-r--r--tools/testfiles/anno_test.hdfbin448 -> 0 bytes
-rw-r--r--tools/testfiles/gr_typ_test.hdfbin2052 -> 0 bytes
-rw-r--r--tools/testfiles/grnameclash_test.hdfbin3981 -> 0 bytes
-rw-r--r--tools/testfiles/image_attr_test.hdfbin1761 -> 0 bytes
-rw-r--r--tools/testfiles/ras24il.hdfbin1525 -> 0 bytes
-rw-r--r--tools/testfiles/ras_24_test.hdfbin2972 -> 0 bytes
-rw-r--r--tools/testfiles/ras_8_test.hdfbin593 -> 0 bytes
-rw-r--r--tools/testfiles/sds_attr_test.hdfbin9758 -> 0 bytes
-rw-r--r--tools/testfiles/sds_dim_test.hdfbin9086 -> 0 bytes
-rw-r--r--tools/testfiles/sds_typ_test.hdfbin9171 -> 0 bytes
-rw-r--r--tools/testfiles/sdsnameclash_test.hdfbin5426 -> 0 bytes
-rw-r--r--tools/testfiles/vdata_test.hdfbin802 -> 0 bytes
-rw-r--r--tools/testfiles/vdnameclash_test.hdfbin1536 -> 0 bytes
-rw-r--r--tools/testfiles/vg_all_test.hdfbin15825 -> 0 bytes
-rw-r--r--tools/testfiles/vg_hl_test.hdfbin1243 -> 0 bytes
-rw-r--r--tools/testfiles/vg_loop_test.hdfbin1249 -> 0 bytes
-rw-r--r--tools/testfiles/vgnameclash_test.hdfbin893 -> 0 bytes
53 files changed, 183 insertions, 130 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 6e4db4d..7dd3249 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1998, 1999, 2000, 2001
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002
* National Center for Supercomputing Applications
* All rights reserved.
*
@@ -36,7 +36,7 @@ static int usingdasho = FALSE;
**/
/* fill_ref_path_table is called to inialize the object reference paths. */
-static herr_t fill_ref_path_table(hid_t, const char *, void UNUSED *);
+static herr_t fill_ref_path_table(hid_t, const char *, void *);
/* module-scoped variables for XML option */
#define DEFAULT_DTD "http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.dtd"
@@ -520,18 +520,18 @@ static void dump_named_datatype(hid_t, const char *);
static void dump_dataset(hid_t, const char *, struct subset_t *);
static void dump_dataspace(hid_t space);
static void dump_datatype(hid_t type);
-static herr_t dump_attr(hid_t, const char *, void UNUSED *);
+static herr_t dump_attr(hid_t, const char *, void *);
static void dump_data(hid_t, int, struct subset_t *);
/* XML format: same interface, alternative output */
static void xml_dump_group(hid_t, const char *);
static void xml_dump_named_datatype(hid_t, const char *);
-static void xml_dump_dataset(hid_t, const char *, struct subset_t UNUSED *);
+static void xml_dump_dataset(hid_t, const char *, struct subset_t *);
static void xml_dump_dataspace(hid_t space);
static void xml_dump_datatype(hid_t type);
-static herr_t xml_dump_attr(hid_t, const char *, void UNUSED *);
-static void xml_dump_data(hid_t, int, struct subset_t UNUSED *);
+static herr_t xml_dump_attr(hid_t, const char *, void *);
+static void xml_dump_data(hid_t, int, struct subset_t *);
/**
** Added for XML **
@@ -594,7 +594,7 @@ static void
usage(const char *prog)
{
fflush(stdout);
- fprintf(stdout, " usage: %s [OPTIONS] file\n", prog);
+ fprintf(stdout, "usage: %s [OPTIONS] file\n", prog);
fprintf(stdout, " OPTIONS\n");
fprintf(stdout, " -h, --help Print a usage message and exit\n");
fprintf(stdout, " -B, --bootblock Print the content of the boot block\n");
@@ -1116,7 +1116,7 @@ dump_dataspace(hid_t space)
*-------------------------------------------------------------------------
*/
static herr_t
-dump_attr(hid_t attr, const char *attr_name, void UNUSED *op_data)
+dump_attr(hid_t attr, const char *attr_name, void * UNUSED op_data)
{
hid_t attr_id, type, space;
herr_t ret = SUCCEED;
@@ -1400,6 +1400,13 @@ dump_all(hid_t group, const char *name, void * op_data)
d_status = EXIT_FAILURE;
ret = FAIL;
} else {
+ int new_len = strlen(prefix) + strlen(name) + 2;
+
+ if (prefix_len <= new_len) {
+ prefix_len = new_len + 1;
+ prefix = realloc(prefix, prefix_len);
+ }
+
strcat(strcat(prefix, "/"), name);
dump_function_table->dump_group_function(obj, name);
strcpy(prefix, tmp);
@@ -1471,7 +1478,8 @@ dump_all(hid_t group, const char *name, void * op_data)
dset_table->objs[i].displayed = 1;
strcat(tmp, "/");
strcat(tmp, name);
- strcpy(dset_table->objs[i].objname, tmp);
+ free(dset_table->objs[i].objname);
+ dset_table->objs[i].objname = HDstrdup(tmp);
}
}
@@ -1564,7 +1572,7 @@ dump_group(hid_t gid, const char *name)
{
H5G_stat_t statbuf;
hid_t dset, type;
- char typename[1024], *tmp, comment[50];
+ char type_name[1024], *tmp, comment[50];
int i, xtype = H5G_UNKNOWN; /* dump all */
tmp = malloc(strlen(prefix) + strlen(name) + 2);
@@ -1591,10 +1599,10 @@ dump_group(hid_t gid, const char *name)
if (!type_table->objs[i].recorded) {
dset = H5Dopen(gid, type_table->objs[i].objname);
type = H5Dget_type(dset);
- sprintf(typename, "#%lu:%lu",
+ sprintf(type_name, "#%lu:%lu",
type_table->objs[i].objno[0],
type_table->objs[i].objno[1]);
- dump_named_datatype(type, typename);
+ dump_named_datatype(type, type_name);
H5Tclose(type);
H5Dclose(dset);
}
@@ -1613,7 +1621,8 @@ dump_group(hid_t gid, const char *name)
indentation(indent);
printf("%s \"%s\"\n", HARDLINK, group_table->objs[i].objname);
} else {
- strcpy(group_table->objs[i].objname, prefix);
+ 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);
@@ -1987,7 +1996,7 @@ set_output_file(const char *fname)
*-------------------------------------------------------------------------
*/
static void
-handle_attributes(hid_t fid, char *attr, void UNUSED *data)
+handle_attributes(hid_t fid, char *attr, void * UNUSED data)
{
dump_selected_attr(fid, attr);
}
@@ -2216,7 +2225,8 @@ handle_datasets(hid_t fid, char *dset, void *data)
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
} else {
- strcpy(dset_table->objs[idx].objname, dset);
+ free(dset_table->objs[idx].objname);
+ dset_table->objs[idx].objname = HDstrdup(dset);
dset_table->objs[idx].displayed = 1;
dump_dataset(dsetid, dset, sset);
}
@@ -2246,7 +2256,7 @@ handle_datasets(hid_t fid, char *dset, void *data)
*-------------------------------------------------------------------------
*/
static void
-handle_groups(hid_t fid, char *group, void UNUSED *data)
+handle_groups(hid_t fid, char *group, void * UNUSED data)
{
H5G_stat_t statbuf;
hid_t gid;
@@ -2260,6 +2270,13 @@ handle_groups(hid_t fid, char *group, void UNUSED *data)
dump_header_format->groupblockend);
d_status = EXIT_FAILURE;
} else {
+ int new_len = strlen(group) + 1;
+
+ if (prefix_len <= new_len) {
+ prefix_len = new_len;
+ prefix = realloc(prefix, prefix_len);
+ }
+
H5Gget_objinfo(gid, ".", TRUE, &statbuf);
strcpy(prefix, group);
dump_group(gid, group);
@@ -2284,7 +2301,7 @@ handle_groups(hid_t fid, char *group, void UNUSED *data)
*-------------------------------------------------------------------------
*/
static void
-handle_links(hid_t fid, char *links, void UNUSED *data)
+handle_links(hid_t fid, char *links, void * UNUSED data)
{
H5G_stat_t statbuf;
@@ -2340,11 +2357,11 @@ handle_links(hid_t fid, char *links, void UNUSED *data)
*-------------------------------------------------------------------------
*/
static void
-handle_datatypes(hid_t fid, char *type, void UNUSED *data)
+handle_datatypes(hid_t fid, char *type, void * UNUSED data)
{
- hid_t typeid;
+ hid_t type_id;
- if ((typeid = H5Topen(fid, type)) < 0) {
+ if ((type_id = H5Topen(fid, type)) < 0) {
/* check if type is unamed data type */
int idx = 0;
@@ -2379,15 +2396,15 @@ handle_datatypes(hid_t fid, char *type, void UNUSED *data)
d_status = EXIT_FAILURE;
} else {
hid_t dsetid = H5Dopen(fid, type_table->objs[idx].objname);
- typeid = H5Dget_type(dsetid);
- dump_named_datatype(typeid, type);
- H5Tclose(typeid);
+ type_id = H5Dget_type(dsetid);
+ dump_named_datatype(type_id, type);
+ H5Tclose(type_id);
H5Dclose(dsetid);
}
} else {
- dump_named_datatype(typeid, type);
+ dump_named_datatype(type_id, type);
- if (H5Tclose(typeid) < 0)
+ if (H5Tclose(type_id) < 0)
d_status = EXIT_FAILURE;
}
}
@@ -3168,7 +3185,7 @@ lookup_ref_path(hobj_ref_t * ref)
*-------------------------------------------------------------------------
*/
static herr_t
-fill_ref_path_table(hid_t group, const char *name, void UNUSED * op_data)
+fill_ref_path_table(hid_t group, const char *name, void * UNUSED op_data)
{
hid_t obj;
char *tmp;
@@ -3267,9 +3284,9 @@ static const char *apos = "&apos;";
static char *
xml_escape_the_name(const char *str)
{
- int extra;
- int len;
- int i;
+ size_t extra;
+ size_t len;
+ size_t i;
const char *cp;
char *ncp;
char *rcp;
@@ -3353,9 +3370,9 @@ xml_escape_the_name(const char *str)
static char *
xml_escape_the_string(const char *str, int slen)
{
- int extra;
- int len;
- int i;
+ size_t extra;
+ size_t len;
+ size_t i;
const char *cp;
char *ncp;
char *rcp;
@@ -3965,7 +3982,7 @@ xml_dump_dataspace(hid_t space)
*-------------------------------------------------------------------------
*/
static void
-xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED *sset)
+xml_dump_data(hid_t obj_id, int obj_data, struct subset_t * UNUSED sset)
{
h5dump_t *outputformat = &xml_dataformat;
int status = -1;
@@ -4069,7 +4086,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED *sset)
*-------------------------------------------------------------------------
*/
static herr_t
-xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data)
+xml_dump_attr(hid_t attr, const char *attr_name, void * UNUSED op_data)
{
hid_t attr_id, type, space;
char *t_aname = xml_escape_the_name(attr_name);
@@ -4350,7 +4367,7 @@ xml_dump_group(hid_t gid, const char *name)
H5G_stat_t statbuf;
char *cp;
hid_t dset, type;
- char typename[1024], *tmp = NULL;
+ char type_name[1024], *tmp = NULL;
char *par = NULL;
int i;
int isRoot = 0;
@@ -4409,7 +4426,8 @@ xml_dump_group(hid_t gid, const char *name)
free(t_objname);
} else {
/* first time this group has been seen -- describe it */
- strcpy(group_table->objs[i].objname, prefix);
+ free(group_table->objs[i].objname);
+ group_table->objs[i].objname = HDstrdup(prefix);
group_table->objs[i].displayed = 1;
/* 1. do all the attributes of the group */
@@ -4422,10 +4440,10 @@ xml_dump_group(hid_t gid, const char *name)
if (!type_table->objs[i].recorded) {
dset = H5Dopen(gid, type_table->objs[i].objname);
type = H5Dget_type(dset);
- sprintf(typename, "#%lu:%lu",
+ sprintf(type_name, "#%lu:%lu",
type_table->objs[i].objno[0],
type_table->objs[i].objno[1]);
- dump_function_table->dump_named_datatype_function(type, typename);
+ dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
}
@@ -4452,10 +4470,10 @@ xml_dump_group(hid_t gid, const char *name)
if (!type_table->objs[i].recorded) {
dset = H5Dopen(gid, type_table->objs[i].objname);
type = H5Dget_type(dset);
- sprintf(typename, "#%lu:%lu",
+ sprintf(type_name, "#%lu:%lu",
type_table->objs[i].objno[0],
type_table->objs[i].objno[1]);
- dump_function_table->dump_named_datatype_function(type, typename);
+ dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
}
@@ -4737,7 +4755,7 @@ check_compression(hid_t dcpl)
*-------------------------------------------------------------------------
*/
static void
-xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED *sset)
+xml_dump_dataset(hid_t did, const char *name, struct subset_t * UNUSED sset)
{
hid_t type, space;
hid_t dcpl;
diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c
index d26c4b8..0fb523b 100644
--- a/tools/h5dump/h5dumptst.c
+++ b/tools/h5dump/h5dumptst.c
@@ -55,6 +55,7 @@
#define FILE34 "tsplit_file"
#define FILE35 "tfamily%05d.h5"
#define FILE36 "tmulti"
+#define FILE37 "tlarge_objname.h5"
#define LENSTR 50
#define LENSTR2 11
@@ -2811,6 +2812,25 @@ void test_multi(void)
H5Pclose(fapl);
}
+static void test_large_objname(void)
+{
+ hid_t fid, group;
+ char grp_name[128];
+ register int i;
+
+ fid = H5Fcreate(FILE37, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ group = H5Gcreate(fid, "this_is_a_large_group_name", 0);
+
+ for (i = 0; i < 50; ++i) {
+ sprintf(grp_name, "this_is_a_large_group_name%d", i);
+ group = H5Gcreate(group, grp_name, 0);
+ }
+
+ H5Gclose(group);
+ H5Fclose(fid);
+}
+
int main(void)
{
test_group();
@@ -2860,5 +2880,7 @@ int main(void)
test_family();
test_multi();
+ test_large_objname();
+
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh
index 58f3a9c..83e71fc 100755
--- a/tools/h5dump/testh5dump.sh
+++ b/tools/h5dump/testh5dump.sh
@@ -155,6 +155,9 @@ TOOLTEST tsplit_file.ddl --filedriver=split tsplit_file
TOOLTEST tfamily.ddl --filedriver=family tfamily%05d.h5
TOOLTEST tmulti.ddl --filedriver=multi tmulti
+# test for files with group names which reach > 1024 bytes in size
+TOOLTEST tlarge_objname.ddl -w157 tlarge_objname.h5
+
# test Subsetting
TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5
TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index baaebc4..c9ef60d 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -1,6 +1,7 @@
/*
- * Copyright (c) 2001 National Center for Supercomputing Applications
- * All rights reserved.
+ * Copyright (c) 2001, 2002
+ * National Center for Supercomputing Applications
+ * All rights reserved.
*
* Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
* Tuesday, 6. March 2001
@@ -52,13 +53,13 @@ error_msg(const char *progname, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- fflush(stdout);
+ HDfflush(stdout);
#ifdef WIN32
- fprintf(stdout, "%s error: ", progname);
- vfprintf(stdout, fmt, ap);
+ HDfprintf(stdout, "%s error: ", progname);
+ HDvfprintf(stdout, fmt, ap);
#else
- fprintf(stderr, "%s error: ", progname);
- vfprintf(stderr, fmt, ap);
+ HDfprintf(stderr, "%s error: ", progname);
+ HDvfprintf(stderr, fmt, ap);
#endif
va_end(ap);
@@ -86,9 +87,14 @@ warn_msg(const char *progname, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- fflush(stdout);
- fprintf(stderr, "%s warning: ", progname);
- vfprintf(stderr, fmt, ap);
+ HDfflush(stdout);
+#ifdef WIN32
+ HDfprintf(stdout, "%s warning: ", progname);
+ HDvfprintf(stdout, fmt, ap);
+#else /* WIN32 */
+ HDfprintf(stderr, "%s warning: ", progname);
+ HDvfprintf(stderr, fmt, ap);
+#endif /* WIN32 */
va_end(ap);
}
@@ -122,7 +128,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
/* check for more flag-like tokens */
if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
return EOF;
- } else if (strcmp(argv[opt_ind], "--") == 0) {
+ } else if (HDstrcmp(argv[opt_ind], "--") == 0) {
opt_ind++;
return EOF;
}
@@ -134,9 +140,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
register int i;
for (i = 0; l_opts && l_opts[i].name; i++) {
- size_t len = strlen(l_opts[i].name);
+ size_t len = HDstrlen(l_opts[i].name);
- if (strncmp(arg, l_opts[i].name, len) == 0) {
+ if (HDstrncmp(arg, l_opts[i].name, len) == 0) {
/* we've found a matching long command line flag */
opt_opt = l_opts[i].shortval;
@@ -147,7 +153,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_arg = argv[++opt_ind];
} else if (l_opts[i].has_arg == require_arg) {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: option required for \"--%s\" flag\n",
argv[0], arg);
@@ -156,7 +162,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
} else {
if (arg[len] == '=') {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: no option required for \"%s\" flag\n",
argv[0], arg);
@@ -173,7 +179,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (l_opts[i].name == NULL) {
/* exhausted all of the l_opts we have and still didn't match */
if (opt_err)
- fprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
+ HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
opt_opt = '?';
}
@@ -188,7 +194,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) {
if (opt_err)
- fprintf(stderr, "%s: unknown option \"%c\"\n",
+ HDfprintf(stderr, "%s: unknown option \"%c\"\n",
argv[0], opt_opt);
/* if no chars left in this token, move to next token */
@@ -207,7 +213,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_arg = &argv[opt_ind++][sp + 1];
} else if (++opt_ind >= argc) {
if (opt_err)
- fprintf(stderr,
+ HDfprintf(stderr,
"%s: value expected for option \"%c\"\n",
argv[0], opt_opt);
@@ -255,7 +261,7 @@ indentation(int x)
while (x-- > 0)
printf(" ");
} else {
- fprintf(stderr, "error: the indentation exceeds the number of cols.\n");
+ HDfprintf(stderr, "error: the indentation exceeds the number of cols.\n");
exit(1);
}
}
@@ -302,17 +308,18 @@ void
init_table(table_t **tbl)
{
int i;
- table_t *table = malloc(sizeof(table_t));
+ table_t *table = HDmalloc(sizeof(table_t));
table->size = 20;
table->nobjs = 0;
- table->objs = malloc(table->size * sizeof(obj_t));
+ table->objs = HDmalloc(table->size * sizeof(obj_t));
for (i = 0; i < table->size; i++) {
table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].recorded = 0;
table->objs[i].objflag = 0;
+ table->objs[i].objname = NULL;
}
*tbl = table;
@@ -334,7 +341,7 @@ void
init_prefix(char **prefix, int prefix_len)
{
assert(prefix_len > 0);
- *prefix = calloc((size_t)prefix_len, 1);
+ *prefix = HDcalloc((size_t)prefix_len, 1);
}
@@ -417,93 +424,94 @@ find_objs(hid_t group, const char *name, void *op_data)
H5Gget_objinfo(group, name, TRUE, &statbuf);
- tmp = malloc(strlen(info->prefix) + strlen(name) + 2);
- strcpy(tmp, info->prefix);
+ tmp = HDmalloc(HDstrlen(info->prefix) + HDstrlen(name) + 2);
+ HDstrcpy(tmp, info->prefix);
switch (statbuf.type) {
- case H5G_GROUP:
- if ((obj = H5Gopen(group, name)) >= 0) {
- if (info->prefix_len < (int)(strlen(info->prefix) + strlen(name) + 2)) {
- info->prefix_len *= 2;
- info->prefix = realloc(info->prefix,
- info->prefix_len * sizeof(char));
- }
+ case H5G_GROUP:
+ if ((obj = H5Gopen(group, name)) >= 0) {
+ if (info->prefix_len < (int)(HDstrlen(info->prefix) + HDstrlen(name) + 2)) {
+ info->prefix_len *= 2;
+ info->prefix = HDrealloc(info->prefix,
+ info->prefix_len * sizeof(char));
+ }
- strcat(strcat(info->prefix,"/"), name);
+ HDstrcat(HDstrcat(info->prefix,"/"), name);
- if (statbuf.nlink > info->threshold) {
- if (search_obj(info->group_table, statbuf.objno) == FAIL) {
- add_obj(info->group_table, statbuf.objno, info->prefix);
- H5Giterate(obj, ".", NULL, find_objs, (void *)info);
+ if (statbuf.nlink > info->threshold) {
+ if (search_obj(info->group_table, statbuf.objno) == FAIL) {
+ add_obj(info->group_table, statbuf.objno, info->prefix);
+ H5Giterate(obj, ".", NULL, find_objs, (void *)info);
+ }
+ } else {
+ H5Giterate (obj, ".", NULL, find_objs, (void *)info);
}
- } else {
- H5Giterate (obj, ".", NULL, find_objs, (void *)info);
- }
- strcpy(info->prefix, tmp);
- H5Gclose (obj);
- } else {
- info->status = 1;
- }
+ HDstrcpy(info->prefix, tmp);
+ H5Gclose (obj);
+ } else {
+ info->status = 1;
+ }
- break;
+ break;
- case H5G_DATASET:
- strcat(tmp,"/");
- strcat(tmp,name); /* absolute name of the data set */
+ case H5G_DATASET:
+ HDstrcat(tmp,"/");
+ HDstrcat(tmp,name); /* absolute name of the data set */
- if (statbuf.nlink > info->threshold &&
- search_obj(info->dset_table, statbuf.objno) == FAIL)
- add_obj(info->dset_table, statbuf.objno, tmp);
+ if (statbuf.nlink > info->threshold &&
+ search_obj(info->dset_table, statbuf.objno) == FAIL)
+ add_obj(info->dset_table, statbuf.objno, tmp);
- if ((obj = H5Dopen (group, name)) >= 0) {
- type = H5Dget_type(obj);
+ if ((obj = H5Dopen (group, name)) >= 0) {
+ type = H5Dget_type(obj);
- if (H5Tcommitted(type) > 0) {
- H5Gget_objinfo(type, ".", TRUE, &statbuf);
+ if (H5Tcommitted(type) > 0) {
+ H5Gget_objinfo(type, ".", TRUE, &statbuf);
- if (search_obj(info->type_table, statbuf.objno) == FAIL) {
- add_obj(info->type_table, statbuf.objno, tmp);
- info->type_table->objs[info->type_table->nobjs - 1].objflag = 0;
+ if (search_obj(info->type_table, statbuf.objno) == FAIL) {
+ add_obj(info->type_table, statbuf.objno, tmp);
+ info->type_table->objs[info->type_table->nobjs - 1].objflag = 0;
+ }
}
- }
- H5Tclose(type);
- H5Dclose (obj);
- } else {
- info->status = 1;
- }
-
- break;
+ H5Tclose(type);
+ H5Dclose (obj);
+ } else {
+ info->status = 1;
+ }
+
+ break;
- case H5G_TYPE:
- strcat(tmp,"/");
- strcat(tmp,name); /* absolute name of the type */
- i = search_obj(info->type_table, statbuf.objno);
+ case H5G_TYPE:
+ HDstrcat(tmp,"/");
+ HDstrcat(tmp,name); /* absolute name of the type */
+ i = search_obj(info->type_table, statbuf.objno);
- if (i == FAIL) {
- add_obj(info->type_table, statbuf.objno, tmp) ;
+ if (i == FAIL) {
+ add_obj(info->type_table, statbuf.objno, tmp) ;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].recorded = 1;
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].recorded = 1;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
- } else {
- strcpy (info->type_table->objs[i].objname, tmp);
- info->type_table->objs[i].recorded = 1;
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
+ } else {
+ HDfree(info->type_table->objs[i].objname);
+ info->type_table->objs[i].objname = HDstrdup(tmp);
+ info->type_table->objs[i].recorded = 1;
- /* named data type */
- info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
- }
+ /* named data type */
+ info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
+ }
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
- free(tmp);
+ HDfree(tmp);
return SUCCEED;
}
@@ -637,18 +645,20 @@ add_obj(table_t *table, unsigned long *objno, char *objname)
if (table->nobjs == table->size) {
table->size *= 2;
- table->objs = realloc(table->objs, table->size * sizeof(obj_t));
+ table->objs = HDrealloc(table->objs, table->size * sizeof(obj_t));
for (i = table->nobjs; i < table->size; i++) {
table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].recorded = 0;
table->objs[i].objflag = 0;
+ table->objs[i].objname = NULL;
}
}
i = table->nobjs++;
table->objs[i].objno[0] = objno[0];
table->objs[i].objno[1] = objno[1];
- strcpy(table->objs[i].objname, objname);
+ HDfree(table->objs[i].objname);
+ table->objs[i].objname = HDstrdup(objname);
}
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index eda8e00b..bb47c94 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -69,7 +69,7 @@ extern int get_option(int argc, const char **argv, const char *opt,
/*struct taken from the dumper. needed in table struct*/
typedef struct obj_t {
unsigned long objno[2];
- char objname[1024];
+ char *objname;
int displayed;
int recorded;
int objflag;
diff --git a/tools/testfiles/Expected/anno_test.h5 b/tools/testfiles/Expected/anno_test.h5
deleted file mode 100644
index 8656bc2..0000000
--- a/tools/testfiles/Expected/anno_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/gr_typ_test.h5 b/tools/testfiles/Expected/gr_typ_test.h5
deleted file mode 100644
index 9238a46..0000000
--- a/tools/testfiles/Expected/gr_typ_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/grnameclash_test.h5 b/tools/testfiles/Expected/grnameclash_test.h5
deleted file mode 100644
index dcf73f8..0000000
--- a/tools/testfiles/Expected/grnameclash_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/image_attr_test.h5 b/tools/testfiles/Expected/image_attr_test.h5
deleted file mode 100644
index 9fd1e18..0000000
--- a/tools/testfiles/Expected/image_attr_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/ras24il.h5 b/tools/testfiles/Expected/ras24il.h5
deleted file mode 100644
index cfc2c04..0000000
--- a/tools/testfiles/Expected/ras24il.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/ras_24_test.h5 b/tools/testfiles/Expected/ras_24_test.h5
deleted file mode 100644
index 7ecc9de..0000000
--- a/tools/testfiles/Expected/ras_24_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/ras_8_test.h5 b/tools/testfiles/Expected/ras_8_test.h5
deleted file mode 100644
index 3d3c402..0000000
--- a/tools/testfiles/Expected/ras_8_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/sds_attr.h5 b/tools/testfiles/Expected/sds_attr.h5
deleted file mode 100644
index 49b2b0b..0000000
--- a/tools/testfiles/Expected/sds_attr.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/sds_attr_test.h5 b/tools/testfiles/Expected/sds_attr_test.h5
deleted file mode 100644
index 4628e15..0000000
--- a/tools/testfiles/Expected/sds_attr_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/sds_dim_test.h5 b/tools/testfiles/Expected/sds_dim_test.h5
deleted file mode 100644
index c3f9bed..0000000
--- a/tools/testfiles/Expected/sds_dim_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/sds_typ_test.h5 b/tools/testfiles/Expected/sds_typ_test.h5
deleted file mode 100644
index a26bb90..0000000
--- a/tools/testfiles/Expected/sds_typ_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/sdsnameclash_test.h5 b/tools/testfiles/Expected/sdsnameclash_test.h5
deleted file mode 100644
index 4eacd82..0000000
--- a/tools/testfiles/Expected/sdsnameclash_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tall.hdf b/tools/testfiles/Expected/tall.hdf
deleted file mode 100644
index b99ac28..0000000
--- a/tools/testfiles/Expected/tall.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tattr.hdf b/tools/testfiles/Expected/tattr.hdf
deleted file mode 100644
index 36b2497..0000000
--- a/tools/testfiles/Expected/tattr.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tcompound.hdf b/tools/testfiles/Expected/tcompound.hdf
deleted file mode 100644
index e5809d7..0000000
--- a/tools/testfiles/Expected/tcompound.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tcompound2.hdf b/tools/testfiles/Expected/tcompound2.hdf
deleted file mode 100644
index c0c5191..0000000
--- a/tools/testfiles/Expected/tcompound2.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tdset.hdf b/tools/testfiles/Expected/tdset.hdf
deleted file mode 100644
index 79753ea..0000000
--- a/tools/testfiles/Expected/tdset.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tdset2.hdf b/tools/testfiles/Expected/tdset2.hdf
deleted file mode 100644
index 2005d79..0000000
--- a/tools/testfiles/Expected/tdset2.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tgroup.hdf b/tools/testfiles/Expected/tgroup.hdf
deleted file mode 100644
index 88a8232..0000000
--- a/tools/testfiles/Expected/tgroup.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/thlink.hdf b/tools/testfiles/Expected/thlink.hdf
deleted file mode 100644
index a54ed0a..0000000
--- a/tools/testfiles/Expected/thlink.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tloop.hdf b/tools/testfiles/Expected/tloop.hdf
deleted file mode 100644
index 862d37e..0000000
--- a/tools/testfiles/Expected/tloop.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tmany.hdf b/tools/testfiles/Expected/tmany.hdf
deleted file mode 100644
index eb81862..0000000
--- a/tools/testfiles/Expected/tmany.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tslink.hdf b/tools/testfiles/Expected/tslink.hdf
deleted file mode 100644
index bb1ae97..0000000
--- a/tools/testfiles/Expected/tslink.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tstr.hdf b/tools/testfiles/Expected/tstr.hdf
deleted file mode 100644
index 5507e24..0000000
--- a/tools/testfiles/Expected/tstr.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/tstr2.hdf b/tools/testfiles/Expected/tstr2.hdf
deleted file mode 100644
index dc4df5b..0000000
--- a/tools/testfiles/Expected/tstr2.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vdata_test.h5 b/tools/testfiles/Expected/vdata_test.h5
deleted file mode 100644
index d81a34b..0000000
--- a/tools/testfiles/Expected/vdata_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vdnameclash_test.h5 b/tools/testfiles/Expected/vdnameclash_test.h5
deleted file mode 100644
index d5d6190..0000000
--- a/tools/testfiles/Expected/vdnameclash_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vg_all_test.h5 b/tools/testfiles/Expected/vg_all_test.h5
deleted file mode 100644
index be3b756..0000000
--- a/tools/testfiles/Expected/vg_all_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vg_hl_test.h5 b/tools/testfiles/Expected/vg_hl_test.h5
deleted file mode 100644
index a12eecd..0000000
--- a/tools/testfiles/Expected/vg_hl_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vg_loop_test.h5 b/tools/testfiles/Expected/vg_loop_test.h5
deleted file mode 100644
index 507d625..0000000
--- a/tools/testfiles/Expected/vg_loop_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/Expected/vgnameclash_test.h5 b/tools/testfiles/Expected/vgnameclash_test.h5
deleted file mode 100644
index 0d4e463..0000000
--- a/tools/testfiles/Expected/vgnameclash_test.h5
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/anno_test.hdf b/tools/testfiles/anno_test.hdf
deleted file mode 100644
index 3b6d7d9..0000000
--- a/tools/testfiles/anno_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/gr_typ_test.hdf b/tools/testfiles/gr_typ_test.hdf
deleted file mode 100644
index 5d70e3e..0000000
--- a/tools/testfiles/gr_typ_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/grnameclash_test.hdf b/tools/testfiles/grnameclash_test.hdf
deleted file mode 100644
index 2f385ae..0000000
--- a/tools/testfiles/grnameclash_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/image_attr_test.hdf b/tools/testfiles/image_attr_test.hdf
deleted file mode 100644
index 8a9f329..0000000
--- a/tools/testfiles/image_attr_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/ras24il.hdf b/tools/testfiles/ras24il.hdf
deleted file mode 100644
index d2d6ae5..0000000
--- a/tools/testfiles/ras24il.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/ras_24_test.hdf b/tools/testfiles/ras_24_test.hdf
deleted file mode 100644
index 1bafe9c..0000000
--- a/tools/testfiles/ras_24_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/ras_8_test.hdf b/tools/testfiles/ras_8_test.hdf
deleted file mode 100644
index 2fec68a..0000000
--- a/tools/testfiles/ras_8_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/sds_attr_test.hdf b/tools/testfiles/sds_attr_test.hdf
deleted file mode 100644
index 7e7323f5..0000000
--- a/tools/testfiles/sds_attr_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/sds_dim_test.hdf b/tools/testfiles/sds_dim_test.hdf
deleted file mode 100644
index 53d71b9..0000000
--- a/tools/testfiles/sds_dim_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/sds_typ_test.hdf b/tools/testfiles/sds_typ_test.hdf
deleted file mode 100644
index b2d9fcb..0000000
--- a/tools/testfiles/sds_typ_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/sdsnameclash_test.hdf b/tools/testfiles/sdsnameclash_test.hdf
deleted file mode 100644
index d32070b..0000000
--- a/tools/testfiles/sdsnameclash_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vdata_test.hdf b/tools/testfiles/vdata_test.hdf
deleted file mode 100644
index f44bad8..0000000
--- a/tools/testfiles/vdata_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vdnameclash_test.hdf b/tools/testfiles/vdnameclash_test.hdf
deleted file mode 100644
index 5ec91fc..0000000
--- a/tools/testfiles/vdnameclash_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vg_all_test.hdf b/tools/testfiles/vg_all_test.hdf
deleted file mode 100644
index 94f51c2..0000000
--- a/tools/testfiles/vg_all_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vg_hl_test.hdf b/tools/testfiles/vg_hl_test.hdf
deleted file mode 100644
index 367fcd6..0000000
--- a/tools/testfiles/vg_hl_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vg_loop_test.hdf b/tools/testfiles/vg_loop_test.hdf
deleted file mode 100644
index c2ce53b..0000000
--- a/tools/testfiles/vg_loop_test.hdf
+++ /dev/null
Binary files differ
diff --git a/tools/testfiles/vgnameclash_test.hdf b/tools/testfiles/vgnameclash_test.hdf
deleted file mode 100644
index 269f36e..0000000
--- a/tools/testfiles/vgnameclash_test.hdf
+++ /dev/null
Binary files differ