2018-04-20 05:46:50 +02:00
|
|
|
|
|
|
|
#include "cw.h"
|
2022-08-13 09:47:12 +02:00
|
|
|
#include "dbg.h"
|
2018-04-20 05:46:50 +02:00
|
|
|
|
|
|
|
int cw_out_generic_with_index(struct cw_ElemHandler * eh,
|
|
|
|
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
|
|
|
|
|
|
|
{
|
2022-08-13 09:47:12 +02:00
|
|
|
stop();
|
2022-08-14 12:26:34 +02:00
|
|
|
char key[CW_CFG_MAX_KEY_LEN];
|
2018-04-20 05:46:50 +02:00
|
|
|
int idx;
|
2022-07-31 17:15:32 +02:00
|
|
|
cw_Val_t * result, search;
|
2018-04-20 05:46:50 +02:00
|
|
|
int len,start;
|
|
|
|
uint8_t * ob;
|
|
|
|
|
|
|
|
|
|
|
|
idx = 0;
|
|
|
|
ob = dst;
|
|
|
|
|
|
|
|
do {
|
|
|
|
sprintf(key,"%s.%d",eh->key,idx);
|
|
|
|
search.key=key;
|
2022-08-13 09:47:12 +02:00
|
|
|
result = mavl_get_first(params->cfg,&search);
|
2018-04-20 05:46:50 +02:00
|
|
|
if (result==NULL)
|
|
|
|
break;
|
|
|
|
if (strncmp(result->key,key,strlen(key))!=0)
|
|
|
|
break;
|
|
|
|
|
2022-07-29 12:11:19 +02:00
|
|
|
start = params->msgset->header_len(eh);
|
2018-04-20 05:46:50 +02:00
|
|
|
len = cw_put_byte(ob+start,idx);
|
|
|
|
|
|
|
|
len += result->type->put(result,ob+start+len);
|
|
|
|
|
2022-07-29 12:11:19 +02:00
|
|
|
ob += params->msgset->write_header(eh,ob,len);
|
2018-04-20 05:46:50 +02:00
|
|
|
|
|
|
|
idx++;
|
|
|
|
|
|
|
|
}while(1);
|
|
|
|
|
|
|
|
return ob-dst;
|
|
|
|
}
|
|
|
|
|