/* Copyright 2018, UCAR/Unidata. See the COPYRIGHT file for more information. */ #include "d4includes.h" #include /* Provide a simple dump of binary data */ /**************************************************/ void NCD4_dumpbytes(size_t size, const void* data0, int swap) { size_t extended; void* data = NULL; char* pos = NULL; size_t i; extended = size + 8; data = calloc(1,extended); /* provide some space to simplify the code */ memcpy(data,data0,size); fprintf(stderr," C XU8 U8 I8 XU32 U32 I32 I16 I64 F32\t\t\tF64\n"); for(i=0,pos=data;i= 0x7f) v.s[0] = '?'; fprintf(stderr,"[%04lu]", (unsigned long)i); fprintf(stderr," '%s'",v.s); fprintf(stderr," %03x %03u %04d", v.u8[0], v.u8[0], v.i8[0]); fprintf(stderr," 0x%08x %012u %013d", v.u32[0], v.u32[0], v.i32[0]); fprintf(stderr," %07d", v.i16[0]); fprintf(stderr," %020lld", v.i64[0]); fprintf(stderr," %4.4g\t\t%4.4lg", v.f32[0], v.f64[0]); fprintf(stderr,"\n"); fflush(stderr); } nullfree(data); } void NCD4_tagdump(size_t size, const void* data0, int swap, const char* tag) { fprintf(stderr,"++++++++++ %s ++++++++++\n",tag); NCD4_dumpbytes(size,data0,swap); fprintf(stderr,"++++++++++ %s ++++++++++\n",tag); fflush(stderr); } /* Dump the variables in a group */ void NCD4_dumpvars(NCD4node* group) { size_t i; fprintf(stderr,"%s.vars:\n",group->name); for(i=0;ivars);i++) { NCD4node* var = (NCD4node*)nclistget(group->vars,i); NCD4node* type; switch (var->subsort) { default: type = var->basetype; fprintf(stderr,"<%s name=\"%s\"/>\n",type->name,var->name); break; case NC_STRUCT: fprintf(stderr,"<%s name=\"%s\"/>\n","Struct",var->name); break; case NC_SEQ: fprintf(stderr,"<%s name=\"%s\"/>\n","Sequence",var->name); break; } } fflush(stderr); } union ATOMICS* NCD4_dumpatomic(NCD4node* var, void* data) { union ATOMICS* p = (union ATOMICS*)data; return p; }