actube/src/cw/cw_out_generic_with_index.c

43 lines
708 B
C
Raw Normal View History

#include "cw.h"
2022-08-13 09:47:12 +02:00
#include "dbg.h"
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];
int idx;
2022-07-31 17:15:32 +02:00
cw_Val_t * result, search;
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);
if (result==NULL)
break;
if (strncmp(result->key,key,strlen(key))!=0)
break;
start = params->msgset->header_len(eh);
len = cw_put_byte(ob+start,idx);
len += result->type->put(result,ob+start+len);
ob += params->msgset->write_header(eh,ob,len);
idx++;
}while(1);
return ob-dst;
}