Example #1
0
static int
ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type)
{
	switch(type) {
	case NC_CHAR:
		return NC_ECHAR;
	case NC_BYTE:
		return ncx_pad_putn_schar_int(xpp, nelems, tp);
	case NC_SHORT:
		return ncx_pad_putn_short_int(xpp, nelems, tp);
	case NC_INT:
		return ncx_putn_int_int(xpp, nelems, tp);
	case NC_FLOAT:
		return ncx_putn_float_int(xpp, nelems, tp);
	case NC_DOUBLE:
		return ncx_putn_double_int(xpp, nelems, tp);
	case NC_UBYTE:
		return ncx_pad_putn_uchar_int(xpp, nelems, tp);
	case NC_USHORT:
		return ncx_putn_ushort_int(xpp, nelems, tp);
	case NC_UINT:
		return ncx_putn_uint_int(xpp, nelems, tp);
	case NC_INT64:
		return ncx_putn_longlong_int(xpp, nelems, tp);
	case NC_UINT64:
		return ncx_putn_ulonglong_int(xpp, nelems, tp);
	default:
                assert("ncx_pad_putn_Iint invalid type" == 0);
	}
	return NC_EBADTYPE;
}
Example #2
0
/* Write a NC_var to the header */
static int
v1h_put_NC_var(v1hs *psp, const NC_var *varp)
{
	int status;

	status = v1h_put_NC_string(psp, varp->name);
	if(status != ENOERR)
		return status;

	status = v1h_put_size_t(psp, &varp->ndims);
	if(status != ENOERR)
		return status;

	if (psp->version == 5) {
		status = check_v1hs(psp, ncx_len_int64(varp->ndims));
		if(status != ENOERR)
			return status;
		status = ncx_putn_longlong_int(&psp->pos,
				varp->ndims, varp->dimids);
		if(status != ENOERR)
			return status;
	}
	else {
  	    status = check_v1hs(psp, ncx_len_int(varp->ndims));
	    if(status != ENOERR)
		return status;
	    status = ncx_putn_int_int(&psp->pos,
			varp->ndims, varp->dimids);
	    if(status != ENOERR)
		return status;
	}

	status = v1h_put_NC_attrarray(psp, &varp->attrs);
	if(status != ENOERR)
		return status;

	status = v1h_put_nc_type(psp, &varp->type);
	if(status != ENOERR)
		return status;

	status = v1h_put_size_t(psp, &varp->len);
	if(status != ENOERR)
		return status;

	status = check_v1hs(psp, psp->version == 1 ? 4 : 8); /*begin*/
	if(status != ENOERR)
		 return status;
	status = ncx_put_off_t(&psp->pos, &varp->begin, psp->version == 1 ? 4 : 8);
	if(status != ENOERR)
		return status;

	return ENOERR;
}
static int
ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type)
{
  switch(type) {
  case NC_CHAR:
    return NC_ECHAR;
  case NC_BYTE:
    return ncx_pad_putn_schar_int(xpp, nelems, tp);
  case NC_SHORT:
    return ncx_pad_putn_short_int(xpp, nelems, tp);
  case NC_INT:
    return ncx_putn_int_int(xpp, nelems, tp);
  case NC_FLOAT:
    return ncx_putn_float_int(xpp, nelems, tp);
  case NC_DOUBLE:
    return ncx_putn_double_int(xpp, nelems, tp);
  case NC_NAT:
    break; /* Some compilers complain if enums are missing from a switch */
  }
  assert("ncx_pad_putn_Iint invalid type" == 0);
  return NC_EBADTYPE;
}