version 1.4.4.2, 2012/04/03 09:21:06
|
version 1.6, 2012/07/22 21:54:47
|
Line 115 cfgInitConfig(cfg_root_t * __restrict cfg)
|
Line 115 cfgInitConfig(cfg_root_t * __restrict cfg)
|
if (!cfg) |
if (!cfg) |
return -1; |
return -1; |
|
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_init(&cfg->rc_mtx, NULL); |
pthread_mutex_init(&cfg->rc_mtx, NULL); |
#endif | |
SLIST_INIT(cfg); |
SLIST_INIT(cfg); |
RB_INIT(cfg); |
RB_INIT(cfg); |
return 0; |
return 0; |
Line 175 cfgUnloadConfig(cfg_root_t * __restrict cfg)
|
Line 174 cfgUnloadConfig(cfg_root_t * __restrict cfg)
|
AIT_FREE_VAL(&av->cfg_val); |
AIT_FREE_VAL(&av->cfg_val); |
AIT_FREE_VAL(&av->cfg_attr); |
AIT_FREE_VAL(&av->cfg_attr); |
AIT_FREE_VAL(&av->cfg_sec); |
AIT_FREE_VAL(&av->cfg_sec); |
free(av); | io_free(av); |
} |
} |
cfg->rbh_root = NULL; |
cfg->rbh_root = NULL; |
CFG_RC_UNLOCK(cfg); |
CFG_RC_UNLOCK(cfg); |
|
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_destroy(&cfg->rc_mtx); |
pthread_mutex_destroy(&cfg->rc_mtx); |
#endif |
|
} |
} |
|
|
#if 0 |
|
/* |
/* |
* CreateConfig() Create config file from memory | * cfgCreateConfig() - Create config file from memory |
| * |
* @csConfigName = New config filename |
* @csConfigName = New config filename |
* @cfg = Head list element | * @cfg = Config root |
* return: 0 ok; -1 error:: can`t save new config | * @whitespace = Additional whitespace characters to file |
*/ | * return: -1 error or 0 ok |
int CreateConfig(const char *csConfigName, sl_config * __restrict cfg) | */ |
| int |
| cfgCreateConfig(const char *csConfigName, cfg_root_t * __restrict cfg, int whitespace) |
{ |
{ |
FILE *f; |
FILE *f; |
int ret; |
int ret; |
Line 200 int CreateConfig(const char *csConfigName, sl_config *
|
Line 199 int CreateConfig(const char *csConfigName, sl_config *
|
if (!csConfigName || !cfg) |
if (!csConfigName || !cfg) |
return -1; |
return -1; |
|
|
f = fopen(csConfigName, "wt"); | f = fopen(csConfigName, "w"); |
if (!f) { |
if (!f) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} |
} |
|
|
ret ^= ret; | ret = cfgWriteConfig(f, cfg, whitespace); |
ret = WriteConfig(f, cfg); | |
|
|
fclose(f); |
fclose(f); |
return ret; |
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 |
|