Commit 74f7a0c1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved pml_search_kvl_ventry() and pml_get_kvl_ventry() to pmlist.c.

parent 4d9e7157
...@@ -109,54 +109,6 @@ void defineVarUnits(var_t *vars, int vlistID2, int varID, const char *units) ...@@ -109,54 +109,6 @@ void defineVarUnits(var_t *vars, int vlistID2, int varID, const char *units)
} }
} }
list_t *pml_search_kvl_ventry(list_t *pml, const char *key, const char *value, int nentry, const char **entry)
{
if ( pml && key && value )
{
listNode_t *node = pml->head;
while ( node )
{
if ( node->data )
{
list_t *kvl = *(list_t **)node->data;
const char *listname = list_name(kvl);
for ( int i = 0; i < nentry; ++i )
if ( strcmp(listname, entry[i]) == 0 )
{
keyValues_t *kv = kvlist_search(kvl, key);
if ( kv && kv->nvalues > 0 && *(kv->values[0]) == *value && strcmp(kv->values[0], value) == 0 ) return kvl;
}
}
node = node->next;
}
}
return NULL;
}
list_t *pml_get_kvl_ventry(list_t *pml, int nentry, const char **entry)
{
if ( pml )
{
listNode_t *node = pml->head;
while ( node )
{
if ( node->data )
{
list_t *kvl = *(list_t **)node->data;
const char *listname = list_name(kvl);
for ( int i = 0; i < nentry; ++i )
if ( strcmp(listname, entry[i]) == 0 ) return kvl;
}
node = node->next;
}
}
return NULL;
}
static static
void apply_cmor_table(const char *filename, int nvars, int vlistID2, var_t *vars) void apply_cmor_table(const char *filename, int nvars, int vlistID2, var_t *vars)
{ {
......
...@@ -151,6 +151,55 @@ int kvlist_parse_cmdline(list_t *kvl, int nparams, char **params) ...@@ -151,6 +151,55 @@ int kvlist_parse_cmdline(list_t *kvl, int nparams, char **params)
return 0; return 0;
} }
list_t *pml_search_kvl_ventry(list_t *pml, const char *key, const char *value, int nentry, const char **entry)
{
if ( pml && key && value )
{
listNode_t *node = pml->head;
while ( node )
{
if ( node->data )
{
list_t *kvl = *(list_t **)node->data;
const char *listname = list_name(kvl);
for ( int i = 0; i < nentry; ++i )
if ( strcmp(listname, entry[i]) == 0 )
{
keyValues_t *kv = kvlist_search(kvl, key);
if ( kv && kv->nvalues > 0 && *(kv->values[0]) == *value && strcmp(kv->values[0], value) == 0 ) return kvl;
}
}
node = node->next;
}
}
return NULL;
}
list_t *pml_get_kvl_ventry(list_t *pml, int nentry, const char **entry)
{
if ( pml )
{
listNode_t *node = pml->head;
while ( node )
{
if ( node->data )
{
list_t *kvl = *(list_t **)node->data;
const char *listname = list_name(kvl);
for ( int i = 0; i < nentry; ++i )
if ( strcmp(listname, entry[i]) == 0 ) return kvl;
}
node = node->next;
}
}
return NULL;
}
/* /*
int main(void) int main(void)
{ {
......
...@@ -25,4 +25,7 @@ void kvlist_destroy(list_t *list); ...@@ -25,4 +25,7 @@ void kvlist_destroy(list_t *list);
void kvlist_append(list_t *kvl, const char *key, const char **values, int nvalues); 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); int kvlist_parse_cmdline(list_t *kvl, int nparams, char **params);
list_t *pml_search_kvl_ventry(list_t *pml, const char *key, const char *value, int nentry, const char **entry);
list_t *pml_get_kvl_ventry(list_t *pml, int nentry, const char **entry);
#endif #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