diff --git a/HISTORY b/HISTORY index fb97152..ac027a5 100644 --- a/HISTORY +++ b/HISTORY @@ -1,11 +1,12 @@ -Version 1.21 2015-09-13 +Version 1.21 2015-09-14 * ini_file_reader support annotation function * correct PTHREAD_MUTEX_ERRORCHECK define * support 32 bit OS * allow_ips support CIDR addresses such as 172.16.12.0/22 * add function get_first_local_ip * ioevent for BSD ok + * iniGetValues use iniGetValuesEx Version 1.20 2015-08-06 * add GEO function get_line_distance_km diff --git a/src/ini_file_reader.c b/src/ini_file_reader.c index 5370af3..0d776d8 100644 --- a/src/ini_file_reader.c +++ b/src/ini_file_reader.c @@ -831,55 +831,35 @@ bool iniGetBoolValue(const char *szSectionName, const char *szItemName, \ int iniGetValues(const char *szSectionName, const char *szItemName, \ IniContext *pContext, char **szValues, const int max_values) { - IniItem targetItem; - IniSection *pSection; - IniItem *pFound; IniItem *pItem; IniItem *pItemEnd; char **ppValues; + int count; if (max_values <= 0) { return 0; } - INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, \ - targetItem, pFound, 0) - if (pFound == NULL) + pItem = iniGetValuesEx(szSectionName, szItemName, + pContext, &count); + if (count == 0) { return 0; } + if (count > max_values) + { + count = max_values; + } ppValues = szValues; - *ppValues++ = pFound->value; - for (pItem=pFound-1; pItem>=pSection->items; pItem--) + pItemEnd = pItem + count; + for (; pItemname, szItemName) != 0) - { - break; - } - - if (ppValues - szValues < max_values) - { - *ppValues++ = pItem->value; - } + *ppValues++ = pItem->value; } - pItemEnd = pSection->items + pSection->count; - for (pItem=pFound+1; pItemname, szItemName) != 0) - { - break; - } - - if (ppValues - szValues < max_values) - { - *ppValues++ = pItem->value; - } - } - - return ppValues - szValues; + return count; } IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, \