Eliminated types_tree from msgset
This commit is contained in:
parent
e2e6d29069
commit
85f79eac6a
@ -111,6 +111,8 @@ send_cmd(struct shelldata * sd, const char *cmd)
|
|||||||
void
|
void
|
||||||
wlan0_cmd(struct shelldata * sd, const char *cmd)
|
wlan0_cmd(struct shelldata * sd, const char *cmd)
|
||||||
{
|
{
|
||||||
|
stop();
|
||||||
|
|
||||||
struct cw_Conn * conn;
|
struct cw_Conn * conn;
|
||||||
wtplist_lock();
|
wtplist_lock();
|
||||||
conn = find_ap(sd->prompt);
|
conn = find_ap(sd->prompt);
|
||||||
@ -119,7 +121,7 @@ wlan0_cmd(struct shelldata * sd, const char *cmd)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FILE *f=fopen("wlan0.ktv","r");
|
FILE *f=fopen("wlan0.ktv","r");
|
||||||
cw_ktv_read_file(f,sd->update_cfg,conn->msgset->types_tree);
|
// cw_ktv_read_file(f,sd->update_cfg,conn->msgset->types_tree);
|
||||||
//conn->update_cfg=sd->update_cfg;
|
//conn->update_cfg=sd->update_cfg;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,10 @@ void cw_msgset_destroy(struct cw_MsgSet *set)
|
|||||||
mavl_destroy(set->handlers_by_key);
|
mavl_destroy(set->handlers_by_key);
|
||||||
if (set->statemachine_states)
|
if (set->statemachine_states)
|
||||||
mavl_destroy(set->statemachine_states);
|
mavl_destroy(set->statemachine_states);
|
||||||
|
|
||||||
|
/* if (set->types_tree)
|
||||||
|
mavl_destroy(set->types_tree);*/
|
||||||
|
|
||||||
free(set);
|
free(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +118,7 @@ void cw_msgset_destroy(struct cw_MsgSet *set)
|
|||||||
*/
|
*/
|
||||||
struct cw_MsgSet *cw_msgset_create()
|
struct cw_MsgSet *cw_msgset_create()
|
||||||
{
|
{
|
||||||
const cw_Type_t **ti;
|
//const cw_Type_t **ti;
|
||||||
|
|
||||||
/* allocate memory for a message_set */
|
/* allocate memory for a message_set */
|
||||||
struct cw_MsgSet *set = malloc(sizeof(struct cw_MsgSet));
|
struct cw_MsgSet *set = malloc(sizeof(struct cw_MsgSet));
|
||||||
@ -149,15 +153,16 @@ struct cw_MsgSet *cw_msgset_create()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
set->types_tree = cw_ktv_create_types_tree();
|
/* set->types_tree = cw_ktv_create_types_tree();
|
||||||
if (set->types_tree == NULL){
|
if (set->types_tree == NULL){
|
||||||
cw_msgset_destroy(set);
|
cw_msgset_destroy(set);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* insert default types */
|
/ * insert default types * /
|
||||||
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
||||||
mavl_insert_ptr(set->types_tree,*ti);
|
mavl_insert_ptr(set->types_tree,*ti);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
set->statemachine_states = mavl_create(cmp_machinestate,NULL,sizeof(cw_StateMachineState_t));
|
set->statemachine_states = mavl_create(cmp_machinestate,NULL,sizeof(cw_StateMachineState_t));
|
||||||
@ -336,7 +341,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
update_msgdata(set, msg, msgdef);
|
update_msgdata(set, msg, msgdef);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
/* {
|
||||||
mavliter_t it;
|
mavliter_t it;
|
||||||
cw_dbg(DBG_MOD," Known types:");
|
cw_dbg(DBG_MOD," Known types:");
|
||||||
mavliter_init(&it,set->types_tree);
|
mavliter_init(&it,set->types_tree);
|
||||||
@ -345,7 +350,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
cw_dbg(DBG_MOD, " Type: %s", t->name);
|
cw_dbg(DBG_MOD, " Type: %s", t->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -64,7 +64,7 @@ struct cw_MsgSet {
|
|||||||
mavl_t msgdata;
|
mavl_t msgdata;
|
||||||
mavl_t handlers_by_id;
|
mavl_t handlers_by_id;
|
||||||
mavl_t handlers_by_key;
|
mavl_t handlers_by_key;
|
||||||
mavl_t types_tree;
|
// mavl_t types_tree;
|
||||||
mavl_t statemachine_states;
|
mavl_t statemachine_states;
|
||||||
int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
|
int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
|
||||||
int (*header_len)(struct cw_ElemHandler *handler);
|
int (*header_len)(struct cw_ElemHandler *handler);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "cw/dtls.h"
|
#include "cw/dtls.h"
|
||||||
#include "wtp.h"
|
#include "wtp.h"
|
||||||
#include "cw/mavltypes.h"
|
#include "cw/mavltypes.h"
|
||||||
|
#include "cw/cfg.h"
|
||||||
|
|
||||||
|
|
||||||
#define MAX_MODS 32
|
#define MAX_MODS 32
|
||||||
struct bootcfg{
|
struct bootcfg{
|
||||||
@ -85,17 +87,14 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct bootcfg bootcfg;
|
struct bootcfg bootcfg;
|
||||||
struct cw_Mod * mod;
|
struct cw_Mod * mod;
|
||||||
struct cw_MsgSet * msgset;
|
struct cw_MsgSet * msgset=NULL;
|
||||||
struct cw_Conn * conn;
|
struct cw_Conn * conn;
|
||||||
FILE * file;
|
FILE * file;
|
||||||
mavl_t global_cfg, types_tree;
|
cw_Cfg_t * global_cfg =NULL;
|
||||||
const cw_Type_t ** ti;
|
const cw_Type_t ** ti;
|
||||||
int i;
|
int i;
|
||||||
struct cw_DiscoveryResult dis;
|
struct cw_DiscoveryResult dis;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bootcfg.nmods=0;
|
bootcfg.nmods=0;
|
||||||
@ -118,33 +117,26 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create an empty global config */
|
/* create an empty global config */
|
||||||
global_cfg=cw_ktv_create();
|
global_cfg=cw_cfg_create();
|
||||||
if (msgset==NULL){
|
if (msgset==NULL){
|
||||||
cw_log(LOG_ERR, "Error creating global_cfg: %s", strerror(errno));
|
cw_log(LOG_ERR, "Error creating global_cfg: %s", strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
goto errX;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* create a types tree with default types */
|
|
||||||
types_tree = cw_ktv_create_types_tree();
|
|
||||||
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
|
||||||
mavl_insert_ptr(types_tree,*ti);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read the initial config file */
|
/* read the initial config file */
|
||||||
file = fopen(bootcfg.cfgfilename,"r");
|
rc = cw_cfg_load(bootcfg.cfgfilename,global_cfg);
|
||||||
|
if (rc){
|
||||||
if (file == NULL){
|
|
||||||
cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.cfgfilename, strerror(errno));
|
cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.cfgfilename, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
goto errX;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_ktv_read_file(file,global_cfg,types_tree);
|
// cw_ktv_read_file(file,global_cfg,types_tree);
|
||||||
|
|
||||||
|
|
||||||
cw_dbg_ktv_dump(global_cfg,DBG_CFG_DMP,"----- global cfg start -----","","----- global cfg end -----");
|
// cw_dbg_ktv_dump(global_cfg,DBG_CFG_DMP,"----- global cfg start -----","","----- global cfg end -----");
|
||||||
|
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
/*clean_cfg(global_cfg);*/
|
/*clean_cfg(global_cfg);*/
|
||||||
|
|
||||||
|
|
||||||
@ -244,5 +236,14 @@ printf("JOIN CONF\n");
|
|||||||
cw_discovery_free_results(&dis);
|
cw_discovery_free_results(&dis);
|
||||||
|
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
|
errX:
|
||||||
|
if (msgset)
|
||||||
|
cw_msgset_destroy(msgset);
|
||||||
|
|
||||||
|
if (global_cfg != NULL)
|
||||||
|
cw_cfg_destroy(global_cfg);
|
||||||
|
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user