--- libaitcfg/src/queue.c 2014/03/19 17:44:48 1.14.4.3 +++ libaitcfg/src/queue.c 2014/03/19 18:36:08 1.14.4.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: queue.c,v 1.14.4.3 2014/03/19 17:44:48 misho Exp $ +* $Id: queue.c,v 1.14.4.4 2014/03/19 18:36:08 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -97,6 +97,8 @@ cfg_getSection(cfg_root_t * __restrict cfg, const char return NULL; } else memset(&fav, 0, sizeof fav); + if (csSec && !*csSec) + csSec = NULL; if (csSec && *csSec) AIT_KEY(&fav.cfg_sec) = crcFletcher16((u_short*) csSec, @@ -105,8 +107,13 @@ cfg_getSection(cfg_root_t * __restrict cfg, const char av = RB_NFIND(tagRC, cfg, &fav); if (!av) return NULL; - if (strcmp(AIT_GET_STR(&av->cfg_sec), csSec)) - return NULL; + if (csSec) { + if (AIT_ISEMPTY(&av->cfg_sec) || strcmp(AIT_GET_STR(&av->cfg_sec), csSec)) + return NULL; + } else { + if (!AIT_ISEMPTY(&av->cfg_sec)) + return NULL; + } arr = array_Init(1); if (!arr) { @@ -115,9 +122,17 @@ cfg_getSection(cfg_root_t * __restrict cfg, const char } else array_Push(arr, av, 0); - while ((av = RB_NEXT(tagRC, cfg, av)) && av && !AIT_ISEMPTY(&av->cfg_sec) && - !strcmp(AIT_GET_STR(&av->cfg_sec), csSec)) + while ((av = RB_NEXT(tagRC, cfg, av)) && av) { + if (csSec) { + if (AIT_ISEMPTY(&av->cfg_sec) || strcmp(AIT_GET_STR(&av->cfg_sec), csSec)) + break; + } else { + if (!AIT_ISEMPTY(&av->cfg_sec)) + break; + } + array_Push(arr, av, 0); + } return arr; }