actube/src/cw/cw_out_generic_indexed_enum.c

69 lines
1.3 KiB
C
Raw Normal View History

#include "cw.h"
2022-08-13 09:47:12 +02:00
#include"dbg.h"
2022-08-17 18:41:17 +02:00
#include "cfg.h"
2022-08-13 09:47:12 +02:00
int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst)
{
2022-08-17 18:41:17 +02:00
// cw_dbg(DBG_X,"Fix: cw_out_generic_indexed_enum %s",handler->key);
// stop();
2022-08-13 09:47:12 +02:00
2022-08-14 12:26:34 +02:00
char key[CW_CFG_MAX_KEY_LEN];
int i;
2022-08-17 18:41:17 +02:00
// cw_Val_t * result;
int len,start;
uint8_t * ob;
2022-07-31 17:15:32 +02:00
const cw_ValIndexed_t *ie;
cw_ValEnum_t * e;
ie = handler->type;
i = 0;
ob = dst;
e = ie->type;
for(i=0; e[i].name!=NULL; i++) {
2022-08-17 18:41:17 +02:00
int b;
sprintf(key,"%s/%s",handler->key,e[i].name);
2022-08-17 18:41:17 +02:00
cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
2022-08-17 18:41:17 +02:00
b = cw_cfg_base_exists_l(params->cfg_list,handler->key);
if (!b){
stop();
continue;
2022-08-17 18:41:17 +02:00
}
start = params->msgset->header_len(handler);
len = 0;
if (ie->idxpos==0)
len = 1;
2022-08-17 18:41:17 +02:00
if (e[i].fun_out==NULL){
stop();
// result =
// len += result->type->put(result,ob+start+len);
}
else{
len += ((cw_Type_t*)e[i].type)->write(params->cfg_list,key,ob+start+len,e[i].param);
// len += cw_ktv_write_struct(params->cfg,
// NULL,e[i].type,key,ob+start+len);
}
cw_set_byte(ob+start+ie->idxpos,e[i].value);
if (ie->idxpos==len)
len++;
ob += params->msgset->write_header(handler,ob,len);
2022-08-17 18:41:17 +02:00
// cw_val_destroy(result);
}
return ob-dst;
2022-08-17 18:41:17 +02:00
2022-08-14 13:31:58 +02:00
return 0;
}