Commit 212256a1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced vlistDefVarName()/vlistInqVarName() by...

Replaced vlistDefVarName()/vlistInqVarName() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_NAME.
parent ee3ebf79
2020-06-10 Uwe Schulzweida
* Replaced vlistDefVarName()/vlistInqVarName() by cdiDefKeyString()/cdiInqKeyString() with CDI_KEY_NAME
2020-05-15 Uwe Schulzweida 2020-05-15 Uwe Schulzweida
* Erroneous behaviour setting GRIB2 bitsPerValue (bug fix) [report: Florian Prill] * Erroneous behaviour setting GRIB2 bitsPerValue (bug fix) [report: Florian Prill]
......
vlistDefVarName(vlistID, varID, name) -> cdiDefKeyString(vlistID, varID, CDI_KEY_NAME, name)
vlistInqVarName(vlistID, varID, name) -> cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length) // partly obsolete
gridDefXname(gridID, xname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_NAME, xname) gridDefXname(gridID, xname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_NAME, xname)
gridDefXlongname(gridID, xlongname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_LONGNAME, xlongname) gridDefXlongname(gridID, xlongname) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_LONGNAME, xlongname)
gridDefXunits(gridID, xunits) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_UNITS, xunits) gridDefXunits(gridID, xunits) -> cdiDefKeyString(gridID, CDI_XAXIS, CDI_KEY_UNITS, xunits)
......
...@@ -782,8 +782,9 @@ int cdfDefVar(stream_t *streamptr, int varID) ...@@ -782,8 +782,9 @@ int cdfDefVar(stream_t *streamptr, int varID)
size_t chunks[4]; size_t chunks[4];
int ndims = cdfDefineDimsAndChunks(streamptr, varID, xid, yid, zid, gridsize, dimorder, dims, lchunk, chunks, axis, &iax); int ndims = cdfDefineDimsAndChunks(streamptr, varID, xid, yid, zid, gridsize, dimorder, dims, lchunk, chunks, axis, &iax);
char name[CDI_MAX_NAME]; name[0] = 0; char name[CDI_MAX_NAME];
if ( vlistInqVarNamePtr(vlistID, varID) ) vlistInqVarName(vlistID, varID, name); int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
char longname[CDI_MAX_NAME]; longname[0] = 0; char longname[CDI_MAX_NAME]; longname[0] = 0;
char stdname[CDI_MAX_NAME]; stdname[0] = 0; char stdname[CDI_MAX_NAME]; stdname[0] = 0;
......
...@@ -875,6 +875,8 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2); ...@@ -875,6 +875,8 @@ int cdiCopyKeys(int cdiID1, int varID1, int cdiID2, int varID2);
int cdiCopyKey(int cdiID1, int varID1, int key, int cdiID2); int cdiCopyKey(int cdiID1, int varID1, int key, int cdiID2);
int cdiDeleteKey(int cdiID, int varID, int key);
// GRID routines // GRID routines
// gridDefXname: Define the name of a X-axis // gridDefXname: Define the name of a X-axis
......
...@@ -208,6 +208,28 @@ void cdi_define_key(const cdi_key_t *keyp, cdi_keys_t *keysp) ...@@ -208,6 +208,28 @@ void cdi_define_key(const cdi_key_t *keyp, cdi_keys_t *keysp)
} }
int cdiDeleteKey(int cdiID, int varID, int key)
{
int status = -1;
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
cdi_key_t *keyp = find_key(keysp, key);
if ( keyp != NULL ) // key in use
{
if ( keyp->length )
{
free(keyp->v.s);
keyp->v.s = NULL;
keyp->length = 0;
}
}
return status;
}
void cdiCopyVarKeys(const cdi_keys_t *keysp1, cdi_keys_t *keysp2) void cdiCopyVarKeys(const cdi_keys_t *keysp1, cdi_keys_t *keysp2)
{ {
for ( size_t keyid = 0; keyid < keysp1->nelems; keyid++ ) for ( size_t keyid = 0; keyid < keysp1->nelems; keyid++ )
......
...@@ -3183,7 +3183,6 @@ void cdf_define_code_and_param(int vlistID, int varID) ...@@ -3183,7 +3183,6 @@ void cdf_define_code_and_param(int vlistID, int varID)
if ( strStartsWith(name, "var") ) if ( strStartsWith(name, "var") )
{ {
vlistDefVarCode(vlistID, varID, atoi(name+3)); vlistDefVarCode(vlistID, varID, atoi(name+3));
// vlistDestroyVarName(vlistID, varID);
} }
} }
else if ( len > 4 && isdigit((int) name[4]) ) else if ( len > 4 && isdigit((int) name[4]) )
...@@ -3191,7 +3190,6 @@ void cdf_define_code_and_param(int vlistID, int varID) ...@@ -3191,7 +3190,6 @@ void cdf_define_code_and_param(int vlistID, int varID)
if ( strStartsWith(name, "code") ) if ( strStartsWith(name, "code") )
{ {
vlistDefVarCode(vlistID, varID, atoi(name+4)); vlistDefVarCode(vlistID, varID, atoi(name+4));
// vlistDestroyVarName(vlistID, varID);
} }
} }
else if ( len > 5 && isdigit((int) name[5]) ) else if ( len > 5 && isdigit((int) name[5]) )
...@@ -3201,7 +3199,6 @@ void cdf_define_code_and_param(int vlistID, int varID) ...@@ -3201,7 +3199,6 @@ void cdf_define_code_and_param(int vlistID, int varID)
int pnum = -1, pcat = 255, pdis = 255; int pnum = -1, pcat = 255, pdis = 255;
sscanf(name+5, "%d.%d.%d", &pnum, &pcat, &pdis); sscanf(name+5, "%d.%d.%d", &pnum, &pcat, &pdis);
vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis)); vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis));
// vlistDestroyVarName(vlistID, varID);
} }
} }
} }
...@@ -3222,7 +3219,7 @@ void cdf_define_institut_and_model_id(int vlistID, int varID) ...@@ -3222,7 +3219,7 @@ void cdf_define_institut_and_model_id(int vlistID, int varID)
tableInqEntry(cdiDefaultTableID, code, -1, name, longname, units); tableInqEntry(cdiDefaultTableID, code, -1, name, longname, units);
if ( name[0] ) if ( name[0] )
{ {
vlistDestroyVarName(vlistID, varID); cdiDeleteKey(vlistID, varID, CDI_KEY_NAME);
vlistDestroyVarLongname(vlistID, varID); vlistDestroyVarLongname(vlistID, varID);
vlistDestroyVarUnits(vlistID, varID); vlistDestroyVarUnits(vlistID, varID);
......
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
#include "cdi_int.h" #include "cdi_int.h"
/*int TableDefine = 0; */ /* Define new table also if the entry already exist */
/* This is needed for createtable */
#include "tablepar.h" #include "tablepar.h"
#include "table.h" #include "table.h"
...@@ -97,11 +94,8 @@ static void parTableInitEntry(int tableID) ...@@ -97,11 +94,8 @@ static void parTableInitEntry(int tableID)
static void tableGetPath(void) static void tableGetPath(void)
{ {
char *path = getenv("TABLEPATH"); char *path = getenv("TABLEPATH");
if ( path ) tablePath = strdupx(path); if ( path ) tablePath = strdupx(path);
/* // printf("tablePath = %s\n", tablePath);
printf("tablePath = %s\n", tablePath);
*/
} }
static void parTableFinalize(void) static void parTableFinalize(void)
...@@ -129,8 +123,7 @@ static void parTableInit(void) ...@@ -129,8 +123,7 @@ static void parTableInit(void)
ParTableInit = 1; ParTableInit = 1;
atexit(parTableFinalize); atexit(parTableFinalize);
if ( cdiPartabIntern ) if ( cdiPartabIntern ) tableDefault();
tableDefault();
tableGetPath(); tableGetPath();
} }
...@@ -138,8 +131,8 @@ static void parTableInit(void) ...@@ -138,8 +131,8 @@ static void parTableInit(void)
static int tableNewEntry() static int tableNewEntry()
{ {
int tableID = 0; int tableID = 0;
static int init = 0;
static int init = 0;
if ( ! init ) if ( ! init )
{ {
for ( tableID = 0; tableID < parTableSize; tableID++ ) for ( tableID = 0; tableID < parTableSize; tableID++ )
...@@ -147,16 +140,13 @@ static int tableNewEntry() ...@@ -147,16 +140,13 @@ static int tableNewEntry()
init = 1; init = 1;
} }
/* // Look for a free slot in parTable.
Look for a free slot in parTable.
*/
for ( tableID = 0; tableID < parTableSize; tableID++ ) for ( tableID = 0; tableID < parTableSize; tableID++ )
{ {
if ( ! parTable[tableID].used ) break; if ( ! parTable[tableID].used ) break;
} }
if ( tableID == parTableSize ) if ( tableID == parTableSize ) Error("no more entries!");
Error("no more entries!");
parTable[tableID].used = true; parTable[tableID].used = true;
parTableNum++; parTableNum++;
...@@ -239,7 +229,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units) ...@@ -239,7 +229,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
static int static int
decodeForm2(char *pline, char *name, char *longname, char *units) decodeForm2(char *pline, char *name, char *longname, char *units)
{ {
/* Format 2 : code | name | longname | units */ // Format 2 : code | name | longname | units
char *pend; char *pend;
pline = strchr(pline, '|'); pline = strchr(pline, '|');
...@@ -345,9 +335,7 @@ int tableRead(const char *tablefile) ...@@ -345,9 +335,7 @@ int tableRead(const char *tablefile)
if ( len < 4 ) continue; if ( len < 4 ) continue;
while ( isspace((int) *pline) ) pline++; while ( isspace((int) *pline) ) pline++;
id = atoi(pline); id = atoi(pline);
/* // if ( id > 255 ) id -= 256;
if ( id > 255 ) id -= 256;
*/
if ( id == 0 ) continue; if ( id == 0 ) continue;
while ( isdigit((int) *pline) ) pline++; while ( isdigit((int) *pline) ) pline++;
...@@ -573,11 +561,9 @@ int tableInqModel(int tableID) ...@@ -573,11 +561,9 @@ int tableInqModel(int tableID)
static void partabCheckID(int item) static void partabCheckID(int item)
{ {
if ( item < 0 || item >= parTableSize ) if ( item < 0 || item >= parTableSize ) Error("item %d undefined!", item);
Error("item %d undefined!", item);
if ( ! parTable[item].name ) if ( ! parTable[item].name ) Error("item %d name undefined!", item);
Error("item %d name undefined!", item);
} }
...@@ -585,8 +571,7 @@ const char *tableInqNamePtr(int tableID) ...@@ -585,8 +571,7 @@ const char *tableInqNamePtr(int tableID)
{ {
const char *tablename = NULL; const char *tablename = NULL;
if ( CDI_Debug ) if ( CDI_Debug ) Message("tableID = %d", tableID);
Message("tableID = %d", tableID);
if ( ! ParTableInit ) parTableInit(); if ( ! ParTableInit ) parTableInit();
......
...@@ -229,7 +229,7 @@ void vlist_delete(vlist_t *vlistptr) ...@@ -229,7 +229,7 @@ void vlist_delete(vlist_t *vlistptr)
for ( int varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
if ( vars[varID].levinfo ) Free(vars[varID].levinfo); if ( vars[varID].levinfo ) Free(vars[varID].levinfo);
if ( vars[varID].name ) Free(vars[varID].name); //if ( vars[varID].name ) Free(vars[varID].name);
if ( vars[varID].longname ) Free(vars[varID].longname); if ( vars[varID].longname ) Free(vars[varID].longname);
if ( vars[varID].stdname ) Free(vars[varID].stdname); if ( vars[varID].stdname ) Free(vars[varID].stdname);
if ( vars[varID].units ) Free(vars[varID].units); if ( vars[varID].units ) Free(vars[varID].units);
...@@ -293,7 +293,7 @@ void cdiVlistDestroy_(int vlistID) ...@@ -293,7 +293,7 @@ void cdiVlistDestroy_(int vlistID)
static static
void var_copy_entries(var_t *var2, var_t *var1) void var_copy_entries(var_t *var2, var_t *var1)
{ {
if ( var1->name ) var2->name = strdupx(var1->name); //if ( var1->name ) var2->name = strdupx(var1->name);
if ( var1->longname ) var2->longname = strdupx(var1->longname); if ( var1->longname ) var2->longname = strdupx(var1->longname);
if ( var1->stdname ) var2->stdname = strdupx(var1->stdname); if ( var1->stdname ) var2->stdname = strdupx(var1->stdname);
if ( var1->units ) var2->units = strdupx(var1->units); if ( var1->units ) var2->units = strdupx(var1->units);
...@@ -841,15 +841,21 @@ void vlistMerge(int vlistID2, int vlistID1) ...@@ -841,15 +841,21 @@ void vlistMerge(int vlistID2, int vlistID1)
if ( nvars1 == nvars2 ) if ( nvars1 == nvars2 )
{ {
char name1[CDI_MAX_NAME], name2[CDI_MAX_NAME];
for ( varID = 0; varID < nvars2; varID++ ) for ( varID = 0; varID < nvars2; varID++ )
{ {
size_t ngp1 = gridInqSize(vars1[varID].gridID); size_t ngp1 = gridInqSize(vars1[varID].gridID);
size_t ngp2 = gridInqSize(vars2[varID].gridID); size_t ngp2 = gridInqSize(vars2[varID].gridID);
if ( ngp1 != ngp2 ) break; if ( ngp1 != ngp2 ) break;
if ( vars1[varID].name && vars2[varID].name ) int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID1, varID, CDI_KEY_NAME, name1, &length);
length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID2, varID, CDI_KEY_NAME, name2, &length);
if ( *name1 && *name2 )
{ {
if ( strcmp(vars1[varID].name, vars2[varID].name) != 0 ) break; if ( strcmp(name1, name2) != 0 ) break;
} }
else else
{ {
...@@ -1089,9 +1095,10 @@ int vlistNtsteps(int vlistID) ...@@ -1089,9 +1095,10 @@ int vlistNtsteps(int vlistID)
static static
void vlistPrintKernel(vlist_t *vlistptr, FILE *fp) void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
{ {
fprintf ( fp, "#\n# vlistID %d\n#\n", vlistptr->self); const int vlistID = vlistptr->self;
fprintf ( fp, "#\n# vlistID %d\n#\n", vlistID);
int nvars = vlistptr->nvars; const int nvars = vlistptr->nvars;
fprintf(fp, "nvars : %d\n" fprintf(fp, "nvars : %d\n"
"ngrids : %d\n" "ngrids : %d\n"
...@@ -1115,7 +1122,9 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp) ...@@ -1115,7 +1122,9 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
int zaxisID = vlistptr->vars[varID].zaxisID; int zaxisID = vlistptr->vars[varID].zaxisID;
int subtypeID = vlistptr->vars[varID].subtypeID; int subtypeID = vlistptr->vars[varID].subtypeID;
int tsteptype = vlistptr->vars[varID].tsteptype; int tsteptype = vlistptr->vars[varID].tsteptype;
const char *name = vlistptr->vars[varID].name; char name[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
const char *longname = vlistptr->vars[varID].longname; const char *longname = vlistptr->vars[varID].longname;
const char *units = vlistptr->vars[varID].units; const char *units = vlistptr->vars[varID].units;
int flag = vlistptr->vars[varID].flag; int flag = vlistptr->vars[varID].flag;
...@@ -1125,7 +1134,7 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp) ...@@ -1125,7 +1134,7 @@ void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
cdiParamToString(param, paramstr, sizeof(paramstr)); cdiParamToString(param, paramstr, sizeof(paramstr));
fprintf(fp, "%6d %-8s %6d %6d %6d %6d %5d %6d %-8s %s [%s]\n", fprintf(fp, "%6d %-8s %6d %6d %6d %6d %5d %6d %-8s %s [%s]\n",
varID, paramstr, gridID, zaxisID, subtypeID, tsteptype, flag, iorank, varID, paramstr, gridID, zaxisID, subtypeID, tsteptype, flag, iorank,
name?name:"", longname?longname:"", units?units:""); name, longname?longname:"", units?units:"");
} }
fputs("\n" fputs("\n"
......
...@@ -66,7 +66,6 @@ typedef struct ...@@ -66,7 +66,6 @@ typedef struct
int xyz; int xyz;
bool missvalused; // true if missval is defined bool missvalused; // true if missval is defined
bool lvalidrange; bool lvalidrange;
char *name;
char *longname; char *longname;
char *stdname; char *stdname;
char *units; char *units;
...@@ -122,7 +121,6 @@ vlist_t *vlist_to_pointer(int vlistID); ...@@ -122,7 +121,6 @@ vlist_t *vlist_to_pointer(int vlistID);
void cdiVlistMakeInternal(int vlistID); void cdiVlistMakeInternal(int vlistID);
void cdiVlistMakeImmutable(int vlistID); void cdiVlistMakeImmutable(int vlistID);
void vlistCheckVarID(const char *caller, int vlistID, int varID); void vlistCheckVarID(const char *caller, int vlistID, int varID);
void vlistDestroyVarName(int vlistID, int varID);
void vlistDestroyVarLongname(int vlistID, int varID); void vlistDestroyVarLongname(int vlistID, int varID);
void vlistDestroyVarStdname(int vlistID, int varID); void vlistDestroyVarStdname(int vlistID, int varID);
void vlistDestroyVarUnits(int vlistID, int varID); void vlistDestroyVarUnits(int vlistID, int varID);
......
...@@ -35,7 +35,6 @@ void vlistvarInitEntry(int vlistID, int varID) ...@@ -35,7 +35,6 @@ void vlistvarInitEntry(int vlistID, int varID)
vlistptr->vars[varID].missval = CDI_default_missval; vlistptr->vars[varID].missval = CDI_default_missval;
vlistptr->vars[varID].addoffset = 0.0; vlistptr->vars[varID].addoffset = 0.0;
vlistptr->vars[varID].scalefactor = 1.0; vlistptr->vars[varID].scalefactor = 1.0;
vlistptr->vars[varID].name = NULL;
vlistptr->vars[varID].longname = NULL; vlistptr->vars[varID].longname = NULL;
vlistptr->vars[varID].stdname = NULL; vlistptr->vars[varID].stdname = NULL;
vlistptr->vars[varID].units = NULL; vlistptr->vars[varID].units = NULL;
...@@ -388,23 +387,19 @@ int vlistInqVarCode(int vlistID, int varID) ...@@ -388,23 +387,19 @@ int vlistInqVarCode(int vlistID, int varID)
int code = pnum; int code = pnum;
if ( pdis != 255 ) code = -varID-1; // GRIB2 Parameter if ( pdis != 255 ) code = -varID-1; // GRIB2 Parameter
if ( code < 0 && vlistptr->vars[varID].tableID != -1 && vlistptr->vars[varID].name != NULL ) int tableID = vlistptr->vars[varID].tableID;
if (code < 0 && tableID != -1)
{ {
tableInqParCode(vlistptr->vars[varID].tableID, vlistptr->vars[varID].name, &code); char name[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
if (name[0]) tableInqParCode(tableID, name, &code);
} }
return code; return code;
} }
const char *vlistInqVarNamePtr(int vlistID, int varID)
{
vlistCheckVarID(__func__, vlistID, varID);
const vlist_t *vlistptr = vlist_to_pointer(vlistID);
return vlistptr->vars[varID].name;
}
/* /*
@Function vlistInqVarName @Function vlistInqVarName
@Title Get the name of a Variable @Title Get the name of a Variable
...@@ -428,16 +423,15 @@ otherwise the result is an empty string. ...@@ -428,16 +423,15 @@ otherwise the result is an empty string.
*/ */
void vlistInqVarName(int vlistID, int varID, char *name) void vlistInqVarName(int vlistID, int varID, char *name)
{ {
/*
int length = CDI_MAX_NAME; int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length); (void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
*/
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID(__func__, vlistID, varID);
if ( vlistptr->vars[varID].name == NULL ) if (!name[0])
{ {
vlistCheckVarID(__func__, vlistID, varID);
vlist_t *vlistptr = vlist_to_pointer(vlistID);
int param = vlistptr->vars[varID].param; int param = vlistptr->vars[varID].param;
int pdis, pcat, pnum; int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis); cdiDecodeParam(param, &pnum, &pcat, &pdis);
...@@ -445,17 +439,14 @@ void vlistInqVarName(int vlistID, int varID, char *name) ...@@ -445,17 +439,14 @@ void vlistInqVarName(int vlistID, int varID, char *name)
{ {
int code = pnum; int code = pnum;
int tableID = vlistptr->vars[varID].tableID; int tableID = vlistptr->vars[varID].tableID;
name[0] = 0;
tableInqEntry(tableID, code, -1, name, NULL, NULL); tableInqEntry(tableID, code, -1, name, NULL, NULL);
if ( !name[0] ) sprintf(name, "var%d", code); if (!name[0]) sprintf(name, "var%d", code);
} }
else else
{ {
sprintf(name, "param%d.%d.%d", pnum, pcat, pdis); sprintf(name, "param%d.%d.%d", pnum, pcat, pdis);
} }
} }
else
strcpy(name, vlistptr->vars[varID].name); //FIXME: This may overrun the provided buffer.
return; return;
} }
...@@ -477,27 +468,26 @@ The memory for the returned string is allocated to fit the string via Malloc(). ...@@ -477,27 +468,26 @@ The memory for the returned string is allocated to fit the string via Malloc().
@EndFunction @EndFunction
*/ */
char* vlistCopyVarName(int vlistId, int varId) char *vlistCopyVarName(int vlistID, int varID)
{ {
vlist_t* vlistptr = vlist_to_pointer(vlistId); // If a name is set in the variable description, use that.
vlistCheckVarID(__func__, vlistId, varId); char name[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
(void)cdiInqKeyString(vlistID, varID, CDI_KEY_NAME, name, &length);
if (name[0]) return strdup(name);
//If a name is set in the variable description, use that. vlistCheckVarID(__func__, vlistID, varID);
{ vlist_t *vlistptr = vlist_to_pointer(vlistID);
const char* name = vlistptr->vars[varId].name;
if (name) return strdup(name);
}
//Otherwise we check if we should use the table of parameter descriptions. // Otherwise we check if we should use the table of parameter descriptions.
int param = vlistptr->vars[varId].param; int param = vlistptr->vars[varID].param;
int discipline, category, number; int discipline, category, number;
cdiDecodeParam(param, &number, &category, &discipline); cdiDecodeParam(param, &number, &category, &discipline);
char *result = NULL; char *result = NULL;
if (discipline == 255) if (discipline == 255)
{ {
int tableId = vlistptr->vars[varId].tableID; int tableID = vlistptr->vars[varID].tableID;
char name[CDI_MAX_NAME]; name[0] = 0; tableInqEntry(tableID, number, -1, name, NULL, NULL);
tableInqEntry(tableId, number, -1, name, NULL, NULL);
if ( name[0] ) if ( name[0] )
result = strdup(name); result = strdup(name);
else else
...@@ -842,22 +832,7 @@ The function @func{vlistDefVarName} defines the name of a variable. ...@@ -842,22 +832,7 @@ The function @func{vlistDefVarName} defines the name of a variable.
*/ */
void vlistDefVarName(int vlistID, int varID, const char *name) void vlistDefVarName(int vlistID, int varID, const char *name)
{ {
//(void)cdiDefKeyString(vlistID, varID, CDI_KEY_NAME, name); (void)cdiDefKeyString(vlistID, varID, CDI_KEY_NAME, name);
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistCheckVarID(__func__, vlistID, varID);
if ( name )
{
if ( vlistptr->vars[varID].name )
{
Free(vlistptr->vars[varID].name);
vlistptr->vars[varID].name = NULL;
}
vlistptr->vars[varID].name = strdupx(name);
reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
}
} }
/* /*
...@@ -1233,18 +1208,6 @@ int vlistInqVarTimave(int vlistID, int varID) ...@@ -1233,18 +1208,6 @@ int vlistInqVarTimave(int vlistID, int varID)
} }