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,11 +1,14 @@
# http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock # http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock
constant identifier="HDF5"; constant identifier="HDF5";
ascii[8] signature : dump; ascii[8] signature : dump;
uint8 versionNumberOfSuperblock : dump; uint8 versionNumberOfSuperblock : dump;
if(versionNumberOfSuperblock == 2) { if (versionNumberOfSuperblock == 0 ||
versionNumberOfSuperblock == 1 ||
versionNumberOfSuperblock == 2 ||
versionNumberOfSuperblock == 3)
{
uint8 sizeOfOffsets : dump; uint8 sizeOfOffsets : dump;
uint8 sizeOfLength : dump; uint8 sizeOfLength : dump;
uint8 fileConsistencyFlags : dump; uint8 fileConsistencyFlags : dump;
@ -25,5 +28,4 @@ if(versionNumberOfSuperblock == 2) {
} }
#ascii[4] superblockChecksum; #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; 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) static int read_HDF5(reader *r)
{ {
/* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */ /* 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; tmp[i++] = version_of_superblock;
err = check_hdf5_superblock_version(version_of_superblock);
if(version_of_superblock != 2) { if(err) {
grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid version_of_superblock: %ld, only version 2 is supported", (long)version_of_superblock); grib_context_log(c, GRIB_LOG_ERROR,"read_HDF5: invalid version of superblock: %ld", (long)version_of_superblock);
return GRIB_NOT_IMPLEMENTED; return GRIB_NOT_IMPLEMENTED;
} }