actube/src/cw/val.c

29 lines
536 B
C
Raw Normal View History

2022-08-18 08:49:55 +02:00
#include "val.h"
#include "cfg.h"
#include "dbg.h"
int cw_generic_write_l(cw_Cfg_t **cfg, const struct cw_Type*type, const char *key, uint8_t *dst, const void * param)
{
cw_Val_t val;
int l;
const char *s;
memset(&val,0,sizeof(cw_Val_t));
val.type=type;
val.valguard=param;
s = cw_cfg_get_l(cfg,key,NULL);
if (s==NULL)
return -1;
type->from_str(&val,s);
l = type->put(&val,dst);
if(type->del)
type->del(&val);
return l;
}
void cw_val_destroy(cw_Val_t *val)
{
if (val->type->del)
val->type->del(val);
free (val);
}