actube/src/cw/cw_ktv_get.c

33 lines
754 B
C
Raw Normal View History

2022-07-31 17:15:32 +02:00
#include "val.h"
#include "mavl.h"
/**
* @brief Get a ktv value from a ktv store
* @param ktv ktv store
* @param key key to search for
* @param type type to match
2022-07-31 17:15:32 +02:00
* @return A pointer to a #cw_Val_t element, found in the ktv store or
* NULL if no element with matching key/type is found.
*/
2022-07-31 17:15:32 +02:00
cw_Val_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type)
{
2022-07-31 17:15:32 +02:00
cw_Val_t search, *result;
/* we can safely cast from const char * to char *, because
* we never will use the search varaiable to store ktv values */
search.key=(char*)key;
result = mavl_get(ktv,&search);
if (result == NULL){
return NULL;
}
if (type == NULL){
return result;
}
if (strcmp(type->name,result->type->name)==0){
return result;
}
return NULL;
}