summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-10-06 16:11:18 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-10-06 16:11:18 (GMT)
commitdefe612ab21a22b9d54e19fa332d45f8489a6da5 (patch)
treed142a0ce72e5f80a3cba336542e5cadc96458a8c
parent5d9f7ebd4c1fb7a008aaa5190fa212dbca5c711c (diff)
downloadhdf5-defe612ab21a22b9d54e19fa332d45f8489a6da5.zip
hdf5-defe612ab21a22b9d54e19fa332d45f8489a6da5.tar.gz
hdf5-defe612ab21a22b9d54e19fa332d45f8489a6da5.tar.bz2
[svn-r9370] Purpose:
Refactor code Description: Refactor common code for determining the native type for using in the tools into separate routine. Also, reduce diffs between the two branches and bring back some fixes from the development branch to the release branch. Platforms tested: FreeBSD 4.10 (sleipnir) too minor to require h5committest
-rw-r--r--tools/h5dump/h5dump.c156
-rw-r--r--tools/h5dump/h5dumpgentest.c2
-rw-r--r--tools/h5ls/h5ls.c146
-rw-r--r--tools/h5repack/h5repack_copy.c24
-rw-r--r--tools/h5repack/h5repack_refs.c36
-rw-r--r--tools/lib/Makefile.in2
-rw-r--r--tools/lib/h5diff.c2
-rw-r--r--tools/lib/h5diff.h5
-rw-r--r--tools/lib/h5diff_array.c8
-rw-r--r--tools/lib/h5diff_attr.c24
-rw-r--r--tools/lib/h5diff_dset.c45
-rw-r--r--tools/lib/h5tools.c14
-rw-r--r--tools/lib/h5tools.h6
-rw-r--r--tools/lib/h5tools_filters.c2
-rw-r--r--tools/lib/h5tools_str.c3
-rw-r--r--tools/lib/h5tools_type.c47
-rw-r--r--tools/lib/h5trav.c6
-rw-r--r--tools/lib/h5trav.h6
-rw-r--r--tools/lib/talign.c7
19 files changed, 228 insertions, 313 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index eabbd61..6ff89d5 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -47,7 +47,7 @@ static int display_all = TRUE;
static int display_oid = FALSE;
static int display_data = TRUE;
static int display_attr_data = TRUE;
-static int display_char = FALSE; /*print 1-byte numbers as ASCII? */
+static int display_char = FALSE; /*print 1-byte numbers as ASCII */
static int usingdasho = FALSE;
static int display_bb = FALSE; /*superblock */
static int display_dcpl = FALSE; /*dcpl */
@@ -65,9 +65,9 @@ static int display_escape = FALSE; /*escape non printable characters
static int doxml = 0;
static int useschema = 1;
-static const char *xml_dtd_uri = NULL;
-static const char *xmlnsprefix="hdf5:";
-hid_t thefile = -1;
+static const char *xml_dtd_uri = NULL;
+static const char *xmlnsprefix="hdf5:";
+hid_t thefile = -1;
/** end XML **/
@@ -79,12 +79,7 @@ static herr_t dump_all(hid_t group, const char *name, void *op_data);
#ifdef LATER
static void check_compression(hid_t);
#endif /* LATER */
-static int xml_name_to_XID(const char *, char *, int , int );
-
-
-
-/* external functions */
-extern int print_data(hid_t, hid_t, int);
+static int xml_name_to_XID(const char *, char *, int , int );
static h5dump_t dataformat = {
0, /*raw */
@@ -151,9 +146,8 @@ static h5dump_t dataformat = {
"%s", /*dset_blockformat_pre */
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
- 1 , /*array indices */
- 1 /*escape non printable characters */
-
+ 1, /*array indices */
+ 1 /*escape non printable characters */
};
/**
@@ -236,8 +230,8 @@ static h5dump_t xml_dataformat = {
"%s", /*dset_blockformat_pre */
"%s", /*dset_ptformat_pre */
"%s", /*dset_ptformat */
- 0 , /*array indices */
- 0 /*escape non printable characters */
+ 0, /*array indices */
+ 0 /*escape non printable characters */
};
/** XML **/
@@ -1604,7 +1598,7 @@ 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(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[i].objno);
+ sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[i].objno);
dump_named_datatype(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -1649,7 +1643,7 @@ dump_group(hid_t gid, const char *name)
*
* Programmer: Ruey-Hsia Li
*
- * Modifications:
+ * Modifications: pvn, 2004, added dcpl dump
*
*-------------------------------------------------------------------------
*/
@@ -1851,7 +1845,7 @@ dump_subsetting_header(struct subset_t *sset, int dims)
*
* Programmer: Ruey-Hsia Li
*
- * Modifications:
+ * Modifications: pvn, print the matrix indices
*
*-------------------------------------------------------------------------
*/
@@ -1868,7 +1862,6 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex)
int depth;
int stdindent = COL; /* should be 3 */
-
outputformat->line_ncols = nCols;
outputformat->do_escape=display_escape;
/* print the matrix indices */
@@ -1948,14 +1941,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex)
if(space_type == H5S_NULL || space_type == H5S_NO_CLASS || space_type == H5S_COMPLEX) {
status = SUCCEED;
} else {
- H5T_class_t type_class;
-
type = H5Aget_type(obj_id);
- type_class = H5Tget_class(type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
+ p_type = h5tools_get_native_type(type);
ndims = H5Sget_simple_extent_dims(space, size, NULL);
@@ -2062,35 +2049,29 @@ static void dump_comment(hid_t obj_id)
static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id)
{
- h5tools_context_t ctx; /*print context */
- size_t size;
- void *buf=NULL;
- int nelmts=1;
- h5dump_t *outputformat = &dataformat;
- hid_t n_type;
- H5T_class_t type_class;
-
- memset(&ctx, 0, sizeof(ctx));
- ctx.indent_level=2;
-
- type_class = H5Tget_class(type_id);
- if(type_class==H5T_BITFIELD)
- n_type=H5Tcopy(type_id);
- else
- n_type = H5Tget_native_type(type_id,H5T_DIR_DEFAULT);
-
- size = H5Tget_size(n_type);
- buf = malloc(size);
-
- H5Pget_fill_value(dcpl, n_type, buf);
-
- h5tools_dump_simple_data(stdout, outputformat, obj_id, &ctx,
- START_OF_DATA | END_OF_DATA, nelmts, n_type, buf);
+ h5tools_context_t ctx; /*print context */
+ size_t size;
+ void *buf=NULL;
+ hsize_t nelmts=1;
+ h5dump_t *outputformat = &dataformat;
+ hid_t n_type;
+
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.indent_level=2;
- H5Tclose(n_type);
+ n_type = h5tools_get_native_type(type_id);
- if (buf)
- free (buf);
+ size = H5Tget_size(n_type);
+ buf = malloc(size);
+
+ H5Pget_fill_value(dcpl, n_type, buf);
+
+ h5tools_dump_simple_data(stdout, outputformat, obj_id, &ctx, START_OF_DATA | END_OF_DATA, nelmts, n_type, buf);
+
+ H5Tclose(n_type);
+
+ if (buf)
+ free (buf);
}
@@ -2189,8 +2170,8 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
printf("%s %s\n", EXTERNAL, BEGIN);
/*start indent */
indent += COL;
- for ( i=0; i<next; i++) {
- H5Pget_external(dcpl_id,i,sizeof(name),name,&offset,&size);
+ for ( j=0; j<(unsigned)next; j++) {
+ H5Pget_external(dcpl_id,j,sizeof(name),name,&offset,&size);
indentation(indent + COL);
HDfprintf(stdout,"FILENAME %s SIZE %Hu OFFSET %ld\n",name,size,offset);
}
@@ -2356,15 +2337,18 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
H5Pget_fill_time(dcpl_id, &ft);
switch ( ft )
{
- case H5D_FILL_TIME_ALLOC:
- printf("%s", "H5D_FILL_TIME_ALLOC\n");
- break;
- case H5D_FILL_TIME_NEVER:
- printf("%s", "H5D_FILL_TIME_NEVER\n");
- break;
- case H5D_FILL_TIME_IFSET:
- printf("%s", "H5D_FILL_TIME_IFSET\n");
- break;
+ case H5D_FILL_TIME_ALLOC:
+ printf("%s", "H5D_FILL_TIME_ALLOC\n");
+ break;
+ case H5D_FILL_TIME_NEVER:
+ printf("%s", "H5D_FILL_TIME_NEVER\n");
+ break;
+ case H5D_FILL_TIME_IFSET:
+ printf("%s", "H5D_FILL_TIME_IFSET\n");
+ break;
+ default:
+ assert(0);
+ break;
}
indentation(indent + COL);
printf("%s ", "VALUE ");
@@ -2396,15 +2380,18 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
H5Pget_alloc_time(dcpl_id, &at);
switch (at)
{
- case H5D_ALLOC_TIME_EARLY:
- printf("%s", "H5D_ALLOC_TIME_EARLY\n");
- break;
- case H5D_ALLOC_TIME_INCR:
- printf("%s", "H5D_ALLOC_TIME_INCR\n");
- break;
- case H5D_ALLOC_TIME_LATE:
- printf("%s", "H5D_ALLOC_TIME_LATE\n");
- break;
+ case H5D_ALLOC_TIME_EARLY:
+ printf("%s", "H5D_ALLOC_TIME_EARLY\n");
+ break;
+ case H5D_ALLOC_TIME_INCR:
+ printf("%s", "H5D_ALLOC_TIME_INCR\n");
+ break;
+ case H5D_ALLOC_TIME_LATE:
+ printf("%s", "H5D_ALLOC_TIME_LATE\n");
+ break;
+ default:
+ assert(0);
+ break;
}
/* end indent */
indent -= COL;
@@ -2867,7 +2854,6 @@ handle_datasets(hid_t fid, char *dset, void *data)
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
} else {
-
dset_table->objs[idx].displayed = 1;
dump_dataset(dsetid, dset, sset);
}
@@ -3458,7 +3444,6 @@ main(int argc, const char *argv[])
info.dset_table = dset_table;
info.status = d_status;
-
thefile = fid;
/* find all objects that might be targets of a refernce */
if ((gid = H5Gopen(fid, "/")) < 0) {
@@ -3542,7 +3527,7 @@ main(int argc, const char *argv[])
}
}
- if (!doxml)
+ if (!doxml)
{
if (display_fi)
{
@@ -3626,7 +3611,7 @@ done:
/*-------------------------------------------------------------------------
* Function: print_enum
*
- * Purpose: prints the enum data -
+ * Purpose: prints the enum data
*
* Return: void
*
@@ -4849,13 +4834,7 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU
status = xml_print_strs(obj_id, ATTRIBUTE_DATA);
} else {
/* all other data */
- H5T_class_t type_class;
-
- type_class = H5Tget_class(type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
+ p_type = h5tools_get_native_type(type);
H5Tclose(type);
@@ -5676,7 +5655,7 @@ check_filters(hid_t dcpl)
}
}
-static void xml_dump_fill_value(hid_t type)
+static void xml_dump_fill_value(hid_t dcpl, hid_t type)
{
size_t sz;
size_t i;
@@ -5692,6 +5671,8 @@ char * name;
space = H5Tget_size(type);
buf = malloc((size_t)space);
+ H5Pget_fill_value(dcpl, type, buf);
+
if (H5Tget_class(type) == H5T_REFERENCE) {
path = lookup_ref_path(*(hobj_ref_t *)buf);
@@ -5968,7 +5949,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
indentation(indent + COL);
printf("<%sNoFill/>\n",xmlnsprefix);
} else {
- xml_dump_fill_value(type);
+ xml_dump_fill_value(dcpl,type);
}
indent -= COL;
@@ -6204,8 +6185,7 @@ xml_print_enum(hid_t type)
static hid_t
h5_fileaccess(void)
{
- static const char *multi_letters = "msbrglo";
-
+ static const char *multi_letters = "msbrglo";
const char *val = NULL;
const char *name;
char s[1024];
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index bc84d08..51ca97f 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -5098,7 +5098,7 @@ static void gent_string(void)
hid_t str_tid; /* datatype ID */
hid_t did; /* dataset ID */
char buf1[]={"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"};
- char *buf2[SPACE1_DIM1]= {
+ const char *buf2[SPACE1_DIM1]= {
"Four score and seven\n years ago our forefathers brought forth on this continent a new nation,",
"conceived in liberty\n and dedicated to the proposition that all men are created equal.",
"Now we are engaged\n in a great civil war,",
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 6066812..5d1c6b2 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -78,7 +78,6 @@ static herr_t list (hid_t group, const char *name, void *cd);
static void display_type(hid_t type, int ind);
static char *fix_name(const char *path, const char *base);
-
hid_t thefile;
char *prefix;
char *progname;
@@ -1333,13 +1332,13 @@ list_attr (hid_t obj, const char *attr_name, void UNUSED *op_data)
printf("%*s", MAX(0, 9-n), "");
if ((attr = H5Aopen_name(obj, attr_name))) {
- space = H5Aget_space(attr);
- type = H5Aget_type(attr);
+ space = H5Aget_space(attr);
+ type = H5Aget_type(attr);
- /* Data space */
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
- space_type = H5Sget_simple_extent_type(space);
- switch (space_type) {
+ /* Data space */
+ ndims = H5Sget_simple_extent_dims(space, size, NULL);
+ space_type = H5Sget_simple_extent_type(space);
+ switch (space_type) {
case H5S_SCALAR:
/* scalar dataspace */
puts(" scalar");
@@ -1357,76 +1356,68 @@ list_attr (hid_t obj, const char *attr_name, void UNUSED *op_data)
/* null dataspace */
puts(" null");
break;
- }
-
- /* Data type */
- printf(" Type: ");
- display_type(type, 15);
- putchar('\n');
-
- /* Data */
- memset(&info, 0, sizeof info);
- info.line_multi_new = 1;
- if (nelmts<5) {
- info.idx_fmt = "";
- info.line_1st = " Data: ";
- info.line_pre = " ";
- info.line_cont = " ";
- info.str_repeat = 8;
-
- } else {
- printf(" Data:\n");
- info.idx_fmt = "(%s)";
- info.line_pre = " %s ";
- info.line_cont = " %s ";
- info.str_repeat = 8;
- }
-
- info.line_ncols = width_g;
- if (label_g) info.cmpd_name = "%s=";
- if (string_g && 1==H5Tget_size(type) &&
- H5T_INTEGER==H5Tget_class(type)) {
- info.ascii = TRUE;
- info.elmt_suf1 = "";
- info.elmt_suf2 = "";
- info.idx_fmt = "(%s)";
- info.line_pre = " %s \"";
- info.line_suf = "\"";
- }
-
- /* values of type reference */
- info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
- info.obj_hidefileno = 0;
- if (hexdump_g) {
- p_type = H5Tcopy(type);
- } else {
- H5T_class_t type_class;
-
- type_class = H5Tget_class(type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
- }
-
- if (p_type>=0) {
- temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- assert(temp_need==(hsize_t)((size_t)temp_need));
- need = (size_t)temp_need;
- buf = malloc(need);
- assert(buf);
- if (H5Aread(attr, p_type, buf)>=0) {
- h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1);
- }
- free(buf);
- H5Tclose(p_type);
- }
-
- H5Sclose(space);
- H5Tclose(type);
- H5Aclose(attr);
+ }
+
+ /* Data type */
+ printf(" Type: ");
+ display_type(type, 15);
+ putchar('\n');
+
+ /* Data */
+ memset(&info, 0, sizeof info);
+ info.line_multi_new = 1;
+ if (nelmts<5) {
+ info.idx_fmt = "";
+ info.line_1st = " Data: ";
+ info.line_pre = " ";
+ info.line_cont = " ";
+ info.str_repeat = 8;
+
+ } else {
+ printf(" Data:\n");
+ info.idx_fmt = "(%s)";
+ info.line_pre = " %s ";
+ info.line_cont = " %s ";
+ info.str_repeat = 8;
+ }
+
+ info.line_ncols = width_g;
+ if (label_g) info.cmpd_name = "%s=";
+ if (string_g && 1==H5Tget_size(type) &&
+ H5T_INTEGER==H5Tget_class(type)) {
+ info.ascii = TRUE;
+ info.elmt_suf1 = "";
+ info.elmt_suf2 = "";
+ info.idx_fmt = "(%s)";
+ info.line_pre = " %s \"";
+ info.line_suf = "\"";
+ }
+
+ /* values of type reference */
+ info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
+ info.obj_hidefileno = 0;
+ if (hexdump_g)
+ p_type = H5Tcopy(type);
+ else
+ p_type = h5tools_get_native_type(type);
+
+ if (p_type>=0) {
+ temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
+ assert(temp_need==(hsize_t)((size_t)temp_need));
+ need = (size_t)temp_need;
+ buf = malloc(need);
+ assert(buf);
+ if (H5Aread(attr, p_type, buf)>=0)
+ h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1);
+ free(buf);
+ H5Tclose(p_type);
+ }
+
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Aclose(attr);
} else {
- putchar('\n');
+ putchar('\n');
}
return 0;
@@ -2272,6 +2263,3 @@ main (int argc, const char *argv[])
}
leave(0);
}
-
-
-
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 5908809..a5b6a3f 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -259,7 +259,6 @@ int do_copy_objects(hid_t fidin,
#endif /* LATER */
int i, j;
int wrote=0;
- H5T_class_t type_class; /* datatype class */
/*-------------------------------------------------------------------------
* copy the suppplied object list
@@ -323,15 +322,8 @@ int do_copy_objects(hid_t fidin,
for (j=0; j<rank; j++)
nelmts*=dims[j];
- if((type_class = H5Tget_class(ftype_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype_id=H5Tcopy(ftype_id))<0)
- goto error;
- } else {
- if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
+ goto error;
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
@@ -618,7 +610,6 @@ int copy_attr(hid_t loc_in,
char name[255];
int n, j;
unsigned u;
- H5T_class_t type_class;
if ((n = H5Aget_num_attrs(loc_in))<0)
goto error;
@@ -658,15 +649,8 @@ int copy_attr(hid_t loc_in,
for (j=0; j<rank; j++)
nelmts*=dims[j];
- if((type_class = H5Tget_class(ftype_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype_id=H5Tcopy(ftype_id))<0)
- goto error;
- } else {
- if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
+ goto error;
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 4662341..f093d12 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -22,7 +22,7 @@
static const char* MapIdToName(hid_t refobj_id,
trav_table_t *travt);
-static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id);
+static void close_obj(H5G_obj_t obj_type, hid_t obj_id);
static int copy_refs_attr(hid_t loc_in,
@@ -67,7 +67,6 @@ int do_copy_refobjs(hid_t fidin,
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
int next; /* external files */
int i, j;
- H5T_class_t type_class; /* datatype class */
/*-------------------------------------------------------------------------
* browse
@@ -124,15 +123,8 @@ int do_copy_refobjs(hid_t fidin,
for (j=0; j<rank; j++)
nelmts*=dims[j];
- if((type_class = H5Tget_class(ftype_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype_id=H5Tcopy(ftype_id))<0)
- goto error;
- } else {
- if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
+ goto error;
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
@@ -165,7 +157,7 @@ int do_copy_refobjs(hid_t fidin,
*/
if (H5Tequal(mtype_id, H5T_STD_REF_OBJ))
{
- H5G_obj_t1 obj_type;
+ H5G_obj_t obj_type;
hid_t refobj_id;
hobj_ref_t *refbuf=NULL; /* buffer for object references */
hobj_ref_t *buf=NULL;
@@ -240,7 +232,7 @@ int do_copy_refobjs(hid_t fidin,
*/
else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG))
{
- H5G_obj_t1 obj_type;
+ H5G_obj_t 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 */
@@ -486,7 +478,6 @@ static int copy_refs_attr(hid_t loc_in,
char name[255];
int n, j;
unsigned u;
- H5T_class_t type_class; /* datatype class */
if ((n = H5Aget_num_attrs(loc_in))<0)
goto error;
@@ -527,15 +518,8 @@ static int copy_refs_attr(hid_t loc_in,
for (j=0; j<rank; j++)
nelmts*=dims[j];
- if((type_class = H5Tget_class(ftype_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype_id=H5Tcopy(ftype_id))<0)
- goto error;
- } else {
- if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype_id=h5tools_get_native_type(ftype_id))<0)
+ goto error;
if ((msize=H5Tget_size(mtype_id))==0)
goto error;
@@ -547,7 +531,7 @@ static int copy_refs_attr(hid_t loc_in,
*/
if (H5Tequal(mtype_id, H5T_STD_REF_OBJ))
{
- H5G_obj_t1 obj_type;
+ H5G_obj_t obj_type;
hid_t refobj_id;
hobj_ref_t *refbuf=NULL;
unsigned k;
@@ -624,7 +608,7 @@ static int copy_refs_attr(hid_t loc_in,
*/
else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG))
{
- H5G_obj_t1 obj_type;
+ H5G_obj_t 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 */
@@ -734,7 +718,7 @@ error:
*-------------------------------------------------------------------------
*/
-static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id)
+static void close_obj(H5G_obj_t obj_type, hid_t obj_id)
{
H5E_BEGIN_TRY
{
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
index 2fff656..0e382b9 100644
--- a/tools/lib/Makefile.in
+++ b/tools/lib/Makefile.in
@@ -41,7 +41,7 @@ PROGS=$(PUB_PROGS) $(TEST_PROGS)
## Source and object files for the library; do not install
##
-LIB_SRC=h5tools.c h5tools_str.c h5tools_utils.c h5diff.c h5diff_array.c h5diff_attr.c h5diff_dset.c h5diff_util.c h5trav.c h5trav_table.c h5tools_filters.c h5tools_ref.c
+LIB_SRC=h5tools.c h5tools_str.c h5tools_utils.c h5diff.c h5diff_array.c h5diff_attr.c h5diff_dset.c h5diff_util.c h5trav.c h5trav_table.c h5tools_filters.c h5tools_ref.c h5tools_type.c
LIB_OBJ=$(LIB_SRC:.c=.lo)
PUB_LIB=
AUX_LIB=$(LIB)
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index f5ba995..c271f21 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -412,7 +412,7 @@ hsize_t diff( hid_t file1_id,
hid_t file2_id,
const char *path2,
diff_opt_t *options,
- H5G_obj_t1 type )
+ H5G_obj_t type )
{
hid_t type1_id;
hid_t type2_id;
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 4c56f81..1ef3c87 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -18,9 +18,6 @@
#include "hdf5.h"
#include "h5trav.h"
-typedef H5G_obj_t H5G_obj_t1;
-
-
#if 0
#define H5DIFF_DEBUG
@@ -115,7 +112,7 @@ hsize_t diff( hid_t file1_id,
hid_t file2_id,
const char *path2,
diff_opt_t *options,
- H5G_obj_t1 type );
+ H5G_obj_t type );
hsize_t diff_compare( hid_t file1_id,
const char *file1_name,
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 73a1fbf..0339e47 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -17,7 +17,7 @@
#include "H5private.h"
/* local functions */
-static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id);
+static void close_obj(H5G_obj_t obj_type, hid_t obj_id);
static int diff_region(hid_t region1_id, hid_t region2_id);
static hbool_t is_zero(const void *_mem, size_t size);
@@ -202,8 +202,8 @@ hsize_t diff_datum(void *_mem1,
size_t size;
int iszero1;
int iszero2;
- H5G_obj_t1 obj1_type;
- H5G_obj_t1 obj2_type;
+ H5G_obj_t obj1_type;
+ H5G_obj_t obj2_type;
hid_t obj1_id;
hid_t obj2_id;
H5G_stat_t sb1;
@@ -1659,7 +1659,7 @@ is_zero(const void *_mem, size_t size)
*/
static
-void close_obj(H5G_obj_t1 obj_type, hid_t obj_id)
+void close_obj(H5G_obj_t obj_type, hid_t obj_id)
{
switch (obj_type) {
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 3278bdb..fb4343f 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -12,6 +12,7 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "h5tools.h"
#include "h5diff.h"
#include "H5private.h"
@@ -66,7 +67,6 @@ int diff_attr(hid_t loc1_id,
int ret=0;
hsize_t nfound;
int cmp=1;
- H5T_class_t type_class; /* Datatype class */
if ((n1 = H5Aget_num_attrs(loc1_id))<0)
goto error;
@@ -162,25 +162,11 @@ int diff_attr(hid_t loc1_id,
for (j=0; j<rank1; j++)
nelmts1*=dims1[j];
- if((type_class = H5Tget_class(ftype1_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype1_id=H5Tcopy(ftype1_id))<0)
- goto error;
- } else {
- if ((mtype1_id=H5Tget_native_type(ftype1_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0)
+ goto error;
- if((type_class = H5Tget_class(ftype2_id))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((mtype2_id=H5Tcopy(ftype2_id))<0)
- goto error;
- } else {
- if ((mtype2_id=H5Tget_native_type(ftype2_id,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0)
+ goto error;
if ((msize1=H5Tget_size(mtype1_id))==0)
goto error;
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 767587d..0cc8324 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -155,7 +155,6 @@ hsize_t diff_datasetid( hid_t dset1_id,
hsize_t storage_size1;
hsize_t storage_size2;
hsize_t nfound=0; /* number of differences found */
- H5T_class_t type_class; /* data type class */
int cmp=1; /* do diff or not */
int i;
@@ -267,25 +266,11 @@ hsize_t diff_datasetid( hid_t dset1_id,
* memory type and sizes
*-------------------------------------------------------------------------
*/
- if((type_class = H5Tget_class(f_type1))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((m_type1=H5Tcopy(f_type1))<0)
- goto error;
- } else {
- if ((m_type1=H5Tget_native_type(f_type1,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((m_type1=h5tools_get_native_type(f_type1))<0)
+ goto error;
- if((type_class = H5Tget_class(f_type2))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((m_type2=H5Tcopy(f_type2))<0)
- goto error;
- } else {
- if ((m_type2=H5Tget_native_type(f_type2,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((m_type2=h5tools_get_native_type(f_type2))<0)
+ goto error;
m_size1 = H5Tget_size( m_type1 );
m_size2 = H5Tget_size( m_type2 );
@@ -322,15 +307,8 @@ hsize_t diff_datasetid( hid_t dset1_id,
{
H5Tclose(m_type1);
- if((type_class = H5Tget_class(f_type2))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((m_type1=H5Tcopy(f_type2))<0)
- goto error;
- } else {
- if ((m_type1=H5Tget_native_type(f_type2,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((m_type1=h5tools_get_native_type(f_type2))<0)
+ goto error;
m_size1 = H5Tget_size( m_type1 );
}
@@ -338,15 +316,8 @@ hsize_t diff_datasetid( hid_t dset1_id,
{
H5Tclose(m_type2);
- if((type_class = H5Tget_class(f_type1))<0)
- goto error;
- if(type_class==H5T_BITFIELD) {
- if((m_type2=H5Tcopy(f_type1))<0)
- goto error;
- } else {
- if ((m_type2=H5Tget_native_type(f_type1,H5T_DIR_DEFAULT))<0)
- goto error;
- }
+ if ((m_type2=h5tools_get_native_type(f_type1))<0)
+ goto error;
m_size2 = H5Tget_size( m_type2 );
}
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index d3a2d7a..dd96aa7 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -43,8 +43,6 @@
#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
-
-
/* global variables */
int indent;
int compound_data;
@@ -1137,15 +1135,8 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type,
if (info->raw)
p_type = H5Tcopy(f_type);
- else {
- H5T_class_t type_class;
-
- type_class = H5Tget_class(f_type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(f_type);
- else
- p_type = H5Tget_native_type(f_type,H5T_DIR_DEFAULT);
- }
+ else
+ p_type = h5tools_get_native_type(f_type);
H5Tclose(f_type);
@@ -1219,3 +1210,4 @@ h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type,
return h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem,
indentlevel);
}
+
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 7837a5e..f5731a0 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -315,10 +315,10 @@ typedef struct h5dump_t {
const char *dset_ptformat_pre;
const char *dset_ptformat;
- /*print array indices in output matrix */
+ /*print array indices in output matrix */
int pindex;
- /*escape non printable characters */
+ /*escape non printable characters */
int do_escape;
} h5dump_t;
@@ -473,7 +473,6 @@ extern FILE *rawdatastream; /*output stream for raw data */
#define STRSIZE "STRSIZE"
#define STRPAD "STRPAD"
#define SUBSET "SUBSET"
-
#define FILTERS "FILTERS"
#define DEFLATE "COMPRESSION DEFLATE"
#define DEFLATE_LEVEL "LEVEL"
@@ -502,6 +501,7 @@ extern int h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset
hid_t p_typ, struct subset_t *sset, int indentlevel);
extern int h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
hid_t type, hid_t space, void *mem, int indentlevel);
+extern hid_t h5tools_get_native_type(hid_t type);
extern void h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index 5315fd4..368283f 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -1,5 +1,3 @@
-
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 3350f51..f5a1690 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -28,8 +28,6 @@
#include "h5tools_str.h" /*function prototypes */
#include "h5tools_ref.h"
-
-
/*
* If REPEAT_VERBOSE is defined then character strings will be printed so
* that repeated character sequences like "AAAAAAAAAA" are displayed as
@@ -931,7 +929,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
}
-
for (x = 0; x < ctx->indent_level + 1; x++)
h5tools_str_append(str,"%s",OPT(info->line_indent,""));
} /* end if */
diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c
new file mode 100644
index 0000000..53a3505
--- /dev/null
+++ b/tools/lib/h5tools_type.c
@@ -0,0 +1,47 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include "h5tools.h"
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_get_native_type
+ *
+ * Purpose: Wrapper around H5Tget_native_type() to work around
+ * Problems with bitfields.
+ *
+ * Return: Success: datatype ID
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, October 5, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5tools_get_native_type(hid_t type)
+{
+ hid_t p_type;
+ H5T_class_t type_class;
+
+ type_class = H5Tget_class(type);
+ if(type_class==H5T_BITFIELD)
+ p_type=H5Tcopy(type);
+ else
+ p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
+
+ return(p_type);
+}
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 93211c5..8094c33 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -25,7 +25,7 @@ int traverse( hid_t loc_id,
int print);
herr_t get_nnames( hid_t loc_id,
- const char *group_name );
+ const char *group_name );
herr_t get_name_type( hid_t loc_id,
const char *group_name,
@@ -322,14 +322,12 @@ int traverse( hid_t loc_id,
int inserted_objs=0;
int i, j;
-
/* get the number of names */
if (( n_names = get_nnames( loc_id, group_name )) < 0 )
return -1;
for ( i = 0; i < n_names; i++)
{
-
if (get_name_type( loc_id, group_name, i, &name, &type ) < 0 )
return -1;
@@ -407,7 +405,6 @@ int traverse( hid_t loc_id,
}
-
break;
/*-------------------------------------------------------------------------
@@ -512,7 +509,6 @@ int traverse( hid_t loc_id,
break;
-
default:
break;
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 671e17c..e8e8a3f 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -27,9 +27,9 @@
* the TYPE can be:
* H5G_UNKNOWN = -1,
* H5G_LINK, Object is a symbolic link
- * H5G_GROUP, Object is a group
- * H5G_DATASET, Object is a dataset
- * H5G_TYPE, Object is a named data type
+ * H5G_GROUP, Object is a group
+ * H5G_DATASET, Object is a dataset
+ * H5G_TYPE, Object is a named data type
*-------------------------------------------------------------------------
*/
diff --git a/tools/lib/talign.c b/tools/lib/talign.c
index 082e37e..bb9f96e 100644
--- a/tools/lib/talign.c
+++ b/tools/lib/talign.c
@@ -29,7 +29,6 @@ int main(void)
hsize_t dim[2];
hsize_t cdim[4];
- H5T_class_t type_class;
char string5[5];
float fok[2] = {1234., 2341.};
@@ -73,11 +72,7 @@ int main(void)
H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
H5Tclose(array_dt);
- type_class = H5Tget_class(cmp);
- if(type_class==H5T_BITFIELD)
- fix=H5Tcopy(cmp);
- else
- fix=H5Tget_native_type(cmp, H5T_DIR_DEFAULT);
+ fix=h5tools_get_native_type(cmp);
cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));