You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
724 B
36 lines
724 B
#include "cw.h"
|
|
|
|
|
|
static const cw_ValEnum_t * get_enum(const cw_ValEnum_t * e, int val){
|
|
int i;
|
|
for (i=0; e[i].type != NULL; i++ ){
|
|
if (e[i].value==val){
|
|
return &(e[i]);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
|
|
int cw_in_generic_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
|
uint8_t * elem_data, int elem_len)
|
|
{
|
|
int val;
|
|
const cw_ValEnum_t * e;
|
|
char key[CW_CFG_MAX_KEY_LEN];
|
|
struct cw_ElemHandler thandler;
|
|
|
|
val = cw_get_byte(elem_data+1);
|
|
e = get_enum(handler->type,val);
|
|
if (e!=NULL){
|
|
sprintf(key,"%s/%s",handler->key,e->name);
|
|
}
|
|
else{
|
|
sprintf(key,"%s/%u",handler->key,val);
|
|
}
|
|
|
|
thandler.type=e->type;
|
|
thandler.key=key;
|
|
return e->fun_in(&thandler,params,elem_data,elem_len-1);
|
|
|
|
}
|
|
|