2018-04-22 09:00:55 +02:00
|
|
|
#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
|
|
|
|
2018-04-22 09:00:55 +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];
|
2018-04-22 09:00:55 +02:00
|
|
|
int i;
|
2022-08-17 18:41:17 +02:00
|
|
|
// cw_Val_t * result;
|
2018-04-22 09:00:55 +02:00
|
|
|
int len,start;
|
|
|
|
uint8_t * ob;
|
2022-07-31 17:15:32 +02:00
|
|
|
const cw_ValIndexed_t *ie;
|
|
|
|
cw_ValEnum_t * e;
|
2018-04-22 09:00:55 +02:00
|
|
|
|
|
|
|
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;
|
2018-04-22 09:00:55 +02:00
|
|
|
sprintf(key,"%s/%s",handler->key,e[i].name);
|
2022-07-29 12:11:19 +02:00
|
|
|
|
2022-08-17 18:41:17 +02:00
|
|
|
cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
|
2022-07-29 12:11:19 +02:00
|
|
|
|
2022-08-17 18:41:17 +02:00
|
|
|
b = cw_cfg_base_exists_l(params->cfg_list,handler->key);
|
|
|
|
if (!b){
|
|
|
|
stop();
|
2018-04-22 09:00:55 +02:00
|
|
|
continue;
|
2022-08-17 18:41:17 +02:00
|
|
|
}
|
2022-07-29 12:11:19 +02:00
|
|
|
start = params->msgset->header_len(handler);
|
2018-04-22 09:00:55 +02:00
|
|
|
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);
|
|
|
|
}
|
2018-04-22 09:00:55 +02:00
|
|
|
|
|
|
|
cw_set_byte(ob+start+ie->idxpos,e[i].value);
|
|
|
|
if (ie->idxpos==len)
|
|
|
|
len++;
|
|
|
|
|
2022-07-29 12:11:19 +02:00
|
|
|
ob += params->msgset->write_header(handler,ob,len);
|
2022-08-17 18:41:17 +02:00
|
|
|
// cw_val_destroy(result);
|
2018-04-22 09:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ob-dst;
|
2022-08-17 18:41:17 +02:00
|
|
|
|
2022-08-14 13:31:58 +02:00
|
|
|
return 0;
|
2018-04-22 09:00:55 +02:00
|
|
|
|
2022-07-28 01:36:16 +02:00
|
|
|
}
|