예제 #1
0
파일: var.c 프로젝트: karoraw1/GLM_Wrapper
/*
 * Step thru NC_VARIABLE array, seeking match on name.
 * Return varid or -1 on not found.
 * *varpp is set to the appropriate NC_var.
 * Formerly (sort of)
NC_hvarid
 */
int
NC_findvar(const NC_vararray *ncap, const char *uname, NC_var **varpp)
{
	int hash_var_id;
	char *name;

	assert(ncap != NULL);

	if(ncap->nelems == 0)
		return -1;


	/* normalized version of uname */
	name = (char *)utf8proc_NFC((const unsigned char *)uname);
	if(name == NULL)
	    return NC_ENOMEM;

	hash_var_id = (int)NC_hashmapGetVar(ncap, name);
	free(name);
	if (hash_var_id >= 0) {
	  if (varpp != NULL)
	    *varpp = ncap->value[hash_var_id];
	  return(hash_var_id); /* Normal return */
	}
	return(-1); /* not found */
}
예제 #2
0
파일: var.c 프로젝트: Kitware/VTK
/*
 * Step thru NC_VARIABLE array, seeking match on name.
 * Return varid or -1 on not found.
 * *varpp is set to the appropriate NC_var.
 * Formerly (sort of)
NC_hvarid
 */
int
NC_findvar(const NC_vararray *ncap, const char *uname, NC_var **varpp)
{
	int hash_var_id;
	char *name;
	int stat;

	assert(ncap != NULL);

	if(ncap->nelems == 0)
		return -1;


	/* normalized version of uname */
        stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name);
        if(stat != NC_NOERR)
	    return stat;

	hash_var_id = (int)NC_hashmapGetVar(ncap, name);
	free(name);
	if (hash_var_id >= 0) {
	  if (varpp != NULL)
	    *varpp = ncap->value[hash_var_id];
	  return(hash_var_id); /* Normal return */
	}
	return(-1); /* not found */
}