diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-01-23 20:48:45 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-01-23 20:48:45 (GMT) |
commit | 615a1fc7ec94b1c2f23fe3595033181afbf5a9e3 (patch) | |
tree | 6bc13879c04b7e71f2b45b7670ad150a9b3dfffa | |
parent | 313102f942252d948f5eb0e9b2246f295b3b9c76 (diff) | |
download | hdf5-615a1fc7ec94b1c2f23fe3595033181afbf5a9e3.zip hdf5-615a1fc7ec94b1c2f23fe3595033181afbf5a9e3.tar.gz hdf5-615a1fc7ec94b1c2f23fe3595033181afbf5a9e3.tar.bz2 |
[svn-r11888] Purpose:
Code cleanup
Description:
Check in some of the code cleanups from working on the external link
support. (This doesn't include any of the external link features)
Platforms tested:
FreeBSD 4.11 (sleipnir)
Mac OSX.4 (amazon)
Linux 2.4
39 files changed, 2730 insertions, 2842 deletions
@@ -1512,6 +1512,7 @@ ./tools/h5repack/h5repack_parse.c ./tools/h5repack/h5repack_refs.c ./tools/h5repack/h5repack_verify.c +./tools/h5repack/testh5repack.h ./tools/h5repack/testh5repack_attr.c ./tools/h5repack/testh5repack_dset.c ./tools/h5repack/testh5repack_main.c diff --git a/perform/perf.c b/perform/perf.c index 8f5d096..0f47bee 100644 --- a/perform/perf.c +++ b/perform/perf.c @@ -460,7 +460,7 @@ double Wtime() #else /* H5_HAVE_PARALLEL */ /* dummy program since H5_HAVE_PARALLE is not configured in */ int -main() +main(int UNUSED argc, char UNUSED **argv) { printf("No parallel performance because parallel is not configured in\n"); return(0); diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 03796f3..1c46b29 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -609,11 +609,11 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, /* Check if we are doing any logging at all */ if(file->fa.flags!=0) { file->iosize=fa->buf_size; - if(file->fa.flags&H5FD_LOG_NUM_READ) { + if(file->fa.flags&H5FD_LOG_FILE_READ) { file->nread=H5MM_calloc(file->iosize); assert(file->nread); } /* end if */ - if(file->fa.flags&H5FD_LOG_NUM_WRITE) { + if(file->fa.flags&H5FD_LOG_FILE_WRITE) { file->nwrite=H5MM_calloc(file->iosize); assert(file->nwrite); } /* end if */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 7ca5045..a2e676e 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -170,7 +170,7 @@ H5G_build_fullpath(const char *prefix, const char *name) path_len += HDstrlen(name) + need_sep; /* Allocate space for the path */ - if(NULL == (full_path = H5FL_BLK_MALLOC(str_buf, path_len + 1))) + if(NULL == (full_path = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build full path */ @@ -369,7 +369,7 @@ H5G_get_name(hid_t id, char *name/*out*/, size_t size) if(name) { HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len + 1, size)); if(len >= size) - name[size-1]='\0'; + name[size-1] = '\0'; } /* end if */ } /* end if */ } /* end if */ @@ -494,7 +494,7 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char /* Allocate space for the new path */ new_path_len = path_prefix2_len + HDstrlen(dst_suffix) + full_suffix_len; - if(NULL == (new_path = H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) + if(NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new path */ @@ -620,7 +620,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Allocate space for the new full path */ new_full_len = HDstrlen(src_path) + HDstrlen(full_path); - if(NULL == (new_full_path = H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ @@ -666,7 +666,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Build new full path */ /* Create the new full path */ - if(NULL == (new_full_path = H5FL_BLK_MALLOC(str_buf, HDstrlen(full_suffix) + 1))) + if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, HDstrlen(full_suffix) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(new_full_path, full_suffix); @@ -752,7 +752,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Allocate space for the new full path */ new_full_len = HDstrlen(dst_path) + HDstrlen(full_suffix); - if(NULL == (new_full_path = H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 0bbf21e..f41e55e 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -317,14 +317,11 @@ done: * Programmer: Robb Matzke * Thursday, April 2, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t -H5O_shared_size (const H5F_t *f, const void *_mesg) +H5O_shared_size (const H5F_t *f, const void UNUSED *_mesg) { - const H5O_shared_t *shared = (const H5O_shared_t *) _mesg; size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size); @@ -62,17 +62,17 @@ H5RS_xstrdup(const char *s) { char *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5RS_xstrdup); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5RS_xstrdup) - if (s) { - ret_value = H5FL_BLK_MALLOC(str_buf,HDstrlen(s) + 1); - assert (ret_value); + if(s) { + ret_value = (char *)H5FL_BLK_MALLOC(str_buf, HDstrlen(s) + 1); + HDassert(ret_value); HDstrcpy(ret_value, s); } /* end if */ else - ret_value=NULL; + ret_value = NULL; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_xstrdup() */ @@ -147,7 +147,7 @@ H5RS_wrap(const char *s) HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ - ret_value->s=(char*)s; + ret_value->s=(char*)s; /* (Cast away const OK - QAK) */ ret_value->wrapped=1; ret_value->n=1; @@ -160,7 +160,7 @@ done: NAME H5RS_own PURPOSE - Transfer ownership of a regular string to a reference counted string + Transfer ownership of a regular string to a reference counted string USAGE H5RS_str_t *H5RS_own(s) const char *s; IN: String to transfer ownership of @@ -286,7 +286,7 @@ H5RS_incr(H5RS_str_t *rs) PURPOSE "Duplicate" a ref-counted string USAGE - H5RS_str_t H5RS_incr(rs) + H5RS_str_t H5RS_dup(rs) H5RS_str_t *rs; IN/OUT: Ref-counted string to "duplicate" RETURNS diff --git a/src/H5detect.c b/src/H5detect.c index d5af70c..4b15c36 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -520,10 +520,6 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) #include \"H5FLprivate.h\"\n\ #include \"H5Tpkg.h\"\n\ \n\ -/* Declare external the free lists for H5T_t's and H5T_shared_t's */\n\ -H5FL_EXTERN(H5T_t);\n\ -H5FL_EXTERN(H5T_shared_t);\n\ -\n\ \n"); /* The interface initialization function */ diff --git a/test/dsets.c b/test/dsets.c index b5cace3..8c62dcd 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1306,7 +1306,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ void *tconv_buf = NULL; /* Temporary conversion buffer */ - int i, j, n; /* Local index variables */ + hsize_t i, j, n; /* Local index variables */ herr_t status; /* Error status */ /* Create the data space */ @@ -2161,7 +2161,7 @@ test_missing_filter(hid_t file) const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ hsize_t dset_size; /* Dataset size */ - int i,j; /* Local index variables */ + hsize_t i,j; /* Local index variables */ herr_t ret; /* Generic return value */ char testfile[512]=""; /* Buffer to hold name of existing test file */ char *srcdir = HDgetenv("srcdir"); /* The source directory, if we are using the --srcdir configure option */ @@ -2413,7 +2413,7 @@ test_onebyte_shuffle(hid_t file) const hsize_t chunk_size[2] = {10, 20}; unsigned char orig_data[10][20]; unsigned char new_data[10][20]; - int i, j; + hsize_t i, j; #else /* H5_HAVE_FILTER_SHUFFLE */ const char *not_supported= " Data shuffling is not enabled."; #endif /* H5_HAVE_FILTER_SHUFFLE */ @@ -2675,7 +2675,7 @@ test_types(hid_t file) #ifndef H5_WANT_H5_V1_4_COMPAT /* This message derives from H5Z */ -const H5Z_class_t H5Z_CAN_APPLY[1] = {{ +const H5Z_class_t H5Z_CAN_APPLY_TEST[1] = {{ H5Z_FILTER_BOGUS, /* Filter id number */ "bogus", /* Filter name for debugging */ can_apply_bogus, /* The "can apply" callback */ @@ -2707,7 +2707,7 @@ test_can_apply(hid_t file) const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ hsize_t dset_size; /* Dataset size */ - int i,j; /* Local index variables */ + hsize_t i,j; /* Local index variables */ TESTING("dataset filter 'can apply' callback"); @@ -2722,7 +2722,7 @@ test_can_apply(hid_t file) printf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ - if(H5Zregister (H5Z_CAN_APPLY)<0) { + if(H5Zregister (H5Z_CAN_APPLY_TEST)<0) { H5_FAILED(); printf(" Line %d: Can't register 'can apply' filter\n",__LINE__); goto error; @@ -3034,7 +3034,7 @@ error: #ifndef H5_WANT_H5_V1_4_COMPAT /* This message derives from H5Z */ -const H5Z_class_t H5Z_SET_LOCAL[1] = {{ +const H5Z_class_t H5Z_SET_LOCAL_TEST[1] = {{ H5Z_FILTER_BOGUS2, /* Filter id number */ "bogus2", /* Filter name for debugging */ NULL, /* The "can apply" callback */ @@ -3068,7 +3068,7 @@ test_set_local(hid_t fapl) const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ hsize_t dset_size; /* Dataset size */ unsigned cd_values[2]={BOGUS2_PARAM_1, BOGUS2_PARAM_2}; /* Parameters for Bogus2 filter */ - int i,j; /* Local index variables */ + hsize_t i,j; /* Local index variables */ double n; /* Local index variables */ TESTING("dataset filter 'set local' callback"); @@ -3101,7 +3101,7 @@ test_set_local(hid_t fapl) printf(" Line %d: Can't set chunk sizes\n",__LINE__); goto error; } /* end if */ - if(H5Zregister (H5Z_SET_LOCAL)<0) { + if(H5Zregister (H5Z_SET_LOCAL_TEST)<0) { H5_FAILED(); printf(" Line %d: Can't register 'set local' filter\n",__LINE__); goto error; diff --git a/test/trefstr.c b/test/trefstr.c index 8073c3f..979a184 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -299,7 +299,7 @@ test_refstr_own(void) MESSAGE(5, ("Testing Transferring Ref-Counted Strings\n")); /* Initialize buffer */ - s = H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); + s = (char *)H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); HDstrcpy(s, "foo"); /* Transfer ownership of dynamically allocated string to ref-counted string */ diff --git a/test/unlink.c b/test/unlink.c index f031e0c..7c8b5d6 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -248,8 +248,6 @@ test_many(hid_t file) * Programmer: Robb Matzke * Friday, September 25, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static int @@ -260,12 +258,12 @@ test_symlink(hid_t file) TESTING("symlink removal"); /* Create a test group and symlink */ - if ((work=H5Gcreate(file, "/test_symlink", 0))<0) goto error; - if (H5Glink(work, H5G_LINK_SOFT, "link_value", "link")<0) goto error; - if (H5Gunlink(work, "link")<0) goto error; + if ((work=H5Gcreate(file, "/test_symlink", 0))<0) TEST_ERROR; + if (H5Glink(work, H5G_LINK_SOFT, "link_value", "link")<0) TEST_ERROR; + if (H5Gunlink(work, "link")<0) TEST_ERROR; /* Cleanup */ - if (H5Gclose(work)<0) goto error; + if (H5Gclose(work)<0) TEST_ERROR; PASSED(); return 0; @@ -529,7 +527,7 @@ test_filespace(void) hsize_t dims[FILESPACE_NDIMS]= {FILESPACE_DIM0, FILESPACE_DIM1, FILESPACE_DIM2}; /* Dataset dimensions */ hsize_t chunk_dims[FILESPACE_NDIMS]= {FILESPACE_CHUNK0, FILESPACE_CHUNK1, FILESPACE_CHUNK2}; /* Chunk dimensions */ hsize_t attr_dims[FILESPACE_ATTR_NDIMS]= {FILESPACE_ATTR_DIM0, FILESPACE_ATTR_DIM1}; /* Attribute dimensions */ - int *data; /* Pointer to dataset buffer */ + int *data = NULL; /* Pointer to dataset buffer */ int *tmp_data; /* Temporary pointer to dataset buffer */ off_t empty_size; /* Size of an empty file */ off_t file_size; /* Size of each file created */ @@ -1231,6 +1229,10 @@ test_filespace(void) return 0; error: + /* Release dataset buffer */ + if(data) + HDfree(data); + return 1; } /* end test_filespace() */ @@ -1505,7 +1507,7 @@ test_unlink_rightleaf(hid_t fid) ngroups = 150; /* Number of groups to create */ char name[256]; /* Name of object to create */ - TESTING("Deleting right-most child in non-leaf B-tree node"); + TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ gids = (hid_t *) HDmalloc (ngroups * sizeof(hid_t)); @@ -1530,6 +1532,9 @@ test_unlink_rightleaf(hid_t fid) for (n = 0; n < ngroups; n++) if(H5Gclose(gids[n])<0) TEST_ERROR; + /* Close root group ID */ + if(H5Gclose(rootid)<0) TEST_ERROR; + /* Free memory */ HDfree(gids); @@ -1566,7 +1571,7 @@ test_unlink_rightnode(hid_t fid) ngroups = 150; /* Number of groups to create */ char name[256]; /* Name of object to create */ - TESTING("Deleting right-most child in non-leaf B-tree node"); + TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ gids = (hid_t *) HDmalloc (ngroups * sizeof(hid_t)); @@ -1591,6 +1596,9 @@ test_unlink_rightnode(hid_t fid) if(H5Gunlink(fid,"/ZoneB8")<0) TEST_ERROR; if(H5Gunlink(fid,"/ZoneB80")<0) TEST_ERROR; + /* Close root group ID */ + if(H5Gclose(rootid)<0) TEST_ERROR; + /* Free memory */ HDfree(gids); @@ -1627,7 +1635,7 @@ test_unlink_middlenode(hid_t fid) ngroups = 250; /* Number of groups to create */ char name[256]; /* Name of object to create */ - TESTING("Deleting right-most child in non-leaf B-tree node"); + TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ gids = (hid_t *) HDmalloc (ngroups * sizeof(hid_t)); @@ -1795,6 +1803,9 @@ test_unlink_middlenode(hid_t fid) if(H5Gunlink(fid,"/ZoneC8")<0) TEST_ERROR; if(H5Gunlink(fid,"/ZoneC80")<0) TEST_ERROR; + /* Close root group ID */ + if(H5Gclose(rootid)<0) TEST_ERROR; + /* Free memory */ HDfree(gids); @@ -1828,7 +1839,7 @@ test_resurrect_dataset(void) hid_t f=-1, s=-1, d=-1, fapl=-1; char filename[1024]; - TESTING("Resurrecting dataset after deletion"); + TESTING("resurrecting dataset after deletion"); /* Create file */ fapl = h5_fileaccess(); @@ -1902,7 +1913,7 @@ test_resurrect_datatype(void) hid_t file=-1, type=-1, fapl=-1; char filename[1024]; - TESTING("Resurrecting datatype after deletion"); + TESTING("resurrecting datatype after deletion"); /* Create file */ fapl = h5_fileaccess(); @@ -1972,7 +1983,7 @@ test_resurrect_group(void) hid_t file=-1, group=-1, fapl=-1; char filename[1024]; - TESTING("Resurrecting group after deletion"); + TESTING("resurrecting group after deletion"); /* Create file */ fapl = h5_fileaccess(); @@ -2047,11 +2058,11 @@ test_unlink_chunked_dataset(void) hsize_t chunk_dims[FILESPACE_NDIMS]={FILESPACE_CHUNK0,FILESPACE_CHUNK1,FILESPACE_CHUNK2}; char filename[1024]; - TESTING("Unlinking chunked dataset"); + TESTING("unlinking chunked dataset"); /* Create file */ fapl_id = h5_fileaccess(); - h5_fixname(FILENAME[7], fapl_id, filename, sizeof filename); + h5_fixname(FILENAME[9], fapl_id, filename, sizeof filename); /* Create the file */ if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id))<0) TEST_ERROR; @@ -2084,7 +2095,7 @@ test_unlink_chunked_dataset(void) if(H5Fclose(file_id)<0) TEST_ERROR; /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT))<0) TEST_ERROR; + if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id))<0) TEST_ERROR; /* Delete the dataset */ if(H5Gunlink(file_id, DATASETNAME)<0) TEST_ERROR; @@ -2196,6 +2207,7 @@ main(void) nerrors += test_unlink_chunked_dataset(); /* Close */ + if (H5Pclose(fapl2)<0) TEST_ERROR; if (H5Fclose(file)<0) TEST_ERROR; if (nerrors) { printf("***** %d FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index dc75ea2..c99fd11 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -59,7 +59,7 @@ static char *prefix; static const char *driver = NULL; /* The driver to open the file with. */ -static const dump_header *dump_header_format; +static const h5dump_header_t *dump_header_format; /* things to display or which are set via command line parameters */ static int display_all = TRUE; @@ -86,21 +86,20 @@ static int doxml = 0; static int useschema = 1; static const char *xml_dtd_uri = NULL; static const char *xmlnsprefix="hdf5:"; +static int indent; /*how far in to indent the line */ /** end XML **/ /* internal functions */ -static hid_t h5_fileaccess(void); -static void dump_oid(hid_t oid); -static void print_enum(hid_t type); -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 ); -static void init_prefix(char **prfx, size_t prfx_len); - -static h5dump_t dataformat = { +static hid_t h5_fileaccess(void); +static void dump_oid(hid_t oid); +static void print_enum(hid_t type); +static herr_t dump_all(hid_t group, const char *name, void *op_data); +static int xml_name_to_XID(const char *, char *, int , int ); +static void init_prefix(char **prfx, size_t prfx_len); +static void add_prefix(char **prfx, size_t *prfx_len, const char *name); + +static h5tool_format_t dataformat = { 0, /*raw */ "", /*fmt_raw */ @@ -184,7 +183,7 @@ static h5dump_t dataformat = { * * This table only affects XML output. */ -static h5dump_t xml_dataformat = { +static h5tool_format_t xml_dataformat = { 0, /*raw */ "", /*fmt_raw */ @@ -255,13 +254,13 @@ static h5dump_t xml_dataformat = { /** XML **/ -static const dump_header standardformat = { +static const h5dump_header_t standardformat = { "standardformat", /*name */ "HDF5", /*fileebgin */ "", /*fileend */ SUPER_BLOCK, /*bootblockbegin */ "", /*bootblockend */ - GROUPNAME, /*groupbegin */ + GROUP, /*groupbegin */ "", /*groupend */ DATASET, /*datasetbegin */ "", /*datasetend */ @@ -1337,244 +1336,263 @@ static herr_t dump_all(hid_t group, const char *name, void * op_data) { hid_t obj; - char *targbuf, *tmp = NULL; + char *obj_path = NULL; /* Full path of object */ H5G_stat_t statbuf; herr_t ret = SUCCEED; - H5Gget_objinfo(group, name, FALSE, &statbuf); + /* Stat the object */ + if(H5Gget_objinfo(group, name, FALSE, &statbuf) < 0) { + error_msg(progname, "unable to get object information\n"); + d_status = EXIT_FAILURE; + ret = FAIL; + goto done; + } /* end if */ if (*(int *)op_data != H5G_UNKNOWN && statbuf.type != *(int *) op_data) goto done; - tmp = malloc(strlen(prefix) + strlen(name) + 2); - strcpy(tmp, prefix); + /* Build the object's path name */ + obj_path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDassert(obj_path); + HDstrcpy(obj_path, prefix); + HDstrcat(obj_path, "/"); + HDstrcat(obj_path, name); switch (statbuf.type) { - case H5G_LINK: - indentation(indent); - targbuf = malloc(statbuf.linklen); + case H5G_LINK: + { + char *targbuf; - if (!doxml) { - begin_obj(dump_header_format->softlinkbegin, name, - dump_header_format->softlinkblockbegin); - indentation(indent + COL); - } + indentation(indent); + targbuf = HDmalloc(statbuf.linklen); + HDassert(targbuf); - if (H5Gget_linkval(group, name, statbuf.linklen, targbuf) < 0) { - error_msg(progname, "unable to get link value\n"); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - /* print the value of a soft link */ - if (!doxml) { - /* Standard DDL: no modification */ - printf("LINKTARGET \"%s\"\n", targbuf); - } else { - /* XML */ - char *linkxid = malloc(100); - char *parentxid = malloc(100); - char *targetxid = malloc(100); - char *t_prefix = xml_escape_the_name(strcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_targbuf = xml_escape_the_name(targbuf); - char *tmp2, *t_tmp; - int res; - - tmp2 = malloc(strlen(prefix) + statbuf.linklen + 1); - strcpy(tmp2, prefix); - - if (targbuf && targbuf[0] == '/') - strcpy(tmp2, targbuf); - else - strcat(strcat(tmp2, "/"), targbuf); - - t_tmp = xml_escape_the_name(strcat(strcat(tmp, "/"), name)); - xml_name_to_XID(t_tmp,linkxid,100,1); - xml_name_to_XID(prefix,parentxid,100,1); - - res = xml_name_to_XID(tmp2,targetxid,100,0); - - if (res == 0) { - /* target obj found */ - printf("<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " + if (!doxml) { + begin_obj(dump_header_format->softlinkbegin, name, + dump_header_format->softlinkblockbegin); + indentation(indent + COL); + } + + if (H5Gget_linkval(group, name, statbuf.linklen, targbuf) < 0) { + error_msg(progname, "unable to get link value\n"); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + /* print the value of a soft link */ + if (!doxml) { + /* Standard DDL: no modification */ + printf("LINKTARGET \"%s\"\n", targbuf); + } else { + /* XML */ + char linkxid[100]; + char parentxid[100]; + char targetxid[100]; + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char *t_targbuf = xml_escape_the_name(targbuf); + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_link_path; + int res; + + t_link_path = HDmalloc(HDstrlen(prefix) + statbuf.linklen + 1); + if(targbuf[0] == '/') + HDstrcpy(t_link_path, targbuf); + else { + HDstrcpy(t_link_path, prefix); + HDstrcat(HDstrcat(t_link_path, "/"), targbuf); + } /* end else */ + + /* 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); + + /* Try to create an OBJ-XID for the object pointed to */ + res = xml_name_to_XID(t_link_path, targetxid, sizeof(targetxid), 0); + if (res == 0) { + /* target obj found */ + printf("<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " "TargetPath=\"%s\" TargetObj=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, - linkxid, - t_tmp, - t_targbuf, targetxid, - parentxid, t_prefix); - free(targetxid); - } else { - /* dangling link -- omit from xml attributes */ - printf("<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + targetxid, /* TargetObj */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + } else { + /* dangling link -- omit from xml attributes */ + printf("<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, - linkxid, - t_tmp, - t_targbuf, - parentxid, t_prefix); - } + "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + } - free(t_name); - free(t_targbuf); - free(t_tmp); - free(tmp2); - free(linkxid); - free(parentxid); - } - } + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_targbuf); + HDfree(t_obj_path); + HDfree(t_link_path); + } + } - if (!doxml) { - indentation(indent); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); - } + if (!doxml) { + indentation(indent); + end_obj(dump_header_format->softlinkend, + dump_header_format->softlinkblockend); + } - free(targbuf); - break; + HDfree(targbuf); + break; + } - case H5G_GROUP: - if ((obj = H5Gopen(group, name)) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - size_t new_len = strlen(prefix) + strlen(name) + 2; + case H5G_GROUP: + if ((obj = H5Gopen(group, name)) < 0) { + error_msg(progname, "unable to dump group \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + char *old_prefix; /* Pointer to previous prefix */ - if (prefix_len <= new_len) { - prefix_len = new_len + 1; - prefix = realloc(prefix, prefix_len); - } + /* Keep copy of prefix before iterating into group */ + old_prefix = HDstrdup(prefix); + HDassert(old_prefix); - strcat(strcat(prefix, "/"), name); - dump_function_table->dump_group_function(obj, name); - strcpy(prefix, tmp); - H5Gclose(obj); - } + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - break; + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - case H5G_DATASET: - if ((obj = H5Dopen(group, name)) >= 0) { - /* hard link */ - H5Gget_objinfo(obj, ".", TRUE, &statbuf); + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); - if (statbuf.nlink > 1) { - obj_t *found_obj; /* Found object */ + /* Close group */ + H5Gclose(obj); + } - found_obj = search_obj(dset_table, statbuf.objno); + break; - if (found_obj == NULL) { - indentation(indent); - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); - indentation(indent + COL); - error_msg(progname, - "internal error (file %s:line %d)\n", - __FILE__, __LINE__); - indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); - d_status = EXIT_FAILURE; - ret = FAIL; - H5Dclose(obj); - goto done; - } else if (found_obj->displayed) { - indentation(indent); + case H5G_DATASET: + if ((obj = H5Dopen(group, name)) >= 0) { + /* hard link */ + H5Gget_objinfo(obj, ".", TRUE, &statbuf); + + if (statbuf.nlink > 1) { + obj_t *found_obj; /* Found object */ + + found_obj = search_obj(dset_table, statbuf.objno); + + if (found_obj == NULL) { + indentation(indent); + begin_obj(dump_header_format->datasetbegin, name, + dump_header_format->datasetblockbegin); + indentation(indent + COL); + error_msg(progname, + "internal error (file %s:line %d)\n", + __FILE__, __LINE__); + indentation(indent); + end_obj(dump_header_format->datasetend, + dump_header_format->datasetblockend); + d_status = EXIT_FAILURE; + ret = FAIL; + H5Dclose(obj); + goto done; + } else if (found_obj->displayed) { + indentation(indent); + + if (!doxml) { + begin_obj(dump_header_format->datasetbegin, name, + dump_header_format->datasetblockbegin); + indentation(indent + COL); + printf("%s \"%s\"\n", HARDLINK, found_obj->objname); + indentation(indent); + end_obj(dump_header_format->datasetend, + dump_header_format->datasetblockend); + } else { + /* the XML version */ + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char dsetxid[100]; + char parentxid[100]; + char pointerxid[100]; + + /* Create OBJ-XIDs for the parent and object */ + xml_name_to_XID(obj_path, dsetxid, sizeof(dsetxid), 1); + xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); + + printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " + "H5Path=\"%s\" Parents=\"%s\" " + "H5ParentPaths=\"%s\">\n", + xmlnsprefix, + t_name, /* Dataset Name */ + dsetxid, get_next_xid(), /* OBJ-XID */ + t_obj_path, /* H5Path */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + + indentation(indent + COL); + xml_name_to_XID(found_obj->objname, pointerxid, sizeof(pointerxid), 1); + printf("<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", + xmlnsprefix, + pointerxid,t_obj_path); + indentation(indent); + printf("</%sDataset>\n", xmlnsprefix); + + HDfree(t_name); + HDfree(t_obj_path); + HDfree(t_prefix); + } - if (!doxml) { - begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); - indentation(indent + COL); - printf("%s \"%s\"\n", HARDLINK, found_obj->objname); - indentation(indent); - end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); - } else { - /* the XML version */ - char *t_tmp; - char *t_prefix; - char *t_name; - char *dsetxid = malloc(100); - char *parentxid = malloc(100); - char *pointerxid = malloc(100); - char *tx_tmp = malloc(strlen(tmp)+strlen(name)+1); - strcpy(tx_tmp,tmp); - t_tmp = xml_escape_the_name(strcat(strcat(tx_tmp, "/"), name)); - t_prefix = xml_escape_the_name(prefix); - t_name = xml_escape_the_name(name); - xml_name_to_XID( strcat(strcat(tmp,"/"),name), dsetxid,100,1); - xml_name_to_XID( prefix ,parentxid,100,1); - - printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " - "H5Path=\"%s\" Parents=\"%s\" " - "H5ParentPaths=\"%s\">\n", - xmlnsprefix, - t_name, dsetxid, get_next_xid(), - t_tmp, parentxid, - (strcmp(prefix, "") ? t_prefix : "/")); - - indentation(indent + COL); - xml_name_to_XID(found_obj->objname,pointerxid,100,1); - printf("<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", - xmlnsprefix, - pointerxid,t_tmp); - indentation(indent); - printf("</%sDataset>\n", xmlnsprefix); - - free(t_name); - free(dsetxid); - free(parentxid); - free(pointerxid); - free(t_tmp); - free(tx_tmp); - free(t_prefix); - } - - H5Dclose(obj); - goto done; - } else { - found_obj->displayed = TRUE; + H5Dclose(obj); + goto done; + } else { + found_obj->displayed = TRUE; + } + } /* end if */ - } - } + dump_function_table->dump_dataset_function(obj, name, NULL); + H5Dclose(obj); + } else { + error_msg(progname, "unable to dump dataset \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } + break; - dump_function_table->dump_dataset_function(obj, name, NULL); - H5Dclose(obj); - } else { - error_msg(progname, "unable to dump dataset \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } - break; + case H5G_TYPE: + if ((obj = H5Topen(group, name)) < 0) { + error_msg(progname, "unable to dump data type \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + dump_function_table->dump_named_datatype_function(obj, name); + H5Tclose(obj); + } + break; - case H5G_TYPE: - if ((obj = H5Topen(group, name)) < 0) { - error_msg(progname, "unable to dump data type \"%s\"\n", name); - d_status = EXIT_FAILURE; + default: + error_msg(progname, "unknown object \"%s\"\n", name); + d_status = EXIT_FAILURE; ret = FAIL; - } else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; - - default: - error_msg(progname, "unknown object \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; } done: - free(tmp); + if(obj_path) + HDfree(obj_path); return ret; } @@ -1632,19 +1650,19 @@ dump_group(hid_t gid, const char *name) char type_name[1024], *tmp; int xtype = H5G_UNKNOWN; /* dump all */ - tmp = malloc(strlen(prefix) + strlen(name) + 2); - strcpy(tmp, prefix); + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); indentation(indent); begin_obj(dump_header_format->groupbegin, name, dump_header_format->groupblockbegin); indent += COL; if (display_oid) - dump_oid(gid); + dump_oid(gid); dump_comment(gid); - if (!strcmp(name, "/") && unamedtype) { + if (!HDstrcmp(name, "/") && unamedtype) { unsigned u; /* Local index variable */ /* dump unamed type in root group */ @@ -1730,33 +1748,33 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) dump_dataspace(space); if (display_oid) - dump_oid(did); + dump_oid(did); if (display_dcpl) - dump_dcpl(dcpl_id, type, did); + dump_dcpl(dcpl_id, type, did); if (display_data) switch (H5Tget_class(type)) { - case H5T_TIME: - indentation(indent + COL); - printf("DATA{ not yet implemented.}\n"); - break; + case H5T_TIME: + indentation(indent + COL); + printf("DATA{ not yet implemented.}\n"); + break; - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - dump_data(did, DATASET_DATA, sset, display_ai); - break; + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + dump_data(did, DATASET_DATA, sset, display_ai); + break; - default: - break; + default: + break; } indent += COL; @@ -1787,7 +1805,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) static void dump_dims(hsize_t *s, int dims) { - register int i; + int i; for (i = 0; i < dims; i++) { printf("%u", (unsigned int)s[i]); @@ -1876,7 +1894,7 @@ dump_subsetting_header(struct subset_t *sset, int dims) static void dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) { - h5dump_t *outputformat = &dataformat; + h5tool_format_t *outputformat = &dataformat; int status = -1; void *buf; hid_t space, type, p_type; @@ -1890,12 +1908,11 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) outputformat->do_escape=display_escape; /* print the matrix indices */ outputformat->pindex=pindex; - if (outputformat->pindex) - { - outputformat->idx_fmt = "(%s): "; - outputformat->idx_n_fmt = "%lu"; - outputformat->idx_sep = ","; - outputformat->line_pre = "%s"; + if (outputformat->pindex) { + outputformat->idx_fmt = "(%s): "; + outputformat->idx_n_fmt = "%lu"; + outputformat->idx_sep = ","; + outputformat->line_pre = "%s"; } indent += COL; @@ -1926,7 +1943,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) if (obj_data == DATASET_DATA) { hid_t f_type = H5Dget_type(obj_id); char string_prefix[64]; - h5dump_t string_dataformat; + h5tool_format_t string_dataformat; if (display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) { /* @@ -1966,7 +1983,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) status = SUCCEED; } else { char string_prefix[64]; - h5dump_t string_dataformat; + h5tool_format_t string_dataformat; type = H5Aget_type(obj_id); p_type = h5tools_get_native_type(type); @@ -2074,15 +2091,15 @@ dump_oid(hid_t oid) static void dump_comment(hid_t obj_id) { - char comment[50]; + char comment[50]; - comment[0] = '\0'; - H5Gget_comment(obj_id, ".", sizeof(comment), comment); + comment[0] = '\0'; + H5Gget_comment(obj_id, ".", sizeof(comment), comment); - if (comment[0]) { - indentation(indent); - printf("COMMENT \"%s\"\n", comment); - } + if (comment[0]) { + indentation(indent); + printf("COMMENT \"%s\"\n", comment); + } } @@ -2106,7 +2123,7 @@ static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id) size_t size; void *buf=NULL; hsize_t nelmts=1; - h5dump_t *outputformat = &dataformat; + h5tool_format_t *outputformat = &dataformat; hid_t n_type; memset(&ctx, 0, sizeof(ctx)); @@ -2143,302 +2160,290 @@ static void dump_fill_value(hid_t dcpl,hid_t type_id, hid_t obj_id) static void dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) { - int nfilters; /* number of filters */ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_name[256]; /* filter name */ - unsigned szip_options_mask; - unsigned szip_pixels_per_block; - hsize_t chsize[64]; /* chunk size in elements */ - int rank; /* rank */ - char name[256]; /* external file name */ - off_t offset; /* offset of external file */ - hsize_t size; /* size of external file */ - H5D_fill_value_t fvstatus; - H5D_alloc_time_t at; - H5D_fill_time_t ft; - hsize_t storage_size; - haddr_t ioffset; - int i, next; - unsigned j; - - storage_size=H5Dget_storage_size(obj_id); - ioffset=H5Dget_offset(obj_id); - next=H5Pget_external_count(dcpl_id); - strcpy(f_name,"\0"); + int nfilters; /* number of filters */ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + char f_name[256]; /* filter name */ + unsigned szip_options_mask; + unsigned szip_pixels_per_block; + hsize_t chsize[64]; /* chunk size in elements */ + int rank; /* rank */ + char name[256]; /* external file name */ + off_t offset; /* offset of external file */ + hsize_t size; /* size of external file */ + H5D_fill_value_t fvstatus; + H5D_alloc_time_t at; + H5D_fill_time_t ft; + hsize_t storage_size; + haddr_t ioffset; + int i, next; + unsigned j; + + storage_size=H5Dget_storage_size(obj_id); + ioffset=H5Dget_offset(obj_id); + next=H5Pget_external_count(dcpl_id); + strcpy(f_name,"\0"); + + /*------------------------------------------------------------------------- + * STORAGE_LAYOUT + *------------------------------------------------------------------------- + */ + indentation(indent + COL); + printf("%s %s\n", STORAGE_LAYOUT, BEGIN); + + if (H5D_CHUNKED == H5Pget_layout(dcpl_id)) { + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("%s ", CHUNKED); + + rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize); + HDfprintf(stdout,"%s %Hu", dump_header_format->dataspacedimbegin, chsize[0]); + for ( i=1; i<rank; i++) + HDfprintf(stdout, ", %Hu", chsize[i]); + printf(" %s\n", dump_header_format->dataspacedimend); + indentation(indent + COL); + HDfprintf(stdout, "SIZE %Hu\n ", storage_size); + + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + } + else if (H5D_COMPACT == H5Pget_layout(dcpl_id)) { + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("%s\n", COMPACT); + + indentation(indent + COL); + HDfprintf(stdout, "SIZE %Hu\n", storage_size); + + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + } + else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) { + /*------------------------------------------------------------------------- + * EXTERNAL_FILE + *------------------------------------------------------------------------- + */ + if (next) { + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("%s\n", CONTIGUOUS); + + indentation(indent + COL); + printf("%s %s\n", EXTERNAL, BEGIN); + + /*start indent */ + indent += COL; + 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); + } + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + } + else { + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("%s\n", CONTIGUOUS); + + indentation(indent + COL); + HDfprintf(stdout,"SIZE %Hu\n", storage_size); + indentation(indent + COL); + HDfprintf(stdout,"OFFSET %Hu\n", ioffset); + + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + } + } + /*------------------------------------------------------------------------- + * FILTERS + *------------------------------------------------------------------------- + */ + nfilters = H5Pget_nfilters(dcpl_id); -/*------------------------------------------------------------------------- - * STORAGE_LAYOUT - *------------------------------------------------------------------------- - */ - indentation(indent + COL); - printf("%s %s\n", STORAGE_LAYOUT, BEGIN); - - if (H5D_CHUNKED == H5Pget_layout(dcpl_id)) - { - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("%s ", CHUNKED); - rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize); - HDfprintf(stdout,"%s %Hu", dump_header_format->dataspacedimbegin, chsize[0]); - for ( i=1; i<rank; i++) - HDfprintf(stdout, ", %Hu", chsize[i]); - printf(" %s\n", dump_header_format->dataspacedimend); - indentation(indent + COL); - HDfprintf(stdout, "SIZE %Hu\n ", storage_size); - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - } - else if (H5D_COMPACT == H5Pget_layout(dcpl_id)) - { - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("%s\n", COMPACT); - indentation(indent + COL); - HDfprintf(stdout, "SIZE %Hu\n", storage_size); - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - } - else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) - { - /*------------------------------------------------------------------------- - * EXTERNAL_FILE - *------------------------------------------------------------------------- - */ - if (next) - { - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("%s\n", CONTIGUOUS); - indentation(indent + COL); - printf("%s %s\n", EXTERNAL, BEGIN); - /*start indent */ - indent += COL; - 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); - } - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - } - else - { - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("%s\n", CONTIGUOUS); - indentation(indent + COL); - HDfprintf(stdout,"SIZE %Hu\n", storage_size); - indentation(indent + COL); - HDfprintf(stdout,"OFFSET %Hu\n", ioffset); - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - } - } -/*------------------------------------------------------------------------- - * FILTERS - *------------------------------------------------------------------------- - */ - nfilters = H5Pget_nfilters(dcpl_id); - - indentation(indent + COL); - printf("%s %s\n", FILTERS, BEGIN); - indent += COL; - - if (nfilters) - { - for (i=0; i<nfilters; i++) - { - cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter(dcpl_id, - (unsigned)i, - &filt_flags, - &cd_nelmts, - cd_values, - sizeof(f_name), - f_name); - - switch (filtn) - { - case H5Z_FILTER_DEFLATE: + printf("%s %s\n", FILTERS, BEGIN); + indent += COL; + + if (nfilters) { + for (i=0; i<nfilters; i++) { + cd_nelmts = NELMTS(cd_values); + filtn = H5Pget_filter(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, + cd_values, sizeof(f_name), f_name); + + switch (filtn) { + case H5Z_FILTER_DEFLATE: + indentation(indent + COL); + printf("%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END); + break; + case H5Z_FILTER_SHUFFLE: + indentation(indent + COL); + printf("%s\n", SHUFFLE); + break; + case H5Z_FILTER_FLETCHER32: + indentation(indent + COL); + printf("%s\n", FLETCHER32); + break; + case H5Z_FILTER_SZIP: + { + szip_options_mask=cd_values[0];; + szip_pixels_per_block=cd_values[1]; + + indentation(indent + COL); + printf("%s %s\n",SZIP, BEGIN); + + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("PIXELS_PER_BLOCK %d\n", szip_pixels_per_block); + + indentation(indent + COL); + if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK) + printf("MODE %s\n", "HARDWARE"); + else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK) + printf("MODE %s\n", "K13"); + + indentation(indent + COL); + if (szip_options_mask & H5_SZIP_EC_OPTION_MASK) + printf("CODING %s\n", "ENTROPY"); + else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK) + printf("CODING %s\n", "NEAREST NEIGHBOUR"); + + indentation(indent + COL); + if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK) + printf("BYTE_ORDER %s\n", "LSB"); + else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK) + printf("BYTE_ORDER %s\n", "MSB"); + + indentation(indent + COL); + if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) + printf("HEADER %s\n", "RAW"); + + /*end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); + } + break; + default: + indentation(indent + COL); + if (H5Zfilter_avail(filtn)) + printf("%s %s\n", "USER_REGISTERED_FILTER", BEGIN); + else + printf("%s %s\n", "UNKNOWN_FILTER", BEGIN); + /*start indent */ + indent += COL; + indentation(indent + COL); + printf("FILTER_ID %d\n", filtn); + if (f_name[0]!='\0') { + indentation(indent + COL); + printf("COMMENT %s\n", f_name); + } + if (cd_nelmts) { + indentation(indent + COL); + printf("%s %s ","PARAMS", BEGIN); + for (j=0; j<cd_nelmts; j++) + printf("%d ", cd_values[j]); + printf("%s\n", END); + } + break; + }/*switch*/ + } /*i*/ + }/*nfilters*/ + else { + indentation(indent + COL); + printf("NONE\n"); + } + indent -= COL; indentation(indent + COL); - printf("%s %s %s %d %s\n", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END); - break; - case H5Z_FILTER_SHUFFLE: + printf("%s\n",END); + + /*------------------------------------------------------------------------- + * FILLVALUE + *------------------------------------------------------------------------- + */ indentation(indent + COL); - printf("%s\n", SHUFFLE); - break; - case H5Z_FILTER_FLETCHER32: + printf("%s %s\n", FILLVALUE, BEGIN); + /*start indent */ + indent += COL; indentation(indent + COL); - printf("%s\n", FLETCHER32); - break; - case H5Z_FILTER_SZIP: - { - szip_options_mask=cd_values[0];; - szip_pixels_per_block=cd_values[1]; - - indentation(indent + COL); - printf("%s %s\n",SZIP, BEGIN); - - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("PIXELS_PER_BLOCK %d\n", szip_pixels_per_block); - - indentation(indent + COL); - if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK) - printf("MODE %s\n", "HARDWARE"); - else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK) - printf("MODE %s\n", "K13"); - - indentation(indent + COL); - if (szip_options_mask & H5_SZIP_EC_OPTION_MASK) - printf("CODING %s\n", "ENTROPY"); - else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK) - printf("CODING %s\n", "NEAREST NEIGHBOUR"); - - indentation(indent + COL); - if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK) - printf("BYTE_ORDER %s\n", "LSB"); - else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK) - printf("BYTE_ORDER %s\n", "MSB"); - - indentation(indent + COL); - if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) - printf("HEADER %s\n", "RAW"); - - /*end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); + printf("FILL_TIME "); + 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; + default: + assert(0); + break; } - break; - default: indentation(indent + COL); - if (H5Zfilter_avail(filtn)) - printf("%s %s\n", "USER_REGISTERED_FILTER", BEGIN); + printf("%s ", "VALUE "); + H5Pfill_value_defined(dcpl_id, &fvstatus); + if (fvstatus == H5D_FILL_VALUE_UNDEFINED) + printf("%s\n", "H5D_FILL_VALUE_UNDEFINED"); else - printf("%s %s\n", "UNKNOWN_FILTER", BEGIN); + dump_fill_value(dcpl_id,type_id,obj_id); + /* end indent */ + indent -= COL; + indentation(indent + COL); + printf("\n"); + indentation(indent + COL); + printf("%s\n",END); + + /*------------------------------------------------------------------------- + * ALLOCATION_TIME + *------------------------------------------------------------------------- + */ + indentation(indent + COL); + printf("ALLOCATION_TIME %s\n",BEGIN); /*start indent */ indent += COL; indentation(indent + COL); - printf("FILTER_ID %d\n", filtn); - if (f_name[0]!='\0') { - indentation(indent + COL); - printf("COMMENT %s\n", f_name); - } - if (cd_nelmts) { - indentation(indent + COL); - printf("%s %s ","PARAMS", BEGIN); - for (j=0; j<cd_nelmts; j++) { - printf("%d ", cd_values[j]); - } - printf("%s\n", END); + 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; + default: + assert(0); + break; } - break; - }/*switch*/ - } /*i*/ - }/*nfilters*/ - else - { - indentation(indent + COL); - printf("NONE\n"); - } - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); - -/*------------------------------------------------------------------------- - * FILLVALUE - *------------------------------------------------------------------------- - */ - indentation(indent + COL); - printf("%s %s\n", FILLVALUE, BEGIN); - /*start indent */ - indent += COL; - indentation(indent + COL); - printf("FILL_TIME "); - 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; - default: - assert(0); - break; - } - indentation(indent + COL); - printf("%s ", "VALUE "); - H5Pfill_value_defined(dcpl_id, &fvstatus); - if (fvstatus == H5D_FILL_VALUE_UNDEFINED) - { - printf("%s\n", "H5D_FILL_VALUE_UNDEFINED"); - } - else - { - dump_fill_value(dcpl_id,type_id,obj_id); - } - /* end indent */ - indent -= COL; - indentation(indent + COL); - printf("\n"); - indentation(indent + COL); - printf("%s\n",END); - -/*------------------------------------------------------------------------- - * ALLOCATION_TIME - *------------------------------------------------------------------------- - */ - indentation(indent + COL); - printf("ALLOCATION_TIME %s\n",BEGIN); - /*start indent */ - indent += COL; - indentation(indent + COL); - 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; - default: - assert(0); - break; - } - /* end indent */ - indent -= COL; - indentation(indent + COL); - printf("%s\n",END); + /* end indent */ + indent -= COL; + indentation(indent + COL); + printf("%s\n",END); } /*------------------------------------------------------------------------- @@ -2457,112 +2462,94 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) static void dump_fcpl(hid_t fid) { - hid_t fcpl; /* file creation property list ID */ - hid_t fapl; /* file access property list ID */ - hsize_t userblock; /* userblock size retrieved from FCPL */ - size_t off_size; /* size of offsets in the file */ - size_t len_size; /* size of lengths in the file */ - unsigned super; /* superblock version # */ - unsigned freelist; /* free list version # */ - unsigned stab; /* symbol table entry version # */ - unsigned shhdr; /* shared object header version # */ - hid_t fdriver; /* file driver */ - char dname[15]; /* buffer to store driver name */ + hid_t fcpl; /* file creation property list ID */ + hid_t fapl; /* file access property list ID */ + hsize_t userblock; /* userblock size retrieved from FCPL */ + size_t off_size; /* size of offsets in the file */ + size_t len_size; /* size of lengths in the file */ + unsigned super; /* superblock version # */ + unsigned freelist; /* free list version # */ + unsigned stab; /* symbol table entry version # */ + unsigned shhdr; /* shared object header version # */ + hid_t fdriver; /* file driver */ + char dname[15]; /* buffer to store driver name */ #ifdef H5_WANT_H5_V1_4_COMPAT - int sym_lk; - int sym_ik; /* symbol table B-tree internal 'K' value */ + int sym_lk; + int sym_ik; /* symbol table B-tree internal 'K' value */ #else - unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ - unsigned sym_ik; /* symbol table B-tree internal 'K' value */ + unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ + unsigned sym_ik; /* symbol table B-tree internal 'K' value */ #endif - unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ - - fcpl=H5Fget_create_plist(fid); - H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); - H5Pget_userblock(fcpl,&userblock); - H5Pget_sizes(fcpl,&off_size,&len_size); - H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); - H5Pget_istore_k(fcpl,&istore_ik); - H5Pclose(fcpl); - fapl=h5_fileaccess(); - fdriver=H5Pget_driver(fapl); - H5Pclose(fapl); - -/*------------------------------------------------------------------------- - * SUPER_BLOCK - *------------------------------------------------------------------------- - */ - printf("%s %s\n",SUPER_BLOCK, BEGIN); - indentation(indent + COL); - printf("%s %u\n","SUPERBLOCK_VERSION", super); - indentation(indent + COL); - printf("%s %u\n","FREELIST_VERSION", freelist); - indentation(indent + COL); - printf("%s %u\n","SYMBOLTABLE_VERSION", stab); - indentation(indent + COL); - printf("%s %u\n","OBJECTHEADER_VERSION", shhdr); - indentation(indent + COL); - HDfprintf(stdout,"%s %Hd\n","OFFSET_SIZE", (long_long)off_size); - indentation(indent + COL); - HDfprintf(stdout,"%s %Hd\n","LENGTH_SIZE", (long_long)len_size); - indentation(indent + COL); - printf("%s %u\n","BTREE_RANK", sym_ik); - indentation(indent + COL); - printf("%s %d\n","BTREE_LEAF", sym_lk); - - if (H5FD_CORE==fdriver) - { - strcpy(dname,"H5FD_CORE"); - } - else if (H5FD_FAMILY==fdriver) - { - strcpy(dname,"H5FD_FAMILY"); - } - else if (H5FD_GASS==fdriver) - { - strcpy(dname,"H5FD_GASS"); - } - else if (H5FD_LOG==fdriver) - { - strcpy(dname,"H5FD_LOG"); - } - else if (H5FD_MPIO==fdriver) - { - strcpy(dname,"H5FD_MPIO"); - } - else if (H5FD_MULTI==fdriver) - { - strcpy(dname,"H5FD_MULTI"); - } - else if (H5FD_SEC2==fdriver) - { - strcpy(dname,"H5FD_SEC2"); - } - else if (H5FD_STDIO==fdriver) - { - strcpy(dname,"H5FD_STDIO"); - } + unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ + + fcpl=H5Fget_create_plist(fid); + H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + H5Pget_userblock(fcpl,&userblock); + H5Pget_sizes(fcpl,&off_size,&len_size); + H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); + H5Pget_istore_k(fcpl,&istore_ik); + H5Pclose(fcpl); + fapl=h5_fileaccess(); + fdriver=H5Pget_driver(fapl); + H5Pclose(fapl); + + /*------------------------------------------------------------------------- + * SUPER_BLOCK + *------------------------------------------------------------------------- + */ + printf("%s %s\n",SUPER_BLOCK, BEGIN); + indentation(indent + COL); + printf("%s %u\n","SUPERBLOCK_VERSION", super); + indentation(indent + COL); + printf("%s %u\n","FREELIST_VERSION", freelist); + indentation(indent + COL); + printf("%s %u\n","SYMBOLTABLE_VERSION", stab); + indentation(indent + COL); + printf("%s %u\n","OBJECTHEADER_VERSION", shhdr); + indentation(indent + COL); + HDfprintf(stdout,"%s %Hd\n","OFFSET_SIZE", (long_long)off_size); + indentation(indent + COL); + HDfprintf(stdout,"%s %Hd\n","LENGTH_SIZE", (long_long)len_size); + indentation(indent + COL); + printf("%s %u\n","BTREE_RANK", sym_ik); + indentation(indent + COL); + printf("%s %d\n","BTREE_LEAF", sym_lk); + + if (H5FD_CORE==fdriver) + HDstrcpy(dname,"H5FD_CORE"); + else if (H5FD_FAMILY==fdriver) + HDstrcpy(dname,"H5FD_FAMILY"); + else if (H5FD_GASS==fdriver) + HDstrcpy(dname,"H5FD_GASS"); + else if (H5FD_LOG==fdriver) + HDstrcpy(dname,"H5FD_LOG"); + else if (H5FD_MPIO==fdriver) + HDstrcpy(dname,"H5FD_MPIO"); + else if (H5FD_MULTI==fdriver) + HDstrcpy(dname,"H5FD_MULTI"); + else if (H5FD_SEC2==fdriver) + HDstrcpy(dname,"H5FD_SEC2"); + else if (H5FD_STDIO==fdriver) + HDstrcpy(dname,"H5FD_STDIO"); #ifdef H5_HAVE_STREAM - else if (H5FD_STREAM==fdriver) - { - strcpy(dname,"H5FD_STREAM"); - } + else if (H5FD_STREAM==fdriver) + HDstrcpy(dname,"H5FD_STREAM"); #endif - indentation(indent + COL); - printf("%s %s\n","FILE_DRIVER", dname); - indentation(indent + COL); - printf("%s %u\n","ISTORE_K", istore_ik); - printf("%s\n",END); - -/*------------------------------------------------------------------------- - * USER_BLOCK - *------------------------------------------------------------------------- - */ - printf("USER_BLOCK %s\n",BEGIN); - indentation(indent + COL); - HDfprintf(stdout,"%s %Hu\n","USERBLOCK_SIZE", userblock); - printf("%s\n",END); + indentation(indent + COL); + printf("%s %s\n","FILE_DRIVER", dname); + indentation(indent + COL); + printf("%s %u\n","ISTORE_K", istore_ik); + printf("%s\n",END); + + /*------------------------------------------------------------------------- + * USER_BLOCK + *------------------------------------------------------------------------- + */ + printf("USER_BLOCK %s\n",BEGIN); + indentation(indent + COL); + HDfprintf(stdout,"%s %Hu\n","USERBLOCK_SIZE", userblock); + printf("%s\n",END); } /*------------------------------------------------------------------------- @@ -2926,15 +2913,15 @@ handle_groups(hid_t fid, char *group, void UNUSED * data) dump_header_format->groupblockend); d_status = EXIT_FAILURE; } else { - size_t new_len = strlen(group) + 1; + size_t new_len = HDstrlen(group) + 1; if (prefix_len <= new_len) { prefix_len = new_len; - prefix = realloc(prefix, prefix_len); + prefix = HDrealloc(prefix, prefix_len); } H5Gget_objinfo(gid, ".", TRUE, &statbuf); - strcpy(prefix, group); + HDstrcpy(prefix, group); dump_group(gid, group); if (H5Gclose(gid) < 0) @@ -2962,15 +2949,10 @@ handle_links(hid_t fid, char *links, void UNUSED * data) H5G_stat_t statbuf; if (H5Gget_objinfo(fid, links, FALSE, &statbuf) < 0) { - begin_obj(dump_header_format->softlinkbegin, links, - dump_header_format->softlinkblockbegin); - indentation(COL); error_msg(progname, "unable to get obj info from \"%s\"\n", links); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); d_status = EXIT_FAILURE; } else if (statbuf.type == H5G_LINK) { - char *buf = malloc(statbuf.linklen); + char *buf = HDmalloc(statbuf.linklen); begin_obj(dump_header_format->softlinkbegin, links, dump_header_format->softlinkblockbegin); @@ -2986,14 +2968,9 @@ handle_links(hid_t fid, char *links, void UNUSED * data) end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend); - free(buf); + HDfree(buf); } else { - begin_obj(dump_header_format->softlinkbegin, links, - dump_header_format->softlinkblockbegin); - indentation(COL); error_msg(progname, "\"%s\" is not a link\n", links); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); d_status = EXIT_FAILURE; } } @@ -3471,13 +3448,13 @@ main(int argc, const char *argv[]) /* find all objects that might be targets of a refernce */ init_ref_path_table(fid); /* Insert the root group into the ref. path table */ - H5Giterate(fid, "/", NULL, fill_ref_path_table, (void *)""); + H5Giterate(fid, (const char *)"/", NULL, fill_ref_path_table, (void *)""); if (doxml) { /* initialize XML */ /* reset prefix! */ - strcpy(prefix, ""); + HDstrcpy(prefix, ""); /* make sure the URI is initialized to something */ if (xml_dtd_uri == NULL) { @@ -3602,7 +3579,7 @@ done: free_table(dset_table); free_table(type_table); - free(prefix); + HDfree(prefix); /* To Do: clean up XML table */ @@ -4514,7 +4491,7 @@ xml_dump_dataspace(hid_t space) static void xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNUSED pindex) { - h5dump_t *outputformat = &xml_dataformat; + h5tool_format_t *outputformat = &xml_dataformat; int status = -1; void *buf; hid_t space, type, p_type; @@ -4749,14 +4726,14 @@ xml_dump_named_datatype(hid_t type, const char *name) char *t_prefix; char *t_name; - tmp = malloc(strlen(prefix) + strlen(name) + 2); - strcpy(tmp, prefix); - strcat(tmp, "/"); - strcat(tmp, name); + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); + HDstrcat(tmp, "/"); + HDstrcat(tmp, name); indentation(indent); - /*char **/ dtxid = malloc(100); - /*char **/ parentxid = malloc(100); + /*char **/ dtxid = HDmalloc(100); + /*char **/ parentxid = HDmalloc(100); /*char **/t_tmp = xml_escape_the_name(tmp); /*char **/t_prefix = xml_escape_the_name(prefix); /*char **/t_name = xml_escape_the_name(name); @@ -4775,20 +4752,20 @@ xml_dump_named_datatype(hid_t type, const char *name) "Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, name, dtxid, - parentxid,(strcmp(prefix, "") ? t_prefix : "/")); + parentxid,(HDstrcmp(prefix, "") ? t_prefix : "/")); } else { printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, t_name, dtxid, - t_tmp, parentxid, (strcmp(prefix, "") ? t_prefix : "/")); + t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/")); } - free(dtxid); - free(parentxid); - free(t_tmp); - free(t_prefix); - free(t_name); - free(tmp); + HDfree(dtxid); + HDfree(parentxid); + HDfree(t_tmp); + HDfree(t_prefix); + HDfree(t_name); + HDfree(tmp); indent += COL; indentation(indent); @@ -4833,17 +4810,17 @@ xml_dump_group(hid_t gid, const char *name) char *t_objname; char *par_name; - if (strcmp(name, "/") == 0) { + if (HDstrcmp(name, "/") == 0) { isRoot = 1; - tmp = malloc(2); - strcpy(tmp, "/"); + tmp = HDmalloc(2); + HDstrcpy(tmp, "/"); } else { - tmp = malloc(strlen(prefix) + strlen(name) + 2); - strcpy(tmp, prefix); + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); par = HDstrdup(tmp); - cp = strrchr(par, '/'); + cp = HDstrrchr(par, '/'); if (cp != NULL) { - if ((cp == par) && strlen(par) > 1) { + if ((cp == par) && HDstrlen(par) > 1) { *(cp + 1) = '\0'; } else { *cp = '\0'; @@ -5257,53 +5234,6 @@ xml_print_strs(hid_t did, int source) } /*------------------------------------------------------------------------- - * Function: check_compression - * - * Purpose: private function to check for compression and - * put a comment in the XML. (Not fully implemented.) - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -#ifdef LATER -static void -check_compression(hid_t dcpl) -{ - int nfilt; - int i; - H5Z_filter_t filter; - char namebuf[20]; - size_t cd_nelmts = 1; - unsigned int cd_values; - unsigned int flags; -/* not used yet: will need to do somehting more elaborate to handle future - * compression methods. - char *t1 = "H5Z_FILTER_DEFLATE"; -*/ - - nfilt = H5Pget_nfilters(dcpl); - if (nfilt <= 0) - return; - for (i = 0; i < nfilt; i++) { - filter = H5Pget_filter(dcpl, i, &flags, - (size_t *) &cd_nelmts, - &cd_values, 20, namebuf); - if (filter == H5Z_FILTER_DEFLATE) { - indentation(indent + COL); - printf("<%sCompression />\n",xmlnsprefix); - indentation(indent + COL); - printf("<!-- Compression parameter %d -->\n", cd_values); - } - } -} -#endif /* LATER */ - -/*------------------------------------------------------------------------- * Function: check_filters * * Purpose: private function to check for the filters and @@ -5516,6 +5446,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) printf("</%sData>\n",xmlnsprefix); indent -= COL; } + /*------------------------------------------------------------------------- * Function: xml_dump_group * @@ -5544,13 +5475,13 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) hsize_t tempi; char *tmp; char *t_name, *t_tmp, *t_prefix; - char *rstr = malloc(100); - char *pstr = malloc(100); + char *rstr = HDmalloc(100); + char *pstr = HDmalloc(100); - tmp = malloc(strlen(prefix) + strlen(name) + 2); - strcpy(tmp, prefix); - strcat(tmp, "/"); - strcat(tmp, name); + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); + HDstrcat(tmp, "/"); + HDstrcat(tmp, name); indentation(indent); t_name = xml_escape_the_name(name); @@ -5562,12 +5493,12 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) printf("<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n",xmlnsprefix, t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/"); - free(t_name); - free(t_tmp); - free(t_prefix); - free(rstr); - free(pstr); - free(tmp); + HDfree(t_name); + HDfree(t_tmp); + HDfree(t_prefix); + HDfree(rstr); + HDfree(pstr); + HDfree(tmp); dcpl = H5Dget_create_plist(did); type = H5Dget_type(did); @@ -6042,3 +5973,28 @@ init_prefix(char **prfx, size_t prfx_len) *prfx = HDcalloc(prfx_len, 1); } + +/*------------------------------------------------------------------------- + * Function: add_prefix + * + * Purpose: Add object to prefix + * + * Return: void + * + *------------------------------------------------------------------------- + */ +static void +add_prefix(char **prfx, size_t *prfx_len, const char *name) +{ + size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2; + + /* Check if we need more space */ + if(*prfx_len <= new_len) { + *prfx_len = new_len + 1; + *prfx = HDrealloc(*prfx, *prfx_len); + } + + /* Append object name to prefix */ + HDstrcat(HDstrcat(*prfx, "/"), name); +} /* end add_prefix */ + diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h index 96e7d71..dbc5de9 100644 --- a/tools/h5dump/h5dump.h +++ b/tools/h5dump/h5dump.h @@ -18,4 +18,133 @@ #define H5DUMP_MAX_RANK H5S_MAX_RANK +#define ATTRIBUTE_DATA 0 +#define DATASET_DATA 1 +#define ENUM_DATA 2 +#define COL 3 + +/* Strings for output */ +#define ATTRIBUTE "ATTRIBUTE" +#define BLOCK "BLOCK" +#define SUPER_BLOCK "SUPER_BLOCK" +#define COMPRESSION "COMPRESSION" +#define CONCATENATOR "//" +#define COMPLEX "COMPLEX" +#define COUNT "COUNT" +#define CSET "CSET" +#define CTYPE "CTYPE" +#define DATA "DATA" +#define DATASPACE "DATASPACE" +#define EXTERNAL "EXTERNAL" +#define FILENO "FILENO" +#define HARDLINK "HARDLINK" +#define NLINK "NLINK" +#define OBJID "OBJECTID" +#define OBJNO "OBJNO" +#define S_SCALAR "SCALAR" +#define S_SIMPLE "SIMPLE" +#define S_NULL "NULL" +#define SOFTLINK "SOFTLINK" +#define STORAGELAYOUT "STORAGELAYOUT" +#define START "START" +#define STRIDE "STRIDE" +#define STRSIZE "STRSIZE" +#define STRPAD "STRPAD" +#define SUBSET "SUBSET" +#define FILTERS "FILTERS" +#define DEFLATE "COMPRESSION DEFLATE" +#define DEFLATE_LEVEL "LEVEL" +#define SHUFFLE "PREPROCESSING SHUFFLE" +#define FLETCHER32 "CHECKSUM FLETCHER32" +#define SZIP "COMPRESSION SZIP" +#define NBIT "COMPRESSION NBIT" +#define SCALEOFFSET "COMPRESSION SCALEOFFSET" +#define SCALEOFFSET_MINBIT "MIN BITS" +#define STORAGE_LAYOUT "STORAGE_LAYOUT" +#define CONTIGUOUS "CONTIGUOUS" +#define COMPACT "COMPACT" +#define CHUNKED "CHUNKED" +#define EXTERNAL_FILE "EXTERNAL_FILE" +#define FILLVALUE "FILLVALUE" +#define FILE_CONTENTS "FILE_CONTENTS" + +#define BEGIN "{" +#define END "}" + +typedef struct h5dump_header_t { + const char *name; + const char *filebegin; + const char *fileend; + const char *bootblockbegin; + const char *bootblockend; + const char *groupbegin; + const char *groupend; + const char *datasetbegin; + const char *datasetend; + const char *attributebegin; + const char *attributeend; + const char *datatypebegin; + const char *datatypeend; + const char *dataspacebegin; + const char *dataspaceend; + const char *databegin; + const char *dataend; + const char *softlinkbegin; + const char *softlinkend; + const char *subsettingbegin; + const char *subsettingend; + const char *startbegin; + const char *startend; + const char *stridebegin; + const char *strideend; + const char *countbegin; + const char *countend; + const char *blockbegin; + const char *blockend; + + const char *fileblockbegin; + const char *fileblockend; + const char *bootblockblockbegin; + const char *bootblockblockend; + const char *groupblockbegin; + const char *groupblockend; + const char *datasetblockbegin; + const char *datasetblockend; + const char *attributeblockbegin; + const char *attributeblockend; + const char *datatypeblockbegin; + const char *datatypeblockend; + const char *dataspaceblockbegin; + const char *dataspaceblockend; + const char *datablockbegin; + const char *datablockend; + const char *softlinkblockbegin; + const char *softlinkblockend; + const char *strblockbegin; + const char *strblockend; + const char *enumblockbegin; + const char *enumblockend; + const char *structblockbegin; + const char *structblockend; + const char *vlenblockbegin; + const char *vlenblockend; + const char *subsettingblockbegin; + const char *subsettingblockend; + const char *startblockbegin; + const char *startblockend; + const char *strideblockbegin; + const char *strideblockend; + const char *countblockbegin; + const char *countblockend; + const char *blockblockbegin; + const char *blockblockend; + + const char *dataspacedescriptionbegin; + const char *dataspacedescriptionend; + const char *dataspacedimbegin; + const char *dataspacedimend; + +} h5dump_header_t; + + #endif /* !H5DUMP_H__ */ diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index f5cc080..50ca3a0 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -11,15 +11,13 @@ * 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 <hdf5.h> -#include <H5private.h> -#include <stdio.h> -#ifndef MIPSEL -#include <math.h> -#endif /* MIPSEL */ -#include <string.h> -#include <ctype.h> -#include "h5import.h" +#include "hdf5.h" +#include "H5private.h" +#include <stdio.h> +#include <math.h> +#include <string.h> +#include <ctype.h> +#include "h5import.h" int main(int argc, char *argv[]) { @@ -30,15 +28,15 @@ int main(int argc, char *argv[]) int state = 0; struct Input *in=NULL; - const char *err1 = "Invalid number of arguments: %d.\n"; - const char *err2 = "Error in state table.\n"; - const char *err3 = "No output file given.\n"; - const char *err4 = "Program aborted.\n"; - const char *err5 = "Invalid path %s.\n"; - const char *err6 = "Invalid dimensions - %s.\n"; - const char *err7 = "Invalid type of data - %s.\n"; - const char *err8 = "Invalid size of data - %s.\n"; - const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; + const char *err1 = "Invalid number of arguments: %d.\n"; + const char *err2 = "Error in state table.\n"; + const char *err3 = "No output file given.\n"; + const char *err4 = "Program aborted.\n"; + const char *err5 = "Invalid path %s.\n"; + const char *err6 = "Invalid dimensions - %s.\n"; + const char *err7 = "Invalid type of data - %s.\n"; + const char *err8 = "Invalid size of data - %s.\n"; + const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; (void) setvbuf(stderr, (char *) NULL, _IOLBF, 0); (void) setvbuf(stdout, (char *) NULL, _IOLBF, 0); diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h index cf318fc..85fa71e 100755 --- a/tools/h5import/h5import.h +++ b/tools/h5import/h5import.h @@ -18,6 +18,9 @@ * */ +#ifndef H5IMPORT_H__ +#define H5IMPORT_H__ + /* * state table tokens */ @@ -220,3 +223,6 @@ hid_t createInputDataType(struct Input *in); static int readUIntegerData(FILE **strm, struct Input *in); static int allocateUIntegerStorage(struct Input *in); static int validateConfigurationParameters(struct Input * in); + +#endif /* H5IMPORT_H__ */ + diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c index e6c29e5..32d3fe5 100755 --- a/tools/h5import/h5importtest.c +++ b/tools/h5import/h5importtest.c @@ -11,8 +11,10 @@ * 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 <stdio.h> -#include <H5private.h> +#include "H5private.h" + /* * Name: * h5importtest @@ -286,4 +288,3 @@ main(void) return (0); } - diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index f022689..620d12c 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -64,7 +64,7 @@ static struct dispatch_t { herr_t (*close)(hid_t obj); herr_t (*list1)(hid_t obj); herr_t (*list2)(hid_t obj, const char *name); -} dispatch_g[H5G_NTYPES]; +} dispatch_g[H5G_NLIBTYPES]; #define DISPATCH(TYPE,NAME,OPEN,CLOSE,LIST1,LIST2) { \ dispatch_g[TYPE].name = (NAME); \ @@ -1226,7 +1226,7 @@ dump_dataset_values(hid_t dset) { hid_t f_type = H5Dget_type(dset); size_t size = H5Tget_size(f_type); - h5dump_t info; + h5tool_format_t info; char string_prefix[64]; static char fmt_double[16], fmt_float[16]; @@ -1332,7 +1332,7 @@ list_attr (hid_t obj, const char *attr_name, void UNUSED *op_data) size_t need; hsize_t temp_need; void *buf; - h5dump_t info; + h5tool_format_t info; H5S_class_t space_type; printf(" Attribute: "); diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index f8ea1db..dae857e 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -29,7 +29,6 @@ #define MAX_NC_NAME 256 /* max length of a name */ #define MAX_VAR_DIMS 32 /* max per variable dimensions */ - /*------------------------------------------------------------------------- * data structures for command line options *------------------------------------------------------------------------- @@ -44,7 +43,7 @@ typedef struct { the type of filter and additional parameter type can be one of the filters H5Z_FILTER_NONE 0, uncompress if compressed - H5Z_FILTER_DEFLATE 1 , deflation like gzip + H5Z_FILTER_DEFLATE 1 , deflation like gzip H5Z_FILTER_SHUFFLE 2 , shuffle the data H5Z_FILTER_FLETCHER32 3 , letcher32 checksum of EDC H5Z_FILTER_SZIP 4 , szip compression @@ -247,78 +246,7 @@ obj_list_t* parse_layout(const char *str, const char* get_sfilter (H5Z_filter_t filtn); int parse_number(char *str); -/*------------------------------------------------------------------------- - * tests - *------------------------------------------------------------------------- - */ - -#define FNAME0 "test0.h5" -#define FNAME0OUT "test0.out.h5" -#define FNAME1 "test1.h5" -#define FNAME1OUT "test1.out.h5" -#define FNAME2 "test2.h5" -#define FNAME2OUT "test2.out.h5" -#define FNAME3 "test3.h5" -#define FNAME3OUT "test3.out.h5" -#define FNAME4 "test4.h5" -#define FNAME4OUT "test4.out.h5" -#define FNAME5 "test5.h5" -#define FNAME5OUT "test5.out.h5" -#define FNAME6 "test6.h5" -#define FNAME7 "test_szip.h5" -#define FNAME8 "test_deflate.h5" -#define FNAME9 "test_shuffle.h5" -#define FNAME10 "test_fletcher32.h5" -#define FNAME11 "test_all.h5" -#define FNAME7OUT "test_szip.out.h5" -#define FNAME8OUT "test_deflate.out.h5" -#define FNAME9OUT "test_shuffle.out.h5" -#define FNAME10OUT "test_fletcher32.out.h5" -#define FNAME11OUT "test_all.out.h5" - -int make_testfiles(void); - -int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *dset_name, - hid_t type_id, - void *buf ); -int write_attr(hid_t loc_id, - int rank, - hsize_t *dims, - const char *attr_name, - hid_t type_id, - void *buf); -void write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid, /* for reference create */ - int make_diffs /* flag to modify data buffers */); -void write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t file_id, - int make_diffs /* flag to modify data buffers */); - - - -/*------------------------------------------------------------------------- - * tests utils - *------------------------------------------------------------------------- - */ -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t dcpl, - void *buf); - -int make_attr(hid_t loc_id, - int rank, - hsize_t *dims, - const char *attr_name, - hid_t type_id, - void *buf); - - #endif /* H5REPACK_H__ */ + diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 94d1e09..1f5d37e 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -507,7 +507,7 @@ int do_copy_objects(hid_t fidin, default: if (options->verbose) printf(" %-10s %s\n","User defined object",travt->objs[i].name); - break; + goto error; } } diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index b87a713..a6a94db 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -147,8 +147,6 @@ int aux_assign_obj(const char* name, /* object name from traverse lis tmp.nfilters=1; tmp.filter[0]=options->filter_g; } - - if (options->all_layout) { /* assign the global layout info to the OBJ info */ @@ -163,10 +161,7 @@ int aux_assign_obj(const char* name, /* object name from traverse lis default: break; }/*switch*/ - } - - } *obj = tmp; @@ -199,7 +194,6 @@ int apply_filters(const char* name, /* object name from traverse list */ pack_opt_t *options) /* repack options */ { int nfilters; /* number of filters in DCPL */ - unsigned aggression; /* the deflate level */ hsize_t nelmts; /* number of elements in dataset */ size_t size; /* size of datatype in bytes */ hsize_t chsize[64]; /* chunk size in elements */ @@ -207,6 +201,7 @@ int apply_filters(const char* name, /* object name from traverse list */ int i; pack_info_t obj; + if (rank==0) goto out; @@ -275,8 +270,7 @@ int apply_filters(const char* name, /* object name from traverse list */ } } - - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * the type of filter and additional parameter * type can be one of the filters * H5Z_FILTER_NONE 0, uncompress if compressed @@ -313,12 +307,16 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ case H5Z_FILTER_DEFLATE: - aggression=obj.filter[i].cd_values[0]; - /* set up for deflated data */ - if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) - return -1; - if(H5Pset_deflate(dcpl_id,aggression)<0) - return -1; + { + unsigned aggression; /* the deflate level */ + + aggression = obj.filter[i].cd_values[0]; + /* set up for deflated data */ + if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) + return -1; + if(H5Pset_deflate(dcpl_id,aggression)<0) + return -1; + } break; /*------------------------------------------------------------------------- diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index 5294134..7c1fab7 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -136,9 +136,12 @@ void usage(void) printf("-i input Input HDF5 File\n"); printf("-o output Output HDF5 File\n"); printf("[-h] Print usage message\n"); - printf("[-v] Verbose mode. Print output (list of objects, filters, warnings)\n"); + printf("[-v] Verbose mode. Print more output (list of objects,\n"); + printf(" filters, warnings)\n"); printf("[-f 'filter'] Filter type: 'filter' is a string with the format\n"); + printf("\n"); printf(" <list of objects> : <name of filter> = <filter parameters>\n"); + printf("\n"); printf(" <list of objects> is a comma separated list of object names\n"); printf(" meaning apply compression only to those objects.\n"); printf(" if no object names are specified, the filter is applied to all objects\n"); @@ -152,9 +155,13 @@ void usage(void) printf(" SHUF (no parameter)\n"); printf(" FLET (no parameter)\n"); printf(" GZIP=<deflation level> from 1-9\n"); - printf(" SZIP=<pixels per block,coding> (pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN')\n"); + printf(" SZIP=<pixels per block,coding>\n"); + printf(" (pixels per block is a even number in 2-32 and coding method\n"); + printf(" is 'EC' or 'NN')\n"); printf("[-l 'layout'] Layout type. 'layout' is a string with the format\n"); + printf("\n"); printf(" <list of objects> : <layout type>\n"); + printf("\n"); printf(" <list of objects> is a comma separated list of object names,\n"); printf(" meaning that layout information is supplied for those objects.\n"); printf(" if no object names are specified, the layout is applied to all objects\n"); @@ -167,8 +174,9 @@ void usage(void) printf(" <dim_1 x dim_2 x ... dim_n>\n"); printf("\n"); printf("-e file File with the -f and -l options (only filter and layout flags)\n"); - printf("-m number Do not apply the filter to objects which size in bytes is smaller than number.\n"); - printf(" If no size is specified a minimum of 1024 bytes is assumed.\n"); + printf("-m size Do not apply the filter to objects which size in bytes\n"); + printf(" is smaller than number. If no size is specified a minimum of\n"); + printf(" 1024 bytes is assumed.\n"); printf("\n"); printf("Examples of use:\n"); printf("\n"); @@ -186,4 +194,3 @@ void usage(void) printf("\n"); } - diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 7bb6d10..1b043ce 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -17,7 +17,6 @@ #include "h5repack.h" - /*------------------------------------------------------------------------- * Function: init_packobject * diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index 64691ba..961f401 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -133,11 +133,13 @@ obj_list_t* parse_filter(const char *str, if ( c=='=') { /*one more parameter */ scomp[k]='\0'; /*cut space */ - /*SZIP is a special case , it can be - SZIP=8,EC - SZIP=8,NN - */ - +/*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP + * szip has the format SZIP=<pixels per block,coding> + * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' + * example SZIP=8,NN + *------------------------------------------------------------------------- + */ if (strcmp(scomp,"SZIP")==0) { l=-1; /* mask index check */ @@ -182,6 +184,11 @@ obj_list_t* parse_filter(const char *str, } /* u */ } /*if */ +/*------------------------------------------------------------------------- + * all other filters + *------------------------------------------------------------------------- + */ + else { /* here we could have 1 or 2 digits */ diff --git a/tools/h5repack/testh5repack_attr.c b/tools/h5repack/testh5repack_attr.c index f18bbc2..7635cf2 100644 --- a/tools/h5repack/testh5repack_attr.c +++ b/tools/h5repack/testh5repack_attr.c @@ -15,6 +15,7 @@ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" +#include "testh5repack.h" /*------------------------------------------------------------------------- * Function: write_attr_in diff --git a/tools/h5repack/testh5repack_detect_szip.c b/tools/h5repack/testh5repack_detect_szip.c index 16962af..095910e 100644 --- a/tools/h5repack/testh5repack_detect_szip.c +++ b/tools/h5repack/testh5repack_detect_szip.c @@ -16,6 +16,7 @@ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" +#include "testh5repack.h" /*------------------------------------------------------------------------- diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c index 862257a..c345028 100644 --- a/tools/h5repack/testh5repack_dset.c +++ b/tools/h5repack/testh5repack_dset.c @@ -15,6 +15,7 @@ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" +#include "testh5repack.h" static void make_dset_reg_ref(hid_t loc_id); diff --git a/tools/h5repack/testh5repack_main.c b/tools/h5repack/testh5repack_main.c index 1876f9c..5398c14 100644 --- a/tools/h5repack/testh5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -15,6 +15,7 @@ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" +#include "testh5repack.h" #include "h5diff.h" #if 0 diff --git a/tools/h5repack/testh5repack_make.c b/tools/h5repack/testh5repack_make.c index d25864b..3437682 100644 --- a/tools/h5repack/testh5repack_make.c +++ b/tools/h5repack/testh5repack_make.c @@ -15,6 +15,7 @@ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" +#include "testh5repack.h" #define DIM1 40 #define DIM2 20 @@ -896,7 +897,7 @@ int make_layout(hid_t loc_id) hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; int buf[DIM1][DIM2]; int i, j, n; - char name[5]; + char name[6]; for (i=n=0; i<DIM1; i++){ diff --git a/tools/h5repack/testh5repack_util.c b/tools/h5repack/testh5repack_util.c index cad52d3..63b8b1d 100644 --- a/tools/h5repack/testh5repack_util.c +++ b/tools/h5repack/testh5repack_util.c @@ -14,6 +14,7 @@ #include "hdf5.h" #include "h5repack.h" +#include "testh5repack.h" /*------------------------------------------------------------------------- * Function: make_dset diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 72ab415..64ee827 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -391,10 +391,10 @@ hsize_t diff_compare( hid_t file1_id, * * Purpose: switch between types and choose the diff function * TYPE is either - * 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_LINK Object is a symbolic link * * Return: Number of differences found * @@ -405,33 +405,32 @@ hsize_t diff_compare( hid_t file1_id, *------------------------------------------------------------------------- */ -hsize_t diff( hid_t file1_id, - const char *path1, - hid_t file2_id, - const char *path2, - diff_opt_t *options, - H5G_obj_t1 type ) +hsize_t +diff (hid_t file1_id, + const char *path1, + hid_t file2_id, const char *path2, diff_opt_t * options, H5G_obj_t type) { - hid_t type1_id=(-1); - hid_t type2_id=(-1); - hid_t grp1_id=(-1); - hid_t grp2_id=(-1); - int ret; - H5G_stat_t sb1; - H5G_stat_t sb2; - char *buf1=NULL; - char *buf2=NULL; - hsize_t nfound=0; - - switch ( type ) - { -/*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: + hid_t type1_id=(-1); + hid_t type2_id=(-1); + hid_t grp1_id=(-1); + hid_t grp2_id=(-1); + int ret; + H5G_stat_t sb1; + H5G_stat_t sb2; + hsize_t nfound = 0; + + switch (type) + { + /*------------------------------------------------------------------------- + * H5G_DATASET + *------------------------------------------------------------------------- + */ + case H5G_DATASET: - /* always print name */ + /*------------------------------------------------------------------------- + * verbose, always print name + *------------------------------------------------------------------------- + */ if (options->m_verbose) { if (print_objname(options,(hsize_t)1)) @@ -538,42 +537,38 @@ hsize_t diff( hid_t file1_id, *------------------------------------------------------------------------- */ case H5G_LINK: - if (H5Gget_objinfo(file1_id,path1,FALSE,&sb1)<0) - goto out; - if (H5Gget_objinfo(file1_id,path1,FALSE,&sb2)<0) - goto out; - - buf1 = malloc(sb1.linklen); - buf2 = malloc(sb2.linklen); - - if (H5Gget_linkval(file1_id,path1,sb1.linklen,buf1)<0) - goto out; - if (H5Gget_linkval(file2_id,path2,sb1.linklen,buf2)<0) - goto out; + { + char *buf1 = NULL; + char *buf2 = NULL; - ret = HDstrcmp(buf1,buf2); + if (H5Gget_objinfo (file1_id, path1, FALSE, &sb1) < 0) + goto out; + if (H5Gget_objinfo (file1_id, path1, FALSE, &sb2) < 0) + goto out; - /* if "buf1" != "buf2" then the links are "different" */ - nfound = (ret!=0) ? 1 : 0; + buf1 = HDmalloc (sb1.linklen); + buf2 = HDmalloc (sb2.linklen); - if (print_objname(options,nfound)) - printf( "Link: <%s> and <%s>\n",path1,path2); + if (H5Gget_linkval (file1_id, path1, sb1.linklen, buf1) < 0) + goto out; + if (H5Gget_linkval (file2_id, path2, sb1.linklen, buf2) < 0) + goto out; - if (buf1) { - free(buf1); - buf1=NULL; - } + ret = HDstrcmp (buf1, buf2); - if (buf2) { - free(buf2); - buf2=NULL; - } + /* if "buf1" != "buf2" then the links are "different" */ + nfound = (ret != 0) ? 1 : 0; - break; + if (print_objname (options, nfound)) + printf( "Link: <%s> and <%s>\n",path1,path2); + HDfree (buf1); + HDfree (buf2); + } + break; default: - nfound=0; + nfound = 0; if (options->m_verbose) { printf("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2, get_type(type) ); @@ -583,27 +578,21 @@ hsize_t diff( hid_t file1_id, } - out: - - /* close */ - /* disable error reporting */ - H5E_BEGIN_TRY { - H5Tclose(type1_id); - H5Tclose(type2_id); - H5Gclose(grp1_id); - H5Tclose(grp2_id); - /* enable error reporting */ - } H5E_END_TRY; +out: - if (buf1) - free(buf1); - if (buf2) - free(buf2); + /* close */ + /* disable error reporting */ + H5E_BEGIN_TRY + { + H5Tclose (type1_id); + H5Tclose (type2_id); + H5Gclose (grp1_id); + H5Tclose (grp2_id); + /* enable error reporting */ + } + H5E_END_TRY; - return nfound; + return nfound; } - - - diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 8716a02..78e4949 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -59,10 +59,10 @@ typedef struct { int p; /* relative error to compare*/ double percent; /* relative error value */ int n; /* count, compare up to count */ - hsize_t count; /* count value */ + hsize_t count; /* count value */ int err_stat; /* an error ocurred (1, error, 0, no error) */ int cmn_objs; /* do we have comparable objects */ - int not_cmp; /* are the objects comparable */ + int not_cmp; /* are the objects comparable */ } diff_opt_t; @@ -240,136 +240,136 @@ hsize_t diff_datum(void *_mem1, hsize_t diff_float(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_double(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_schar(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_uchar(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_short(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_ushort(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_int(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_uint(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_long(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_ulong(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_llong(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); hsize_t diff_ullong(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index f61c9e5..9d761dd 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -61,124 +61,124 @@ hsize_t diff_array( void *_mem1, hid_t container1_id, hid_t container2_id) /* dataset where the reference came from*/ { - hsize_t nfound=0; /* number of differences found */ - size_t size; /* size of datum */ - unsigned char *mem1 = (unsigned char*)_mem1; - unsigned char *mem2 = (unsigned char*)_mem2; - unsigned char *tmp1; - unsigned char *tmp2; - hsize_t acc[32]; /* accumulator position */ - hsize_t pos[32]; /* matrix position */ - int ph=1; /* print header */ - hsize_t i; - int j; - - /* get the size. */ - size = H5Tget_size( m_type ); - - acc[rank-1]=1; - for(j=(rank-2); j>=0; j--) - { - acc[j]=acc[j+1]*(int)dims[j+1]; - } - for ( j = 0; j < rank; j++) - pos[j]=0; - - - if(H5Tis_variable_str(m_type)) - { - tmp1 = ((unsigned char**)mem1)[0]; - tmp2 = ((unsigned char**)mem2)[0]; - nfound+=diff_datum( - tmp1, - tmp2, - m_type, - (hsize_t)0, - rank, - acc, - pos, - options, - name1, - name2, - container1_id, - container2_id, - &ph); - } - - else + hsize_t nfound=0; /* number of differences found */ + size_t size; /* size of datum */ + unsigned char *mem1 = (unsigned char*)_mem1; + unsigned char *mem2 = (unsigned char*)_mem2; + unsigned char *tmp1; + unsigned char *tmp2; + hsize_t acc[32]; /* accumulator position */ + hsize_t pos[32]; /* matrix position */ + int ph=1; /* print header */ + hsize_t i; + int j; + + /* get the size. */ + size = H5Tget_size( m_type ); + + acc[rank-1]=1; + for(j=(rank-2); j>=0; j--) + { + acc[j]=acc[j+1]*(int)dims[j+1]; + } + for ( j = 0; j < rank; j++) + pos[j]=0; + + + if(H5Tis_variable_str(m_type)) + { + tmp1 = ((unsigned char**)mem1)[0]; + tmp2 = ((unsigned char**)mem2)[0]; + nfound+=diff_datum( + tmp1, + tmp2, + m_type, + (hsize_t)0, + rank, + acc, + pos, + options, + name1, + name2, + container1_id, + container2_id, + &ph); + } - { + else - switch (H5Tget_class(m_type)) - { - default: - assert(0); - break; - - case H5T_FLOAT: - if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) - nfound=diff_float(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) - nfound=diff_double(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - break; - - case H5T_INTEGER: - - if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) - nfound=diff_schar(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - nfound=diff_uchar(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) - nfound=diff_short(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - nfound=diff_ushort(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_INT)) - nfound=diff_int(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_UINT)) - nfound=diff_uint(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_LONG)) - nfound=diff_long(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) - nfound=diff_ulong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) - nfound=diff_llong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) - nfound=diff_ullong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); - - break; - - case H5T_COMPOUND: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - case H5T_VLEN: - case H5T_REFERENCE: - - for ( i = 0; i < nelmts; i++) - { - nfound+=diff_datum( - mem1 + i * size, - mem2 + i * size, /* offset */ - m_type, - i, - rank, - acc, - pos, - options, - name1, - name2, - container1_id, - container2_id, - &ph); - if (options->n && nfound>=options->count) - return nfound; - } /* i */ - } /* switch */ - } /* else */ + { - return nfound; + switch (H5Tget_class(m_type)) + { + default: + assert(0); + break; + + case H5T_FLOAT: + if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) + nfound=diff_float(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) + nfound=diff_double(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + break; + + case H5T_INTEGER: + + if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) + nfound=diff_schar(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) + nfound=diff_uchar(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) + nfound=diff_short(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) + nfound=diff_ushort(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_INT)) + nfound=diff_int(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_UINT)) + nfound=diff_uint(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_LONG)) + nfound=diff_long(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) + nfound=diff_ulong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) + nfound=diff_llong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) + nfound=diff_ullong(mem1,mem2,nelmts,rank,acc,pos,options,name1,name2,&ph); + + break; + + case H5T_COMPOUND: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + case H5T_VLEN: + case H5T_REFERENCE: + + for ( i = 0; i < nelmts; i++) + { + nfound+=diff_datum( + mem1 + i * size, + mem2 + i * size, /* offset */ + m_type, + i, + rank, + acc, + pos, + options, + name1, + name2, + container1_id, + container2_id, + &ph); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ + } /* switch */ + } /* else */ + + return nfound; } @@ -223,678 +223,689 @@ hsize_t diff_array( void *_mem1, */ hsize_t diff_datum(void *_mem1, - void *_mem2, - hid_t m_type, - hsize_t i, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - hid_t container1_id, - hid_t container2_id, /*where the reference came from*/ - int *ph) /*print header */ + void *_mem2, + hid_t m_type, + hsize_t i, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + hid_t container1_id, + hid_t container2_id, /*where the reference came from*/ + int *ph) /*print header */ { - static char fmt_llong[255]; - static char fmt_ullong[255]; - static char fmt_llongp[255]; - static char fmt_ullongp[255]; - hsize_t dims[H5S_MAX_RANK]; - unsigned char *mem1 = (unsigned char*)_mem1; - unsigned char *mem2 = (unsigned char*)_mem2; - unsigned u; - hid_t memb_type; - size_t type_size; - size_t offset; - int nmembs; - int j; - hsize_t nelmts; - hsize_t ndims; - size_t size; - int iszero1; - int iszero2; - H5G_obj_t1 obj1_type; - H5G_obj_t1 obj2_type; - hid_t obj1_id; - hid_t obj2_id; - H5G_stat_t sb1; - H5G_stat_t sb2; - hsize_t nfound=0; /* differences found */ - int ret=0; /* check return error */ - - if (!fmt_llong[0]) { - - /* Build default formats for long long types */ - sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su %%%su %%%su\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - sprintf(fmt_llongp, "%%%sd %%%sd %%%sd %%%sd\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullongp, "%%%su %%%su %%%su %%%su\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - - } - - type_size = H5Tget_size( m_type ); - - switch (H5Tget_class(m_type)) - { - default: - assert(0); - break; - case H5T_TIME: - assert(0); - break; - -/*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - case H5T_COMPOUND: - nmembs = H5Tget_nmembers(m_type); - for (j = 0; j < nmembs; j++) - { - offset = H5Tget_member_offset(m_type, (unsigned)j); - memb_type = H5Tget_member_type(m_type, (unsigned)j); - nfound+=diff_datum( - mem1+offset, - mem2+offset, - memb_type, - i, - rank, - acc, - pos, - options, - obj1, - obj2, - container1_id, - container2_id, - ph); - H5Tclose(memb_type); - } - break; - -/*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - case H5T_STRING: - - if(H5Tis_variable_str(m_type)) - type_size = HDstrlen((char*)mem1); - else - type_size = H5Tget_size(m_type); - - for (u=0; u<type_size; u++) - nfound+=diff_char( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - ph); - - - break; - -/*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - case H5T_BITFIELD: - { - /* byte-by-byte comparison */ - for (u=0; u<type_size; u++) - nfound+=diff_native_uchar( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - ph); - - } - break; -/*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - case H5T_OPAQUE: - - /* byte-by-byte comparison */ - for (u=0; u<type_size; u++) - nfound+=diff_native_uchar( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - ph); - - break; - - -/*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - case H5T_ENUM: - -/* For enumeration types we compare the names instead of the - integer values. For each pair of elements being - compared, we convert both bit patterns to their corresponding - enumeration constant and do a string comparison */ - - { - char enum_name1[1024]; - char enum_name2[1024]; - - /* disable error reporting */ - H5E_BEGIN_TRY { - - if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && - (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) - { - if (HDstrcmp(enum_name1,enum_name2)!=0) - { - nfound=1; - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(SFORMAT,enum_name1,enum_name2); - } - } - } - else - { - for (u=0; u<type_size; u++) - nfound+=diff_native_uchar( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - ph); - } - - /* enable error reporting */ - } H5E_END_TRY; - } - - - break; -/*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - case H5T_ARRAY: - /* get the array's base datatype for each element */ - memb_type = H5Tget_super(m_type); - size = H5Tget_size(memb_type); - ndims = H5Tget_array_ndims(m_type); - H5Tget_array_dims(m_type, dims, NULL); - assert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* calculate the number of array elements */ - for (u = 0, nelmts = 1; u <ndims; u++) - nelmts *= dims[u]; - for (u = 0; u < nelmts; u++) - nfound+=diff_datum( - mem1 + u * size, - mem2 + u * size, /* offset */ - memb_type, - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - container1_id, - container2_id, - ph); - H5Tclose(memb_type); - break; - -/*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - case H5T_VLEN: - - /* get the VL sequences's base datatype for each element */ - memb_type = H5Tget_super(m_type); - size = H5Tget_size(memb_type); - - /* get the number of sequence elements */ - nelmts = ((hvl_t *)mem1)->len; - - for (j = 0; j < (int)nelmts; j++) - nfound+=diff_datum( - ((char *)(((hvl_t *)mem1)->p)) + j * size, - ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */ - memb_type, - i, /* index position */ - rank, - acc, - pos, - options, - obj1, - obj2, - container1_id, - container2_id, - ph); - - H5Tclose(memb_type); - - break; - - - case H5T_REFERENCE: - - iszero1=is_zero(_mem1, H5Tget_size(m_type)); - iszero2=is_zero(_mem2, H5Tget_size(m_type)); - if (iszero1==1 && iszero2==1) - return 0; - else if (iszero1!=iszero2) - return 1; - else - { - -/*------------------------------------------------------------------------- - * H5T_STD_REF_DSETREG - * Dataset region reference - *------------------------------------------------------------------------- - */ - - if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) + static char fmt_llong[255]; + static char fmt_ullong[255]; + static char fmt_llongp[255]; + static char fmt_ullongp[255]; + hsize_t dims[H5S_MAX_RANK]; + unsigned char *mem1 = (unsigned char*)_mem1; + unsigned char *mem2 = (unsigned char*)_mem2; + unsigned u; + hid_t memb_type; + size_t type_size; + size_t offset; + int nmembs; + int j; + hsize_t nelmts; + hsize_t ndims; + size_t size; + int iszero1; + int iszero2; + H5G_obj_t1 obj1_type; + H5G_obj_t1 obj2_type; + hid_t obj1_id; + hid_t obj2_id; + H5G_stat_t sb1; + H5G_stat_t sb2; + hsize_t nfound=0; /* differences found */ + int ret=0; /* check return error */ + + if (!fmt_llong[0]) { + + /* Build default formats for long long types */ + sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullong, "%%%su %%%su %%%su\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + sprintf(fmt_llongp, "%%%sd %%%sd %%%sd %%%sd\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullongp, "%%%su %%%su %%%su %%%su\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + + } + + type_size = H5Tget_size( m_type ); + + switch (H5Tget_class(m_type)) + { + default: + assert(0); + break; + case H5T_TIME: + assert(0); + break; + + /*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + case H5T_COMPOUND: + nmembs = H5Tget_nmembers(m_type); + for (j = 0; j < nmembs; j++) + { + offset = H5Tget_member_offset(m_type, (unsigned)j); + memb_type = H5Tget_member_type(m_type, (unsigned)j); + nfound+=diff_datum( + mem1+offset, + mem2+offset, + memb_type, + i, + rank, + acc, + pos, + options, + obj1, + obj2, + container1_id, + container2_id, + ph); + H5Tclose(memb_type); + } + break; + + /*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + case H5T_STRING: + { + + H5T_str_t pad; + char *s; + + if(H5Tis_variable_str(m_type)) { - hid_t region1_id; - hid_t region2_id; - - if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0) - ret= -1; - if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0) - ret= -1; - if (H5Gget_objinfo(obj1_id, ".", FALSE, &sb1)<0) - ret= -1; - if (H5Gget_objinfo(obj2_id, ".", FALSE, &sb2)<0) - ret= -1; - if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0) - ret= -1; - if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0) - ret= -1; - - if (ret==-1) { - options->err_stat=1; - return 0; - } - - if (diff_region(region1_id,region2_id)) - { - printf("Different region referenced\n"); - } - - close_obj(H5G_DATASET,obj1_id); - close_obj(H5G_DATASET,obj2_id); - H5Sclose(region1_id); - H5Sclose(region2_id); - - }/*dataset reference*/ - - -/*------------------------------------------------------------------------- - * H5T_STD_REF_OBJ - * Object references. get the type and OID of the referenced object - *------------------------------------------------------------------------- - */ - else if (H5Tequal(m_type, H5T_STD_REF_OBJ)) + /* mem1 is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + s = *(char**)mem1; + if(s!=NULL) + size = HDstrlen(s); + } + else { + s = (char *)mem1; + size = H5Tget_size(m_type); + } - if ((obj1_type = H5Rget_obj_type(container1_id, H5R_OBJECT, _mem1))<0) - ret= -1; - if ((obj2_type = H5Rget_obj_type(container2_id, H5R_OBJECT, _mem2))<0) - ret= -1; - if (ret==-1) { - options->err_stat=1; - return 0; - } - - /* check object type */ - if (obj1_type!=obj2_type) - { - printf("Different object types referenced: <%s> and <%s>", obj1, obj2); - return 1; - } - - if ((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1))<0) - ret= -1; - if ((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2))<0) - ret= -1; - if (ret==-1) { - options->err_stat=1; - return 0; - } - - - /*deep compare */ - switch (obj1_type) { - case H5G_DATASET: - nfound=diff_datasetid(obj1_id, - obj2_id, - NULL, - NULL, - options); - break; - default: - printf("Warning: Comparison not possible of object types referenced: <%s> and <%s>", - obj1, obj2); - options->not_cmp=1; - break; - } - - close_obj(obj1_type,obj1_id); - close_obj(obj2_type,obj2_id); - - }/*object reference*/ - - }/*is zero*/ + pad = H5Tget_strpad(m_type); + /* check for NULL pointer for string */ + if(s!=NULL) + for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++) + nfound+=diff_char( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + } break; - - case H5T_INTEGER: - - -/*------------------------------------------------------------------------- - * H5T_NATIVE_SCHAR - *------------------------------------------------------------------------- - */ - if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) - { - char temp1_char; - char temp2_char; - assert(type_size==sizeof(char)); - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&temp2_char, mem2, sizeof(char)); - /* -d and !-p */ - if (options->d && !options->p) - { - if (abs(temp1_char-temp2_char) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char), - abs(1-temp2_char/temp1_char)); - } - nfound++; - } - } - /* -d and -p */ - else if ( options->d && options->p) - { - if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent && - abs(temp1_char-temp2_char) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char), - abs(1-temp2_char/temp1_char)); - } - nfound++; - } - } - else if (temp1_char != temp2_char) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char)); - } - nfound++; - } - - } /*H5T_NATIVE_SCHAR*/ - -/*------------------------------------------------------------------------- - * H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ - else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - { - unsigned char temp1_uchar; - unsigned char temp2_uchar; - assert(type_size==sizeof(unsigned char)); - - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - /* -d and !-p */ - if (options->d && !options->p) - { - if (abs(temp1_uchar-temp2_uchar) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar), - abs(1-temp2_uchar/temp1_uchar)); - } - nfound++; - } - } - /* -d and -p */ - else if ( options->d && options->p) - { - if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent && - abs(temp1_uchar-temp2_uchar) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar), - abs(1-temp2_uchar/temp1_uchar)); - } - nfound++; - } - } - else if (temp1_uchar != temp2_uchar) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); - } - nfound++; - } - - } /*H5T_NATIVE_UCHAR*/ - - -/*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) - { - short temp1_short; - short temp2_short; - assert(type_size==sizeof(short)); - - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&temp2_short, mem2, sizeof(short)); - /* -d and !-p */ - if (options->d && !options->p) - { - if (abs(temp1_short-temp2_short) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), - abs(1-temp2_short/temp1_short)); - } - nfound++; - } - } - /* -d and -p */ - else if ( options->d && options->p) - { - if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent && - abs(temp1_short-temp2_short) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), - abs(1-temp2_short/temp1_short)); - } - nfound++; - } - } - else if (temp1_short != temp2_short) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); - } - nfound++; - } - - - } /*H5T_NATIVE_SHORT*/ - -/*------------------------------------------------------------------------- - * H5T_NATIVE_USHORT - *------------------------------------------------------------------------- - */ - - else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - { - unsigned short temp1_ushort; - unsigned short temp2_ushort; - assert(type_size==sizeof(short)); - - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - /* -d and !-p */ - if (options->d && !options->p) - { - if (abs(temp1_ushort-temp2_ushort) > options->delta) - { - - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!options->d && options->p) - { - if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent ) - { - - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), - abs(1-temp2_ushort/temp1_ushort)); - } - nfound++; - } - } - /* -d and -p */ - else if ( options->d && options->p) - { - if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent && - abs(temp1_ushort-temp2_ushort) > options->delta ) - { - - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), - abs(1-temp2_ushort/temp1_ushort)); + /*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + case H5T_BITFIELD: + { + /* byte-by-byte comparison */ + for (u=0; u<type_size; u++) + nfound+=diff_native_uchar( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + + } + break; + + /*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + case H5T_OPAQUE: + + /* byte-by-byte comparison */ + for (u=0; u<type_size; u++) + nfound+=diff_native_uchar( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + + break; + + + /*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + case H5T_ENUM: + + /* For enumeration types we compare the names instead of the + integer values. For each pair of elements being + compared, we convert both bit patterns to their corresponding + enumeration constant and do a string comparison */ + + { + char enum_name1[1024]; + char enum_name2[1024]; + + /* disable error reporting */ + H5E_BEGIN_TRY { + + if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && + (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) + { + if (HDstrcmp(enum_name1,enum_name2)!=0) + { + nfound=1; + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(SFORMAT,enum_name1,enum_name2); + } + } + else + { + for (u=0; u<type_size; u++) + nfound+=diff_native_uchar( + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + ph); + } + } + /* enable error reporting */ + } H5E_END_TRY; + } + + + break; + /*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + case H5T_ARRAY: + /* get the array's base datatype for each element */ + memb_type = H5Tget_super(m_type); + size = H5Tget_size(memb_type); + ndims = H5Tget_array_ndims(m_type); + H5Tget_array_dims(m_type, dims, NULL); + assert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (u = 0, nelmts = 1; u <ndims; u++) + nelmts *= dims[u]; + for (u = 0; u < nelmts; u++) + nfound+=diff_datum( + mem1 + u * size, + mem2 + u * size, /* offset */ + memb_type, + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + container1_id, + container2_id, + ph); + H5Tclose(memb_type); + break; + + /*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + case H5T_VLEN: + + /* get the VL sequences's base datatype for each element */ + memb_type = H5Tget_super(m_type); + size = H5Tget_size(memb_type); + + /* get the number of sequence elements */ + nelmts = ((hvl_t *)mem1)->len; + + for (j = 0; j < (int)nelmts; j++) + nfound+=diff_datum( + ((char *)(((hvl_t *)mem1)->p)) + j * size, + ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */ + memb_type, + i, /* index position */ + rank, + acc, + pos, + options, + obj1, + obj2, + container1_id, + container2_id, + ph); + + H5Tclose(memb_type); + + break; + + + case H5T_REFERENCE: + + iszero1=is_zero(_mem1, H5Tget_size(m_type)); + iszero2=is_zero(_mem2, H5Tget_size(m_type)); + if (iszero1==1 && iszero2==1) + return 0; + else if (iszero1!=iszero2) + return 1; + else + { + + /*------------------------------------------------------------------------- + * H5T_STD_REF_DSETREG + * Dataset region reference + *------------------------------------------------------------------------- + */ + + if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) + { + hid_t region1_id; + hid_t region2_id; + + if ((obj1_id = H5Rdereference(container1_id, H5R_DATASET_REGION, _mem1))<0) + ret= -1; + if ((obj2_id = H5Rdereference(container2_id, H5R_DATASET_REGION, _mem2))<0) + ret= -1; + if (H5Gget_objinfo(obj1_id, ".", FALSE, &sb1)<0) + ret= -1; + if (H5Gget_objinfo(obj2_id, ".", FALSE, &sb2)<0) + ret= -1; + if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0) + ret= -1; + if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0) + ret= -1; + + if (ret==-1) { + options->err_stat=1; + return 0; + } + + if (diff_region(region1_id,region2_id)) + { + printf("Different region referenced\n"); + } + + close_obj(H5G_DATASET,obj1_id); + close_obj(H5G_DATASET,obj2_id); + H5Sclose(region1_id); + H5Sclose(region2_id); + + }/*dataset reference*/ + + + /*------------------------------------------------------------------------- + * H5T_STD_REF_OBJ + * Object references. get the type and OID of the referenced object + *------------------------------------------------------------------------- + */ + else if (H5Tequal(m_type, H5T_STD_REF_OBJ)) + { + + if ((obj1_type = H5Rget_obj_type(container1_id, H5R_OBJECT, _mem1))<0) + ret= -1; + if ((obj2_type = H5Rget_obj_type(container2_id, H5R_OBJECT, _mem2))<0) + ret= -1; + if (ret==-1) { + options->err_stat=1; + return 0; + } + + /* check object type */ + if (obj1_type!=obj2_type) + { + printf("Different object types referenced: <%s> and <%s>", obj1, obj2); + return 1; + } + + if ((obj1_id = H5Rdereference(container1_id, H5R_OBJECT, _mem1))<0) + ret= -1; + if ((obj2_id = H5Rdereference(container2_id, H5R_OBJECT, _mem2))<0) + ret= -1; + if (ret==-1) { + options->err_stat=1; + return 0; + } + + + /*deep compare */ + switch (obj1_type) { + case H5G_DATASET: + nfound=diff_datasetid(obj1_id, + obj2_id, + NULL, + NULL, + options); + break; + default: + printf("Warning: Comparison not possible of object types referenced: <%s> and <%s>", + obj1, obj2); + options->not_cmp=1; + break; + } + + close_obj(obj1_type,obj1_id); + close_obj(obj2_type,obj2_id); + + }/*object reference*/ + + }/*is zero*/ + + + break; + + + case H5T_INTEGER: + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_SCHAR + *------------------------------------------------------------------------- + */ + if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) + { + char temp1_char; + char temp2_char; + assert(type_size==sizeof(char)); + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&temp2_char, mem2, sizeof(char)); + /* -d and !-p */ + if (options->d && !options->p) + { + if (abs(temp1_char-temp2_char) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char)); + } + nfound++; + } + } + /* !-d and -p */ + else if (!options->d && options->p) + { + if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char),abs(1-temp2_char/temp1_char)); + } + nfound++; + } + } + /* -d and -p */ + else if ( options->d && options->p) + { + if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent && + abs(temp1_char-temp2_char) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char),abs(1-temp2_char/temp1_char)); + } + nfound++; + } + } + else if (temp1_char != temp2_char) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_char,temp2_char,abs(temp1_char-temp2_char)); + } + nfound++; + } + + } /*H5T_NATIVE_SCHAR*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ + else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) + { + unsigned char temp1_uchar; + unsigned char temp2_uchar; + assert(type_size==sizeof(unsigned char)); + + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + /* -d and !-p */ + if (options->d && !options->p) + { + if (abs(temp1_uchar-temp2_uchar) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); + } + nfound++; + } + } + /* !-d and -p */ + else if (!options->d && options->p) + { + if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar),abs(1-temp2_uchar/temp1_uchar)); + } + nfound++; + } + } + /* -d and -p */ + else if ( options->d && options->p) + { + if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent && + abs(temp1_uchar-temp2_uchar) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar),abs(1-temp2_uchar/temp1_uchar)); + } + nfound++; + } + } + else if (temp1_uchar != temp2_uchar) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); + + } + nfound++; + } + + } /*H5T_NATIVE_UCHAR*/ + + + /*------------------------------------------------------------------------- + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) + { + short temp1_short; + short temp2_short; + assert(type_size==sizeof(short)); + + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&temp2_short, mem2, sizeof(short)); + /* -d and !-p */ + if (options->d && !options->p) + { + if (abs(temp1_short-temp2_short) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); + } + nfound++; + } + } + /* !-d and -p */ + else if (!options->d && options->p) + { + if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short),abs(1-temp2_short/temp1_short)); + } + nfound++; + } + } + /* -d and -p */ + else if ( options->d && options->p) + { + if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent && + abs(temp1_short-temp2_short) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short),abs(1-temp2_short/temp1_short)); + } + nfound++; + } + } + else if (temp1_short != temp2_short) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); + } + nfound++; + } + + + } /*H5T_NATIVE_SHORT*/ + + /*------------------------------------------------------------------------- + * H5T_NATIVE_USHORT + *------------------------------------------------------------------------- + */ + + else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) + { + unsigned short temp1_ushort; + unsigned short temp2_ushort; + assert(type_size==sizeof(short)); + + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + /* -d and !-p */ + if (options->d && !options->p) + { + if (abs(temp1_ushort-temp2_ushort) > options->delta) + { + + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); + } + nfound++; + } + } + /* !-d and -p */ + else if (!options->d && options->p) + { + if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent ) + { + + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort),abs(1-temp2_ushort/temp1_ushort)); + } + nfound++; + } + } + /* -d and -p */ + else if ( options->d && options->p) + { + if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent && + abs(temp1_ushort-temp2_ushort) > options->delta ) + { + + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + + printf(SPACES); + printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort),abs(1-temp2_ushort/temp1_ushort)); } nfound++; } @@ -1662,12 +1673,12 @@ hsize_t diff_char(unsigned char *mem1, const char *obj2, int *ph) { - hsize_t nfound=0; /* differences found */ - unsigned char temp1_uchar; - unsigned char temp2_uchar; + hsize_t nfound=0; /* differences found */ + unsigned char temp1_uchar; + unsigned char temp2_uchar; - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); if (temp1_uchar != temp2_uchar) { @@ -1680,18 +1691,18 @@ hsize_t diff_char(unsigned char *mem1, nfound++; } - return nfound; + return nfound; } /*------------------------------------------------------------------------- - * Function: is_zero + * Function: is_zero * - * Purpose: Determines if memory is initialized to all zero bytes. + * Purpose: Determines if memory is initialized to all zero bytes. * - * Return: TRUE if all bytes are zero; FALSE otherwise + * Return: TRUE if all bytes are zero; FALSE otherwise * *------------------------------------------------------------------------- */ @@ -1708,9 +1719,9 @@ is_zero(const void *_mem, size_t size) } /*------------------------------------------------------------------------- - * Function: close_obj + * Function: close_obj * - * Purpose: Auxialiary function to close an object + * Purpose: Auxialiary function to close an object * *------------------------------------------------------------------------- */ @@ -1869,38 +1880,38 @@ static int diff_region(hid_t region1_id, hid_t region2_id) *------------------------------------------------------------------------- */ hsize_t diff_float(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - float temp1_float; - float temp2_float; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + float temp1_float; + float temp2_float; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_float, mem1, sizeof(float)); - memcpy(&temp2_float, mem2, sizeof(float)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_float, mem1, sizeof(float)); + memcpy(&temp2_float, mem2, sizeof(float)); - if (fabs(temp1_float-temp2_float) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); + if (fabs(temp1_float-temp2_float) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); printf(FFORMAT,temp1_float,temp2_float,fabs(temp1_float-temp2_float)); } nfound++; @@ -2008,38 +2019,38 @@ hsize_t diff_float(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_double(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - double temp1_double; - double temp2_double; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + double temp1_double; + double temp2_double; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_double, mem1, sizeof(double)); - memcpy(&temp2_double, mem2, sizeof(double)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_double, mem1, sizeof(double)); + memcpy(&temp2_double, mem2, sizeof(double)); - if (fabs(temp1_double-temp2_double) > options->delta) - { + if (fabs(temp1_double-temp2_double) > options->delta) + { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); printf(SPACES); printf(FFORMAT,temp1_double,temp2_double,fabs(temp1_double-temp2_double)); } @@ -2149,31 +2160,31 @@ hsize_t diff_double(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_schar(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - char temp1_char; + hsize_t nfound=0; /* number of differences found */ + char temp1_char; char temp2_char; - hsize_t i; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&temp2_char, mem2, sizeof(char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&temp2_char, mem2, sizeof(char)); if (abs(temp1_char-temp2_char) > options->delta) { @@ -2187,19 +2198,19 @@ hsize_t diff_schar(unsigned char *mem1, } mem1+=sizeof(char); mem2+=sizeof(char); - if (options->n && nfound>=options->count) - return nfound; - } - } + if (options->n && nfound>=options->count) + return nfound; + } + } - /* !-d and -p */ - else if (!options->d && options->p) - { + /* !-d and -p */ + else if (!options->d && options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&temp2_char, mem2, sizeof(char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&temp2_char, mem2, sizeof(char)); if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent ) { @@ -2214,19 +2225,19 @@ hsize_t diff_schar(unsigned char *mem1, } mem1+=sizeof(char); mem2+=sizeof(char); - if (options->n && nfound>=options->count) - return nfound; - } - } + if (options->n && nfound>=options->count) + return nfound; + } + } - /* -d and -p */ - else if ( options->d && options->p) - { + /* -d and -p */ + else if ( options->d && options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&temp2_char, mem2, sizeof(char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&temp2_char, mem2, sizeof(char)); if ( temp1_char!=0 && abs(1-temp2_char/temp1_char) > options->percent && abs(temp1_char-temp2_char) > options->delta ) @@ -2242,18 +2253,18 @@ hsize_t diff_schar(unsigned char *mem1, } mem1+=sizeof(char); mem2+=sizeof(char); - if (options->n && nfound>=options->count) - return nfound; - } + if (options->n && nfound>=options->count) + return nfound; + } - } - else - { + } + else + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_char, mem1, sizeof(char)); - memcpy(&temp2_char, mem2, sizeof(char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_char, mem1, sizeof(char)); + memcpy(&temp2_char, mem2, sizeof(char)); if (temp1_char != temp2_char) { @@ -2266,15 +2277,15 @@ hsize_t diff_schar(unsigned char *mem1, nfound++; } - mem1+=sizeof(char); - mem2+=sizeof(char); - if (options->n && nfound>=options->count) - return nfound; - } /* nelmts */ + mem1+=sizeof(char); + mem2+=sizeof(char); + if (options->n && nfound>=options->count) + return nfound; + } /* nelmts */ - } + } - return nfound; + return nfound; } @@ -2289,31 +2300,31 @@ hsize_t diff_schar(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_uchar(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - unsigned char temp1_uchar; + hsize_t nfound=0; /* number of differences found */ + unsigned char temp1_uchar; unsigned char temp2_uchar; - hsize_t i; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); if (abs(temp1_uchar-temp2_uchar) > options->delta) { @@ -2331,16 +2342,16 @@ hsize_t diff_uchar(unsigned char *mem1, return nfound; } - } + } - /* !-d and -p */ - else if (!options->d && options->p) - { + /* !-d and -p */ + else if (!options->d && options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent ) { @@ -2355,19 +2366,19 @@ hsize_t diff_uchar(unsigned char *mem1, } mem1+=sizeof(unsigned char); mem2+=sizeof(unsigned char); - if (options->n && nfound>=options->count) - return nfound; - } - } + if (options->n && nfound>=options->count) + return nfound; + } + } - /* -d and -p */ - else if ( options->d && options->p) - { + /* -d and -p */ + else if ( options->d && options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); if ( temp1_uchar!=0 && abs(1-temp2_uchar/temp1_uchar) > options->percent && abs(temp1_uchar-temp2_uchar) > options->delta ) @@ -2383,39 +2394,39 @@ hsize_t diff_uchar(unsigned char *mem1, } mem1+=sizeof(unsigned char); mem2+=sizeof(unsigned char); - if (options->n && nfound>=options->count) - return nfound; - } - - } - else - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - - if (temp1_uchar != temp2_uchar) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); - } - nfound++; - } - - mem1+=sizeof(unsigned char); - mem2+=sizeof(unsigned char); - if (options->n && nfound>=options->count) - return nfound; - } /* nelmts */ - - } - - return nfound; + if (options->n && nfound>=options->count) + return nfound; + } + + } + else + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + memcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + + if (temp1_uchar != temp2_uchar) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uchar,temp2_uchar,abs(temp1_uchar-temp2_uchar)); + } + nfound++; + } + + mem1+=sizeof(unsigned char); + mem2+=sizeof(unsigned char); + if (options->n && nfound>=options->count) + return nfound; + } /* nelmts */ + + } + + return nfound; } @@ -2431,31 +2442,31 @@ hsize_t diff_uchar(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_short(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - short temp1_short; + hsize_t nfound=0; /* number of differences found */ + short temp1_short; short temp2_short; - hsize_t i; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&temp2_short, mem2, sizeof(short)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&temp2_short, mem2, sizeof(short)); if (abs(temp1_short-temp2_short) > options->delta) { @@ -2473,93 +2484,93 @@ hsize_t diff_short(unsigned char *mem1, return nfound; } - } - - /* !-d and -p */ - else if (!options->d && options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&temp2_short, mem2, sizeof(short)); - - if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), - abs(1-temp2_short/temp1_short)); - } - nfound++; - } - mem1+=sizeof(short); - mem2+=sizeof(short); - if (options->n && nfound>=options->count) - return nfound; - } - - - } - - /* -d and -p */ - else if ( options->d && options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&temp2_short, mem2, sizeof(short)); - - if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent && - abs(temp1_short-temp2_short) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), - abs(1-temp2_short/temp1_short)); - } - nfound++; - } - mem1+=sizeof(short); - mem2+=sizeof(short); - if (options->n && nfound>=options->count) - return nfound; - } - - } - else - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_short, mem1, sizeof(short)); - memcpy(&temp2_short, mem2, sizeof(short)); - - if (temp1_short != temp2_short) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); - } - nfound++; - } - - mem1+=sizeof(short); - mem2+=sizeof(short); - if (options->n && nfound>=options->count) - return nfound; - } /* nelmts */ - - } - - return nfound; + } + + /* !-d and -p */ + else if (!options->d && options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&temp2_short, mem2, sizeof(short)); + + if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), + abs(1-temp2_short/temp1_short)); + } + nfound++; + } + mem1+=sizeof(short); + mem2+=sizeof(short); + if (options->n && nfound>=options->count) + return nfound; + } + + + } + + /* -d and -p */ + else if ( options->d && options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&temp2_short, mem2, sizeof(short)); + + if ( temp1_short!=0 && abs(1-temp2_short/temp1_short) > options->percent && + abs(temp1_short-temp2_short) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short), + abs(1-temp2_short/temp1_short)); + } + nfound++; + } + mem1+=sizeof(short); + mem2+=sizeof(short); + if (options->n && nfound>=options->count) + return nfound; + } + + } + else + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_short, mem1, sizeof(short)); + memcpy(&temp2_short, mem2, sizeof(short)); + + if (temp1_short != temp2_short) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_short,temp2_short,abs(temp1_short-temp2_short)); + } + nfound++; + } + + mem1+=sizeof(short); + mem2+=sizeof(short); + if (options->n && nfound>=options->count) + return nfound; + } /* nelmts */ + + } + + return nfound; } @@ -2573,135 +2584,135 @@ hsize_t diff_short(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_ushort(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - unsigned short temp1_ushort; + hsize_t nfound=0; /* number of differences found */ + unsigned short temp1_ushort; unsigned short temp2_ushort; - hsize_t i; - - - /* -d and !-p */ - if (options->d && !options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - if (abs(temp1_ushort-temp2_ushort) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); - } - nfound++; - } - mem1+=sizeof(unsigned short); - mem2+=sizeof(unsigned short); - if (options->n && nfound>=options->count) - return nfound; - } - - } - - /* !-d and -p */ - else if (!options->d && options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), - abs(1-temp2_ushort/temp1_ushort)); - } - nfound++; - } - mem1+=sizeof(unsigned short); - mem2+=sizeof(unsigned short); - if (options->n && nfound>=options->count) - return nfound; - } - - - } - - /* -d and -p */ - else if ( options->d && options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent && - abs(temp1_ushort-temp2_ushort) > options->delta ) - { - if ( print_data(options) ) - { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), - abs(1-temp2_ushort/temp1_ushort)); - } - nfound++; - } - mem1+=sizeof(unsigned short); - mem2+=sizeof(unsigned short); - if (options->n && nfound>=options->count) - return nfound; - } - - } - else - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - if (temp1_ushort != temp2_ushort) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); - } - nfound++; - } - - mem1+=sizeof(unsigned short); - mem2+=sizeof(unsigned short); - if (options->n && nfound>=options->count) - return nfound; - } /* nelmts */ - - } - - return nfound; + hsize_t i; + + + /* -d and !-p */ + if (options->d && !options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + + if (abs(temp1_ushort-temp2_ushort) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); + } + nfound++; + } + mem1+=sizeof(unsigned short); + mem2+=sizeof(unsigned short); + if (options->n && nfound>=options->count) + return nfound; + } + + } + + /* !-d and -p */ + else if (!options->d && options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + + if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), + abs(1-temp2_ushort/temp1_ushort)); + } + nfound++; + } + mem1+=sizeof(unsigned short); + mem2+=sizeof(unsigned short); + if (options->n && nfound>=options->count) + return nfound; + } + + + } + + /* -d and -p */ + else if ( options->d && options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + + if ( temp1_ushort!=0 && abs(1-temp2_ushort/temp1_ushort) > options->percent && + abs(temp1_ushort-temp2_ushort) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IPFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort), + abs(1-temp2_ushort/temp1_ushort)); + } + nfound++; + } + mem1+=sizeof(unsigned short); + mem2+=sizeof(unsigned short); + if (options->n && nfound>=options->count) + return nfound; + } + + } + else + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + memcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + + if (temp1_ushort != temp2_ushort) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_ushort,temp2_ushort,abs(temp1_ushort-temp2_ushort)); + } + nfound++; + } + + mem1+=sizeof(unsigned short); + mem2+=sizeof(unsigned short); + if (options->n && nfound>=options->count) + return nfound; + } /* nelmts */ + + } + + return nfound; } @@ -2716,39 +2727,39 @@ hsize_t diff_ushort(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_int(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - int temp1_int; - int temp2_int; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + int temp1_int; + int temp2_int; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_int, mem1, sizeof(int)); - memcpy(&temp2_int, mem2, sizeof(int)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_int, mem1, sizeof(int)); + memcpy(&temp2_int, mem2, sizeof(int)); - if (abs(temp1_int-temp2_int) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_int,temp2_int,abs(temp1_int-temp2_int)); + if (abs(temp1_int-temp2_int) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_int,temp2_int,abs(temp1_int-temp2_int)); } nfound++; } @@ -2859,39 +2870,39 @@ hsize_t diff_int(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_uint(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - unsigned int temp1_uint; - unsigned int temp2_uint; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + unsigned int temp1_uint; + unsigned int temp2_uint; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { + /* -d and !-p */ + if (options->d && !options->p) + { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_uint, mem1, sizeof(unsigned int)); - memcpy(&temp2_uint, mem2, sizeof(unsigned int)); + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_uint, mem1, sizeof(unsigned int)); + memcpy(&temp2_uint, mem2, sizeof(unsigned int)); - if (abs(temp1_uint-temp2_uint) > options->delta) - { - if ( print_data(options) ) - { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(IFORMAT,temp1_uint,temp2_uint,abs(temp1_uint-temp2_uint)); + if (abs((int)(temp1_uint-temp2_uint)) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(IFORMAT,temp1_uint,temp2_uint,abs(temp1_uint-temp2_uint)); } nfound++; } @@ -3002,63 +3013,63 @@ hsize_t diff_uint(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_long(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - long temp1_long; - long temp2_long; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + long temp1_long; + long temp2_long; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_long, mem1, sizeof(long)); - memcpy(&temp2_long, mem2, sizeof(long)); - - if (labs(temp1_long-temp2_long) > (long)options->delta) - { - if ( print_data(options) ) + /* -d and !-p */ + if (options->d && !options->p) { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(LIFORMAT,temp1_long,temp2_long,labs(temp1_long-temp2_long)); - } - nfound++; - } - mem1+=sizeof(long); - mem2+=sizeof(long); - if (options->n && nfound>=options->count) - return nfound; - } - } + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_long, mem1, sizeof(long)); + memcpy(&temp2_long, mem2, sizeof(long)); - /* !-d and -p */ - else if (!options->d && options->p) - { + if (labs(temp1_long-temp2_long) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(LIFORMAT,temp1_long,temp2_long,labs(temp1_long-temp2_long)); + } + nfound++; + } + mem1+=sizeof(long); + mem2+=sizeof(long); + if (options->n && nfound>=options->count) + return nfound; + } - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_long, mem1, sizeof(long)); - memcpy(&temp2_long, mem2, sizeof(long)); + } - if ( temp1_long!=0 && labs(1-temp2_long/temp1_long) > options->percent ) - { - if ( print_data(options) ) + /* !-d and -p */ + else if (!options->d && options->p) { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_long, mem1, sizeof(long)); + memcpy(&temp2_long, mem2, sizeof(long)); + + if ( temp1_long!=0 && labs(1-temp2_long/temp1_long) > options->percent ) + { + if ( print_data(options) ) + { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); printf(SPACES); printf(LPIFORMAT,temp1_long,temp2_long,labs(temp1_long-temp2_long), @@ -3156,36 +3167,41 @@ hsize_t diff_ulong(unsigned char *mem1, int *ph) { - hsize_t nfound=0; /* number of differences found */ - unsigned long temp1_ulong; - unsigned long temp2_ulong; - hsize_t i; + hsize_t nfound=0; /* number of differences found */ + unsigned long temp1_ulong; + unsigned long temp2_ulong; + hsize_t i; - /* -d and !-p */ - if (options->d && !options->p) - { - - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - memcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - - if (labs((long)(temp1_ulong-temp2_ulong)) > (long)options->delta) - { - if ( print_data(options) ) + /* -d and !-p */ + if (options->d && !options->p) { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(LIFORMAT,temp1_ulong,temp2_ulong,labs(temp1_ulong-temp2_ulong)); - } - nfound++; - } - mem1+=sizeof(unsigned long); - mem2+=sizeof(unsigned long); - if (options->n && nfound>=options->count) - return nfound; - } + + for ( i = 0; i < nelmts; i++) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ulong, mem1, sizeof(unsigned long)); + memcpy(&temp2_ulong, mem2, sizeof(unsigned long)); + + if (labs((long)(temp1_ulong-temp2_ulong)) > (long)options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(LIFORMAT,temp1_ulong,temp2_ulong,labs(temp1_ulong-temp2_ulong)); + } + nfound++; + } + mem1+=sizeof(unsigned long); + mem2+=sizeof(unsigned long); + if (options->n && nfound>=options->count) + return nfound; + } + + } } @@ -3288,102 +3304,102 @@ hsize_t diff_ulong(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_llong(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - long_long temp1_llong; - long_long temp2_llong; - hsize_t i; - static char fmt_llong[255]; - static char fmt_llongp[255]; - - if (!fmt_llong[0]) { - /* build default formats for long long types */ - sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - sprintf(fmt_llongp, "%%%sd %%%sd %%%sd %%%sd\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - } - + hsize_t nfound=0; /* number of differences found */ + long_long temp1_llong; + long_long temp2_llong; + hsize_t i; + static char fmt_llong[255]; + static char fmt_llongp[255]; - /* -d and !-p */ - if (options->d && !options->p) - { + if (!fmt_llong[0]) { + /* build default formats for long long types */ + sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + sprintf(fmt_llongp, "%%%sd %%%sd %%%sd %%%sd\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + } - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_llong, mem1, sizeof(long_long)); - memcpy(&temp2_llong, mem2, sizeof(long_long)); - if (labs( (long) (temp1_llong-temp2_llong)) > options->delta) - { - if ( print_data(options) ) + /* -d and !-p */ + if (options->d && !options->p) { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(fmt_llong,temp1_llong,temp2_llong,labs((long)(temp1_llong-temp2_llong))); - } - nfound++; - } - mem1+=sizeof(long_long); - mem2+=sizeof(long_long); - if (options->n && nfound>=options->count) - return nfound; - } - } + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_llong, mem1, sizeof(long_long)); + memcpy(&temp2_llong, mem2, sizeof(long_long)); - /* !-d and -p */ - else if (!options->d && options->p) - { + if (labs( (long) (temp1_llong-temp2_llong)) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(fmt_llong,temp1_llong,temp2_llong,labs((long)(temp1_llong-temp2_llong))); + } + nfound++; + } + mem1+=sizeof(long_long); + mem2+=sizeof(long_long); + if (options->n && nfound>=options->count) + return nfound; + } - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_llong, mem1, sizeof(long_long)); - memcpy(&temp2_llong, mem2, sizeof(long_long)); + } - if ( temp1_llong!=0 && labs((long)(1-temp2_llong/temp1_llong)) > options->percent ) - { - if ( print_data(options) ) + /* !-d and -p */ + else if (!options->d && options->p) { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(fmt_llongp,temp1_llong,temp2_llong,labs((long)(temp1_llong-temp2_llong)), - labs((long)(1-temp2_llong/temp1_llong))); - } - nfound++; - } - mem1+=sizeof(long_long); - mem2+=sizeof(long_long); - if (options->n && nfound>=options->count) - return nfound; - } + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_llong, mem1, sizeof(long_long)); + memcpy(&temp2_llong, mem2, sizeof(long_long)); - } + if ( temp1_llong!=0 && labs((long)(1-temp2_llong/temp1_llong)) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(fmt_llongp,temp1_llong,temp2_llong,labs((long)(temp1_llong-temp2_llong)), + labs((long)(1-temp2_llong/temp1_llong))); + } + nfound++; + } + mem1+=sizeof(long_long); + mem2+=sizeof(long_long); + if (options->n && nfound>=options->count) + return nfound; + } - /* -d and -p */ - else if ( options->d && options->p) - { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_llong, mem1, sizeof(long_long)); - memcpy(&temp2_llong, mem2, sizeof(long_long)); + } - if ( temp1_llong!=0 && labs((long)(1-temp2_llong/temp1_llong)) > options->percent && - labs((long)(temp1_llong-temp2_llong)) > options->delta ) - { - if ( print_data(options) ) + /* -d and -p */ + else if ( options->d && options->p) + { + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_llong, mem1, sizeof(long_long)); + memcpy(&temp2_llong, mem2, sizeof(long_long)); + + if ( temp1_llong!=0 && labs((long)(1-temp2_llong/temp1_llong)) > options->percent && + labs((long)(temp1_llong-temp2_llong)) > options->delta ) + { + if ( print_data(options) ) { print_pos(ph,1,i,acc,pos,rank,obj1,obj2); printf(SPACES); @@ -3441,107 +3457,107 @@ hsize_t diff_llong(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_ullong(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - int rank, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + int rank, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { - hsize_t nfound=0; /* number of differences found */ - unsigned long_long temp1_ullong; - unsigned long_long temp2_ullong; - hsize_t i; - static char fmt_ullong[255]; - static char fmt_ullongp[255]; - - if (!fmt_ullong[0]) { - /* build default formats for long long types */ - sprintf(fmt_ullong, "%%%su %%%su %%%su\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullongp, "%%%su %%%su %%%su %%%su\n", - H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); - } - + hsize_t nfound=0; /* number of differences found */ + unsigned long_long temp1_ullong; + unsigned long_long temp2_ullong; + hsize_t i; + static char fmt_ullong[255]; + static char fmt_ullongp[255]; - /* -d and !-p */ - if (options->d && !options->p) - { + if (!fmt_ullong[0]) { + /* build default formats for long long types */ + sprintf(fmt_ullong, "%%%su %%%su %%%su\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullongp, "%%%su %%%su %%%su %%%su\n", + H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH, H5_PRINTF_LL_WIDTH); + } - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); - memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); - if (labs((long)(temp1_ullong-temp2_ullong)) > options->delta) - { - if ( print_data(options) ) + /* -d and !-p */ + if (options->d && !options->p) { - print_pos(ph,0,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(fmt_ullong,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong))); - } - nfound++; - } - mem1+=sizeof(unsigned long_long); - mem2+=sizeof(unsigned long_long); - if (options->n && nfound>=options->count) - return nfound; - } - } + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); + memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); - /* !-d and -p */ - else if (!options->d && options->p) - { + if (labs((long)(temp1_ullong-temp2_ullong)) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(fmt_ullong,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong))); + } + nfound++; + } + mem1+=sizeof(unsigned long_long); + mem2+=sizeof(unsigned long_long); + if (options->n && nfound>=options->count) + return nfound; + } - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); - memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); + } - if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent ) - { - if ( print_data(options) ) + /* !-d and -p */ + else if (!options->d && options->p) { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(fmt_ullongp,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong)), - labs((long)(1-temp2_ullong/temp1_ullong))); - } - nfound++; - } - mem1+=sizeof(unsigned long_long); - mem2+=sizeof(unsigned long_long); - if (options->n && nfound>=options->count) - return nfound; - } + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); + memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); - } + if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(fmt_ullongp,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong)), + labs((long)(1-temp2_ullong/temp1_ullong))); + } + nfound++; + } + mem1+=sizeof(unsigned long_long); + mem2+=sizeof(unsigned long_long); + if (options->n && nfound>=options->count) + return nfound; + } - /* -d and -p */ - else if ( options->d && options->p) - { - for ( i = 0; i < nelmts; i++) - { - memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); - memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); + } - if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent && - labs((long)(temp1_ullong-temp2_ullong)) > options->delta ) - { - if ( print_data(options) ) + /* -d and -p */ + else if ( options->d && options->p) { - print_pos(ph,1,i,acc,pos,rank,obj1,obj2); - printf(SPACES); - printf(fmt_ullongp,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong)), - labs((long)(1-temp2_ullong/temp1_ullong))); + + for ( i = 0; i < nelmts; i++) + { + memcpy(&temp1_ullong, mem1, sizeof(unsigned long_long)); + memcpy(&temp2_ullong, mem2, sizeof(unsigned long_long)); + + if ( temp1_ullong!=0 && labs((long)(1-temp2_ullong/temp1_ullong)) > options->percent && + labs((long)(temp1_ullong-temp2_ullong)) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,i,acc,pos,rank,obj1,obj2); + printf(SPACES); + printf(fmt_ullongp,temp1_ullong,temp2_ullong,labs((long)(temp1_ullong-temp2_ullong)), + labs((long)(1-temp2_ullong/temp1_ullong))); } nfound++; } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index f5bd847..ac578c0 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -44,7 +44,6 @@ #define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) /* global variables */ -int indent; int compound_data; FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ @@ -429,7 +428,7 @@ h5tools_ncols(const char *s) *------------------------------------------------------------------------- */ static void -h5tools_simple_prefix(FILE *stream, const h5dump_t *info, +h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, int secnum) { h5tools_str_t prefix; @@ -542,7 +541,7 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, *------------------------------------------------------------------------- */ void -h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, +h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { @@ -554,7 +553,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, size_t ncols = 80; /*available output width */ h5tools_str_t buffer; /*string into which to render */ int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ + hsize_t curr_pos; /* total data element position */ int elmt_counter = 0;/*counts the # elements printed. *I (ptl?) needed something that *isn't going to get reset when a new @@ -673,9 +672,9 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, if (secnum) multiline++; - /* pass to the prefix the total position instead of the current - stripmine position i; this is necessary to print the array - indices */ + /* pass to the prefix in h5tools_simple_prefix the total position + instead of the current stripmine position i; this is necessary + to print the array indices */ curr_pos = ctx->sm_pos + i; h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); @@ -710,7 +709,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, *------------------------------------------------------------------------- */ static herr_t -h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, +h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_type, struct subset_t *sset, int indentlevel) { @@ -877,7 +876,7 @@ done: *------------------------------------------------------------------------- */ static int -h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, +h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_type, int indentlevel) { hid_t f_space; /*file data space */ @@ -1014,7 +1013,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, flags = (elmtno == 0) ? START_OF_DATA : 0; flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0; - /* initialize the current stripmine position; this is necessary to print the array + /* initialize the current stripmine position; this is necessary to print the array indices */ ctx.sm_pos = elmtno; @@ -1072,7 +1071,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, *------------------------------------------------------------------------- */ static int -h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, +h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel) { int i; /*counters */ @@ -1161,7 +1160,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, *------------------------------------------------------------------------- */ int -h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type, +h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _p_type, struct subset_t *sset, int indentlevel) { hid_t f_space; @@ -1169,7 +1168,7 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type, hid_t f_type; H5S_class_t space_type; int status = FAIL; - h5dump_t info_dflt; + h5tool_format_t info_dflt; /* Use default values */ if (!stream) @@ -1239,10 +1238,10 @@ done: *------------------------------------------------------------------------- */ int -h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type, +h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel) { - h5dump_t info_dflt; + h5tool_format_t info_dflt; /* Use default values */ if (!stream) diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 01bcca7..3400008 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -32,7 +32,7 @@ /* * Information about how to format output. */ -typedef struct h5dump_t { +typedef struct h5tool_format_t { /* * Fields associated with formatting numeric data. If a datatype matches * multiple formats based on its size, then the first applicable format @@ -321,102 +321,27 @@ typedef struct h5dump_t { /*escape non printable characters */ int do_escape; -} h5dump_t; - -typedef struct dump_header{ - const char *name; - const char *filebegin; - const char *fileend; - const char *bootblockbegin; - const char *bootblockend; - const char *groupbegin; - const char *groupend; - const char *datasetbegin; - const char *datasetend; - const char *attributebegin; - const char *attributeend; - const char *datatypebegin; - const char *datatypeend; - const char *dataspacebegin; - const char *dataspaceend; - const char *databegin; - const char *dataend; - const char *softlinkbegin; - const char *softlinkend; - const char *subsettingbegin; - const char *subsettingend; - const char *startbegin; - const char *startend; - const char *stridebegin; - const char *strideend; - const char *countbegin; - const char *countend; - const char *blockbegin; - const char *blockend; - - const char *fileblockbegin; - const char *fileblockend; - const char *bootblockblockbegin; - const char *bootblockblockend; - const char *groupblockbegin; - const char *groupblockend; - const char *datasetblockbegin; - const char *datasetblockend; - const char *attributeblockbegin; - const char *attributeblockend; - const char *datatypeblockbegin; - const char *datatypeblockend; - const char *dataspaceblockbegin; - const char *dataspaceblockend; - const char *datablockbegin; - const char *datablockend; - const char *softlinkblockbegin; - const char *softlinkblockend; - const char *strblockbegin; - const char *strblockend; - const char *enumblockbegin; - const char *enumblockend; - const char *structblockbegin; - const char *structblockend; - const char *vlenblockbegin; - const char *vlenblockend; - const char *subsettingblockbegin; - const char *subsettingblockend; - const char *startblockbegin; - const char *startblockend; - const char *strideblockbegin; - const char *strideblockend; - const char *countblockbegin; - const char *countblockend; - const char *blockblockbegin; - const char *blockblockend; - - const char *dataspacedescriptionbegin; - const char *dataspacedescriptionend; - const char *dataspacedimbegin; - const char *dataspacedimend; - -} dump_header; +} h5tool_format_t; typedef struct h5tools_context_t { - size_t cur_column; /*current column for output */ - size_t cur_elmt; /*current element/output line */ - int need_prefix; /*is line prefix needed? */ - int ndims; /*dimensionality */ - hsize_t p_min_idx[H5S_MAX_RANK]; /*min selected index */ - hsize_t p_max_idx[H5S_MAX_RANK]; /*max selected index */ - int prev_multiline; /*was prev datum multiline? */ - size_t prev_prefix_len;/*length of previous prefix */ - int continuation; /*continuation of previous data?*/ - hsize_t size_last_dim; /*the size of the last dimension, - *needed so we can break after each - *row */ - int indent_level; /*the number of times we need some - *extra indentation */ - int default_indent_level; /*this is used when the indent level gets changed */ - hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ - hsize_t pos[H5S_MAX_RANK]; /* matrix position */ - hsize_t sm_pos; /* current stripmine element position */ + size_t cur_column; /*current column for output */ + size_t cur_elmt; /*current element/output line */ + int need_prefix; /*is line prefix needed? */ + int ndims; /*dimensionality */ + hsize_t p_min_idx[H5S_MAX_RANK]; /*min selected index */ + hsize_t p_max_idx[H5S_MAX_RANK]; /*max selected index */ + int prev_multiline; /*was prev datum multiline? */ + size_t prev_prefix_len; /*length of previous prefix */ + int continuation; /*continuation of previous data?*/ + hsize_t size_last_dim; /*the size of the last dimension, + *needed so we can break after each + *row */ + int indent_level; /*the number of times we need some + *extra indentation */ + int default_indent_level; /*this is used when the indent level gets changed */ + hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ + hsize_t pos[H5S_MAX_RANK]; /* matrix position */ + hsize_t sm_pos; /* current stripmine element position */ } h5tools_context_t; /* a structure to hold the subsetting particulars for a dataset */ @@ -427,70 +352,12 @@ struct subset_t { hsize_t *block; }; -/*if we get a new program that needs to use the library add its name here*/ -typedef enum { - UNKNOWN = 0, - H5LS, - H5DUMP -} ProgType; - -/* taken from h5dump.h */ -#define ATTRIBUTE_DATA 0 -#define DATASET_DATA 1 -#define ENUM_DATA 2 - -#define COL 3 - -extern int indent; /*how far in to indent the line */ extern FILE *rawdatastream; /*output stream for raw data */ -/* taken from h5dump.h*/ -#define ATTRIBUTE "ATTRIBUTE" -#define BLOCK "BLOCK" -#define SUPER_BLOCK "SUPER_BLOCK" -#define COMPRESSION "COMPRESSION" -#define CONCATENATOR "//" -#define COMPLEX "COMPLEX" -#define COUNT "COUNT" -#define CSET "CSET" -#define CTYPE "CTYPE" -#define DATA "DATA" +/* Strings for output */ +#define GROUP "GROUP" #define DATASET "DATASET" -#define DATASPACE "DATASPACE" #define DATATYPE "DATATYPE" -#define EXTERNAL "EXTERNAL" -#define FILENO "FILENO" -#define GROUPNAME "GROUP" -#define HARDLINK "HARDLINK" -#define NLINK "NLINK" -#define OBJID "OBJECTID" -#define OBJNO "OBJNO" -#define S_SCALAR "SCALAR" -#define S_SIMPLE "SIMPLE" -#define SOFTLINK "SOFTLINK" -#define STORAGELAYOUT "STORAGELAYOUT" -#define START "START" -#define STRIDE "STRIDE" -#define STRSIZE "STRSIZE" -#define STRPAD "STRPAD" -#define SUBSET "SUBSET" -#define FILTERS "FILTERS" -#define DEFLATE "COMPRESSION DEFLATE" -#define DEFLATE_LEVEL "LEVEL" -#define SHUFFLE "PREPROCESSING SHUFFLE" -#define FLETCHER32 "CHECKSUM FLETCHER32" -#define SZIP "COMPRESSION SZIP" -#define STORAGE_LAYOUT "STORAGE_LAYOUT" -#define CONTIGUOUS "CONTIGUOUS" -#define COMPACT "COMPACT" -#define CHUNKED "CHUNKED" -#define EXTERNAL_FILE "EXTERNAL_FILE" -#define FILLVALUE "FILLVALUE" -#define FILE_CONTENTS "FILE_CONTENTS" - - -#define BEGIN "{" -#define END "}" /* Definitions of useful routines */ extern void h5tools_init(void); @@ -498,13 +365,13 @@ extern void h5tools_close(void); extern hid_t h5tools_fopen(const char *fname, const char *driver, char *drivername, size_t drivername_len, int argc, const char *argv[]); -extern int h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, +extern int h5tools_dump_dset(FILE *stream, const h5tool_format_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, +extern int h5tools_dump_mem(FILE *stream, const h5tool_format_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, +extern void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem); @@ -512,7 +379,7 @@ extern int h5tools_canreadf(const char* name, hid_t dcpl_id); extern int h5tools_can_encode(H5Z_filter_t filtn); -void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); - +void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); #endif /* H5TOOLS_H__ */ + diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index ddae7bb..01755fd 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -110,7 +110,7 @@ free_ref_path_info(void *item, void UNUSED *key, void UNUSED *operator_data/*in, { ref_path_node_t *node = (ref_path_node_t *)item; - HDfree(node->path); + HDfree((void *)node->path); HDfree(node); return(0); diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 26d2fdc..2729401 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -24,7 +24,7 @@ #include <string.h> #include "H5private.h" -#include "h5tools.h" /*for h5dump_t structure */ +#include "h5tools.h" /*for h5tool_format_t structure */ #include "h5tools_ref.h" #include "h5tools_str.h" /*function prototypes */ @@ -308,7 +308,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) *------------------------------------------------------------------------- */ char * -h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info, +h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, int ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx) { @@ -368,7 +368,7 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info, *------------------------------------------------------------------------- */ int -h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) +h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t *info) { hssize_t nblocks, npoints; hsize_t alloc_size; @@ -465,7 +465,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) *------------------------------------------------------------------------- */ void -h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch) +h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch) { if (info->str_locale == ESCAPE_HTML) { if (ch <= ' ' || ch > '~') @@ -568,7 +568,7 @@ h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch) *------------------------------------------------------------------------- */ char * -h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, +h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx) { size_t n, offset, size=0, nelmts, start; @@ -864,7 +864,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, /* Print object type and close object */ switch (otype) { case H5G_GROUP: - h5tools_str_append(str, GROUPNAME); + h5tools_str_append(str, GROUP); H5Gclose(obj); break; case H5G_DATASET: diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 0b6df60..19872a1 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -31,12 +31,12 @@ extern char *h5tools_str_append(h5tools_str_t *str, const char *fmt, ...); extern char *h5tools_str_reset(h5tools_str_t *str); extern char *h5tools_str_trunc(h5tools_str_t *str, size_t size); extern char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt); -extern char *h5tools_str_prefix(h5tools_str_t *str, const h5dump_t *info, +extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, int ndims, hsize_t min_idx[], - hsize_t max_idx[],h5tools_context_t *ctx); -extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5dump_t *); -extern void h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch); -extern char *h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, + hsize_t max_idx[], h5tools_context_t *ctx); +extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5tool_format_t *); +extern void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned char ch); +extern char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx); diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 0dd7815..ae2d1a6 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -592,7 +592,7 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, init_table(type_table); /* Init the find_objs_t */ - info->prefix = ""; + info->prefix = (char *)""; info->group_table = *group_table; info->type_table = *type_table; info->dset_table = *dset_table; diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 3e76250..ff4e488 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -17,14 +17,14 @@ #include "H5private.h" /* functions for traversal */ -int traverse( hid_t loc_id, +static int traverse( hid_t loc_id, const char *group_name, trav_table_t *table, trav_info_t *info, int *idx, int print); -herr_t get_nnames( hid_t loc_id, +static hssize_t get_nnames( hid_t loc_id, const char *group_name ); herr_t get_name_type( hid_t loc_id, @@ -159,36 +159,6 @@ void h5trav_freeinfo( trav_info_t *info, int nobjs ) /*------------------------------------------------------------------------- - * Function: count_names - * - * Purpose: operator function - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October 10, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -static herr_t count_names( hid_t loc_id, const char *name, void *op_data) -{ - - H5G_stat_t statbuf; - - if (H5Gget_objinfo( loc_id, name, 0, &statbuf) < 0 ) - return 1; - - (*(int *)op_data)++; - - /* Define a default zero value for return. This will cause the iterator to continue */ - return 0; -} - -/*------------------------------------------------------------------------- * Function: get_nnames * * Purpose: Counts the number of names in the group GROUP_NAME @@ -209,15 +179,24 @@ static herr_t count_names( hid_t loc_id, const char *name, void *op_data) *------------------------------------------------------------------------- */ -herr_t get_nnames( hid_t loc_id, const char *group_name ) +static hssize_t get_nnames( hid_t loc_id, const char *group_name ) { + hid_t gid; + hsize_t nobjs = 0; - int nobjs = 0; + /* Open the group */ + if((gid = H5Gopen(loc_id, group_name)) < 0) + return(-1); - if ( H5Giterate( loc_id, group_name, NULL, count_names, (void *)&nobjs ) < 0 ) - return -1; + /* Retrieve the number of objects in it */ + if(H5Gget_num_objs(gid, &nobjs) < 0) + return(-1); - return nobjs; + /* Close the group */ + if(H5Gclose(gid) < 0) + return(-1); + + return((hssize_t)nobjs); } @@ -242,7 +221,7 @@ static herr_t opget_info( hid_t loc_id, const char *name, void *op_data) H5G_stat_t statbuf; - if (H5Gget_objinfo( loc_id, name, 0, &statbuf) < 0 ) + if (H5Gget_objinfo( loc_id, name, FALSE, &statbuf) < 0 ) return -1; ((trav_info_t *)op_data)->type = statbuf.type; @@ -306,7 +285,7 @@ herr_t get_name_type( hid_t loc_id, *------------------------------------------------------------------------- */ -int traverse( hid_t loc_id, +static int traverse( hid_t loc_id, const char *group_name, trav_table_t *table, trav_info_t *info, @@ -323,7 +302,7 @@ int traverse( hid_t loc_id, int i, j; /* get the number of names */ - if (( n_names = get_nnames( loc_id, group_name )) < 0 ) + if (( n_names = (int)get_nnames( loc_id, group_name )) < 0 ) return -1; for ( i = 0; i < n_names; i++) @@ -332,13 +311,13 @@ int traverse( hid_t loc_id, return -1; /* allocate path buffer */ - path = (char*) HDmalloc(strlen(group_name) + strlen(name) + 2); + path = (char*) HDmalloc(HDstrlen(group_name) + HDstrlen(name) + 2); /* initialize path */ - strcpy( path, group_name ); - if ( strcmp(group_name,"/")!=0 ) - strcat( path, "/" ); - strcat( path, name ); + HDstrcpy( path, group_name ); + if ( HDstrcmp(group_name, "/") != 0 ) + HDstrcat( path, "/" ); + HDstrcat( path, name ); /* disable error reporting */ H5E_BEGIN_TRY { @@ -483,8 +462,6 @@ int traverse( hid_t loc_id, case H5G_LINK: { - char *targbuf=NULL; - /* increment */ inserted_objs++; @@ -493,12 +470,14 @@ int traverse( hid_t loc_id, if (statbuf.linklen>0) { - targbuf=malloc(statbuf.linklen); + char *targbuf=NULL; + + targbuf = HDmalloc(statbuf.linklen); + assert(targbuf); H5Gget_linkval(loc_id,path,statbuf.linklen,targbuf); if (print) printf(" %-10s %s -> %s\n", "link", path, targbuf); - if (targbuf) - free(targbuf); + free(targbuf); } else { @@ -511,6 +490,8 @@ int traverse( hid_t loc_id, default: + HDfprintf(stderr, "traverse: Unknown object!\n"); + return (-1); break; } diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index ca9755a..7198dd6 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -17,19 +17,14 @@ #include "hdf5.h" -#if 0 -#define H5_TRAV_DEBUG -#endif - - /*------------------------------------------------------------------------- * public struct to store name and type of an object * 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_LINK, Object is a symbolic link *------------------------------------------------------------------------- */ |