WTP reads two configs no
It read 1st the file startup.ckv, wich will never be overwritten. And then config.ckv, wich will saved when ever config cahnges ar made.
This commit is contained in:
parent
d7c826fac6
commit
4995cac9b8
@ -14,7 +14,7 @@ static int config_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr,
|
||||
{
|
||||
cw_dbg(DBG_X,"*** Configurations Status Response received ****");
|
||||
cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlbalCfg");
|
||||
cw_cfg_save(bootcfg.cfgfilename, params->conn->global_cfg,
|
||||
cw_cfg_save(bootcfg.config_file, params->conn->global_cfg,
|
||||
"#\n# This file is igenerated by WAT\n# If you edit this, your cahnges might be overwritten\n#\n");
|
||||
cw_dbg(DBG_X,"*** Cnofig Saved ***");
|
||||
|
||||
|
@ -35,7 +35,7 @@ static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr,
|
||||
// cw_dbg(DBG_X," **** Configuration Update Request Received ***");
|
||||
// cw_cfg_dump(params->conn->global_cfg);
|
||||
cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlobalCfg");
|
||||
cw_cfg_save(bootcfg.cfgfilename, params->conn->global_cfg,
|
||||
cw_cfg_save(bootcfg.config_file, params->conn->global_cfg,
|
||||
"#\n# This file is igenerated by WAT\n# If you edit this, your cahnges might be overwritten\n#\n");
|
||||
// cw_dbg(DBG_X," **** Configuration Update Request Received Saved ***");
|
||||
return 0;
|
||||
|
@ -27,7 +27,8 @@ struct bootcfg{
|
||||
const char * modnames[MAX_MODS];
|
||||
int nmods;
|
||||
const char * modpath;
|
||||
const char * cfgfilename;
|
||||
const char * config_file;
|
||||
const char * startup_file;
|
||||
};
|
||||
|
||||
extern struct bootcfg bootcfg;
|
||||
|
@ -32,9 +32,10 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
||||
int c;
|
||||
opterr = 1;
|
||||
|
||||
bootcfg->cfgfilename = "config.ckv";
|
||||
bootcfg->config_file = "config.ckv";
|
||||
bootcfg->startup_file = "startup.ckv";
|
||||
|
||||
while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) {
|
||||
while ( (c = getopt (argc, argv, "s:p:d:vc:m:h")) != -1) {
|
||||
|
||||
switch (c) {
|
||||
case 'v':
|
||||
@ -59,7 +60,10 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
||||
cw_mod_set_path(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
bootcfg->cfgfilename = optarg;
|
||||
bootcfg->config_file = optarg;
|
||||
break;
|
||||
case 's':
|
||||
bootcfg->startup_file = optarg;
|
||||
break;
|
||||
case '?':
|
||||
exit(EXIT_FAILURE);
|
||||
@ -86,7 +90,7 @@ int main (int argc, char **argv)
|
||||
struct cw_Conn * conn=NULL;
|
||||
//FILE * file;
|
||||
cw_Cfg_t * global_cfg =NULL;
|
||||
//const cw_Type_t ** ti;
|
||||
cw_Cfg_t * cfg=NULL;
|
||||
int i;
|
||||
int rc=EXIT_FAILURE;
|
||||
struct cw_DiscoveryResults * results;
|
||||
@ -120,14 +124,31 @@ int main (int argc, char **argv)
|
||||
cw_log(LOG_ERR, "Error creating global_cfg: %s", strerror(errno));
|
||||
goto errX;
|
||||
}
|
||||
global_cfg->name = "Global CFG";
|
||||
|
||||
/* read the initial config file */
|
||||
rc = cw_cfg_load(bootcfg.cfgfilename,global_cfg);
|
||||
|
||||
/* read the startup config file */
|
||||
rc = cw_cfg_load(bootcfg.startup_file,global_cfg);
|
||||
if (rc){
|
||||
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.startup_file, strerror(errno));
|
||||
goto errX;
|
||||
}
|
||||
|
||||
/* Create a temp. cfg */
|
||||
cfg = cw_cfg_create();
|
||||
if (cfg==NULL)
|
||||
goto errX;
|
||||
|
||||
/* read the current config file into temp. cfg */
|
||||
rc = cw_cfg_load(bootcfg.config_file,cfg);
|
||||
if (rc){
|
||||
cw_cfg_destroy(cfg);
|
||||
cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.config_file, strerror(errno));
|
||||
goto errX;
|
||||
}
|
||||
|
||||
/* copy the temp. cfg into startup cfg - and show debug messages */
|
||||
cw_cfg_copy(cfg, global_cfg,DBG_CFG_UPDATES,"Startup CFG");
|
||||
|
||||
/* create a connection object */
|
||||
conn = conn_create_noq(-1, NULL);
|
||||
@ -137,6 +158,8 @@ int main (int argc, char **argv)
|
||||
goto errX;
|
||||
}
|
||||
|
||||
cw_cfg_destroy(cfg);
|
||||
|
||||
|
||||
/* conn->mod=mod;*/
|
||||
conn->detected = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user