Commit e1d58c6b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

app/cdi: added support for DATATYPE_CPX

parent e50f57ff
......@@ -523,7 +523,7 @@ void setDefaultDataType(char *datatypestr)
{
static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
int nbits = -1;
enum {D_UINT, D_INT, D_FLT};
enum {D_UINT, D_INT, D_FLT, D_CPX};
int dtype = -1;
if ( *datatypestr == 'i' || *datatypestr == 'I' )
......@@ -541,6 +541,11 @@ void setDefaultDataType(char *datatypestr)
dtype = D_FLT;
datatypestr++;
}
else if ( *datatypestr == 'c' || *datatypestr == 'C' )
{
dtype = D_CPX;
datatypestr++;
}
if ( isdigit((int) *datatypestr) )
{
......@@ -564,7 +569,7 @@ void setDefaultDataType(char *datatypestr)
else
{
fprintf(stderr, "Unsupported number of bits %d!\n", nbits);
fprintf(stderr, "Use 32/64 for filetype nc, srv, ext, ieg and 1-32 for grb.\n");
fprintf(stderr, "Use I8/I16/I32/F32/F64 for nc/nc2/nc4/nc4c; F32/F64 for grb2/srv/ext/ieg; P1 - P24 for grb/grb2.\n");
exit(EXIT_FAILURE);
}
}
......@@ -602,20 +607,37 @@ void setDefaultDataType(char *datatypestr)
exit(EXIT_FAILURE);
}
}
else if ( dtype == D_CPX )
{
if ( nbits == 32 ) DefaultDataType = DATATYPE_CPX32;
else if ( nbits == 64 ) DefaultDataType = DATATYPE_CPX64;
else
{
fprintf(stderr, "Unsupported number of bits = %d for datatype CPX!\n", nbits);
exit(EXIT_FAILURE);
}
}
}
}
if ( *datatypestr != 0 )
{
if ( *datatypestr == 'l' || *datatypestr == 'L' )
{
if ( IsBigendian() ) DefaultByteorder = CDI_LITTLEENDIAN;
datatypestr++;
}
if ( *datatypestr == 'b' || *datatypestr == 'B' )
else if ( *datatypestr == 'b' || *datatypestr == 'B' )
{
if ( ! IsBigendian() ) DefaultByteorder = CDI_BIGENDIAN;
datatypestr++;
}
else
{
fprintf(stderr, "Unsupported character in number of bytes: >%s< !\n", datatypestr);
exit(EXIT_FAILURE);
}
}
}
static
......@@ -655,14 +677,14 @@ void setDefaultFileType(char *filetypestr)
fprintf(stderr, "Unexpected character >%c< in file type >%s<!\n", *ftstr, filetypestr);
fprintf(stderr, "Use format[_nbits] with:\n");
fprintf(stderr, " format = grb, grb2, nc, nc2, nc4, nc4c, srv, ext or ieg\n");
fprintf(stderr, " nbits = 32/64 for nc/nc2/nc4/nc4c/srv/ext/ieg; 1 - 24 for grb/grb2\n");
fprintf(stderr, " nbits = 32/64 for grb2/nc/nc2/nc4/nc4c/srv/ext/ieg; 1 - 24 for grb/grb2\n");
exit(EXIT_FAILURE);
}
}
}
}
static
int handle_error(int cdiErrno, const char *fmt, ...)
{
va_list args;
......@@ -680,7 +702,7 @@ int handle_error(int cdiErrno, const char *fmt, ...)
return (cdiErrno);
}
static
void defineCompress(const char *arg)
{
size_t len = strlen(arg);
......@@ -788,10 +810,7 @@ int main(int argc, char *argv[])
if ( optind < argc ) fname1 = argv[optind++];
if ( optind < argc ) fname2 = argv[optind++];
if ( optind < argc )
{
fprintf(stderr, "optind: %d argc: %d\n", optind, argc);
}
if ( optind < argc ) fprintf(stderr, "optind: %d argc: %d\n", optind, argc);
if ( Debug || Version ) version();
......@@ -1025,12 +1044,3 @@ int main(int argc, char *argv[])
return (0);
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment