version 1.1, 2008/08/28 13:17:41
|
version 1.3, 2009/10/19 15:00:10
|
Line 1
|
Line 1
|
|
/************************************************************************* |
|
* (C) 2008 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com> |
|
* by Michael Pounov <misho@openbsd-bg.org> |
|
* |
|
* $Author$ |
|
* $Id$ |
|
* |
|
*************************************************************************/ |
#include "global.h" |
#include "global.h" |
#include "aitcfg.h" |
#include "aitcfg.h" |
|
|
Line 20 inline int InitConfig(sl_config * __restrict cfg)
|
Line 28 inline int InitConfig(sl_config * __restrict cfg)
|
if (!cfg) |
if (!cfg) |
return -1; |
return -1; |
|
|
return (int) (cfg->slh_first = NULL); | cfg->slh_first = NULL; |
| return 0; |
} |
} |
|
|
/* |
/* |
Line 67 void UnloadConfig(sl_config * __restrict cfg)
|
Line 76 void UnloadConfig(sl_config * __restrict cfg)
|
if (!cfg->slh_first) |
if (!cfg->slh_first) |
return; |
return; |
|
|
for (av = cfg->slh_first; av; av = av->sle_next) { | while ((av = cfg->slh_first)) { |
cfg->slh_first = cfg->slh_first->sle_next; |
cfg->slh_first = cfg->slh_first->sle_next; |
|
|
if (av->psValue) |
if (av->psValue) |
Line 102 int CreateConfig(const char *csConfigName, sl_config *
|
Line 111 int CreateConfig(const char *csConfigName, sl_config *
|
|
|
ret ^= ret; |
ret ^= ret; |
ret = WriteConfig(f, cfg); |
ret = WriteConfig(f, cfg); |
|
|
|
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); |
fclose(f); |
return ret; |
return ret; |