version 1.16.6.1, 2025/08/19 10:42:28
|
version 1.17, 2025/08/19 11:43:53
|
Line 160 cfgEndConfig(cfg_root_t **pcfg)
|
Line 160 cfgEndConfig(cfg_root_t **pcfg)
|
* cfgInitConfigExt() - Init existed config root |
* cfgInitConfigExt() - Init existed config root |
* |
* |
* @cfg = Config root |
* @cfg = Config root |
* return: NULL error or !=NULL inited config root | * return: -1 error or 0 inited config root |
*/ |
*/ |
cfg_root_t * | int |
cfgInitConfigExt(cfg_root_t * __restrict cfg) |
cfgInitConfigExt(cfg_root_t * __restrict cfg) |
{ |
{ |
if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg)) | if (!cfg) { |
cfgUnloadConfig(cfg); | cfg_SetErr(EINVAL, "Invalid parameter"); |
| return -1; |
| } |
|
|
memset(cfg, 0, sizeof(cfg_root_t)); |
memset(cfg, 0, sizeof(cfg_root_t)); |
|
|
Line 174 cfgInitConfigExt(cfg_root_t * __restrict cfg)
|
Line 176 cfgInitConfigExt(cfg_root_t * __restrict cfg)
|
|
|
TAILQ_INIT(cfg); |
TAILQ_INIT(cfg); |
RB_INIT(cfg); |
RB_INIT(cfg); |
return cfg; | return 0; |
} |
} |
|
|
/* |
/* |
Line 190 cfgLoadConfig(const char *cfgName, cfg_root_t * __rest
|
Line 192 cfgLoadConfig(const char *cfgName, cfg_root_t * __rest
|
FILE *f; |
FILE *f; |
int ret; |
int ret; |
|
|
if (!cfgName || !cfg) { | if (!cfgName || cfgInitConfigExt(cfg)) { |
cfg_SetErr(EINVAL, "Invalid parameter(s)"); |
cfg_SetErr(EINVAL, "Invalid parameter(s)"); |
return -1; |
return -1; |
} else { |
|
if (!TAILQ_EMPTY(cfg) || !RB_EMPTY(cfg)) |
|
cfgUnloadConfig(cfg); |
|
|
|
memset(cfg, 0, sizeof(cfg_root_t)); |
|
|
|
pthread_mutex_init(&cfg->rc_mtx, NULL); |
|
|
|
TAILQ_INIT(cfg); |
|
RB_INIT(cfg); |
|
} |
} |
|
|
f = fopen(cfgName, "r"); |
f = fopen(cfgName, "r"); |
Line 258 cfgUnloadConfig(cfg_root_t * __restrict cfg)
|
Line 250 cfgUnloadConfig(cfg_root_t * __restrict cfg)
|
|
|
cfgClearConfig(cfg); |
cfgClearConfig(cfg); |
pthread_mutex_destroy(&cfg->rc_mtx); |
pthread_mutex_destroy(&cfg->rc_mtx); |
|
memset(&cfg->rc_mtx, 0, sizeof cfg->rc_mtx); |
} |
} |
|
|
/* |
/* |