ECC-727: handle all versions of HDF5 Super Block (versions)

This commit is contained in:
Shahram Najm 2018-07-31 13:30:05 +01:00
parent 09116019e8
commit dec1eced12
2 changed files with 29 additions and 23 deletions

View File

@ -1,29 +1,31 @@
# http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock
constant identifier="HDF5";
ascii[8] signature : dump;
uint8 versionNumberOfSuperblock : dump;
if(versionNumberOfSuperblock == 2) {
uint8 sizeOfOffsets : dump;
uint8 sizeOfLength : dump;
uint8 fileConsistencyFlags : dump;
if (versionNumberOfSuperblock == 0 ||
versionNumberOfSuperblock == 1 ||
versionNumberOfSuperblock == 2 ||
versionNumberOfSuperblock == 3)
{
uint8 sizeOfOffsets : dump;
uint8 sizeOfLength : dump;
uint8 fileConsistencyFlags : dump;
if(sizeOfOffsets == 8) {
uint64_little_endian baseAddress : dump;
uint64_little_endian superblockExtensionAddress : dump;
uint64_little_endian endOfFileAddress : dump;
uint64_little_endian rootGroupObjectHeaderAddress : dump;
}
if(sizeOfOffsets == 8) {
uint64_little_endian baseAddress : dump;
uint64_little_endian superblockExtensionAddress : dump;
uint64_little_endian endOfFileAddress : dump;
uint64_little_endian rootGroupObjectHeaderAddress : dump;
}
if(sizeOfOffsets == 4) {
uint32_little_endian baseAddress : dump;
uint32_little_endian superblockExtensionAddress : dump;
uint32_little_endian endOfFileAddress : dump;
uint32_little_endian rootGroupObjectHeaderAddress : dump;
}
#ascii[4] superblockChecksum;
if(sizeOfOffsets == 4) {
uint32_little_endian baseAddress : dump;
uint32_little_endian superblockExtensionAddress : dump;
uint32_little_endian endOfFileAddress : dump;
uint32_little_endian rootGroupObjectHeaderAddress : dump;
}
#ascii[4] superblockChecksum;
}

View File

@ -491,7 +491,11 @@ static int read_HDF5_offset(reader *r, int length, unsigned long* v, unsigned ch
return 0;
}
static int check_hdf5_superblock_version(unsigned char version)
{
if (version==0 || version==1 || version==2 || version==3) return GRIB_SUCCESS;
return GRIB_INVALID_MESSAGE;
}
static int read_HDF5(reader *r)
{
/* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */
@ -529,9 +533,9 @@ static int read_HDF5(reader *r)
}
tmp[i++] = version_of_superblock;
if(version_of_superblock != 2) {
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid version_of_superblock: %ld, only version 2 is supported", (long)version_of_superblock);
err = check_hdf5_superblock_version(version_of_superblock);
if(err) {
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid version of superblock: %ld", (long)version_of_superblock);
return GRIB_NOT_IMPLEMENTED;
}