/********************************************************************* * Copyright 2018, UCAR/Unidata * See netcdf/COPYRIGHT file for copying and redistribution conditions. *********************************************************************/ #include "config.h" #include #include "netcdf.h" #ifdef _MSC_VER #include #endif /* Code taken directly from libdap4/dapcvt.c */ /* Forward */ static size_t nctypesizeof(nc_type nctype); int NCD4_convert(nc_type srctype, nc_type dsttype, char* memory0, char* value0, size_t count) { int ncstat = NC_NOERR; size_t i; char* memory = memory0; char* value = value0; /* In order to deal with the DAP upgrade problem, try to preserve the bit patterns */ /* Provide space and pointer casts for intermediate results */ signed char ncbyte; signed char* ncbytep; char ncchar; char* nccharp; short ncshort; short* ncshortp; int ncint; int* ncintp; float ncfloat; float* ncfloatp; double ncdouble; double* ncdoublep; unsigned char ncubyte; unsigned char* ncubytep; unsigned short ncushort; unsigned short* ncushortp; unsigned int ncuint; unsigned int* ncuintp; long long ncint64; long long* ncint64p; unsigned long long ncuint64; unsigned long long* ncuint64p; #define CASE(nc1,nc2) (nc1*256+nc2) #define CUT8(e) ((unsigned char)((e) & 0xff)) #define CUT16(e) ((unsigned short)((e) & 0xffff)) #define CUT32(e) ((unsigned int)((e) & 0xffffffff)) #define ARM(vs,ncs,ts,vd,ncd,td) \ case CASE(ncs,ncd):\ vs##p = (ts *)value;\ vs = *vs##p;\ vd##p = (td *)memory;\ *vd##p = (td)vs;\ break; for(i=0;i