Counter function
FossilOrigin-Name: 7f88de81e3340b664d21ef5b091aebec1115813b6751d824930ea2734ddb50ae
This commit is contained in:
@ -78,6 +78,7 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
|
||||
char ikey[CW_KTV_MAX_KEY_LEN];
|
||||
cw_KTV_t search, * result;
|
||||
char *d;
|
||||
int i;
|
||||
|
||||
sprintf(ikey,"%s.%d",key,n);
|
||||
|
||||
@ -90,13 +91,35 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
|
||||
return -1;
|
||||
}
|
||||
|
||||
d = strchr(result->key,'.');
|
||||
/*d = strchr(result->key,'.');*/
|
||||
d=NULL;
|
||||
/* for (i = strlen(result->key); i>=0; i--){
|
||||
if (result->key[i]=='/')
|
||||
break;
|
||||
}
|
||||
*/ for (i = strlen(ikey); i>=0; i--){
|
||||
|
||||
if (ikey[i]=='.'){
|
||||
d = result->key+i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (d==NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strncmp(result->key,ikey,d-result->key)!=0)
|
||||
if(result->key[i]!='.'){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* if (strncmp(result->key,ikey,d-result->key)!=0)
|
||||
return -1;
|
||||
*/
|
||||
if (strncmp(result->key,ikey,i)!=0)
|
||||
return -1;
|
||||
|
||||
return atoi(d+1);
|
||||
|
||||
return atoi(result->key+i+1);
|
||||
}
|
||||
|
@ -8,23 +8,14 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
, uint8_t * dst)
|
||||
{
|
||||
int i,l, offset;
|
||||
/* int radios;*/
|
||||
|
||||
uint8_t * cdst;
|
||||
|
||||
cdst = dst;
|
||||
|
||||
/* radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);*/
|
||||
|
||||
/* int idx=0;
|
||||
while(1){
|
||||
|
||||
idx = cw_ktv_idx_get_next(params->conn->local_cfg,"radio",idx);
|
||||
idx++;
|
||||
}
|
||||
*/
|
||||
|
||||
offset = params->conn->header_len(handler);
|
||||
/* for(i=0;i<radios;i++){*/
|
||||
|
||||
i=-1;
|
||||
while(1){
|
||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||
@ -47,11 +38,78 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
|
||||
|
||||
cdst+=params->conn->write_header(handler,cdst,l);
|
||||
|
||||
|
||||
/* l = cw_write_radio_element(handler,params,i,dst+len);
|
||||
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
|
||||
len+=l;*/
|
||||
}
|
||||
return cdst-dst;
|
||||
}
|
||||
|
||||
|
||||
int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst, int i, const char *current, const char * next)
|
||||
{
|
||||
char *sl;
|
||||
int l;
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
char tcurrent[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
|
||||
sl = strchr(next,'/');
|
||||
if (sl==NULL){
|
||||
cw_KTV_t * result;
|
||||
sprintf(key,"%s/%s",current,next);
|
||||
result = cw_ktv_base_exists(params->conn->local_cfg,key);
|
||||
if (result != NULL){
|
||||
printf("Yea! We can do it: %s\n",result->key);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(key,current);
|
||||
if (key[0!=0])
|
||||
strcat(key,"/");
|
||||
l = sl - next;
|
||||
strncat(key,next,l);
|
||||
|
||||
|
||||
printf("Here we are %s\n",key);
|
||||
cw_dbg_ktv_dump(params->conn->local_cfg,DBG_INFO,"start"," ", "end" );
|
||||
i=-1;
|
||||
while(1){
|
||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||
cw_KTV_t * result;
|
||||
|
||||
i = cw_ktv_idx_get_next(params->conn->local_cfg,key,i+1);
|
||||
if (i==-1)
|
||||
break;
|
||||
sprintf(basekey,"%s.%d",key,i);
|
||||
printf("Our basekey is %s\n",basekey);
|
||||
result = cw_ktv_base_exists(params->conn->local_cfg,basekey);
|
||||
if (result == NULL){
|
||||
continue;
|
||||
}
|
||||
|
||||
cw_out_traverse0(handler,params,dst,-1,basekey,next+l+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
|
||||
{
|
||||
int i;
|
||||
char current[CW_KTV_MAX_KEY_LEN];
|
||||
i=-1;
|
||||
|
||||
|
||||
current[0]=0;
|
||||
|
||||
cw_out_traverse0(handler,params,dst,-1,current,handler->key);
|
||||
|
||||
printf("Hello world\n");
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user