mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
cleanup of whitespace in HDF5 directory
This commit is contained in:
parent
8b1f5a8fad
commit
c771443e43
File diff suppressed because it is too large
Load Diff
3418
libhdf5/hdf5open.c
3418
libhdf5/hdf5open.c
File diff suppressed because it is too large
Load Diff
@ -34,64 +34,64 @@ extern int
|
||||
NC4_inq_type_equal(int ncid1, nc_type typeid1, int ncid2,
|
||||
nc_type typeid2, int *equalp)
|
||||
{
|
||||
NC_GRP_INFO_T *grpone, *grptwo;
|
||||
NC_TYPE_INFO_T *type1, *type2;
|
||||
int retval;
|
||||
NC_GRP_INFO_T *grpone, *grptwo;
|
||||
NC_TYPE_INFO_T *type1, *type2;
|
||||
int retval;
|
||||
|
||||
LOG((2, "nc_inq_type_equal: ncid1 0x%x typeid1 %d ncid2 0x%x typeid2 %d",
|
||||
ncid1, typeid1, ncid2, typeid2));
|
||||
LOG((2, "nc_inq_type_equal: ncid1 0x%x typeid1 %d ncid2 0x%x typeid2 %d",
|
||||
ncid1, typeid1, ncid2, typeid2));
|
||||
|
||||
/* Check input. */
|
||||
if(equalp == NULL) return NC_NOERR;
|
||||
/* Check input. */
|
||||
if(equalp == NULL) return NC_NOERR;
|
||||
|
||||
if (typeid1 <= NC_NAT || typeid2 <= NC_NAT)
|
||||
return NC_EINVAL;
|
||||
if (typeid1 <= NC_NAT || typeid2 <= NC_NAT)
|
||||
return NC_EINVAL;
|
||||
|
||||
/* If one is atomic, and the other user-defined, the types are not
|
||||
* equal. */
|
||||
if ((typeid1 <= NC_STRING && typeid2 > NC_STRING) ||
|
||||
(typeid2 <= NC_STRING && typeid1 > NC_STRING))
|
||||
{
|
||||
*equalp = 0;
|
||||
return NC_NOERR;
|
||||
}
|
||||
/* If one is atomic, and the other user-defined, the types are not
|
||||
* equal. */
|
||||
if ((typeid1 <= NC_STRING && typeid2 > NC_STRING) ||
|
||||
(typeid2 <= NC_STRING && typeid1 > NC_STRING))
|
||||
{
|
||||
*equalp = 0;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/* If both are atomic types, the answer is easy. */
|
||||
if (typeid1 <= NUM_ATOMIC_TYPES)
|
||||
{
|
||||
if (typeid1 == typeid2)
|
||||
*equalp = 1;
|
||||
else
|
||||
*equalp = 0;
|
||||
return NC_NOERR;
|
||||
}
|
||||
/* If both are atomic types, the answer is easy. */
|
||||
if (typeid1 <= NUM_ATOMIC_TYPES)
|
||||
{
|
||||
if (typeid1 == typeid2)
|
||||
*equalp = 1;
|
||||
else
|
||||
*equalp = 0;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/* Not atomic types - so find type1 and type2 information. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid1, &grpone)))
|
||||
return retval;
|
||||
if (!(type1 = nclistget(grpone->nc4_info->alltypes, typeid1)))
|
||||
return NC_EBADTYPE;
|
||||
if ((retval = nc4_find_nc4_grp(ncid2, &grptwo)))
|
||||
return retval;
|
||||
if (!(type2 = nclistget(grptwo->nc4_info->alltypes, typeid2)))
|
||||
return NC_EBADTYPE;
|
||||
/* Not atomic types - so find type1 and type2 information. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid1, &grpone)))
|
||||
return retval;
|
||||
if (!(type1 = nclistget(grpone->nc4_info->alltypes, typeid1)))
|
||||
return NC_EBADTYPE;
|
||||
if ((retval = nc4_find_nc4_grp(ncid2, &grptwo)))
|
||||
return retval;
|
||||
if (!(type2 = nclistget(grptwo->nc4_info->alltypes, typeid2)))
|
||||
return NC_EBADTYPE;
|
||||
|
||||
/* Are the two types equal? */
|
||||
{
|
||||
hid_t hid1, hid2;
|
||||
/* Are the two types equal? */
|
||||
{
|
||||
hid_t hid1, hid2;
|
||||
|
||||
/* Get the HDF5 types from the HDF5-specific type info. */
|
||||
assert(type1->format_type_info && type2->format_type_info);
|
||||
hid1 = ((NC_HDF5_TYPE_INFO_T *)type1->format_type_info)->native_hdf_typeid;
|
||||
hid2 = ((NC_HDF5_TYPE_INFO_T *)type2->format_type_info)->native_hdf_typeid;
|
||||
/* Get the HDF5 types from the HDF5-specific type info. */
|
||||
assert(type1->format_type_info && type2->format_type_info);
|
||||
hid1 = ((NC_HDF5_TYPE_INFO_T *)type1->format_type_info)->native_hdf_typeid;
|
||||
hid2 = ((NC_HDF5_TYPE_INFO_T *)type2->format_type_info)->native_hdf_typeid;
|
||||
|
||||
/* Ask HDF5 if the types are equal. */
|
||||
if ((retval = H5Tequal(hid1, hid2)) < 0)
|
||||
return NC_EHDFERR;
|
||||
*equalp = 1 ? retval : 0;
|
||||
}
|
||||
/* Ask HDF5 if the types are equal. */
|
||||
if ((retval = H5Tequal(hid1, hid2)) < 0)
|
||||
return NC_EHDFERR;
|
||||
*equalp = 1 ? retval : 0;
|
||||
}
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,65 +111,65 @@ NC4_inq_type_equal(int ncid1, nc_type typeid1, int ncid2,
|
||||
extern int
|
||||
NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
|
||||
{
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_GRP_INFO_T *grptwo;
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_TYPE_INFO_T *type = NULL;
|
||||
char *norm_name;
|
||||
int i, retval;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_GRP_INFO_T *grptwo;
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_TYPE_INFO_T *type = NULL;
|
||||
char *norm_name;
|
||||
int i, retval;
|
||||
|
||||
/* Handle atomic types. */
|
||||
for (i = 0; i < NUM_ATOMIC_TYPES; i++)
|
||||
if (!strcmp(name, nc4_atomic_name[i]))
|
||||
{
|
||||
if (typeidp)
|
||||
*typeidp = i;
|
||||
return NC_NOERR;
|
||||
}
|
||||
/* Handle atomic types. */
|
||||
for (i = 0; i < NUM_ATOMIC_TYPES; i++)
|
||||
if (!strcmp(name, nc4_atomic_name[i]))
|
||||
{
|
||||
if (typeidp)
|
||||
*typeidp = i;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5 && grp);
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5 && grp);
|
||||
|
||||
/* If the first char is a /, this is a fully-qualified
|
||||
* name. Otherwise, this had better be a local name (i.e. no / in
|
||||
* the middle). */
|
||||
if (name[0] != '/' && strstr(name, "/"))
|
||||
return NC_EINVAL;
|
||||
/* If the first char is a /, this is a fully-qualified
|
||||
* name. Otherwise, this had better be a local name (i.e. no / in
|
||||
* the middle). */
|
||||
if (name[0] != '/' && strstr(name, "/"))
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Normalize name. */
|
||||
if (!(norm_name = (char*)malloc(strlen(name) + 1)))
|
||||
return NC_ENOMEM;
|
||||
if ((retval = nc4_normalize_name(name, norm_name))) {
|
||||
free(norm_name);
|
||||
return retval;
|
||||
}
|
||||
/* Is the type in this group? If not, search parents. */
|
||||
for (grptwo = grp; grptwo; grptwo = grptwo->parent) {
|
||||
type = (NC_TYPE_INFO_T*)ncindexlookup(grptwo->type,norm_name);
|
||||
if(type)
|
||||
{
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Normalize name. */
|
||||
if (!(norm_name = (char*)malloc(strlen(name) + 1)))
|
||||
return NC_ENOMEM;
|
||||
if ((retval = nc4_normalize_name(name, norm_name))) {
|
||||
free(norm_name);
|
||||
return retval;
|
||||
}
|
||||
/* Is the type in this group? If not, search parents. */
|
||||
for (grptwo = grp; grptwo; grptwo = grptwo->parent) {
|
||||
type = (NC_TYPE_INFO_T*)ncindexlookup(grptwo->type,norm_name);
|
||||
if(type)
|
||||
{
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Still didn't find type? Search file recursively, starting at the
|
||||
* root group. */
|
||||
if (!type)
|
||||
if ((type = nc4_rec_find_named_type(grp->nc4_info->root_grp, norm_name)))
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
/* Still didn't find type? Search file recursively, starting at the
|
||||
* root group. */
|
||||
if (!type)
|
||||
if ((type = nc4_rec_find_named_type(grp->nc4_info->root_grp, norm_name)))
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
|
||||
free(norm_name);
|
||||
free(norm_name);
|
||||
|
||||
/* OK, I give up already! */
|
||||
if (!type)
|
||||
return NC_EBADTYPE;
|
||||
/* OK, I give up already! */
|
||||
if (!type)
|
||||
return NC_EBADTYPE;
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,71 +196,71 @@ static int
|
||||
add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
|
||||
nc_type type_class, nc_type *typeidp)
|
||||
{
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
NC_HDF5_TYPE_INFO_T *hdf5_type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
NC_HDF5_TYPE_INFO_T *hdf5_type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(name, norm_name)))
|
||||
return retval;
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(name, norm_name)))
|
||||
return retval;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x size %d name %s base_typeid %d ",
|
||||
__FUNCTION__, ncid, size, norm_name, base_typeid));
|
||||
LOG((2, "%s: ncid 0x%x size %d name %s base_typeid %d ",
|
||||
__FUNCTION__, ncid, size, norm_name, base_typeid));
|
||||
|
||||
/* Find group metadata. */
|
||||
if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5 && grp);
|
||||
/* Find group metadata. */
|
||||
if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5 && grp);
|
||||
|
||||
/* User types cannot be defined with classic model flag. */
|
||||
if (h5->cmode & NC_CLASSIC_MODEL)
|
||||
return NC_ESTRICTNC3;
|
||||
/* User types cannot be defined with classic model flag. */
|
||||
if (h5->cmode & NC_CLASSIC_MODEL)
|
||||
return NC_ESTRICTNC3;
|
||||
|
||||
/* Turn on define mode if it is not on. */
|
||||
if (!(h5->cmode & NC_INDEF))
|
||||
if ((retval = NC4_redef(ncid)))
|
||||
return retval;
|
||||
/* Turn on define mode if it is not on. */
|
||||
if (!(h5->cmode & NC_INDEF))
|
||||
if ((retval = NC4_redef(ncid)))
|
||||
return retval;
|
||||
|
||||
/* No size is provided for vlens or enums, get it from the base type. */
|
||||
if (type_class == NC_VLEN || type_class == NC_ENUM)
|
||||
{
|
||||
if ((retval = nc4_get_typelen_mem(grp->nc4_info, base_typeid, &size)))
|
||||
return retval;
|
||||
}
|
||||
else if (size <= 0)
|
||||
return NC_EINVAL;
|
||||
/* No size is provided for vlens or enums, get it from the base type. */
|
||||
if (type_class == NC_VLEN || type_class == NC_ENUM)
|
||||
{
|
||||
if ((retval = nc4_get_typelen_mem(grp->nc4_info, base_typeid, &size)))
|
||||
return retval;
|
||||
}
|
||||
else if (size <= 0)
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Check that this name is not in use as a var, grp, or type. */
|
||||
if ((retval = nc4_check_dup_name(grp, norm_name)))
|
||||
return retval;
|
||||
/* Check that this name is not in use as a var, grp, or type. */
|
||||
if ((retval = nc4_check_dup_name(grp, norm_name)))
|
||||
return retval;
|
||||
|
||||
/* Add to our list of types. */
|
||||
if ((retval = nc4_type_list_add(grp, size, norm_name, &type)))
|
||||
return retval;
|
||||
/* Add to our list of types. */
|
||||
if ((retval = nc4_type_list_add(grp, size, norm_name, &type)))
|
||||
return retval;
|
||||
|
||||
/* Allocate storage for HDF5-specific type info. */
|
||||
if (!(hdf5_type = calloc(1, sizeof(NC_HDF5_TYPE_INFO_T))))
|
||||
return NC_ENOMEM;
|
||||
type->format_type_info = hdf5_type;
|
||||
/* Allocate storage for HDF5-specific type info. */
|
||||
if (!(hdf5_type = calloc(1, sizeof(NC_HDF5_TYPE_INFO_T))))
|
||||
return NC_ENOMEM;
|
||||
type->format_type_info = hdf5_type;
|
||||
|
||||
/* Remember info about this type. */
|
||||
type->nc_type_class = type_class;
|
||||
if (type_class == NC_VLEN)
|
||||
type->u.v.base_nc_typeid = base_typeid;
|
||||
else if (type_class == NC_ENUM) {
|
||||
type->u.e.base_nc_typeid = base_typeid;
|
||||
type->u.e.enum_member = nclistnew();
|
||||
} else if (type_class == NC_COMPOUND)
|
||||
type->u.c.field = nclistnew();
|
||||
/* Remember info about this type. */
|
||||
type->nc_type_class = type_class;
|
||||
if (type_class == NC_VLEN)
|
||||
type->u.v.base_nc_typeid = base_typeid;
|
||||
else if (type_class == NC_ENUM) {
|
||||
type->u.e.base_nc_typeid = base_typeid;
|
||||
type->u.e.enum_member = nclistnew();
|
||||
} else if (type_class == NC_COMPOUND)
|
||||
type->u.c.field = nclistnew();
|
||||
|
||||
/* Return the typeid to the user. */
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
/* Return the typeid to the user. */
|
||||
if (typeidp)
|
||||
*typeidp = type->hdr.id;
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,7 +283,7 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
|
||||
int
|
||||
NC4_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp)
|
||||
{
|
||||
return add_user_type(ncid, size, name, 0, NC_COMPOUND, typeidp);
|
||||
return add_user_type(ncid, size, name, 0, NC_COMPOUND, typeidp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -305,8 +305,8 @@ int
|
||||
NC4_insert_compound(int ncid, nc_type typeid1, const char *name, size_t offset,
|
||||
nc_type field_typeid)
|
||||
{
|
||||
return nc_insert_array_compound(ncid, typeid1, name, offset,
|
||||
field_typeid, 0, NULL);
|
||||
return nc_insert_array_compound(ncid, typeid1, name, offset,
|
||||
field_typeid, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,42 +331,42 @@ NC4_insert_array_compound(int ncid, int typeid1, const char *name,
|
||||
size_t offset, nc_type field_typeid,
|
||||
int ndims, const int *dim_sizesp)
|
||||
{
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
|
||||
LOG((2, "nc_insert_array_compound: ncid 0x%x, typeid %d name %s "
|
||||
"offset %d field_typeid %d ndims %d", ncid, typeid1,
|
||||
name, offset, field_typeid, ndims));
|
||||
LOG((2, "nc_insert_array_compound: ncid 0x%x, typeid %d name %s "
|
||||
"offset %d field_typeid %d ndims %d", ncid, typeid1,
|
||||
name, offset, field_typeid, ndims));
|
||||
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(name, norm_name)))
|
||||
return retval;
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(name, norm_name)))
|
||||
return retval;
|
||||
|
||||
/* Find file metadata. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
|
||||
return retval;
|
||||
/* Find file metadata. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
|
||||
return retval;
|
||||
|
||||
/* Find type metadata. */
|
||||
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
|
||||
return retval;
|
||||
/* Find type metadata. */
|
||||
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
|
||||
return retval;
|
||||
|
||||
/* Did the user give us a good compound type typeid? */
|
||||
if (!type || type->nc_type_class != NC_COMPOUND)
|
||||
return NC_EBADTYPE;
|
||||
/* Did the user give us a good compound type typeid? */
|
||||
if (!type || type->nc_type_class != NC_COMPOUND)
|
||||
return NC_EBADTYPE;
|
||||
|
||||
/* If this type has already been written to the file, you can't
|
||||
* change it. */
|
||||
if (type->committed)
|
||||
return NC_ETYPDEFINED;
|
||||
/* If this type has already been written to the file, you can't
|
||||
* change it. */
|
||||
if (type->committed)
|
||||
return NC_ETYPDEFINED;
|
||||
|
||||
/* Insert new field into this type's list of fields. */
|
||||
if ((retval = nc4_field_list_add(type, norm_name, offset, field_typeid,
|
||||
ndims, dim_sizesp)))
|
||||
return retval;
|
||||
/* Insert new field into this type's list of fields. */
|
||||
if ((retval = nc4_field_list_add(type, norm_name, offset, field_typeid,
|
||||
ndims, dim_sizesp)))
|
||||
return retval;
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/* Opaque type. */
|
||||
@ -392,7 +392,7 @@ int
|
||||
NC4_def_opaque(int ncid, size_t datum_size, const char *name,
|
||||
nc_type *typeidp)
|
||||
{
|
||||
return add_user_type(ncid, datum_size, name, 0, NC_OPAQUE, typeidp);
|
||||
return add_user_type(ncid, datum_size, name, 0, NC_OPAQUE, typeidp);
|
||||
}
|
||||
|
||||
|
||||
@ -416,7 +416,7 @@ int
|
||||
NC4_def_vlen(int ncid, const char *name, nc_type base_typeid,
|
||||
nc_type *typeidp)
|
||||
{
|
||||
return add_user_type(ncid, 0, name, base_typeid, NC_VLEN, typeidp);
|
||||
return add_user_type(ncid, 0, name, base_typeid, NC_VLEN, typeidp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -440,7 +440,7 @@ int
|
||||
NC4_def_enum(int ncid, nc_type base_typeid, const char *name,
|
||||
nc_type *typeidp)
|
||||
{
|
||||
return add_user_type(ncid, 0, name, base_typeid, NC_ENUM, typeidp);
|
||||
return add_user_type(ncid, 0, name, base_typeid, NC_ENUM, typeidp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,41 +463,41 @@ int
|
||||
NC4_insert_enum(int ncid, nc_type typeid1, const char *identifier,
|
||||
const void *value)
|
||||
{
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_TYPE_INFO_T *type;
|
||||
char norm_name[NC_MAX_NAME + 1];
|
||||
int retval;
|
||||
|
||||
LOG((2, "nc_insert_enum: ncid 0x%x, typeid %d identifier %s value %d", ncid,
|
||||
typeid1, identifier, value));
|
||||
LOG((2, "nc_insert_enum: ncid 0x%x, typeid %d identifier %s value %d", ncid,
|
||||
typeid1, identifier, value));
|
||||
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(identifier, norm_name)))
|
||||
return retval;
|
||||
/* Check and normalize the name. */
|
||||
if ((retval = nc4_check_name(identifier, norm_name)))
|
||||
return retval;
|
||||
|
||||
/* Find file metadata. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
|
||||
return retval;
|
||||
/* Find file metadata. */
|
||||
if ((retval = nc4_find_nc4_grp(ncid, &grp)))
|
||||
return retval;
|
||||
|
||||
/* Find type metadata. */
|
||||
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
|
||||
return retval;
|
||||
/* Find type metadata. */
|
||||
if ((retval = nc4_find_type(grp->nc4_info, typeid1, &type)))
|
||||
return retval;
|
||||
|
||||
/* Did the user give us a good enum typeid? */
|
||||
if (!type || type->nc_type_class != NC_ENUM)
|
||||
return NC_EBADTYPE;
|
||||
/* Did the user give us a good enum typeid? */
|
||||
if (!type || type->nc_type_class != NC_ENUM)
|
||||
return NC_EBADTYPE;
|
||||
|
||||
/* If this type has already been written to the file, you can't
|
||||
* change it. */
|
||||
if (type->committed)
|
||||
return NC_ETYPDEFINED;
|
||||
/* If this type has already been written to the file, you can't
|
||||
* change it. */
|
||||
if (type->committed)
|
||||
return NC_ETYPDEFINED;
|
||||
|
||||
/* Insert new field into this type's list of fields. */
|
||||
if ((retval = nc4_enum_member_add(type, type->size,
|
||||
norm_name, value)))
|
||||
return retval;
|
||||
/* Insert new field into this type's list of fields. */
|
||||
if ((retval = nc4_enum_member_add(type, type->size,
|
||||
norm_name, value)))
|
||||
return retval;
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,10 +517,10 @@ int
|
||||
NC4_put_vlen_element(int ncid, int typeid1, void *vlen_element,
|
||||
size_t len, const void *data)
|
||||
{
|
||||
nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
|
||||
tmp->len = len;
|
||||
tmp->p = (void *)data;
|
||||
return NC_NOERR;
|
||||
nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
|
||||
tmp->len = len;
|
||||
tmp->p = (void *)data;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,10 +540,10 @@ int
|
||||
NC4_get_vlen_element(int ncid, int typeid1, const void *vlen_element,
|
||||
size_t *len, void *data)
|
||||
{
|
||||
const nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
|
||||
int type_size = 4;
|
||||
const nc_vlen_t *tmp = (nc_vlen_t*)vlen_element;
|
||||
int type_size = 4;
|
||||
|
||||
*len = tmp->len;
|
||||
memcpy(data, tmp->p, tmp->len * type_size);
|
||||
return NC_NOERR;
|
||||
*len = tmp->len;
|
||||
memcpy(data, tmp->p, tmp->len * type_size);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user