Commit f8a564dc authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

now compiling with c++ and --with-grib_api

parent 73685001
...@@ -69,7 +69,7 @@ static inline void *gribHandleNew(int editionNumber) ...@@ -69,7 +69,7 @@ static inline void *gribHandleNew(int editionNumber)
static inline void gribHandleDelete(void *gh) static inline void gribHandleDelete(void *gh)
{ {
grib_handle_delete(gh); grib_handle_delete((struct grib_handle *)gh);
} }
#else #else
#define gribHandleNew(editionNumber) (NULL) #define gribHandleNew(editionNumber) (NULL)
......
...@@ -32,9 +32,9 @@ char* gribCopyString(grib_handle* gribHandle, const char* key) ...@@ -32,9 +32,9 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
#ifdef HAVE_GRIB_GET_LENGTH #ifdef HAVE_GRIB_GET_LENGTH
if(!grib_get_length(gribHandle, key, &length)) if(!grib_get_length(gribHandle, key, &length))
{ {
char* result = xmalloc(length); char* result = (char *)xmalloc(length);
if(!grib_get_string(gribHandle, key, result, &length)) if(!grib_get_string(gribHandle, key, result, &length))
result = xrealloc(result, length); result = (char *)xrealloc(result, length);
else else
{ {
free(result); free(result);
...@@ -47,7 +47,7 @@ char* gribCopyString(grib_handle* gribHandle, const char* key) ...@@ -47,7 +47,7 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
* this unlikely in grib_api versions * this unlikely in grib_api versions
* not providing grib_get_length */ * not providing grib_get_length */
int rc; int rc;
result = xmalloc(length); result = (char *)xmalloc(length);
while ((rc = grib_get_string(gribHandle, key, result, &length)) while ((rc = grib_get_string(gribHandle, key, result, &length))
== GRIB_BUFFER_TOO_SMALL || rc == GRIB_ARRAY_TOO_SMALL) == GRIB_BUFFER_TOO_SMALL || rc == GRIB_ARRAY_TOO_SMALL)
{ {
...@@ -78,7 +78,7 @@ bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expec ...@@ -78,7 +78,7 @@ bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expec
size_t length; size_t length;
if(grib_get_length(gribHandle, key, &length)) return false; if(grib_get_length(gribHandle, key, &length)) return false;
if(length != expectedLength) return false; if(length != expectedLength) return false;
char *value = xmalloc(length); char *value = (char *)xmalloc(length);
if(grib_get_string(gribHandle, key, value, &length)) return false; if(grib_get_string(gribHandle, key, value, &length)) return false;
int rc = !strcmp(value, expectedValue); int rc = !strcmp(value, expectedValue);
free(value); free(value);
...@@ -257,7 +257,7 @@ static int addToDate(struct tm* me, long long amount, long unit) ...@@ -257,7 +257,7 @@ static int addToDate(struct tm* me, long long amount, long unit)
static char* makeDateString(struct tm* me) static char* makeDateString(struct tm* me)
{ {
char *result char *result
= xmalloc( 4+1+ 2+1+ 2+1+ 2+1+ 2+1+ 2+ 4+ 1); = (char *)xmalloc( 4+1+ 2+1+ 2+1+ 2+1+ 2+1+ 2+ 4+ 1);
sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec); sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec);
return result; return result;
} }
...@@ -288,12 +288,21 @@ static int getAvailabilityOfRelativeTimes(grib_handle* gh, bool* outHaveForecast ...@@ -288,12 +288,21 @@ static int getAvailabilityOfRelativeTimes(grib_handle* gh, bool* outHaveForecast
char* gribMakeTimeString(grib_handle* gh, bool getEndTime) char* gribMakeTimeString(grib_handle* gh, bool getEndTime)
{ {
//Get the parts of the reference date. //Get the parts of the reference date.
#ifdef __cplusplus
struct tm date;
date.tm_mon = (int) gribGetLong(gh, "month") - 1; //months are zero based in struct tm and one based in GRIBy
date.tm_mday = (int)gribGetLong(gh, "day");
date.tm_hour = (int)gribGetLong(gh, "hour");
date.tm_min = (int)gribGetLong(gh, "minute");
#else
struct tm date = { struct tm date = {
.tm_mon = (int)gribGetLong(gh, "month") - 1, //months are zero based in struct tm and one based in GRIB .tm_mon = (int)gribGetLong(gh, "month") - 1, //months are zero based in struct tm and one based in GRIBy
.tm_mday = (int)gribGetLong(gh, "day"), .tm_mday = (int)gribGetLong(gh, "day"),
.tm_hour = (int)gribGetLong(gh, "hour"), .tm_hour = (int)gribGetLong(gh, "hour"),
.tm_min = (int)gribGetLong(gh, "minute") .tm_min = (int)gribGetLong(gh, "minute")
}; };
#endif
if(gribEditionNumber(gh) == 1) if(gribEditionNumber(gh) == 1)
{ {
date.tm_year = (int)gribGetLong(gh, "yearOfCentury"); //years are -1900 based both in struct tm and GRIB1 date.tm_year = (int)gribGetLong(gh, "yearOfCentury"); //years are -1900 based both in struct tm and GRIB1
......
...@@ -26,7 +26,7 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c ...@@ -26,7 +26,7 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c
{ {
#define super() (&me->super) #define super() (&me->super)
if(me) goto destruct; if(me) goto destruct;
me = xmalloc(sizeof(*me)); me = (CdiGribIterator *)xmalloc(sizeof(*me));
baseIterConstruct(super(), filetype); baseIterConstruct(super(), filetype);
me->file = cdiInputFile_make(path); me->file = cdiInputFile_make(path);
...@@ -45,7 +45,7 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c ...@@ -45,7 +45,7 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c
destruct: destruct:
if(me->super.gridId != CDI_UNDEFID) gridDestroy(me->super.gridId); if(me->super.gridId != CDI_UNDEFID) gridDestroy(me->super.gridId);
if(me->gribHandle) grib_handle_delete(me->gribHandle); if(me->gribHandle) grib_handle_delete((struct grib_handle *)me->gribHandle);
free(me->gribBuffer); free(me->gribBuffer);
cdiRefObject_release(&me->file->super); cdiRefObject_release(&me->file->super);
destructSuper: destructSuper:
...@@ -68,20 +68,19 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super) ...@@ -68,20 +68,19 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
//Allocate memory and copy data. (operations that may fail) //Allocate memory and copy data. (operations that may fail)
CdiGribIterator* result = xmalloc(sizeof(*result)); CdiGribIterator* result = (struct CdiGribIterator *)xmalloc(sizeof(*result));
if(!result) goto fail; if(!result) goto fail;
*result = (CdiGribIterator)
{ result->file = me->file;
.file = me->file, result->fileOffset = me->fileOffset;
.fileOffset = me->fileOffset, result->gribBuffer = NULL;
.gribBuffer = NULL, result->bufferSize = me->bufferSize;
.bufferSize = me->bufferSize, result->curRecordSize = me->curRecordSize;
.curRecordSize = me->curRecordSize, result->gribHandle = NULL;
.gribHandle = NULL
};
if(me->gribBuffer) if(me->gribBuffer)
{ {
result->gribBuffer = xmalloc(me->bufferSize); result->gribBuffer = (unsigned char *)xmalloc(me->bufferSize);
if(!result->gribBuffer) goto freeResult; if(!result->gribBuffer) goto freeResult;
memcpy(result->gribBuffer, me->gribBuffer, me->curRecordSize); memcpy(result->gribBuffer, me->gribBuffer, me->curRecordSize);
} }
...@@ -107,7 +106,7 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super) ...@@ -107,7 +106,7 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
//Error handling. //Error handling.
deleteGribHandle: deleteGribHandle:
if(result->gribHandle) grib_handle_delete(result->gribHandle); if(result->gribHandle) grib_handle_delete((grib_handle *)result->gribHandle);
freeBuffer: freeBuffer:
free(result->gribBuffer); free(result->gribBuffer);
freeResult: freeResult:
...@@ -120,9 +119,9 @@ char* cdiGribIterator_serialize(CdiIterator* super) ...@@ -120,9 +119,9 @@ char* cdiGribIterator_serialize(CdiIterator* super)
{ {
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
const char* path = cdiInputFile_getPath(me->file); const char* path = (char *)cdiInputFile_getPath(me->file);
char* escapedPath = cdiEscapeSpaces(path); char* escapedPath = (char *)cdiEscapeSpaces(path);
char* result = xmalloc(strlen(escapedPath) + 3 * sizeof(int) * CHAR_BIT/8); char* result = (char *)xmalloc(strlen(escapedPath) + 3 * sizeof(int) * CHAR_BIT/8);
sprintf(result, "%s %zu", escapedPath, me->fileOffset); sprintf(result, "%s %zu", escapedPath, me->fileOffset);
free(escapedPath); free(escapedPath);
return result; return result;
...@@ -132,7 +131,7 @@ char* cdiGribIterator_serialize(CdiIterator* super) ...@@ -132,7 +131,7 @@ char* cdiGribIterator_serialize(CdiIterator* super)
CdiGribIterator* cdiGribIterator_deserialize(const char* description) CdiGribIterator* cdiGribIterator_deserialize(const char* description)
{ {
char* path; char* path;
CdiGribIterator* me = xmalloc(sizeof(*me)); CdiGribIterator* me = (CdiGribIterator *)xmalloc(sizeof(*me));
if(!me) goto fail; if(!me) goto fail;
description = baseIter_constructFromString(&me->super, description); description = baseIter_constructFromString(&me->super, description);
...@@ -177,7 +176,7 @@ static void cdiGribIterator_ensureBuffer(CdiGribIterator* me, size_t requiredSiz ...@@ -177,7 +176,7 @@ static void cdiGribIterator_ensureBuffer(CdiGribIterator* me, size_t requiredSiz
{ {
me->bufferSize *= 2; me->bufferSize *= 2;
if(me->bufferSize < requiredSize) me->bufferSize = requiredSize; if(me->bufferSize < requiredSize) me->bufferSize = requiredSize;
me->gribBuffer = xrealloc(me->gribBuffer, me->bufferSize); me->gribBuffer = (unsigned char *)xrealloc(me->gribBuffer, me->bufferSize);
} }
} }
...@@ -197,7 +196,7 @@ static const unsigned char* positionOfGribMarker(const unsigned char* data, size ...@@ -197,7 +196,7 @@ static const unsigned char* positionOfGribMarker(const unsigned char* data, size
{ {
for(const unsigned char* currentPosition = data, *end = data + size; currentPosition < end; currentPosition++) for(const unsigned char* currentPosition = data, *end = data + size; currentPosition < end; currentPosition++)
{ {
currentPosition = memchr(currentPosition, 'G', size - (size_t)(currentPosition - data) - 3); //-3 to ensure that we don't overrun the buffer during the strncmp() call. currentPosition = (unsigned char *)memchr(currentPosition, 'G', size - (size_t)(currentPosition - data) - 3); //-3 to ensure that we don't overrun the buffer during the strncmp() call.
if(!currentPosition) return NULL; if(!currentPosition) return NULL;
if(!strncmp((const char*)currentPosition, "GRIB", 4)) return currentPosition; if(!strncmp((const char*)currentPosition, "GRIB", 4)) return currentPosition;
} }
...@@ -235,13 +234,13 @@ static ssize_t scanToGribMarker(CdiGribIterator* me) ...@@ -235,13 +234,13 @@ static ssize_t scanToGribMarker(CdiGribIterator* me)
static unsigned decode24(void* beData) static unsigned decode24(void* beData)
{ {
unsigned char* bytes = beData; unsigned char* bytes = (unsigned char *)beData;
return ((unsigned)bytes[0] << 16) + ((unsigned)bytes[1] << 8) + (unsigned)bytes[2]; return ((unsigned)bytes[0] << 16) + ((unsigned)bytes[1] << 8) + (unsigned)bytes[2];
} }
static uint64_t decode64(void* beData) static uint64_t decode64(void* beData)
{ {
unsigned char* bytes = beData; unsigned char* bytes = (unsigned char *)beData;
uint64_t result = 0; uint64_t result = 0;
for(size_t i = 0; i < 8; i++) result = (result << 8) + bytes[i]; for(size_t i = 0; i < 8; i++) result = (result << 8) + bytes[i];
return result; return result;
...@@ -302,7 +301,7 @@ static void hexdump(void* data, size_t size) ...@@ -302,7 +301,7 @@ static void hexdump(void* data, size_t size)
static int readMessage(CdiGribIterator* me) static int readMessage(CdiGribIterator* me)
{ {
//Destroy the old grib_handle. //Destroy the old grib_handle.
if(me->gribHandle) grib_handle_delete(me->gribHandle), me->gribHandle = NULL; if(me->gribHandle) grib_handle_delete((grib_handle *)me->gribHandle), me->gribHandle = NULL;
me->fileOffset += (off_t)me->curRecordSize; me->fileOffset += (off_t)me->curRecordSize;
//Find the next record and determine its size. //Find the next record and determine its size.
...@@ -338,11 +337,11 @@ int cdiGribIterator_nextField(CdiIterator* super) ...@@ -338,11 +337,11 @@ int cdiGribIterator_nextField(CdiIterator* super)
if(result) return result; if(result) return result;
//Get the metadata that's published as variables in the base class. //Get the metadata that's published as variables in the base class.
super->datatype = gribGetDatatype(me->gribHandle); super->datatype = gribGetDatatype((grib_handle *)me->gribHandle);
super->timesteptype = gribapiGetTsteptype(me->gribHandle); super->timesteptype = gribapiGetTsteptype((grib_handle *)me->gribHandle);
cdiDecodeParam(gribapiGetParam(me->gribHandle), &super->param.number, &super->param.category, &super->param.discipline); cdiDecodeParam(gribapiGetParam((grib_handle *)me->gribHandle), &super->param.number, &super->param.category, &super->param.discipline);
grid_t grid; grid_t grid;
gribapiGetGrid(me->gribHandle, &grid); gribapiGetGrid((grib_handle *)me->gribHandle, &grid);
super->gridId = gridGenerate(&grid); super->gridId = gridGenerate(&grid);
return CDI_NOERR; return CDI_NOERR;
...@@ -351,7 +350,7 @@ int cdiGribIterator_nextField(CdiIterator* super) ...@@ -351,7 +350,7 @@ int cdiGribIterator_nextField(CdiIterator* super)
char* cdiGribIterator_inqTime(CdiIterator* super, bool getEndTime) char* cdiGribIterator_inqTime(CdiIterator* super, bool getEndTime)
{ {
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
return gribMakeTimeString(me->gribHandle, getEndTime); return gribMakeTimeString((grib_handle *)me->gribHandle, getEndTime);
} }
int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit) int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
...@@ -360,15 +359,15 @@ int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outN ...@@ -360,15 +359,15 @@ int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outN
//First determine the zaxis type corresponding to the given level. //First determine the zaxis type corresponding to the given level.
int zaxisType = ZAXIS_GENERIC; int zaxisType = ZAXIS_GENERIC;
if(gribEditionNumber(me->gribHandle) <= 1) if(gribEditionNumber((grib_handle *)me->gribHandle) <= 1)
{ {
int levelType = (int)gribGetLongDefault(me->gribHandle, "indicatorOfTypeOfLevel", 255); int levelType = (int)gribGetLongDefault((grib_handle *)me->gribHandle, "indicatorOfTypeOfLevel", 255);
if(levelSelector && !isGrib1DualLevel(levelType)) levelType = 255; if(levelSelector && !isGrib1DualLevel(levelType)) levelType = 255;
zaxisType = grib1ltypeToZaxisType(levelType); zaxisType = grib1ltypeToZaxisType(levelType);
} }
else else
{ {
int levelType = (int)gribGetLongDefault(me->gribHandle, levelSelector ? "typeOfSecondFixedSurface" : "typeOfFirstFixedSurface", 255); int levelType = (int)gribGetLongDefault((grib_handle *)me->gribHandle, levelSelector ? "typeOfSecondFixedSurface" : "typeOfFirstFixedSurface", 255);
zaxisType = grib2ltypeToZaxisType(levelType); zaxisType = grib2ltypeToZaxisType(levelType);
} }
...@@ -448,33 +447,33 @@ int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValu ...@@ -448,33 +447,33 @@ int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValu
if(!outValue2) outValue2 = &trash; if(!outValue2) outValue2 = &trash;
*outValue1 = *outValue2 = 0; *outValue1 = *outValue2 = 0;
if(gribEditionNumber(me->gribHandle) > 1) if(gribEditionNumber((grib_handle *)me->gribHandle) > 1)
{ {
if(levelSelector) if(levelSelector)
{ {
return readLevel2(me->gribHandle, "typeOfFirstFixedSurface", "scaleFactorOfFirstFixedSurface", "scaledValueOfFirstFixedSurface", outValue1, outValue2); return readLevel2((grib_handle *)me->gribHandle, "typeOfFirstFixedSurface", "scaleFactorOfFirstFixedSurface", "scaledValueOfFirstFixedSurface", outValue1, outValue2);
} }
else else
{ {
return readLevel2(me->gribHandle, "typeOfSecondFixedSurface", "scaleFactorOfSecondFixedSurface", "scaledValueOfSecondFixedSurface", outValue1, outValue2); return readLevel2((grib_handle *)me->gribHandle, "typeOfSecondFixedSurface", "scaleFactorOfSecondFixedSurface", "scaledValueOfSecondFixedSurface", outValue1, outValue2);
} }
} }
else else
{ {
long levelType = (uint8_t)gribGetLongDefault(me->gribHandle, "indicatorOfTypeOfLevel", -1); //1 byte long levelType = (uint8_t)gribGetLongDefault((grib_handle *)me->gribHandle, "indicatorOfTypeOfLevel", -1); //1 byte
if(levelType == 255) if(levelType == 255)
{} {}
else if(isGrib1DualLevel((int)levelType)) else if(isGrib1DualLevel((int)levelType))
{ {
*outValue1 = (double)gribGetLongDefault(me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0); *outValue1 = (double)gribGetLongDefault((grib_handle *)me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0);
} }
else if(levelType == 100) else if(levelType == 100)
{ {
*outValue1 = 100 * (double)gribGetLongDefault(me->gribHandle, "level", 0); //2 bytes *outValue1 = 100 * (double)gribGetLongDefault((grib_handle *)me->gribHandle, "level", 0); //2 bytes
} }
else else
{ {
*outValue1 = (double)gribGetLongDefault(me->gribHandle, "level", 0); //2 bytes *outValue1 = (double)gribGetLongDefault((grib_handle *)me->gribHandle, "level", 0); //2 bytes
} }
} }
return CDI_NOERR; return CDI_NOERR;
...@@ -487,19 +486,19 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL ...@@ -487,19 +486,19 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL
if(outVgridNumber) if(outVgridNumber)
{ {
long temp; long temp;
if(grib_get_long(me->gribHandle, "numberOfVGridUsed", &temp)) return CDI_EINVAL; if(grib_get_long((grib_handle *)me->gribHandle, "numberOfVGridUsed", &temp)) return CDI_EINVAL;
*outVgridNumber = (int)temp; *outVgridNumber = (int)temp;
} }
if(outLevelCount) if(outLevelCount)
{ {
long temp; long temp;
if(grib_get_long(me->gribHandle, "nlev", &temp)) return CDI_EINVAL; if(grib_get_long((grib_handle *)me->gribHandle, "nlev", &temp)) return CDI_EINVAL;
*outLevelCount = (int)temp; *outLevelCount = (int)temp;
} }
if(outUuid) if(outUuid)
{ {
size_t size = sizeof(*outUuid); size_t size = sizeof(*outUuid);
if(grib_get_bytes(me->gribHandle, "uuidOfVGrid", *outUuid, &size)) return CDI_EINVAL; if(grib_get_bytes((grib_handle *)me->gribHandle, "uuidOfVGrid", *outUuid, &size)) return CDI_EINVAL;
if(size != sizeof(*outUuid)) return CDI_EUFSTRUCT; if(size != sizeof(*outUuid)) return CDI_EUFSTRUCT;
} }
...@@ -509,18 +508,18 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL ...@@ -509,18 +508,18 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL
char* cdiGribIterator_copyVariableName(CdiIterator* super) char* cdiGribIterator_copyVariableName(CdiIterator* super)
{ {
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
return gribCopyString(me->gribHandle, "shortName"); return gribCopyString((grib_handle *)me->gribHandle, "shortName");
} }
void cdiGribIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss) void cdiGribIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss)
{ {
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
gribGetDoubleArray(me->gribHandle, "values", buffer); gribGetDoubleArray((grib_handle *)me->gribHandle, "values", buffer);
long gridType = gribGetLong(me->gribHandle, "gridDefinitionTemplateNumber"); long gridType = gribGetLong((grib_handle *)me->gribHandle, "gridDefinitionTemplateNumber");
if(nmiss) if(nmiss)
{ {
*nmiss = (gridType >= 50 && gridType <= 53) ? (size_t)0 : (size_t)gribGetLong(me->gribHandle, "numberOfMissing"); //The condition excludes harmonic data. *nmiss = (gridType >= 50 && gridType <= 53) ? (size_t)0 : (size_t)gribGetLong((grib_handle *)me->gribHandle, "numberOfMissing"); //The condition excludes harmonic data.
} }
} }
...@@ -528,8 +527,8 @@ void cdiGribIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss ...@@ -528,8 +527,8 @@ void cdiGribIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss
{ {
CdiGribIterator* me = (CdiGribIterator*)super; CdiGribIterator* me = (CdiGribIterator*)super;
size_t valueCount = gribGetArraySize(me->gribHandle, "values"); size_t valueCount = gribGetArraySize((grib_handle *)me->gribHandle, "values");
double* temp = malloc(valueCount*sizeof(*temp)); double* temp = (double *)malloc(valueCount*sizeof(*temp));
cdiGribIterator_readField(super, temp, nmiss); cdiGribIterator_readField(super, temp, nmiss);
for(size_t i = valueCount; i--; ) buffer[i] = (float)temp[i]; for(size_t i = valueCount; i--; ) buffer[i] = (float)temp[i];
free(temp); free(temp);
...@@ -578,7 +577,7 @@ void cdiGribIterator_delete(CdiGribIterator* me) ...@@ -578,7 +577,7 @@ void cdiGribIterator_delete(CdiGribIterator* me)
int cdiGribIterator_inqEdition(CdiGribIterator* me) int cdiGribIterator_inqEdition(CdiGribIterator* me)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return (int)gribEditionNumber(me->gribHandle); return (int)gribEditionNumber((grib_handle *)me->gribHandle);
#else #else
(void)me; (void)me;
xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with"); xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
...@@ -602,7 +601,7 @@ int cdiGribIterator_inqEdition(CdiGribIterator* me) ...@@ -602,7 +601,7 @@ int cdiGribIterator_inqEdition(CdiGribIterator* me)
int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result) int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return grib_get_long(me->gribHandle, key, result); return grib_get_long((grib_handle *)me->gribHandle, key, result);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -628,7 +627,7 @@ int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result) ...@@ -628,7 +627,7 @@ int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result) int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result)
{ {
#ifdef HAVE_GRIB_GET_LENGTH #ifdef HAVE_GRIB_GET_LENGTH
return grib_get_length(me->gribHandle, key, result); return grib_get_length((grib_handle *)me->gribHandle, key, result);
#elif defined(HAVE_LIBGRIB_API) #elif defined(HAVE_LIBGRIB_API)
(void)me; (void)me;
(void)key; (void)key;
...@@ -660,7 +659,7 @@ int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* resu ...@@ -660,7 +659,7 @@ int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* resu
int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length) int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return grib_get_string(me->gribHandle, key, result, length); return grib_get_string((grib_handle *)me->gribHandle, key, result, length);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -688,7 +687,7 @@ int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result ...@@ -688,7 +687,7 @@ int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result
long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key) long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return gribGetLong(me->gribHandle, key); return gribGetLong((grib_handle *)me->gribHandle, key);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -715,7 +714,7 @@ long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key) ...@@ -715,7 +714,7 @@ long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue) long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return gribGetLongDefault(me->gribHandle, key, defaultValue); return gribGetLongDefault((grib_handle *)me->gribHandle, key, defaultValue);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -743,7 +742,7 @@ long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, l ...@@ -743,7 +742,7 @@ long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, l
char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key) char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return gribCopyString(me->gribHandle, key); return gribCopyString((grib_handle *)me->gribHandle, key);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -768,7 +767,7 @@ char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key) ...@@ -768,7 +767,7 @@ char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result) int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return grib_get_double(me->gribHandle, key, result); return grib_get_double((grib_handle *)me->gribHandle, key, result);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -794,7 +793,7 @@ int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* resu ...@@ -794,7 +793,7 @@ int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* resu
int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result) int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result)
{ {
#ifdef HAVE_LIBGRIB_API #ifdef HAVE_LIBGRIB_API
return grib_get_size(me->gribHandle, key, result); return grib_get_size((grib_handle *)me->gribHandle, key, result);
#else #else
(void)me; (void)me;
(void)key; (void)key;
...@@ -820,7 +819,7 @@ int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result ...@@ -820,7 +819,7 @@ int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result
int cdiGribIterator_getLongArray(CdiGribIterator* me, const char*