--- libaitcfg/src/parse.c 2012/08/30 13:49:44 1.10.2.2 +++ libaitcfg/src/parse.c 2012/08/30 14:16:51 1.10.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: parse.c,v 1.10.2.2 2012/08/30 13:49:44 misho Exp $ +* $Id: parse.c,v 1.10.2.3 2012/08/30 14:16:51 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -361,7 +361,7 @@ cfgReadLines(FILE *f, const char *delim, const char *e { char line[BUFSIZ]; struct tagCfg *d, *av = NULL; - char *psAttr, *psVal = NULL; + char *p, *psSec, *psAttr, *psVal; if (!cfg) return -1; @@ -369,6 +369,7 @@ cfgReadLines(FILE *f, const char *delim, const char *e delim = ATR_LINES_DELIM; while (!feof(f)) { + psSec = psAttr = psVal = NULL; memset(line, 0, sizeof line); fgets(line, sizeof line - 1, f); /* check for user end-of-file */ @@ -385,12 +386,14 @@ cfgReadLines(FILE *f, const char *delim, const char *e continue; } - if (!io_MakeAV2(line, delim, &psAttr, &psVal)) + if (!io_MakeAV2(line, delim, &p, &psVal)) continue; else { + io_RTrimStr(p); io_LTrimStr(psVal); - io_RTrimStr(psAttr); } + if (!io_MakeAV2(p, SEC_LINES_DELIM, &psSec, &psAttr)) + psAttr = p; /* *NEW PAIR* alloc new pair element */ av = io_malloc(sizeof(struct tagCfg)); @@ -400,6 +403,11 @@ cfgReadLines(FILE *f, const char *delim, const char *e } else memset(av, 0, sizeof(struct tagCfg)); + if (psSec) { + AIT_SET_STR(&av->cfg_sec, psSec); + AIT_KEY(&av->cfg_sec) = crcFletcher16(AIT_GET_LIKE(&av->cfg_sec, u_short*), + io_align(AIT_LEN(&av->cfg_sec) - 1, 1) / 2); + } if (psVal) AIT_SET_STR(&av->cfg_val, psVal); AIT_SET_STR(&av->cfg_attr, psAttr);