diff --git a/app/cdi.c b/app/cdi.c index 39b1e0678f081bcc54d9315e2542f640c9414ae4..18df1e676aeb51f4f54822d0ae7b8e491127dacd 100644 --- a/app/cdi.c +++ b/app/cdi.c @@ -430,25 +430,26 @@ printShortinfo(int streamID, int vlistID, int vardis) // datatype int datatype = vlistInqVarDatatype(vlistID, varID); // clang-format off - if (datatype == CDI_DATATYPE_PACK ) strcpy(pstr, "P0"); - else if (datatype > 0 && datatype <= 32 ) sprintf(pstr, "P%d", datatype); - else if (datatype == CDI_DATATYPE_CPX32 ) strcpy(pstr, "C32"); - else if (datatype == CDI_DATATYPE_CPX64 ) strcpy(pstr, "C64"); - else if (datatype == CDI_DATATYPE_FLT32 ) strcpy(pstr, "F32"); - else if (datatype == CDI_DATATYPE_FLT64 ) strcpy(pstr, "F64"); - else if (datatype == CDI_DATATYPE_INT8 ) strcpy(pstr, "I8"); - else if (datatype == CDI_DATATYPE_INT16 ) strcpy(pstr, "I16"); - else if (datatype == CDI_DATATYPE_INT32 ) strcpy(pstr, "I32"); - else if (datatype == CDI_DATATYPE_UINT8 ) strcpy(pstr, "U8"); - else if (datatype == CDI_DATATYPE_UINT16) strcpy(pstr, "U16"); - else if (datatype == CDI_DATATYPE_UINT32) strcpy(pstr, "U32"); - else strcpy(pstr, "-1"); + if (datatype == CDI_DATATYPE_PACK ) strcpy(pstr, "P0"); + else if (datatype > 0 && datatype <= 32 ) sprintf(pstr, "P%d", datatype); + else if (datatype == CDI_DATATYPE_CPX32 ) strcpy(pstr, "C32"); + else if (datatype == CDI_DATATYPE_CPX64 ) strcpy(pstr, "C64"); + else if (datatype == CDI_DATATYPE_FLT32 ) strcpy(pstr, "F32"); + else if (datatype == CDI_DATATYPE_FLT64 ) strcpy(pstr, "F64"); + else if (datatype == CDI_DATATYPE_INT8 ) strcpy(pstr, "I8"); + else if (datatype == CDI_DATATYPE_INT16 ) strcpy(pstr, "I16"); + else if (datatype == CDI_DATATYPE_INT32 ) strcpy(pstr, "I32"); + else if (datatype == CDI_DATATYPE_UINT8 ) strcpy(pstr, "U8"); + else if (datatype == CDI_DATATYPE_UINT16) strcpy(pstr, "U16"); + else if (datatype == CDI_DATATYPE_UINT32) strcpy(pstr, "U32"); + else strcpy(pstr, "-1"); // clang-format on fprintf(stdout, " %-3s", pstr); - bool isCompressed = (vlistInqVarCompType(vlistID, varID) != CDI_COMPRESS_NONE); - fprintf(stdout, "%c ", isCompressed ? 'z' : ' '); + int compType = vlistInqVarCompType(vlistID, varID); + bool isCompressed = (compType != CDI_COMPRESS_NONE); + fprintf(stdout, "%c ", isCompressed ? (int) comptype_to_name(compType)[0] : ' '); // parameter info fprintf(stdout, ": "); diff --git a/app/printinfo.c b/app/printinfo.c index ae96a0f0420ef33d61e43ddec3273306f91cd0b3..51cbd1866408195b1c1fbeeef2587d2e9d604e19 100644 --- a/app/printinfo.c +++ b/app/printinfo.c @@ -50,13 +50,16 @@ time2str(CdiTime time, char *timestr, int maxlen) } const char * -comp_name(int comptype) +comptype_to_name(int compType) { - if (comptype == CDI_COMPRESS_SZIP) return "szip"; - if (comptype == CDI_COMPRESS_AEC) return "aec"; - if (comptype == CDI_COMPRESS_ZIP) return "zip"; - if (comptype == CDI_COMPRESS_JPEG) return "jpeg"; - if (comptype == CDI_COMPRESS_FILTER) return "filter"; + switch (compType) + { + case CDI_COMPRESS_SZIP: return "szip"; + case CDI_COMPRESS_AEC: return "aec"; + case CDI_COMPRESS_ZIP: return "zip"; + case CDI_COMPRESS_JPEG: return "jpeg"; + case CDI_COMPRESS_FILTER: return "filter"; + } return " "; } @@ -66,7 +69,7 @@ printFiletype(int streamID, int vlistID) int filetype = streamInqFiletype(streamID); // clang-format off - switch ( filetype ) + switch (filetype) { case CDI_FILETYPE_GRB: printf("GRIB"); break; case CDI_FILETYPE_GRB2: printf("GRIB2"); break; @@ -82,9 +85,9 @@ printFiletype(int streamID, int vlistID) default: printf(" File format: unsupported filetype %d" , filetype); break; } - if ( filetype == CDI_FILETYPE_SRV || filetype == CDI_FILETYPE_EXT || filetype == CDI_FILETYPE_IEG ) + if (filetype == CDI_FILETYPE_SRV || filetype == CDI_FILETYPE_EXT || filetype == CDI_FILETYPE_IEG) { - switch ( streamInqByteorder(streamID) ) + switch (streamInqByteorder(streamID)) { case CDI_BIGENDIAN: printf(" BIGENDIAN"); break; case CDI_LITTLEENDIAN: printf(" LITTLEENDIAN"); break; @@ -102,7 +105,7 @@ printFiletype(int streamID, int vlistID) int comptype = vlistInqVarCompType(vlistID, varID); if (comptype == comps[k]) { - printf("%c%s", (kk++ == 0) ? ' ' : '/', comp_name(comptype)); + printf("%c%s", (kk++ == 0) ? ' ' : '/', comptype_to_name(comptype)); break; } } diff --git a/app/printinfo.h b/app/printinfo.h index 69a30c96384a225a3f600e02cbf0423019e25fad..3b14dfff4e4e6640b9d8fb758d5b1ee844c2ac52 100644 --- a/app/printinfo.h +++ b/app/printinfo.h @@ -7,7 +7,7 @@ void datetime2str(CdiDateTime dt, char *datetimestr, int maxlen); void date2str(CdiDate date, char *datestr, int maxlen); void time2str(CdiTime time, char *timestr, int maxlen); -const char *comp_name(int comptype); +const char *comptype_to_name(int comptype); void printFiletype(int streamID, int vlistID); void printGridInfo(int vlistID);