version 1.12, 2013/05/30 09:12:27
|
version 1.12.4.1, 2014/01/29 23:46:35
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 | Copyright 2004 - 2014 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 138 cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg)
|
Line 138 cfgReadConfig(FILE *f, cfg_root_t * __restrict cfg)
|
} |
} |
/* section */ |
/* section */ |
if (*line == '[') { |
if (*line == '[') { |
AIT_SET_STR(&av->cfg_val, line); |
|
psAttr = line + strlen(line) - 1; |
psAttr = line + strlen(line) - 1; |
if (*psAttr == ']') { |
if (*psAttr == ']') { |
*psAttr = 0; |
*psAttr = 0; |
flg = 0; |
flg = 0; |
strlcpy(szSection, line + 1, sizeof szSection); |
strlcpy(szSection, line + 1, sizeof szSection); |
|
AIT_SET_STR(&av->cfg_sec, line); |
} else |
} else |
EDEBUG(7, "Ignore section '%s' ... not found ']'", line); |
EDEBUG(7, "Ignore section '%s' ... not found ']'", line); |
continue; |
continue; |
Line 196 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
Line 196 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
{ |
{ |
struct tagCfg *av; |
struct tagCfg *av; |
time_t tim; |
time_t tim; |
char line[BUFSIZ] = { 0 }, szSection[STRSIZ] = { 0 }; | char line[BUFSIZ] = { 0 }, szSection[STRSIZ] = { [0 ... STRSIZ - 1] = 0 }; |
|
|
if (!f || !cfg) { |
if (!f || !cfg) { |
cfg_SetErr(EINVAL, "Invalid parameter(s)"); |
cfg_SetErr(EINVAL, "Invalid parameter(s)"); |
Line 206 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
Line 206 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
CFG_RC_LOCK(cfg); |
CFG_RC_LOCK(cfg); |
_invertQueue(cfg); |
_invertQueue(cfg); |
SLIST_FOREACH(av, cfg, cfg_next) { |
SLIST_FOREACH(av, cfg, cfg_next) { |
/* add +1 line for section [] */ | /* empty lines or comment */ |
| if (AIT_ISEMPTY(&av->cfg_attr)) { |
| if (AIT_ISEMPTY(&av->cfg_val)) |
| continue; |
| strlcpy(line, AIT_GET_STR(&av->cfg_val), sizeof line); |
| goto skip_sec; |
| } |
| |
| /* section [] */ |
if (!AIT_ISEMPTY(&av->cfg_sec) && AIT_ADDR(&av->cfg_sec) && |
if (!AIT_ISEMPTY(&av->cfg_sec) && AIT_ADDR(&av->cfg_sec) && |
strcmp(AIT_GET_STR(&av->cfg_sec), szSection)) { |
strcmp(AIT_GET_STR(&av->cfg_sec), szSection)) { |
strlcpy(szSection, AIT_GET_STR(&av->cfg_sec), sizeof szSection); |
strlcpy(szSection, AIT_GET_STR(&av->cfg_sec), sizeof szSection); |
if (!cfg_Write(f, "\n[%s]\n", AIT_GET_STR(&av->cfg_sec))) { | if (!cfg_Write(f, "[%s]\n", AIT_GET_STR(&av->cfg_sec))) { |
LOGERR; |
LOGERR; |
|
_invertQueue(cfg); |
CFG_RC_UNLOCK(cfg); |
CFG_RC_UNLOCK(cfg); |
return -1; |
return -1; |
} |
} |
} | } else if (AIT_ISEMPTY(&av->cfg_sec) && *szSection) { |
if (AIT_ISEMPTY(&av->cfg_sec) && *szSection) { | |
memset(szSection, 0, sizeof szSection); |
memset(szSection, 0, sizeof szSection); |
if (!cfg_Write(f, "\n[]\n")) { | if (!cfg_Write(f, "[]\n")) { |
LOGERR; |
LOGERR; |
|
_invertQueue(cfg); |
CFG_RC_UNLOCK(cfg); |
CFG_RC_UNLOCK(cfg); |
return -1; |
return -1; |
} |
} |
Line 236 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
Line 245 cfgWriteConfig(FILE *f, cfg_root_t * __restrict cfg, i
|
} |
} |
if (!AIT_ISEMPTY(&av->cfg_val) && AIT_TYPE(&av->cfg_val) == string) |
if (!AIT_ISEMPTY(&av->cfg_val) && AIT_TYPE(&av->cfg_val) == string) |
strlcat(line, AIT_GET_STRZ(&av->cfg_val), sizeof line); |
strlcat(line, AIT_GET_STRZ(&av->cfg_val), sizeof line); |
| skip_sec: |
/* write */ |
/* write */ |
if (!cfg_Write(f, "%s\n", line)) { |
if (!cfg_Write(f, "%s\n", line)) { |
LOGERR; |
LOGERR; |