2018-03-12 11:22:06 +01:00
|
|
|
|
|
|
|
#include "ktv.h"
|
|
|
|
|
2018-03-17 16:21:23 +01:00
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
2018-03-12 11:22:06 +01:00
|
|
|
{
|
2018-03-17 16:21:23 +01:00
|
|
|
char key[CW_KTV_MAX_KEY_LEN];
|
|
|
|
char type[256];
|
2018-03-15 20:07:17 +01:00
|
|
|
char val[2048];
|
2018-03-12 11:22:06 +01:00
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
|
|
|
|
int rc;
|
|
|
|
struct cw_Type typesearch, *cwtype;
|
2018-03-12 11:22:06 +01:00
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
|
|
|
|
do {
|
2018-03-17 16:21:23 +01:00
|
|
|
|
|
|
|
rc = cw_ktv_read_line(file,key,type,val);
|
|
|
|
if (rc != 0){
|
|
|
|
continue;
|
2018-03-15 20:07:17 +01:00
|
|
|
}
|
2018-03-17 16:21:23 +01:00
|
|
|
|
|
|
|
typesearch.name=type;
|
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
cwtype = mavl_get_ptr(types,&typesearch);
|
|
|
|
if (cwtype != NULL){
|
2018-03-17 16:21:23 +01:00
|
|
|
/*// printf("Yes! I know the type: %s\n",cwtype->name);*/
|
2018-03-15 20:07:17 +01:00
|
|
|
}
|
2018-03-17 12:32:40 +01:00
|
|
|
else {
|
|
|
|
printf("Unknown type: %s\n",typesearch.name);
|
2018-03-15 20:07:17 +01:00
|
|
|
continue;
|
2018-03-17 12:32:40 +01:00
|
|
|
}
|
2018-03-17 16:21:23 +01:00
|
|
|
|
2018-04-25 10:43:27 +02:00
|
|
|
cw_ktv_add_from_str(ktv,key,cwtype,NULL,val);
|
2018-03-15 20:07:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
}while(rc==0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|