static bool do_binread(void *item,int nitem,int eio, const char *desc,const char *srcfile,int line) { size_t size=0,rsize; int ssize; check_nitem(); switch (eio) { case eioREAL: if (curfio->bDouble) size = sizeof(double); else size = sizeof(float); break; case eioDOUBLE: size = sizeof(double); break; case eioINT: size = sizeof(int); break; case eioGMX_STEP_T: size = sizeof(gmx_step_t); break; case eioUCHAR: size = sizeof(unsigned char); break; case eioNUCHAR: size = sizeof(unsigned char); break; case eioUSHORT: size = sizeof(unsigned short); break; case eioRVEC: case eioNRVEC: if (curfio->bDouble) size = sizeof(double)*DIM; else size = sizeof(float)*DIM; break; case eioIVEC: size = sizeof(ivec); break; case eioSTRING: do_binread(&ssize,1,eioINT,desc,srcfile,line); size = ssize; break; default: FE(); } if (item) rsize = fread(item,size,nitem,curfio->fp); else { /* Skip over it if we have a NULL pointer here */ #ifdef HAVE_FSEEKO fseeko(curfio->fp,(off_t)(size*nitem),SEEK_CUR); #else fseek(curfio->fp,(size*nitem),SEEK_CUR); #endif rsize = nitem; } if ((rsize != nitem) && (curfio->bDebug)) fprintf(stderr,"Error reading %s %s from file %s (source %s, line %d)\n", eioNames[eio],desc,curfio->fn,srcfile,line); return (rsize == nitem); }
static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, const char *desc, const char *srcfile, int line) { size_t size = 0, rsize; int ssize; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { case eioREAL: if (fio->bDouble) { size = sizeof(double); } else { size = sizeof(float); } break; case eioFLOAT: size = sizeof(float); break; case eioDOUBLE: size = sizeof(double); break; case eioINT: size = sizeof(int); break; case eioGMX_LARGE_INT: size = sizeof(gmx_large_int_t); break; case eioUCHAR: size = sizeof(unsigned char); break; case eioNUCHAR: size = sizeof(unsigned char); break; case eioUSHORT: size = sizeof(unsigned short); break; case eioRVEC: case eioNRVEC: if (fio->bDouble) { size = sizeof(double) * DIM; } else { size = sizeof(float) * DIM; } break; case eioIVEC: size = sizeof(ivec); break; case eioSTRING: do_binread(fio, &ssize, 1, eioINT, desc, srcfile, line); size = ssize; break; default: gmx_fio_fe(fio, eio, desc, srcfile, line); } if (item) { rsize = fread(item, size, nitem, fio->fp); } else { /* Skip over it if we have a NULL pointer here */ gmx_fseek(fio->fp, (gmx_off_t)(size*nitem), SEEK_CUR); rsize = nitem; } if ((rsize != nitem) && (fio->bDebug)) { fprintf(stderr, "Error reading %s %s from file %s (source %s, line %d)\n", eioNames[eio], desc, fio->fn, srcfile, line); } return (rsize == nitem); }