--- libaitcfg/src/aitcfg.c 2012/04/03 11:51:52 1.4.4.3 +++ libaitcfg/src/aitcfg.c 2012/04/03 14:39:20 1.4.4.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcfg.c,v 1.4.4.3 2012/04/03 11:51:52 misho Exp $ +* $Id: aitcfg.c,v 1.4.4.4 2012/04/03 14:39:20 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -182,14 +182,16 @@ cfgUnloadConfig(cfg_root_t * __restrict cfg) pthread_mutex_destroy(&cfg->rc_mtx); } -#if 0 /* - * CreateConfig() Create config file from memory + * cfgCreateConfig() - Create config file from memory + * * @csConfigName = New config filename - * @cfg = Head list element - * return: 0 ok; -1 error:: can`t save new config -*/ -int CreateConfig(const char *csConfigName, sl_config * __restrict cfg) + * @cfg = Config root + * @whitespace = Additional whitespace characters to file + * return: -1 error or 0 ok + */ +int +cfgCreateConfig(const char *csConfigName, cfg_root_t * __restrict cfg, int whitespace) { FILE *f; int ret; @@ -197,43 +199,14 @@ int CreateConfig(const char *csConfigName, sl_config * if (!csConfigName || !cfg) return -1; - f = fopen(csConfigName, "wt"); + f = fopen(csConfigName, "w"); if (!f) { LOGERR; return -1; } - ret ^= ret; - ret = WriteConfig(f, cfg); + ret = cfgWriteConfig(f, cfg, whitespace); fclose(f); return ret; } - -/* - * cfg_CreateConfig() Create config file from memory without whitespaces! - * @csConfigName = New config filename - * @cfg = Head list element - * return: 0 ok; -1 error:: can`t save new config -*/ -int cfg_CreateConfig(const char *csConfigName, sl_config * __restrict cfg) -{ - FILE *f; - int ret; - - if (!csConfigName || !cfg) - return -1; - - f = fopen(csConfigName, "wt"); - if (!f) { - LOGERR; - return -1; - } - - ret ^= ret; - ret = cfg_WriteConfig(f, cfg); - - fclose(f); - return ret; -} -#endif