--- libaitcfg/src/aitcfg.c 2025/08/19 11:43:53 1.17 +++ libaitcfg/src/aitcfg.c 2026/08/04 18:59:27 1.18 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcfg.c,v 1.17 2025/08/19 11:43:53 misho Exp $ +* $Id: aitcfg.c,v 1.18 2026/08/04 18:59:27 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2025 +Copyright 2004 - 2026 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -203,12 +203,42 @@ cfgLoadConfig(const char *cfgName, cfg_root_t * __rest return -1; } - ret = cfgReadConfig(f, cfg); + ret = cfg_ReadConfig(f, cfg, 1); fclose(f); return ret; } +/* + * cfgLoadConfigExt() - Load config from file with recursion level of includes + * + * @cfgName = Config filename + * @cfg = Config root + * @lvl = Level of include recursion + * return: -1 error or 0 ok + */ +int +cfgLoadConfigExt(const char *cfgName, cfg_root_t * __restrict cfg, int lvl) +{ + FILE *f; + int ret; + + if (!cfgName || cfgInitConfigExt(cfg)) { + cfg_SetErr(EINVAL, "Invalid parameter(s)"); + return -1; + } + + f = fopen(cfgName, "r"); + if (!f) { + LOGERR; + return -1; + } + + ret = cfg_ReadConfig(f, cfg, lvl); + + fclose(f); + return ret; +} /* * cfgClearConfig() - Clear config and free resources *