Some improvemts for the ktv file parser

FossilOrigin-Name: 51c8ae52f86aa8fc824e07fe22d35b7ba5e82f5e4d7506cb5ff9c302ef87056a
This commit is contained in:
7u83@mail.ru
2018-03-17 15:21:23 +00:00
parent 6722bb159c
commit 5edd4ab621
16 changed files with 61 additions and 160 deletions

View File

@ -1,10 +1,11 @@
#include "ktv.h"
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
{
char key[256];
char xtype[256];
char key[CW_KTV_MAX_KEY_LEN];
char type[256];
char val[2048];
@ -13,38 +14,26 @@ int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
do {
cw_KTV_t nktv, *nres;
rc = cw_ktv_read_line(file,key,xtype,val);
if (rc == 0){
printf("Got a line %s:%s:%s\n",key,xtype,val);
rc = cw_ktv_read_line(file,key,type,val);
if (rc != 0){
continue;
}
typesearch.name=xtype;
/* printf("Searching for type: '%s'\n",xtype);*/
typesearch.name=type;
cwtype = mavl_get_ptr(types,&typesearch);
if (cwtype != NULL){
// printf("Yes! I know the type: %s\n",cwtype->name);
/*// printf("Yes! I know the type: %s\n",cwtype->name);*/
}
else {
printf("Unknown type: %s\n",typesearch.name);
continue;
}
cw_ktv_add_from_str(ktv,key,cwtype,val);
/* nres = cwtype->from_str(&nktv,val);
if (nres !=NULL ){
// printf("Yea, created from string\n");
nktv.key=cw_strdup(key);
mavl_add(ktv, &nktv, NULL);
}
*/
}while(rc==0);
return 0;