static int ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type) { switch(type) { case NC_CHAR: return NC_ECHAR; case NC_BYTE: return ncx_pad_getn_schar_int(xpp, nelems, tp); case NC_SHORT: return ncx_pad_getn_short_int(xpp, nelems, tp); case NC_INT: return ncx_getn_int_int(xpp, nelems, tp); case NC_FLOAT: return ncx_getn_float_int(xpp, nelems, tp); case NC_DOUBLE: return ncx_getn_double_int(xpp, nelems, tp); case NC_UBYTE: return ncx_pad_getn_uchar_int(xpp, nelems, tp); case NC_USHORT: return ncx_getn_ushort_int(xpp, nelems, tp); case NC_UINT: return ncx_getn_uint_int(xpp, nelems, tp); case NC_INT64: return ncx_getn_longlong_int(xpp, nelems, tp); case NC_UINT64: return ncx_getn_ulonglong_int(xpp, nelems, tp); default: assert("ncx_pad_getn_Iint invalid type" == 0); } return NC_EBADTYPE; }
/* Read a NC_var from the header */ static int v1h_get_NC_var(v1hs *gsp, NC_var **varpp) { NC_string *strp; int status; size_t ndims; NC_var *varp; status = v1h_get_NC_string(gsp, &strp); if(status != ENOERR) return status; status = v1h_get_size_t(gsp, &ndims); if(status != ENOERR) goto unwind_name; varp = new_x_NC_var(strp, ndims); if(varp == NULL) { status = NC_ENOMEM; goto unwind_name; } if (gsp->version == 5) { status = check_v1hs(gsp, ncx_len_int64(ndims)); if(status != ENOERR) goto unwind_alloc; status = ncx_getn_longlong_int((const void **)(&gsp->pos), ndims, varp->dimids); if(status != ENOERR) goto unwind_alloc; } else { status = check_v1hs(gsp, ncx_len_int(ndims)); if(status != ENOERR) goto unwind_alloc; status = ncx_getn_int_int((const void **)(&gsp->pos), ndims, varp->dimids); if(status != ENOERR) goto unwind_alloc; } status = v1h_get_NC_attrarray(gsp, &varp->attrs); if(status != ENOERR) goto unwind_alloc; status = v1h_get_nc_type(gsp, &varp->type); if(status != ENOERR) goto unwind_alloc; status = v1h_get_size_t(gsp, &varp->len); if(status != ENOERR) goto unwind_alloc; status = check_v1hs(gsp, gsp->version == 1 ? 4 : 8); if(status != ENOERR) goto unwind_alloc; status = ncx_get_off_t((const void **)&gsp->pos, &varp->begin, gsp->version == 1 ? 4 : 8); if(status != ENOERR) goto unwind_alloc; *varpp = varp; return ENOERR; unwind_alloc: free_NC_var(varp); /* frees name */ return status; unwind_name: free_NC_string(strp); return status; }