Skip to content
Snippets Groups Projects
Commit 378f990b authored by rswindell's avatar rswindell
Browse files

Created iniReadSectionCount(), like iniGetSectionCount(), except it operates

on FILE* (like iniReadSectionList()).
parent 9c4d5134
Branches
Tags
No related merge requests found
......@@ -931,6 +931,33 @@ size_t iniGetSectionCount(str_list_t list, const char* prefix)
return(items);
}
size_t iniReadSectionCount(FILE* fp, const char* prefix)
{
char* p;
char str[INI_MAX_LINE_LEN];
ulong items=0;
if(fp==NULL)
return(0);
rewind(fp);
while(!feof(fp)) {
if(fgets(str,sizeof(str),fp)==NULL)
break;
if(is_eof(str))
break;
if((p=section_name(str))==NULL)
continue;
if(prefix!=NULL)
if(strnicmp(p,prefix,strlen(prefix))!=0)
continue;
items++;
}
return(items);
}
str_list_t iniReadKeyList(FILE* fp, const char* section)
{
......
......@@ -67,6 +67,8 @@ extern "C" {
/* Read all section names and return as an allocated string list */
/* Optionally (if prefix!=NULL), returns a subset of section names */
str_list_t iniReadSectionList(FILE*, const char* prefix);
/* Returns number (count) of sections */
size_t iniReadSectionCount(FILE*, const char* prefix);
/* Read all key names and return as an allocated string list */
str_list_t iniReadKeyList(FILE*, const char* section);
/* Read all key and value pairs and return as a named string list */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment