--- libaitcfg/src/queue.c 2024/10/29 00:55:44 1.19.10.1 +++ libaitcfg/src/queue.c 2025/10/09 16:43:05 1.21 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: queue.c,v 1.19.10.1 2024/10/29 00:55:44 misho Exp $ +* $Id: queue.c,v 1.21 2025/10/09 16:43:05 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -187,6 +187,39 @@ cfg_getSection(cfg_root_t * __restrict cfg, const char array_Destroy(&arr); return arr; +} + +/* + * cfg_delSection() - Delete entire section + * + * @cfg = Config root + * @csSec = Config section //[{csSec}] + * return: -1 error, 0 nothing deleted or >0 deleted attributes + */ +int +cfg_delSection(cfg_root_t * __restrict cfg, const char *csSec) +{ + int ret = 0; + array_t *arr = NULL; + struct tagCfg *av; + register int i; + + if (!cfg) { + cfg_SetErr(EINVAL, "Invalid argument(s)"); + return -1; + } + if (csSec && !*csSec) + csSec = NULL; + + arr = cfg_getSection(cfg, csSec); + if (!arr) + return ret; + for (i = 0; i < array_Size(arr); i++) + if ((av = array(arr, i, struct tagCfg*)) && AIT_ADDR(&av->cfg_attr)) + if (cfg_unsetAttribute(cfg, csSec, AIT_GET_STR(&av->cfg_attr)) > 0) + ret++; + array_Destroy(&arr); + return ret; } /*