diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-09-13 15:44:56 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-09-13 15:44:56 (GMT) |
commit | 579284f422b6ed25b7a5f4a518c19740fff297c8 (patch) | |
tree | 564b2a7b4c13854a19ffaf465f94e6abd52d6340 | |
parent | 15d118faedd8e61e8ec2a715cf8fcea5b1afab35 (diff) | |
download | hdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.zip hdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.tar.gz hdf5-579284f422b6ed25b7a5f4a518c19740fff297c8.tar.bz2 |
[svn-r14144] Description:
Move H5Gget_objinfo() to deprecated symbols section and retarget
internal usage to H5Lget_info()/H5Oget_info().
Misc. other code cleanups...
Tested on:
FreeBSD/32 6.2 (duty)
FreeBSD/64 6.2 (liberty)
Linux/32 2.6 (kagiso)
Linux/64 2.6 (smirom)
AIX/32 5.3 (copper)
Solaris/32 2.10 (linew)
Mac OS X/32 10.4.10 (amazon)
65 files changed, 5012 insertions, 5822 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 0ea3923..b76d8b0 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -341,6 +341,7 @@ void CommonFG::move( const H5std_string& src, const H5std_string& dst ) const move( src.c_str(), dst.c_str() ); } +#ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- // Function: CommonFG::getObjinfo ///\brief Returns information about an object. @@ -402,6 +403,7 @@ void CommonFG::getObjinfo( const H5std_string& name, H5G_stat_t& statbuf ) const { getObjinfo( name.c_str(), statbuf ); } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- // Function: CommonFG::getLinkval diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index ed1c132..2a2e6cd 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -69,13 +69,6 @@ class H5_DLLCPP CommonFG { // Returns the number of objects in this group. hsize_t getNumObjs() const; - // Returns information about an HDF5 object, given by its name, - // at this location. - void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const char* name, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; - // Retrieves the name of an object in this group, given the // object's index. ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; @@ -87,6 +80,13 @@ class H5_DLLCPP CommonFG { H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; #ifndef H5_NO_DEPRECATED_SYMBOLS + // Returns information about an HDF5 object, given by its name, + // at this location. + void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; + void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; + void getObjinfo(const char* name, H5G_stat_t& statbuf) const; + void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; + // Iterates over the elements of this group - not implemented in // C++ style yet. int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index ca0516a..0d545d7 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -1026,7 +1026,9 @@ static void test_attr_dtype_shared() { int data=8; /* Data to write */ int rdata=0; /* Read read in */ +#ifndef H5_NO_DEPRECATED_SYMBOLS H5G_stat_t statbuf; /* Object's information */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ h5_stat_size_t filesize; /* Size of file after modifications */ // Output message about test being performed @@ -1054,9 +1056,11 @@ static void test_attr_dtype_shared() // Commit datatype to file dtype.commit(fid1, TYPE1_NAME); +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Create dataspace for dataset DataSpace dspace; @@ -1070,16 +1074,20 @@ static void test_attr_dtype_shared() // Create dataset DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace); +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Create attribute on dataset Attribute attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Close attribute attr.close(); @@ -1087,16 +1095,20 @@ static void test_attr_dtype_shared() // Delete attribute dset.removeAttr(ATTR1_NAME); +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Create attribute on dataset attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Write data into the attribute attr.write(PredType::NATIVE_INT,&data); @@ -1125,18 +1137,22 @@ static void test_attr_dtype_shared() delete attr2; delete dset2; +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Unlink the dataset fid1.unlink(DSET1_NAME); } // end of enclosing to test reference counts +#ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ // Unlink the named datatype fid1.unlink(TYPE1_NAME); diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 91a4c40..8c10623 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -138,7 +138,7 @@ herr_t H5DSattach_scale(hid_t did, hobj_ref_t ref_j; /* iterator reference */ hvl_t *buf; /* VL buffer to store in the attribute */ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - H5G_stat_t sb1, sb2; + H5O_info_t oi1, oi2; H5I_type_t it1, it2; int i, len; int found_ds=0; @@ -152,15 +152,15 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* get info for the dataset in the parameter list */ - if (H5Gget_objinfo(did,".",TRUE,&sb1)<0) + if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0) return FAIL; /* get info for the scale in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0) return FAIL; /* same object, not valid */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) return FAIL; /* get ID type */ @@ -329,18 +329,16 @@ herr_t H5DSattach_scale(hid_t did, goto out; /* get info for DS in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0) + if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0) goto out; /* get info for this DS */ - if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0) goto out; /* same object, so this DS scale is already in this DIM IDX */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) - { + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) found_ds = 1; - } /* close the dereferenced dataset */ if (H5Dclose(dsid_j)<0) @@ -596,14 +594,14 @@ herr_t H5DSdetach_scale(hid_t did, hid_t tid = -1; /* attribute type ID */ hid_t aid = -1; /* attribute ID */ int rank; /* rank of dataset */ - ds_list_t *dsbuf=NULL; /* array of attribute data in the DS pointing to the dataset */ - ds_list_t *dsbufn=NULL; /* array of attribute data in the DS pointing to the dataset */ - hsize_t *dims=NULL; /* dimension of the "REFERENCE_LIST" array */ + ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + ds_list_t *dsbufn = NULL; /* array of attribute data in the DS pointing to the dataset */ + hsize_t *dims = NULL; /* dimension of the "REFERENCE_LIST" array */ hobj_ref_t ref; /* reference to the DS */ - hvl_t *buf=NULL; /* VL buffer to store in the attribute */ + hvl_t *buf = NULL; /* VL buffer to store in the attribute */ unsigned i, j, jj; - H5G_stat_t sb1, sb2, sb3, sb4; - int found_dset=0, found_ds=0; + H5O_info_t oi1, oi2, oi3, oi4; + int found_dset = 0, found_ds = 0; H5I_type_t it1, it2; /*------------------------------------------------------------------------- @@ -615,15 +613,15 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* get info for the dataset in the parameter list */ - if (H5Gget_objinfo(did,".",TRUE,&sb1)<0) + if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0) return FAIL; /* get info for the scale in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0) return FAIL; /* same object, not valid */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) return FAIL; /* get ID type */ @@ -709,20 +707,17 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* get info for DS in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0) + if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0) goto out; /* get info for this DS */ - if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0) goto out; /* same object, reset */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) - { + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) { for(jj=j; jj<buf[idx].len-1; jj++) - { ((hobj_ref_t *)buf[idx].p)[jj] = ((hobj_ref_t *)buf[idx].p)[jj+1]; - } buf[idx].len--; found_ds = 1; @@ -794,21 +789,17 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* get info for dataset in the parameter list */ - if (H5Gget_objinfo(did,".",TRUE,&sb3)<0) + if(H5Oget_info(did, ".", &oi3, H5P_DEFAULT) < 0) goto out; /* get info for this dataset */ - if (H5Gget_objinfo(did_i,".",TRUE,&sb4)<0) + if(H5Oget_info(did_i, ".", &oi4, H5P_DEFAULT) < 0) goto out; /* same object, reset. we want to detach only for this DIM */ - if (!memcmp(&sb3.fileno, &sb4.fileno, sizeof(sb3.fileno)) && !memcmp(&sb3.objno, &sb4.objno, sizeof(sb3.objno)) - && (int)idx==dsbuf[i].dim_idx) - { + if(oi3.fileno == oi4.fileno && oi3.addr == oi4.addr && (int)idx == dsbuf[i].dim_idx) { for(jj=i; jj<nelmts-1; jj++) - { dsbuf[jj] = dsbuf[jj+1]; - } nelmts--; found_dset=1; @@ -966,7 +957,7 @@ htri_t H5DSis_attached(hid_t did, hvl_t *buf; /* VL buffer to store in the attribute */ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ hid_t did_i; /* dataset ID in REFERENCE_LIST */ - H5G_stat_t sb1, sb2, sb3, sb4; + H5O_info_t oi1, oi2, oi3, oi4; H5I_type_t it1, it2; int i; int found_dset=0, found_ds=0; @@ -980,15 +971,15 @@ htri_t H5DSis_attached(hid_t did, return FAIL; /* get info for the dataset in the parameter list */ - if (H5Gget_objinfo(did,".",TRUE,&sb1)<0) + if(H5Oget_info(did, ".", &oi1, H5P_DEFAULT) < 0) return FAIL; /* get info for the scale in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid, ".", &oi2, H5P_DEFAULT) < 0) return FAIL; /* same object, not valid */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) return FAIL; /* get ID type */ @@ -1062,18 +1053,16 @@ htri_t H5DSis_attached(hid_t did, goto out; /* get info for DS in the parameter list */ - if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0) + if(H5Oget_info(dsid, ".", &oi1, H5P_DEFAULT) < 0) goto out; /* get info for this DS */ - if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0) + if(H5Oget_info(dsid_j, ".", &oi2, H5P_DEFAULT) < 0) goto out; /* same object */ - if (!memcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) && !memcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) - { + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) found_ds = 1; - } /* close the dereferenced dataset */ if (H5Dclose(dsid_j)<0) @@ -1150,18 +1139,16 @@ htri_t H5DSis_attached(hid_t did, goto out; /* get info for dataset in the parameter list */ - if (H5Gget_objinfo(did,".",TRUE,&sb3)<0) + if(H5Oget_info(did, ".", &oi3, H5P_DEFAULT) < 0) goto out; /* get info for this dataset */ - if (H5Gget_objinfo(did_i,".",TRUE,&sb4)<0) + if(H5Oget_info(did_i, ".", &oi4, H5P_DEFAULT) < 0) goto out; /* same object */ - if (!memcmp(&sb3.fileno, &sb4.fileno, sizeof(sb3.fileno)) && !memcmp(&sb3.objno, &sb4.objno, sizeof(sb3.objno)) - && (int)idx==dsbuf[i].dim_idx) { + if(oi3.fileno == oi4.fileno && oi3.addr == oi4.addr && (int)idx==dsbuf[i].dim_idx) found_dset=1; - } /* if */ /* close the dereferenced dataset */ if (H5Dclose(did_i)<0) diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 10977a7..d7f720a 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -38,13 +38,11 @@ int indent = 0; * *------------------------------------------------------------------------- */ - -herr_t H5LT_open_id( hid_t loc_id, - const char *obj_name, - int obj_type ); - -herr_t H5LT_close_id( hid_t obj_id, - int obj_type ); +static herr_t H5LT_get_attribute_mem(hid_t loc_id, + const char *obj_name, + const char *attr_name, + hid_t mem_type_id, + void *data); /*------------------------------------------------------------------------- * @@ -1121,16 +1119,10 @@ herr_t H5LTset_attribute_string( hid_t loc_id, hid_t attr_id; hid_t obj_id; int has_attr; - H5G_stat_t statbuf; size_t attr_size; - - /* Get the type of object */ - if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0) - return -1; - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the attribute */ @@ -1176,14 +1168,14 @@ herr_t H5LTset_attribute_string( hid_t loc_id, goto out; /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) + if(H5Oclose(obj_id) < 0) return -1; return 0; out: - H5LT_close_id( obj_id, statbuf.type ); + H5Oclose(obj_id); return -1; } @@ -1219,14 +1211,9 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, hid_t obj_id, sid, attr_id; hsize_t dim_size=size; int has_attr; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the data space for the attribute. */ @@ -1260,99 +1247,16 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, goto out; /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) + if(H5Oclose(obj_id) < 0 ) return -1; return 0; out: - H5LT_close_id( obj_id, statbuf.type ); + H5Oclose(obj_id); return -1; } -/*------------------------------------------------------------------------- - * Function: H5LT_open_id - * - * Purpose: Private function used by H5LT_set_attribute_* - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - *------------------------------------------------------------------------- - */ - -herr_t H5LT_open_id( hid_t loc_id, - const char *obj_name, - int obj_type /*basic object type*/ ) -{ - hid_t obj_id = -1; - - switch(obj_type) { - case H5G_DATASET: - /* Open the dataset. */ - if((obj_id = H5Dopen(loc_id, obj_name)) < 0) - return -1; - break; - - case H5G_GROUP: - /* Open the group. */ - if((obj_id = H5Gopen2(loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; - break; - - default: - return -1; - } - - return obj_id; -} - - -/*------------------------------------------------------------------------- - * Function: H5LT_close_id - * - * Purpose: Private function used by H5LT_set_attribute_* - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - *------------------------------------------------------------------------- - */ - -herr_t H5LT_close_id( hid_t obj_id, - int obj_type /*basic object type*/ ) -{ - switch ( obj_type ) - { - case H5G_DATASET: - /* Close the dataset. */ - if ( H5Dclose( obj_id ) < 0 ) - return -1; - break; - - case H5G_GROUP: - /* Close the group. */ - if ( H5Gclose( obj_id ) < 0 ) - return -1; - break; - - default: - return -1; - } - - return 0; -} - /*------------------------------------------------------------------------- * Function: H5LTset_attribute_char @@ -1825,21 +1729,16 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id, { hid_t attr_id; hid_t sid; - H5G_stat_t statbuf; hid_t obj_id; - /* Get the type of object */ - if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0) - return -1; - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 ) { - H5LT_close_id( obj_id, statbuf.type ); + H5Oclose(obj_id); return -1; } @@ -1860,14 +1759,14 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id, goto out;; /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) + if(H5Oclose(obj_id) < 0 ) return -1; return 0; out: H5Aclose( attr_id ); - H5LT_close_id( obj_id, statbuf.type ); + H5Oclose(obj_id); return -1; } @@ -1897,21 +1796,16 @@ herr_t H5LTget_attribute_info( hid_t loc_id, hid_t attr_id; hid_t tid; hid_t sid; - H5G_stat_t statbuf; hid_t obj_id; - /* Get the type of object */ - if (H5Gget_objinfo( loc_id, obj_name, 1, &statbuf )<0) - return -1; - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 ) { - H5LT_close_id( obj_id, statbuf.type ); + H5Oclose(obj_id); return -1; } @@ -1945,15 +1839,15 @@ herr_t H5LTget_attribute_info( hid_t loc_id, goto out; /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) + if(H5Oclose(obj_id) < 0 ) return -1; return 0; out: - H5Tclose( tid ); - H5Aclose( attr_id ); - H5LT_close_id( obj_id, statbuf.type ); + H5Tclose(tid); + H5Aclose(attr_id); + H5Oclose(obj_id); return -1; } @@ -2695,17 +2589,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id, const char *attr_name, char *data ) { - /* identifiers */ hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) + if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Get the attribute */ @@ -2713,7 +2601,7 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) + if(H5Oclose(obj_id) < 0) return -1; return 0; @@ -2742,29 +2630,11 @@ herr_t H5LTget_attribute_char( hid_t loc_id, const char *attr_name, char *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_CHAR, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } /*------------------------------------------------------------------------- @@ -2789,29 +2659,11 @@ herr_t H5LTget_attribute_uchar( hid_t loc_id, const char *attr_name, unsigned char *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_UCHAR, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -2838,29 +2690,11 @@ herr_t H5LTget_attribute_short( hid_t loc_id, const char *attr_name, short *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_SHORT, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } /*------------------------------------------------------------------------- @@ -2885,29 +2719,11 @@ herr_t H5LTget_attribute_ushort( hid_t loc_id, const char *attr_name, unsigned short *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_USHORT, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -2934,29 +2750,11 @@ herr_t H5LTget_attribute_int( hid_t loc_id, const char *attr_name, int *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_INT, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } /*------------------------------------------------------------------------- @@ -2981,29 +2779,11 @@ herr_t H5LTget_attribute_uint( hid_t loc_id, const char *attr_name, unsigned int *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_UINT, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -3030,30 +2810,13 @@ herr_t H5LTget_attribute_long( hid_t loc_id, const char *attr_name, long *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_LONG, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } + /*------------------------------------------------------------------------- * Function: H5LTget_attribute_long_long * @@ -3076,29 +2839,11 @@ herr_t H5LTget_attribute_long_long( hid_t loc_id, const char *attr_name, long_long *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_LLONG, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -3124,29 +2869,11 @@ herr_t H5LTget_attribute_ulong( hid_t loc_id, const char *attr_name, unsigned long *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_ULONG, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -3174,29 +2901,11 @@ herr_t H5LTget_attribute_float( hid_t loc_id, const char *attr_name, float *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_FLOAT, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -3224,29 +2933,11 @@ herr_t H5LTget_attribute_double( hid_t loc_id, const char *attr_name, double *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, H5T_NATIVE_DOUBLE, data ) < 0 ) - return -1; - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; - + return 0; } @@ -3275,31 +2966,11 @@ herr_t H5LTget_attribute( hid_t loc_id, hid_t mem_type_id, void *data ) { + /* Get the attribute */ + if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) + return -1; - /* identifiers */ - hid_t obj_id; - H5G_stat_t statbuf; - - /* Get the type of object */ - if (H5Gget_objinfo(loc_id, obj_name, 1, &statbuf)<0) - return -1; - - /* Open the object */ - if ((obj_id = H5LT_open_id( loc_id, obj_name, statbuf.type )) < 0) - return -1; - - /* Get the attribute */ - if ( H5LT_get_attribute_mem( obj_id, attr_name, mem_type_id, data ) < 0 ) - { - H5LT_close_id( obj_id, statbuf.type ); - return -1; - } - - /* Close the object */ - if ( H5LT_close_id( obj_id, statbuf.type ) < 0 ) - return -1; - - return 0; + return 0; } @@ -3328,29 +2999,41 @@ herr_t H5LTget_attribute( hid_t loc_id, */ -herr_t H5LT_get_attribute_mem( hid_t obj_id, +static herr_t H5LT_get_attribute_mem(hid_t loc_id, + const char *obj_name, const char *attr_name, hid_t mem_type_id, - void *data ) + void *data) { + /* identifiers */ + hid_t obj_id = -1; + hid_t attr_id = -1; - /* identifiers */ - hid_t attr_id; + /* Open the object */ + if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + goto out; - if ( ( attr_id = H5Aopen_name( obj_id, attr_name ) ) < 0 ) - return -1; + if((attr_id = H5Aopen_name(obj_id, attr_name)) < 0) + goto out; - if ( H5Aread( attr_id, mem_type_id, data ) < 0 ) - goto out; + if(H5Aread(attr_id, mem_type_id, data) < 0) + goto out; - if ( H5Aclose( attr_id ) < 0 ) - return -1; + if(H5Aclose(attr_id) < 0) + goto out; + attr_id = -1; - return 0; + /* Close the object */ + if(H5Oclose(obj_id) < 0) + goto out; + obj_id = -1; + + return 0; out: - H5Aclose( attr_id ); - return -1; + if(attr_id > 0) + H5Aclose(attr_id); + return -1; } /*------------------------------------------------------------------------- diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h index 51bcbce..c51ee7c 100644 --- a/hl/src/H5LTprivate.h +++ b/hl/src/H5LTprivate.h @@ -27,11 +27,6 @@ *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LT_get_attribute_mem( hid_t obj_id, - const char *attr_name, - hid_t mem_type_id, - void *data ); - H5_HLDLL herr_t H5LT_get_attribute_disk( hid_t obj_id, const char *attr_name, void *data ); diff --git a/src/H5Epublic.h b/src/H5Epublic.h index e690eaa..7b716ef 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -63,11 +63,9 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; /* * One often needs to temporarily disable automatic error reporting when - * trying something that's likely or expected to fail. For instance, to - * determine if an object exists one can call H5Gget_objinfo() which will fail if - * the object doesn't exist. The code to try can be nested between calls to - * H5Eget_auto() and H5Eset_auto(), but it's easier just to use this macro - * like: + * trying something that's likely or expected to fail. The code to try can + * be nested between calls to H5Eget_auto() and H5Eset_auto(), but it's + * easier just to use this macro like: * H5E_BEGIN_TRY { * ...stuff here that's likely to fail... * } H5E_END_TRY; @@ -87,7 +87,7 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); /* * Global count of the number of H5FD_t's handed out. This is used as a * "serial number" for files that are currently open and is used for the - * 'fileno' field in H5G_stat_t. However, if a VFL driver is not able + * 'fileno' field in H5O_info_t. However, if a VFL driver is not able * to detect whether two files are the same, a file that has been opened * by H5Fopen more than once with that VFL driver will have two different * serial numbers. :-/ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index bf90f1e..54e2cd3 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -57,6 +57,7 @@ /* Local Typedefs */ /******************/ +#ifndef H5_NO_DEPRECATED_SYMBOLS /* User data for path traversal routine for getting object info */ typedef struct { H5G_stat_t *statbuf; /* Stat buffer about object */ @@ -75,17 +76,16 @@ typedef struct { /* Local Prototypes */ /********************/ -#ifndef H5_NO_DEPRECATED_SYMBOLS static herr_t H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name); static herr_t H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ static herr_t H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); static herr_t H5G_get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/, hid_t dxpl_id); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /*********************/ @@ -837,50 +837,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_num_objs() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - -/*------------------------------------------------------------------------- - * Function: H5Gget_objtype_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. - * - * Note: Deprecated in favor of H5Lget_info/H5Oget_info - * - * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * Failure: H5G_UNKNOWN - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) -{ - H5G_loc_t loc; /* Object location */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_obj_t ret_value; - - FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN) - H5TRACE2("Go", "ih", loc_id, idx); - - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") - - /* Call internal function*/ - if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_dxpl_id)) == H5G_UNKNOWN) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object type") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_objtype_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objinfo @@ -1072,3 +1028,47 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_objinfo() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + +/*------------------------------------------------------------------------- + * Function: H5Gget_objtype_by_idx + * + * Purpose: Returns the type of objects in the group by giving index. + * + * Note: Deprecated in favor of H5Lget_info/H5Oget_info + * + * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) + * Failure: H5G_UNKNOWN + * + * Programmer: Raymond Lu + * Nov 20, 2002 + * + *------------------------------------------------------------------------- + */ +H5G_obj_t +H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) +{ + H5G_loc_t loc; /* Object location */ + H5O_type_t obj_type; /* Type of object at location */ + H5G_obj_t ret_value; + + FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN) + H5TRACE2("Go", "ih", loc_id, idx); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") + if(H5O_obj_type(loc.oloc, &obj_type, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_GROUP) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") + + /* Call internal function*/ + if((ret_value = H5G_obj_get_type_by_idx(loc.oloc, idx, H5AC_ind_dxpl_id)) == H5G_UNKNOWN) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object type") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_objtype_by_idx() */ + diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 6f4bc00..510c920 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -39,14 +39,6 @@ /* Public Macros */ /*****************/ -/* Deprecated macros, for backward compatibility */ - -/* Macros for types of objects in a group (see H5G_obj_t definition) */ -#define H5G_NTYPES 256 /* Max possible number of types */ -#define H5G_NLIBTYPES 8 /* Number of internal types */ -#define H5G_NUSERTYPES (H5G_NTYPES-H5G_NLIBTYPES) -#define H5G_USERTYPE(X) (8+(X)) /* User defined types */ - #ifdef __cplusplus extern "C" { #endif @@ -71,38 +63,6 @@ typedef struct H5G_info_t { int64_t max_corder; /* Current max. creation order value for group */ } H5G_info_t; -/* Deprecated typedefs, for backward compatibility */ - -/* - * An object has a certain type. The first few numbers are reserved for use - * internally by HDF5. Users may add their own types with higher values. The - * values are never stored in the file -- they only exist while an - * application is running. An object may satisfy the `isa' function for more - * than one type. - */ -typedef enum H5G_obj_t { - H5G_UNKNOWN = -1, /* Unknown object type */ - 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 */ - H5G_UDLINK, /* Object is a user-defined link */ - H5G_RESERVED_5, /* Reserved for future use */ - H5G_RESERVED_6, /* Reserved for future use */ - H5G_RESERVED_7 /* Reserved for future use */ -} H5G_obj_t; - -/* Information about an object */ -typedef struct H5G_stat_t { - unsigned long fileno[2]; /*file number */ - unsigned long objno[2]; /*object number */ - unsigned nlink; /*number of hard links to object*/ - H5G_obj_t type; /*basic object type */ - time_t mtime; /*modification time */ - size_t linklen; /*symbolic link value length */ - H5O_stat_t ohdr; /* Object header information */ -} H5G_stat_t; - /********************/ /* Public Variables */ /********************/ @@ -128,11 +88,28 @@ H5_DLL herr_t H5Gclose(hid_t group_id); * * Use of these functions and variables is deprecated. */ +/* + * An object has a certain type. The first few numbers are reserved for use + * internally by HDF5. Users may add their own types with higher values. The + * values are never stored in the file -- they only exist while an + * application is running. An object may satisfy the `isa' function for more + * than one type. + */ +typedef enum H5G_obj_t { + H5G_UNKNOWN = -1, /* Unknown object type */ + 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 */ + H5G_UDLINK, /* Object is a user-defined link */ + H5G_RESERVED_5, /* Reserved for future use */ + H5G_RESERVED_6, /* Reserved for future use */ + H5G_RESERVED_7 /* Reserved for future use */ +} H5G_obj_t; + H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, size_t size); H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); -H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -148,12 +125,29 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, #define H5G_LINK_SOFT H5L_TYPE_SOFT #define H5G_link_t H5L_type_t +/* Macros for types of objects in a group (see H5G_obj_t definition) */ +#define H5G_NTYPES 256 /* Max possible number of types */ +#define H5G_NLIBTYPES 8 /* Number of internal types */ +#define H5G_NUSERTYPES (H5G_NTYPES - H5G_NLIBTYPES) +#define H5G_USERTYPE(X) (8 + (X)) /* User defined types */ + /* Typedefs */ /* Prototype for H5Giterate() operator */ typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data); +/* Information about an object */ +typedef struct H5G_stat_t { + unsigned long fileno[2]; /*file number */ + unsigned long objno[2]; /*object number */ + unsigned nlink; /*number of hard links to object*/ + H5G_obj_t type; /*basic object type */ + time_t mtime; /*modification time */ + size_t linklen; /*symbolic link value length */ + H5O_stat_t ohdr; /* Object header information */ +} H5G_stat_t; + /* Function prototypes */ H5_DLL hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint); @@ -175,6 +169,8 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); +H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, + hbool_t follow_link, H5G_stat_t *statbuf/*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 17fe139..41e9f18 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -77,20 +77,14 @@ /*******************/ /* Public Typedefs */ /*******************/ -/* A struct that's part of the H5G_stat_t routine (deprecated) */ -typedef struct H5O_stat_t { - hsize_t size; /* Total size of object header in file */ - hsize_t free; /* Free space within object header */ - unsigned nmesgs; /* Number of object header messages */ - unsigned nchunks; /* Number of object header chunks */ -} H5O_stat_t; /* Types of objects in file */ typedef enum H5O_type_t { H5O_TYPE_UNKNOWN = -1, /* Unknown object type */ H5O_TYPE_GROUP, /* Object is a group */ H5O_TYPE_DATASET, /* Object is a dataset */ - H5O_TYPE_NAMED_DATATYPE /* Object is a named data type */ + H5O_TYPE_NAMED_DATATYPE, /* Object is a named data type */ + H5O_TYPE_NTYPES /* Number of different object types (must be last!) */ } H5O_type_t; /* Information struct for object (for H5Oget_info/H5Oget_info_by_idx) */ @@ -162,6 +156,28 @@ H5_DLL ssize_t H5Oget_comment(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id); H5_DLL herr_t H5Oclose(hid_t object_id); +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* Macros */ + +/* Typedefs */ + +/* A struct that's part of the H5G_stat_t routine (deprecated) */ +typedef struct H5O_stat_t { + hsize_t size; /* Total size of object header in file */ + hsize_t free; /* Free space within object header */ + unsigned nmesgs; /* Number of object header messages */ + unsigned nchunks; /* Number of object header chunks */ +} H5O_stat_t; + +/* Function prototypes */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + #ifdef __cplusplus } #endif diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 3581863..5e8a7a4 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -165,11 +165,10 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") for(i = 0; i < sdim->rank; i++) { H5F_DECODE_LENGTH(f, p, sdim->size[i]); -#ifndef H5_HAVE_LARGE_HSIZET + /* Rudimentary check for overflow of the dimension size */ if(sdim->size[i] == 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, NULL, "invalid size detected") -#endif /* H5_HAVE_LARGE_HSIZET */ } /* end for */ if(flags & H5S_VALID_MAX) { diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 92dfdfc..7094fe0 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1026,7 +1026,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * the addresses in the file must be) and just get out now, there * is no need to convert the object reference. Yes, this is * icky and non-portable, but I can't think of a better way to - * support allowing the objno in the H5G_stat_t struct and the + * support allowing the objno in the H5O_info_t struct and the * hobj_ref_t type to be compared directly without introducing a * "native" hobj_ref_t datatype and I think that would break a * lot of existing programs. -QAK diff --git a/src/H5private.h b/src/H5private.h index 184ef7c..dad4e13 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -412,13 +412,12 @@ # define SIZET_MAX ((size_t)(ssize_t)(-1)) # define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) #endif -#ifdef H5_HAVE_LARGE_HSIZET + +/* + * Maximum & minimum values for our typedefs. + */ #define HSIZET_MAX ((hsize_t)ULLONG_MAX) #define HSSIZET_MAX ((hssize_t)LLONG_MAX) -#else /* H5_HAVE_LARGE_HSIZET */ -#define HSIZET_MAX ((hsize_t)SIZET_MAX) -#define HSSIZET_MAX ((hssize_t)SSIZET_MAX) -#endif /* H5_HAVE_LARGE_HSIZET */ #define HSSIZET_MIN (~(HSSIZET_MAX)) /* diff --git a/src/H5public.h b/src/H5public.h index 6b66d7a..00ca6ab 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -148,23 +148,17 @@ typedef long_long ssize_t; #endif /* - * The sizes of file objects have their own types defined here. If large - * sizes are enabled then use a 64-bit data type, otherwise use the size of - * memory objects. + * The sizes of file objects have their own types defined here, use a 64-bit + * type. */ -#ifdef H5_HAVE_LARGE_HSIZET -# if H5_SIZEOF_LONG_LONG>=8 +#if H5_SIZEOF_LONG_LONG >= 8 typedef unsigned long_long hsize_t; typedef signed long_long hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG # define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG -# endif -#else /* H5_HAVE_LARGE_HSIZET */ -typedef size_t hsize_t; -typedef ssize_t hssize_t; -# define H5_SIZEOF_HSIZE_T H5_SIZEOF_SIZE_T -# define H5_SIZEOF_HSSIZE_T H5_SIZEOF_SIZE_T -#endif /* H5_HAVE_LARGE_HSIZET */ +#else +# error "nothing appropriate for hsize_t" +#endif /* * File addresses have their own types. diff --git a/src/H5trace.c b/src/H5trace.c index 77e1984..7c2587d 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -695,6 +695,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) } break; +#ifndef H5_NO_DEPRECATED_SYMBOLS case 's': if(ptr) { if(vp) @@ -707,6 +708,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) fprintf(out, "0x%lx", (unsigned long)statbuf); } break; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ default: fprintf(out, "BADTYPE(G%c)", type[1]); diff --git a/test/dtypes.c b/test/dtypes.c index 75dde75..2783f2d 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -4362,7 +4362,7 @@ test_latest(void) hid_t file = (-1); /* File ID */ hid_t tid1 = (-1), tid2 = (-1); /* Datatype ID */ hid_t fapl = (-1); /* File access property list */ - H5G_stat_t sb; /* Stat buffer for committed datatype */ + H5O_info_t oi; /* Stat buffer for committed datatype */ hsize_t old_dtype_oh_size; /* Size of object header with "old" format */ hsize_t new_dtype_oh_size; /* Size of object header with "new" format */ char filename[1024]; /* Buffer for filename */ @@ -4396,9 +4396,9 @@ test_latest(void) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0) + if(H5Oget_info(file, compnd_type, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - old_dtype_oh_size = sb.ohdr.size; + old_dtype_oh_size = oi.hdr.space.total; /* Close datatype */ if(H5Tclose(tid2) < 0) @@ -4421,11 +4421,11 @@ test_latest(void) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0) + if(H5Oget_info(file, compnd_type, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check that the object header info is still the same */ - if(old_dtype_oh_size != sb.ohdr.size) + if(old_dtype_oh_size != oi.hdr.space.total) TEST_ERROR /* Close datatype */ @@ -4457,9 +4457,9 @@ test_latest(void) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0) + if(H5Oget_info(file, compnd_type, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - new_dtype_oh_size = sb.ohdr.size; + new_dtype_oh_size = oi.hdr.space.total; /* Check that the new format is smaller than the old format */ if(old_dtype_oh_size <= new_dtype_oh_size) @@ -4486,11 +4486,11 @@ test_latest(void) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0) + if(H5Oget_info(file, compnd_type, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check that the object header info is still the same */ - if(new_dtype_oh_size != sb.ohdr.size) + if(new_dtype_oh_size != oi.hdr.space.total) TEST_ERROR /* Close datatype */ diff --git a/test/istore.c b/test/istore.c index 8764643..657e150 100644 --- a/test/istore.c +++ b/test/istore.c @@ -47,11 +47,7 @@ const char *FILENAME[] = { #define TEST_DATATYPE H5T_NATIVE_UCHAR #define TEST_CHUNK_SIZE 50 -#ifdef H5_HAVE_LARGE_HSIZET #define TEST_SPARSE_SIZE 1000000 -#else /* H5_HAVE_LARGE_HSIZET */ -#define TEST_SPARSE_SIZE 1200 -#endif /* H5_HAVE_LARGE_HSIZET */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; hsize_t zero[H5O_LAYOUT_NDIMS]; diff --git a/test/links.c b/test/links.c index fb6fdb6..3ef66a0 100644 --- a/test/links.c +++ b/test/links.c @@ -126,32 +126,32 @@ mklinks(hid_t fapl, hbool_t new_format) /* Create a file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if ((scalar=H5Screate_simple (1, size, size)) < 0) TEST_ERROR + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((scalar = H5Screate_simple(1, size, size)) < 0) TEST_ERROR /* Create a group */ if((grp = H5Gcreate2(file, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose (grp) < 0) TEST_ERROR + if(H5Gclose(grp) < 0) TEST_ERROR /* Create a dataset */ - if ((d1=H5Dcreate (file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Dclose (d1) < 0) TEST_ERROR + if((d1 = H5Dcreate(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Dclose(d1) < 0) TEST_ERROR /* Create a hard link */ - if (H5Lcreate_hard (file, "d1", H5L_SAME_LOC, "grp1/hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_hard(file, "d1", H5L_SAME_LOC, "grp1/hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create a symbolic link */ - if (H5Lcreate_soft ("/d1", file, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/d1", file, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create a symbolic link to something that doesn't exist */ - if (H5Lcreate_soft ("foobar", file, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("foobar", file, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create a recursive symbolic link */ - if (H5Lcreate_soft ("/grp1/recursive", file, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lcreate_soft("/grp1/recursive", file, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close */ - if (H5Sclose (scalar) < 0) TEST_ERROR - if (H5Fclose (file) < 0) TEST_ERROR + if(H5Sclose(scalar) < 0) TEST_ERROR + if(H5Fclose(file) < 0) TEST_ERROR PASSED(); return 0; @@ -194,12 +194,12 @@ new_links(hid_t fapl, hbool_t new_format) /* Create two files */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if ((scalar=H5Screate_simple (1, size, size)) < 0) TEST_ERROR + if((scalar = H5Screate_simple (1, size, size)) < 0) TEST_ERROR /* Create two groups in each file */ if((grp1_a = H5Gcreate2(file_a, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -208,8 +208,8 @@ new_links(hid_t fapl, hbool_t new_format) if((grp2_b = H5Gcreate2(file_b, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create datasets */ - if((dset1=H5Dcreate(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR - if((dset2=H5Dcreate(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset1 = H5Dcreate(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset2 = H5Dcreate(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT)) < 0) TEST_ERROR /* Create links within a file. Both of source and destination use * H5L_SAME_LOC. Both hard and soft links should fail. */ @@ -232,30 +232,30 @@ new_links(hid_t fapl, hbool_t new_format) if(H5Lcreate_hard(grp1_a, "dataset2", grp2_a, "hard2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close dataspace and files */ - if (H5Sclose (scalar) < 0) TEST_ERROR - if (H5Dclose(dset1) < 0) TEST_ERROR - if (H5Dclose(dset2) < 0) TEST_ERROR - if (H5Gclose (grp1_a) < 0) TEST_ERROR - if (H5Gclose (grp2_a) < 0) TEST_ERROR - if (H5Gclose (grp1_b) < 0) TEST_ERROR - if (H5Gclose (grp2_b) < 0) TEST_ERROR - if (H5Fclose (file_a) < 0) TEST_ERROR - if (H5Fclose (file_b) < 0) TEST_ERROR + if(H5Sclose(scalar) < 0) TEST_ERROR + if(H5Dclose(dset1) < 0) TEST_ERROR + if(H5Dclose(dset2) < 0) TEST_ERROR + if(H5Gclose(grp1_a) < 0) TEST_ERROR + if(H5Gclose(grp2_a) < 0) TEST_ERROR + if(H5Gclose(grp1_b) < 0) TEST_ERROR + if(H5Gclose(grp2_b) < 0) TEST_ERROR + if(H5Fclose(file_a) < 0) TEST_ERROR + if(H5Fclose(file_b) < 0) TEST_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Sclose (scalar); - H5Dclose (dset1); - H5Dclose (dset2); - H5Gclose (grp1_a); - H5Gclose (grp2_a); - H5Gclose (grp1_b); - H5Gclose (grp2_b); - H5Fclose (file_a); - H5Fclose (file_b); + H5Sclose(scalar); + H5Dclose(dset1); + H5Dclose(dset2); + H5Gclose(grp1_a); + H5Gclose(grp2_a); + H5Gclose(grp1_b); + H5Gclose(grp2_b); + H5Fclose(file_a); + H5Fclose(file_b); } H5E_END_TRY; return -1; } @@ -282,7 +282,8 @@ static int cklinks(hid_t fapl, hbool_t new_format) { hid_t file; - H5G_stat_t sb1, sb2; + H5O_info_t oinfo1, oinfo2; + H5L_info_t linfo2; char linkval[LINK_BUF_SIZE]; char filename[NAME_BUF_SIZE]; herr_t status; @@ -297,14 +298,14 @@ cklinks(hid_t fapl, hbool_t new_format) if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Hard link */ - if(H5Gget_objinfo(file, "d1", TRUE, &sb1) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file, "grp1/hard", TRUE, &sb2) < 0) FAIL_STACK_ERROR - if(H5G_DATASET != sb2.type) { + if(H5Oget_info(file, "d1", &oinfo1, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file, "grp1/hard", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { + if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { H5_FAILED(); puts(" Hard link test failed. Link seems not to point to the "); puts(" expected file location."); @@ -314,13 +315,13 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR /* Symbolic link */ - if(H5Gget_objinfo(file, "grp1/soft", TRUE, &sb2) < 0) FAIL_STACK_ERROR - if(H5G_DATASET != sb2.type) { + if(H5Oget_info(file, "grp1/soft", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { + if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { H5_FAILED(); puts(" Soft link test failed. Link seems not to point to the "); puts(" expected file location."); @@ -336,15 +337,15 @@ cklinks(hid_t fapl, hbool_t new_format) /* Dangling link */ H5E_BEGIN_TRY { - status = H5Gget_objinfo(file, "grp1/dangle", TRUE, &sb2); + status = H5Oget_info(file, "grp1/dangle", &oinfo2, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { H5_FAILED(); - puts(" H5Gget_objinfo() should have failed for a dangling link."); + puts(" H5Oget_info() should have failed for a dangling link."); TEST_ERROR } /* end if */ - if(H5Gget_objinfo(file, "grp1/dangle", FALSE, &sb2) < 0) FAIL_STACK_ERROR - if(H5G_LINK != sb2.type) { + if(H5Lget_info(file, "grp1/dangle", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5L_TYPE_SOFT != linfo2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR @@ -363,15 +364,15 @@ cklinks(hid_t fapl, hbool_t new_format) /* Recursive link */ H5E_BEGIN_TRY { - status = H5Gget_objinfo(file, "grp1/recursive", TRUE, &sb2); + status = H5Oget_info(file, "grp1/recursive", &oinfo2, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { H5_FAILED(); - puts(" H5Gget_objinfo() should have failed for a recursive link."); + puts(" H5Oget_info() should have failed for a recursive link."); TEST_ERROR } /* end if */ - if(H5Gget_objinfo(file, "grp1/recursive", FALSE, &sb2) < 0) FAIL_STACK_ERROR - if(H5G_LINK != sb2.type) { + if(H5Lget_info(file, "grp1/recursive", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5L_TYPE_SOFT != linfo2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR @@ -420,7 +421,7 @@ static int ck_new_links(hid_t fapl, hbool_t new_format) { hid_t file; - H5G_stat_t sb_dset, sb_hard1, sb_hard2; + H5O_info_t oi_dset, oi_hard1, oi_hard2; char filename[NAME_BUF_SIZE]; if(new_format) @@ -430,23 +431,23 @@ ck_new_links(hid_t fapl, hbool_t new_format) /* Open the file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Get hard link info */ - if(H5Gget_objinfo(file, "/grp1/dataset2", TRUE, &sb_dset) < 0) + if(H5Oget_info(file, "/grp1/dataset2", &oi_dset, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file, "/grp1/hard1", TRUE, &sb_hard1) < 0) + if(H5Oget_info(file, "/grp1/hard1", &oi_hard1, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file, "/grp2/hard2", TRUE, &sb_hard2) < 0) + if(H5Oget_info(file, "/grp2/hard2", &oi_hard2, H5P_DEFAULT) < 0) TEST_ERROR /* Check hard links */ - if(H5G_DATASET!=sb_hard1.type || H5G_DATASET!=sb_hard2.type) { + if(H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } - if(HDmemcmp(&sb_dset.objno, &sb_hard1.objno, sizeof(sb_dset.objno)) || HDmemcmp(&sb_dset.objno, &sb_hard2.objno, sizeof(sb_dset.objno))) { + if(H5F_addr_ne(oi_dset.addr, oi_hard1.addr) || H5F_addr_ne(oi_dset.addr, oi_hard2.addr)) { H5_FAILED(); puts(" Hard link test failed. Link seems not to point to the "); puts(" expected file location."); @@ -455,10 +456,11 @@ ck_new_links(hid_t fapl, hbool_t new_format) /* Cleanup */ if(H5Fclose(file) < 0) TEST_ERROR + PASSED(); return 0; - error: +error: return -1; } @@ -1302,7 +1304,7 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) hid_t fcpl_id=-1; /* Group creation property list ID */ hid_t lcpl_id=-1; hid_t lcpl2_id=-1; - H5G_stat_t statbuf; + H5O_info_t oinfo; H5L_info_t linfo; H5T_cset_t old_cset; int64_t old_corder; /* Creation order value of link */ @@ -1341,13 +1343,13 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) /* Get the group's link's information */ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) < 0) TEST_ERROR + if(H5Oget_info(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR old_cset = linfo.cset; if(old_cset != H5T_CSET_UTF8) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR old_corder = linfo.corder; if(old_corder != 0) TEST_ERROR - old_modification_time = statbuf.mtime; + old_modification_time = oinfo.mtime; /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ curr_time = HDtime(NULL); @@ -1360,16 +1362,16 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) /* Get the link's character set & modification time . They should be unchanged */ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(old_cset != linfo.cset) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(old_corder != linfo.corder) TEST_ERROR /* Create a new link to the group. It should have a different creation order value but the same modification time */ if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group2", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(old_corder == linfo.corder) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR @@ -1381,8 +1383,8 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) * should not change. */ if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group_copied", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group_copied", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(linfo.corder != 2) TEST_ERROR @@ -1392,8 +1394,8 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) /* Move the link with the default property list. */ if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group_copied2", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group_copied2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(linfo.corder != 3) TEST_ERROR @@ -1402,8 +1404,8 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR /* Check that the original link is unchanged */ - if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(old_corder != linfo.corder) TEST_ERROR @@ -1413,8 +1415,8 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) * Its creation order value will change, but modification time should not * change. */ if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group_moved", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group_moved", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(linfo.corder != 4) TEST_ERROR @@ -1424,8 +1426,8 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) /* Move the link again using the default property list. */ if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(file_id, "group_moved_again", TRUE, &statbuf) < 0) TEST_ERROR - if(old_modification_time != statbuf.mtime) TEST_ERROR + if(H5Oget_info(file_id, "group_moved_again", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(old_modification_time != oinfo.mtime) TEST_ERROR if(H5Lget_info(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(linfo.corder_valid != TRUE) TEST_ERROR if(linfo.corder != 5) TEST_ERROR @@ -1600,7 +1602,7 @@ external_link_root(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - H5G_stat_t sb; /* Object information */ + H5L_info_t linfo; /* Link information */ char objname[NAME_BUF_SIZE]; /* Object name */ ssize_t name_len; /* Length of object name */ char filename1[NAME_BUF_SIZE]; @@ -1618,7 +1620,7 @@ external_link_root(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create file to point to */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Close file */ if(H5Fclose(fid) < 0) TEST_ERROR @@ -1627,20 +1629,20 @@ external_link_root(hid_t fapl, hbool_t new_format) if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR /* Create file with link to first file */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create external link to object in first file */ if(H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Check information for external link */ - if (H5Gget_objinfo(fid, "ext_link", FALSE, &sb) < 0) goto error; - if (H5G_UDLINK!=sb.type) { + if(H5Lget_info(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; + if(H5L_TYPE_EXTERNAL != linfo.type) { H5_FAILED(); puts(" Unexpected object type - should have been an external link"); goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, sb.linklen, NULL, &file, &path) < 0) TEST_ERROR + if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR if(HDstrcmp(file, filename1)) { H5_FAILED(); puts(" External link file name incorrect"); @@ -2602,8 +2604,8 @@ external_link_query(hid_t fapl, hbool_t new_format) hid_t gid = (-1); /* Group IDs */ const char *file_name; /* Name of the file the external link points to */ const char *object_name; /* Name of the object the external link points to */ - H5G_stat_t sb; /* Object information */ - H5L_info_t li; /* Link information */ + H5O_info_t oi; /* Object information */ + H5L_info_t li; /* Link information */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ @@ -2647,12 +2649,12 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Open first file */ - if((fid=H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Get size of buffer for external link */ if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR - if (H5L_TYPE_EXTERNAL != li.type) { + if(H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); puts(" Unexpected link class - should have been an external link"); goto error; @@ -2665,12 +2667,12 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) TEST_ERROR /* Compare the file and object names */ - if(strcmp(file_name, filename2)) TEST_ERROR - if(strcmp(object_name, "/dst")) TEST_ERROR + if(HDstrcmp(file_name, filename2)) TEST_ERROR + if(HDstrcmp(object_name, "/dst")) TEST_ERROR /* Query information about object that external link points to */ - if (H5Gget_objinfo(fid, "src", TRUE, &sb) < 0) goto error; - if (H5G_GROUP != sb.type) { + if(H5Oget_info(fid, "src", &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5O_TYPE_GROUP != oi.type) { H5_FAILED(); puts(" Unexpected object type - should have been a group"); goto error; @@ -2699,10 +2701,10 @@ external_link_query(hid_t fapl, hbool_t new_format) PASSED(); return 0; - error: +error: H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_link_query() */ @@ -3339,14 +3341,14 @@ external_link_closing(hid_t fapl, hbool_t new_format) hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4=(-1); hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1); hid_t lcpl_id=(-1); - hsize_t dims[2]; + hsize_t dims[2]; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ buf[NAME_BUF_SIZE]; /* misc. buffer */ - H5L_info_t li; - H5G_stat_t sb; + H5L_info_t li; + H5O_info_t oi; hobj_ref_t obj_ref; if(new_format) @@ -3403,9 +3405,8 @@ external_link_closing(hid_t fapl, hbool_t new_format) /* Test that getting info works */ if(H5Lget_info(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lget_info(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gget_objinfo(fid1, "elink/elink/elink/type1", TRUE, &sb) < 0) TEST_ERROR - if(H5Gget_objinfo(fid1, "elink/elink/elink", TRUE, &sb) < 0) TEST_ERROR - if(H5Gget_objinfo(fid1, "elink/elink/elink", FALSE, &sb) < 0) TEST_ERROR + if(H5Oget_info(fid1, "elink/elink/elink/type1", &oi, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info(fid1, "elink/elink/elink", &oi, H5P_DEFAULT) < 0) TEST_ERROR /* Test move */ if(H5Lmove(fid1, "elink/elink/elink/group1", fid1, @@ -3492,7 +3493,7 @@ external_link_closing(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Gget_objinfo(fid1, "elink/elink2/group2/group3/group4", TRUE, &sb) < 0) TEST_ERROR + if(H5Oget_info(fid1, "elink/elink2/group2/group3/group4", &oi, H5P_DEFAULT) < 0) TEST_ERROR /* Add a few regular groups and a soft link in file2 using intermediate group creation */ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR @@ -4322,9 +4323,8 @@ ud_callbacks(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group ID */ - hid_t lcpl = (-1); /* Link Creation PL */ - H5G_stat_t sb; /* Object information */ - H5L_info_t li; /* Link information */ + hid_t lcpl = (-1); /* Link Creation PL */ + H5L_info_t li; /* Link information */ char ud_target_name[] = UD_CB_TARGET; /* Link target name */ char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; @@ -4422,8 +4422,6 @@ ud_callbacks(hid_t fapl, hbool_t new_format) if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(li.u.val_size != 0) TEST_ERROR if(li.type != UD_CB_TYPE) TEST_ERROR - if(H5Gget_objinfo(fid, UD_CB_LINK_NAME, FALSE, &sb) < 0) FAIL_STACK_ERROR - if(sb.type != H5G_UDLINK) TEST_ERROR /* Unregister the UD hard links */ if(H5Lunregister(UD_HARD_TYPE) < 0) FAIL_STACK_ERROR @@ -4442,8 +4440,8 @@ error: } H5E_END_TRY; return -1; } /* end ud_callbacks() */ - + /*------------------------------------------------------------------------- * Function: lapl_udata * @@ -5176,9 +5174,9 @@ linkinfo(hid_t fapl, hbool_t new_format) char filename[NAME_BUF_SIZE]; if(new_format) - TESTING("link type field in H5Gget_objinfo (w/new group format)") + TESTING("link type field in H5Lget_info (w/new group format)") else - TESTING("link type field in H5Gget_objinfo") + TESTING("link type field in H5Lget_info") /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); @@ -6401,18 +6399,14 @@ link_info_by_idx_old(hid_t fapl) /* Check for creating hard or soft link */ if(hard_link) { - H5G_stat_t sb; /* Buffer for querying object's info */ + H5O_info_t oi; /* Buffer for querying object's info */ /* Create group */ if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -6895,7 +6889,7 @@ delete_by_idx_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - H5G_stat_t sb; /* Buffer for querying object's info */ + H5O_info_t oi; /* Buffer for querying object's info */ /* Make name for link */ sprintf(objname, "filler %02u", u); @@ -6904,12 +6898,8 @@ delete_by_idx_old(hid_t fapl) if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -6972,7 +6962,7 @@ delete_by_idx_old(hid_t fapl) /* Create several links */ for(u = 0; u < CORDER_NLINKS; u++) { - H5G_stat_t sb; /* Buffer for querying object's info */ + H5O_info_t oi; /* Buffer for querying object's info */ /* Make name for link */ sprintf(objname, "filler %02u", u); @@ -6981,12 +6971,8 @@ delete_by_idx_old(hid_t fapl) if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -7960,8 +7946,7 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, { char mntname[NAME_BUF_SIZE]; /* Link value */ hid_t group_id; /* ID of group to test */ - H5G_stat_t sb; /* Buffer for querying object's info */ - haddr_t obj_addr; /* Address of object in file */ + H5O_info_t oi; /* Buffer for querying object's info */ haddr_t mnt_root_addr; /* Address of root group in file to mount */ hid_t obj_id; /* ID of object opened */ unsigned mnt_idx; /* Index to mount group on */ @@ -7986,21 +7971,16 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, if((obj_id = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT)) < 0) TEST_ERROR /* Get the object's information */ - if(H5Gget_objinfo(obj_id, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - obj_addr = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - obj_addr = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(obj_id, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR /* Check that the object is the correct one */ if(order == H5_ITER_INC) { - if(H5F_addr_ne(obj_addr, objno[u])) TEST_ERROR + if(H5F_addr_ne(oi.addr, objno[u])) TEST_ERROR } /* end if */ else if(order == H5_ITER_DEC) { unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ - if(H5F_addr_ne(obj_addr, objno[dec_u])) TEST_ERROR + if(H5F_addr_ne(oi.addr, objno[dec_u])) TEST_ERROR } /* end if */ else { /* XXX: What to do about native order? */ @@ -8017,12 +7997,8 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, */ /* Get the address of the root group in the file to mount */ - if(H5Gget_objinfo(mount_file_id, "/", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - mnt_root_addr = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - mnt_root_addr = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(mount_file_id, "/", &oi, H5P_DEFAULT) < 0) TEST_ERROR + mnt_root_addr = oi.addr; /* Mount a file over a group in main group */ mnt_idx = 2; @@ -8033,16 +8009,11 @@ open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, if((obj_id = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)mnt_idx, H5P_DEFAULT)) < 0) TEST_ERROR /* Get the object's information */ - if(H5Gget_objinfo(obj_id, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - obj_addr = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - obj_addr = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(obj_id, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR /* Check that the object is the root of the mounted file and not in the previous file */ - if(H5F_addr_ne(obj_addr, mnt_root_addr)) TEST_ERROR - if(H5F_addr_eq(obj_addr, objno[mnt_idx])) TEST_ERROR + if(H5F_addr_ne(oi.addr, mnt_root_addr)) TEST_ERROR + if(H5F_addr_eq(oi.addr, objno[mnt_idx])) TEST_ERROR /* Close object */ if(H5Oclose(obj_id) < 0) TEST_ERROR @@ -8086,7 +8057,7 @@ open_by_idx(hid_t fapl) hbool_t use_index; /* Use index on creation order values */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5G_stat_t sb; /* Buffer for querying object's info */ + H5O_info_t oi; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ char objname[NAME_BUF_SIZE]; /* Object name */ char valname[NAME_BUF_SIZE]; /* Link value */ @@ -8189,12 +8160,8 @@ open_by_idx(hid_t fapl) if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -8228,12 +8195,8 @@ open_by_idx(hid_t fapl) if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR @@ -8319,7 +8282,7 @@ open_by_idx_old(hid_t fapl) hid_t group_id = (-1); /* Group ID */ hid_t soft_group_id = (-1); /* Group ID for soft links */ H5_iter_order_t order; /* Order within in the index */ - H5G_stat_t sb; /* Buffer for querying object's info */ + H5O_info_t oi; /* Buffer for querying object's info */ char filename[NAME_BUF_SIZE];/* File name */ char objname[NAME_BUF_SIZE]; /* Object name */ char valname[NAME_BUF_SIZE]; /* Link value */ @@ -8374,12 +8337,8 @@ open_by_idx_old(hid_t fapl) if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve group's address on disk */ - if(H5Gget_objinfo(group_id2, ".", FALSE, &sb) < 0) TEST_ERROR -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno[u] = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); -#else - objno[u] = (haddr_t)sb.objno[0]; -#endif + if(H5Oget_info(group_id2, ".", &oi, H5P_DEFAULT) < 0) TEST_ERROR + objno[u] = oi.addr; /* Close group created */ if(H5Gclose(group_id2) < 0) TEST_ERROR diff --git a/test/mount.c b/test/mount.c index 028f92b..f68589d 100644 --- a/test/mount.c +++ b/test/mount.c @@ -254,7 +254,7 @@ static int test_hide(hid_t fapl) { hid_t file1 = -1, file2 = -1, grp = -1; - H5G_stat_t sb1, sb2; + H5O_info_t oi1, oi2; char filename1[1024], filename2[1024]; TESTING("name hiding under mount point"); @@ -266,7 +266,7 @@ test_hide(hid_t fapl) FAIL_STACK_ERROR /* Get information about file1:/mnt1/file1 for later */ - if(H5Gget_objinfo(file1, "/mnt1/file1", TRUE, &sb1) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt1/file1", &oi1, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Build the virtual file */ if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -285,8 +285,8 @@ test_hide(hid_t fapl) * The original objects under file1:/mnt1 are still accessible by their * other names. This is a rather stupid test but demonstrates a point. */ - if(H5Gget_objinfo(file1, "/file1", TRUE, &sb2) < 0) FAIL_STACK_ERROR - if(HDmemcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) || HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { + if(H5Oget_info(file1, "/file1", &oi2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { H5_FAILED(); puts(" Hard link failed for hidden object."); TEST_ERROR @@ -331,7 +331,7 @@ static int test_assoc(hid_t fapl) { hid_t file1 = -1, file2 = -1; - H5G_stat_t sb1, sb2; + H5O_info_t oi1, oi2; char filename1[1024], filename2[1024]; TESTING("mount point open"); @@ -344,7 +344,7 @@ test_assoc(hid_t fapl) FAIL_STACK_ERROR /* Get information about the root of file2 */ - if(H5Gget_objinfo(file2, "/", TRUE, &sb1) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "/", &oi1, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create the virtual file */ if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -353,8 +353,8 @@ test_assoc(hid_t fapl) * Get info about the mount point -- should be the same as the root group * of file2. */ - if(H5Gget_objinfo(file1, "/mnt1", TRUE, &sb2) < 0) FAIL_STACK_ERROR - if(HDmemcmp(&sb1.fileno, &sb2.fileno, sizeof(sb1.fileno)) || HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { + if(H5Oget_info(file1, "/mnt1", &oi2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { H5_FAILED(); puts(" Association failed."); TEST_ERROR @@ -523,6 +523,7 @@ static int test_preopen(hid_t fapl) { hid_t file1 = -1, file2 = -1, grp = -1; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; TESTING("preopening objects under the mount point"); @@ -540,7 +541,7 @@ test_preopen(hid_t fapl) if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Now access the thing we previously opened */ - if(H5Gget_objinfo(grp, ".", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(grp, ".", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Shut down */ if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR @@ -584,6 +585,7 @@ test_postopen(hid_t fapl) { hid_t file1 = -1, file2 = -1, grp = -1; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; TESTING("open object access after unmount"); @@ -603,10 +605,10 @@ test_postopen(hid_t fapl) if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR /* Now access the thing we previously opened */ - if(H5Gget_objinfo(grp, ".", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(grp, ".", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Try accessing it from the file */ - if(H5Gget_objinfo(file2, "/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Shut down */ if(H5Gclose(grp) < 0) FAIL_STACK_ERROR @@ -648,8 +650,9 @@ static int test_unlink(hid_t fapl) { hid_t file1 = -1, file2 = -1, mnt = -1, root = -1; - herr_t status; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; + herr_t status; TESTING("mount point unlinking"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); @@ -675,12 +678,12 @@ test_unlink(hid_t fapl) * before the H5Fmount() and thus refers to the mount point itself rather * than the group mounted there. */ - if(H5Gget_objinfo(file1, "/mnt_unlink/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(mnt, "/mnt_unlink/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(root, "/mnt_unlink/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(root, "file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt_unlink/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(mnt, "/mnt_unlink/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(root, "/mnt_unlink/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(root, "file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { - status = H5Gget_objinfo(mnt, "file2", TRUE, NULL); + status = H5Oget_info(mnt, "file2", &oinfo, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { H5_FAILED(); @@ -695,9 +698,9 @@ test_unlink(hid_t fapl) * We should still be able to get to "/file2" of file2 by starting at * `root' which is still open, but not by name. */ - if(H5Gget_objinfo(root, "file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(root, "file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { - status = H5Gget_objinfo(mnt, "file2", TRUE, NULL); + status = H5Oget_info(mnt, "file2", &oinfo, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { H5_FAILED(); @@ -705,7 +708,7 @@ test_unlink(hid_t fapl) TEST_ERROR } /* end if */ H5E_BEGIN_TRY { - status = H5Gget_objinfo(file2, "/mnt_unlink/file2", TRUE, NULL); + status = H5Oget_info(file2, "/mnt_unlink/file2", &oinfo, H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { H5_FAILED(); @@ -776,6 +779,7 @@ static int test_mvmpt(hid_t fapl) { hid_t file1 = -1, file2 = -1; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; TESTING("mount point renaming"); @@ -792,7 +796,7 @@ test_mvmpt(hid_t fapl) if(H5Lmove(file1, "/mnt_move_a", H5L_SAME_LOC, "/mnt_move_b", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Access something under the new name */ - if(H5Gget_objinfo(file1, "/mnt_move_b/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt_move_b/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Shut down */ if(H5Funmount(file1, "/mnt_move_b") < 0) FAIL_STACK_ERROR @@ -921,6 +925,7 @@ static int test_uniformity(hid_t fapl) { hid_t file1 = -1, file2 = -1; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; TESTING("file handle uniformity"); @@ -934,18 +939,18 @@ test_uniformity(hid_t fapl) if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Access some things from the file1 handle */ - if(H5Gget_objinfo(file1, "/", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file1, "/mnt1", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file1, "mnt1", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file1, "/mnt1/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file1, "mnt1/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt1", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "mnt1", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt1/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "mnt1/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Access the same things from the file2 handle */ - if(H5Gget_objinfo(file2, "/", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file2, "/mnt1", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file2, "mnt1", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file2, "/mnt1/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file2, "mnt1/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "/", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "/mnt1", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "mnt1", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "/mnt1/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file2, "mnt1/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Shut down */ if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR @@ -984,6 +989,7 @@ static int test_close(hid_t fapl) { hid_t file1 = -1, file2 = -1; + H5O_info_t oinfo; char filename1[1024], filename2[1024]; TESTING("file handle close"); @@ -1001,7 +1007,7 @@ test_close(hid_t fapl) * still accessible through the file2 handle. */ if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file2, "/mnt1", TRUE, NULL) < 0) { + if(H5Oget_info(file2, "/mnt1", &oinfo, H5P_DEFAULT) < 0) { H5_FAILED(); puts(" File1 contents are not accessible!"); TEST_ERROR @@ -1022,7 +1028,7 @@ test_close(hid_t fapl) * Close file2. It is not actually closed because it's a child of file1. */ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file1, "/mnt1/file2", TRUE, NULL) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file1, "/mnt1/file2", &oinfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5Fclose(file1) < 0) FAIL_STACK_ERROR /* Check that all file IDs have been closed */ @@ -2255,9 +2261,10 @@ test_fcdegree_strong(hid_t fapl) hid_t fid1 = -1, fid2 = -1; /* File IDs */ hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ hid_t fapl_id = -1; /* FAPL IDs */ - herr_t ret; /* Generic return value */ + H5O_info_t oinfo; char filename1[1024], filename2[1024]; /* Name of files to mount */ + herr_t ret; /* Generic return value */ TESTING("'strong' file close degree"); @@ -2323,9 +2330,9 @@ test_fcdegree_strong(hid_t fapl) TEST_ERROR /* Check that objects are still open */ - if (H5Gget_objinfo(gidA, ".", TRUE, NULL) < 0) + if(H5Oget_info(gidA, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR - if (H5Gget_objinfo(gidAM, ".", TRUE, NULL) < 0) + if(H5Oget_info(gidAM, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR /* Close file #2 (should close open objects also) */ @@ -2334,12 +2341,12 @@ test_fcdegree_strong(hid_t fapl) /* Check that objects are closed */ H5E_BEGIN_TRY { - ret = H5Gget_objinfo(gidA, ".", TRUE, NULL); + ret = H5Oget_info(gidA, ".", &oinfo, H5P_DEFAULT); } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Gget_objinfo(gidAM, ".", TRUE, NULL); + ret = H5Oget_info(gidAM, ".", &oinfo, H5P_DEFAULT); } H5E_END_TRY; if(ret >= 0) TEST_ERROR diff --git a/test/mtime.c b/test/mtime.c index 0d66e12..d49dd5a 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -63,7 +63,7 @@ main(void) hsize_t size[1] = {2}; time_t now; struct tm *tm; - H5G_stat_t sb1, sb2; + H5O_info_t oi1, oi2; signed char buf1[32], buf2[32]; char filename[1024]; @@ -74,51 +74,51 @@ main(void) /* Create the file, create a dataset, then close the file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if ((space=H5Screate_simple(1, size, NULL))<0) TEST_ERROR; - if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT))<0) + if((space = H5Screate_simple(1, size, NULL)) < 0) TEST_ERROR; + if((dset = H5Dcreate(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT)) < 0) TEST_ERROR; - now = time(NULL); - if (H5Dclose(dset)<0) TEST_ERROR; - if (H5Sclose(space)<0) TEST_ERROR; - if (H5Fclose(file)<0) TEST_ERROR; + now = HDtime(NULL); + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; /* - * Open the file and get the modification time. We'll test the new - * H5Gget_objinfo() arguments too: being able to stat something without - * knowing its name. - */ + * Open the file and get the modification time. We'll test the + * H5Oget_info() arguments too: being able to stat something without + * knowing its name. + */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) TEST_ERROR; - if (H5Gget_objinfo(file, "dset", TRUE, &sb1)<0) TEST_ERROR; - if ((dset=H5Dopen(file, "dset"))<0) TEST_ERROR; - if (H5Gget_objinfo(dset, ".", TRUE, &sb2)<0) TEST_ERROR; - if (H5Dclose(dset)<0) TEST_ERROR; - if (H5Fclose(file)<0) TEST_ERROR; - - /* Compare times from the two ways of calling H5Gget_objinfo() */ - if (HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno)) || sb1.mtime!=sb2.mtime) { + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; + if(H5Oget_info(file, "dset", &oi1, H5P_DEFAULT) < 0) TEST_ERROR; + if((dset = H5Dopen(file, "dset")) < 0) TEST_ERROR; + if(H5Oget_info(dset, ".", &oi2, H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; + + /* Compare addresses & times from the two ways of calling H5Oget_info() */ + if(oi1.addr != oi2.addr || oi1.mtime != oi2.mtime) { H5_FAILED(); - puts(" Calling H5Gget_objinfo() with the dataset ID returned"); + puts(" Calling H5Oget_info() with the dataset ID returned"); puts(" different values than calling it with a file and dataset"); puts(" name."); goto error; } /* Compare times -- they must be within 60 seconds of one another */ - if (0==sb1.mtime) { + if(0 == oi1.mtime) { SKIPPED(); puts(" The modification time could not be decoded on this OS."); puts(" Modification times will be mantained in the file but"); puts(" cannot be queried on this system. See H5O_mtime_decode()."); return 0; - } else if (fabs(HDdifftime(now, sb1.mtime))>60.0) { + } else if(HDfabs(HDdifftime(now, oi1.mtime)) > 60.0) { H5_FAILED(); - tm = localtime(&(sb1.mtime)); - strftime((char*)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); - tm = localtime(&now); - strftime((char*)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); + tm = HDlocaltime(&(oi1.mtime)); + HDstrftime((char*)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); + tm = HDlocaltime(&now); + HDstrftime((char*)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); printf(" got: %s\n ans: %s\n", buf1, buf2); goto error; } @@ -131,32 +131,33 @@ main(void) TESTING("accessing old modification time messages"); { - char testfile[512]=""; - char *srcdir = HDgetenv("srcdir"); - if (srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE1) + 1) < sizeof(testfile))){ - HDstrcpy(testfile, srcdir); - HDstrcat(testfile, "/"); - } - HDstrcat(testfile, TESTFILE1); - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if (file >= 0){ - if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb1)<0) - TEST_ERROR; - if(sb1.mtime!=MTIME1) { + char testfile[512]=""; + char *srcdir = HDgetenv("srcdir"); + + if(srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE1) + 1) < sizeof(testfile))){ + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); + } + HDstrcat(testfile, TESTFILE1); + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if(file >= 0){ + if(H5Oget_info(file, "/Dataset1", &oi1, H5P_DEFAULT) < 0) + TEST_ERROR; + if(oi1.mtime != MTIME1) { + H5_FAILED(); + /* If this fails, examine H5Omtime.c. Modification time is very + * system dependant (e.g., on Windows DST must be hardcoded). */ + puts(" Old modification time incorrect"); + goto error; + } + if(H5Fclose(file) < 0) TEST_ERROR; + } + else { H5_FAILED(); - /* If this fails, examine H5Omtime.c. Modification time is very - * system dependant (e.g., on Windows DST must be hardcoded). */ - puts(" Old modification time incorrect"); + printf("***cannot open the pre-created old modification test file (%s)\n", + testfile); goto error; - } - if (H5Fclose(file)<0) TEST_ERROR; - } - else { - H5_FAILED(); - printf("***cannot open the pre-created old modification test file (%s)\n", - testfile); - goto error; - } /* end else */ + } /* end else */ } PASSED(); @@ -166,30 +167,31 @@ main(void) TESTING("accessing new modification time messages"); { - char testfile[512]=""; - char *srcdir = HDgetenv("srcdir"); - if (srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE2) + 1) < sizeof(testfile))){ - HDstrcpy(testfile, srcdir); - HDstrcat(testfile, "/"); - } - HDstrcat(testfile, TESTFILE2); - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if (file >= 0){ - if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb2)<0) - TEST_ERROR; - if(sb2.mtime!=MTIME2) { - H5_FAILED(); - puts(" Modification time incorrect."); - goto error; + char testfile[512]=""; + char *srcdir = HDgetenv("srcdir"); + + if(srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE2) + 1) < sizeof(testfile))){ + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); } - if (H5Fclose(file)<0) TEST_ERROR; - } - else { - H5_FAILED(); - printf("***cannot open the pre-created old modification test file (%s)\n", - testfile); - goto error; - } /* end else */ + HDstrcat(testfile, TESTFILE2); + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if(file >= 0){ + if(H5Oget_info(file, "/Dataset1", &oi2, H5P_DEFAULT) < 0) + TEST_ERROR; + if(oi2.mtime != MTIME2) { + H5_FAILED(); + puts(" Modification time incorrect."); + goto error; + } + if(H5Fclose(file) < 0) TEST_ERROR; + } + else { + H5_FAILED(); + printf("***cannot open the pre-created old modification test file (%s)\n", + testfile); + goto error; + } /* end else */ } PASSED(); @@ -199,9 +201,7 @@ main(void) return 0; /* Something broke */ - error: +error: return 1; } - - diff --git a/test/objcopy.c b/test/objcopy.c index 331add3..88ee026 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -147,13 +147,13 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) *------------------------------------------------------------------------- */ static void -addr_insert(H5G_stat_t *sb) +addr_insert(H5O_info_t *oi) { size_t n; /* Don't add it if the link count is 1 because such an object can only * be encountered once. */ - if(sb->nlink < 2) + if(oi->rc < 2) return; /* Extend the table */ @@ -164,11 +164,7 @@ addr_insert(H5G_stat_t *sb) /* Insert the entry */ n = idtab_g.nobjs++; -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - idtab_g.obj[n] = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); -#else - idtab_g.obj[n] = (haddr_t)sb->objno[0]; -#endif + idtab_g.obj[n] = oi->addr; } /* end addr_insert() */ @@ -187,21 +183,16 @@ addr_insert(H5G_stat_t *sb) *------------------------------------------------------------------------- */ static hbool_t -addr_lookup(H5G_stat_t *sb) +addr_lookup(H5O_info_t *oi) { - haddr_t obj_addr; /* Object's address in the file */ size_t n; - if(sb->nlink<2) return FALSE; /*only one link possible*/ + if(oi->rc < 2) return FALSE; /*only one link possible*/ -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - obj_addr = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); -#else - obj_addr = (haddr_t)sb->objno[0]; -#endif for(n = 0; n < idtab_g.nobjs; n++) - if(idtab_g.obj[n] == obj_addr) + if(H5F_addr_eq(idtab_g.obj[n], oi->addr)) return TRUE; + return FALSE; } /* end addr_lookup() */ @@ -897,11 +888,12 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if((obj2_id = H5Rdereference(parent2, H5R_OBJECT, ref_buf2)) < 0) TEST_ERROR /* break the infinite loop when the ref_object points to itself */ - if (obj_owner > 0) { - H5G_stat_t stat1, stat2; - if (H5Gget_objinfo(obj_owner, ".", 0, &stat1) < 0) TEST_ERROR - if (H5Gget_objinfo(obj1_id, ".", 0, &stat2) < 0) TEST_ERROR - if ( (stat1.objno[0] == stat2.objno[0]) && (stat1.objno[1] == stat2.objno[1]) ) { + if(obj_owner > 0) { + H5O_info_t oinfo1, oinfo2; + + if(H5Oget_info(obj_owner, ".", &oinfo1, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info(obj1_id, ".", &oinfo2, H5P_DEFAULT) < 0) TEST_ERROR + if(H5F_addr_eq(oinfo1.addr, oinfo2.addr)) { if(H5Oclose(obj1_id) < 0) TEST_ERROR if(H5Oclose(obj2_id) < 0) TEST_ERROR return TRUE; @@ -953,12 +945,12 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if((obj2_id = H5Rdereference(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR /* break the infinite loop when the ref_object points to itself */ - if (obj_owner > 0) { - H5G_stat_t stat1, stat2; - if (H5Gget_objinfo(obj_owner, ".", 0, &stat1) < 0) TEST_ERROR - if (H5Gget_objinfo(obj1_id, ".", 0, &stat2) < 0) TEST_ERROR + if(obj_owner > 0) { + H5O_info_t oinfo1, oinfo2; - if ( (stat1.objno[0] == stat2.objno[0]) && (stat1.objno[1] == stat2.objno[1]) ) { + if(H5Oget_info(obj_owner, ".", &oinfo1, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info(obj1_id, ".", &oinfo2, H5P_DEFAULT) < 0) TEST_ERROR + if(H5F_addr_eq(oinfo1.addr, oinfo2.addr)) { if(H5Oclose(obj1_id) < 0) TEST_ERROR if(H5Oclose(obj2_id) < 0) TEST_ERROR return TRUE; @@ -1270,10 +1262,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) char objname2[NAME_BUF_SIZE]; /* Name of object in group */ H5G_obj_t objtype; /* Type of object in group */ H5G_obj_t objtype2; /* Type of object in group */ - H5G_stat_t objstat; /* Object info */ - H5G_stat_t objstat2; /* Object info */ - H5L_info_t linfo; /* Link information */ - H5L_info_t linfo2; /* Link information */ + H5L_info_t linfo; /* Link information */ + H5L_info_t linfo2; /* Link information */ hid_t oid, oid2; /* IDs of objects within group */ /* Loop over contents of groups */ @@ -1288,12 +1278,22 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if((objtype2 = H5Gget_objtype_by_idx(gid2, idx)) < 0) TEST_ERROR if(objtype != objtype2) TEST_ERROR - /* Compare some pieces of the H5G_stat_t */ - if(H5Gget_objinfo(gid, objname, FALSE, &objstat) < 0) TEST_ERROR - if(H5Gget_objinfo(gid2, objname2, FALSE, &objstat2) < 0) TEST_ERROR - if(objstat.type != objstat2.type) TEST_ERROR - if(objstat.type != H5G_LINK && objstat.type != H5G_UDLINK) { - if(objstat.nlink != objstat2.nlink) TEST_ERROR + /* Get link info */ + if(H5Lget_info(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lget_info(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR + if(linfo.type != linfo2.type) TEST_ERROR + + /* Extra checks for "real" objects */ + if(linfo.type == H5L_TYPE_HARD) { + H5O_info_t oinfo; /* Object info */ + H5O_info_t oinfo2; /* Object info */ + + /* Compare some pieces of the object info */ + if(H5Oget_info(gid, objname, &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Oget_info(gid2, objname2, &oinfo2, H5P_DEFAULT) < 0) TEST_ERROR + + if(oinfo.type != oinfo2.type) TEST_ERROR + if(oinfo.rc != oinfo2.rc) TEST_ERROR /* If NULL messages are preserved, the number of messages * should be the same in the destination. @@ -1301,22 +1301,18 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) * of messages hasn't increased. */ if(H5O_COPY_PRESERVE_NULL_FLAG & copy_flags) { - if(objstat.ohdr.nmesgs != objstat2.ohdr.nmesgs) + if(oinfo.hdr.nmesgs != oinfo2.hdr.nmesgs) ; else - if(objstat.ohdr.nmesgs < objstat2.ohdr.nmesgs) TEST_ERROR + if(oinfo.hdr.nmesgs < oinfo2.hdr.nmesgs) TEST_ERROR } - } /* end if */ - /* Get link info */ - if(H5Lget_info(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR - - /* Check for object already having been compared */ - if(addr_lookup(&objstat)) - continue; - else - addr_insert(&objstat); + /* Check for object already having been compared */ + if(addr_lookup(&oinfo)) + continue; + else + addr_insert(&oinfo); + } /* end if */ /* Compare objects within group */ switch(objtype) { @@ -1385,7 +1381,7 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR /* Compare link udata */ - if(HDmemcmp(linkval, linkval2, objstat.linklen)) TEST_ERROR + if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR } break; diff --git a/test/stab.c b/test/stab.c index e3cfa57..368e00e 100644 --- a/test/stab.c +++ b/test/stab.c @@ -325,7 +325,7 @@ lifecycle(hid_t fapl2) unsigned est_num_entries; /* Estimated # of entries in group */ unsigned est_name_len; /* Estimated length of entry name */ unsigned nmsgs; /* Number of messages in group's header */ - H5G_stat_t obj_stat; /* Object info */ + H5O_info_t oinfo; /* Object info */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE]; h5_stat_size_t empty_size; /* Size of an empty file */ @@ -416,15 +416,11 @@ lifecycle(hid_t fapl2) if(H5G_is_new_dense_test(gid) != FALSE) TEST_ERROR /* Check that the object header is only one chunk and the space has been allocated correctly */ - if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR -#ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 151) TEST_ERROR -#else /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.size != 131) TEST_ERROR -#endif /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.free != 0) TEST_ERROR - if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR - if(obj_stat.ohdr.nchunks != 1) TEST_ERROR + if(H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(oinfo.hdr.space.total != 151) TEST_ERROR + if(oinfo.hdr.space.free != 0) TEST_ERROR + if(oinfo.hdr.nmesgs != 6) TEST_ERROR + if(oinfo.hdr.nchunks != 1) TEST_ERROR /* Create one more "bottom" group, which should push top group into using a symbol table */ sprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); @@ -442,15 +438,11 @@ lifecycle(hid_t fapl2) if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR /* Check that the object header is still one chunk and the space has been allocated correctly */ - if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR -#ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 151) TEST_ERROR -#else /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.size != 131) TEST_ERROR -#endif /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.free != 92) TEST_ERROR - if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR - if(obj_stat.ohdr.nchunks != 1) TEST_ERROR + if(H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR + if(oinfo.hdr.space.total != 151) TEST_ERROR + if(oinfo.hdr.space.free != 92) TEST_ERROR + if(oinfo.hdr.nmesgs != 3) TEST_ERROR + if(oinfo.hdr.nchunks != 1) TEST_ERROR /* Unlink objects from top group */ while(u >= LIFECYCLE_MIN_DENSE) { diff --git a/test/tattr.c b/test/tattr.c index d987994..96f6051 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -1595,9 +1595,9 @@ test_attr_dtype_shared(hid_t fapl) hid_t space_id; /* Dataspace ID for dataset & attribute */ hid_t type_id; /* Datatype ID for named datatype */ hid_t attr_id; /* Attribute ID */ - int data=8; /* Data to write */ - int rdata=0; /* Read read in */ - H5G_stat_t statbuf; /* Object's information */ + int data = 8; /* Data to write */ + int rdata = 0; /* Read read in */ + H5O_info_t oinfo; /* Object's information */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ herr_t ret; /* Generic return value */ @@ -1606,153 +1606,154 @@ test_attr_dtype_shared(hid_t fapl) MESSAGE(5, ("Testing Shared Datatypes with Attributes\n")); /* Create a file */ - file_id=H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file_id, FAIL, "H5Fopen"); /* Close file */ - ret=H5Fclose(file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); /* Get size of file */ - empty_filesize=h5_get_file_size(FILENAME); - if(empty_filesize<0) - TestErrPrintf("Line %d: file size wrong!\n",__LINE__); + empty_filesize = h5_get_file_size(FILENAME); + if(empty_filesize < 0) + TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ - file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,fapl); + file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(file_id, FAIL, "H5Fopen"); /* Create a datatype to commit and use */ - type_id=H5Tcopy(H5T_NATIVE_INT); + type_id = H5Tcopy(H5T_NATIVE_INT); CHECK(type_id, FAIL, "H5Tcopy"); /* Commit datatype to file */ - ret=H5Tcommit(file_id,TYPE1_NAME,type_id); + ret = H5Tcommit(file_id, TYPE1_NAME, type_id); CHECK(ret, FAIL, "H5Tcommit"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 1, "H5Tcommit"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "H5Tcommit"); /* Create dataspace for dataset */ - space_id=H5Screate(H5S_SCALAR); + space_id = H5Screate(H5S_SCALAR); CHECK(space_id, FAIL, "H5Screate"); /* Create dataset */ - dset_id=H5Dcreate(file_id,DSET1_NAME,type_id,space_id,H5P_DEFAULT); + dset_id = H5Dcreate(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 2, "H5Dcreate"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "H5Dcreate"); /* Create attribute on dataset */ - attr_id=H5Acreate(dset_id,ATTR1_NAME,type_id,space_id,H5P_DEFAULT); + attr_id = H5Acreate(dset_id, ATTR1_NAME, type_id, space_id, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Acreate"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 3, "H5Acreate"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 3, "H5Acreate"); /* Close attribute */ - ret=H5Aclose(attr_id); + ret = H5Aclose(attr_id); CHECK(ret, FAIL, "H5Aclose"); /* Delete attribute */ - ret=H5Adelete(dset_id,ATTR1_NAME); + ret = H5Adelete(dset_id, ATTR1_NAME); CHECK(ret, FAIL, "H5Adelete"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 2, "H5Adelete"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "H5Adelete"); /* Create attribute on dataset */ - attr_id=H5Acreate(dset_id,ATTR1_NAME,type_id,space_id,H5P_DEFAULT); + attr_id = H5Acreate(dset_id, ATTR1_NAME, type_id, space_id, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Acreate"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 3, "H5Acreate"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 3, "H5Acreate"); /* Write data into the attribute */ - ret=H5Awrite(attr_id,H5T_NATIVE_INT,&data); + ret = H5Awrite(attr_id, H5T_NATIVE_INT, &data); CHECK(ret, FAIL, "H5Awrite"); /* Close attribute */ - ret=H5Aclose(attr_id); + ret = H5Aclose(attr_id); CHECK(ret, FAIL, "H5Aclose"); /* Close dataset */ - ret=H5Dclose(dset_id); + ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); /* Close dataspace */ - ret=H5Sclose(space_id); + ret = H5Sclose(space_id); CHECK(ret, FAIL, "H5Sclose"); /* Close datatype */ - ret=H5Tclose(type_id); + ret = H5Tclose(type_id); CHECK(ret, FAIL, "H5Tclose"); /* Close file */ - ret=H5Fclose(file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); + /* Re-open file */ - file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,fapl); + file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(file_id, FAIL, "H5Fopen"); /* Open dataset */ - dset_id=H5Dopen(file_id,DSET1_NAME); + dset_id = H5Dopen(file_id, DSET1_NAME); CHECK(dset_id, FAIL, "H5Dopen"); /* Open attribute */ - attr_id=H5Aopen_name(dset_id,ATTR1_NAME); + attr_id = H5Aopen_name(dset_id, ATTR1_NAME); CHECK(attr_id, FAIL, "H5Aopen_name"); /* Read data from the attribute */ - ret=H5Aread(attr_id,H5T_NATIVE_INT,&rdata); + ret = H5Aread(attr_id, H5T_NATIVE_INT, &rdata); CHECK(ret, FAIL, "H5Aread"); VERIFY(data, rdata, "H5Aread"); /* Close attribute */ - ret=H5Aclose(attr_id); + ret = H5Aclose(attr_id); CHECK(ret, FAIL, "H5Aclose"); /* Close dataset */ - ret=H5Dclose(dset_id); + ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 3, "H5Gget_objinfo"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 3, "H5Oget_info"); /* Unlink the dataset */ ret = H5Ldelete(file_id, DSET1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); /* Check reference count on named datatype */ - ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.nlink, 1, "H5Gget_objinfo"); + ret = H5Oget_info(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "H5Ldelete"); /* Unlink the named datatype */ ret = H5Ldelete(file_id, TYPE1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); /* Close file */ - ret=H5Fclose(file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); /* Check size of file */ - filesize=h5_get_file_size(FILENAME); + filesize = h5_get_file_size(FILENAME); VERIFY(filesize, empty_filesize, "h5_get_file_size"); } /* test_attr_dtype_shared() */ diff --git a/test/testhdf5.h b/test/testhdf5.h index 8817725..45ad476 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -69,15 +69,16 @@ } /* Used to make certain a return value _is_ a value */ -#define VERIFY(x, val, where) do { \ - if (GetTestVerbosity()>=VERBO_HI) { \ +#define VERIFY(_x, _val, where) do { \ + long __x = (long)_x, __val = (long)_val; \ + if(GetTestVerbosity() >= VERBO_HI) { \ print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ + "%ld \n", (where), (int)__LINE__, __FILE__, __x); \ } \ - if ((x) != (val)) { \ + if((__x) != (__val)) { \ TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ - "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ + "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } while(0) diff --git a/test/tfile.c b/test/tfile.c index dc971e7..12f09b8 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1246,11 +1246,8 @@ test_file_freespace(void) /* Check that there is the right amount of free space in the file */ free_space = H5Fget_freespace(file); CHECK(free_space, FAIL, "H5Fget_freespace"); -#ifdef H5_HAVE_LARGE_HSIZET VERIFY(free_space, 2376, "H5Fget_freespace"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(free_space, 588, "H5Fget_freespace"); /* XXX: fix me */ -#endif /* H5_HAVE_LARGE_HSIZET */ + /* Delete datasets in file */ for(u = 0; u < 10; u++) { sprintf(name, "Dataset %u", u); diff --git a/test/th5o.c b/test/th5o.c index ff434d6..291c73c 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -378,7 +378,7 @@ test_h5o_refcount(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5G_stat_t sb; /* Statbuffer for H5Gget_objinfo */ + H5O_info_t oinfo; /* Object info struct */ hsize_t dims[RANK]; herr_t ret; /* Value returned from API calls */ @@ -410,15 +410,15 @@ test_h5o_refcount(void) CHECK(ret, FAIL, "H5Sclose"); /* Get ref counts for each object. They should all be 1, since each object has a hard link. */ - ret = H5Gget_objinfo(fid, "group", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "datatype", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "dataset", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); + ret = H5Oget_info(fid, "group", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "datatype", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "dataset", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); /* Increment each object's reference count. */ ret = H5Oincr_refcount(grp); @@ -429,15 +429,15 @@ test_h5o_refcount(void) CHECK(ret, FAIL, "H5Oincr_refcount"); /* Get ref counts for each object. They should all be 2 now. */ - ret = H5Gget_objinfo(fid, "group", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "datatype", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "dataset", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); + ret = H5Oget_info(fid, "group", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "datatype", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "dataset", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); /* Decrement the reference counts and check that they decrease back to 1. */ ret = H5Odecr_refcount(grp); @@ -447,15 +447,15 @@ test_h5o_refcount(void) ret = H5Odecr_refcount(dset); CHECK(ret, FAIL, "H5Odecr_refcount"); - ret = H5Gget_objinfo(fid, "group", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "datatype", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "dataset", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); + ret = H5Oget_info(fid, "group", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "datatype", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "dataset", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); /* Increment the reference counts and then close the file to make sure the increment is permanant */ ret = H5Oincr_refcount(grp); @@ -485,15 +485,15 @@ test_h5o_refcount(void) dset = H5Dopen(fid, "dataset"); CHECK(dset, FAIL, "H5Dopen"); - ret = H5Gget_objinfo(fid, "group", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "datatype", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "dataset", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 2, "reference count in H5Gget_objinfo"); + ret = H5Oget_info(fid, "group", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "datatype", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "dataset", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 2, "reference count in H5Oget_info"); /* Decrement the reference counts and close the file */ ret = H5Odecr_refcount(grp); @@ -523,15 +523,15 @@ test_h5o_refcount(void) dset = H5Dopen(fid, "dataset"); CHECK(dset, FAIL, "H5Dopen"); - ret = H5Gget_objinfo(fid, "group", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "datatype", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); - ret = H5Gget_objinfo(fid, "dataset", FALSE, &sb); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink, 1, "reference count in H5Gget_objinfo"); + ret = H5Oget_info(fid, "group", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "datatype", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); + ret = H5Oget_info(fid, "dataset", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "reference count in H5Oget_info"); /* Close the IDs */ ret = H5Gclose(grp); diff --git a/test/titerate.c b/test/titerate.c index 99f099c..bbb57b3 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -54,7 +54,7 @@ typedef enum { /* Custom group iteration callback data */ typedef struct { char name[NAMELEN]; /* The name of the object */ - int type; /* The type of the object */ + H5O_type_t type; /* The type of the object */ iter_enum command; /* The type of return value */ } iter_info; @@ -547,7 +547,7 @@ liter_cb2(hid_t loc_id, const char *name, const H5L_info_t UNUSED *link_info, void *opdata) { const iter_info *test_info = (const iter_info *)opdata; - H5G_stat_t statbuf; + H5O_info_t oinfo; herr_t ret; /* Generic return value */ if(HDstrcmp(name, test_info->name)) { @@ -558,11 +558,11 @@ liter_cb2(hid_t loc_id, const char *name, const H5L_info_t UNUSED *link_info, /* * Get type of the object and check it. */ - ret = H5Gget_objinfo(loc_id, name, FALSE, &statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); + ret = H5Oget_info(loc_id, name, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); - if(test_info->type != statbuf.type) { - TestErrPrintf("test_info->type = %d, statbuf.type = %d\n", test_info->type, statbuf.type); + if(test_info->type != oinfo.type) { + TestErrPrintf("test_info->type = %d, oinfo.type = %d\n", test_info->type, (int)oinfo.type); return(H5_ITER_ERROR); } /* end if */ diff --git a/test/tmisc.c b/test/tmisc.c index 0fe0434..f9abada 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -233,13 +233,8 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC20_SPACE_RANK 2 /* Make sure the product of the following 2 does not get too close to */ /* 64 bits, risking an overflow. */ -#ifdef H5_HAVE_LARGE_HSIZET #define MISC20_SPACE_DIM0 (8*1024*1024*(uint64_t)1024) #define MISC20_SPACE_DIM1 ((256*1024*(uint64_t)1024)+1) -#else /* H5_HAVE_LARGE_HSIZET */ -#define MISC20_SPACE_DIM0 (128*(uint64_t)1024) -#define MISC20_SPACE_DIM1 ((4*(uint64_t)1024)+1) -#endif /* H5_HAVE_LARGE_HSIZET */ #define MISC20_SPACE2_DIM0 8 #define MISC20_SPACE2_DIM1 4 @@ -610,7 +605,7 @@ test_misc3(void) /**************************************************************** ** -** test_misc4(): Test the that 'fileno' field in H5G_stat_t is +** test_misc4(): Test the that 'fileno' field in H5O_info_t is ** valid. ** ****************************************************************/ @@ -618,11 +613,11 @@ static void test_misc4(void) { hid_t file1, file2, group1, group2, group3; - H5G_stat_t stat1, stat2, stat3; + H5O_info_t oinfo1, oinfo2, oinfo3; herr_t ret; /* Output message about test being performed */ - MESSAGE(5, ("Testing fileno working in H5G_stat_t\n")); + MESSAGE(5, ("Testing fileno working in H5O_info_t\n")); file1 = H5Fcreate(MISC4_FILE_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1, FAIL, "H5Fcreate"); @@ -643,21 +638,21 @@ test_misc4(void) CHECK(group3, FAIL, "H5Gcreate2"); /* Get the stat information for each group */ - ret = H5Gget_objinfo(file1,MISC4_GROUP_1,0,&stat1); - CHECK(ret, FAIL, "H5Gget_objinfo"); - ret = H5Gget_objinfo(file1,MISC4_GROUP_2,0,&stat2); - CHECK(ret, FAIL, "H5Gget_objinfo"); - ret = H5Gget_objinfo(file2,MISC4_GROUP_1,0,&stat3); - CHECK(ret, FAIL, "H5Gget_objinfo"); + ret = H5Oget_info(file1, MISC4_GROUP_1, &oinfo1, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + ret = H5Oget_info(file1, MISC4_GROUP_2, &oinfo2, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + ret = H5Oget_info(file2, MISC4_GROUP_1, &oinfo3, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); /* Verify that the fileno values are the same for groups from file1 */ - VERIFY(stat1.fileno[0],stat2.fileno[0],"H5Gget_objinfo"); + VERIFY(oinfo1.fileno, oinfo2.fileno, "H5Oget_info"); /* Verify that the fileno values are not the same between file1 & file2 */ - if(stat1.fileno[0]==stat3.fileno[0]) - TestErrPrintf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); - if(stat2.fileno[0]==stat3.fileno[0]) - TestErrPrintf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); + if(oinfo1.fileno == oinfo3.fileno) + TestErrPrintf("Error on line %d: oinfo1.fileno != oinfo3.fileno\n", __LINE__); + if(oinfo2.fileno == oinfo3.fileno) + TestErrPrintf("Error on line %d: oinfo2.fileno != oinfo3.fileno\n", __LINE__); /* Close the objects */ ret = H5Gclose(group1); @@ -2832,7 +2827,7 @@ test_misc17(void) /**************************************************************** ** -** test_misc18(): Test new object header information in H5G_stat_t +** test_misc18(): Test new object header information in H5O_info_t ** struct. ** ****************************************************************/ @@ -2843,7 +2838,7 @@ test_misc18(void) hid_t sid; /* 'Space ID */ hid_t did1, did2; /* Dataset IDs */ hid_t aid; /* Attribute ID */ - H5G_stat_t statbuf; /* Information about object */ + H5O_info_t oinfo; /* Information about object */ char attr_name[32]; /* Attribute name buffer */ unsigned u; /* Local index variable */ herr_t ret; /* Generic return value */ @@ -2861,34 +2856,26 @@ test_misc18(void) CHECK(did1, FAIL, "H5Dcreate"); /* Get object information */ - ret = H5Gget_objinfo(fid,MISC18_DSET1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nmesgs, 6, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 1, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 272, "H5Gget_objinfo"); -#ifdef H5_HAVE_LARGE_HSIZET - VERIFY(statbuf.ohdr.free, 152, "H5Gget_objinfo"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.ohdr.free, 160, "H5Gget_objinfo"); -#endif /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.linklen, 0, "H5Gget_objinfo"); + ret = H5Oget_info(fid, MISC18_DSET1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.hdr.nmesgs, 6, "H5Oget_info"); + VERIFY(oinfo.hdr.nchunks, 1, "H5Oget_info"); + VERIFY(oinfo.hdr.space.total, 272, "H5Oget_info"); + VERIFY(oinfo.hdr.space.free, 152, "H5Oget_info"); + VERIFY(oinfo.num_attrs, 0, "H5Oget_info"); /* Create second dataset */ did2 = H5Dcreate(fid, MISC18_DSET2_NAME, H5T_STD_U32LE, sid, H5P_DEFAULT); CHECK(did2, FAIL, "H5Screate_simple"); /* Get object information */ - ret = H5Gget_objinfo(fid,MISC18_DSET2_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nmesgs, 6, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 1, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 272, "H5Gget_objinfo"); -#ifdef H5_HAVE_LARGE_HSIZET - VERIFY(statbuf.ohdr.free, 152, "H5Gget_objinfo"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.ohdr.free, 160, "H5Gget_objinfo"); -#endif /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.linklen, 0, "H5Gget_objinfo"); + ret = H5Oget_info(fid, MISC18_DSET2_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.hdr.nmesgs, 6, "H5Oget_info"); + VERIFY(oinfo.hdr.nchunks, 1, "H5Oget_info"); + VERIFY(oinfo.hdr.space.total, 272, "H5Oget_info"); + VERIFY(oinfo.hdr.space.free, 152, "H5Oget_info"); + VERIFY(oinfo.num_attrs, 0, "H5Oget_info"); /* Loop creating attributes on each dataset, flushing them to the file each time */ for(u=0; u<10; u++) { @@ -2897,14 +2884,14 @@ test_misc18(void) /* Create & close attribute on first dataset */ aid = H5Acreate(did1, attr_name, H5T_STD_U32LE, sid, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Gget_objinfo"); + CHECK(aid, FAIL, "H5Acreate"); ret = H5Aclose(aid); CHECK(ret, FAIL, "HAclose"); /* Create & close attribute on second dataset */ aid = H5Acreate(did2, attr_name, H5T_STD_U32LE, sid, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Gget_objinfo"); + CHECK(aid, FAIL, "H5Acreate"); ret = H5Aclose(aid); CHECK(ret, FAIL, "HAclose"); @@ -2915,36 +2902,22 @@ test_misc18(void) } /* end for */ /* Get object information for dataset #1 now */ - ret = H5Gget_objinfo(fid,MISC18_DSET1_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); -#ifdef H5_HAVE_LARGE_HSIZET - VERIFY(statbuf.ohdr.nmesgs, 24, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 9, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 888, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.free, 16, "H5Gget_objinfo"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.ohdr.nmesgs, 26, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 9, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 888, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.free, 24, "H5Gget_objinfo"); -#endif /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.linklen, 0, "H5Gget_objinfo"); + ret = H5Oget_info(fid, MISC18_DSET1_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.hdr.nmesgs, 24, "H5Oget_info"); + VERIFY(oinfo.hdr.nchunks, 9, "H5Oget_info"); + VERIFY(oinfo.hdr.space.total, 888, "H5Oget_info"); + VERIFY(oinfo.hdr.space.free, 16, "H5Oget_info"); + VERIFY(oinfo.num_attrs, 10, "H5Oget_info"); /* Get object information for dataset #2 now */ - ret = H5Gget_objinfo(fid,MISC18_DSET2_NAME,0,&statbuf); - CHECK(ret, FAIL, "H5Gget_objinfo"); -#ifdef H5_HAVE_LARGE_HSIZET - VERIFY(statbuf.ohdr.nmesgs, 24, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 9, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 888, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.free, 16, "H5Gget_objinfo"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.ohdr.nmesgs, 26, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.nchunks, 9, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.size, 888, "H5Gget_objinfo"); - VERIFY(statbuf.ohdr.free, 24, "H5Gget_objinfo"); -#endif /* H5_HAVE_LARGE_HSIZET */ - VERIFY(statbuf.linklen, 0, "H5Gget_objinfo"); + ret = H5Oget_info(fid, MISC18_DSET2_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.hdr.nmesgs, 24, "H5Oget_info"); + VERIFY(oinfo.hdr.nchunks, 9, "H5Oget_info"); + VERIFY(oinfo.hdr.space.total, 888, "H5Oget_info"); + VERIFY(oinfo.hdr.space.free, 16, "H5Oget_info"); + VERIFY(oinfo.num_attrs, 10, "H5Oget_info"); /* Close second dataset */ ret = H5Dclose(did2); @@ -3426,10 +3399,8 @@ test_misc20(void) CHECK(dcpl, FAIL, "H5Pcreate"); /* Try to use chunked storage for this dataset */ -#ifdef H5_HAVE_LARGE_HSIZET - ret = H5Pset_chunk(dcpl,rank,big_dims); + ret = H5Pset_chunk(dcpl, rank, big_dims); VERIFY(ret, FAIL, "H5Pset_chunk"); -#endif /* H5_HAVE_LARGE_HSIZET */ /* Verify that the storage for the dataset is the correct size and hasn't * been truncated. @@ -3440,11 +3411,11 @@ test_misc20(void) CHECK(fid, FAIL, "H5Fcreate"); /* Create dataspace with _really_ big dimensions */ - sid = H5Screate_simple(rank,big_dims,NULL); + sid = H5Screate_simple(rank, big_dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); /* Make certain that the dataset's storage doesn't get allocated :-) */ - ret = H5Pset_alloc_time(dcpl,H5D_ALLOC_TIME_LATE); + ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); CHECK(ret, FAIL, "H5Pset_alloc_time"); /* Create dataset with big dataspace */ @@ -3452,15 +3423,15 @@ test_misc20(void) CHECK(did, FAIL, "H5Dcreate"); /* Close datasset */ - ret=H5Dclose(did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); /* Close dataspace */ - ret=H5Sclose(sid); + ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); /* Create dataspace with small dimensions */ - sid = H5Screate_simple(rank,small_dims,NULL); + sid = H5Screate_simple(rank, small_dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); /* Create dataset with big dataspace */ @@ -3468,15 +3439,15 @@ test_misc20(void) CHECK(did, FAIL, "H5Dcreate"); /* Close datasset */ - ret=H5Dclose(did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); /* Close dataspace */ - ret=H5Sclose(sid); + ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); /* Close dataset creation property list */ - ret=H5Pclose(dcpl); + ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); /* Close file */ @@ -3494,15 +3465,15 @@ test_misc20(void) /* Get the layout version */ ret = H5D_layout_version_test(did,&version); CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version,3,"H5D_layout_version_test"); + VERIFY(version, 3, "H5D_layout_version_test"); /* Get the layout contiguous storage size */ ret = H5D_layout_contig_size_test(did,&contig_size); CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, MISC20_SPACE_DIM0*MISC20_SPACE_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5D_layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D_layout_contig_size_test"); /* Close datasset */ - ret=H5Dclose(did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); /* Open dataset with small dimensions */ @@ -3512,15 +3483,15 @@ test_misc20(void) /* Get the layout version */ ret = H5D_layout_version_test(did,&version); CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version,3,"H5D_layout_version_test"); + VERIFY(version, 3, "H5D_layout_version_test"); /* Get the layout contiguous storage size */ ret = H5D_layout_contig_size_test(did,&contig_size); CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, MISC20_SPACE2_DIM0*MISC20_SPACE2_DIM1*H5Tget_size(H5T_NATIVE_INT), "H5D_layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE2_DIM0 * MISC20_SPACE2_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D_layout_contig_size_test"); /* Close datasset */ - ret=H5Dclose(did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); /* Close file */ @@ -3530,7 +3501,7 @@ test_misc20(void) /* Verify that the storage size is computed correctly for older versions of layout info */ /* Generate the correct name for the test file, by prepending the source path */ - if (srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC20_FILE_OLD) + 1) < sizeof(testfile))) { + if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC20_FILE_OLD) + 1) < sizeof(testfile))) { HDstrcpy(testfile, srcdir); HDstrcat(testfile, "/"); } @@ -3539,30 +3510,26 @@ test_misc20(void) /* * Open the old file and the dataset and get old settings. */ - fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Open dataset with small dimensions */ did = H5Dopen(fid, MISC20_DSET_NAME); -#ifdef H5_HAVE_LARGE_HSIZET CHECK(did, FAIL, "H5Dopen"); /* Get the layout version */ ret = H5D_layout_version_test(did,&version); CHECK(ret, FAIL, "H5D_layout_version_test"); - VERIFY(version,2,"H5D_layout_version_test"); + VERIFY(version, 2, "H5D_layout_version_test"); /* Get the layout contiguous storage size */ ret = H5D_layout_contig_size_test(did,&contig_size); CHECK(ret, FAIL, "H5D_layout_contig_size_test"); - VERIFY(contig_size, MISC20_SPACE_DIM0*MISC20_SPACE_DIM1*H5Tget_size(H5T_STD_I32LE), "H5D_layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_STD_I32LE)), "H5D_layout_contig_size_test"); /* Close datasset */ - ret=H5Dclose(did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); -#else /* H5_HAVE_LARGE_HSIZET */ - VERIFY(did, FAIL, "H5Dopen"); -#endif /* H5_HAVE_LARGE_HSIZET */ /* Close file */ ret = H5Fclose(fid); @@ -3797,12 +3764,12 @@ test_misc22(void) static void test_misc23(void) { - herr_t status; hsize_t dims[] = {10}; hid_t file_id=0, group_id=0, type_id=0, space_id=0, tmp_id=0, create_id=H5P_DEFAULT, access_id=H5P_DEFAULT; char objname[MISC23_NAME_BUF_SIZE]; /* Name of object */ - H5G_stat_t sb; + H5O_info_t oinfo; + herr_t status; /* Output message about test being performed */ MESSAGE(5, ("Testing intermediate group creation\n")); @@ -3869,7 +3836,7 @@ test_misc23(void) CHECK(tmp_id, FAIL, "H5Gcreate2"); /* Query that the name of the new group is correct */ - status = H5Iget_name( tmp_id, objname, (size_t)MISC23_NAME_BUF_SIZE ); + status = H5Iget_name(tmp_id, objname, (size_t)MISC23_NAME_BUF_SIZE); CHECK(status, FAIL, "H5Iget_name"); VERIFY_STR(objname, "/A/B01/grp", "H5Iget_name"); @@ -3880,9 +3847,9 @@ test_misc23(void) tmp_id = H5Gopen2(file_id, "/A/B01", H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Gopen2"); - status = H5Gget_objinfo(tmp_id, ".", FALSE, &sb); - CHECK(status, FAIL, "H5Gget_objinfo"); - VERIFY(sb.nlink,1,"H5Gget_objinfo"); + status = H5Oget_info(tmp_id, ".", &oinfo, H5P_DEFAULT); + CHECK(status, FAIL, "H5Oget_info"); + VERIFY(oinfo.rc, 1, "H5Oget_info"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); @@ -4841,7 +4808,7 @@ test_misc(void) test_misc1(); /* Test unlinking a dataset & immediately re-using name */ test_misc2(); /* Test storing a VL-derived datatype in two different files */ test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ - test_misc4(); /* Test retrieving the fileno for various objects with H5Gget_objinfo() */ + test_misc4(); /* Test retrieving the fileno for various objects with H5Oget_info() */ test_misc5(); /* Test several level deep nested compound & VL datatypes */ test_misc6(); /* Test object header continuation code */ test_misc7(); /* Test for sensible datatypes stored on disk */ @@ -4855,7 +4822,7 @@ test_misc(void) test_misc15(); /* Test that checking a file's access property list more than once works */ test_misc16(); /* Test array of fixed-length string */ test_misc17(); /* Test array of ASCII character */ - test_misc18(); /* Test new object header information in H5G_stat_t struct */ + test_misc18(); /* Test new object header information in H5O_info_t struct */ test_misc19(); /* Test incrementing & decrementing ref count on IDs */ test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ #if defined H5_HAVE_FILTER_SZIP diff --git a/test/tsohm.c b/test/tsohm.c index 16acf71..f5b5235 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -735,7 +735,7 @@ static void test_sohm_size1(void) h5_stat_size_t norm_final_filesize2; h5_stat_size_t sohm_final_filesize2; h5_stat_size_t sohm_btree_final_filesize2; - H5G_stat_t statbuf; + H5O_info_t oinfo; unsigned num_indexes = 1; unsigned index_flags = H5O_MESG_DTYPE_FLAG; unsigned min_mesg_size = 50; @@ -776,11 +776,11 @@ static void test_sohm_size1(void) CHECK_I(file, "size1_helper"); /* Get the size of a dataset object header */ - ret = H5Gget_objinfo(file, DSETNAME[0], 0, &statbuf); - CHECK_I(ret, "H5Gget_objinfo"); + ret = H5Oget_info(file, DSETNAME[0], &oinfo, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info"); ret = H5Fclose(file); CHECK_I(ret, "H5Fclose"); - norm_oh_size = statbuf.ohdr.size; + norm_oh_size = oinfo.hdr.space.total; /* Get the new file size */ norm_final_filesize = h5_get_file_size(FILENAME); @@ -832,11 +832,11 @@ static void test_sohm_size1(void) CHECK_I(file, "size1_helper"); /* Get the size of a dataset object header */ - ret = H5Gget_objinfo(file, DSETNAME[0], 0, &statbuf); - CHECK_I(ret, "H5Gget_objinfo"); + ret = H5Oget_info(file, DSETNAME[0], &oinfo, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info"); ret = H5Fclose(file); CHECK_I(ret, "H5Fclose"); - sohm_oh_size = statbuf.ohdr.size; + sohm_oh_size = oinfo.hdr.space.total; /* Get the new file size */ sohm_final_filesize = h5_get_file_size(FILENAME); @@ -887,11 +887,11 @@ static void test_sohm_size1(void) CHECK_I(file, "size1_helper"); /* Get the size of a dataset object header */ - ret = H5Gget_objinfo(file, DSETNAME[0], 0, &statbuf); - CHECK_I(ret, "H5Gget_objinfo"); + ret = H5Oget_info(file, DSETNAME[0], &oinfo, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info"); ret = H5Fclose(file); CHECK_I(ret, "H5Fclose"); - sohm_btree_oh_size = statbuf.ohdr.size; + sohm_btree_oh_size = oinfo.hdr.space.total; /* Get the new file size */ sohm_btree_final_filesize = h5_get_file_size(FILENAME); @@ -924,10 +924,10 @@ static void test_sohm_size1(void) * continuation message and a NULL message. if(sohm_oh_size >= norm_oh_size) - VERIFY(sohm_oh_size, 1, "H5Gget_objinfo"); + VERIFY(sohm_oh_size, 1, "H5Oget_info"); */ if(sohm_oh_size != sohm_btree_oh_size) - VERIFY(sohm_btree_oh_size, 1, "H5Gget_objinfo"); + VERIFY(sohm_btree_oh_size, 1, "H5Oget_info"); /* Both sohm files should be bigger than a normal file when empty. * It's hard to say whether a B-tree with no nodes allocated should be diff --git a/test/unlink.c b/test/unlink.c index a3a4213..9ac7532 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -439,7 +439,7 @@ static int check_new_move(hid_t fapl) { hid_t file; - H5G_stat_t sb_hard1, sb_hard2; + H5O_info_t oi_hard1, oi_hard2; char filename[1024]; char linkval[1024]; @@ -447,20 +447,24 @@ check_new_move(hid_t fapl) /* Open file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Get hard link info */ - if(H5Gget_objinfo(file, "/group2/group_new_name", TRUE, &sb_hard1) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file, "/group1/hard", TRUE, &sb_hard2) < 0) FAIL_STACK_ERROR + if(H5Oget_info(file, "/group2/group_new_name", &oi_hard1, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5Oget_info(file, "/group1/hard", &oi_hard2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check hard links */ - if(H5G_GROUP != sb_hard1.type || H5G_GROUP != sb_hard2.type) + if(H5O_TYPE_GROUP != oi_hard1.type || H5O_TYPE_GROUP != oi_hard2.type) FAIL_PUTS_ERROR(" Unexpected object type, should have been a group") - if(HDmemcmp(&sb_hard1.objno, &sb_hard2.objno, sizeof(sb_hard1.objno))) + if(H5F_addr_ne(oi_hard1.addr, oi_hard2.addr)) FAIL_PUTS_ERROR(" Hard link test failed. Link seems not to point to the expected file location.") /* Check soft links */ - if(H5Lget_val(file, "group2/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Lget_val(file, "group2/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR if(HDstrcmp(linkval, "/group1/group_move")) FAIL_PUTS_ERROR(" Soft link test failed. Wrong link value") @@ -2128,7 +2132,7 @@ test_full_group_compact(hid_t fapl) { hid_t file_id = -1; hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5G_stat_t sb; /* Stat buffer for object */ + H5O_info_t oi; /* Stat buffer for object */ char objname[128]; /* Buffer for name of objects to create */ char objname2[128]; /* Buffer for name of objects to create */ char filename[1024]; /* Buffer for filename */ @@ -2200,8 +2204,8 @@ test_full_group_compact(hid_t fapl) /* Check reference count on objects to keep */ for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { sprintf(objname, "/keep/keep %u\n", u); - if(H5Gget_objinfo(file_id, objname, TRUE, &sb) < 0) FAIL_STACK_ERROR - if(sb.nlink != 2) TEST_ERROR + if(H5Oget_info(file_id, objname, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi.rc != 2) TEST_ERROR } /* end for */ /* Close the file */ @@ -2217,8 +2221,8 @@ test_full_group_compact(hid_t fapl) /* Check reference count on objects to keep */ for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { sprintf(objname, "/keep/keep %u\n", u); - if(H5Gget_objinfo(file_id, objname, TRUE, &sb) < 0) FAIL_STACK_ERROR - if(sb.nlink != 1) TEST_ERROR + if(H5Oget_info(file_id, objname, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi.rc != 1) TEST_ERROR } /* end for */ /* Close the file */ @@ -2262,7 +2266,7 @@ test_full_group_dense(hid_t fapl) hid_t file_id = -1; hid_t gcpl = (-1); /* Group creation property list ID */ hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5G_stat_t sb; /* Stat buffer for object */ + H5O_info_t oi; /* Stat buffer for object */ char objname[128]; /* Buffer for name of objects to create */ char objname2[128]; /* Buffer for name of objects to create */ char filename[1024]; /* Buffer for filename */ @@ -2346,8 +2350,8 @@ test_full_group_dense(hid_t fapl) /* Check reference count on objects to keep */ for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { sprintf(objname, "/keep/keep %u\n", u); - if(H5Gget_objinfo(file_id, objname, TRUE, &sb) < 0) FAIL_STACK_ERROR - if(sb.nlink != 2) TEST_ERROR + if(H5Oget_info(file_id, objname, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi.rc != 2) TEST_ERROR } /* end for */ /* Close the file */ @@ -2363,8 +2367,8 @@ test_full_group_dense(hid_t fapl) /* Check reference count on objects to keep */ for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { sprintf(objname, "/keep/keep %u\n", u); - if(H5Gget_objinfo(file_id, objname, TRUE, &sb) < 0) FAIL_STACK_ERROR - if(sb.nlink != 1) TEST_ERROR + if(H5Oget_info(file_id, objname, &oi, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi.rc != 1) TEST_ERROR } /* end for */ /* Close the file */ @@ -1017,10 +1017,8 @@ test_multi(void) /* Before any data is written, the raw data file is empty. So * the file size is only the size of b-tree + HADDR_MAX/4. */ -#ifdef H5_HAVE_LARGE_HSIZET if(file_size < HADDR_MAX/4 || file_size > HADDR_MAX/2) TEST_ERROR; -#endif /* H5_HAVE_LARGE_HSIZET */ if((dset=H5Dcreate(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT))<0) TEST_ERROR; @@ -1055,10 +1053,8 @@ test_multi(void) * beginning of raw data file is set at HADDR_MAX/2. It's supposed * to be (HADDR_MAX/2 + 128*128*4) */ -#ifdef H5_HAVE_LARGE_HSIZET if(file_size < HADDR_MAX/2 || file_size > HADDR_MAX) TEST_ERROR; -#endif /* H5_HAVE_LARGE_HSIZET */ if(H5Sclose(space)<0) TEST_ERROR; diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c index 13059f2..c5c447c 100644 --- a/tools/h5diff/h5diff_main.c +++ b/tools/h5diff/h5diff_main.c @@ -65,29 +65,29 @@ int main(int argc, const char *argv[]) { - int ret; - const char *fname1 = NULL; - const char *fname2 = NULL; - const char *objname1 = NULL; - const char *objname2 = NULL; - hsize_t nfound=0; - diff_opt_t options; + int ret; + const char *fname1 = NULL; + const char *fname2 = NULL; + const char *objname1 = NULL; + const char *objname2 = NULL; + hsize_t nfound=0; + diff_opt_t options; - parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); - nfound = h5diff(fname1,fname2,objname1,objname2,&options); + nfound = h5diff(fname1,fname2,objname1,objname2,&options); - print_info(&options); + print_info(&options); -/*------------------------------------------------------------------------- - * exit code - * >0 if differences, 0 if no differences, <0 if error - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * exit code + * >0 if differences, 0 if no differences, <0 if error + *------------------------------------------------------------------------- + */ - ret= (nfound==0 ? 0 : 1 ); - if (options.err_stat) - ret=-1; - return ret; + ret = (nfound == 0 ? 0 : 1 ); + if(options.err_stat) + ret = -1; + return ret; } diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c index 989a74b..9cbc993 100644 --- a/tools/h5diff/ph5diff_main.c +++ b/tools/h5diff/ph5diff_main.c @@ -72,40 +72,40 @@ int main(int argc, const char *argv[]) if(g_nTasks == 1) { - printf("Only 1 task available...doing serial diff\n"); + printf("Only 1 task available...doing serial diff\n"); - g_Parallel = 0; + g_Parallel = 0; - parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); - nfound = h5diff(fname1,fname2,objname1,objname2,&options); + nfound = h5diff(fname1, fname2, objname1, objname2, &options); - print_info(&options); + print_info(&options); - MPI_Finalize(); + MPI_Finalize(); - return 0; + return 0; } /* Have the manager process the command-line */ if(nID == 0) { - parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_input(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); - nfound = h5diff(fname1,fname2,objname1,objname2,&options); + nfound = h5diff(fname1, fname2, objname1, objname2, &options); - MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); - print_info(&options); - print_manager_output(); + print_info(&options); + print_manager_output(); - MPI_Finalize(); + MPI_Finalize(); - return 0; + return 0; } /* All other tasks become workers and wait for assignments. */ else - ph5diff_worker(nID); + ph5diff_worker(nID); } /*------------------------------------------------------------------------- diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 0a2ca3b..5706837 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -56,7 +56,7 @@ const char *progname = "h5dump"; #define H5_SZIP_RAW_OPTION_MASK 128 int d_status = EXIT_SUCCESS; -static int unamedtype = 0; /* shared data type with no name */ +static int unamedtype = 0; /* shared datatype with no name */ static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; static size_t prefix_len = 1024; static char *prefix; @@ -621,7 +621,7 @@ usage(const char *prog) fprintf(stdout, " with -o (output file) and -d (dataset). B can be:\n"); fprintf(stdout, " MEMORY for a memory type, FILE for the file type,\n"); fprintf(stdout, " LE or BE for pre-existing little or big endian types\n"); - fprintf(stdout, " -t P, --datatype=P Print the specified named data type\n"); + fprintf(stdout, " -t P, --datatype=P Print the specified named datatype\n"); fprintf(stdout, " -w N, --width=N Set the number of columns of output\n"); fprintf(stdout, " -x, --xml Output in XML using Schema\n"); fprintf(stdout, " -u, --use-dtd Output in XML using DTD\n"); @@ -674,7 +674,7 @@ usage(const char *prog) /*------------------------------------------------------------------------- * Function: print_datatype * - * Purpose: print the data type. + * Purpose: print the datatype. * * Return: void * @@ -706,16 +706,14 @@ print_datatype(hid_t type,unsigned in_group) const char *sign_s=NULL; /* sign scheme string */ if (!in_group && H5Tcommitted(type) > 0) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oinfo; obj_t *obj; /* Found object */ - H5Gget_objinfo(type, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - obj = search_obj(type_table, objno); + H5Oget_info(type, ".", &oinfo, H5P_DEFAULT); + obj = search_obj(type_table, oinfo.addr); - if (obj) { - if (!obj->recorded) + if(obj) { + if(!obj->recorded) HDfprintf(stdout,"\"/#%a\"", obj->objno); else printf("\"%s\"", obj->objname); @@ -724,371 +722,369 @@ print_datatype(hid_t type,unsigned in_group) d_status = EXIT_FAILURE; } } else { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - if (H5Tequal(type, H5T_STD_I8BE)==TRUE) { - printf("H5T_STD_I8BE"); - } else if (H5Tequal(type, H5T_STD_I8LE)==TRUE) { - printf("H5T_STD_I8LE"); - } else if (H5Tequal(type, H5T_STD_I16BE)==TRUE) { - printf("H5T_STD_I16BE"); - } else if (H5Tequal(type, H5T_STD_I16LE)==TRUE) { - printf("H5T_STD_I16LE"); - } else if (H5Tequal(type, H5T_STD_I32BE)==TRUE) { - printf("H5T_STD_I32BE"); - } else if (H5Tequal(type, H5T_STD_I32LE)==TRUE) { - printf("H5T_STD_I32LE"); - } else if (H5Tequal(type, H5T_STD_I64BE)==TRUE) { - printf("H5T_STD_I64BE"); - } else if (H5Tequal(type, H5T_STD_I64LE)==TRUE) { - printf("H5T_STD_I64LE"); - } else if (H5Tequal(type, H5T_STD_U8BE)==TRUE) { - printf("H5T_STD_U8BE"); - } else if (H5Tequal(type, H5T_STD_U8LE)==TRUE) { - printf("H5T_STD_U8LE"); - } else if (H5Tequal(type, H5T_STD_U16BE)==TRUE) { - printf("H5T_STD_U16BE"); - } else if (H5Tequal(type, H5T_STD_U16LE)==TRUE) { - printf("H5T_STD_U16LE"); - } else if (H5Tequal(type, H5T_STD_U32BE)==TRUE) { - printf("H5T_STD_U32BE"); - } else if (H5Tequal(type, H5T_STD_U32LE)==TRUE) { - printf("H5T_STD_U32LE"); - } else if (H5Tequal(type, H5T_STD_U64BE)==TRUE) { - printf("H5T_STD_U64BE"); - } else if (H5Tequal(type, H5T_STD_U64LE)==TRUE) { - printf("H5T_STD_U64LE"); - } else if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) { - printf("H5T_NATIVE_SCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) { - printf("H5T_NATIVE_UCHAR"); - } else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) { - printf("H5T_NATIVE_SHORT"); - } else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) { - printf("H5T_NATIVE_USHORT"); - } else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) { - printf("H5T_NATIVE_INT"); - } else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) { - printf("H5T_NATIVE_UINT"); - } else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) { - printf("H5T_NATIVE_LONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) { - printf("H5T_NATIVE_ULONG"); - } else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) { - printf("H5T_NATIVE_LLONG"); - } else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) { - printf("H5T_NATIVE_ULLONG"); - } else { + switch(H5Tget_class(type)) { + case H5T_INTEGER: + if(H5Tequal(type, H5T_STD_I8BE) == TRUE) { + printf("H5T_STD_I8BE"); + } else if(H5Tequal(type, H5T_STD_I8LE) == TRUE) { + printf("H5T_STD_I8LE"); + } else if(H5Tequal(type, H5T_STD_I16BE) == TRUE) { + printf("H5T_STD_I16BE"); + } else if(H5Tequal(type, H5T_STD_I16LE) == TRUE) { + printf("H5T_STD_I16LE"); + } else if(H5Tequal(type, H5T_STD_I32BE) == TRUE) { + printf("H5T_STD_I32BE"); + } else if(H5Tequal(type, H5T_STD_I32LE) == TRUE) { + printf("H5T_STD_I32LE"); + } else if(H5Tequal(type, H5T_STD_I64BE) == TRUE) { + printf("H5T_STD_I64BE"); + } else if(H5Tequal(type, H5T_STD_I64LE) == TRUE) { + printf("H5T_STD_I64LE"); + } else if(H5Tequal(type, H5T_STD_U8BE) == TRUE) { + printf("H5T_STD_U8BE"); + } else if(H5Tequal(type, H5T_STD_U8LE) == TRUE) { + printf("H5T_STD_U8LE"); + } else if(H5Tequal(type, H5T_STD_U16BE) == TRUE) { + printf("H5T_STD_U16BE"); + } else if(H5Tequal(type, H5T_STD_U16LE) == TRUE) { + printf("H5T_STD_U16LE"); + } else if(H5Tequal(type, H5T_STD_U32BE) == TRUE) { + printf("H5T_STD_U32BE"); + } else if(H5Tequal(type, H5T_STD_U32LE) == TRUE) { + printf("H5T_STD_U32LE"); + } else if(H5Tequal(type, H5T_STD_U64BE) == TRUE) { + printf("H5T_STD_U64BE"); + } else if(H5Tequal(type, H5T_STD_U64LE) == TRUE) { + printf("H5T_STD_U64LE"); + } else if(H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) { + printf("H5T_NATIVE_SCHAR"); + } else if(H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) { + printf("H5T_NATIVE_UCHAR"); + } else if(H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) { + printf("H5T_NATIVE_SHORT"); + } else if(H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) { + printf("H5T_NATIVE_USHORT"); + } else if(H5Tequal(type, H5T_NATIVE_INT) == TRUE) { + printf("H5T_NATIVE_INT"); + } else if(H5Tequal(type, H5T_NATIVE_UINT) == TRUE) { + printf("H5T_NATIVE_UINT"); + } else if(H5Tequal(type, H5T_NATIVE_LONG) == TRUE) { + printf("H5T_NATIVE_LONG"); + } else if(H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) { + printf("H5T_NATIVE_ULONG"); + } else if(H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) { + printf("H5T_NATIVE_LLONG"); + } else if(H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) { + printf("H5T_NATIVE_ULLONG"); + } else { - /* byte order */ - if (H5Tget_size(type)>1) - { - order = H5Tget_order(type); - if (H5T_ORDER_LE==order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE==order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX==order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* sign */ - if ((sign=H5Tget_sign(type))>=0) - { - if (H5T_SGN_NONE==sign) { - sign_s = " unsigned"; - } else if (H5T_SGN_2==sign) { - sign_s = ""; - } else { - sign_s = " unknown-sign"; - } - } else { - sign_s = " unknown-sign"; - } - - /* print size, order, and sign */ - printf("%lu-bit%s%s integer", - (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); - } - break; + /* byte order */ + if(H5Tget_size(type)>1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) { + order_s = " little-endian"; + } else if (H5T_ORDER_BE == order) { + order_s = " big-endian"; + } else if (H5T_ORDER_VAX == order) { + order_s = " mixed-endian"; + } else { + order_s = " unknown-byte-order"; + } + } else { + order_s = ""; + } + + /* sign */ + if ((sign=H5Tget_sign(type))>=0) + { + if (H5T_SGN_NONE == sign) { + sign_s = " unsigned"; + } else if (H5T_SGN_2 == sign) { + sign_s = ""; + } else { + sign_s = " unknown-sign"; + } + } else { + sign_s = " unknown-sign"; + } + + /* print size, order, and sign */ + printf("%lu-bit%s%s integer", + (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); + } + break; - case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE)==TRUE) { - printf("H5T_IEEE_F32BE"); - } else if (H5Tequal(type, H5T_IEEE_F32LE)==TRUE) { - printf("H5T_IEEE_F32LE"); - } else if (H5Tequal(type, H5T_IEEE_F64BE)==TRUE) { - printf("H5T_IEEE_F64BE"); - } else if (H5Tequal(type, H5T_IEEE_F64LE)==TRUE) { - printf("H5T_IEEE_F64LE"); - } else if (H5Tequal(type, H5T_VAX_F32)==TRUE) { - printf("H5T_VAX_F32"); - } else if (H5Tequal(type, H5T_VAX_F64)==TRUE) { - printf("H5T_VAX_F64"); - } else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) { - printf("H5T_NATIVE_FLOAT"); - } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) { - printf("H5T_NATIVE_DOUBLE"); + case H5T_FLOAT: + if(H5Tequal(type, H5T_IEEE_F32BE) == TRUE) { + printf("H5T_IEEE_F32BE"); + } else if(H5Tequal(type, H5T_IEEE_F32LE) == TRUE) { + printf("H5T_IEEE_F32LE"); + } else if(H5Tequal(type, H5T_IEEE_F64BE) == TRUE) { + printf("H5T_IEEE_F64BE"); + } else if(H5Tequal(type, H5T_IEEE_F64LE) == TRUE) { + printf("H5T_IEEE_F64LE"); + } else if(H5Tequal(type, H5T_VAX_F32) == TRUE) { + printf("H5T_VAX_F32"); + } else if(H5Tequal(type, H5T_VAX_F64) == TRUE) { + printf("H5T_VAX_F64"); + } else if(H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) { + printf("H5T_NATIVE_FLOAT"); + } else if(H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) { + printf("H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 - } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) { - printf("H5T_NATIVE_LDOUBLE"); + } else if(H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) { + printf("H5T_NATIVE_LDOUBLE"); #endif - } else { - - /* byte order */ - if (H5Tget_size(type)>1) - { - order = H5Tget_order(type); - if (H5T_ORDER_LE==order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE==order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX==order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* print size and byte order */ - printf("%lu-bit%s floating-point", - (unsigned long)(8*H5Tget_size(type)), order_s); + } else { - } - break; + /* byte order */ + if(H5Tget_size(type)>1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) { + order_s = " little-endian"; + } else if (H5T_ORDER_BE == order) { + order_s = " big-endian"; + } else if (H5T_ORDER_VAX == order) { + order_s = " mixed-endian"; + } else { + order_s = " unknown-byte-order"; + } + } else { + order_s = ""; + } - case H5T_TIME: - printf("H5T_TIME: not yet implemented"); - break; + /* print size and byte order */ + printf("%lu-bit%s floating-point", + (unsigned long)(8*H5Tget_size(type)), order_s); - case H5T_STRING: - /* Make a copy of type in memory in case when TYPE is on disk, the size - * will be bigger than in memory. This makes it easier to compare - * types in memory. */ - tmp_type = H5Tcopy(type); - size = H5Tget_size(tmp_type); - str_pad = H5Tget_strpad(tmp_type); - cset = H5Tget_cset(tmp_type); - is_vlstr = H5Tis_variable_str(tmp_type); - - printf("H5T_STRING %s\n", dump_header_format->strblockbegin); - indent += COL; + } + break; - indentation(indent + COL); - if(is_vlstr) - printf("%s H5T_VARIABLE;\n", STRSIZE); - else - printf("%s %d;\n", STRSIZE, (int) size); + case H5T_TIME: + printf("H5T_TIME: not yet implemented"); + break; - indentation(indent + COL); - printf("%s ", STRPAD); - if (str_pad == H5T_STR_NULLTERM) - printf("H5T_STR_NULLTERM;\n"); - else if (str_pad == H5T_STR_NULLPAD) - printf("H5T_STR_NULLPAD;\n"); - else if (str_pad == H5T_STR_SPACEPAD) - printf("H5T_STR_SPACEPAD;\n"); - else - printf("H5T_STR_ERROR;\n"); + case H5T_STRING: + /* Make a copy of type in memory in case when TYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + tmp_type = H5Tcopy(type); + size = H5Tget_size(tmp_type); + str_pad = H5Tget_strpad(tmp_type); + cset = H5Tget_cset(tmp_type); + is_vlstr = H5Tis_variable_str(tmp_type); + + printf("H5T_STRING %s\n", dump_header_format->strblockbegin); + indent += COL; - indentation(indent + COL); - printf("%s ", CSET); + indentation(indent + COL); + if(is_vlstr) + printf("%s H5T_VARIABLE;\n", STRSIZE); + else + printf("%s %d;\n", STRSIZE, (int) size); - if (cset == H5T_CSET_ASCII) - printf("H5T_CSET_ASCII;\n"); - else - printf("unknown_cset;\n"); + indentation(indent + COL); + printf("%s ", STRPAD); + if (str_pad == H5T_STR_NULLTERM) + printf("H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + printf("H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + printf("H5T_STR_SPACEPAD;\n"); + else + printf("H5T_STR_ERROR;\n"); - str_type = H5Tcopy(H5T_C_S1); - if(is_vlstr) - H5Tset_size(str_type, H5T_VARIABLE); - else - H5Tset_size(str_type, size); - H5Tset_cset(str_type, cset); - H5Tset_strpad(str_type, str_pad); + indentation(indent + COL); + printf("%s ", CSET); - indentation(indent + COL); - printf("%s ", CTYPE); + if (cset == H5T_CSET_ASCII) + printf("H5T_CSET_ASCII;\n"); + else + printf("unknown_cset;\n"); - /* Check C variable-length string first. Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - printf("H5T_C_S1;\n"); - goto done; - } + str_type = H5Tcopy(H5T_C_S1); + if(is_vlstr) + H5Tset_size(str_type, H5T_VARIABLE); + else + H5Tset_size(str_type, size); + H5Tset_cset(str_type, cset); + H5Tset_strpad(str_type, str_pad); - /* Change the endianness and see if they're equal. */ - order = H5Tget_order(tmp_type); - if(order==H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if(order==H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); + indentation(indent + COL); + printf("%s ", CTYPE); - if (H5Tequal(tmp_type, str_type)) { - printf("H5T_C_S1;\n"); - goto done; - } + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + printf("H5T_C_S1;\n"); + goto done; + } - /* If not equal to C variable-length string, check Fortran type. */ - H5Tclose(str_type); - str_type = H5Tcopy(H5T_FORTRAN_S1); - H5Tset_cset(str_type, cset); - H5Tset_size(str_type, size); - H5Tset_strpad(str_type, str_pad); - - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - printf("H5T_FORTRAN_S1;\n"); - goto done; - } + /* Change the endianness and see if they're equal. */ + order = H5Tget_order(tmp_type); + if(order==H5T_ORDER_LE) + H5Tset_order(str_type, H5T_ORDER_LE); + else if(order==H5T_ORDER_BE) + H5Tset_order(str_type, H5T_ORDER_BE); - /* Change the endianness and see if they're equal. */ - order = H5Tget_order(tmp_type); - if(order==H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if(order==H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); + if (H5Tequal(tmp_type, str_type)) { + printf("H5T_C_S1;\n"); + goto done; + } - if (H5Tequal(tmp_type, str_type)) { - printf("H5T_FORTRAN_S1;\n"); - goto done; - } + /* If not equal to C variable-length string, check Fortran type. */ + H5Tclose(str_type); + str_type = H5Tcopy(H5T_FORTRAN_S1); + H5Tset_cset(str_type, cset); + H5Tset_size(str_type, size); + H5Tset_strpad(str_type, str_pad); - /* Type doesn't match any of above. */ - printf("unknown_one_character_type;\n "); - d_status = EXIT_FAILURE; + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + printf("H5T_FORTRAN_S1;\n"); + goto done; + } -done: - H5Tclose(str_type); - H5Tclose(tmp_type); + /* Change the endianness and see if they're equal. */ + order = H5Tget_order(tmp_type); + if(order==H5T_ORDER_LE) + H5Tset_order(str_type, H5T_ORDER_LE); + else if(order==H5T_ORDER_BE) + H5Tset_order(str_type, H5T_ORDER_BE); - indent -= COL; - indentation(indent + COL); - printf("%s", dump_header_format->strblockend); - break; + if (H5Tequal(tmp_type, str_type)) { + printf("H5T_FORTRAN_S1;\n"); + goto done; + } - case H5T_BITFIELD: - if (H5Tequal(type, H5T_STD_B8BE)==TRUE) { - printf("H5T_STD_B8BE"); - } else if (H5Tequal(type, H5T_STD_B8LE)==TRUE) { - printf("H5T_STD_B8LE"); - } else if (H5Tequal(type, H5T_STD_B16BE)==TRUE) { - printf("H5T_STD_B16BE"); - } else if (H5Tequal(type, H5T_STD_B16LE)==TRUE) { - printf("H5T_STD_B16LE"); - } else if (H5Tequal(type, H5T_STD_B32BE)==TRUE) { - printf("H5T_STD_B32BE"); - } else if (H5Tequal(type, H5T_STD_B32LE)==TRUE) { - printf("H5T_STD_B32LE"); - } else if (H5Tequal(type, H5T_STD_B64BE)==TRUE) { - printf("H5T_STD_B64BE"); - } else if (H5Tequal(type, H5T_STD_B64LE)==TRUE) { - printf("H5T_STD_B64LE"); - } else { - printf("undefined bitfield"); + /* Type doesn't match any of above. */ + printf("unknown_one_character_type;\n "); d_status = EXIT_FAILURE; - } - break; - case H5T_OPAQUE: - printf("\n"); - indentation(indent + COL); - printf("H5T_OPAQUE;\n"); - indentation(indent + COL); - printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type)); - indentation(indent); - break; + done: + H5Tclose(str_type); + H5Tclose(tmp_type); + + indent -= COL; + indentation(indent + COL); + printf("%s", dump_header_format->strblockend); + break; - case H5T_COMPOUND: - nmembers = H5Tget_nmembers(type); - printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin); + case H5T_BITFIELD: + if (H5Tequal(type, H5T_STD_B8BE)==TRUE) { + printf("H5T_STD_B8BE"); + } else if (H5Tequal(type, H5T_STD_B8LE)==TRUE) { + printf("H5T_STD_B8LE"); + } else if (H5Tequal(type, H5T_STD_B16BE)==TRUE) { + printf("H5T_STD_B16BE"); + } else if (H5Tequal(type, H5T_STD_B16LE)==TRUE) { + printf("H5T_STD_B16LE"); + } else if (H5Tequal(type, H5T_STD_B32BE)==TRUE) { + printf("H5T_STD_B32BE"); + } else if (H5Tequal(type, H5T_STD_B32LE)==TRUE) { + printf("H5T_STD_B32LE"); + } else if (H5Tequal(type, H5T_STD_B64BE)==TRUE) { + printf("H5T_STD_B64BE"); + } else if (H5Tequal(type, H5T_STD_B64LE)==TRUE) { + printf("H5T_STD_B64LE"); + } else { + printf("undefined bitfield"); + d_status = EXIT_FAILURE; + } + break; - for (i = 0; i < nmembers; i++) { - mname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); + case H5T_OPAQUE: + printf("\n"); + indentation(indent + COL); + printf("H5T_OPAQUE;\n"); indentation(indent + COL); + printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type)); + indentation(indent); + break; - if (H5Tget_class(mtype) == H5T_COMPOUND) - indent += COL; + case H5T_COMPOUND: + nmembers = H5Tget_nmembers(type); + printf("H5T_COMPOUND %s\n", dump_header_format->structblockbegin); - print_datatype(mtype,0); + for (i = 0; i < nmembers; i++) { + mname = H5Tget_member_name(type, i); + mtype = H5Tget_member_type(type, i); + indentation(indent + COL); - if (H5Tget_class(mtype) == H5T_COMPOUND) - indent -= COL; + if (H5Tget_class(mtype) == H5T_COMPOUND) + indent += COL; - printf(" \"%s\";\n", mname); - free(mname); - } + print_datatype(mtype,0); - indentation(indent); - printf("%s", dump_header_format->structblockend); - break; + if (H5Tget_class(mtype) == H5T_COMPOUND) + indent -= COL; - case H5T_REFERENCE: - printf("H5T_REFERENCE"); - break; + printf(" \"%s\";\n", mname); + free(mname); + } - case H5T_ENUM: - printf("H5T_ENUM %s\n", dump_header_format->enumblockbegin); - indent += COL; - indentation(indent + COL); - super = H5Tget_super(type); - print_datatype(super,0); - printf(";\n"); - print_enum(type); - indent -= COL; - indentation(indent + COL); - printf("%s", dump_header_format->enumblockend); - break; + indentation(indent); + printf("%s", dump_header_format->structblockend); + break; - case H5T_VLEN: - printf("H5T_VLEN %s ", dump_header_format->vlenblockbegin); - super = H5Tget_super(type); - print_datatype(super,0); - H5Tclose(super); + case H5T_REFERENCE: + printf("H5T_REFERENCE"); + break; - /* Print closing */ - printf("%s", dump_header_format->vlenblockend); - break; + case H5T_ENUM: + printf("H5T_ENUM %s\n", dump_header_format->enumblockbegin); + indent += COL; + indentation(indent + COL); + super = H5Tget_super(type); + print_datatype(super,0); + printf(";\n"); + print_enum(type); + indent -= COL; + indentation(indent + COL); + printf("%s", dump_header_format->enumblockend); + break; - case H5T_ARRAY: - /* Get array base type */ - super = H5Tget_super(type); + case H5T_VLEN: + printf("H5T_VLEN %s ", dump_header_format->vlenblockbegin); + super = H5Tget_super(type); + print_datatype(super,0); + H5Tclose(super); - /* Print lead-in */ - printf("H5T_ARRAY { "); + /* Print closing */ + printf("%s", dump_header_format->vlenblockend); + break; - /* Get array information */ - ndims = H5Tget_array_ndims(type); - H5Tget_array_dims(type, dims, NULL); + case H5T_ARRAY: + /* Get array base type */ + super = H5Tget_super(type); - /* Print array dimensions */ - for (i = 0; i < ndims; i++) - printf("[%d]", (int) dims[i]); + /* Print lead-in */ + printf("H5T_ARRAY { "); - printf(" "); + /* Get array information */ + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims(type, dims, NULL); - /* Print base type */ - print_datatype(super,0); + /* Print array dimensions */ + for (i = 0; i < ndims; i++) + printf("[%d]", (int) dims[i]); - /* Close array base type */ - H5Tclose(super); + printf(" "); - /* Print closing */ - printf(" }"); + /* Print base type */ + print_datatype(super,0); - break; + /* Close array base type */ + H5Tclose(super); - default: - printf("unknown data type"); - d_status = EXIT_FAILURE; - break; + /* Print closing */ + printf(" }"); + + break; + + default: + printf("unknown datatype"); + d_status = EXIT_FAILURE; + break; } } /* end else */ } @@ -1097,8 +1093,8 @@ done: /*------------------------------------------------------------------------- * Function: dump_datatype * - * Purpose: Dump the data type. Data type can be HDF5 predefined - * atomic data type or committed/transient data type. + * Purpose: Dump the datatype. Datatype can be HDF5 predefined + * atomic datatype or committed/transient datatype. * * Return: void * @@ -1127,7 +1123,7 @@ dump_datatype(hid_t type) /*------------------------------------------------------------------------- * Function: dump_dataspace * - * Purpose: Dump the data space. Data space can be named data space, + * Purpose: Dump the dataspace. Dataspace can be named dataspace, * array, or others. * * Return: void @@ -1150,49 +1146,52 @@ dump_dataspace(hid_t space) indentation(indent + COL); printf("%s ", dump_header_format->dataspacebegin); - switch (space_type) { + switch(space_type) { case H5S_SCALAR: - /* scalar dataspace */ - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedescriptionbegin, S_SCALAR); + /* scalar dataspace */ + HDfprintf(stdout, "%s %s", + dump_header_format->dataspacedescriptionbegin, S_SCALAR); break; + case H5S_SIMPLE: - /* simple dataspace */ - HDfprintf(stdout, "%s %s { %s %Hu", - dump_header_format->dataspacedescriptionbegin, S_SIMPLE, - dump_header_format->dataspacedimbegin, size[0]); + /* simple dataspace */ + HDfprintf(stdout, "%s %s { %s %Hu", + dump_header_format->dataspacedescriptionbegin, S_SIMPLE, + dump_header_format->dataspacedimbegin, size[0]); - for (i = 1; i < ndims; i++) - HDfprintf(stdout, ", %Hu", size[i]); + for(i = 1; i < ndims; i++) + HDfprintf(stdout, ", %Hu", size[i]); - printf(" %s / ", dump_header_format->dataspacedimend); + printf(" %s / ", dump_header_format->dataspacedimend); - if (maxsize[0] == H5S_UNLIMITED) - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedimbegin, - "H5S_UNLIMITED"); - else - HDfprintf(stdout, "%s %Hu", - dump_header_format->dataspacedimbegin, maxsize[0]); + if(maxsize[0] == H5S_UNLIMITED) + HDfprintf(stdout, "%s %s", + dump_header_format->dataspacedimbegin, + "H5S_UNLIMITED"); + else + HDfprintf(stdout, "%s %Hu", + dump_header_format->dataspacedimbegin, maxsize[0]); - for (i = 1; i < ndims; i++) - if (maxsize[i] == H5S_UNLIMITED) - HDfprintf(stdout, ", %s", "H5S_UNLIMITED"); - else - HDfprintf(stdout, ", %Hu", maxsize[i]); + for(i = 1; i < ndims; i++) + if(maxsize[i] == H5S_UNLIMITED) + HDfprintf(stdout, ", %s", "H5S_UNLIMITED"); + else + HDfprintf(stdout, ", %Hu", maxsize[i]); - printf(" %s }", dump_header_format->dataspacedimend); + printf(" %s }", dump_header_format->dataspacedimend); + break; - break; case H5S_NULL: - /* null dataspace */ - HDfprintf(stdout, "%s %s", - dump_header_format->dataspacedescriptionbegin, S_NULL); + /* null dataspace */ + HDfprintf(stdout, "%s %s", + dump_header_format->dataspacedescriptionbegin, S_NULL); break; + case H5S_NO_CLASS: default: - printf("%s unknown dataspace %s\n", BEGIN, END); - } + printf("%s unknown dataspace %s\n", BEGIN, END); + break; + } /* end switch */ end_obj(dump_header_format->dataspaceend, dump_header_format->dataspaceblockend); @@ -1214,41 +1213,44 @@ dump_dataspace(hid_t space) *------------------------------------------------------------------------- */ static herr_t -dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) +dump_attr(hid_t oid, const char *attr_name, void UNUSED * op_data) { - hid_t attr_id, type, space; + hid_t attr_id; herr_t ret = SUCCEED; indentation(indent); begin_obj(dump_header_format->attributebegin, attr_name, dump_header_format->attributeblockbegin); - if ((attr_id = H5Aopen_name(attr, attr_name)) < 0) { - indentation(indent + COL); + if((attr_id = H5Aopen_name(oid, attr_name)) < 0) { + indentation(indent + COL); error_msg(progname, "unable to open attribute \"%s\"\n", attr_name); - indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - ret = FAIL; + indentation(indent); + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + ret = FAIL; } else { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); - dump_datatype(type); - dump_dataspace(space); + hid_t type, space; - if (display_oid) - dump_oid(attr_id); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); + dump_datatype(type); + dump_dataspace(space); - if (display_data || display_attr_data) - dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); + if(display_oid) + dump_oid(attr_id); - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - indentation(indent); - end_obj(dump_header_format->attributeend, - dump_header_format->attributeblockend); + if(display_data || display_attr_data) + dump_data(attr_id, ATTRIBUTE_DATA, NULL, display_ai); + + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + + indentation(indent); + end_obj(dump_header_format->attributeend, + dump_header_format->attributeblockend); } return ret; @@ -1272,72 +1274,42 @@ dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) static herr_t dump_selected_attr(hid_t loc_id, const char *name) { - int j; + hid_t oid, attr_id; char *obj_name; const char *attr_name; - hid_t oid, attr_id, type, space; - H5G_stat_t statbuf; + int j; - j = (int)strlen(name) - 1; - obj_name = malloc((size_t)j + 2); + j = (int)HDstrlen(name) - 1; + obj_name = HDmalloc((size_t)j + 2); /* find the last / */ - while (name[j] != '/' && j >= 0) - j--; + while(name[j] != '/' && j >= 0) + j--; /* object name */ - if (j == -1) { - strcpy(obj_name, "/"); - } else { - strncpy(obj_name, name, (size_t)j + 1); + if(j == -1) + HDstrcpy(obj_name, "/"); + else { + HDstrncpy(obj_name, name, (size_t)j + 1); obj_name[j + 1] = '\0'; - } + } /* end else */ attr_name = name + j + 1; begin_obj(dump_header_format->attributebegin, name, dump_header_format->attributeblockbegin); - H5Gget_objinfo(loc_id, obj_name, FALSE, &statbuf); - - switch(statbuf.type) { - case H5G_GROUP: - if((oid = H5Gopen2(loc_id, obj_name, H5P_DEFAULT)) < 0) { - indentation(COL); - error_msg(progname, "unable to open group \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - - case H5G_DATASET: - if((oid = H5Dopen(loc_id, obj_name)) < 0) { - indentation(COL); - error_msg(progname, "unable to open dataset \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - case H5G_TYPE: - if((oid = H5Topen(loc_id, obj_name)) < 0) { - indentation(COL); - error_msg(progname, "unable to open datatype \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - - default: - indentation(COL); - error_msg(progname, "unable to open unknown \"%s\"\n", obj_name); - end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; - return FAIL; - } /* end switch */ + /* Open the object with the attribute */ + if((oid = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) { + indentation(COL); + error_msg(progname, "unable to open object \"%s\"\n", obj_name); + end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); + d_status = EXIT_FAILURE; + return FAIL; + } /* end if */ if((attr_id = H5Aopen_name(oid, attr_name)) >= 0) { + hid_t type, space; + type = H5Aget_type(attr_id); space = H5Aget_space(attr_id); dump_datatype(type); @@ -1361,34 +1333,13 @@ dump_selected_attr(hid_t loc_id, const char *name) d_status = EXIT_FAILURE; } - switch(statbuf.type) { - case H5G_GROUP: - if(H5Gclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - - case H5G_DATASET: - if(H5Dclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - - case H5G_TYPE: - if(H5Tclose(oid) < 0) { - d_status = EXIT_FAILURE; - return FAIL; - } /* end if */ - break; - - default: - d_status = EXIT_FAILURE; - return FAIL; - } /* end switch */ + /* Close object */ + if(H5Oclose(oid) < 0) { + d_status = EXIT_FAILURE; + return FAIL; + } /* end if */ - free(obj_name); + HDfree(obj_name); return SUCCEED; } @@ -1411,24 +1362,12 @@ dump_selected_attr(hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ static herr_t -dump_all(hid_t group, const char *name, const H5L_info_t *linfo, void * op_data) +dump_all(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data) { hid_t obj; char *obj_path = NULL; /* Full path of object */ - H5G_stat_t statbuf; herr_t ret = SUCCEED; - /* Stat the object */ - if(H5Gget_objinfo(group, name, FALSE, &statbuf) < 0) { - error_msg(progname, "unable to get object information for \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - goto done; - } /* end if */ - - if (*(int *)op_data != H5G_UNKNOWN && statbuf.type != *(int *) op_data) - goto done; - /* Build the object's path name */ obj_path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDassert(obj_path); @@ -1436,356 +1375,359 @@ dump_all(hid_t group, const char *name, const H5L_info_t *linfo, void * op_data) HDstrcat(obj_path, "/"); HDstrcat(obj_path, name); - switch (statbuf.type) { - case H5G_LINK: - { - char *targbuf; - - indentation(indent); - targbuf = HDmalloc(statbuf.linklen); - HDassert(targbuf); + if(linfo->type == H5L_TYPE_HARD) { + H5O_info_t oinfo; - if (!doxml) { - begin_obj(dump_header_format->softlinkbegin, name, - dump_header_format->softlinkblockbegin); - indentation(indent + COL); - } + /* Stat the object */ + if(H5Oget_info(group, name, &oinfo, H5P_DEFAULT) < 0) { + error_msg(progname, "unable to get object information for \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + goto done; + } /* end if */ - if (H5Lget_val(group, name, targbuf, statbuf.linklen, H5P_DEFAULT) < 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); + switch(oinfo.type) { + case H5O_TYPE_GROUP: + if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { + error_msg(progname, "unable to dump group \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; } 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; + char *old_prefix; /* Pointer to previous prefix */ - 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 */ + /* Keep copy of prefix before iterating into group */ + old_prefix = HDstrdup(prefix); + HDassert(old_prefix); - /* 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); + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - /* 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, /* 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, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - } - - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_targbuf); - HDfree(t_obj_path); - HDfree(t_link_path); - } - } + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - if (!doxml) { - indentation(indent); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); - } + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); - HDfree(targbuf); - break; - } + /* Close group */ + H5Gclose(obj); + } + break; - case H5G_UDLINK: - indentation(indent); - switch(linfo->type) { - case H5L_TYPE_EXTERNAL: - { - char *targbuf; + case H5O_TYPE_DATASET: + if((obj = H5Dopen(group, name)) >= 0) { + if(oinfo.rc > 1) { + obj_t *found_obj; /* Found object */ - targbuf = HDmalloc(statbuf.linklen); - HDassert(targbuf); - if(!doxml) - begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin); + found_obj = search_obj(dset_table, oinfo.addr); - if(H5Lget_val(group, name, targbuf, statbuf.linklen, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to get external link value\n"); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - const char *filename; - const char *targname; + 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(H5Lunpack_elink_val(targbuf, statbuf.linklen, NULL, &filename, &targname) < 0) { - error_msg(progname, "unable to unpack external link value\n"); - d_status = EXIT_FAILURE; - ret = FAIL; - } else { - if (!doxml) { + if(!doxml) { + begin_obj(dump_header_format->datasetbegin, name, + dump_header_format->datasetblockbegin); indentation(indent + COL); - printf("LINKCLASS %d\n", linfo->type); - indentation(indent + COL); - printf("TARGETFILE \"%s\"\n", filename); - indentation(indent + COL); - printf("TARGETPATH \"%s\"\n", targname); - } - /* XML */ - else { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + 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_filename = xml_escape_the_name(filename); - char *t_targname = xml_escape_the_name(targname); + 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(t_obj_path, linkxid, sizeof(linkxid), 1); + xml_name_to_XID(obj_path, dsetxid, sizeof(dsetxid), 1); xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); - printf("<%sExternalLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetFilename=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - filename, /* TargetFilename */ - targname, /* TargetPath*/ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - HDfree(t_prefix); + 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_filename); - HDfree(t_targname); HDfree(t_obj_path); + HDfree(t_prefix); } + + H5Dclose(obj); + goto done; + } else { + found_obj->displayed = TRUE; } - } - if (!doxml) - end_obj(dump_header_format->extlinkend, dump_header_format->extlinkblockend); - HDfree(targbuf); - } - break; + } /* end if */ - default: - if (!doxml) { - begin_obj(dump_header_format->udlinkbegin, name, dump_header_format->udlinkblockbegin); - indentation(indent + COL); - } - if (!doxml) - printf("LINKCLASS %d\n", linfo->type); - else /* XML */ - { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_obj_path = xml_escape_the_name(obj_path); - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, sizeof(parentxid), 1); - - printf("<%sUserDefined LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "LinkClass=\"%d\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - linfo->type, /* LinkClass */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_obj_path); - } - if (!doxml) { - indentation(indent); - end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend); - } - } - 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 H5O_TYPE_NAMED_DATATYPE: + if((obj = H5Topen(group, name)) < 0) { + error_msg(progname, "unable to dump datatype \"%s\"\n", name); + d_status = EXIT_FAILURE; + ret = FAIL; + } else { + dump_function_table->dump_named_datatype_function(obj, name); + H5Tclose(obj); + } + break; - case H5G_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", name); + default: + error_msg(progname, "unknown object \"%s\"\n", name); d_status = EXIT_FAILURE; ret = FAIL; - } else { - char *old_prefix; /* Pointer to previous prefix */ + } + } /* end if */ + else { + char *targbuf; - /* Keep copy of prefix before iterating into group */ - old_prefix = HDstrdup(prefix); - HDassert(old_prefix); + switch(linfo->type) { + case H5L_TYPE_SOFT: + indentation(indent); + targbuf = HDmalloc(linfo->u.val_size); + HDassert(targbuf); - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); + if(!doxml) { + begin_obj(dump_header_format->softlinkbegin, name, + dump_header_format->softlinkblockbegin); + indentation(indent + COL); + } - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 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) + linfo->u.val_size + 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, /* 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, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + } - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_targbuf); + HDfree(t_obj_path); + HDfree(t_link_path); + } + } - /* Close group */ - H5Gclose(obj); - } - break; + if (!doxml) { + indentation(indent); + end_obj(dump_header_format->softlinkend, + dump_header_format->softlinkblockend); + } - case H5G_DATASET: - if ((obj = H5Dopen(group, name)) >= 0) { - haddr_t objno; /* Compact form of object's location */ + HDfree(targbuf); + break; - /* hard link */ - H5Gget_objinfo(obj, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); + case H5L_TYPE_EXTERNAL: + targbuf = HDmalloc(linfo->u.val_size); + HDassert(targbuf); - if (statbuf.nlink > 1) { - obj_t *found_obj; /* Found object */ + indentation(indent); + if(!doxml) + begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin); - found_obj = search_obj(dset_table, objno); + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg(progname, "unable to get external link value\n"); + d_status = EXIT_FAILURE; + ret = FAIL; + } /* end if */ + else { + const char *filename; + const char *targname; - 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); + if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + error_msg(progname, "unable to unpack external link value\n"); 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); + } /* end if */ + else { + if(!doxml) { 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]; + printf("LINKCLASS %d\n", linfo->type); + indentation(indent + COL); + printf("TARGETFILE \"%s\"\n", filename); + indentation(indent + COL); + printf("TARGETPATH \"%s\"\n", targname); + } /* end if */ + /* XML */ + else { + char linkxid[100]; char parentxid[100]; - char pointerxid[100]; + char *t_name = xml_escape_the_name(name); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_filename = xml_escape_the_name(filename); + char *t_targname = xml_escape_the_name(targname); /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(obj_path, dsetxid, sizeof(dsetxid), 1); + xml_name_to_XID(t_obj_path, linkxid, sizeof(linkxid), 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); - + printf("<%sExternalLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetFilename=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + filename, /* TargetFilename */ + targname, /* TargetPath*/ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + HDfree(t_prefix); HDfree(t_name); + HDfree(t_filename); + HDfree(t_targname); HDfree(t_obj_path); - HDfree(t_prefix); - } - - H5Dclose(obj); - goto done; - } else { - found_obj->displayed = TRUE; - } + } /* end else */ + } /* end else */ + } /* end else */ + if(!doxml) { + indentation(indent); + end_obj(dump_header_format->extlinkend, dump_header_format->extlinkblockend); } /* end if */ + HDfree(targbuf); + 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; + default: + indentation(indent); + if(!doxml) { + begin_obj(dump_header_format->udlinkbegin, name, dump_header_format->udlinkblockbegin); + indentation(indent + COL); + printf("LINKCLASS %d\n", linfo->type); + indentation(indent); + end_obj(dump_header_format->udlinkend, dump_header_format->udlinkblockend); + } /* end if */ + /* XML */ + else { + char linkxid[100]; + char parentxid[100]; + char *t_name = xml_escape_the_name(name); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_obj_path = xml_escape_the_name(obj_path); - 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; + /* 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); - default: - error_msg(progname, "unknown object \"%s\"\n", name); - d_status = EXIT_FAILURE; - ret = FAIL; - } + printf("<%sUserDefined LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "LinkClass=\"%d\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />\n", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + linfo->type, /* LinkClass */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_obj_path); + } /* end else */ + break; + } /* end switch */ + } /* end else */ done: if(obj_path) @@ -1796,7 +1738,7 @@ done: /*------------------------------------------------------------------------- * Function: dump_named_datatype * - * Purpose: Dump named data type + * Purpose: Dump named datatype * * Return: void * @@ -1810,25 +1752,25 @@ done: static void dump_named_datatype(hid_t type, const char *name) { - indentation(indent); - printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, - dump_header_format->datatypeblockbegin); - - if (H5Tget_class(type) == H5T_COMPOUND) { - print_datatype(type,1); - } else { - indentation(indent + COL); - print_datatype(type,1); - printf(";\n"); - } + indentation(indent); + printf("%s \"%s\" %s", dump_header_format->datatypebegin, name, + dump_header_format->datatypeblockbegin); - /* print attributes */ - indent += COL; - H5Aiterate(type, NULL, dump_attr, NULL); - indent -= COL; + if(H5Tget_class(type) == H5T_COMPOUND) + print_datatype(type, 1); + else { + indentation(indent + COL); + print_datatype(type, 1); + printf(";\n"); + } /* end else */ + + /* print attributes */ + indent += COL; + H5Aiterate(type, NULL, dump_attr, NULL); + indent -= COL; - end_obj(dump_header_format->datatypeend, - dump_header_format->datatypeblockend); + end_obj(dump_header_format->datatypeend, + dump_header_format->datatypeblockend); } /*------------------------------------------------------------------------- @@ -1849,11 +1791,9 @@ dump_named_datatype(hid_t type, const char *name) static void dump_group(hid_t gid, const char *name) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oinfo; hid_t dset, type; char type_name[1024], *tmp; - int xtype = H5G_UNKNOWN; /* dump all */ tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); @@ -1882,13 +1822,12 @@ dump_group(hid_t gid, const char *name) } } /* end if */ - H5Gget_objinfo(gid, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); + H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT); - if (statbuf.nlink > 1) { + if(oinfo.rc > 1) { obj_t *found_obj; /* Found object */ - found_obj = search_obj(group_table, objno); + found_obj = search_obj(group_table, oinfo.addr); if (found_obj == NULL) { indentation(indent); @@ -1901,11 +1840,11 @@ dump_group(hid_t gid, const char *name) } else { found_obj->displayed = TRUE; H5Aiterate(gid, NULL, dump_attr, NULL); - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); } } else { H5Aiterate(gid, NULL, dump_attr, NULL); - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); } indent -= COL; @@ -1930,27 +1869,32 @@ dump_group(hid_t gid, const char *name) static void dump_dataset(hid_t did, const char *name, struct subset_t *sset) { - hid_t type, space, dcpl_id; + hid_t type, space; indentation(indent); begin_obj(dump_header_format->datasetbegin, name, - dump_header_format->datasetblockbegin); + dump_header_format->datasetblockbegin); + type = H5Dget_type(did); space = H5Dget_space(did); - dcpl_id = H5Dget_create_plist(did); dump_comment(did); dump_datatype(type); dump_dataspace(space); - if (display_oid) + if(display_oid) dump_oid(did); - if (display_dcpl) + if(display_dcpl) { + hid_t dcpl_id; + + dcpl_id = H5Dget_create_plist(did); dump_dcpl(dcpl_id, type, did); + H5Pclose(dcpl_id); + } /* end if */ - if (display_data) - switch (H5Tget_class(type)) { + if(display_data) + switch(H5Tget_class(type)) { case H5T_TIME: indentation(indent + COL); printf("DATA{ not yet implemented.}\n"); @@ -1971,17 +1915,18 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) default: break; - } + } /* end switch */ indent += COL; H5Aiterate(did, NULL, dump_attr, NULL); indent -= COL; + H5Tclose(type); H5Sclose(space); - H5Pclose(dcpl_id); + indentation(indent); end_obj(dump_header_format->datasetend, - dump_header_format->datasetblockend); + dump_header_format->datasetblockend); } /*------------------------------------------------------------------------- @@ -2136,12 +2081,12 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) dump_header_format->datablockbegin); /* Print all the values. */ - if (obj_data == DATASET_DATA) { + if(obj_data == DATASET_DATA) { hid_t f_type = H5Dget_type(obj_id); char string_prefix[64]; h5tool_format_t string_dataformat; - if (display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) { + if(display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) { /* * Print 1-byte integer data as an ASCII character string * instead of integers if the `-r' or `--string' command-line @@ -3042,8 +2987,7 @@ parse_subset_params(char *dset) static void handle_datasets(hid_t fid, char *dset, void *data) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oinfo; hid_t dsetid; struct subset_t *sset = (struct subset_t *)data; @@ -3109,15 +3053,13 @@ handle_datasets(hid_t fid, char *dset, void *data) } } - H5Gget_objinfo(dsetid, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - - if (statbuf.nlink > 1) { + H5Oget_info(dsetid, ".", &oinfo, H5P_DEFAULT); + if(oinfo.rc > 1) { obj_t *found_obj; /* Found object */ - found_obj = search_obj(dset_table, objno); + found_obj = search_obj(dset_table, oinfo.addr); - if (found_obj) { + if(found_obj) { if (found_obj->displayed) { begin_obj(dump_header_format->datasetbegin, dset, dump_header_format->datasetblockbegin); @@ -3130,14 +3072,14 @@ handle_datasets(hid_t fid, char *dset, void *data) found_obj->displayed = TRUE; dump_dataset(dsetid, dset, sset); } - } else { - d_status = EXIT_FAILURE; } - } else { - dump_dataset(dsetid, dset, sset); + else + d_status = EXIT_FAILURE; } + else + dump_dataset(dsetid, dset, sset); - if (H5Dclose(dsetid) < 0) + if(H5Dclose(dsetid) < 0) d_status = EXIT_FAILURE; } @@ -3199,47 +3141,44 @@ handle_groups(hid_t fid, char *group, void UNUSED * data) static void handle_links(hid_t fid, char *links, void UNUSED * data) { - H5G_stat_t statbuf; H5L_info_t linfo; - if(H5Gget_objinfo(fid, links, FALSE, &statbuf) < 0) { - error_msg(progname, "unable to get obj info from \"%s\"\n", links); - d_status = EXIT_FAILURE; - } else if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { + if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { error_msg(progname, "unable to get link info from \"%s\"\n", links); d_status = EXIT_FAILURE; - } else if(statbuf.type == H5G_LINK) { /* Soft link */ - char *buf = HDmalloc(statbuf.linklen); - - begin_obj(dump_header_format->softlinkbegin, links, - dump_header_format->softlinkblockbegin); - indentation(COL); - - if(H5Lget_val(fid, links, buf, statbuf.linklen, H5P_DEFAULT) >= 0) { - printf("LINKTARGET \"%s\"\n", buf); - } else { - error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n", - links); - d_status = EXIT_FAILURE; - } + } else if(linfo.type == H5L_TYPE_HARD) { + error_msg(progname, "\"%s\" is a hard link\n", links); + d_status = EXIT_FAILURE; + } else { + char *buf = HDmalloc(linfo.u.val_size); - end_obj(dump_header_format->softlinkend, - dump_header_format->softlinkblockend); - HDfree(buf); - } else if(statbuf.type == H5G_UDLINK) { /* User-defined link */ - char *buf = HDmalloc(statbuf.linklen); - begin_obj(dump_header_format->udlinkbegin, links, - dump_header_format->udlinkblockbegin); - indentation(COL); switch(linfo.type) { + case H5L_TYPE_SOFT: /* Soft link */ + begin_obj(dump_header_format->softlinkbegin, links, + dump_header_format->softlinkblockbegin); + indentation(COL); + if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) + printf("LINKTARGET \"%s\"\n", buf); + else { + error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n", + links); + d_status = EXIT_FAILURE; + } + end_obj(dump_header_format->softlinkend, + dump_header_format->softlinkblockend); + break; + case H5L_TYPE_EXTERNAL: + begin_obj(dump_header_format->udlinkbegin, links, + dump_header_format->udlinkblockbegin); + indentation(COL); begin_obj(dump_header_format->extlinkbegin, links, dump_header_format->extlinkblockbegin); - if(H5Lget_val(fid, links, buf, statbuf.linklen, H5P_DEFAULT) >= 0) { + if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { const char *elink_file; const char *elink_path; - if(H5Lunpack_elink_val(buf, statbuf.linklen, NULL, &elink_file, &elink_path)>=0) { + if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) { indentation(COL); printf("LINKCLASS %d\n", linfo.type); indentation(COL); @@ -3250,26 +3189,28 @@ handle_links(hid_t fid, char *links, void UNUSED * data) error_msg(progname, "h5dump error: unable to unpack external link value for \"%s\"\n", links); d_status = EXIT_FAILURE; } - } else { - error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n", links); - d_status = EXIT_FAILURE; - } - end_obj(dump_header_format->extlinkend, - dump_header_format->extlinkblockend); - break; - default: - begin_obj(dump_header_format->udlinkbegin, links, - dump_header_format->udlinkblockbegin); - indentation(COL); - printf("LINKCLASS %d\n", linfo.type); - end_obj(dump_header_format->udlinkend, - dump_header_format->udlinkblockend); - } + } else { + error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n", links); + d_status = EXIT_FAILURE; + } + end_obj(dump_header_format->extlinkend, + dump_header_format->extlinkblockend); + break; + + default: + begin_obj(dump_header_format->udlinkbegin, links, + dump_header_format->udlinkblockbegin); + indentation(COL); + begin_obj(dump_header_format->udlinkbegin, links, + dump_header_format->udlinkblockbegin); + indentation(COL); + printf("LINKCLASS %d\n", linfo.type); + end_obj(dump_header_format->udlinkend, + dump_header_format->udlinkblockend); + break; + } /* end switch */ HDfree(buf); - } else { - error_msg(progname, "\"%s\" is not a link\n", links); - d_status = EXIT_FAILURE; - } + } /* end else */ } /*------------------------------------------------------------------------- @@ -3292,14 +3233,14 @@ handle_datatypes(hid_t fid, char *type, void UNUSED * data) hid_t type_id; if ((type_id = H5Topen(fid, type)) < 0) { - /* check if type is unamed data type */ + /* check if type is unamed datatype */ unsigned idx = 0; while (idx < type_table->nobjs ) { char name[128]; if (!type_table->objs[idx].recorded) { - /* unamed data type */ + /* unamed datatype */ sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno); if (!HDstrcmp(name, type)) @@ -3733,27 +3674,27 @@ main(int argc, const char *argv[]) /* Check for conflicting options */ if (doxml) { - if (!display_all) { + if (!display_all) { error_msg(progname, "option \"%s\" not available for XML\n", - "to display selected objects"); - leave(EXIT_FAILURE); - } else if (display_bb) { + "to display selected objects"); + leave(EXIT_FAILURE); + } else if (display_bb) { error_msg(progname, "option \"%s\" not available for XML\n", - "--boot-block"); - leave(EXIT_FAILURE); - } else if (display_oid == 1) { + "--boot-block"); + leave(EXIT_FAILURE); + } else if (display_oid == 1) { error_msg(progname, "option \"%s\" not available for XML\n", - "--object-ids"); - leave(EXIT_FAILURE); + "--object-ids"); + leave(EXIT_FAILURE); } else if (display_char == TRUE) { error_msg(progname, "option \"%s\" not available for XML\n", - "--string"); - leave(EXIT_FAILURE); - } else if (usingdasho) { + "--string"); + leave(EXIT_FAILURE); + } else if (usingdasho) { error_msg(progname, "option \"%s\" not available for XML\n", - "--output"); - leave(EXIT_FAILURE); - } + "--output"); + leave(EXIT_FAILURE); + } } else { if (xml_dtd_uri) { warn_msg(progname, "option \"%s\" only applies with XML: %s\n", @@ -3778,9 +3719,8 @@ main(int argc, const char *argv[]) /* allocate and initialize internal data structure */ init_prefix(&prefix, prefix_len); - /* find all objects that might be targets of a refernce */ - init_ref_path_table(fid); /* Insert the root group into the ref. path table */ - H5Literate(fid, (const char *)"/", H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table, (void *)"", H5P_DEFAULT); + /* find all objects that might be targets of a reference */ + fill_ref_path_table(fid); if(doxml) { /* initialize XML */ @@ -3811,7 +3751,7 @@ main(int argc, const char *argv[]) goto done; } - /* does there exist unamed committed data type */ + /* does there exist unamed committed datatype */ for (u = 0; u < type_table->nobjs; u++) if (!type_table->objs[u].recorded) { unamedtype = 1; @@ -3824,12 +3764,12 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml) { - begin_obj(dump_header_format->filebegin, fname, - dump_header_format->fileblockbegin); + begin_obj(dump_header_format->filebegin, fname, + dump_header_format->fileblockbegin); } else { - printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - /* alternative first element, depending on schema or DTD. */ + /* alternative first element, depending on schema or DTD. */ if (useschema) { if (strcmp(xmlnsprefix,"") == 0) { printf("<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", @@ -3848,11 +3788,11 @@ main(int argc, const char *argv[]) "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5File " "http://hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); } - } else { - printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", - xml_dtd_uri); - printf("<HDF5-File>\n"); - } + } else { + printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", + xml_dtd_uri); + printf("<HDF5-File>\n"); + } } if (!doxml) { @@ -3942,7 +3882,7 @@ print_enum(hid_t type) unsigned nmembs; /*number of members */ int nchars; /*number of output characters */ hid_t super; /*enum base integer type */ - hid_t native = -1; /*native integer data type */ + hid_t native = -1; /*native integer datatype */ size_t dst_size; /*destination value type size */ unsigned i; @@ -3951,7 +3891,7 @@ print_enum(hid_t type) super = H5Tget_super(type); /* - * Determine what data type to use for the native values. To simplify + * Determine what datatype to use for the native values. To simplify * things we entertain three possibilities: * 1. long_long -- the largest native signed integer * 2. unsigned long_long -- the largest native unsigned integer @@ -3978,7 +3918,7 @@ print_enum(hid_t type) H5Tget_member_value(type, i, value + i * H5Tget_size(type)); } - /* Convert values to native data type */ + /* Convert values to native datatype */ if (native > 0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); @@ -4300,32 +4240,32 @@ xml_print_datatype(hid_t type, unsigned in_group) int nmembs; htri_t is_vlstr=FALSE; - if (!in_group && H5Tcommitted(type) > 0) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + if(!in_group && H5Tcommitted(type) > 0) { + H5O_info_t oinfo; obj_t *found_obj; /* Found object */ /* detect a shared datatype, output only once */ - H5Gget_objinfo(type, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - found_obj = search_obj(type_table, objno); + H5Oget_info(type, ".", &oinfo, H5P_DEFAULT); + found_obj = search_obj(type_table, oinfo.addr); - if (found_obj) { + if(found_obj) { /* This should be defined somewhere else */ /* These 2 cases are handled the same right now, but probably will have something different eventually */ char * dtxid = malloc(100); - xml_name_to_XID(found_obj->objname,dtxid,100,1); + + xml_name_to_XID(found_obj->objname, dtxid, 100, 1); if (!found_obj->recorded) { /* 'anonymous' NDT. Use it's object num. as it's name. */ printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n", - xmlnsprefix, dtxid); + xmlnsprefix, dtxid); } else { /* point to the NDT by name */ char *t_objname = xml_escape_the_name(found_obj->objname); + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n", - xmlnsprefix, dtxid,t_objname); + xmlnsprefix, dtxid, t_objname); free(t_objname); } free(dtxid); @@ -4333,311 +4273,310 @@ xml_print_datatype(hid_t type, unsigned in_group) printf("<!-- h5dump error: unknown committed type. -->\n"); d_status = EXIT_FAILURE; } - } else { switch (H5Tget_class(type)) { - case H5T_INTEGER: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */ - ord = H5Tget_order(type); - sgn = H5Tget_sign(type); - indentation(indent); - printf("<%sIntegerType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); - break; - case H5T_ORDER_BE: - printf("BE"); + case H5T_INTEGER: + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */ + ord = H5Tget_order(type); + sgn = H5Tget_sign(type); + indentation(indent); + printf("<%sIntegerType ByteOrder=\"",xmlnsprefix); + switch (ord) { + case H5T_ORDER_LE: + printf("LE"); + break; + case H5T_ORDER_BE: + printf("BE"); + break; + case H5T_ORDER_VAX: + default: + printf("ERROR_UNKNOWN"); + } + printf("\" Sign=\""); + switch (sgn) { + case H5T_SGN_NONE: + printf("false"); + break; + case H5T_SGN_2: + printf("true"); + break; + default: + printf("ERROR_UNKNOWN"); + } + printf("\" Size=\""); + sz = H5Tget_size(type); + printf("%lu", (unsigned long)sz); + printf("\" />\n"); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); break; - case H5T_ORDER_VAX: - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Sign=\""); - switch (sgn) { - case H5T_SGN_NONE: - printf("false"); + + case H5T_FLOAT: + /* <hdf5:FloatType ByteOrder="bo" Size="bytes" + SignBitLocation="bytes" + ExponentBits="eb" ExponentLocation="el" + MantissaBits="mb" MantissaLocation="ml" /> */ + ord = H5Tget_order(type); + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sFloatType ByteOrder=\"",xmlnsprefix); + switch (ord) { + case H5T_ORDER_LE: + printf("LE"); + break; + case H5T_ORDER_BE: + printf("BE"); + break; + case H5T_ORDER_VAX: + printf("VAX"); + break; + default: + printf("ERROR_UNKNOWN"); + } + printf("\" Size=\""); + sz = H5Tget_size(type); + printf("%lu", (unsigned long)sz); + H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); + printf("\" SignBitLocation=\"%lu\" ", (unsigned long)spos); + printf("ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); + printf("MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n", + (unsigned long)msize, (unsigned long)mpos); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); break; - case H5T_SGN_2: - printf("true"); + + case H5T_TIME: + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sTimeType />\n",xmlnsprefix); + printf("<!-- H5T_TIME: not yet implemented -->"); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); break; - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Size=\""); - sz = H5Tget_size(type); - printf("%lu", (unsigned long)sz); - printf("\" />\n"); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; - case H5T_FLOAT: - /* <hdf5:FloatType ByteOrder="bo" Size="bytes" - SignBitLocation="bytes" - ExponentBits="eb" ExponentLocation="el" - MantissaBits="mb" MantissaLocation="ml" /> */ - ord = H5Tget_order(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sFloatType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); + case H5T_STRING: + /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */ + size = H5Tget_size(type); + str_pad = H5Tget_strpad(type); + cset = H5Tget_cset(type); + is_vlstr = H5Tis_variable_str(type); + + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sStringType Cset=\"",xmlnsprefix); + if (cset == H5T_CSET_ASCII) { + printf("H5T_CSET_ASCII\" "); + } else { + printf("unknown_cset\" "); + } + if(is_vlstr) + printf("StrSize=\"H5T_VARIABLE\" StrPad=\""); + else + printf("StrSize=\"%d\" StrPad=\"", (int) size); + if (str_pad == H5T_STR_NULLTERM) { + printf("H5T_STR_NULLTERM\"/>\n"); + } else if (str_pad == H5T_STR_NULLPAD) { + printf("H5T_STR_NULLPAD\"/>\n"); + } else if (str_pad == H5T_STR_SPACEPAD) { + printf("H5T_STR_SPACEPAD\"/>\n"); + } else { + printf("H5T_STR_ERROR\"/>\n"); + } + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); break; - case H5T_ORDER_BE: - printf("BE"); + + case H5T_BITFIELD: + /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */ + ord = H5Tget_order(type); + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sBitfieldType ByteOrder=\"",xmlnsprefix); + switch (ord) { + case H5T_ORDER_LE: + printf("LE"); + break; + case H5T_ORDER_BE: + printf("BE"); + break; + case H5T_ORDER_VAX: + default: + printf("ERROR_UNKNOWN"); + } + size = H5Tget_size(type); + printf("\" Size=\"%lu\"/>\n", (unsigned long)size); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); break; - case H5T_ORDER_VAX: - printf("VAX"); - break; - default: - printf("ERROR_UNKNOWN"); - } - printf("\" Size=\""); - sz = H5Tget_size(type); - printf("%lu", (unsigned long)sz); - H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); - printf("\" SignBitLocation=\"%lu\" ", (unsigned long)spos); - printf("ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); - printf("MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />\n", - (unsigned long)msize, (unsigned long)mpos); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; - case H5T_TIME: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sTimeType />\n",xmlnsprefix); - printf("<!-- H5T_TIME: not yet implemented -->"); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + case H5T_OPAQUE: + /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */ + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, H5Tget_tag(type)); + size = H5Tget_size(type); + printf("Size=\"%lu\"/>\n", (unsigned long)size); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); + break; - case H5T_STRING: - /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */ - size = H5Tget_size(type); - str_pad = H5Tget_strpad(type); - cset = H5Tget_cset(type); - is_vlstr = H5Tis_variable_str(type); + case H5T_COMPOUND: + /* recursively describe the components of a compound datatype */ - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sStringType Cset=\"",xmlnsprefix); - if (cset == H5T_CSET_ASCII) { - printf("H5T_CSET_ASCII\" "); - } else { - printf("unknown_cset\" "); - } - if(is_vlstr) - printf("StrSize=\"H5T_VARIABLE\" StrPad=\""); - else - printf("StrSize=\"%d\" StrPad=\"", (int) size); - if (str_pad == H5T_STR_NULLTERM) { - printf("H5T_STR_NULLTERM\"/>\n"); - } else if (str_pad == H5T_STR_NULLPAD) { - printf("H5T_STR_NULLPAD\"/>\n"); - } else if (str_pad == H5T_STR_SPACEPAD) { - printf("H5T_STR_SPACEPAD\"/>\n"); - } else { - printf("H5T_STR_ERROR\"/>\n"); - } - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + /* type of a dataset */ + nmembers = H5Tget_nmembers(type); - case H5T_BITFIELD: - /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */ - ord = H5Tget_order(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sBitfieldType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - printf("LE"); - break; - case H5T_ORDER_BE: - printf("BE"); - break; - case H5T_ORDER_VAX: - default: - printf("ERROR_UNKNOWN"); - } - size = H5Tget_size(type); - printf("\" Size=\"%lu\"/>\n", (unsigned long)size); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + indentation(indent); + printf("<%sCompoundType>\n",xmlnsprefix); - case H5T_OPAQUE: - /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */ - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, H5Tget_tag(type)); - size = H5Tget_size(type); - printf("Size=\"%lu\"/>\n", (unsigned long)size); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + /* List each member Field of the type */ + /* <hdf5:Field FieldName="name" > */ + /* <hdf5:DataType > */ + indent += COL; + for (i = 0; i < nmembers; i++) { + char *t_fname; - case H5T_COMPOUND: - /* recursively describe the components of a compound datatype */ + mname = H5Tget_member_name(type, i); + mtype = H5Tget_member_type(type, i); + indentation(indent); + t_fname = xml_escape_the_name(mname); + printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname); - /* type of a dataset */ - nmembers = H5Tget_nmembers(type); + free(mname); + free(t_fname); + indent += COL; + indentation(indent); + printf("<%sDataType>\n",xmlnsprefix); + indent += COL; + xml_print_datatype(mtype,0); + indent -= COL; + indentation(indent); + printf("</%sDataType>\n",xmlnsprefix); + indent -= COL; - indentation(indent); - printf("<%sCompoundType>\n",xmlnsprefix); + indentation(indent); + printf("</%sField>\n",xmlnsprefix); + } + indent -= COL; + indentation(indent); + printf("</%sCompoundType>\n",xmlnsprefix); + break; - /* List each member Field of the type */ - /* <hdf5:Field FieldName="name" > */ - /* <hdf5:DataType > */ - indent += COL; - for (i = 0; i < nmembers; i++) { - char *t_fname; + case H5T_REFERENCE: + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + /* Only Object references supported at this time */ + printf("<%sReferenceType>\n",xmlnsprefix); + indentation(indent + COL); + printf("<%sObjectReferenceType />\n",xmlnsprefix); + indentation(indent); + printf("</%sReferenceType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); + break; - mname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); + case H5T_ENUM: + /* <hdf5:EnumType Nelems="ne" > + list Name, values of enum + */ + nmembs = H5Tget_nmembers(type); + indentation(indent); + printf("<%sAtomicType>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs); + xml_print_enum(type); indentation(indent); - t_fname = xml_escape_the_name(mname); - printf("<%sField FieldName=\"%s\">\n",xmlnsprefix, t_fname); + printf("</%sEnumType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sAtomicType>\n",xmlnsprefix); + break; - free(mname); - free(t_fname); + case H5T_VLEN: + indentation(indent); + printf("<%sVLType>\n",xmlnsprefix); + super = H5Tget_super(type); indent += COL; indentation(indent); printf("<%sDataType>\n",xmlnsprefix); indent += COL; - xml_print_datatype(mtype,0); + xml_print_datatype(super,0); indent -= COL; indentation(indent); printf("</%sDataType>\n",xmlnsprefix); indent -= COL; - indentation(indent); - printf("</%sField>\n",xmlnsprefix); - } - indent -= COL; - indentation(indent); - printf("</%sCompoundType>\n",xmlnsprefix); - break; - - case H5T_REFERENCE: - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - /* Only Object references supported at this time */ - printf("<%sReferenceType>\n",xmlnsprefix); - indentation(indent + COL); - printf("<%sObjectReferenceType />\n",xmlnsprefix); - indentation(indent); - printf("</%sReferenceType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; - - case H5T_ENUM: - /* <hdf5:EnumType Nelems="ne" > - list Name, values of enum - */ - nmembs = H5Tget_nmembers(type); - indentation(indent); - printf("<%sAtomicType>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sEnumType Nelems=\"%d\">\n",xmlnsprefix, nmembs); - xml_print_enum(type); - indentation(indent); - printf("</%sEnumType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sAtomicType>\n",xmlnsprefix); - break; + printf("</%sVLType>\n",xmlnsprefix); + H5Tclose(super); - case H5T_VLEN: - indentation(indent); - printf("<%sVLType>\n",xmlnsprefix); - super = H5Tget_super(type); - indent += COL; - indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); - indent += COL; - xml_print_datatype(super,0); - indent -= COL; - indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sVLType>\n",xmlnsprefix); - H5Tclose(super); + break; - break; + case H5T_ARRAY: + /* Get array base type */ + super = H5Tget_super(type); - case H5T_ARRAY: - /* Get array base type */ - super = H5Tget_super(type); + /* Print lead-in */ + indentation(indent); + printf("<%sArrayType Ndims=\"",xmlnsprefix); + ndims = H5Tget_array_ndims(type); + printf("%u\">\n", ndims); - /* Print lead-in */ - indentation(indent); - printf("<%sArrayType Ndims=\"",xmlnsprefix); - ndims = H5Tget_array_ndims(type); - printf("%u\">\n", ndims); + /* Get array information */ + H5Tget_array_dims(type, dims, NULL); - /* Get array information */ - H5Tget_array_dims(type, dims, NULL); + /* list of dimensions */ + indent += COL; + for (i = 0; i < ndims; i++) { + indentation(indent); + printf("<%sArrayDimension DimSize=\"%u\"/>\n", + xmlnsprefix, + (int) dims[i]); + } + indent -= COL; - /* list of dimensions */ - indent += COL; - for (i = 0; i < ndims; i++) { + indent += COL; indentation(indent); - printf("<%sArrayDimension DimSize=\"%u\"/>\n", - xmlnsprefix, - (int) dims[i]); - } - indent -= COL; - - indent += COL; - indentation(indent); - printf("<%sDataType>\n",xmlnsprefix); - indent += COL; - xml_print_datatype(super,0); - indent -= COL; - indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sArrayType>\n",xmlnsprefix); - /* Close array base type */ - H5Tclose(super); - break; + printf("<%sDataType>\n",xmlnsprefix); + indent += COL; + xml_print_datatype(super,0); + indent -= COL; + indentation(indent); + printf("</%sDataType>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sArrayType>\n",xmlnsprefix); + /* Close array base type */ + H5Tclose(super); + break; - default: - printf("<!-- unknown data type -->"); - d_status = EXIT_FAILURE; - break; + default: + printf("<!-- unknown datatype -->"); + d_status = EXIT_FAILURE; + break; } } /* end else */ } @@ -4662,51 +4601,51 @@ xml_dump_datatype(hid_t type) indent += COL; indentation(indent); - if (H5Tcommitted(type) > 0) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + if(H5Tcommitted(type) > 0) { + H5O_info_t oinfo; obj_t *found_obj; /* Found object */ - /* Data type is a shared or named data type */ - H5Gget_objinfo(type, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - found_obj = search_obj(type_table, objno); - - if (found_obj) { - /* Shared data type, must be entered as an object */ - /* These 2 cases are the same now, but may change */ - char * dtxid = malloc(100); - xml_name_to_XID(found_obj->objname,dtxid,100,1); - if (!found_obj->recorded) { - /* anonymous stored data type: - following the dumper's current - practice: - use it's object ref as its name - */ - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", - xmlnsprefix, dtxid); + /* Datatype is a shared or named datatype */ + H5Oget_info(type, ".", &oinfo, H5P_DEFAULT); + found_obj = search_obj(type_table, oinfo.addr); - } else { - /* pointer to a named data type already in XML */ + if(found_obj) { + /* Shared datatype, must be entered as an object */ + /* These 2 cases are the same now, but may change */ + char * dtxid = malloc(100); + + xml_name_to_XID(found_obj->objname, dtxid, 100, 1); + if (!found_obj->recorded) { + /* anonymous stored datatype: + following the dumper's current + practice: + use it's object ref as its name + */ + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n", + xmlnsprefix, dtxid); + } else { + /* pointer to a named datatype already in XML */ char *t_objname = xml_escape_the_name(found_obj->objname); - printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", - xmlnsprefix, dtxid,t_objname); - free(t_objname); + + printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n", + xmlnsprefix, dtxid, t_objname); + free(t_objname); + } + free(dtxid); + } else { + printf("<!-- h5dump error: unknown committed type. -->\n"); } - free(dtxid); - } else { - printf("<!-- h5dump error: unknown committed type. -->\n"); + indent -= COL; } - indent -= COL; - return; + else { + printf("<%sDataType>\n", xmlnsprefix); + indent += COL; + xml_print_datatype(type, 0); + indent -= COL; + indentation(indent); + printf("</%sDataType>\n", xmlnsprefix); + indent -= COL; } - printf("<%sDataType>\n",xmlnsprefix); - indent += COL; - xml_print_datatype(type,0); - indent -= COL; - indentation(indent); - printf("</%sDataType>\n",xmlnsprefix); - indent -= COL; } /*------------------------------------------------------------------------- @@ -4738,47 +4677,47 @@ xml_dump_dataspace(hid_t space) switch (space_type) { case H5S_SCALAR: - /* scalar dataspace (just a tag, no XML attrs. defined */ - printf("<%sScalarDataspace />\n",xmlnsprefix); - + /* scalar dataspace (just a tag, no XML attrs. defined */ + printf("<%sScalarDataspace />\n",xmlnsprefix); break; - case H5S_SIMPLE: - /* simple dataspace */ - /* <hdf5:SimpleDataspace Ndims="nd"> */ - printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); - /* print the <hdf5:Dimension> elements */ - for (i = 0; i < ndims; i++) { - indentation(indent + COL + COL + COL); - if (maxsize[i] == H5S_UNLIMITED) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", - xmlnsprefix,size[i]); - } else if (maxsize[i] == (hsize_t) 0) { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix,size[i], size[i]); - } else { - HDfprintf(stdout, - "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", - xmlnsprefix, size[i], maxsize[i]); - } - } - indentation(indent + COL + COL); - printf("</%sSimpleDataspace>\n", xmlnsprefix ); + case H5S_SIMPLE: + /* simple dataspace */ + /* <hdf5:SimpleDataspace Ndims="nd"> */ + printf("<%sSimpleDataspace Ndims=\"%d\">\n",xmlnsprefix, ndims); + /* print the <hdf5:Dimension> elements */ + for (i = 0; i < ndims; i++) { + indentation(indent + COL + COL + COL); + if (maxsize[i] == H5S_UNLIMITED) { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"UNLIMITED\"/>\n", + xmlnsprefix,size[i]); + } else if (maxsize[i] == (hsize_t) 0) { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix,size[i], size[i]); + } else { + HDfprintf(stdout, + "<%sDimension DimSize=\"%Hu\" MaxDimSize=\"%Hu\"/>\n", + xmlnsprefix, size[i], maxsize[i]); + } + } + indentation(indent + COL + COL); + printf("</%sSimpleDataspace>\n", xmlnsprefix ); break; + #ifdef TMP /* Commented out: wait until the schema is updated first */ case H5S_NULL: - /* null dataspace (just a tag, no XML attrs. defined */ - printf("<%sNullDataspace />\n",xmlnsprefix); - + /* null dataspace (just a tag, no XML attrs. defined */ + printf("<%sNullDataspace />\n",xmlnsprefix); break; #endif /* TMP */ + case H5S_NO_CLASS: default: - printf("<!-- unknown dataspace -->\n"); + printf("<!-- unknown dataspace -->\n"); } indentation(indent + COL); @@ -4829,60 +4768,59 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU indentation(indent + COL); printf("<%sDataFromFile>\n",xmlnsprefix); if (obj_data == DATASET_DATA) { - type = H5Dget_type(obj_id); - if (H5Tget_class(type) == H5T_REFERENCE) { - status = xml_print_refs(obj_id, DATASET_DATA); - } else if (H5Tget_class(type) == H5T_STRING) { - status = xml_print_strs(obj_id, DATASET_DATA); - } else { - status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth); - } - } else { - /* Attribute data */ - type = H5Aget_type(obj_id); - - if (H5Tget_class(type) == H5T_REFERENCE) { - /* references are done differently than - the standard output: - XML dumps a path to the object - referenced. - */ - status = xml_print_refs(obj_id, ATTRIBUTE_DATA); - H5Tclose(type); - } else if (H5Tget_class(type) == H5T_STRING) { - status = xml_print_strs(obj_id, ATTRIBUTE_DATA); + type = H5Dget_type(obj_id); + if (H5Tget_class(type) == H5T_REFERENCE) { + status = xml_print_refs(obj_id, DATASET_DATA); + } else if (H5Tget_class(type) == H5T_STRING) { + status = xml_print_strs(obj_id, DATASET_DATA); + } else { + status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, NULL, depth); + } } else { - /* all other data */ + /* Attribute data */ + type = H5Aget_type(obj_id); + + if (H5Tget_class(type) == H5T_REFERENCE) { + /* references are done differently than + the standard output: + XML dumps a path to the object + referenced. + */ + status = xml_print_refs(obj_id, ATTRIBUTE_DATA); + H5Tclose(type); + } else if (H5Tget_class(type) == H5T_STRING) { + status = xml_print_strs(obj_id, ATTRIBUTE_DATA); + } else { + /* all other data */ p_type = h5tools_get_native_type(type); - H5Tclose(type); + H5Tclose(type); - space = H5Aget_space(obj_id); + space = H5Aget_space(obj_id); - ndims = H5Sget_simple_extent_dims(space, size, NULL); + ndims = H5Sget_simple_extent_dims(space, size, NULL); - for (i = 0; i < ndims; i++) - nelmts *= size[i]; + for (i = 0; i < ndims; i++) + nelmts *= size[i]; - buf = - malloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); - assert(buf); + buf = malloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); + assert(buf); - if (H5Aread(obj_id, p_type, buf) >= 0) + if (H5Aread(obj_id, p_type, buf) >= 0) status = h5tools_dump_mem(stdout, outputformat, obj_id, - p_type, space, buf, depth); + p_type, space, buf, depth); - free(buf); - H5Tclose(p_type); - H5Sclose(space); - H5Tclose(type); - } + free(buf); + H5Tclose(p_type); + H5Sclose(space); + H5Tclose(type); + } } if (status == FAIL) { - indentation(indent + COL); - printf("Unable to print data.\n"); - status = 1; + indentation(indent + COL); + printf("Unable to print data.\n"); + status = 1; } indentation(indent + COL); @@ -4917,104 +4855,104 @@ xml_dump_attr(hid_t attr, const char *attr_name, void UNUSED * op_data) free(t_aname); if ((attr_id = H5Aopen_name(attr, attr_name)) >= 0) { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); space_type = H5Sget_simple_extent_type(space); - dump_function_table->dump_dataspace_function(space); - dump_function_table->dump_datatype_function(type); - - if (display_attr_data && space_type!=H5S_NULL) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + dump_function_table->dump_dataspace_function(space); + dump_function_table->dump_datatype_function(type); + + if (display_attr_data && space_type!=H5S_NULL) { + switch (H5Tget_class(type)) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("<hdf5:Data>\n"); - printf("</%sData>\n",xmlnsprefix); - indent -= COL; - break; + case H5T_TIME: + indent += COL; + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Time data not yet implemented. -->\n"); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("<hdf5:Data>\n"); + printf("</%sData>\n",xmlnsprefix); + indent -= COL; + break; - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + case H5T_COMPOUND: + indentation(indent); + printf("<!-- Note: format of compound data not specified -->\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - printf("<!-- Note: Region references not supported -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(attr_id, ATTRIBUTE_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - } - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + case H5T_REFERENCE: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + printf("<!-- Note: Region references not supported -->\n"); + indentation(indent); + printf("<%sNoData />\n",xmlnsprefix); + } else { + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(attr_id, ATTRIBUTE_DATA); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + } + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - default: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + case H5T_VLEN: + printf("<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; + } + } else { + /* The case of an attribute never yet written ?? + * Or dataspace is H5S_NULL. */ + indentation(indent + COL); + printf("<%sData>\n",xmlnsprefix); + indentation(indent + COL + COL); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent + COL); + printf("</%sData>\n",xmlnsprefix); } - } else { - /* The case of an attribute never yet written ?? - * Or dataspace is H5S_NULL. */ - indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); - indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent + COL); - printf("</%sData>\n",xmlnsprefix); - } - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); - return SUCCEED; + H5Tclose(type); + H5Sclose(space); + H5Aclose(attr_id); + indentation(indent); + printf("</%sAttribute>\n", xmlnsprefix ); + return SUCCEED; } else { - /* ?? failed */ - indentation(indent + COL); - printf("<!-- h5dump error: unable to open attribute. -->\n"); - indentation(indent); - printf("</%sAttribute>\n", xmlnsprefix ); - d_status = EXIT_FAILURE; - return FAIL; + /* ?? failed */ + indentation(indent + COL); + printf("<!-- h5dump error: unable to open attribute. -->\n"); + indentation(indent); + printf("</%sAttribute>\n", xmlnsprefix ); + d_status = EXIT_FAILURE; + return FAIL; } } @@ -5047,29 +4985,30 @@ xml_dump_named_datatype(hid_t type, const char *name) HDstrcat(tmp, name); indentation(indent); - /*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); - xml_name_to_XID(tmp,dtxid,100,1); - xml_name_to_XID(prefix,parentxid,100,1); - if (strncmp(name, "#", 1) == 0) { - /* Special: this is an 'anonymous' NDT, deleted but - still in use. - We follow the dumper's undocumented practice, and - use its object id as its name. - Exactly the same as normal, but a separate case - in the event we want to do something else in - the future. - */ - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + dtxid = HDmalloc(100); + parentxid = HDmalloc(100); + t_tmp = xml_escape_the_name(tmp); + t_prefix = xml_escape_the_name(prefix); + t_name = xml_escape_the_name(name); + + xml_name_to_XID(tmp, dtxid, 100, 1); + xml_name_to_XID(prefix, parentxid, 100, 1); + if(HDstrncmp(name, "#", 1) == 0) { + /* Special: this is an 'anonymous' NDT, deleted but + still in use. + We follow the dumper's undocumented practice, and + use its object id as its name. + Exactly the same as normal, but a separate case + in the event we want to do something else in + the future. + */ + printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, name, dtxid, parentxid,(HDstrcmp(prefix, "") ? t_prefix : "/")); } else { - printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + printf("<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix, t_name, dtxid, @@ -5114,70 +5053,65 @@ xml_dump_named_datatype(hid_t type, const char *name) static void xml_dump_group(hid_t gid, const char *name) { - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oinfo; char *cp; hid_t dset, type; char type_name[1024], *tmp = NULL; char *par = NULL; int isRoot = 0; - int xtype; char *ptrstr; char *t_objname; char *par_name; - if (HDstrcmp(name, "/") == 0) { - isRoot = 1; - tmp = HDmalloc(2); - HDstrcpy(tmp, "/"); + if(HDstrcmp(name, "/") == 0) { + isRoot = 1; + tmp = HDmalloc(2); + HDstrcpy(tmp, "/"); } else { - tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(tmp, prefix); - par = HDstrdup(tmp); - cp = HDstrrchr(par, '/'); - if (cp != NULL) { - if ((cp == par) && HDstrlen(par) > 1) { - *(cp + 1) = '\0'; - } else { - *cp = '\0'; + tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, prefix); + par = HDstrdup(tmp); + cp = HDstrrchr(par, '/'); + if(cp) { + if((cp == par) && HDstrlen(par) > 1) + *(cp + 1) = '\0'; + else + *cp = '\0'; } } - } indentation(indent); - indent += COL; - H5Gget_objinfo(gid, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - if (statbuf.nlink > 1) { + H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT); + if(oinfo.rc > 1) { obj_t *found_obj; /* Found object */ - /* Group with more than one link to it... */ - found_obj = search_obj(group_table, objno); + /* Group with more than one link to it... */ + found_obj = search_obj(group_table, oinfo.addr); - if (found_obj == NULL) { - indentation(indent); - error_msg(progname, "internal error (file %s:line %d)\n", - __FILE__, __LINE__); - d_status = EXIT_FAILURE; - } else { + if (found_obj == NULL) { + indentation(indent); + error_msg(progname, "internal error (file %s:line %d)\n", + __FILE__, __LINE__); + d_status = EXIT_FAILURE; + } else { char *t_name = xml_escape_the_name(name); char *grpxid = malloc(100); char *parentxid = malloc(100); - if (found_obj->displayed) { + if(found_obj->displayed) { /* already seen: enter a groupptr */ - if (isRoot) { + if(isRoot) { /* probably can't happen! */ - xml_name_to_XID("/",grpxid,100,1); + xml_name_to_XID("/", grpxid, 100, 1); printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", - xmlnsprefix,grpxid,"/"); + xmlnsprefix, grpxid, "/"); } else { t_objname = xml_escape_the_name(found_obj->objname); par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp,grpxid,100,1); - xml_name_to_XID(par,parentxid,100,1); + xml_name_to_XID(tmp, grpxid, 100, 1); + xml_name_to_XID(par, parentxid, 100, 1); printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\">\n", xmlnsprefix,t_name, grpxid, get_next_xid(), @@ -5198,22 +5132,22 @@ xml_dump_group(hid_t gid, const char *name) ptrstr, t_objname, parentxid, par_name); free(t_objname); free(par_name); - } else { /* first time this group has been seen -- describe it */ - if (isRoot) { - xml_name_to_XID("/",grpxid,100,1); + if(isRoot) { + xml_name_to_XID("/", grpxid, 100, 1); printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", - xmlnsprefix,grpxid,"/"); + xmlnsprefix, grpxid, "/"); } else { char *t_tmp = xml_escape_the_name(tmp); + par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp,grpxid,100,1); - xml_name_to_XID(par,parentxid,100,1); + xml_name_to_XID(tmp, grpxid, 100, 1); + xml_name_to_XID(par, parentxid, 100, 1); printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", - xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name); + xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name); free(t_tmp); free(par_name); } @@ -5223,12 +5157,12 @@ xml_dump_group(hid_t gid, const char *name) H5Aiterate(gid, NULL, dump_function_table->dump_attribute_function, NULL); - if (!strcmp(name, "/") && unamedtype) { + if(isRoot && unamedtype) { unsigned u; /* Very special case: dump unamed type in root group */ - for (u = 0; u < type_table->nobjs; u++) { - if (!type_table->objs[u].recorded) { + for(u = 0; u < type_table->nobjs; u++) { + if(!type_table->objs[u].recorded) { dset = H5Dopen(gid, type_table->objs[u].objname); type = H5Dget_type(dset); sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); @@ -5239,17 +5173,8 @@ xml_dump_group(hid_t gid, const char *name) } } - /* iterate through all the members */ - xtype = H5G_TYPE; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_DATASET; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_GROUP; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_LINK; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_UDLINK; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); + /* iterate through all the links */ + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); } free(t_name); free(grpxid); @@ -5258,41 +5183,43 @@ xml_dump_group(hid_t gid, const char *name) } else { /* only link -- must be first time! */ - char *t_name = xml_escape_the_name(name); + char *t_name = xml_escape_the_name(name); char *grpxid = malloc(100); char *parentxid = malloc(100); - if (isRoot) { - xml_name_to_XID("/",grpxid,100,1); + + if(isRoot) { + xml_name_to_XID("/", grpxid, 100, 1); printf("<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">\n", - xmlnsprefix,grpxid,"/"); + xmlnsprefix, grpxid, "/"); } else { char *t_tmp = xml_escape_the_name(tmp); + par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp,grpxid,100,1); - xml_name_to_XID(par,parentxid,100,1); + xml_name_to_XID(tmp, grpxid, 100, 1); + xml_name_to_XID(par, parentxid, 100, 1); printf("<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", - xmlnsprefix,t_name, grpxid, t_tmp, - parentxid, par_name); + "Parents=\"%s\" H5ParentPaths=\"%s\" >\n", + xmlnsprefix, t_name, grpxid, t_tmp, + parentxid, par_name); free(t_tmp); free(par_name); } - free(t_name); + free(t_name); free(grpxid); free(parentxid); /* 1. do all the attributes of the group */ H5Aiterate(gid, NULL, dump_function_table->dump_attribute_function, NULL); - if (!strcmp(name, "/") && unamedtype) { + if(isRoot && unamedtype) { unsigned u; /* Very special case: dump unamed type in root group */ - for (u = 0; u < type_table->nobjs; u++) { - if (!type_table->objs[u].recorded) { + for(u = 0; u < type_table->nobjs; u++) { + if(!type_table->objs[u].recorded) { dset = H5Dopen(gid, type_table->objs[u].objname); type = H5Dget_type(dset); - sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); + sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); dump_function_table->dump_named_datatype_function(type, type_name); H5Tclose(type); H5Dclose(dset); @@ -5300,26 +5227,16 @@ xml_dump_group(hid_t gid, const char *name) } } - /* iterate through all the members */ - xtype = H5G_TYPE; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_DATASET; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_GROUP; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_LINK; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); - xtype = H5G_UDLINK; - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, (void *) &xtype, H5P_DEFAULT); + /* iterate through all the links */ + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); } indent -= COL; indentation(indent); - if (isRoot) { - printf("</%sRootGroup>\n",xmlnsprefix); - } else { - printf("</%sGroup>\n" ,xmlnsprefix); - } + if(isRoot) + printf("</%sRootGroup>\n", xmlnsprefix); + else + printf("</%sGroup>\n" , xmlnsprefix); free(tmp); } @@ -5347,53 +5264,55 @@ xml_print_refs(hid_t did, int source) hsize_t i; if (source == DATASET_DATA) { - type = H5Dget_type(did); + type = H5Dget_type(did); } else if (source == ATTRIBUTE_DATA) { - type = H5Aget_type(did); + type = H5Aget_type(did); } else { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } if (H5Tget_class(type) != H5T_REFERENCE) { - /* return an error */ - return FAIL; - } - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - /* region ref not supported yet... */ - /* return an error */ - return FAIL; - } - if (source == DATASET_DATA) { - space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = calloc((size_t)ssiz, sizeof(char)); - if (buf == NULL) { + /* return an error */ return FAIL; } - e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - /* need to check result here */ - if (e < 0) { - free(buf); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + /* region ref not supported yet... */ + /* return an error */ return FAIL; } + if (source == DATASET_DATA) { + space = H5Dget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); + buf = calloc((size_t)ssiz, sizeof(char)); + if(buf == NULL) + return FAIL; + e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + /* need to check result here */ + if(e < 0) { + free(buf); + return FAIL; + } } else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + space = H5Aget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); - buf = calloc((size_t)ssiz, sizeof(char)); - if (buf == NULL) { - free(buf); - return FAIL; - } - e = H5Aread(did, H5T_STD_REF_OBJ, buf); - /* need to check the result here */ + buf = calloc((size_t)ssiz, sizeof(char)); + if (buf == NULL) { + free(buf); + return FAIL; + } + e = H5Aread(did, H5T_STD_REF_OBJ, buf); + /* need to check the result here */ + if(e < 0) { + free(buf); + return FAIL; + } } else { - /* error */ - return FAIL; + /* error */ + return FAIL; } refbuf = (hobj_ref_t *) buf; @@ -5402,19 +5321,19 @@ xml_print_refs(hid_t did, int source) for (i = 0; i < ssiz; i++) { const char *path; - path = lookup_ref_path(*refbuf); - indentation(indent + COL); + path = lookup_ref_path(*refbuf); + indentation(indent + COL); - if (!path) { - printf("\"%s\"\n", "NULL"); - } else { + if (!path) { + printf("\"%s\"\n", "NULL"); + } else { char *t_path = xml_escape_the_string(path, -1); - printf("\"%s\"\n", t_path); + printf("\"%s\"\n", t_path); free(t_path); - } + } - refbuf++; + refbuf++; } free(buf); @@ -5449,54 +5368,50 @@ xml_print_strs(hid_t did, int source) htri_t is_vlstr; if (source == DATASET_DATA) { - type = H5Dget_type(did); + type = H5Dget_type(did); } else if (source == ATTRIBUTE_DATA) { - type = H5Aget_type(did); + type = H5Aget_type(did); } else { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } if (H5Tget_class(type) != H5T_STRING) { - /* return an error */ - return FAIL; + /* return an error */ + return FAIL; } is_vlstr = H5Tis_variable_str(type); if (source == DATASET_DATA) { - space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = malloc((size_t)ssiz); - - if (buf == NULL) { - return FAIL; - } + space = H5Dget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); - e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + buf = malloc((size_t)ssiz); + if(buf == NULL) + return FAIL; - if (e < 0) { - free(buf); - return FAIL; - } + e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (e < 0) { + free(buf); + return FAIL; + } } else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + space = H5Aget_space(did); + ssiz = H5Sget_simple_extent_npoints(space); + ssiz *= H5Tget_size(type); - buf = malloc((size_t)ssiz); - if (buf == NULL) { - return FAIL; - } + buf = malloc((size_t)ssiz); + if(buf == NULL) + return FAIL; - e = H5Aread(did, type, buf); - if (e < 0) { - free(buf); - return FAIL; - } + e = H5Aread(did, type, buf); + if (e < 0) { + free(buf); + return FAIL; + } } else { - /* error */ - return FAIL; + /* error */ + return FAIL; } /* pull out each string... */ @@ -5516,16 +5431,16 @@ xml_print_strs(hid_t did, int source) HDstrncpy(onestring, bp, tsiz); str_size = tsiz; } - indentation(indent + COL); + indentation(indent + COL); - if (!onestring) { - printf("NULL\n"); - } else { + if (!onestring) { + printf("NULL\n"); + } else { char *t_onestring = xml_escape_the_string(onestring, (int)str_size); - printf("\"%s\"\n", t_onestring); + printf("\"%s\"\n", t_onestring); free(t_onestring); - } + } bp += tsiz; } @@ -5560,72 +5475,72 @@ check_filters(hid_t dcpl) nfilt = H5Pget_nfilters(dcpl); if (nfilt <= 0) - return; + return; for (i = 0; i < nfilt; i++) { #ifdef H5_WANT_H5_V1_6_COMPAT - filter = H5Pget_filter(dcpl, (unsigned)i, &flags, + filter = H5Pget_filter(dcpl, (unsigned)i, &flags, (size_t *) &cd_nelmts, cd_values, 120, namebuf); #else - filter = H5Pget_filter(dcpl, (unsigned)i, &flags, + filter = H5Pget_filter(dcpl, (unsigned)i, &flags, (size_t *) &cd_nelmts, cd_values, 120, namebuf, NULL); #endif /* H5_WANT_H5_V1_6_COMPAT */ - if (filter == H5Z_FILTER_DEFLATE) { - indentation(indent + COL); - printf("<%sDeflate Level=\"",xmlnsprefix); + if (filter == H5Z_FILTER_DEFLATE) { + indentation(indent + COL); + printf("<%sDeflate Level=\"",xmlnsprefix); if (cd_nelmts < 1) { - /* not sure what this means? */ - printf("6"); + /* not sure what this means? */ + printf("6"); } else { - printf("%d",cd_values[0]); + printf("%d",cd_values[0]); } - printf("\"/>\n"); - } else if (filter == H5Z_FILTER_FLETCHER32) { - indentation(indent + COL); - printf("<%sFletcher32 />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SHUFFLE) { - indentation(indent + COL); - printf("<%sShuffle />",xmlnsprefix); - } else if (filter == H5Z_FILTER_SZIP) { + printf("\"/>\n"); + } else if (filter == H5Z_FILTER_FLETCHER32) { + indentation(indent + COL); + printf("<%sFletcher32 />",xmlnsprefix); + } else if (filter == H5Z_FILTER_SHUFFLE) { + indentation(indent + COL); + printf("<%sShuffle />",xmlnsprefix); + } else if (filter == H5Z_FILTER_SZIP) { - indentation(indent + COL); - printf("<%sSZIP ",xmlnsprefix); + indentation(indent + COL); + printf("<%sSZIP ",xmlnsprefix); if (cd_nelmts < 2) { - /* no pixels ? */ - printf("Pixels_per_block=\"-1\" "); + /* no pixels ? */ + printf("Pixels_per_block=\"-1\" "); } else { - printf("Pixels_per_block=\"%d\" ",cd_values[1]); + printf("Pixels_per_block=\"%d\" ",cd_values[1]); } - /* analyse the options mask */ - if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { - printf("Mode =\"Hardware\" "); - } else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { - printf("Mode =\"K13\" "); - } - printf("Coding=\""); - if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { - printf("Entropy"); - } else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { - printf("NN"); - } - printf("\" "); + /* analyse the options mask */ + if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { + printf("Mode =\"Hardware\" "); + } else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { + printf("Mode =\"K13\" "); + } + printf("Coding=\""); + if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { + printf("Entropy"); + } else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { + printf("NN"); + } + printf("\" "); - printf("ByteOrder=\""); - if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { - printf("LSB"); - } else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { - printf("MSB"); - } - printf("\" "); + printf("ByteOrder=\""); + if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { + printf("LSB"); + } else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { + printf("MSB"); + } + printf("\" "); - if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { - printf("Header=\"Raw\""); - } + if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { + printf("Header=\"Raw\""); + } printf("/>\n"); - } else { - /* unknown option */ - } + } else { + /* unknown option */ + } } } @@ -5675,76 +5590,76 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* all other data */ switch (H5Tget_class(type)) { case H5T_INTEGER: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - indentation(indent); - printf("\"%d\"\n",*(int *)buf); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; + indentation(indent); + printf("<%sDataFromFile>\n",xmlnsprefix); + indentation(indent); + printf("\"%d\"\n",*(int *)buf); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + break; case H5T_FLOAT: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - indentation(indent); - printf("\"%f\"\n",*(float *)buf); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; + indentation(indent); + printf("<%sDataFromFile>\n",xmlnsprefix); + indentation(indent); + printf("\"%f\"\n",*(float *)buf); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + break; case H5T_BITFIELD: case H5T_OPAQUE: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - sz = H5Tget_size(type); - indentation(indent); - printf("\""); - for (i = 0; i < sz; i++) { - printf("%x ",*(unsigned int *)buf); - buf = (char *)buf + sizeof(unsigned int); - } - printf("\"\n"); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; + indentation(indent); + printf("<%sDataFromFile>\n",xmlnsprefix); + sz = H5Tget_size(type); + indentation(indent); + printf("\""); + for (i = 0; i < sz; i++) { + printf("%x ",*(unsigned int *)buf); + buf = (char *)buf + sizeof(unsigned int); + } + printf("\"\n"); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + break; case H5T_ENUM: - indentation(indent); - printf("<%sDataFromFile>\n",xmlnsprefix); - name = H5Tget_member_name(type, *(unsigned *)buf); - indentation(indent); - printf("\"%s\"\n",name); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - break; + indentation(indent); + printf("<%sDataFromFile>\n",xmlnsprefix); + name = H5Tget_member_name(type, *(unsigned *)buf); + indentation(indent); + printf("\"%s\"\n",name); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + break; case H5T_ARRAY: - indentation(indent); + indentation(indent); printf("<!-- Array fill values not yet implemented. -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); break; case H5T_TIME: - indentation(indent); + indentation(indent); printf("<!-- Time fill not yet implemented. -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); break; case H5T_COMPOUND: - indentation(indent); + indentation(indent); printf("<!-- Compound fill not yet implemented. -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); break; - case H5T_VLEN: - indentation(indent); + case H5T_VLEN: + indentation(indent); printf("<!-- VL fill not yet implemented. -->\n"); indentation(indent); printf("<%sNoData />\n",xmlnsprefix); break; - default: - indentation(indent); - printf("<!-- Unknown fill datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); - printf("<%sNoData/>\n",xmlnsprefix); - break; - } + default: + indentation(indent); + printf("<!-- Unknown fill datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + break; + } } free(buf); indent -= COL; @@ -5811,67 +5726,67 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) space = H5Dget_space(did); /* Print information about storage layout */ - if (H5D_CHUNKED == H5Pget_layout(dcpl)) { - maxdims = H5Sget_simple_extent_ndims(space); - chsize = (hsize_t *) malloc(maxdims * sizeof(hsize_t)); - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sChunkedLayout ",xmlnsprefix); - ndims = H5Pget_chunk(dcpl, maxdims, chsize); - printf("Ndims=\"%d\">\n", ndims); + if(H5D_CHUNKED == H5Pget_layout(dcpl)) { + maxdims = H5Sget_simple_extent_ndims(space); + chsize = (hsize_t *) malloc(maxdims * sizeof(hsize_t)); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sChunkedLayout ",xmlnsprefix); + ndims = H5Pget_chunk(dcpl, maxdims, chsize); + printf("Ndims=\"%d\">\n", ndims); - indent += COL; + indent += COL; - for (i = 0; i < ndims; i++) { - indentation(indent); - HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", - xmlnsprefix, chsize[i]); - } + for (i = 0; i < ndims; i++) { + indentation(indent); + HDfprintf(stdout, "<%sChunkDimension DimSize=\"%Hu\" />\n", + xmlnsprefix, chsize[i]); + } - indentation(indent); - printf("<%sRequiredFilter>\n",xmlnsprefix); - indent += COL; - check_filters(dcpl); - indent -= COL; - indentation(indent); - printf("</%sRequiredFilter>\n",xmlnsprefix); + indentation(indent); + printf("<%sRequiredFilter>\n",xmlnsprefix); + indent += COL; + check_filters(dcpl); + indent -= COL; + indentation(indent); + printf("</%sRequiredFilter>\n",xmlnsprefix); - indent -= COL; + indent -= COL; - indentation(indent); - printf("</%sChunkedLayout>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); - indent -= COL; - free(chsize); + indentation(indent); + printf("</%sChunkedLayout>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sStorageLayout>\n",xmlnsprefix); + indent -= COL; + free(chsize); } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sContiguousLayout/>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); - indent -= COL; - indentation(indent); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sContiguousLayout/>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sStorageLayout>\n",xmlnsprefix); + indent -= COL; + indentation(indent); } else if (H5D_COMPACT == H5Pget_layout(dcpl)) { - indent += COL; - indentation(indent); - printf("<%sStorageLayout>\n",xmlnsprefix); - indent += COL; - indentation(indent); - printf("<%sCompactLayout/>\n",xmlnsprefix); - indent -= COL; - indentation(indent); - printf("</%sStorageLayout>\n",xmlnsprefix); - indent -= COL; - indentation(indent); + indent += COL; + indentation(indent); + printf("<%sStorageLayout>\n",xmlnsprefix); + indent += COL; + indentation(indent); + printf("<%sCompactLayout/>\n",xmlnsprefix); + indent -= COL; + indentation(indent); + printf("</%sStorageLayout>\n",xmlnsprefix); + indent -= COL; + indentation(indent); } /* and check for external.... ?? */ @@ -5883,36 +5798,36 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) H5Pget_fill_time(dcpl, &ft); printf("FillTime=\""); switch ( ft ) { - case H5D_FILL_TIME_ALLOC: - printf("FillOnAlloc"); - break; - case H5D_FILL_TIME_NEVER: - printf("FillNever"); - break; - case H5D_FILL_TIME_IFSET: - printf("FillIfSet"); - break; - default: - printf("?"); - break; + case H5D_FILL_TIME_ALLOC: + printf("FillOnAlloc"); + break; + case H5D_FILL_TIME_NEVER: + printf("FillNever"); + break; + case H5D_FILL_TIME_IFSET: + printf("FillIfSet"); + break; + default: + printf("?"); + break; } printf("\" "); H5Pget_alloc_time(dcpl, &at); printf("AllocationTime=\""); switch ( at ) { - case H5D_ALLOC_TIME_EARLY: - printf("Early"); - break; - case H5D_ALLOC_TIME_INCR: - printf("Incremental"); - break; - case H5D_ALLOC_TIME_LATE: - printf("Late"); - break; - case H5D_ALLOC_TIME_DEFAULT: - default: - printf("?"); - break; + case H5D_ALLOC_TIME_EARLY: + printf("Early"); + break; + case H5D_ALLOC_TIME_INCR: + printf("Incremental"); + break; + case H5D_ALLOC_TIME_LATE: + printf("Late"); + break; + case H5D_ALLOC_TIME_DEFAULT: + default: + printf("?"); + break; } printf("\""); printf(">\n"); @@ -5948,77 +5863,77 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) tempi = H5Dget_storage_size(did); if (display_data && (tempi > 0)) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; + switch (H5Tget_class(type)) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; - case H5T_TIME: - indent += COL; - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Time data not yet implemented. -->\n"); - indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indent -= COL; - break; + case H5T_TIME: + indent += COL; + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Time data not yet implemented. -->\n"); + indentation(indent); + printf("<%sNoData />\n",xmlnsprefix); + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indent -= COL; + break; - case H5T_COMPOUND: - indentation(indent); - printf("<!-- Note: format of compound data not specified -->\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; + case H5T_COMPOUND: + indentation(indent); + printf("<!-- Note: format of compound data not specified -->\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; - case H5T_REFERENCE: - indentation(indent); - printf("<%sData>\n",xmlnsprefix); - indentation(indent); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - printf("<!-- Note: Region references not supported -->\n"); + case H5T_REFERENCE: indentation(indent); - printf("<%sNoData />\n",xmlnsprefix); - } else { - printf("<%sDataFromFile>\n",xmlnsprefix); - xml_print_refs(did, DATASET_DATA); - indentation(indent); - printf("</%sDataFromFile>\n",xmlnsprefix); - } - indentation(indent); - printf("</%sData>\n",xmlnsprefix); - break; + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + printf("<!-- Note: Region references not supported -->\n"); + indentation(indent); + printf("<%sNoData />\n",xmlnsprefix); + } else { + printf("<%sDataFromFile>\n",xmlnsprefix); + xml_print_refs(did, DATASET_DATA); + indentation(indent); + printf("</%sDataFromFile>\n",xmlnsprefix); + } + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; - case H5T_VLEN: - printf("<!-- Note: format of VL data not specified -->\n"); - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - break; - default: - indentation(indent); + case H5T_VLEN: + printf("<!-- Note: format of VL data not specified -->\n"); + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + break; + default: + indentation(indent); + printf("<%sData>\n",xmlnsprefix); + indentation(indent); + printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); + indentation(indent); + printf("<%sNoData/>\n",xmlnsprefix); + indentation(indent); + printf("</%sData>\n",xmlnsprefix); + break; + } + } else { + /* no data written */ + indentation(indent + COL); printf("<%sData>\n",xmlnsprefix); - indentation(indent); - printf("<!-- Unknown datatype: %d -->\n", H5Tget_class(type)); - indentation(indent); + indentation(indent + COL + COL); printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent); + indentation(indent + COL); printf("</%sData>\n",xmlnsprefix); - break; - } - } else { - /* no data written */ - indentation(indent + COL); - printf("<%sData>\n",xmlnsprefix); - indentation(indent + COL + COL); - printf("<%sNoData/>\n",xmlnsprefix); - indentation(indent + COL); - printf("</%sData>\n",xmlnsprefix); } H5Tclose(type); @@ -6045,13 +5960,13 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) static void xml_print_enum(hid_t type) { - char **name = NULL; /*member names */ + char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - unsigned nmembs; /*number of members */ - hid_t super; /*enum base integer type */ - hid_t native = -1; /*native integer data type */ - size_t dst_size; /*destination value type size */ - unsigned i; /*miscellaneous counters */ + unsigned nmembs; /*number of members */ + hid_t super; /*enum base integer type */ + hid_t native = -1; /*native integer datatype */ + size_t dst_size; /*destination value type size */ + unsigned i; /*miscellaneous counters */ size_t j; nmembs = H5Tget_nmembers(type); @@ -6064,22 +5979,22 @@ xml_print_enum(hid_t type) printf("</%sDataType>\n",xmlnsprefix); /* - * Determine what data type to use for the native values. To simplify + * Determine what datatype to use for the native values. To simplify * things we entertain three possibilities: * 1. long_long -- the largest native signed integer * 2. unsigned long_long -- the largest native unsigned integer * 3. raw format */ if (H5Tget_size(type) <= sizeof(long_long)) { - dst_size = sizeof(long_long); + dst_size = sizeof(long_long); - if (H5T_SGN_NONE == H5Tget_sign(type)) { - native = H5T_NATIVE_ULLONG; - } else { - native = H5T_NATIVE_LLONG; - } + if (H5T_SGN_NONE == H5Tget_sign(type)) { + native = H5T_NATIVE_ULLONG; + } else { + native = H5T_NATIVE_LLONG; + } } else { - dst_size = H5Tget_size(type); + dst_size = H5Tget_size(type); } /* Get the names and raw values of all members */ @@ -6087,13 +6002,13 @@ xml_print_enum(hid_t type) value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { - name[i] = H5Tget_member_name(type, i); - H5Tget_member_value(type, i, value + i * H5Tget_size(type)); + name[i] = H5Tget_member_name(type, i); + H5Tget_member_value(type, i, value + i * H5Tget_size(type)); } - /* Convert values to native data type */ + /* Convert values to native datatype */ if (native > 0) - H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); + H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet */ @@ -6103,38 +6018,38 @@ xml_print_enum(hid_t type) for (i = 0; i < nmembs; i++) { char *t_name = xml_escape_the_name(name[i]); - indentation(indent); - printf("<%sEnumElement>\n",xmlnsprefix); - indentation(indent + COL); - printf("%s\n", t_name); + indentation(indent); + printf("<%sEnumElement>\n",xmlnsprefix); + indentation(indent + COL); + printf("%s\n", t_name); free(t_name); - indentation(indent); - printf("</%sEnumElement>\n",xmlnsprefix); - indentation(indent); - printf("<%sEnumValue>\n",xmlnsprefix); - indentation(indent + COL); - if (native < 0) { - printf("0x"); - - for (j = 0; j < dst_size; j++) - printf("%02x", value[i * dst_size + j]); - } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) - ((void *) (value + i * dst_size)))); - } else { - HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", - *((long_long *) ((void *) (value + i * dst_size)))); - } - printf("\n"); - indentation(indent); - printf("</%sEnumValue>\n",xmlnsprefix); + indentation(indent); + printf("</%sEnumElement>\n",xmlnsprefix); + indentation(indent); + printf("<%sEnumValue>\n",xmlnsprefix); + indentation(indent + COL); + if (native < 0) { + printf("0x"); + + for (j = 0; j < dst_size; j++) + printf("%02x", value[i * dst_size + j]); + } else if (H5T_SGN_NONE == H5Tget_sign(native)) { + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long_long *) + ((void *) (value + i * dst_size)))); + } else { + HDfprintf(stdout,"%" H5_PRINTF_LL_WIDTH "d", + *((long_long *) ((void *) (value + i * dst_size)))); + } + printf("\n"); + indentation(indent); + printf("</%sEnumValue>\n",xmlnsprefix); } indent -= COL; /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); @@ -6183,55 +6098,54 @@ h5_fileaccess(void) if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + /* Unix read() and write() system calls */ + if (H5Pset_fapl_sec2(fapl)<0) return -1; } else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; + /* Standard C fread() and fwrite() system calls */ + if (H5Pset_fapl_stdio(fapl)<0) return -1; } else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; + /* In-core temporary file with 1MB increment */ + if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; } else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, + /* Split meta data and raw data each using default driver */ + if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) return -1; } else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); - } + /* Multi-file driver, general case of the split driver */ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][1024]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); + + assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + memb_fapl[mt] = H5P_DEFAULT; + memb_map[mt] = mt; + sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); + memb_name[mt] = sv[mt]; + memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); + } - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { - return -1; - } + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, + memb_addr, FALSE) < 0) + return -1; } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ - /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) - return -1; + /* Family of files, each 1MB and using the default driver */ + if ((val=HDstrtok(NULL, " \t\n\r"))) + fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "log")) { long log_flags = H5FD_LOG_LOC_IO; @@ -6240,14 +6154,14 @@ h5_fileaccess(void) log_flags = HDstrtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) - return -1; + return -1; } else if (!HDstrcmp(name, "direct")) { /* Substitute Direct I/O driver with sec2 driver temporarily because * some output has sec2 driver as the standard. */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + if (H5Pset_fapl_sec2(fapl)<0) return -1; } else { - /* Unknown driver */ - return -1; + /* Unknown driver */ + return -1; } return fapl; @@ -6297,5 +6211,3 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name) HDstrcat(HDstrcat(*prfx, "/"), name); } /* end add_prefix */ - - diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index c3c89a3..3d8104c 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -66,17 +66,17 @@ 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_NLIBTYPES]; +} dispatch_g[H5O_TYPE_NTYPES]; -#define DISPATCH(TYPE,NAME,OPEN,CLOSE,LIST1,LIST2) { \ - dispatch_g[TYPE].name = (NAME); \ - dispatch_g[TYPE].open = (OPEN); \ +#define DISPATCH(TYPE, NAME, OPEN, CLOSE, LIST1, LIST2) { \ + dispatch_g[TYPE].name = (NAME); \ + dispatch_g[TYPE].open = (OPEN); \ dispatch_g[TYPE].close = (CLOSE); \ dispatch_g[TYPE].list1 = (LIST1); \ dispatch_g[TYPE].list2 = (LIST2); \ } -static herr_t list (hid_t group, const char *name, const H5L_info_t *linfo, void *cd); +static herr_t list(hid_t group, const char *name, const H5L_info_t *linfo, void *cd); static void display_type(hid_t type, int ind); static char *fix_name(const char *path, const char *base); @@ -145,30 +145,24 @@ usage: %s [OPTIONS] [OBJECTS...]\n\ *------------------------------------------------------------------------- */ static void -sym_insert(H5G_stat_t *sb, const char *name) +sym_insert(const H5O_info_t *oi, const char *name) { - haddr_t objno; /* Compact form of object's location */ int n; /* Don't add it if the link count is 1 because such an object can only * have one name. */ - if (sb->nlink<2) return; + if(oi->rc < 2) + return; /* Extend the table */ - if (idtab_g.nobjs>=idtab_g.nalloc) { + if(idtab_g.nobjs >= idtab_g.nalloc) { idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc); - idtab_g.obj = realloc(idtab_g.obj, - idtab_g.nalloc*sizeof(idtab_g.obj[0])); - } + idtab_g.obj = realloc(idtab_g.obj, idtab_g.nalloc*sizeof(idtab_g.obj[0])); + } /* end if */ /* Insert the entry */ n = idtab_g.nobjs++; -#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - objno = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); -#else - objno = (haddr_t)sb->objno[0]; -#endif - idtab_g.obj[n].id = objno; + idtab_g.obj[n].id = oi->addr; idtab_g.obj[n].name = HDstrdup(name); } @@ -190,17 +184,18 @@ sym_insert(H5G_stat_t *sb, const char *name) *------------------------------------------------------------------------- */ static char * -sym_lookup(H5G_stat_t *sb) +sym_lookup(const H5O_info_t *oi) { - haddr_t objno; /* Compact form of object's location */ int n; - if (sb->nlink<2) return NULL; /*only one name possible*/ - objno = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); - for (n=0; n<idtab_g.nobjs; n++) { - if(idtab_g.obj[n].id == objno) + /*only one name possible*/ + if(oi->rc < 2) + return NULL; + + for(n = 0; n < idtab_g.nobjs; n++) + if(idtab_g.obj[n].id == oi->addr) return idtab_g.obj[n].name; - } + return NULL; } @@ -1173,21 +1168,18 @@ display_type(hid_t type, int ind) } /* Shared? If so then print the type's OID */ - if (H5Tcommitted(type)) { - H5G_stat_t sb; + if(H5Tcommitted(type)) { + H5O_info_t oi; - if (H5Gget_objinfo(type, ".", FALSE, &sb)>=0) { - haddr_t objno; /* Compact form of object's location */ - - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); + if(H5Oget_info(type, ".", &oi, H5P_DEFAULT) >= 0) printf("shared-%lu:"H5_PRINTF_HADDR_FMT" ", - sb.fileno[0], objno); - } else + oi.fileno, oi.addr); + else printf("shared "); - } + } /* end if */ /* Print the type */ - if ((!simple_output_g && display_native_type(type, ind)) || + if((!simple_output_g && display_native_type(type, ind)) || display_ieee_type(type, ind) || display_int_type(type, ind) || display_float_type(type, ind) || @@ -1709,108 +1701,6 @@ datatype_list2(hid_t type, const char UNUSED *name) /*------------------------------------------------------------------------- - * Function: slink_open - * - * Purpose: This gets called to open a symbolic link. Since symbolic - * links don't correspond to actual objects we simply print the - * link information and return failure. - * - * Return: Success: 0 - an invalid object but successful return - * of this function. - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Thursday, August 27, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hid_t -slink_open(hid_t location, const char *name, hid_t UNUSED apl_id) -{ - H5G_stat_t statbuf; - - if(H5Gget_objinfo(location, name, FALSE, &statbuf) < 0) - return -1; - - if(statbuf.type == H5G_LINK) { /* Soft link */ - char *buf = HDmalloc(statbuf.linklen); - - if(H5Lget_val(location, name, buf, statbuf.linklen, H5P_DEFAULT) < 0) { - HDfree(buf); - return -1; - } - - HDfputs(buf, stdout); - HDfree(buf); - } - - return 0; -} - - -/*------------------------------------------------------------------------- - * Function: udlink_open - * - * Purpose: This gets called to open a user-defined link. Since these - * links don't correspond to actual objects we simply print a message - * and return failure. - * - * Return: Success: 0 - an invalid object but successful return - * of this function. - * - * Failure: -1 - * - * Programmer: James Laird - * Tuesday, June 6, 2006 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hid_t -udlink_open(hid_t location, const char *name, hid_t UNUSED apl_id) -{ - H5L_info_t linfo; - char * buf = NULL; - const char * filename; - const char * path; - - if(H5Lget_info(location, name, &linfo, H5P_DEFAULT) < 0) - return -1; - - switch(linfo.type) { - /* For external links, try to display info for the object it points to */ - case H5L_TYPE_EXTERNAL: - if((buf = HDmalloc(linfo.u.val_size)) == NULL) - goto error; - if(H5Lget_val(location, name, buf, linfo.u.val_size, H5P_DEFAULT) < 0) - goto error; - - if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &filename, &path) < 0) - goto error; - HDfputs("file: ", stdout); - HDfputs(filename, stdout); - HDfputs(" path: ", stdout); - HDfputs(path, stdout); - break; - - default: - HDfputs("cannot follow UD links", stdout); - } - - return 0; - -error: - if(buf) - HDfree(buf); - return -1; -} - - -/*------------------------------------------------------------------------- * Function: list * * Purpose: Prints the group member name. @@ -1830,102 +1720,162 @@ error: *------------------------------------------------------------------------- */ static herr_t -list(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *_iter) +list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter) { - hid_t obj = -1; - char buf[512], comment[50], *fullname = NULL, *s = NULL; - H5G_stat_t sb; - haddr_t objno; /* Compact form of object's location */ - struct tm *tm; - herr_t status; iter_t *iter = (iter_t*)_iter; + char *fullname = NULL; int n; /* Print the object name, either full name or base name */ fullname = fix_name(iter->container, name); - if (fullname_g) { + if(fullname_g) n = display_string(stdout, fullname, TRUE); - printf("%*s ", MAX(0, 24-n), ""); - } else { + else n = display_string(stdout, name, TRUE); - printf("%*s ", MAX(0, 24-n), ""); - } + printf("%*s ", MAX(0, (24 - n)), ""); + + /* Actions on objects */ + if(linfo->type == H5L_TYPE_HARD) { + H5O_info_t oi; + char *s; + hid_t obj; + + /* Get object information */ + if(H5Oget_info(group, name, &oi, H5P_DEFAULT) < 0) { + puts("**NOT FOUND**"); + return 0; + } else if(oi.type < 0 || oi.type >= H5O_TYPE_NTYPES) { + printf("Unknown type(%d)", (int)oi.type); + oi.type = H5O_TYPE_UNKNOWN; + } + if(oi.type >= 0 && dispatch_g[oi.type].name) + fputs(dispatch_g[oi.type].name, stdout); + + /* If the object has already been printed then just show the object ID + * and return. */ + if((s = sym_lookup(&oi))) { + printf(", same as "); + display_string(stdout, s, TRUE); + printf("\n"); + goto done; + } /* end if */ + else + sym_insert(&oi, fullname); + + /* Open the object. Not all objects can be opened. If this is the case + * then return right away. + */ + if(oi.type >= 0 && + (NULL == dispatch_g[oi.type].open || + (obj = (dispatch_g[oi.type].open)(group, name, H5P_DEFAULT)) < 0)) { + printf(" *ERROR*\n"); + goto done; + } /* end if */ - /* Get object information */ - H5E_BEGIN_TRY { - status = H5Gget_objinfo(group, name, FALSE, &sb); - } H5E_END_TRY; - if(status < 0) { - puts("**NOT FOUND**"); - return 0; - } else if(sb.type < 0 || sb.type >= H5G_NTYPES) { - printf("Unknown type(%d)", sb.type); - sb.type = H5G_UNKNOWN; - } - if(sb.type >= 0 && dispatch_g[sb.type].name) - fputs(dispatch_g[sb.type].name, stdout); - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); - - /* If the object has already been printed then just show the object ID - * and return. */ - if((s = sym_lookup(&sb))) { - printf(", same as "); - display_string(stdout, s, TRUE); - printf("\n"); - goto done; - } else { - sym_insert(&sb, fullname); - } + /* List the first line of information for the object. */ + if(oi.type >= 0 && dispatch_g[oi.type].list1) + (dispatch_g[oi.type].list1)(obj); + putchar('\n'); - /* Open the object. Not all objects can be opened. If this is the case - * then return right away. */ - if(sb.type >= 0 && - (NULL == dispatch_g[sb.type].open || - (obj = (dispatch_g[sb.type].open)(group, name, H5P_DEFAULT)) < 0)) { - printf(" *ERROR*\n"); - goto done; - } /* end if */ + /* Show detailed information about the object, beginning with information + * which is common to all objects. */ + if(verbose_g > 0) { + char comment[50]; + + /* Display attributes */ + if(oi.type >= 0) + H5Aiterate(obj, NULL, list_attr, NULL); + + /* Object location & reference count */ + printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oi.fileno, oi.addr); + printf(" %-10s %u\n", "Links:", (unsigned)oi.rc); + + /* Modification time */ + if(oi.mtime > 0) { + char buf[256]; + struct tm *tm; + + if(simple_output_g) + tm = HDgmtime(&(oi.mtime)); + else + tm = HDlocaltime(&(oi.mtime)); + if(tm) { + HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); + printf(" %-10s %s\n", "Modified:", buf); + } /* end if */ + } /* end if */ - /* List the first line of information for the object. */ - if(sb.type >= 0 && dispatch_g[sb.type].list1) - (dispatch_g[sb.type].list1)(obj); - putchar('\n'); - - /* Show detailed information about the object, beginning with information - * which is common to all objects. */ - if(verbose_g > 0 && H5G_LINK != sb.type && H5G_UDLINK != sb.type) { - if(sb.type >= 0) - H5Aiterate(obj, NULL, list_attr, NULL); - printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", sb.fileno[0], objno); - printf(" %-10s %u\n", "Links:", sb.nlink); - if(sb.mtime > 0) { - if(simple_output_g) - tm = HDgmtime(&(sb.mtime)); - else - tm = HDlocaltime(&(sb.mtime)); - if(tm) { - HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - printf(" %-10s %s\n", "Modified:", buf); + /* Object comment */ + comment[0] = '\0'; + H5Oget_comment(group, name, comment, sizeof(comment), H5P_DEFAULT); + HDstrcpy(comment + sizeof(comment) - 4, "..."); + if(comment[0]) { + printf(" %-10s \"", "Comment:"); + display_string(stdout, comment, FALSE); + puts("\""); } /* end if */ } /* end if */ - comment[0] = '\0'; - H5Oget_comment(group, name, comment, sizeof(comment), H5P_DEFAULT); - HDstrcpy(comment + sizeof(comment) - 4, "..."); - if(comment[0]) { - printf(" %-10s \"", "Comment:"); - display_string(stdout, comment, FALSE); - puts("\""); - } /* end if */ + + /* Detailed list for object */ + if(oi.type >= 0 && dispatch_g[oi.type].list2) + (dispatch_g[oi.type].list2)(obj, fullname); + + /* Close the object. */ + if(oi.type >= 0 && dispatch_g[oi.type].close) + (dispatch_g[oi.type].close)(obj); } /* end if */ - if(sb.type >= 0 && dispatch_g[sb.type].list2) - (dispatch_g[sb.type].list2)(obj, fullname); + /* Actions on links */ + else { + char *buf; + + HDfputs("-> ", stdout); + switch(linfo->type) { + case H5L_TYPE_SOFT: + if((buf = HDmalloc(linfo->u.val_size)) == NULL) + goto done; + + if(H5Lget_val(group, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf); + goto done; + } /* end if */ + + HDfputs(buf, stdout); + HDfree(buf); + break; -done: - /* Close the object. */ - if(sb.type >= 0 && obj >= 0 && dispatch_g[sb.type].close) - (dispatch_g[sb.type].close)(obj); + case H5L_TYPE_EXTERNAL: + { + const char *filename; + const char *path; + + if((buf = HDmalloc(linfo->u.val_size)) == NULL) + goto done; + + if(H5Lget_val(group, name, buf, linfo->u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf); + goto done; + } /* end if */ + if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0) { + HDfree(buf); + goto done; + } /* end if */ + + HDfputs("file: ", stdout); + HDfputs(filename, stdout); + HDfputs(" path: ", stdout); + HDfputs(path, stdout); + } + break; + + default: + HDfputs("cannot follow UD links", stdout); + break; + } /* end switch */ + HDfputc('\n', stdout); + } /* end else */ - if (fullname) +done: + if(fullname) free(fullname); return 0; } /* end list() */ @@ -2104,178 +2054,182 @@ leave(int ret) *------------------------------------------------------------------------- */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - hid_t file=-1, root=-1; - char *fname=NULL, *oname=NULL, *x; + hid_t file = -1, root = -1; + char *fname = NULL, *oname = NULL, *x; const char *s = NULL; - char *rest, *container=NULL; + char *rest, *container = NULL; int argno; - H5G_stat_t sb; - iter_t iter; static char root_name[] = "/"; char drivername[50]; - const char *preferred_driver=NULL; + const char *preferred_driver = NULL; /* Initialize h5tools lib */ h5tools_init(); - /* Build display table */ + /* Build object display table */ DISPATCH(H5G_DATASET, "Dataset", H5Dopen2, H5Dclose, dataset_list1, dataset_list2); DISPATCH(H5G_GROUP, "Group", H5Gopen2, H5Gclose, NULL, group_list2); DISPATCH(H5G_TYPE, "Type", H5Topen2, H5Tclose, NULL, datatype_list2); - DISPATCH(H5G_LINK, "-> ", slink_open, NULL, NULL, NULL); - DISPATCH(H5G_UDLINK, "-> ", udlink_open, NULL, NULL, NULL); - -#if 0 - /* Name of this program without the path */ - if ((progname=strrchr(argv[0], '/'))) progname++; - else progname = argv[0]; -#endif /* Default output width */ width_g = get_width(); /* Switches come before non-switch arguments */ - for (argno=1; argno<argc && '-'==argv[argno][0]; argno++) { - if (!strcmp(argv[argno], "--")) { + for(argno = 1; argno < argc && '-' == argv[argno][0]; argno++) { + if(!HDstrcmp(argv[argno], "--")) { /* Last switch */ argno++; break; - } else if (!strcmp(argv[argno], "--help")) { + } else if(!HDstrcmp(argv[argno], "--help")) { usage(); leave(0); - } else if (!strcmp(argv[argno], "--address")) { + } else if(!HDstrcmp(argv[argno], "--address")) { address_g = TRUE; - } else if (!strcmp(argv[argno], "--data")) { + } else if(!HDstrcmp(argv[argno], "--data")) { data_g = TRUE; - } else if (!strcmp(argv[argno], "--errors")) { + } else if(!HDstrcmp(argv[argno], "--errors")) { show_errors_g = TRUE; - } else if (!strcmp(argv[argno], "--full")) { + } else if(!HDstrcmp(argv[argno], "--full")) { fullname_g = TRUE; - } else if (!strcmp(argv[argno], "--group")) { + } else if(!HDstrcmp(argv[argno], "--group")) { grp_literal_g = TRUE; - } else if (!strcmp(argv[argno], "--label")) { + } else if(!HDstrcmp(argv[argno], "--label")) { label_g = TRUE; - } else if (!strcmp(argv[argno], "--recursive")) { + } else if(!HDstrcmp(argv[argno], "--recursive")) { recursive_g = TRUE; fullname_g = TRUE; - } else if (!strcmp(argv[argno], "--simple")) { + } else if(!HDstrcmp(argv[argno], "--simple")) { simple_output_g = TRUE; - } else if (!strcmp(argv[argno], "--string")) { + } else if(!HDstrcmp(argv[argno], "--string")) { string_g = TRUE; - } else if (!strncmp(argv[argno], "--vfd=", 6)) { + } else if(!HDstrncmp(argv[argno], "--vfd=", 6)) { preferred_driver = argv[argno]+6; - } else if (!strncmp(argv[argno], "--width=", 8)) { - width_g = (int)strtol(argv[argno]+8, &rest, 0); + } else if(!HDstrncmp(argv[argno], "--width=", 8)) { + width_g = (int)HDstrtol(argv[argno]+8, &rest, 0); - if (0 == width_g) + if(0 == width_g) no_line_wrap_g = TRUE; - else if (width_g<0 || *rest) { + else if(width_g < 0 || *rest) { usage(); leave(1); } - } else if (!strcmp(argv[argno], "--width")) { - if (argno+1>=argc) { + } else if(!HDstrcmp(argv[argno], "--width")) { + if((argno + 1) >= argc) { usage(); leave(1); } else { s = argv[++argno]; } - width_g = (int)strtol(s, &rest, 0); - if (width_g<=0 || *rest) { + width_g = (int)HDstrtol(s, &rest, 0); + if(width_g <= 0 || *rest) { usage(); leave(1); } - } else if (!strcmp(argv[argno], "--verbose")) { + } else if(!HDstrcmp(argv[argno], "--verbose")) { verbose_g++; - } else if (!strcmp(argv[argno], "--version")) { + } else if(!HDstrcmp(argv[argno], "--version")) { print_version(progname); leave(0); - } else if (!strcmp(argv[argno], "--hexdump")) { + } else if(!HDstrcmp(argv[argno], "--hexdump")) { hexdump_g = TRUE; - } else if (!strncmp(argv[argno], "-w", 2)) { - if (argv[argno][2]) { - s = argv[argno]+2; - } else if (argno+1>=argc) { + } else if(!HDstrncmp(argv[argno], "-w", 2)) { + if(argv[argno][2]) { + s = argv[argno] + 2; + } else if((argno + 1) >= argc) { usage(); leave(1); } else { s = argv[++argno]; } - width_g = (int)strtol(s, &rest, 0); + width_g = (int)HDstrtol(s, &rest, 0); - if (0 == width_g) + if(0 == width_g) no_line_wrap_g = TRUE; - else if (width_g<0 || *rest) { + else if(width_g < 0 || *rest) { usage(); leave(1); } - } else if ('-'!=argv[argno][1]) { + } else if('-'!=argv[argno][1]) { /* Single-letter switches */ - for (s=argv[argno]+1; *s; s++) { - switch (*s) { + for(s = argv[argno] + 1; *s; s++) { + switch(*s) { case '?': case 'h': /* --help */ usage(); leave(0); + case 'a': /* --address */ address_g = TRUE; break; + case 'd': /* --data */ data_g = TRUE; break; + case 'e': /* --errors */ show_errors_g = TRUE; break; + case 'f': /* --full */ fullname_g = TRUE; break; + case 'g': /* --group */ grp_literal_g = TRUE; break; + case 'l': /* --label */ label_g = TRUE; break; + case 'r': /* --recursive */ recursive_g = TRUE; fullname_g = TRUE; break; + case 'S': /* --simple */ simple_output_g = TRUE; break; + case 's': /* --string */ string_g = TRUE; break; + case 'v': /* --verbose */ verbose_g++; break; + case 'V': /* --version */ print_version(progname); leave(0); + case 'x': /* --hexdump */ hexdump_g = TRUE; break; + default: usage(); leave(1); - } - } + } /* end switch */ + } /* end for */ } else { usage(); leave(1); } - } + } /* end for */ /* If no arguments remain then print a usage message (instead of doing * absolutely nothing ;-) */ - if (argno>=argc) { + if(argno >= argc) { usage(); leave(1); - } + } /* end if */ /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ - if (!show_errors_g) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + if(!show_errors_g) + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Each remaining argument is an hdf5 file followed by an optional slash @@ -2291,42 +2245,67 @@ main (int argc, const char *argv[]) * then there must have been something wrong with the file (perhaps it * doesn't exist). */ show_file_name_g = (argc-argno > 1); /*show file names if more than one*/ - while (argno<argc) { + while(argno < argc) { + H5O_info_t oi; + H5L_info_t li; + iter_t iter; + fname = HDstrdup(argv[argno++]); oname = NULL; file = -1; - while (fname && *fname) { + while(fname && *fname) { file = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername); - if (file>=0) { - if (verbose_g) { - printf("Opened \"%s\" with %s driver.\n", - fname, drivername); - } + if(file >= 0) { + if(verbose_g) + printf("Opened \"%s\" with %s driver.\n", fname, drivername); break; /*success*/ - } + } /* end if */ /* Shorten the file name; lengthen the object name */ x = oname; oname = strrchr(fname, '/'); - if (x) *x = '/'; - if (!oname) break; + if(x) + *x = '/'; + if(!oname) + break; *oname = '\0'; - } - if (file<0) { + } /* end while */ + if(file < 0) { fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); continue; - } + } /* end if */ if(oname) oname++; if(!oname || !*oname) oname = root_name; + /* Check for root group as object name */ + if(HDstrcmp(oname, root_name)) { + /* Check the type of link given */ + if(H5Lget_info(file, oname, &li, H5P_DEFAULT) < 0) { + char *fullname = NULL; + int n; + + fullname = fix_name(oname, "/"); + if(fullname_g) + n = display_string(stdout, fullname, TRUE); + else + n = display_string(stdout, oname, TRUE); + printf("%*s \n", MAX(0, (24 - n)), "**NOT FOUND**"); + + HDfree(fullname); + leave(1); + } /* end if */ + } /* end if */ + else + li.type = H5L_TYPE_HARD; + /* Open the object and display it's information */ - if(H5Gget_objinfo(file, oname, TRUE, &sb) >= 0 && H5G_GROUP == sb.type && !grp_literal_g) { + if(li.type == H5L_TYPE_HARD && H5Oget_info(file, oname, &oi, H5P_DEFAULT) >= 0 && H5O_TYPE_GROUP == oi.type && !grp_literal_g) { /* Specified name is a group. List the complete contents of the group. */ - sym_insert(&sb, oname); + sym_insert(&oi, oname); iter.container = container = fix_name((show_file_name_g ? fname : ""), oname); /* list root attributes */ @@ -2341,21 +2320,21 @@ main (int argc, const char *argv[]) /* list */ H5Literate(file, oname, H5_INDEX_NAME, H5_ITER_INC, NULL, list, &iter, H5P_DEFAULT); free(container); - } else if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) { leave(1); /*major problem!*/ - } else { /* Specified name is a non-group object -- list that object. The - * container for the object is everything up to the base name. */ + * container for the object is everything up to the base name. + */ iter.container = show_file_name_g ? fname : "/"; - list(root, oname, NULL, &iter); + list(root, oname, &li, &iter); if(H5Gclose(root) < 0) leave(1); } H5Fclose(file); free(fname); - } + } /* end while */ + leave(0); } diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index c710bce..42dca2a 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -626,12 +626,12 @@ int do_copy_objects(hid_t fidin, */ if ( has_filter && apply_s == 0 ) printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", - travt->objs[i].name, - (int)options->threshold); + travt->objs[i].name, + (int)options->threshold); if ( has_filter && apply_f == 0 ) printf(" <warning: could not apply the filter to %s>\n", - travt->objs[i].name); + travt->objs[i].name); } /* verbose */ diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 8a549cd..a29ae48 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -30,8 +30,8 @@ */ static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt); -static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id); -static int copy_refs_attr(hid_t loc_in,hid_t loc_out,pack_opt_t *options,trav_table_t *travt,hid_t fidout); +static int copy_refs_attr(hid_t loc_in, hid_t loc_out, pack_opt_t *options, + trav_table_t *travt, hid_t fidout); /*------------------------------------------------------------------------- * Function: do_copy_refobjs @@ -53,15 +53,15 @@ int do_copy_refobjs(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in=(-1); /* read group ID */ - hid_t grp_out=(-1); /* write group ID */ - hid_t dset_in=(-1); /* read dataset ID */ - hid_t dset_out=(-1); /* write dataset ID */ - hid_t type_in=(-1); /* named type ID */ - hid_t dcpl_id=(-1); /* dataset creation property list ID */ - hid_t space_id=(-1); /* space ID */ - hid_t ftype_id=(-1); /* file data type ID */ - hid_t mtype_id=(-1); /* memory data type ID */ + hid_t grp_in = (-1); /* read group ID */ + hid_t grp_out = (-1); /* write group ID */ + hid_t dset_in = (-1); /* read dataset ID */ + hid_t dset_out = (-1); /* write dataset ID */ + hid_t type_in = (-1); /* named type ID */ + hid_t dcpl_id = (-1); /* dataset creation property list ID */ + hid_t space_id = (-1); /* space ID */ + hid_t ftype_id = (-1); /* file data type ID */ + hid_t mtype_id = (-1); /* memory data type ID */ size_t msize; /* memory size of memory type */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ @@ -73,83 +73,75 @@ int do_copy_refobjs(hid_t fidin, * browse *------------------------------------------------------------------------- */ - - for ( i = 0; i < travt->nobjs; i++) - { - switch ( travt->objs[i].type ) - { + for(i = 0; i < travt->nobjs; i++) { + switch(travt->objs[i].type) { /*------------------------------------------------------------------------- - * H5G_GROUP + * H5TRAV_TYPE_GROUP *------------------------------------------------------------------------- */ - case H5G_GROUP: - + case H5TRAV_TYPE_GROUP: /*------------------------------------------------------------------------- * copy referenced objects in attributes *------------------------------------------------------------------------- */ - - if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) goto error; - if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) goto error; - if (copy_refs_attr(grp_in,grp_out,options,travt,fidout) < 0) + if(copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0) goto error; - if (H5Gclose(grp_out) < 0) + if(H5Gclose(grp_out) < 0) goto error; - if (H5Gclose(grp_in) < 0) + if(H5Gclose(grp_in) < 0) goto error; - /*------------------------------------------------------------------------- * check for hard links *------------------------------------------------------------------------- */ - if(travt->objs[i].nlinks) for(j = 0; j < travt->objs[i].nlinks; j++) H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); break; /*------------------------------------------------------------------------- - * H5G_DATASET + * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- */ - case H5G_DATASET: - - if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0) + case H5TRAV_TYPE_DATASET: + if((dset_in = H5Dopen(fidin,travt->objs[i].name)) < 0) goto error; - if ((space_id=H5Dget_space(dset_in))<0) + if((space_id = H5Dget_space(dset_in)) < 0) goto error; - if ((ftype_id=H5Dget_type (dset_in))<0) + if((ftype_id = H5Dget_type (dset_in)) < 0) goto error; - if ((dcpl_id=H5Dget_create_plist(dset_in))<0) + if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) goto error; - if ( (rank=H5Sget_simple_extent_ndims(space_id))<0) + if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) goto error; - if ( H5Sget_simple_extent_dims(space_id,dims,NULL)<0) + if(H5Sget_simple_extent_dims(space_id,dims,NULL) < 0) goto error; - nelmts=1; - for (k=0; k<rank; k++) - nelmts*=dims[k]; + nelmts = 1; + for(k = 0; k < rank; k++) + nelmts *= dims[k]; - if ((mtype_id=h5tools_get_native_type(ftype_id))<0) + if((mtype_id = h5tools_get_native_type(ftype_id)) < 0) goto error; - if ((msize=H5Tget_size(mtype_id))==0) + if((msize = H5Tget_size(mtype_id)) == 0) goto error; + /*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off - *------------------------------------------------------------------------- - */ - if (h5tools_canreadf((NULL),dcpl_id)==1) - { + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off + *------------------------------------------------------------------------- + */ + if(h5tools_canreadf(NULL, dcpl_id) == 1) { /*------------------------------------------------------------------------- * test for a valid output dataset *------------------------------------------------------------------------- @@ -161,12 +153,10 @@ int do_copy_refobjs(hid_t fidin, * we cannot just copy the buffers, but instead we recreate the reference *------------------------------------------------------------------------- */ - if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) - { - H5G_obj_t1 obj_type; + if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { hid_t refobj_id; - hobj_ref_t *refbuf=NULL; /* buffer for object references */ - hobj_ref_t *buf=NULL; + hobj_ref_t *refbuf = NULL; /* buffer for object references */ + hobj_ref_t *buf = NULL; const char* refname; unsigned u; @@ -174,74 +164,66 @@ int do_copy_refobjs(hid_t fidin, * read to memory *------------------------------------------------------------------------- */ - - if (nelmts) - { - buf=(void *) HDmalloc((unsigned)(nelmts*msize)); - if ( buf==NULL){ - printf( "cannot read into memory\n" ); + if(nelmts) { + buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + if(buf==NULL) { + printf("cannot read into memory\n" ); goto error; - } - if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + } /* end if */ + if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0) + refbuf = HDcalloc((unsigned)nelmts, msize); + if(refbuf == NULL){ + printf("cannot allocate memory\n" ); goto error; - refbuf=HDcalloc((unsigned)nelmts,msize); - if ( refbuf==NULL){ - printf( "cannot allocate memory\n" ); - goto error; - } - for ( u=0; u<nelmts; u++) - { + } /* end if */ + for(u = 0; u < nelmts; u++) { H5E_BEGIN_TRY { - if ((refobj_id = H5Rdereference(dset_in,H5R_OBJECT,&buf[u]))<0) + if((refobj_id = H5Rdereference(dset_in, H5R_OBJECT, &buf[u])) < 0) continue; } H5E_END_TRY; - /* get the name. a valid name could only occur in the - second traversal of the file */ - if ((refname=MapIdToName(refobj_id,travt))!=NULL) - { + + /* get the name. a valid name could only occur + * in the second traversal of the file + */ + if((refname = MapIdToName(refobj_id, travt)) != NULL) { /* create the reference, -1 parameter for objects */ - if (H5Rcreate(&refbuf[u],fidout,refname,H5R_OBJECT,-1)<0) + if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, -1) < 0) goto error; - if (options->verbose) + if(options->verbose) printf("object <%s> object reference created to <%s>\n", travt->objs[i].name, refname); - }/*refname*/ - close_obj(obj_type,refobj_id); - }/* u */ - }/*nelmts*/ + } /*refname*/ + H5Oclose(refobj_id); + } /* u */ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0) + if((dset_out = H5Dcreate(fidout, travt->objs[i].name, mtype_id, space_id, dcpl_id)) < 0) goto error; - if (nelmts) { - if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0) + if(nelmts) + if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) goto error; - } - if (buf) - free(buf); - if (refbuf) - free(refbuf); - - }/*H5T_STD_REF_OBJ*/ + if(buf) + HDfree(buf); + if(refbuf) + HDfree(refbuf); + } /*H5T_STD_REF_OBJ*/ /*------------------------------------------------------------------------- * dataset region references *------------------------------------------------------------------------- */ - else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) - { - H5G_obj_t1 obj_type; + else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { hid_t refobj_id; - hdset_reg_ref_t *refbuf=NULL; /* input buffer for region references */ - hdset_reg_ref_t *buf=NULL; /* output buffer */ + hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ + hdset_reg_ref_t *buf = NULL; /* output buffer */ const char* refname; unsigned u; @@ -249,91 +231,85 @@ int do_copy_refobjs(hid_t fidin, * read input to memory *------------------------------------------------------------------------- */ - if (nelmts) - { - buf=(void *) HDmalloc((unsigned)(nelmts*msize)); - if ( buf==NULL){ - printf( "cannot read into memory\n" ); - goto error; - } - if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + if(nelmts) { + buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + if(buf == NULL) { + printf("cannot read into memory\n"); goto error; - if ((obj_type = H5Rget_obj_type(dset_in,H5R_DATASET_REGION,buf))<0) + } /* end if */ + if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /*------------------------------------------------------------------------- * create output *------------------------------------------------------------------------- */ - - refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */ - if ( refbuf==NULL){ - printf( "cannot allocate memory\n" ); + refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + if(refbuf == NULL) { + printf("cannot allocate memory\n"); goto error; - } - for ( u=0; u<nelmts; u++) - { + } /* end if */ + + for(u = 0; u < nelmts; u++) { H5E_BEGIN_TRY { - if ((refobj_id = H5Rdereference(dset_in,H5R_DATASET_REGION,&buf[u]))<0) + if((refobj_id = H5Rdereference(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) continue; } H5E_END_TRY; - /* get the name. a valid name could only occur in the - second traversal of the file */ - if ((refname=MapIdToName(refobj_id,travt))!=NULL) - { + /* get the name. a valid name could only occur + * in the second traversal of the file + */ + if((refname = MapIdToName(refobj_id, travt)) != NULL) { hid_t region_id; /* region id of the referenced dataset */ - if ((region_id = H5Rget_region(dset_in,H5R_DATASET_REGION,&buf[u]))<0) + + if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) goto error; + /* create the reference, we need the space_id */ - if (H5Rcreate(&refbuf[u],fidout,refname,H5R_DATASET_REGION,region_id)<0) + if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0) goto error; - if (H5Sclose(region_id)<0) + if(H5Sclose(region_id) < 0) goto error; - if (options->verbose) + if(options->verbose) printf("object <%s> region reference created to <%s>\n", travt->objs[i].name, refname); - }/*refname*/ - close_obj(obj_type,refobj_id); - }/* u */ - }/*nelmts*/ + } /*refname*/ + H5Oclose(refobj_id); + } /* u */ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if ((dset_out=H5Dcreate(fidout,travt->objs[i].name,mtype_id,space_id,dcpl_id))<0) + if((dset_out = H5Dcreate(fidout, travt->objs[i].name, mtype_id, space_id, dcpl_id)) < 0) goto error; - if (nelmts) { - if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0) + if(nelmts) + if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) goto error; - } - if (buf) - free(buf); - if (refbuf) - free(refbuf); + if(buf) + HDfree(buf); + if(refbuf) + HDfree(refbuf); } /* H5T_STD_REF_DSETREG */ - - /*------------------------------------------------------------------------- * not references, open previously created object in 1st traversal *------------------------------------------------------------------------- */ - else - { - if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0) + else { + if((dset_out = H5Dopen(fidout,travt->objs[i].name)) < 0) goto error; - } + } /* end else */ - assert(dset_out!=FAIL); + assert(dset_out != FAIL); /*------------------------------------------------------------------------- * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if (copy_refs_attr(dset_in,dset_out,options,travt,fidout)<0) + if(copy_refs_attr(dset_in, dset_out, options, travt, fidout) < 0) goto error; /*------------------------------------------------------------------------- @@ -344,58 +320,49 @@ int do_copy_refobjs(hid_t fidin, for(j = 0; j < travt->objs[i].nlinks; j++) H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); - if(H5Dclose(dset_out)<0) + if(H5Dclose(dset_out) < 0) goto error; - - }/*can_read*/ + } /*can_read*/ /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - - if (H5Tclose(ftype_id)<0) + if(H5Tclose(ftype_id) < 0) goto error; - if (H5Tclose(mtype_id)<0) + if(H5Tclose(mtype_id) < 0) goto error; - if (H5Pclose(dcpl_id)<0) + if(H5Pclose(dcpl_id) < 0) goto error; - if (H5Sclose(space_id)<0) + if(H5Sclose(space_id) < 0) goto error; - if (H5Dclose(dset_in)<0) + if(H5Dclose(dset_in) < 0) goto error; - break; /*------------------------------------------------------------------------- - * H5G_TYPE + * H5TRAV_TYPE_NAMED_DATATYPE *------------------------------------------------------------------------- */ - case H5G_TYPE: - - if ((type_in = H5Topen (fidin,travt->objs[i].name))<0) + case H5TRAV_TYPE_NAMED_DATATYPE: + if((type_in = H5Topen(fidin, travt->objs[i].name)) < 0) goto error; - - if (H5Tclose(type_in)<0) + if(H5Tclose(type_in) < 0) goto error; - break; /*------------------------------------------------------------------------- * H5G_LINK *------------------------------------------------------------------------- */ - case H5G_LINK: - /*nothing to do */ break; default: - break; - } - } + } /* end switch */ + } /* end for */ return 0; @@ -411,6 +378,7 @@ error: H5Tclose(mtype_id); H5Tclose(type_in); } H5E_END_TRY; + return -1; } @@ -440,285 +408,246 @@ static int copy_refs_attr(hid_t loc_in, hid_t fidout /* for saving references */ ) { - hid_t attr_id=-1; /* attr ID */ - hid_t attr_out=-1; /* attr ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ - size_t msize; /* memory size of type */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - char name[255]; - int n, j; - unsigned u; - - if ((n = H5Aget_num_attrs(loc_in))<0) - goto error; - - for ( u = 0; u < (unsigned)n; u++) - { - -/*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - /* open attribute */ - if ((attr_id = H5Aopen_idx(loc_in, u))<0) - goto error; - - /* get name */ - if (H5Aget_name( attr_id, 255, name )<0) - goto error; - - /* get the file datatype */ - if ((ftype_id = H5Aget_type( attr_id )) < 0 ) - goto error; - - /* get the dataspace handle */ - if ((space_id = H5Aget_space( attr_id )) < 0 ) - goto error; - - /* get dimensions */ - if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) - goto error; - - - /*------------------------------------------------------------------------- - * elements - *------------------------------------------------------------------------- - */ - nelmts=1; - for (j=0; j<rank; j++) - nelmts*=dims[j]; + hid_t attr_id = -1; /* attr ID */ + hid_t attr_out = -1; /* attr ID */ + hid_t space_id = -1; /* space ID */ + hid_t ftype_id = -1; /* file data type ID */ + hid_t mtype_id = -1; /* memory data type ID */ + size_t msize; /* memory size of type */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + char name[255]; + int n, j; + unsigned u; + + if((n = H5Aget_num_attrs(loc_in)) < 0) + goto error; - if ((mtype_id=h5tools_get_native_type(ftype_id))<0) - goto error; + for(u = 0; u < (unsigned)n; u++) { + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + /* open attribute */ + if((attr_id = H5Aopen_idx(loc_in, u)) < 0) + goto error; + + /* get name */ + if(H5Aget_name(attr_id, 255, name) < 0) + goto error; + + /* get the file datatype */ + if((ftype_id = H5Aget_type(attr_id)) < 0) + goto error; + + /* get the dataspace handle */ + if((space_id = H5Aget_space(attr_id)) < 0) + goto error; + + /* get dimensions */ + if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) + goto error; + + + /*------------------------------------------------------------------------- + * elements + *------------------------------------------------------------------------- + */ + nelmts = 1; + for(j = 0; j < rank; j++) + nelmts *= dims[j]; + + if((mtype_id = h5tools_get_native_type(ftype_id)) < 0) + goto error; + + if((msize = H5Tget_size(mtype_id)) == 0) + goto error; + + + /*------------------------------------------------------------------------- + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + *------------------------------------------------------------------------- + */ + if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { + hid_t refobj_id; + hobj_ref_t *refbuf = NULL; + unsigned k; + const char* refname; + hobj_ref_t *buf = NULL; - if ((msize=H5Tget_size(mtype_id))==0) - goto error; + /*------------------------------------------------------------------------- + * read input to memory + *------------------------------------------------------------------------- + */ - -/*------------------------------------------------------------------------- - * object references are a special case - * we cannot just copy the buffers, but instead we recreate the reference - *------------------------------------------------------------------------- - */ - if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) - { - H5G_obj_t1 obj_type; - hid_t refobj_id; - hobj_ref_t *refbuf=NULL; - unsigned k; - const char* refname; - hobj_ref_t *buf=NULL; - - /*------------------------------------------------------------------------- - * read input to memory - *------------------------------------------------------------------------- - */ + if (nelmts) { + buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + if(buf == NULL) { + printf("cannot read into memory\n"); + goto error; + } /* end if */ + if(H5Aread(attr_id, mtype_id, buf) < 0) + goto error; - if (nelmts) - { - buf=(void *) HDmalloc((unsigned)(nelmts*msize)); - if ( buf==NULL){ - printf( "cannot read into memory\n" ); - goto error; - } - if (H5Aread(attr_id,mtype_id,buf)<0) - goto error; - - if ((obj_type = H5Rget_obj_type(attr_id,H5R_OBJECT,buf))<0) - goto error; - refbuf=HDcalloc((unsigned)nelmts,msize); - if ( refbuf==NULL){ - printf( "cannot allocate memory\n" ); - goto error; - } - for ( k=0; k<nelmts; k++) - { - H5E_BEGIN_TRY { - if ((refobj_id = H5Rdereference(attr_id,H5R_OBJECT,&buf[k]))<0) - goto error; - } H5E_END_TRY; - /* get the name. a valid name could only occur in the - second traversal of the file */ - if ((refname=MapIdToName(refobj_id,travt))!=NULL) - { - /* create the reference */ - if (H5Rcreate(&refbuf[k],fidout,refname,H5R_OBJECT,-1)<0) - goto error; - if (options->verbose) - printf("object <%s> reference created to <%s>\n",name,refname); - } - close_obj(obj_type,refobj_id); - }/* k */ - }/*nelmts*/ + refbuf = HDcalloc((unsigned)nelmts, msize); + if(refbuf == NULL) { + printf( "cannot allocate memory\n" ); + goto error; + } /* end if */ - /*------------------------------------------------------------------------- - * copy - *------------------------------------------------------------------------- - */ + for(k = 0; k < nelmts; k++) { + H5E_BEGIN_TRY { + if((refobj_id = H5Rdereference(attr_id, H5R_OBJECT, &buf[k])) < 0) + goto error; + } H5E_END_TRY; + + /* get the name. a valid name could only occur in the + * second traversal of the file + */ + if((refname = MapIdToName(refobj_id, travt)) != NULL) { + /* create the reference */ + if(H5Rcreate(&refbuf[k], fidout, refname, H5R_OBJECT, -1) < 0) + goto error; + if(options->verbose) + printf("object <%s> reference created to <%s>\n", name, refname); + } + H5Oclose(refobj_id); + } /* k */ + } /*nelmts*/ - if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) - goto error; - if (nelmts) - { - if(H5Awrite(attr_out,mtype_id,refbuf)<0) - goto error; - } - if (H5Aclose(attr_out)<0) - goto error; + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + if((attr_out = H5Acreate(loc_out, name, ftype_id, space_id, H5P_DEFAULT)) < 0) + goto error; + if(nelmts) + if(H5Awrite(attr_out, mtype_id, refbuf) < 0) + goto error; + if(H5Aclose(attr_out) < 0) + goto error; + + if(refbuf) + HDfree(refbuf); + if(buf) + HDfree(buf); + }/*H5T_STD_REF_OBJ*/ + + /*------------------------------------------------------------------------- + * dataset region references + *------------------------------------------------------------------------- + */ + else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { + hid_t refobj_id; + hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ + hdset_reg_ref_t *buf = NULL; /* output buffer */ + const char* refname; + unsigned k; - if (refbuf) - free(refbuf); - if (buf) - free(buf); + /*------------------------------------------------------------------------- + * read input to memory + *------------------------------------------------------------------------- + */ + if(nelmts) { + buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + if(buf == NULL) { + printf( "cannot read into memory\n" ); + goto error; + } /* end if */ + if(H5Aread(attr_id, mtype_id, buf) < 0) + goto error; - }/*H5T_STD_REF_OBJ*/ + /*------------------------------------------------------------------------- + * create output + *------------------------------------------------------------------------- + */ + refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + if(refbuf == NULL) { + printf( "cannot allocate memory\n" ); + goto error; + } /* end if */ -/*------------------------------------------------------------------------- - * dataset region references - *------------------------------------------------------------------------- - */ - else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) - { - H5G_obj_t1 obj_type; - hid_t refobj_id; - hdset_reg_ref_t *refbuf=NULL; /* input buffer for region references */ - hdset_reg_ref_t *buf=NULL; /* output buffer */ - const char* refname; - unsigned k; - - /*------------------------------------------------------------------------- - * read input to memory - *------------------------------------------------------------------------- - */ + for(k = 0; k < nelmts; k++) { + H5E_BEGIN_TRY { + if((refobj_id = H5Rdereference(attr_id, H5R_DATASET_REGION, &buf[k])) < 0) + continue; + } H5E_END_TRY; - if (nelmts) - { - buf=(void *) HDmalloc((unsigned)(nelmts*msize)); - if ( buf==NULL){ - printf( "cannot read into memory\n" ); - goto error; - } - if (H5Aread(attr_id,mtype_id,buf)<0) - goto error; - if ((obj_type = H5Rget_obj_type(attr_id,H5R_DATASET_REGION,buf))<0) - goto error; + /* get the name. a valid name could only occur in the + * second traversal of the file + */ + if((refname = MapIdToName(refobj_id, travt)) != NULL) { + hid_t region_id; /* region id of the referenced dataset */ - /*------------------------------------------------------------------------- - * create output - *------------------------------------------------------------------------- - */ - - refbuf=HDcalloc(sizeof(hdset_reg_ref_t),(size_t)nelmts); /*init to zero */ - if ( refbuf==NULL){ - printf( "cannot allocate memory\n" ); - goto error; - } - for ( k=0; k<nelmts; k++) - { - H5E_BEGIN_TRY { - if ((refobj_id = H5Rdereference(attr_id,H5R_DATASET_REGION,&buf[k]))<0) - continue; - } H5E_END_TRY; - /* get the name. a valid name could only occur in the - second traversal of the file */ - if ((refname=MapIdToName(refobj_id,travt))!=NULL) - { - hid_t region_id; /* region id of the referenced dataset */ - if ((region_id = H5Rget_region(attr_id,H5R_DATASET_REGION,&buf[k]))<0) - goto error; - /* create the reference, we need the space_id */ - if (H5Rcreate(&refbuf[k],fidout,refname,H5R_DATASET_REGION,region_id)<0) - goto error; - if (H5Sclose(region_id)<0) - goto error; - if (options->verbose) - printf("object <%s> region reference created to <%s>\n",name,refname); - } - close_obj(obj_type,refobj_id); - }/* k */ - }/*nelmts */ + if((region_id = H5Rget_region(attr_id, H5R_DATASET_REGION, &buf[k])) < 0) + goto error; - /*------------------------------------------------------------------------- - * copy - *------------------------------------------------------------------------- - */ - - if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) - goto error; - if (nelmts) { - if(H5Awrite(attr_out,mtype_id,refbuf)<0) - goto error; - } - if (H5Aclose(attr_out)<0) - goto error; - if (refbuf) - free(refbuf); - if (buf) - free(buf); - } /* H5T_STD_REF_DSETREG */ + /* create the reference, we need the space_id */ + if(H5Rcreate(&refbuf[k], fidout, refname, H5R_DATASET_REGION, region_id) < 0) + goto error; + if(H5Sclose(region_id) < 0) + goto error; + if(options->verbose) + printf("object <%s> region reference created to <%s>\n", name, refname); + } /* end if */ + H5Oclose(refobj_id); + } /* k */ + } /*nelmts */ -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + if((attr_out = H5Acreate(loc_out, name, ftype_id, space_id, H5P_DEFAULT)) < 0) + goto error; + if(nelmts) + if(H5Awrite(attr_out, mtype_id, refbuf) < 0) + goto error; - if (H5Tclose(ftype_id)<0) goto error; - if (H5Tclose(mtype_id)<0) goto error; - if (H5Sclose(space_id)<0) goto error; - if (H5Aclose(attr_id)<0) goto error; - } /* u */ + if(H5Aclose(attr_out) < 0) + goto error; + + if(refbuf) + HDfree(refbuf); + if(buf) + HDfree(buf); + } /* H5T_STD_REF_DSETREG */ + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if(H5Tclose(ftype_id) < 0) + goto error; + if(H5Tclose(mtype_id) < 0) + goto error; + if(H5Sclose(space_id) < 0) + goto error; + if(H5Aclose(attr_id) < 0) + goto error; + } /* u */ - return 0; + return 0; error: - H5E_BEGIN_TRY { - H5Tclose(ftype_id); - H5Tclose(mtype_id); - H5Sclose(space_id); - H5Aclose(attr_id); - H5Aclose(attr_out); - } H5E_END_TRY; - return -1; -} - -/*------------------------------------------------------------------------- - * Function: close_obj - * - * Purpose: Auxiliary function to close an object - * - *------------------------------------------------------------------------- - */ + H5E_BEGIN_TRY { + H5Tclose(ftype_id); + H5Tclose(mtype_id); + H5Sclose(space_id); + H5Aclose(attr_id); + H5Aclose(attr_out); + } H5E_END_TRY; -static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id) -{ - H5E_BEGIN_TRY - { - switch (obj_type) - { - case H5G_GROUP: - H5Gclose(obj_id); - break; - case H5G_DATASET: - H5Dclose(obj_id); - break; - case H5G_TYPE: - H5Tclose(obj_id); - break; - default: - break; - } - } H5E_END_TRY; + return -1; } /*------------------------------------------------------------------------- * Function: MapIdToName * - * Purpose: map an object ID to a name + * Purpose: map a ID from a reference to a dataset name * *------------------------------------------------------------------------- */ @@ -726,57 +655,22 @@ static void close_obj(H5G_obj_t1 obj_type, hid_t obj_id) static const char* MapIdToName(hid_t refobj_id, trav_table_t *travt) { - hid_t id; - hid_t fid; - H5G_stat_t refstat; /* Stat for the refobj id */ - H5G_stat_t objstat; /* Stat for objects in the file */ - unsigned int i; - - /* obtain information to identify the referenced object uniquely */ - if(H5Gget_objinfo(refobj_id, ".", 0, &refstat) <0) - return NULL; - - /* obtains the file ID given an object ID. This ID must be closed */ - if ((fid = H5Iget_file_id(refobj_id))<0) - { - return NULL; - } - - /* linear search */ - for ( i=0; i<travt->nobjs; i++) - { - switch ( travt->objs[i].type ) - { - default: - break; - - /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - - case H5G_DATASET: - - if ((id = H5Dopen(fid,travt->objs[i].name))<0) - return NULL; - if(H5Gget_objinfo(id, ".", 0, &objstat) <0) - return NULL; - if (H5Dclose(id)<0) + unsigned int i; + + /* linear search */ + for(i = 0; i < travt->nobjs; i++) { + if(travt->objs[i].type == H5O_TYPE_DATASET) { + H5O_info_t ref_oinfo; /* Stat for the refobj id */ + + /* obtain information to identify the referenced object uniquely */ + if(H5Oget_info(refobj_id, ".", &ref_oinfo, H5P_DEFAULT) < 0) + return NULL; + + if(ref_oinfo.addr == travt->objs[i].objno) + return(travt->objs[i].name); + } /* end if */ + } /* i */ + return NULL; - if (refstat.fileno[0]==objstat.fileno[0] && refstat.fileno[1]==objstat.fileno[1] - && refstat.objno[0]==objstat.objno[0] && refstat.objno[1]==objstat.objno[1]) - { - H5Fclose(fid); - return travt->objs[i].name; - } - break; - } /* switch */ - } /* i */ - - if (H5Fclose(fid)<0) - return NULL; - - return NULL; } - diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 2d7cc7d..e0174b0 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -192,15 +192,13 @@ hsize_t h5diff(const char *fname1, char filenames[2][1024]; hsize_t nfound = 0; - memset(filenames, 0, 1024*2); + HDmemset(filenames, 0, 1024 * 2); - if(options->m_quiet && - (options->m_verbose || options->m_report)) - { + if(options->m_quiet && (options->m_verbose || options->m_report)) { printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); options->err_stat=1; return 0; - } + } /* end if */ /*------------------------------------------------------------------------- * open the files first; if they are not valid, no point in continuing @@ -208,42 +206,32 @@ hsize_t h5diff(const char *fname1, */ /* disable error reporting */ - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { /* Open the files */ - if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff: <%s>: unable to open file\n", fname1); + if((file1_id = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + printf("h5diff: <%s>: unable to open file\n", fname1); options->err_stat = 1; #ifdef H5_HAVE_PARALLEL if(g_Parallel) - { /* Let tasks know that they won't be needed */ phdiff_dismiss_workers(); - } #endif - goto out; - } - if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff: <%s>: unable to open file\n", fname2); + } /* end if */ + if((file2_id = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + printf("h5diff: <%s>: unable to open file\n", fname2); options->err_stat = 1; #ifdef H5_HAVE_PARALLEL if(g_Parallel) - { /* Let tasks know that they won't be needed */ phdiff_dismiss_workers(); - } #endif - goto out; - } + } /* end if */ /* enable error reporting */ - } - H5E_END_TRY; + } H5E_END_TRY; /*------------------------------------------------------------------------- * Initialize the info structs @@ -256,84 +244,69 @@ hsize_t h5diff(const char *fname1, * get the list of objects in the files *------------------------------------------------------------------------- */ - if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0) - { + if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0) { printf("Error: Could not get file contents\n"); options->err_stat = 1; #ifdef H5_HAVE_PARALLEL if(g_Parallel) - { /* Let tasks know that they won't be needed */ phdiff_dismiss_workers(); - } #endif goto out; - } + } /* end if */ /*------------------------------------------------------------------------- * object name was supplied *------------------------------------------------------------------------- */ - - if (objname1) - { - + if(objname1) { #ifdef H5_HAVE_PARALLEL if(g_Parallel) - { /* Let tasks know that they won't be needed */ phdiff_dismiss_workers(); - } #endif - assert (objname2); + assert(objname2); options->cmn_objs = 1; /* eliminate warning */ - nfound = diff_compare (file1_id, fname1, objname1, info1, - file2_id, fname2, objname2, info2, - options); - } + nfound = diff_compare(file1_id, fname1, objname1, info1, + file2_id, fname2, objname2, info2, + options); + } /* end if */ /*------------------------------------------------------------------------- * compare all *------------------------------------------------------------------------- */ - else - { - + else { #ifdef H5_HAVE_PARALLEL - if(g_Parallel) - { + if(g_Parallel) { int i; - if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) - { + if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) { fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n"); MPI_Abort(MPI_COMM_WORLD, 0); - } + } /* end if */ HDstrcpy(filenames[0], fname1); HDstrcpy(filenames[1], fname2); /* Alert the worker tasks that there's going to be work. */ - for(i = 1; i < g_nTasks; i++) - MPI_Send(filenames, 1024 * 2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); - } + MPI_Send(filenames, (1024 * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); + } /* end if */ #endif nfound = diff_match(file1_id, info1, file2_id, info2, options); - } + } /* end else */ trav_info_free(info1); trav_info_free(info2); out: /* close */ - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { H5Fclose(file1_id); H5Fclose(file2_id); - } - H5E_END_TRY; + } H5E_END_TRY; return nfound; } @@ -358,411 +331,360 @@ out: * *------------------------------------------------------------------------- */ -hsize_t diff_match (hid_t file1_id, +hsize_t diff_match(hid_t file1_id, trav_info_t * info1, hid_t file2_id, trav_info_t * info2, diff_opt_t * options) { - int more_names_exist = (info1->nused > 0 && info2->nused > 0) ? 1 : 0; - trav_table_t *table = NULL; - int cmp; - size_t curr1 = 0; - size_t curr2 = 0; - unsigned infile[2]; - char c1, c2; - hsize_t nfound = 0; - unsigned i; - -/*------------------------------------------------------------------------- - * build the list - *------------------------------------------------------------------------- - */ - trav_table_init (&table); - - while (more_names_exist) - { - /* criteria is string compare */ - cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path); - if (cmp == 0) - { - infile[0] = 1; - infile[1] = 1; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - - curr1++; - curr2++; - } - else if (cmp < 0) - { - infile[0] = 1; - infile[1] = 0; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - curr1++; - } - else - { - infile[0] = 0; - infile[1] = 1; - trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type, - table); - curr2++; - } - - more_names_exist = (curr1 < info1->nused && curr2 < info2->nused) ? 1 : 0; - - } /* end while */ - - /* list1 did not end */ - if (curr1 < info1->nused) - { - while (curr1 < info1->nused) - { - infile[0] = 1; - infile[1] = 0; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - curr1++; - } - } + trav_table_t *table = NULL; + size_t curr1, curr2; + unsigned infile[2]; + hsize_t nfound = 0; + unsigned i; - /* list2 did not end */ - if (curr2 < info2->nused) - { - while (curr2 < info2->nused) - { - infile[0] = 0; - infile[1] = 1; - trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type, - table); - curr2++; - } - } + /*------------------------------------------------------------------------- + * build the list + *------------------------------------------------------------------------- + */ + trav_table_init(&table); + + curr1 = 0; + curr2 = 0; + while(curr1 < info1->nused && curr2 < info2->nused) { + /* criteria is string compare */ + int cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path); + + if(cmp == 0) { + infile[0] = 1; + infile[1] = 1; + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + + curr1++; + curr2++; + } /* end if */ + else if(cmp < 0) { + infile[0] = 1; + infile[1] = 0; + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + curr1++; + } /* end else-if */ + else { + infile[0] = 0; + infile[1] = 1; + trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); + curr2++; + } /* end else */ + } /* end while */ + + /* list1 did not end */ + infile[0] = 1; + infile[1] = 0; + while(curr1 < info1->nused) { + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + curr1++; + } /* end while */ + + /* list2 did not end */ + infile[0] = 0; + infile[1] = 1; + while(curr2 < info2->nused) { + trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); + curr2++; + } /* end while */ -/*------------------------------------------------------------------------- - * print the list - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * print the list + *------------------------------------------------------------------------- + */ + if(options->m_verbose) { + printf("\n"); + printf("file1 file2\n"); + printf("---------------------------------------\n"); + for(i = 0; i < table->nobjs; i++) { + char c1, c2; - if (options->m_verbose) - { - printf ("\n"); - printf ("file1 file2\n"); - printf ("---------------------------------------\n"); - for (i = 0; i < table->nobjs; i++) - { - c1 = (table->objs[i].flags[0]) ? 'x' : ' '; - c2 = (table->objs[i].flags[1]) ? 'x' : ' '; - printf ("%5c %6c %-15s\n", c1, c2, table->objs[i].name); - } - printf ("\n"); - } + c1 = (table->objs[i].flags[0]) ? 'x' : ' '; + c2 = (table->objs[i].flags[1]) ? 'x' : ' '; + printf("%5c %6c %-15s\n", c1, c2, table->objs[i].name); + } /* end for */ + printf ("\n"); + } /* end if */ -/*------------------------------------------------------------------------- - * do the diff for common objects - *------------------------------------------------------------------------- - */ - { + /*------------------------------------------------------------------------- + * do the diff for common objects + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_PARALLEL - char* workerTasks = malloc((g_nTasks-1) * sizeof(char)); - int n; - int busyTasks=0; - struct diffs_found nFoundbyWorker; - struct diff_args args; - int havePrintToken = 1; - MPI_Status Status; - - /*set all tasks as free */ - memset(workerTasks, 1, g_nTasks-1); +{ + char *workerTasks = HDmalloc((g_nTasks - 1) * sizeof(char)); + int n; + int busyTasks = 0; + struct diffs_found nFoundbyWorker; + struct diff_args args; + int havePrintToken = 1; + MPI_Status Status; + + /*set all tasks as free */ + HDmemset(workerTasks, 1, (g_nTasks - 1)); #endif - for (i = 0; i < table->nobjs; i++) - { - if (table->objs[i].flags[0] && table->objs[i].flags[1]) - { + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].flags[0] && table->objs[i].flags[1]) { + options->cmn_objs = 1; + if(!g_Parallel) { + nfound += diff(file1_id, + table->objs[i].name, + file2_id, + table->objs[i].name, options, table->objs[i].type); + } /* end if */ #ifdef H5_HAVE_PARALLEL - int workerFound = 0; + else { + int workerFound = 0; + + h5diffdebug("beginning of big else block\n"); + /* We're in parallel mode */ + /* Since the data type of diff value is hsize_t which can + * be arbitary large such that there is no MPI type that + * matches it, the value is passed between processes as + * an array of bytes in order to be portable. But this + * may not work in non-homogeneous MPI environments. + */ + + /*Set up args to pass to worker task. */ + if(strlen(table->objs[i].name) > 255) { + printf("The parallel diff only supports object names up to 255 characters\n"); + MPI_Abort(MPI_COMM_WORLD, 0); + } /* end if */ + + HDstrcpy(args.name, table->objs[i].name); + args.options = *options; + args.type= table->objs[i].type; + + h5diffdebug2("busyTasks=%d\n", busyTasks); + /* if there are any outstanding print requests, let's handle one. */ + if(busyTasks > 0) { + int incomingMessage; + + /* check if any tasks freed up, and didn't need to print. */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); + + /* first block*/ + if(incomingMessage) { + workerTasks[Status.MPI_SOURCE - 1] = 1; + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + + /* check to see if the print token was returned. */ + if(!havePrintToken) { + /* If we don't have the token, someone is probably sending us output */ + print_incoming_data(); + + /* check incoming queue for token */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + /* incoming token implies free task. */ + if(incomingMessage) { + workerTasks[Status.MPI_SOURCE - 1] = 1; + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end if */ + } /* end if */ + + /* check to see if anyone needs the print token. */ + if(havePrintToken) { + /* check incoming queue for print token requests */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); + if(incomingMessage) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + havePrintToken = 0; + } /* end if */ + } /* end if */ + } /* end if */ + + /* check array of tasks to see which ones are free. + * Manager task never does work, so freeTasks[0] is really + * worker task 0. */ + for(n = 1; (n < g_nTasks) && !workerFound; n++) { + if(workerTasks[n-1]) { + /* send file id's and names to first free worker */ + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); + + /* increment counter for total number of prints. */ + busyTasks++; + + /* mark worker as busy */ + workerTasks[n - 1] = 0; + workerFound = 1; + } /* end if */ + } /* end for */ + + h5diffdebug2("workerfound is %d \n", workerFound); + if(!workerFound) { + /* if they were all busy, we've got to wait for one free up + * before we can move on. If we don't have the token, some + * task is currently printing so we'll wait for that task to + * return it. + */ + + if(!havePrintToken) { + while(!havePrintToken) { + int incomingMessage; + + print_incoming_data(); + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + if(incomingMessage) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + havePrintToken = 1; + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + /* send this task the work unit. */ + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end if */ + } /* end while */ + } /* end if */ + /* if we do have the token, check for task to free up, or wait for a task to request it */ + else { + /* But first print all the data in our incoming queue */ + print_incoming_data(); + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if(Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + int incomingMessage; + + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end else-if */ + else { + printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); + MPI_Finalize(); + } /* end else */ + } /* end else */ + } /* end if */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - options->cmn_objs = 1; - if(!g_Parallel) - { - nfound += diff (file1_id, - table->objs[i].name, - file2_id, - table->objs[i].name, options, table->objs[i].type); - } -#ifdef H5_HAVE_PARALLEL - else - { - h5diffdebug("beginning of big else block\n"); - /* We're in parallel mode */ - /* Since the data type of diff value is hsize_t which can - * be arbitary large such that there is no MPI type that - * matches it, the value is passed between processes as - * an array of bytes in order to be portable. But this - * may not work in non-homogeneous MPI environments. - */ - - /*Set up args to pass to worker task. */ - if(strlen(table->objs[i].name) > 255) - { - printf("The parallel diff only supports object names up to 255 characters\n"); - MPI_Abort(MPI_COMM_WORLD, 0); - } - - strcpy(args.name, table->objs[i].name); - args.options = *options; - args.type= table->objs[i].type; - - h5diffdebug2("busyTasks=%d\n", busyTasks); - /* if there are any outstanding print requests, let's handle one. */ - if(busyTasks > 0) - { - int incomingMessage; - /* check if any tasks freed up, and didn't need to print. */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); - - /* first block*/ - if(incomingMessage) - { - workerTasks[Status.MPI_SOURCE-1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - - /* check to see if the print token was returned. */ - if(!havePrintToken) - { - /* If we don't have the token, someone is probably sending us output */ - print_incoming_data(); - - /* check incoming queue for token */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - /* incoming token implies free task. */ - if(incomingMessage) - { - workerTasks[Status.MPI_SOURCE-1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - } - - /* check to see if anyone needs the print token. */ - if(havePrintToken) - { - /* check incoming queue for print token requests */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - havePrintToken = 0; - } - } - } - - /* check array of tasks to see which ones are free. - * Manager task never does work, so freeTasks[0] is really - * worker task 0. */ + } /* end if */ + } /* end for */ + h5diffdebug("done with for loop\n"); - for(n=1; (n<g_nTasks) && !workerFound; n++) - { - if(workerTasks[n-1]) - { - /* send file id's and names to first free worker */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); - - /* increment counter for total number of prints. */ - busyTasks++; +#ifdef H5_HAVE_PARALLEL + if(g_Parallel) { + /* make sure all tasks are done */ + while(busyTasks > 0) { + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if(Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + if(havePrintToken) { + int incomingMessage; + + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ + else { + int source = Status.MPI_SOURCE; + int incomingMessage; + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + } /* end else */ + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) + { + char data[PRINT_DATA_MAX_SIZE + 1]; + HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); - /* mark worker as busy */ - workerTasks[n-1] = 0; - workerFound = 1; - } - - } + MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); + printf("%s", data); + } /* end else-if */ + else { + printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); + } /* end else */ + } /* end while */ - h5diffdebug2("workerfound is %d \n", workerFound); - if(!workerFound) - { - /* if they were all busy, we've got to wait for one free up before we can move on. - * if we don't have the token, some task is currently printing so we'll wait for that task to return it. */ + for(i = 1; i < g_nTasks; i++) + MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); - if(!havePrintToken) - { - while(!havePrintToken) { - int incomingMessage; + /* Print any final data waiting in our queue */ print_incoming_data(); - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - havePrintToken = 1; - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - /* send this task the work unit. */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - } - } - /* if we do have the token, check for task to free up, or wait for a task to request it */ - else - { - /* But first print all the data in our incoming queue */ - print_incoming_data(); - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { - int incomingMessage; - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - - - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - else - { - printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - MPI_Finalize(); - } - } - } - } -#endif /* H5_HAVE_PARALLEL */ - } - } - h5diffdebug("done with for loop\n"); - -#ifdef H5_HAVE_PARALLEL - if(g_Parallel) - { - while(busyTasks > 0) /* make sure all tasks are done */ - { - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - if(havePrintToken) - { - int incomingMessage; - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - else /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ - { - int source = Status.MPI_SOURCE; - int incomingMessage; - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - - - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - } - } - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) - { - char data[PRINT_DATA_MAX_SIZE+1]; - memset(data, 0, PRINT_DATA_MAX_SIZE+1); - - MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); - - printf("%s", data); - } - else - { - printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - } - } - - for(i=1; i<g_nTasks; i++) - MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); - - /* Print any final data waiting in our queue */ - print_incoming_data(); + } /* end if */ + h5diffdebug("done with if block\n"); - } - h5diffdebug("done with if block\n"); - - free(workerTasks); + free(workerTasks); +} #endif /* H5_HAVE_PARALLEL */ - } - /* free table */ - trav_table_free (table); + /* free table */ + trav_table_free(table); - return nfound; + return nfound; } @@ -856,173 +778,157 @@ hsize_t diff_compare (hid_t file1_id, *------------------------------------------------------------------------- */ -hsize_t diff (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) + h5trav_type_t type) { - hid_t type1_id=(-1); - hid_t type2_id=(-1); - hid_t grp1_id=(-1); - hid_t grp2_id=(-1); + 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: - + switch(type) { /*------------------------------------------------------------------------- - * verbose, always print name + * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- */ - if (options->m_verbose) - { - if (print_objname(options,(hsize_t)1)) - do_print_objname ("dataset", path1, path2); - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - print_found(nfound); + case H5TRAV_TYPE_DATASET: + /*------------------------------------------------------------------------- + * verbose, always print name + *------------------------------------------------------------------------- + */ + if(options->m_verbose) { + if(print_objname(options, (hsize_t)1)) + do_print_objname("dataset", path1, path2); + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + print_found(nfound); + } /* end if */ + /*------------------------------------------------------------------------- + * non verbose, check first if we have differences by enabling quiet mode + * so that printing is off, and compare again if differences found, + * disabling quite mode + *------------------------------------------------------------------------- + */ + else { + if(options->m_quiet == 0) { + /* shut up temporarily */ + options->m_quiet = 1; + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + + /* print again */ + options->m_quiet = 0; + if(nfound) { + if(print_objname(options,nfound)) + do_print_objname("dataset", path1, path2); + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + print_found(nfound); + } /* end if */ + } /* end if */ + /* in quiet mode, just count differences */ + else + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + } /* end else */ + break; - } /*------------------------------------------------------------------------- - * non verbose, check first if we have differences by enabling quiet mode - * so that printing is off, and compare again if differences found, - * disabling quite mode + * H5TRAV_TYPE_NAMED_DATATYPE *------------------------------------------------------------------------- */ - else - { - if (options->m_quiet==0) - { - /* shut up temporarily */ - options->m_quiet=1; - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - /* print again */ - options->m_quiet=0; - if (nfound) - { - if (print_objname(options,nfound)) - do_print_objname ("dataset", path1, path2); - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - print_found(nfound); - } - } - /* in quiet mode, just count differences */ - else - { - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - } - } - - break; - - /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - case H5G_TYPE: - - if ((type1_id = H5Topen(file1_id, path1))<0) - goto out; - if ((type2_id = H5Topen(file2_id, path2))<0) - goto out; - - if ((ret = H5Tequal(type1_id,type2_id))<0) - goto out; - - /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ - nfound = (ret>0) ? 0 : 1; - - if (print_objname(options,nfound)) - do_print_objname ("datatype", path1, path2); - - /* always print the number of differences found in verbose mode */ - if (options->m_verbose) - print_found(nfound); - - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if (path1) - nfound += diff_attr(type1_id,type2_id,path1,path2,options); - - if ( H5Tclose(type1_id)<0) - goto out; - if ( H5Tclose(type2_id)<0) - goto out; - - break; - - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - case H5G_GROUP: + case H5TRAV_TYPE_NAMED_DATATYPE: + if((type1_id = H5Topen(file1_id, path1)) < 0) + goto out; + if((type2_id = H5Topen(file2_id, path2)) < 0) + goto out; + + if((ret = H5Tequal(type1_id, type2_id)) < 0) + goto out; + + /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ + nfound = (ret > 0) ? 0 : 1; + + if(print_objname(options,nfound)) + do_print_objname("datatype", path1, path2); - ret = HDstrcmp(path1, path2); - - /* if "path1" != "path2" then the groups are "different" */ - nfound = (ret != 0) ? 1 : 0; + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); + + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if(path1) + nfound += diff_attr(type1_id, type2_id, path1, path2, options); + + if(H5Tclose(type1_id) < 0) + goto out; + if(H5Tclose(type2_id) < 0) + goto out; + break; + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: + ret = HDstrcmp(path1, path2); - if(print_objname(options, nfound)) - do_print_objname("group", path1, path2); + /* if "path1" != "path2" then the groups are "different" */ + nfound = (ret != 0) ? 1 : 0; + + if(print_objname(options, nfound)) + do_print_objname("group", path1, path2); - /* always print the number of differences found in verbose mode */ - if(options->m_verbose) - print_found(nfound); - - if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) - goto out; - if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) - goto out; + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); + + if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) + goto out; + if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) + goto out; - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if(path1) - nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); - - if(H5Gclose(grp1_id) < 0) - goto out; - if(H5Gclose(grp2_id) < 0) - goto out; - - break; - - - /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ - case H5G_LINK: - { - char *buf1 = NULL; - char *buf2 = NULL; + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if(path1) + nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); + + if(H5Gclose(grp1_id) < 0) + goto out; + if(H5Gclose(grp2_id) < 0) + goto out; + break; + - if(H5Gget_objinfo(file1_id, path1, FALSE, &sb1) < 0) + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_LINK + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_LINK: + { + H5L_info_t li1, li2; + char *buf1, *buf2; + + if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; - if(H5Gget_objinfo(file1_id, path1, FALSE, &sb2) < 0) + if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0) goto out; - buf1 = HDmalloc(sb1.linklen); - buf2 = HDmalloc(sb2.linklen); + buf1 = HDmalloc(li1.u.val_size); + buf2 = HDmalloc(li2.u.val_size); - if(H5Lget_val(file1_id, path1, buf1, sb1.linklen, H5P_DEFAULT) < 0) + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) goto out; - if(H5Lget_val(file2_id, path2, buf2, sb2.linklen, H5P_DEFAULT) < 0) + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) goto out; ret = HDstrcmp(buf1, buf2); @@ -1039,19 +945,16 @@ hsize_t diff (hid_t file1_id, HDfree(buf1); HDfree(buf2); - } - break; - - /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ - case H5G_UDLINK: - { - char *buf1 = NULL; - char *buf2 = NULL; - H5L_info_t li1; - H5L_info_t li2; + } + break; + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_UDLINK + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_UDLINK: + { + H5L_info_t li1, li2; if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; @@ -1059,36 +962,36 @@ hsize_t diff (hid_t file1_id, goto out; /* Only external links will have a query function registered */ - if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL) - { - buf1 = HDmalloc (li1.u.val_size); - buf2 = HDmalloc (li2.u.val_size); + if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL) { + char *buf1, *buf2; + + buf1 = HDmalloc(li1.u.val_size); + buf2 = HDmalloc(li2.u.val_size); - if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + } /* end if */ + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } + } /* end if */ /* If the buffers are the same size, compare them */ - if(li1.u.val_size == li2.u.val_size) - { - if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + if(li1.u.val_size == li2.u.val_size) { + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + } /* end if */ + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - ret = HDmemcmp (buf1, buf2, li1.u.val_size); + } /* end if */ + ret = HDmemcmp(buf1, buf2, li1.u.val_size); } else ret = 1; @@ -1096,18 +999,20 @@ hsize_t diff (hid_t file1_id, /* if "buf1" != "buf2" then the links are "different" */ nfound = (ret != 0) ? 1 : 0; - if (print_objname (options, nfound)) - do_print_objname ("external link", path1, path2); - } - else - { - /* If one or both of these links isn't an external link, we can only - * compare information from H5Lget_info since we don't have a query - * function registered for them. - * - * If the link classes or the buffer length are not the - * same, the links are "different" - */ + if(print_objname(options, nfound)) + do_print_objname("external link", path1, path2); + + HDfree(buf1); + HDfree(buf2); + } /* end if */ + else { + /* If one or both of these links isn't an external link, we can only + * compare information from H5Lget_info since we don't have a query + * function registered for them. + * + * If the link classes or the buffer length are not the + * same, the links are "different" + */ if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size)) nfound = 1; else @@ -1115,47 +1020,37 @@ hsize_t diff (hid_t file1_id, if (print_objname (options, nfound)) do_print_objname ("user defined link", path1, path2); - } + } /* end else */ /* always print the number of differences found in verbose mode */ - if (options->m_verbose) + if(options->m_verbose) print_found(nfound); + } + break; - HDfree (buf1); - HDfree (buf2); - } - break; - - default: - if (options->m_verbose) - { - printf("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(type) ); - } - options->not_cmp=1; - break; - } - + default: + if(options->m_verbose) + printf("Comparison not supported: <%s> and <%s> are of type %s\n", + path1, path2, get_type(type) ); + options->not_cmp = 1; + break; + } - return nfound; + return nfound; out: + options->err_stat = 1; - options->err_stat=1; - - /* 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; -} + /* 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; +} diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index e22502f..60e96b2 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -25,18 +25,18 @@ */ typedef struct { - int m_quiet; /* quiet mide: no output at all */ - int m_report; /* report mode: print the data */ - int m_verbose; /* verbose mode: print the data, list of objcets, warnings */ - int d; /* delta, absolute value to compare */ - double delta; /* delta value */ - int p; /* relative error to compare*/ - double percent; /* relative error value */ - int n; /* count, compare up to count */ - 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 m_quiet; /* quiet mide: no output at all */ + int m_report; /* report mode: print the data */ + int m_verbose; /* verbose mode: print the data, list of objcets, warnings */ + int d; /* delta, absolute value to compare */ + double delta; /* delta value */ + int p; /* relative error to compare*/ + double percent; /* relative error value */ + int n; /* count, compare up to count */ + 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 */ } diff_opt_t; @@ -89,7 +89,7 @@ hsize_t diff( hid_t file1_id, hid_t file2_id, const char *path2, diff_opt_t *options, - H5G_obj_t type ); + h5trav_type_t type ); hsize_t diff_compare( hid_t file1_id, const char *file1_name, @@ -177,161 +177,160 @@ hsize_t diff_datum(void *_mem1, hsize_t diff_float(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + 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, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph); - - + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph); #endif /* H5DIFF_H__ */ + diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 45f46ad..f83a36d 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -2178,189 +2178,165 @@ hsize_t diff_region(hid_t obj1_id, diff_opt_t *options) { - hssize_t nblocks1, npoints1; - hssize_t nblocks2, npoints2; - H5G_stat_t sb1; - H5G_stat_t sb2; - hsize_t alloc_size; - hsize_t *ptdata1; - hsize_t *ptdata2; - int ndims1; - int ndims2; - int i, j; - haddr_t objno1, objno2; /* compact form of object's location */ - hsize_t nfound_b=0; /* block differences found */ - hsize_t nfound_p=0; /* point differences found */ - - ndims1 = H5Sget_simple_extent_ndims(region1_id); - ndims2 = H5Sget_simple_extent_ndims(region2_id); - - H5Gget_objinfo(obj1_id, ".", FALSE, &sb1); - H5Gget_objinfo(obj2_id, ".", FALSE, &sb2); - - objno1 = (haddr_t)sb1.objno[0] | ((haddr_t)sb1.objno[1] << (8 * sizeof(long))); - objno2 = (haddr_t)sb2.objno[0] | ((haddr_t)sb2.objno[1] << (8 * sizeof(long))); - -/* - * These two functions fail if the region does not have blocks or points, - * respectively. They do not currently know how to translate from one to - * the other. - */ - H5E_BEGIN_TRY { - nblocks1 = H5Sget_select_hyper_nblocks(region1_id); - nblocks2 = H5Sget_select_hyper_nblocks(region2_id); - - npoints1 = H5Sget_select_elem_npoints(region1_id); - npoints2 = H5Sget_select_elem_npoints(region2_id); - } H5E_END_TRY; - - if (nblocks1!=nblocks2 || npoints1!=npoints2 || ndims1!=ndims2) - { - options->not_cmp=1; - return 0; - } - -/*------------------------------------------------------------------------- - * compare block information - *------------------------------------------------------------------------- - */ - if (nblocks1 > 0) - { - - alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - - ptdata1 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1); - - ptdata2 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2); - - for (i = 0; i < nblocks1; i++) - { - /* start coordinates and opposite corner */ - for (j = 0; j < ndims1; j++) - { - hsize_t start1, start2, end1, end2; - start1 = ptdata1[i * 2 * ndims1 + j]; - start2 = ptdata2[i * 2 * ndims1 + j]; - end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; - end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; - if (start1 != start2 || end1 != end2) - { - nfound_b++; + hssize_t nblocks1, npoints1; + hssize_t nblocks2, npoints2; + hsize_t alloc_size; + hsize_t *ptdata1; + hsize_t *ptdata2; + int ndims1; + int ndims2; + int i, j; + hsize_t nfound_b = 0; /* block differences found */ + hsize_t nfound_p = 0; /* point differences found */ + + ndims1 = H5Sget_simple_extent_ndims(region1_id); + ndims2 = H5Sget_simple_extent_ndims(region2_id); + + /* + * These two functions fail if the region does not have blocks or points, + * respectively. They do not currently know how to translate from one to + * the other. + */ + H5E_BEGIN_TRY { + nblocks1 = H5Sget_select_hyper_nblocks(region1_id); + nblocks2 = H5Sget_select_hyper_nblocks(region2_id); + + npoints1 = H5Sget_select_elem_npoints(region1_id); + npoints2 = H5Sget_select_elem_npoints(region2_id); + } H5E_END_TRY; + + if(nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) { + options->not_cmp = 1; + return 0; } - } - } + /*------------------------------------------------------------------------- + * compare block information + *------------------------------------------------------------------------- + */ + if(nblocks1 > 0) { + alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]); + assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + + ptdata1 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1); + + ptdata2 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2); + + for (i = 0; i < nblocks1; i++) { + /* start coordinates and opposite corner */ + for (j = 0; j < ndims1; j++) { + hsize_t start1, start2, end1, end2; + + start1 = ptdata1[i * 2 * ndims1 + j]; + start2 = ptdata2[i * 2 * ndims1 + j]; + end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; + end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; + if (start1 != start2 || end1 != end2) + nfound_b++; + } + } - /* print differences if found */ - if (nfound_b && options->m_verbose) - { - parallel_print("Referenced dataset %lu %lu\n", - (unsigned long)objno1,(unsigned long)objno2); - parallel_print("------------------------------------------------------------\n"); - - parallel_print("Region blocks\n"); - for (i = 0; i < nblocks1; i++) - { - parallel_print("block #%d", i); - print_region_block(i, ptdata1, ndims1); - print_region_block(i, ptdata2, ndims1); - parallel_print("\n"); - - } - } - HDfree(ptdata1); - HDfree(ptdata2); - } + /* print differences if found */ + if (nfound_b && options->m_verbose) { + H5O_info_t oi1, oi2; -/*------------------------------------------------------------------------- - * compare point information - *------------------------------------------------------------------------- - */ + H5Oget_info(obj1_id, ".", &oi1, H5P_DEFAULT); + H5Oget_info(obj2_id, ".", &oi2, H5P_DEFAULT); - if (npoints1 > 0) - { - alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - - ptdata1 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); - H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1); + parallel_print("Referenced dataset %lu %lu\n", + (unsigned long)oi1.addr, (unsigned long)oi2.addr); + parallel_print("------------------------------------------------------------\n"); - ptdata2 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); - H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2); + parallel_print("Region blocks\n"); + for (i = 0; i < nblocks1; i++) { + parallel_print("block #%d", i); + print_region_block(i, ptdata1, ndims1); + print_region_block(i, ptdata2, ndims1); + parallel_print("\n"); + } + } - for (i = 0; i < npoints1; i++) - { - hsize_t pt1, pt2; + HDfree(ptdata1); + HDfree(ptdata2); + } - for (j = 0; j < ndims1; j++) - { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) - nfound_p++; - } - } + /*------------------------------------------------------------------------- + * compare point information + *------------------------------------------------------------------------- + */ + if(npoints1 > 0) { + alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]); + assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + + ptdata1 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); + H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1); + + ptdata2 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); + H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2); + + for(i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + + for(j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if(pt1 != pt2) + nfound_p++; + } + } - if (nfound_p && options->m_verbose) - { - parallel_print("Region points\n"); - for (i = 0; i < npoints1; i++) - { - hsize_t pt1, pt2; - int diff_data = 0; - for (j = 0; j < ndims1; j++) - { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) - { - diff_data = 1; - break; - } - } - if (diff_data) - { - parallel_print("point #%d", i); - print_points(i, ptdata1, ndims1); - print_points(i, ptdata2, ndims1); - parallel_print("\n"); - } - } - } + if(nfound_p && options->m_verbose) { + parallel_print("Region points\n"); + for(i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + int diff_data = 0; + + for(j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if(pt1 != pt2) { + diff_data = 1; + break; + } + } + if(diff_data) { + parallel_print("point #%d", i); + print_points(i, ptdata1, ndims1); + print_points(i, ptdata2, ndims1); + parallel_print("\n"); + } + } + } #if defined (H5DIFF_DEBUG) - for (i = 0; i < npoints1; i++) - { - int j; + for (i = 0; i < npoints1; i++) { + int j; - parallel_print("%sPt%lu: " , - i ? "," : "", - (unsigned long)i); + parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); - for (j = 0; j < ndims1; j++) - parallel_print("%s%lu", j ? "," : "(", - (unsigned long)(ptdata1[i * ndims1 + j])); + for (j = 0; j < ndims1; j++) + parallel_print("%s%lu", j ? "," : "(", + (unsigned long)(ptdata1[i * ndims1 + j])); - parallel_print(")"); - } + parallel_print(")"); + } #endif - HDfree(ptdata1); - HDfree(ptdata2); - } + HDfree(ptdata1); + HDfree(ptdata2); + } - nfound_b = nfound_b/ndims1; - nfound_p = nfound_p/ndims1; - return (nfound_p + nfound_b); + nfound_b = nfound_b/ndims1; + nfound_p = nfound_p/ndims1; + return (nfound_p + nfound_b); } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 50bc6cd..44154cd 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -128,12 +128,12 @@ void h5tools_close(void) { if (h5tools_init_g) { - if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); - else - rawdatastream = NULL; - } + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } /* Clean up the reference path table, if it's been used */ term_ref_path_table(); @@ -141,7 +141,7 @@ h5tools_close(void) /* Shut down the library */ H5close(); - h5tools_init_g = 0; + h5tools_init_g = 0; } } @@ -554,152 +554,150 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai *to the ctx->size_last_dim. */ /* binary dump */ - if (bin_output) - { - do_bin_output(stream,nelmts,type,_mem); - bin_output=0; - } - else - { - /* Setup */ - memset(&buffer, 0, sizeof(h5tools_str_t)); - size = H5Tget_size(type); + if(bin_output) { + do_bin_output(stream, nelmts, type, _mem); + bin_output = 0; + } /* end if */ + else { + /* Setup */ + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + size = H5Tget_size(type); - if (info->line_ncols > 0) - ncols = info->line_ncols; + if(info->line_ncols > 0) + ncols = info->line_ncols; - /* 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; + /* 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; - h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); + h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); - for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); + for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); - if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) - h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); + if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) + h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); - s = h5tools_str_fmt(&buffer, 0, "%s"); + s = h5tools_str_fmt(&buffer, 0, "%s"); - /* - * If the element would split on multiple lines if printed at our - * current location... - */ - if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { - if (ctx->prev_multiline) { - /* - * ... and the previous element also occupied more than one - * line, then start this element at the beginning of a line. - */ - ctx->need_prefix = TRUE; - } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) <= ncols) { - /* - * ...but *could* fit on one line otherwise, then we - * should end the current line and start this element on its - * own line. - */ - ctx->need_prefix = TRUE; + /* + * If the element would split on multiple lines if printed at our + * current location... + */ + if (info->line_multi_new == 1 && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) { + if (ctx->prev_multiline) { + /* + * ... and the previous element also occupied more than one + * line, then start this element at the beginning of a line. + */ + ctx->need_prefix = TRUE; + } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) <= ncols) { + /* + * ...but *could* fit on one line otherwise, then we + * should end the current line and start this element on its + * own line. + */ + ctx->need_prefix = TRUE; + } } - } - /* - * We need to break after each row of a dimension---> we should - * break at the end of the each last dimension well that is the - * way the dumper did it before - */ - if (info->arr_linebreak && ctx->cur_elmt) { - if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) - ctx->need_prefix = TRUE; + /* + * We need to break after each row of a dimension---> we should + * break at the end of the each last dimension well that is the + * way the dumper did it before + */ + if (info->arr_linebreak && ctx->cur_elmt) { + if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) + ctx->need_prefix = TRUE; - if ((hsize_t)elmt_counter == ctx->size_last_dim) { - ctx->need_prefix = TRUE; - elmt_counter = 0; + if ((hsize_t)elmt_counter == ctx->size_last_dim) { + ctx->need_prefix = TRUE; + elmt_counter = 0; + } } - } - - /* - * If the previous element occupied multiple lines and this element - * is too long to fit on a line then start this element at the - * beginning of the line. - */ - if (info->line_multi_new == 1 && ctx->prev_multiline && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) - ctx->need_prefix = TRUE; - - /* - * If too many elements have already been printed then we need to - * start a new line. - */ - if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) - ctx->need_prefix = TRUE; - /* - * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause - * the data to split across multiple lines. We display the sections - * one-at a time. - */ - for (secnum = 0, multiline = 0; - (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); - secnum++) { /* - * If the current section plus possible suffix and end-of-line - * information would cause the output to wrap then we need to - * start a new line. + * If the previous element occupied multiple lines and this element + * is too long to fit on a line then start this element at the + * beginning of the line. */ + if (info->line_multi_new == 1 && ctx->prev_multiline && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = TRUE; /* - * Added the info->skip_first because the dumper does not want - * this check to happen for the first line + * If too many elements have already been printed then we need to + * start a new line. */ - if ((!info->skip_first || i) && - (ctx->cur_column + strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) - ctx->need_prefix = 1; + if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) + ctx->need_prefix = TRUE; /* - * Print the prefix or separate the beginning of this element - * from the previous element. + * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause + * the data to split across multiple lines. We display the sections + * one-at a time. */ - if (ctx->need_prefix) { - if (secnum) - multiline++; - - /* 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); - } else if ((i || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); - } + for (secnum = 0, multiline = 0; + (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); + secnum++) { + /* + * If the current section plus possible suffix and end-of-line + * information would cause the output to wrap then we need to + * start a new line. + */ - /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); - } + /* + * Added the info->skip_first because the dumper does not want + * this check to happen for the first line + */ + if ((!info->skip_first || i) && + (ctx->cur_column + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = 1; - ctx->prev_multiline = multiline; - } + /* + * Print the prefix or separate the beginning of this element + * from the previous element. + */ + if (ctx->need_prefix) { + if (secnum) + multiline++; + + /* 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); + } else if ((i || ctx->continuation) && secnum == 0) { + fputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); + } - h5tools_str_close(&buffer); + /* Print the section */ + fputs(section, stream); + ctx->cur_column += strlen(section); + } - }/* else bin */ + ctx->prev_multiline = multiline; + } + h5tools_str_close(&buffer); + }/* else bin */ } diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 0b17b41..715d05e 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -49,49 +49,8 @@ extern int d_status; static int ref_path_table_put(const char *, haddr_t objno); static hbool_t ref_path_table_find(haddr_t objno); - -/*------------------------------------------------------------------------- - * Function: init_ref_path_table - * - * Purpose: Enter the root group ("/") into the path table - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -init_ref_path_table(hid_t fid) -{ - H5G_stat_t sb; - haddr_t objno; /* Compact form of object's location */ - char *root_path; - - /* Set file ID for later queries (XXX: this should be fixed) */ - thefile = fid; - - /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) - return (-1); - - if((root_path = HDstrdup("/")) == NULL) - return (-1); - - if(H5Gget_objinfo(fid, "/", TRUE, &sb)<0) { - /* fatal error? */ - HDfree(root_path); - return (-1); - } - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); - - /* Insert into table (takes ownership of path) */ - ref_path_table_put(root_path, objno); - - return(0); -} +static herr_t fill_ref_path_table_cb(hid_t group, const char *obj_name, + const H5L_info_t *linfo, void *op_data); /*------------------------------------------------------------------------- * Function: free_ref_path_info @@ -158,35 +117,31 @@ term_ref_path_table(void) haddr_t ref_path_table_lookup(const char *thepath) { - H5G_stat_t sb; - haddr_t objno; /* Compact form of object's location */ - - /* Check for external link first, so we don't return the OID of an object in another file */ - if(H5Gget_objinfo(thefile, thepath, FALSE, &sb)<0) - return HADDR_UNDEF; - if(sb.type == H5G_LINK) { - /* Get object ID for object at path */ - /* (If the object is not a soft link, we've already retrieved the - * correct information and don't have to perform this call. -QAK - */ - if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0) - /* fatal error ? */ + H5O_info_t oi; + + /* Allow lookups on the root group, even though it doesn't have any link info */ + if(HDstrcmp(thepath, "/")) { + H5L_info_t li; + + /* Check for external link first, so we don't return the OID of an object in another file */ + if(H5Lget_info(thefile, thepath, &li, H5P_DEFAULT) < 0) + return HADDR_UNDEF; + + /* UD links can't be followed, so they always "dangle" like soft links. */ + if(li.type >= H5L_TYPE_UD_MIN) return HADDR_UNDEF; - } else if(sb.type == H5G_UDLINK) - { - /* UD links can't be followed, so they always "dangle" like - * soft links. - */ - return HADDR_UNDEF; } /* end if */ - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); + /* Get the object info now */ + /* (returns failure for dangling soft links) */ + if(H5Oget_info(thefile, thepath, &oi, H5P_DEFAULT) < 0) + return HADDR_UNDEF; /* All existing objects in the file had better be in the table */ - HDassert(ref_path_table_find(objno)); + HDassert(ref_path_table_find(oi.addr)); /* Return OID */ - return(objno); + return(oi.addr); } /*------------------------------------------------------------------------- @@ -325,6 +280,65 @@ lookup_ref_path(haddr_t ref) } /*------------------------------------------------------------------------- + * Function: fill_ref_path_table_cb + * + * Purpose: Called by interator to create references for + * all objects and enter them in the table. + * + * Return: Error status. + * + * Programmer: REMcG + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linfo, + void *op_data) +{ + if(linfo->type == H5L_TYPE_HARD) { + H5O_info_t oinfo; + + H5Oget_info(group, obj_name, &oinfo, H5P_DEFAULT); + + /* Check if the object is already in the path table */ + if(!ref_path_table_find(oinfo.addr)) { + const char *obj_prefix = (const char *)op_data; + size_t tmp_len; + char *thepath; + + /* Compute length for this object's path */ + tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2; + + /* Allocate room for the path for this object */ + if((thepath = (char *)HDmalloc(tmp_len)) == NULL) + return FAIL; + + /* Build the name for this object */ + HDstrcpy(thepath, obj_prefix); + HDstrcat(thepath, "/"); + HDstrcat(thepath, obj_name); + + /* Insert the object into the path table (takes ownership of the path) */ + ref_path_table_put(thepath, oinfo.addr); + + if(oinfo.type == H5O_TYPE_GROUP) { + /* Iterate over objects in this group, using this group's + * name as their prefix + */ + if(H5Literate(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, thepath, H5P_DEFAULT) < 0) { + error_msg(progname, "unable to dump group \"%s\"\n", thepath); + d_status = EXIT_FAILURE; + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ + + return 0; +} + +/*------------------------------------------------------------------------- * Function: fill_ref_path_table * * Purpose: Called by interator to create references for @@ -339,46 +353,32 @@ lookup_ref_path(haddr_t ref) *------------------------------------------------------------------------- */ herr_t -fill_ref_path_table(hid_t group, const char *obj_name, const H5L_info_t UNUSED *linfo, - void *op_data) +fill_ref_path_table(hid_t fid) { - const char *obj_prefix = (const char *)op_data; - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ - - H5Gget_objinfo(group, obj_name, FALSE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - - /* Check if the object is in the path table */ - if (!ref_path_table_find(objno)) { - size_t tmp_len; - char *thepath; - - /* Compute length for this object's path */ - tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2; - - /* Allocate room for the path for this object */ - if ((thepath = (char *) HDmalloc(tmp_len)) == NULL) - return FAIL; - - /* Build the name for this object */ - HDstrcpy(thepath, obj_prefix); - HDstrcat(thepath, "/"); - HDstrcat(thepath, obj_name); - - /* Insert the object into the path table */ - ref_path_table_put(thepath, objno); - - if(statbuf.type == H5G_GROUP) { - /* Iterate over objects in this group, using this group's - * name as their prefix - */ - if(H5Literate(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table, thepath, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", obj_name); - d_status = EXIT_FAILURE; - } - } - } + H5O_info_t oinfo; + char *root_path; + + /* Set file ID for later queries (XXX: this should be fixed) */ + thefile = fid; + + /* Create skip list to store reference path information */ + if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) + return (-1); + + /* Build the name for root group */ + root_path = HDstrdup("/"); + + /* Get info for root group */ + H5Oget_info(fid, root_path, &oinfo, H5P_DEFAULT); + + /* Insert the root group into the path table (takes ownership of path) */ + ref_path_table_put(root_path, oinfo.addr); + + /* Iterate over objects in this file */ + if(H5Literate(fid, root_path, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, (void *)"", H5P_DEFAULT) < 0) { + error_msg(progname, "unable to dump root group\n"); + d_status = EXIT_FAILURE; + } /* end if */ return 0; } diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h index d996114..567ca4b 100644 --- a/tools/lib/h5tools_ref.h +++ b/tools/lib/h5tools_ref.h @@ -22,14 +22,13 @@ extern "C" { #endif -int init_ref_path_table(hid_t fid); +herr_t fill_ref_path_table(hid_t fid); const char *lookup_ref_path(haddr_t ref); -herr_t fill_ref_path_table(hid_t, const char *, const H5L_info_t *, void *); int get_next_xid(void); -haddr_t get_fake_xid (void); -haddr_t ref_path_table_lookup(const char *); -haddr_t ref_path_table_gen_fake(const char *); -int term_ref_path_table(void); +haddr_t get_fake_xid(void); +haddr_t ref_path_table_lookup(const char *); +haddr_t ref_path_table_gen_fake(const char *); +int term_ref_path_table(void); #ifdef __cplusplus } diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 737c68a..f877baa 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -308,12 +308,12 @@ 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 h5tool_format_t *info, - hsize_t elmtno, int ndims, hsize_t min_idx[], + hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx) { hsize_t p_prod[H5S_MAX_RANK]; size_t i = 0; - hsize_t curr_pos=elmtno; + hsize_t curr_pos = elmtno; h5tools_str_reset(str); @@ -325,10 +325,9 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; - for ( i = 0; i < (size_t)ndims; i++) - { - ctx->pos[i] = curr_pos/ctx->acc[i]; - curr_pos -= ctx->acc[i]*ctx->pos[i]; + for ( i = 0; i < (size_t)ndims; i++) { + ctx->pos[i] = curr_pos/ctx->acc[i]; + curr_pos -= ctx->acc[i]*ctx->pos[i]; } assert( curr_pos == 0 ); @@ -580,31 +579,22 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai char *cp_vp = (char *)vp; hid_t memb, obj, region; unsigned nmembs; - int otype; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; - H5G_stat_t sb; /* * some tempvars to store the value before we append it to the string to * get rid of the memory alignment problem */ - double tempdouble; - float tempfloat; unsigned long_long tempullong; long_long templlong; unsigned long tempulong; long templong; unsigned int tempuint; int tempint; - unsigned short tempushort; - short tempshort; -#if H5_SIZEOF_LONG_DOUBLE !=0 - long double templdouble; -#endif /* Build default formats for long long types */ - if (!fmt_llong[0]) { + if(!fmt_llong[0]) { sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } @@ -612,29 +602,37 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Append value depending on data type */ start = h5tools_str_len(str); - if (info->raw) { + if(info->raw) { size_t i; + n = H5Tget_size(type); if (1==n) { h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]); } else { - for (i = 0; i < n; i++) { - if (i) h5tools_str_append(str, ":"); - h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); + for(i = 0; i < n; i++) { + if(i) + h5tools_str_append(str, ":"); + h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); } } } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - memcpy(&tempfloat, vp, sizeof(float)); + float tempfloat; + + HDmemcpy(&tempfloat, vp, sizeof(float)); h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - memcpy(&tempdouble, vp, sizeof(double)); - h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); + double tempdouble; + + HDmemcpy(&tempdouble, vp, sizeof(double)); + h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); #if H5_SIZEOF_LONG_DOUBLE !=0 } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - memcpy(&templdouble, vp, sizeof(long double)); - h5tools_str_append(str, "%Lf", templdouble); + long double templdouble; + + HDmemcpy(&templdouble, vp, sizeof(long double)); + h5tools_str_append(str, "%Lf", templdouble); #endif - } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || + } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { h5tools_print_char(str, info, (char)(*ucp_vp)); } else if (H5T_STRING == H5Tget_class(type)) { @@ -713,32 +711,36 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "\"\""); } /* end else */ } else if (H5Tequal(type, H5T_NATIVE_INT)) { - memcpy(&tempint, vp, sizeof(int)); + HDmemcpy(&tempint, vp, sizeof(int)); h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } else if (H5Tequal(type, H5T_NATIVE_UINT)) { - memcpy(&tempuint, vp, sizeof(unsigned int)); + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp); } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp); } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - memcpy(&tempshort, vp, sizeof(short)); + short tempshort; + + HDmemcpy(&tempshort, vp, sizeof(short)); h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - memcpy(&tempushort, vp, sizeof(unsigned short)); + unsigned short tempushort; + + HDmemcpy(&tempushort, vp, sizeof(unsigned short)); h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); } else if (H5Tequal(type, H5T_NATIVE_LONG)) { - memcpy(&templong, vp, sizeof(long)); + HDmemcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - memcpy(&tempulong, vp, sizeof(unsigned long)); + HDmemcpy(&tempulong, vp, sizeof(unsigned long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - memcpy(&templlong, vp, sizeof(long_long)); + HDmemcpy(&templlong, vp, sizeof(long_long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - memcpy(&tempullong, vp, sizeof(unsigned long_long)); + HDmemcpy(&tempullong, vp, sizeof(unsigned long_long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { @@ -849,7 +851,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai obj = H5Rdereference(container, H5R_DATASET_REGION, vp); region = H5Rget_region(container, H5R_DATASET_REGION, vp); - H5Gget_objinfo(obj, ".", FALSE, &sb); /* get name of the dataset the region reference points to using H5Rget_name */ H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*)ref_name, 1024); @@ -867,47 +868,46 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai if (h5tools_is_zero(vp, H5Tget_size(type))) { h5tools_str_append(str, "NULL"); } else { - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oi; const char *path; - otype = H5Rget_obj_type(container, H5R_OBJECT, vp); obj = H5Rdereference(container, H5R_OBJECT, vp); - H5Gget_objinfo(obj, ".", FALSE, &sb); + H5Oget_info(obj, ".", &oi, H5P_DEFAULT); /* Print object type and close object */ - switch (otype) { - case H5G_GROUP: + switch(oi.type) { + case H5O_TYPE_GROUP: h5tools_str_append(str, H5_TOOLS_GROUP); - H5Gclose(obj); break; - case H5G_DATASET: + + case H5O_TYPE_DATASET: h5tools_str_append(str, H5_TOOLS_DATASET); - H5Dclose(obj); break; - case H5G_TYPE: + + case H5O_TYPE_NAMED_DATATYPE: h5tools_str_append(str, H5_TOOLS_DATATYPE); - H5Tclose(obj); break; + default: - h5tools_str_append(str, "%u-", otype); + h5tools_str_append(str, "%u-", (unsigned)oi.type); break; - } + } /* end switch */ + H5Oclose(obj); /* Print OID */ - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); - if (info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, objno); + if(info->obj_hidefileno) + h5tools_str_append(str, info->obj_format, oi.addr); else - h5tools_str_append(str, info->obj_format, sb.fileno[0], objno); + h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); /* Print name */ path = lookup_ref_path(*(haddr_t *)vp); if (path) { - h5tools_str_append(str, " "); - h5tools_str_append(str, path); - h5tools_str_append(str, " "); - } - } + h5tools_str_append(str, " "); + h5tools_str_append(str, path); + h5tools_str_append(str, " "); + } /* end if */ + } /* end else */ } else if (H5Tget_class(type) == H5T_ARRAY) { int k, ndims; hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; @@ -929,25 +929,23 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Print the opening bracket */ h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - for (i = 0; i < nelmts; i++) { - if (i) + for(i = 0; i < nelmts; i++) { + if(i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + if(info->arr_linebreak && i && i % dims[ndims - 1] == 0) { int x; h5tools_str_append(str, "%s", "\n"); - /*need to indent some more here*/ - if (ctx->indent_level >= 0 ) - { - if (!info->pindex) - h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - } + /* need to indent some more here*/ + if(ctx->indent_level >= 0) + if(!info->pindex) + h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for (x = 0; x < ctx->indent_level + 1; x++) - h5tools_str_append(str,"%s",OPT(info->line_indent,"")); + for(x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } /* end if */ else if(i && info->arr_sep) h5tools_str_append(str, " "); @@ -961,7 +959,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end for */ /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); H5Tclose(memb); } else if (H5Tget_class(type) == H5T_VLEN) { unsigned int i; diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 0964b7b..607d412 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -33,7 +33,7 @@ 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 h5tool_format_t *info, - hsize_t elmtno, int ndims, hsize_t min_idx[], + hsize_t elmtno, unsigned 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 h5tool_format_t *); extern char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index b04f3c6..4aabe09 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -483,26 +483,23 @@ build_obj_path_name(const char *prefix, const char *name) static herr_t find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *op_data) { - H5G_stat_t statbuf; + H5O_info_t oinfo; find_objs_t *info = (find_objs_t*)op_data; herr_t ret_value = 0; - if(H5Gget_objinfo(group, name, FALSE, &statbuf) < 0) + if(H5Oget_info(group, name, &oinfo, H5P_DEFAULT) < 0) ; /* keep going */ else { - haddr_t objno; /* Compact form of object's location */ - - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - switch (statbuf.type) { + switch(oinfo.type) { char *tmp; size_t tmp_len; - case H5G_GROUP: - if (search_obj(info->group_table, objno) == NULL) { + case H5O_TYPE_GROUP: + if(search_obj(info->group_table, oinfo.addr) == NULL) { char *old_prefix; tmp = build_obj_path_name(info->prefix, name); - add_obj(info->group_table, objno, tmp, TRUE); + add_obj(info->group_table, oinfo.addr, tmp, TRUE); old_prefix = info->prefix; tmp_len = HDstrlen(tmp); @@ -516,44 +513,42 @@ find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void } /* end if */ break; - case H5G_DATASET: - if (search_obj(info->dset_table, objno) == NULL) { + case H5O_TYPE_DATASET: + if(search_obj(info->dset_table, oinfo.addr) == NULL) { hid_t dset; tmp = build_obj_path_name(info->prefix, name); - add_obj(info->dset_table, objno, tmp, TRUE); + add_obj(info->dset_table, oinfo.addr, tmp, TRUE); - if ((dset = H5Dopen (group, name)) >= 0) { + if((dset = H5Dopen (group, name)) >= 0) { hid_t type; type = H5Dget_type(dset); - if (H5Tcommitted(type) > 0) { - H5Gget_objinfo(type, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - - if (search_obj(info->type_table, objno) == NULL) { + if(H5Tcommitted(type) > 0) { + H5Oget_info(type, ".", &oinfo, H5P_DEFAULT); + if (search_obj(info->type_table, oinfo.addr) == NULL) { char *type_name = HDstrdup(tmp); - add_obj(info->type_table, objno, type_name, FALSE); + add_obj(info->type_table, oinfo.addr, type_name, FALSE); } /* end if */ - } + } /* end if */ H5Tclose(type); H5Dclose(dset); - } else { + } /* end if */ + else ret_value = FAIL; - } } /* end if */ break; - case H5G_TYPE: + case H5O_TYPE_NAMED_DATATYPE: { obj_t *found_obj; tmp = build_obj_path_name(info->prefix, name); - if ((found_obj = search_obj(info->type_table, objno)) == NULL) - add_obj(info->type_table, objno, tmp, TRUE); + if((found_obj = search_obj(info->type_table, oinfo.addr)) == NULL) + add_obj(info->type_table, oinfo.addr, tmp, TRUE); else { /* Use latest version of name */ HDfree(found_obj->objname); @@ -594,6 +589,8 @@ herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { + H5O_info_t oinfo; + /* Initialize the tables */ init_table(group_table); init_table(dset_table); @@ -605,25 +602,15 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, info->type_table = *type_table; info->dset_table = *dset_table; - { - /* add the root group as an object, it may have hard links to it */ - - H5G_stat_t statbuf; - haddr_t objno; /* compact form of object's location */ - char* tmp; - - if(H5Gget_objinfo(fid, "/", FALSE, &statbuf) < 0) - return FAIL; - else - { - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - /* call with an empty string, it appends group separator */ - tmp = build_obj_path_name(info->prefix, ""); - add_obj(info->group_table, objno, tmp, TRUE); - } - } - + /* add the root group as an object, it may have hard links to it */ + if(H5Oget_info(fid, "/", &oinfo, H5P_DEFAULT) < 0) + return FAIL; + else { + /* call with an empty string, it appends '/' group separator */ + char *tmp = build_obj_path_name(info->prefix, ""); + add_obj(info->group_table, oinfo.addr, tmp, TRUE); + } /* end else */ /* Find all shared objects */ return(H5Literate(fid, "/", H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info, H5P_DEFAULT)); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 65cca66..58d618d 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -171,11 +171,13 @@ traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo, is_group = (oinfo.type == H5O_TYPE_GROUP) ? TRUE : FALSE; /* Make 'visit object' callback */ - (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata); + if(udata->visitor->visit_obj) + (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata); } /* end if */ else { /* Make 'visit link' callback */ - (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata); + if(udata->visitor->visit_lnk) + (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata); } /* end else */ /* Check for group that we haven't visited yet & recurse */ @@ -267,7 +269,7 @@ traverse(hid_t file_id, const trav_visitor_t *visitor) *------------------------------------------------------------------------- */ static void -trav_info_add(trav_info_t *info, const char *path, H5G_obj_t obj_type) +trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) { size_t idx; /* Index of address to use */ @@ -302,8 +304,8 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, hbool_t UNUSED already_visited, void *udata) { /* Add the object to the 'info' struct */ - /* (object types map directly to "group" types) */ - trav_info_add((trav_info_t *)udata, path, (H5G_obj_t)oinfo->type); + /* (object types map directly to "traversal" types) */ + trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type); return(0); } /* end trav_info_visit_obj() */ @@ -326,7 +328,7 @@ static int trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) { /* Add the link to the 'info' struct */ - trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5G_LINK : H5G_UDLINK)); + trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK)); return(0); } /* end trav_info_visit_lnk() */ @@ -647,7 +649,7 @@ trav_table_add(trav_table_t *table, table->objs[new].objno = oinfo ? oinfo->addr : HADDR_UNDEF; table->objs[new].flags[0] = table->objs[new].flags[1] = 0; table->objs[new].name = (char *)HDstrdup(path); - table->objs[new].type = oinfo ? (H5G_obj_t)oinfo->type : H5G_LINK; + table->objs[new].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; table->objs[new].nlinks = 0; table->objs[new].sizelinks = 0; table->objs[new].links = NULL; @@ -707,7 +709,7 @@ trav_table_addlink(trav_table_t *table, void trav_table_addflags(unsigned *flags, char *name, - H5G_obj_t type, + h5trav_type_t type, trav_table_t *table) { unsigned int new; @@ -715,7 +717,7 @@ void trav_table_addflags(unsigned *flags, if(table->nobjs == table->size) { table->size = MAX(1, table->size * 2); table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); - } + } /* end if */ new = table->nobjs++; table->objs[new].objno = 0; diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 4218013..05bc3cb 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -19,22 +19,32 @@ #include "hdf5.h" /*------------------------------------------------------------------------- - * public struct to store name and type of an object + * public enum to specify type of an object * the TYPE can be: - * H5G_UNKNOWN = -1, - * 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 + * H5TRAV_TYPE_UNKNOWN = -1, + * H5TRAV_TYPE_GROUP, Object is a group + * H5TRAV_TYPE_DATASET, Object is a dataset + * H5TRAV_TYPE_TYPE, Object is a named datatype + * H5TRAV_TYPE_LINK, Object is a symbolic link + * H5TRAV_TYPE_UDLINK, Object is a user-defined link *------------------------------------------------------------------------- */ +typedef enum { + H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */ + H5TRAV_TYPE_GROUP, /* Object is a group */ + H5TRAV_TYPE_DATASET, /* Object is a dataset */ + H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */ + H5TRAV_TYPE_LINK, /* Object is a symbolic link */ + H5TRAV_TYPE_UDLINK /* Object is a user-defined link */ +} h5trav_type_t; -typedef H5G_obj_t H5G_obj_t1; - - +/*------------------------------------------------------------------------- + * public struct to store name and type of an object + *------------------------------------------------------------------------- + */ typedef struct trav_path_t { char *path; - H5G_obj_t type; + h5trav_type_t type; } trav_path_t; typedef struct trav_info_t { @@ -59,10 +69,10 @@ typedef struct trav_link_t { */ typedef struct trav_obj_t { - haddr_t objno; /* object number from H5Gget_objinfo */ + haddr_t objno; /* object address */ unsigned flags[2]; /* h5diff.object is present or not in both files*/ char *name; /* name */ - H5G_obj_t type; /* type of object */ + h5trav_type_t type; /* type of object */ trav_link_t *links; /* array of possible link names */ size_t sizelinks; /* size of links array */ size_t nlinks; /* number of links */ @@ -135,9 +145,8 @@ void trav_table_free(trav_table_t *table); void trav_table_addflags(unsigned *flags, char *objname, - H5G_obj_t type, + h5trav_type_t type, trav_table_t *table); #endif /* H5TRAV_H__ */ - diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index 8ef59bd..d904095 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -16,12 +16,7 @@ #ifndef _PH5DIFF_H__ #define _PH5DIFF_H__ -/* use a larger output buffer for Tflops which does not support vsnprintf. */ -#ifdef __PUMAGON__ #define PRINT_DATA_MAX_SIZE 512 -#else -#define PRINT_DATA_MAX_SIZE 512 -#endif #define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4) /* Send from manager to workers */ #define MPI_TAG_ARGS 1 @@ -41,7 +36,7 @@ extern int g_nTasks; extern unsigned char g_Parallel; extern char outBuff[]; extern int outBuffOffset; -extern FILE* overflow_file; +extern FILE * overflow_file; struct diff_args { @@ -60,5 +55,5 @@ struct diffs_found #include <mpi.h> #endif - #endif /* _PH5DIFF_H__ */ + diff --git a/tools/testfiles/h5copytst.out.ls b/tools/testfiles/h5copytst.out.ls index 378aa0f..c4d1778 100644 --- a/tools/testfiles/h5copytst.out.ls +++ b/tools/testfiles/h5copytst.out.ls @@ -11,7 +11,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /A/B1/simple Dataset {6/6} Location: 1:90216 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /A/B2 Group @@ -20,7 +19,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /A/B2/simple2 Dataset {6/6} Location: 1:94456 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /C Group @@ -32,7 +30,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /C/D/simple Dataset {6/6} Location: 1:97664 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /E Group @@ -47,20 +44,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /E/F/grp_dsets/chunk Dataset {6/6} Location: 1:102744 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/compact Dataset {6/6} Location: 1:103200 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/compound Dataset {2/2} Location: 1:103336 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -69,7 +63,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /E/F/grp_dsets/compressed Dataset {6/6} Location: 1:103552 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -77,14 +70,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /E/F/grp_dsets/named_vl Dataset {2/2} Location: 1:103768 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:103720 variable length of 32-bit little-endian integer /E/F/grp_dsets/nested_vl Dataset {2/2} Location: 1:112240 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -92,7 +83,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /E/F/grp_dsets/simple Dataset {6/6} Location: 1:112384 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /E/F/grp_dsets/vl Type @@ -115,20 +105,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /G/H/grp_nested/grp_dsets/chunk Dataset {6/6} Location: 1:118088 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compact Dataset {6/6} Location: 1:120688 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/compound Dataset {2/2} Location: 1:120824 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -137,7 +124,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /G/H/grp_nested/grp_dsets/compressed Dataset {6/6} Location: 1:123136 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -145,14 +131,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /G/H/grp_nested/grp_dsets/named_vl Dataset {2/2} Location: 1:127448 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:123304 variable length of 32-bit little-endian integer /G/H/grp_nested/grp_dsets/nested_vl Dataset {2/2} Location: 1:127576 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -160,7 +144,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /G/H/grp_nested/grp_dsets/simple Dataset {6/6} Location: 1:127720 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /G/H/grp_nested/grp_dsets/vl Type @@ -171,20 +154,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /chunk Dataset {6/6} Location: 1:6216 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /compact Dataset {6/6} Location: 1:6344 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /compound Dataset {2/2} Location: 1:8528 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -193,7 +173,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /compressed Dataset {6/6} Location: 1:12888 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -204,20 +183,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_dsets/chunk Dataset {6/6} Location: 1:35896 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/compact Dataset {6/6} Location: 1:36352 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/compound Dataset {2/2} Location: 1:36488 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -226,7 +202,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_dsets/compressed Dataset {6/6} Location: 1:36704 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -234,14 +209,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_dsets/named_vl Dataset {2/2} Location: 1:36920 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:36872 variable length of 32-bit little-endian integer /grp_dsets/nested_vl Dataset {2/2} Location: 1:45392 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -249,13 +222,11 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_dsets/simple Dataset {6/6} Location: 1:45536 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/simple_group Dataset {6/6} Location: 1:61744 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_dsets/vl Type @@ -275,20 +246,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_nested/grp_dsets/chunk Dataset {6/6} Location: 1:49256 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/compact Dataset {6/6} Location: 1:51856 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/compound Dataset {2/2} Location: 1:51992 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -297,7 +265,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_nested/grp_dsets/compressed Dataset {6/6} Location: 1:54304 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -305,14 +272,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_nested/grp_dsets/named_vl Dataset {2/2} Location: 1:58616 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:54472 variable length of 32-bit little-endian integer /grp_nested/grp_dsets/nested_vl Dataset {2/2} Location: 1:58744 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -320,7 +285,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_nested/grp_dsets/simple Dataset {6/6} Location: 1:58888 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_nested/grp_dsets/vl Type @@ -334,20 +298,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/chunk Dataset {6/6} Location: 1:65088 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/compact Dataset {6/6} Location: 1:65544 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/compound Dataset {2/2} Location: 1:65680 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -356,7 +317,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/compressed Dataset {6/6} Location: 1:65896 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -367,20 +327,17 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/grp_dsets/chunk Dataset {6/6} Location: 1:78072 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/compact Dataset {6/6} Location: 1:78528 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/compound Dataset {2/2} Location: 1:78664 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -389,7 +346,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/grp_dsets/compressed Dataset {6/6} Location: 1:78880 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Chunks: {2} 8 bytes Storage: <details removed for portability> Filter-0: deflate-1 OPT {1} @@ -397,14 +353,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/grp_dsets/named_vl Dataset {2/2} Location: 1:79096 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:79048 variable length of 32-bit little-endian integer /grp_rename/grp_dsets/nested_vl Dataset {2/2} Location: 1:87568 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -412,7 +366,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/grp_dsets/simple Dataset {6/6} Location: 1:87712 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/grp_dsets/vl Type @@ -423,14 +376,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/named_vl Dataset {2/2} Location: 1:66112 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:66064 variable length of 32-bit little-endian integer /grp_rename/nested_vl Dataset {2/2} Location: 1:74584 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -438,7 +389,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /grp_rename/simple Dataset {6/6} Location: 1:74728 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /grp_rename/vl Type @@ -449,14 +399,12 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /named_vl Dataset {2/2} Location: 1:13104 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: shared-1:13056 variable length of 32-bit little-endian integer /nested_vl Dataset {2/2} Location: 1:27392 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: variable length of variable length of @@ -464,7 +412,6 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /rename Dataset {2/2} Location: 1:31760 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: struct { "str1" +0 20-byte null-terminated ASCII string @@ -473,12 +420,10 @@ Opened "../testfiles/h5copytst.out.h5" with sec2 driver. /simple Dataset {6/6} Location: 1:800 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer /simple_top Dataset {6/6} Location: 1:29584 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: <details removed for portability> Type: 32-bit little-endian integer diff --git a/tools/testfiles/tall-1.ddl b/tools/testfiles/tall-1.ddl index 6069293..cd5f721 100644 --- a/tools/testfiles/tall-1.ddl +++ b/tools/testfiles/tall-1.ddl @@ -68,7 +68,7 @@ GROUP "/" { LINKCLASS 64 TARGETFILE "somefile" TARGETPATH "somepath" -} + } GROUP "g1.2.1" { SOFTLINK "slink" { LINKTARGET "somevalue" diff --git a/tools/testfiles/tall-2A.ddl b/tools/testfiles/tall-2A.ddl index b16feb8..2c56501 100644 --- a/tools/testfiles/tall-2A.ddl +++ b/tools/testfiles/tall-2A.ddl @@ -52,7 +52,7 @@ GROUP "/" { LINKCLASS 64 TARGETFILE "somefile" TARGETPATH "somepath" -} + } GROUP "g1.2.1" { SOFTLINK "slink" { LINKTARGET "somevalue" diff --git a/tools/testfiles/tall-2A.h5.xml b/tools/testfiles/tall-2A.h5.xml index 8a8467c..314ab4e 100644 --- a/tools/testfiles/tall-2A.h5.xml +++ b/tools/testfiles/tall-2A.h5.xml @@ -127,10 +127,10 @@ Expected output for 'h5dump --xml -A tall.h5' </hdf5:Dataset> </hdf5:Group> <hdf5:Group Name="g1.2" OBJ-XID="xid_3568" H5Path="/g1/g1.2" Parents="xid_800" H5ParentPaths="/g1" > + <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3568" H5ParentPaths="/g1/g1.2" /> <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4272" H5Path="/g1/g1.2/g1.2.1" Parents="xid_3568" H5ParentPaths="/g1/g1.2" > - <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4272" H5ParentPaths="/g1/g1.2/g1.2.1" /> + <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4272" H5ParentPaths="/g1/g1.2/g1.2.1" /> </hdf5:Group> - <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3568" H5ParentPaths="/g1/g1.2" /> </hdf5:Group> </hdf5:Group> <hdf5:Group Name="g2" OBJ-XID="xid_1832" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" > diff --git a/tools/testfiles/tall-2B.ddl b/tools/testfiles/tall-2B.ddl index 002156e..ec220e9 100644 --- a/tools/testfiles/tall-2B.ddl +++ b/tools/testfiles/tall-2B.ddl @@ -48,7 +48,7 @@ GROUP "/" { LINKCLASS 64 TARGETFILE "somefile" TARGETPATH "somepath" -} + } GROUP "g1.2.1" { SOFTLINK "slink" { LINKTARGET "somevalue" diff --git a/tools/testfiles/tall.h5.xml b/tools/testfiles/tall.h5.xml index 8f11e54..3747193 100644 --- a/tools/testfiles/tall.h5.xml +++ b/tools/testfiles/tall.h5.xml @@ -140,10 +140,10 @@ Expected output for 'h5dump --xml tall.h5' </hdf5:Dataset> </hdf5:Group> <hdf5:Group Name="g1.2" OBJ-XID="xid_3568" H5Path="/g1/g1.2" Parents="xid_800" H5ParentPaths="/g1" > + <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3568" H5ParentPaths="/g1/g1.2" /> <hdf5:Group Name="g1.2.1" OBJ-XID="xid_4272" H5Path="/g1/g1.2/g1.2.1" Parents="xid_3568" H5ParentPaths="/g1/g1.2" > - <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551614" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4272" H5ParentPaths="/g1/g1.2/g1.2.1" /> + <hdf5:SoftLink LinkName="slink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/g1.2.1/slink" TargetPath="somevalue" Parents="xid_4272" H5ParentPaths="/g1/g1.2/g1.2.1" /> </hdf5:Group> - <hdf5:ExternalLink LinkName="extlink" OBJ-XID="xid_18446744073709551613" H5SourcePath="/g1/g1.2/extlink" TargetFilename="somefile" TargetPath="somepath" Parents="xid_3568" H5ParentPaths="/g1/g1.2" /> </hdf5:Group> </hdf5:Group> <hdf5:Group Name="g2" OBJ-XID="xid_1832" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" > diff --git a/tools/testfiles/tattr2.ls b/tools/testfiles/tattr2.ls index 01ad413..e34206e 100644 --- a/tools/testfiles/tattr2.ls +++ b/tools/testfiles/tattr2.ls @@ -308,7 +308,6 @@ dset Dataset {2/2} (2,2,1) 18, 19, 20, 21, 22, 23, 24 Location: 1:976 Links: 1 - Modified: XXXX-XX-XX XX:XX:XX XXX Storage: 8 logical bytes, 0 allocated bytes Type: 32-bit little-endian integer g1 Group diff --git a/tools/testfiles/tcompound.h5.xml b/tools/testfiles/tcompound.h5.xml index 1cbbf2e..c6de351 100644 --- a/tools/testfiles/tcompound.h5.xml +++ b/tools/testfiles/tcompound.h5.xml @@ -24,57 +24,6 @@ Expected output for 'h5dump --xml tcompound.h5' </hdf5:CompoundType> </hdf5:DataType> </hdf5:NamedDataType> - <hdf5:NamedDataType Name="type1" OBJ-XID="xid_1424" H5Path="/type1" Parents="xid_696" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int_name"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float_name"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> - <hdf5:NamedDataType Name="type2" OBJ-XID="xid_2792" H5Path="/type2" Parents="xid_696" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int_array"> - <hdf5:DataType> - <hdf5:ArrayType Ndims="1"> - <hdf5:ArrayDimension DimSize="4"/> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:ArrayType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float_array"> - <hdf5:DataType> - <hdf5:ArrayType Ndims="2"> - <hdf5:ArrayDimension DimSize="5"/> - <hdf5:ArrayDimension DimSize="6"/> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:ArrayType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="dset1" OBJ-XID="xid_744" H5Path= "/dset1" Parents="xid_696" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> @@ -122,26 +71,6 @@ Expected output for 'h5dump --xml tcompound.h5' </hdf5:Data> </hdf5:Dataset> <hdf5:Group Name="group1" OBJ-XID="xid_2104" H5Path="/group1" Parents="xid_696" H5ParentPaths="/" > - <hdf5:NamedDataType Name="type3" OBJ-XID="xid_5592" H5Path="/group1/type3" Parents="xid_2104" H5ParentPaths="/group1"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="dset2" OBJ-XID="xid_2152" H5Path= "/group1/dset2" Parents="xid_2104" H5ParentPaths="/group1"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> @@ -298,6 +227,26 @@ Expected output for 'h5dump --xml tcompound.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> + <hdf5:NamedDataType Name="type3" OBJ-XID="xid_5592" H5Path="/group1/type3" Parents="xid_2104" H5ParentPaths="/group1"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:Group> <hdf5:Group Name="group2" OBJ-XID="xid_6584" H5Path="/group2" Parents="xid_696" H5ParentPaths="/" > <hdf5:Dataset Name="dset5" OBJ-XID="xid_7040" H5Path= "/group2/dset5" Parents="xid_6584" H5ParentPaths="/group2"> @@ -323,5 +272,56 @@ Expected output for 'h5dump --xml tcompound.h5' </hdf5:Data> </hdf5:Dataset> </hdf5:Group> + <hdf5:NamedDataType Name="type1" OBJ-XID="xid_1424" H5Path="/type1" Parents="xid_696" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int_name"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float_name"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> + <hdf5:NamedDataType Name="type2" OBJ-XID="xid_2792" H5Path="/type2" Parents="xid_696" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int_array"> + <hdf5:DataType> + <hdf5:ArrayType Ndims="1"> + <hdf5:ArrayDimension DimSize="4"/> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:ArrayType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float_array"> + <hdf5:DataType> + <hdf5:ArrayType Ndims="2"> + <hdf5:ArrayDimension DimSize="5"/> + <hdf5:ArrayDimension DimSize="6"/> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:ArrayType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:RootGroup> </hdf5:HDF5-File> diff --git a/tools/testfiles/tcompound2.h5.xml b/tools/testfiles/tcompound2.h5.xml index 2940caa..e0b087c 100644 --- a/tools/testfiles/tcompound2.h5.xml +++ b/tools/testfiles/tcompound2.h5.xml @@ -24,57 +24,6 @@ Expected output for 'h5dump --xml tcompound2.h5' </hdf5:CompoundType> </hdf5:DataType> </hdf5:NamedDataType> - <hdf5:NamedDataType Name="type1" OBJ-XID="xid_3280" H5Path="/type1" Parents="xid_696" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int_name"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float_name"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> - <hdf5:NamedDataType Name="type2" OBJ-XID="xid_6544" H5Path="/type2" Parents="xid_696" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int_array"> - <hdf5:DataType> - <hdf5:ArrayType Ndims="1"> - <hdf5:ArrayDimension DimSize="4"/> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:ArrayType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float_array"> - <hdf5:DataType> - <hdf5:ArrayType Ndims="2"> - <hdf5:ArrayDimension DimSize="5"/> - <hdf5:ArrayDimension DimSize="6"/> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:ArrayType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="dset1" OBJ-XID="xid_744" H5Path= "/dset1" Parents="xid_696" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ChunkedLayout Ndims="1"> @@ -126,26 +75,6 @@ Expected output for 'h5dump --xml tcompound2.h5' </hdf5:Data> </hdf5:Dataset> <hdf5:Group Name="group1" OBJ-XID="xid_3960" H5Path="/group1" Parents="xid_696" H5ParentPaths="/" > - <hdf5:NamedDataType Name="type3" OBJ-XID="xid_6624" H5Path="/group1/type3" Parents="xid_3960" H5ParentPaths="/group1"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="int"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="float"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="dset2" OBJ-XID="xid_4008" H5Path= "/group1/dset2" Parents="xid_3960" H5ParentPaths="/group1"> <hdf5:StorageLayout> <hdf5:ChunkedLayout Ndims="1"> @@ -198,6 +127,26 @@ Expected output for 'h5dump --xml tcompound2.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> + <hdf5:NamedDataType Name="type3" OBJ-XID="xid_6624" H5Path="/group1/type3" Parents="xid_3960" H5ParentPaths="/group1"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:Group> <hdf5:Group Name="group2" OBJ-XID="xid_9512" H5Path="/group2" Parents="xid_696" H5ParentPaths="/" > <hdf5:Dataset Name="dset5" OBJ-XID="xid_9968" H5Path= "/group2/dset5" Parents="xid_9512" H5ParentPaths="/group2"> @@ -227,5 +176,56 @@ Expected output for 'h5dump --xml tcompound2.h5' </hdf5:Data> </hdf5:Dataset> </hdf5:Group> + <hdf5:NamedDataType Name="type1" OBJ-XID="xid_3280" H5Path="/type1" Parents="xid_696" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int_name"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float_name"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> + <hdf5:NamedDataType Name="type2" OBJ-XID="xid_6544" H5Path="/type2" Parents="xid_696" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="int_array"> + <hdf5:DataType> + <hdf5:ArrayType Ndims="1"> + <hdf5:ArrayDimension DimSize="4"/> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:ArrayType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="float_array"> + <hdf5:DataType> + <hdf5:ArrayType Ndims="2"> + <hdf5:ArrayDimension DimSize="5"/> + <hdf5:ArrayDimension DimSize="6"/> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:ArrayType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:RootGroup> </hdf5:HDF5-File> diff --git a/tools/testfiles/tnamed_dtype_attr.h5.xml b/tools/testfiles/tnamed_dtype_attr.h5.xml index 9d4a0c0..0b9ceae 100644 --- a/tools/testfiles/tnamed_dtype_attr.h5.xml +++ b/tools/testfiles/tnamed_dtype_attr.h5.xml @@ -4,13 +4,6 @@ Expected output for 'h5dump --xml tnamed_dtype_attr.h5' <?xml version="1.0" encoding="UTF-8"?> <hdf5:HDF5-File xmlns:hdf5="http://hdfgroup.org/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdfgroup.org/DTDs/HDF5File http://hdfgroup.org/DTDs/HDF5-File.xsd"> <hdf5:RootGroup OBJ-XID="xid_96" H5Path="/"> - <hdf5:NamedDataType Name="Datatype" OBJ-XID="xid_792" H5Path="/Datatype" Parents="xid_96" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="LE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="Dataset" OBJ-XID="xid_1264" H5Path= "/Dataset" Parents="xid_96" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> @@ -39,6 +32,13 @@ Expected output for 'h5dump --xml tnamed_dtype_attr.h5' <hdf5:NoData/> </hdf5:Data> </hdf5:Dataset> + <hdf5:NamedDataType Name="Datatype" OBJ-XID="xid_792" H5Path="/Datatype" Parents="xid_96" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="LE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:NamedDataType> <hdf5:Group Name="g1" OBJ-XID="xid_1536" H5Path="/g1" Parents="xid_96" H5ParentPaths="/" > <hdf5:Attribute Name="Attribute"> <hdf5:Dataspace> diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl index a516dde..9eb9f88 100644 --- a/tools/testfiles/tnofilename.ddl +++ b/tools/testfiles/tnofilename.ddl @@ -25,7 +25,7 @@ usage: h5dump [OPTIONS] file with -o (output file) and -d (dataset). B can be: MEMORY for a memory type, FILE for the file type, LE or BE for pre-existing little or big endian types - -t P, --datatype=P Print the specified named data type + -t P, --datatype=P Print the specified named datatype -w N, --width=N Set the number of columns of output -x, --xml Output in XML using Schema -u, --use-dtd Output in XML using DTD diff --git a/tools/testfiles/tobjref.h5.xml b/tools/testfiles/tobjref.h5.xml index 57cb64b..327291e 100644 --- a/tools/testfiles/tobjref.h5.xml +++ b/tools/testfiles/tobjref.h5.xml @@ -35,33 +35,6 @@ Expected output for 'h5dump --xml tobjref.h5' </hdf5:Data> </hdf5:Dataset> <hdf5:Group Name="Group1" OBJ-XID="xid_1320" H5Path="/Group1" Parents="xid_696" H5ParentPaths="/" > - <hdf5:NamedDataType Name="Datatype1" OBJ-XID="xid_2268" H5Path="/Group1/Datatype1" Parents="xid_1320" H5ParentPaths="/Group1"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="a"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="b"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="c"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="Dataset1" OBJ-XID="xid_1696" H5Path= "/Group1/Dataset1" Parents="xid_1320" H5ParentPaths="/Group1"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> @@ -112,6 +85,33 @@ Expected output for 'h5dump --xml tobjref.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> + <hdf5:NamedDataType Name="Datatype1" OBJ-XID="xid_2268" H5Path="/Group1/Datatype1" Parents="xid_1320" H5ParentPaths="/Group1"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="a"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="b"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="c"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:FloatType ByteOrder="BE" Size="4" SignBitLocation="31" ExponentBits="8" ExponentLocation="23" MantissaBits="23" MantissaLocation="0" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:Group> </hdf5:RootGroup> </hdf5:HDF5-File> diff --git a/tools/testfiles/tref.h5.xml b/tools/testfiles/tref.h5.xml index 5edd4d2..6b093de 100644 --- a/tools/testfiles/tref.h5.xml +++ b/tools/testfiles/tref.h5.xml @@ -4,35 +4,6 @@ Expected output for 'h5dump --xml tref.h5' <?xml version="1.0" encoding="UTF-8"?> <hdf5:HDF5-File xmlns:hdf5="http://hdfgroup.org/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdfgroup.org/DTDs/HDF5File http://hdfgroup.org/DTDs/HDF5-File.xsd"> <hdf5:RootGroup OBJ-XID="xid_696" H5Path="/"> - <hdf5:Dataset Name="ZZZDataset3" OBJ-XID="xid_2612" H5Path= "/ZZZDataset3" Parents="xid_696" H5ParentPaths="/"> - <hdf5:StorageLayout> - <hdf5:ContiguousLayout/> - </hdf5:StorageLayout> - <hdf5:FillValueInfo FillTime="FillIfSet" AllocationTime="Late"> - <hdf5:FillValue> - <hdf5:NoFill/> - </hdf5:FillValue> - </hdf5:FillValueInfo> - <hdf5:Dataspace> - <hdf5:SimpleDataspace Ndims="1"> - <hdf5:Dimension DimSize="3" MaxDimSize="3"/> - </hdf5:SimpleDataspace> - </hdf5:Dataspace> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:ReferenceType> - <hdf5:ObjectReferenceType /> - </hdf5:ReferenceType> - </hdf5:AtomicType> - </hdf5:DataType> - <hdf5:Data> - <hdf5:DataFromFile> - "/Group1/Dataset1" - "/Group1/Dataset2" - "/Group1" - </hdf5:DataFromFile> - </hdf5:Data> - </hdf5:Dataset> <hdf5:Group Name="Group1" OBJ-XID="xid_1344" H5Path="/Group1" Parents="xid_696" H5ParentPaths="/" > <hdf5:Dataset Name="Dataset1" OBJ-XID="xid_1720" H5Path= "/Group1/Dataset1" Parents="xid_1344" H5ParentPaths="/Group1"> <hdf5:StorageLayout> @@ -85,5 +56,34 @@ Expected output for 'h5dump --xml tref.h5' </hdf5:Data> </hdf5:Dataset> </hdf5:Group> + <hdf5:Dataset Name="ZZZDataset3" OBJ-XID="xid_2612" H5Path= "/ZZZDataset3" Parents="xid_696" H5ParentPaths="/"> + <hdf5:StorageLayout> + <hdf5:ContiguousLayout/> + </hdf5:StorageLayout> + <hdf5:FillValueInfo FillTime="FillIfSet" AllocationTime="Late"> + <hdf5:FillValue> + <hdf5:NoFill/> + </hdf5:FillValue> + </hdf5:FillValueInfo> + <hdf5:Dataspace> + <hdf5:SimpleDataspace Ndims="1"> + <hdf5:Dimension DimSize="3" MaxDimSize="3"/> + </hdf5:SimpleDataspace> + </hdf5:Dataspace> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:ReferenceType> + <hdf5:ObjectReferenceType /> + </hdf5:ReferenceType> + </hdf5:AtomicType> + </hdf5:DataType> + <hdf5:Data> + <hdf5:DataFromFile> + "/Group1/Dataset1" + "/Group1/Dataset2" + "/Group1" + </hdf5:DataFromFile> + </hdf5:Data> + </hdf5:Dataset> </hdf5:RootGroup> </hdf5:HDF5-File> diff --git a/tools/testfiles/tsaf.h5.xml b/tools/testfiles/tsaf.h5.xml index 8c44bab..3f4ef38 100644 --- a/tools/testfiles/tsaf.h5.xml +++ b/tools/testfiles/tsaf.h5.xml @@ -307,6 +307,295 @@ Expected output for 'h5dump --xml tsaf.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> + <hdf5:Group Name=".attributes" OBJ-XID="xid_5072" H5Path="/.attributes" Parents="xid_696" H5ParentPaths="/" > + <hdf5:Group Name="database" OBJ-XID="xid_5728" H5Path="/.attributes/database" Parents="xid_5072" H5ParentPaths="/.attributes" > + <hdf5:Dataset Name=".SAF_DbProps" OBJ-XID="xid_6104" H5Path= "/.attributes/database/.SAF_DbProps" Parents="xid_5728" H5ParentPaths="/.attributes/database"> + <hdf5:StorageLayout> + <hdf5:ContiguousLayout/> + </hdf5:StorageLayout> + <hdf5:FillValueInfo FillTime="FillIfSet" AllocationTime="Late"> + <hdf5:FillValue> + <hdf5:NoFill/> + </hdf5:FillValue> + </hdf5:FillValueInfo> + <hdf5:Dataspace> + <hdf5:SimpleDataspace Ndims="1"> + <hdf5:Dimension DimSize="1" MaxDimSize="1"/> + </hdf5:SimpleDataspace> + </hdf5:Dataspace> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="magic"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="SFileDir"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="1024" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="ImportFile"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="1024" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="parallel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="safapi"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="saflib"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vbt"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="dsl"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="hdf5"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="mpi"> + <hdf5:DataType> + <hdf5:CompoundType> + <hdf5:Field FieldName="vmajor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="vminor"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="rel"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="annot"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="DoToc"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="ReadOnly"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="Clobber"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + <hdf5:Field FieldName="OSModes"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:Field> + </hdf5:CompoundType> + </hdf5:DataType> + <!-- Note: format of compound data not specified --> + <hdf5:Data> + <hdf5:DataFromFile> + -604320037 "." "don't import" 1 0 0 0 "none" 0 1 0 "devel" 1 3 0 "" 0 0 0 "none" 1 2 1 "" 1 2 0 "" 1 0 1 0 + </hdf5:DataFromFile> + </hdf5:Data> + </hdf5:Dataset> + </hdf5:Group> + </hdf5:Group> <hdf5:Dataset Name="Blob" OBJ-XID="xid_17612" H5Path= "/Blob" Parents="xid_696" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ChunkedLayout Ndims="1"> @@ -2628,294 +2917,5 @@ Expected output for 'h5dump --xml tsaf.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> - <hdf5:Group Name=".attributes" OBJ-XID="xid_5072" H5Path="/.attributes" Parents="xid_696" H5ParentPaths="/" > - <hdf5:Group Name="database" OBJ-XID="xid_5728" H5Path="/.attributes/database" Parents="xid_5072" H5ParentPaths="/.attributes" > - <hdf5:Dataset Name=".SAF_DbProps" OBJ-XID="xid_6104" H5Path= "/.attributes/database/.SAF_DbProps" Parents="xid_5728" H5ParentPaths="/.attributes/database"> - <hdf5:StorageLayout> - <hdf5:ContiguousLayout/> - </hdf5:StorageLayout> - <hdf5:FillValueInfo FillTime="FillIfSet" AllocationTime="Late"> - <hdf5:FillValue> - <hdf5:NoFill/> - </hdf5:FillValue> - </hdf5:FillValueInfo> - <hdf5:Dataspace> - <hdf5:SimpleDataspace Ndims="1"> - <hdf5:Dimension DimSize="1" MaxDimSize="1"/> - </hdf5:SimpleDataspace> - </hdf5:Dataspace> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="magic"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="SFileDir"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="1024" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="ImportFile"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="1024" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="parallel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="safapi"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="saflib"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vbt"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="dsl"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="hdf5"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="mpi"> - <hdf5:DataType> - <hdf5:CompoundType> - <hdf5:Field FieldName="vmajor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="vminor"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="rel"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="annot"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="10" StrPad="H5T_STR_NULLTERM"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="DoToc"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="ReadOnly"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="Clobber"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - <hdf5:Field FieldName="OSModes"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:Field> - </hdf5:CompoundType> - </hdf5:DataType> - <!-- Note: format of compound data not specified --> - <hdf5:Data> - <hdf5:DataFromFile> - -604320037 "." "don't import" 1 0 0 0 "none" 0 1 0 "devel" 1 3 0 "" 0 0 0 "none" 1 2 1 "" 1 2 0 "" 1 0 1 0 - </hdf5:DataFromFile> - </hdf5:Data> - </hdf5:Dataset> - </hdf5:Group> - </hdf5:Group> </hdf5:RootGroup> </hdf5:HDF5-File> diff --git a/tools/testfiles/tvlstr.h5.xml b/tools/testfiles/tvlstr.h5.xml index 8a0a180..98a3b30 100644 --- a/tools/testfiles/tvlstr.h5.xml +++ b/tools/testfiles/tvlstr.h5.xml @@ -15,13 +15,6 @@ Expected output for 'h5dump --xml tvlstr.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Attribute> - <hdf5:NamedDataType Name="vl_string_type" OBJ-XID="xid_1576" H5Path="/vl_string_type" Parents="xid_928" H5ParentPaths="/"> - <hdf5:DataType> - <hdf5:AtomicType> - <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="H5T_VARIABLE" StrPad="H5T_STR_NULLPAD"/> - </hdf5:AtomicType> - </hdf5:DataType> - </hdf5:NamedDataType> <hdf5:Dataset Name="Dataset1" OBJ-XID="xid_976" H5Path= "/Dataset1" Parents="xid_928" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> @@ -53,5 +46,12 @@ Expected output for 'h5dump --xml tvlstr.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> + <hdf5:NamedDataType Name="vl_string_type" OBJ-XID="xid_1576" H5Path="/vl_string_type" Parents="xid_928" H5ParentPaths="/"> + <hdf5:DataType> + <hdf5:AtomicType> + <hdf5:StringType Cset="H5T_CSET_ASCII" StrSize="H5T_VARIABLE" StrPad="H5T_STR_NULLPAD"/> + </hdf5:AtomicType> + </hdf5:DataType> + </hdf5:NamedDataType> </hdf5:RootGroup> </hdf5:HDF5-File> |