missing val.c added

This commit is contained in:
7u83 2022-08-18 08:49:55 +02:00
parent b54f4fb9fa
commit b574aac31f
1 changed files with 28 additions and 0 deletions

28
src/cw/val.c Normal file
View File

@ -0,0 +1,28 @@
#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);
}