--- libaitcfg/src/queue.c 2021/11/26 01:15:03 1.19 +++ 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 2021/11/26 01:15:03 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 @@ -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 - 2021 +Copyright 2004 - 2024 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -119,7 +119,7 @@ void cfg_dumpCfg(cfg_root_t * __restrict cfg) { struct tagCfg *r, *c, *ctmp, *q, *qtmp; - int syn; + int syn = 0; r = RB_ROOT(cfg); printf("ROOT:: KEY=%.8x [%s] %s=%s\n", ((AIT_KEY(&r->cfg_sec) << 15) | AIT_KEY(&r->cfg_attr)), @@ -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; } /*