parent
14354039e1
commit
6dc8d80102
@ -1,43 +0,0 @@ |
||||
#include "val.h" |
||||
#include "cw.h" |
||||
|
||||
#include "log.h" |
||||
#include "dbg.h" |
||||
|
||||
cw_Val_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const void * valguard, |
||||
const uint8_t * data, int len) |
||||
{ |
||||
cw_Val_t mdata, *mresult; |
||||
int exists; |
||||
mdata.key=cw_strdup(key); |
||||
mdata.valguard=valguard; |
||||
|
||||
if (!mdata.key){ |
||||
cw_log(LOG_ERR, "Can't allocate memory for KTV key %s: %s", |
||||
key,strerror(errno)); |
||||
return NULL; |
||||
} |
||||
|
||||
|
||||
mresult = type->get(&mdata,data,len); |
||||
if (!mresult){ |
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s", |
||||
key,type->name, strerror(errno)); |
||||
free(mdata.key); |
||||
return NULL; |
||||
} |
||||
|
||||
mavl_del(kvtstore,&mdata); |
||||
mresult = mavl_insert(kvtstore, &mdata, &exists); |
||||
if (exists){ |
||||
cw_log(LOG_ERR, "Element already exists %s", key); |
||||
/* element already exists */ |
||||
free(mdata.key); |
||||
if (type->del) |
||||
type->del(&mdata); |
||||
return mresult; |
||||
} |
||||
|
||||
return mresult; |
||||
} |
@ -1,45 +0,0 @@ |
||||
#include "val.h" |
||||
#include "cw.h" |
||||
|
||||
#include "log.h" |
||||
#include "dbg.h" |
||||
|
||||
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key,
|
||||
const struct cw_Type *type, |
||||
const void * valguard, |
||||
const char * str) |
||||
{ |
||||
cw_Val_t mdata, *mresult; |
||||
int exists; |
||||
|
||||
/* cw_dbg(DBG_ELEM,"KVStore (%p,%d) add elem (%s): %s", kvstore, kvstore->count,
|
||||
type->name, key ); |
||||
*/ |
||||
mdata.key=cw_strdup(key); |
||||
mdata.valguard=valguard; |
||||
if (!mdata.key){ |
||||
cw_log(LOG_ERR, "Can't allocate memory for key %s: %s", |
||||
key,strerror(errno)); |
||||
return NULL; |
||||
} |
||||
|
||||
mresult = type->from_str(&mdata,str); |
||||
if (!mresult){ |
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s", |
||||
key,type->name, strerror(errno)); |
||||
free(mdata.key); |
||||
return NULL; |
||||
} |
||||
|
||||
mresult = mavl_insert(kvtstore, &mdata, &exists); |
||||
if (exists){ |
||||
cw_log(LOG_ERR, "Element already exists %s", key); |
||||
/* element already exists */ |
||||
free(mdata.key); |
||||
if (type->del) |
||||
type->del(&mdata); |
||||
return key; |
||||
} |
||||
|
||||
return mdata.key; |
||||
} |
@ -1,29 +0,0 @@ |
||||
#include "val.h" |
||||
/**
|
||||
* @file
|
||||
* @description Implementation of cw_ktv_base_exisits |
||||
*/ |
||||
|
||||
|
||||
/**
|
||||
* @brief Check if elements with e certain baskey can be found in
|
||||
* in ktvstore. |
||||
* @param ktvstore ktvstore to search in |
||||
* @param basekey basekey to search for |
||||
* @return The first ktv element belonging to the base eky,
|
||||
* otherwise NULL if no element was found.
|
||||
*
|
||||
*/ |
||||
cw_Val_t * cw_ktv_base_exists(mavl_t ktvstore, const char *basekey) |
||||
{ |
||||
cw_Val_t * result, search; |
||||
search.key=(char*)basekey; |
||||
result = mavl_get_first(ktvstore,&search); |
||||
if (result == NULL) |
||||
return NULL; |
||||
|
||||
if (strncmp(result->key,basekey,strlen(basekey))==0) |
||||
return result; |
||||
|
||||
return NULL; |
||||
}
|
@ -1,14 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
cw_Val_t * cw_ktv_cast(cw_Val_t *v,const cw_Type_t * type) |
||||
{ |
||||
if (strcmp(v->type->name,type->name)==0) |
||||
return v; |
||||
if (type->cast==NULL) |
||||
return NULL; |
||||
if (!type->cast(v)) |
||||
return NULL; |
||||
|
||||
return v; |
||||
} |
||||
|
@ -1,32 +0,0 @@ |
||||
|
||||
#include "val.h" |
||||
#include "mavl.h" |
||||
|
||||
/**
|
||||
* @brief Get a ktv value from a ktv store |
||||
* @param ktv ktv store |
||||
* @param key key to search for |
||||
* @param type type to match |
||||
* @return A pointer to a #cw_Val_t element, found in the ktv store or |
||||
* NULL if no element with matching key/type is found. |
||||
*/ |
||||
cw_Val_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type) |
||||
{ |
||||
cw_Val_t search, *result; |
||||
/* we can safely cast from const char * to char *, because
|
||||
* we never will use the search varaiable to store ktv values */ |
||||
search.key=(char*)key; |
||||
|
||||
result = mavl_get(ktv,&search); |
||||
if (result == NULL){ |
||||
return NULL; |
||||
} |
||||
if (type == NULL){ |
||||
return result; |
||||
} |
||||
if (strcmp(type->name,result->type->name)==0){ |
||||
return result; |
||||
} |
||||
|
||||
return NULL; |
||||
} |
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
uint8_t cw_ktv_get_bool(mavl_t ktv,const char *key, uint8_t def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_BOOL); |
||||
if (k != NULL){ |
||||
return k->val.boolean; |
||||
} |
||||
return def; |
||||
} |
@ -1,13 +0,0 @@ |
||||
#include "val.h" |
||||
#include "bstr.h" |
||||
|
||||
bstr16_t cw_ktv_get_bstr16(mavl_t ktv,const char *key, bstr16_t def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_BSTR16); |
||||
if (k != NULL){ |
||||
return bstr16_create(k->type->data(k),k->type->len(k)); |
||||
} |
||||
return def; |
||||
} |
||||
|
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_BYTE); |
||||
if (k != NULL){ |
||||
return k->val.byte; |
||||
} |
||||
return def; |
||||
} |
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
uint32_t cw_ktv_get_dword(mavl_t ktv,const char *key, uint32_t def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_DWORD); |
||||
if (k != NULL){ |
||||
return k->val.dword; |
||||
} |
||||
return def; |
||||
} |
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
char * cw_ktv_get_str(mavl_t ktv,const char *key, char * def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_STR); |
||||
if (k != NULL){ |
||||
return k->val.ptr; |
||||
} |
||||
return def; |
||||
} |
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
void * cw_ktv_get_sysptr(mavl_t ktv,const char *key, void * def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_SYSPTR); |
||||
if (k != NULL){ |
||||
return k->val.ptr; |
||||
} |
||||
return def; |
||||
} |
@ -1,11 +0,0 @@ |
||||
#include "val.h" |
||||
|
||||
uint16_t cw_ktv_get_word(mavl_t ktv,const char *key, uint16_t def) |
||||
{ |
||||
cw_Val_t * k; |
||||
k = cw_ktv_get(ktv,key,CW_TYPE_WORD); |
||||
if (k != NULL){ |
||||
return k->val.word; |
||||
} |
||||
return def; |
||||
} |
@ -1,126 +0,0 @@ |
||||
#include "val.h" |
||||
#include "cfg.h" |
||||
|
||||
void * ktvn(struct mavl *t ,const void *search) |
||||
{ |
||||
|
||||
struct mavlnode *n,/**lastl,*/*lastb; |
||||
lastb = NULL; /*lastl=NULL;*/ |
||||
n = t->root; |
||||
while(n){ |
||||
int rc; |
||||
/* const cw_Val_t;*//* *c1,*c2;*/ |
||||
/*c1=search;
|
||||
c2=mavlnode_dataptr(n); |
||||
*/ |
||||
|
||||
rc = t->cmp(search,mavlnode_dataptr(n)); |
||||
|
||||
/*printf("Compare: %s %s = %d\n",c1->key,c2->key, rc);*/ |
||||
|
||||
if (rc==0){ |
||||
return NULL; |
||||
|
||||
} |
||||
|
||||
if (rc<0){ |
||||
/*lastl = n;*/ |
||||
if (n->s[0]==NULL){ |
||||
return mavlnode_dataptr(lastb); |
||||
|
||||
} |
||||
n=n->s[0]; |
||||
} |
||||
else{ |
||||
lastb=n; |
||||
if(n->s[1]==NULL){ |
||||
return mavlnode_dataptr(lastb); |
||||
|
||||
} |
||||
n=n->s[1]; |
||||
} |
||||
} |
||||
return NULL; |
||||
|
||||
} |
||||
|
||||
int cw_ktv_idx_get(mavl_t ktv, const char *key) |
||||
{ |
||||
char ikey[CW_CFG_MAX_KEY_LEN]; |
||||
cw_Val_t search, * result; |
||||
char *d; |
||||
|
||||
sprintf(ikey,"%s.%d",key,65536); |
||||
|
||||
search.key=ikey; |
||||
/*//result = ktvn(ktv,&search);*/ |
||||
|
||||
result = mavl_get_last(ktv,&search); |
||||
|
||||
if (result == NULL){ |
||||
return -1; |
||||
} |
||||
|
||||
d = strchr(result->key,'.'); |
||||
if (d==NULL){ |
||||
return -1; |
||||
} |
||||
|
||||
if (strncmp(result->key,ikey,d-result->key)!=0) |
||||
return -1; |
||||
|
||||
return atoi(d+1); |
||||
} |
||||
|
||||
|
||||
|
||||
int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n) |
||||
{ |
||||
char ikey[CW_CFG_MAX_KEY_LEN]; |
||||
cw_Val_t search, * result; |
||||
char *d; |
||||
int i; |
||||
|
||||
sprintf(ikey,"%s.%d",key,n); |
||||
|
||||
search.key=ikey; |
||||
/*//result = ktvn(ktv,&search);*/ |
||||
|
||||
result = mavl_get_first(ktv,&search); |
||||
|
||||
if (result == NULL){ |
||||
return -1; |
||||
} |
||||
|
||||
/*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(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(result->key+i+1); |
||||
} |
@ -1,67 +0,0 @@ |
||||
|
||||
#include <ctype.h> |
||||
|
||||
#include "val.h" |
||||
/**
|
||||
* @brief Default function to compare two values of type #cw_Val_t. |
||||
* |
||||
* @param v1 |
||||
* @param v2 |
||||
* @return |
||||
*/ |
||||
int cw_ktv_mavlcmp (const void *v1, const void *v2) |
||||
{ |
||||
char *d1, *d2, *k1, *k2; |
||||
int l1, l2, rc, i1, i2; |
||||
|
||||
k1 = ( (cw_Val_t *) v1)->key; |
||||
k2 = ( (cw_Val_t *) v2)->key; |
||||
|
||||
while (1) { |
||||
/* Find dots in both keys */ |
||||
d1 = strchr (k1, '.'); |
||||
d2 = strchr (k2, '.'); |
||||
|
||||
/* if there are no dots, compare keys as normal */ |
||||
if (d1 == NULL || d2 == NULL) |
||||
return strcmp (k1, k2); |
||||
|
||||
|
||||
/* calculate the length of the key till dots */ |
||||
l1 = d1 - k1; /*((cw_Val_t *) v1)->key;*/ |
||||
l2 = d2 - k2; /*((cw_Val_t *) v2)->key;*/ |
||||
|
||||
/* if length differs do a normal compare */ |
||||
if (l1 != l2) { |
||||
return strcmp (k1, k2); /*((cw_Val_t *) v1)->key, ((cw_Val_t *) v2)->key);*/ |
||||
} |
||||
|
||||
|
||||
rc = strncmp (k1, k2, l1); /*((cw_Val_t *) v1)->key,((cw_Val_t *) v2)->key,l1);*/ |
||||
|
||||
if (rc != 0) { |
||||
return rc; |
||||
} |
||||
|
||||
d1++; |
||||
d2++; |
||||
i1 = atoi (d1); |
||||
i2 = atoi (d2); |
||||
|
||||
rc = i1 - i2; |
||||
|
||||
if (rc != 0) |
||||
return rc; |
||||
|
||||
while (isdigit (*d1)) |
||||
d1++; |
||||
|
||||
while (isdigit (*d2)) |
||||
d2++; |
||||
|
||||
k1=d1; |
||||
k2=d2; |
||||
/*return strcmp(d1,d2);*/ |
||||
/*return cw_ktv_mavlcmp(d1,d2);*/ |
||||
} |
||||
} |
@ -1,8 +0,0 @@ |
||||
|
||||
#include "val.h" |
||||
|
||||
int cw_ktv_mavlcmp_type_by_name (const void *v1, const void *v2) |
||||
{ |
||||
return strcmp ( (*((struct cw_Type**) v1))->name,
|
||||
(*((struct cw_Type**) v2))->name); |
||||
} |
@ -1,14 +0,0 @@ |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
|
||||
#include "val.h" |
||||
|
||||
void cw_ktv_mavldel(void *data) |
||||
{ |
||||
struct cw_Val *ktv = data; |
||||
if (ktv->type->del) { |
||||
ktv->type->del(data); |
||||
} |
||||
free(ktv->key); |
||||
} |
@ -1,359 +0,0 @@ |
||||
#include <stdint.h> |
||||
|
||||
#include "val.h" |
||||
|
||||
|
||||
static int str_getc(struct cw_Val_Reader * r) |
||||
{ |
||||
if (r->next==r->maxlen) |
||||
return EOF; |
||||
|
||||
return *((uint8_t*)(r->data)+r->next++); |
||||
} |
||||
|
||||
static void str_ungetc(struct cw_Val_Reader * r, int c) |
||||
{ |
||||
if (r->next>0) |
||||
r->next--; |
||||
} |
||||
|
||||
void cw_ktv_init_str_reader(struct cw_Val_Reader *r, const char * str, int len) |
||||
{ |
||||
memset(r,0,sizeof(struct cw_Val_Reader)); |
||||
r->data = str; |
||||
r->xgetchar=str_getc; |
||||
r->ungetchar=str_ungetc; |
||||
r->maxlen=len; |
||||
} |
||||
|
||||
#include <ctype.h> |
||||
|
||||
#include "val.h" |
||||
/*
|
||||
struct parser { |
||||
int line; |
||||
int pos; |
||||
int prevpos; |
||||
char error[256]; |
||||
int quote; |
||||
FILE *f; |
||||
int (*getc)(struct parser *); |
||||
void (*ungetc)(struct parser *) |
||||
}; |
||||
*/ |
||||
|
||||
|
||||
|
||||
static int get_char(struct cw_Val_Reader *r) |
||||
{ |
||||
int c; |
||||
c = r->xgetchar (r); |
||||
r->pos++; |
||||
if (c=='\n'){ |
||||
r->prevpos=r->pos; |
||||
r->line ++; |
||||
r->pos=0; |
||||
} |
||||
return c; |
||||
} |
||||
|
||||
|
||||
static void unget_char(struct cw_Val_Reader * r,int c){ |
||||
r->ungetchar(r,c); |
||||
if (c=='\n'){ |
||||
r->line--; |
||||
r->pos=r->prevpos; |
||||
} |
||||
else |
||||
r->pos--; |
||||
} |
||||
|
||||
|
||||
|
||||
static int get_char_q(struct cw_Val_Reader *p) |
||||
{ |
||||
int c; |
||||
|
||||
while(1) { |
||||
c = get_char(p); |
||||
if (c==EOF || c=='\n') |
||||
return c; |
||||
|
||||
if(c=='"' && !p->quote){ |
||||
p->quote=1; |
||||
continue; |
||||
} |
||||
if(c=='"' && p->quote){ |
||||
p->quote=0; |
||||
continue; |
||||
} |
||||
break; |
||||
} |
||||
|
||||
|
||||
if (!p->quote) |
||||
return c; |
||||
|
||||
if (c!='\\') |
||||
return c; |
||||
|
||||
c = get_char(p); |
||||
switch(c){ |
||||
case EOF: |
||||
return c; |
||||
case 'n': |
||||
return '\n'; |
||||
|
||||
case '\\': |
||||
return '\\'; |
||||
case '"': |
||||
return '"'; |
||||
default: |
||||
unget_char(p,c); |
||||
return '\\'; |
||||
} |
||||
|
||||
/* We will never reach here */ |
||||
/* return c;*/ |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int skip_chars (struct cw_Val_Reader *r, const char * chars) |
||||
{ |
||||
int c; |
||||
|
||||
while ( (c = get_char (r)) != EOF) { |
||||
if (strchr (chars, c)) |
||||
continue; |
||||
return c; |
||||
} |
||||
return c; |
||||
} |
||||
|
||||
static int skip_to_chars (struct cw_Val_Reader *r, const char *chars) |
||||
{ |
||||
int c; |
||||
|
||||
while ( (c = get_char (r)) != EOF) { |
||||
if (strchr (chars, c)) |
||||
return c; |
||||
} |
||||
return c; |
||||
} |
||||
|
||||
|
||||
|
||||
static int read_key (struct cw_Val_Reader *r, char *key, int max_len) |
||||
{ |
||||
int c,n; |
||||
|
||||
do { |
||||
c = skip_chars (r, " \t\n\a\v"); |
||||
if (c == '#') { |
||||
c = skip_to_chars (r, "\n\a"); |
||||
} else { |
||||
break; |
||||
} |
||||
} while (c != EOF); |
||||
|
||||
unget_char(r,c); |
||||
c=get_char_q(r); |
||||
|
||||
n=0; |
||||
while(c!=EOF && n<max_len){ |
||||
if (!r->quote && !isalnum(c) && !strchr("._/-()@#|{}[]\\",c)){ |
||||
unget_char(r,c); |
||||
break; |
||||
} |
||||
|
||||
key[n]=c; |
||||
c=get_char_q(r); |
||||
n++; |
||||
|
||||
} |
||||
key[n]=0; |
||||
return n; |
||||
} |
||||
|
||||
|
||||
static int skip_to_colon(struct cw_Val_Reader * r) |
||||
{ |
||||
int c; |
||||
c = skip_chars (r, " \t"); |
||||
if (c!=':' && c!='='){ |
||||
if (c=='\n'){ |
||||
unget_char(r,c); |
||||
sprintf(r->error,"Unexpected EOL, colon or equal sign expected."); |
||||
return -1; |
||||
} |
||||
sprintf(r->error,"Colon or equal sign expected."); |
||||
return -1; |
||||
} |
||||
return c; |
||||
} |
||||
|
||||
|
||||
static int read_type(struct cw_Val_Reader * r, char *type, int max_len) |
||||
{ |
||||
int c,n; |
||||
|
||||
c = skip_to_colon(r); |
||||
if (c==-1) |
||||
return -1; |
||||
if (c=='='){ |
||||
unget_char(r,c); |
||||
return sprintf(type,"%s","Str"); |
||||
|
||||
} |
||||
|
||||
c = skip_chars (r, " \t"); |
||||
|
||||
if (c==':'){ |
||||
unget_char(r,c); |
||||
sprintf(type,"%s","Str"); |
||||
return 0; |
||||
} |
||||
|
||||
if (!isalpha(c)){ |
||||
if (c=='\n'){ |
||||
unget_char(r,c); |
||||
/*sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL.", p->line, p->pos);*/ |
||||
return -1; |
||||
} |
||||
|
||||
/*sprintf(p->error,"Error at line %d, pos %d: Letter expected.", p->line, p->pos);*/ |
||||
return -1; |
||||
} |
||||
|
||||
n=0; |
||||
while(c!=EOF && n<max_len){ |
||||
if (!isalnum(c) && !strchr("_/-.()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){ |
||||
unget_char(r,c); |
||||
break; |
||||
} |
||||
|
||||
type[n]=c; |
||||
c=get_char(r); |
||||
n++; |
||||
} |
||||
type[n]=0; |
||||
return n; |
||||
} |
||||
|
||||
|
||||
static int read_val(struct cw_Val_Reader *r, char *val, int max_len){ |
||||
int c,n,quote; |
||||
c = skip_to_colon(r); |
||||
if (c==-1) |
||||
return -1; |
||||
c = skip_chars (r, " \t"); |
||||
if (c=='"'){ |
||||
quote=1; |
||||
c=get_char(r); |
||||
} |
||||
else{ |
||||
quote=0; |
||||
} |
||||
n=0; |
||||
while(c!=EOF && n<max_len){ |
||||
if (quote && c=='"'){ |
||||
break; |
||||
} |
||||
if (c=='\n'){ |
||||
break; |
||||
} |
||||
if (quote){ |
||||
if (c=='\\'){ |
||||
c = get_char(r); |
||||
switch(c){ |
||||
case 'n': |
||||
c='\n'; |
||||
break; |
||||
case '\\': |
||||
break; |
||||
case '"': |
||||
break; |
||||
default: |
||||
unget_char(r,c); |
||||
c='\\'; |
||||
} |
||||
} |
||||
} |
||||
val[n++]=c; |
||||
c=get_char(r); |
||||
} |
||||
|
||||
|
||||
if(!quote && n>0){ |
||||
while(n>0){ |
||||
if (isspace(val[n-1])) |
||||
n--; |
||||
else |
||||
break; |
||||
} |
||||
} |
||||
|
||||
val[n]=0; |
||||
|
||||
return n; |
||||
|
||||
} |
||||
|
||||
|
||||
/*
|
||||
int cw_ktv_parse_line (FILE *f, char * key, char * type, char *val) |
||||
{ |
||||
int n; |
||||
|
||||
struct parser p; |
||||
p.line=1; |
||||
p.pos=0; |
||||
p.prevpos=0; |
||||
p.quote=0; |
||||
p.f=f; |
||||
|
||||
n = read_key (&p,key,CW_KTV_MAX_KEY_LEN); |
||||
n = read_type (&p,type,CW_KTV_MAX_KEY_LEN); |
||||
if (n==-1){ |
||||
return -1; |
||||
} |
||||
|
||||
n = read_val (&p,val,CW_KTV_MAX_KEY_LEN); |
||||
if (n==-1){ |
||||
return -1; |
||||
} |
||||
return 0; |
||||
} |
||||
*/ |
||||
|
||||
|
||||
int cw_ktv_parse_line(struct cw_Val_Reader * r) |
||||
{ |
||||
|
||||
} |
||||
|
||||
int cw_ktv_parse_string(struct cw_Val_Reader *r, char *key, char *type, char *val) |
||||
{ |
||||
|
||||
int n; |
||||
|
||||
|
||||
|
||||
n = read_key (r,key,CW_KTV_MAX_KEY_LEN); |
||||
n = read_type(r,type,200); |
||||
if (n==1) |
||||
return -1; |
||||
n = read_val(r,val,200); |
||||
return n; |
||||
|
||||
} |
@ -1,40 +0,0 @@ |
||||
|
||||
#include "val.h" |
||||
#include "cfg.h" |
||||
|
||||
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types) |
||||
{ |
||||
char key[CW_CFG_MAX_KEY_LEN]; |
||||
char type[256]; |
||||
char val[2048]; |
||||
|
||||
|
||||
int rc; |
||||
struct cw_Type typesearch, *cwtype; |
||||
|
||||
|
||||
do { |
||||
|
||||
rc = cw_ktv_read_line(file,key,type,val); |
||||
if (rc != 0){ |
||||
continue; |
||||
} |
||||
|
||||
|