Commit 561e6590 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added kvlist_new() and kvlist_destroy().

parent be533a76
......@@ -28,6 +28,7 @@
#include "error.h"
#include "util.h"
#include "pml.h"
#include "pmlist.h"
double datestr_to_double(const char *datestr, int opt);
......@@ -58,6 +59,7 @@ void write_const_vars(int streamID2, int vlistID2, int nvars, double **vardata2)
}
}
//#define TEST_KVL
void *Select(void *argument)
{
......@@ -96,10 +98,18 @@ void *Select(void *argument)
int nsel = operatorArgc();
char **argnames = operatorArgv();
if ( nsel == 0 ) cdoAbort("Parameter missing!");
if ( cdoVerbose )
for ( int i = 0; i < nsel; ++i )
cdoPrint("name %d = %s", i+1, argnames[i]);
#ifdef TEST_KVL
list_t *kvl = kvlist_new("SELECT");
if ( kvlist_parse_cmdline(kvl, nsel, argnames) != 0 ) cdoAbort("Parse error!");
if ( cdoVerbose ) kvlist_print(kvl);
#endif
pml_t *pml = pml_create("SELECT");
PML_ADD_INT(pml, timestep_of_year, 4096, "Timestep of year");
......@@ -198,7 +208,7 @@ void *Select(void *argument)
int gridID = vlistInqVarGrid(vlistID1, varID);
int zaxisID = vlistInqVarZaxis(vlistID1, varID);
int nlevs = zaxisInqSize(zaxisID);
ltype = zaxis2ltype(zaxisID);
ltype = zaxis2ltype(zaxisID);
zaxisnum = vlistZaxisIndex(vlistID1, zaxisID)+1;
int zaxistype = zaxisInqType(zaxisID);
......@@ -656,6 +666,10 @@ void *Select(void *argument)
pml_destroy(pml);
#ifdef TEST_KVL
kvlist_destroy(kvl);
#endif
if ( array ) Free(array);
if ( vars ) Free(vars);
if ( vardata2 )
......
......@@ -93,6 +93,18 @@ void free_kvlist(void *data)
}
list_t *kvlist_new(const char *name)
{
return list_new(sizeof(keyValues_t *), free_keyval, name);
}
void kvlist_destroy(list_t *list)
{
list_destroy(list);
}
void kvlist_append(list_t *kvl, const char *key, const char **values, int nvalues)
{
keyValues_t *keyval = (keyValues_t *) malloc(sizeof(keyValues_t));
......
......@@ -20,8 +20,9 @@ void kvlist_print(list_t *kvl);
void free_keyval(void *data);
void free_kvlist(void *data);
list_t *kvlist_new(const char *name);
void kvlist_destroy(list_t *list);
void kvlist_append(list_t *kvl, const char *key, const char **values, int nvalues);
int kvlist_parse_cmdline(list_t *kvl, int nparams, char **params);
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment