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

iniGetSectionList() now supports an optional 'prefix' string argument, if

specified, will limit the sections that are returned to those that begin with
the specified prefix (which is removed from the section names).
parent 91f2a888
No related branches found
No related tags found
No related merge requests found
......@@ -198,7 +198,7 @@ void* iniFreeNamedStringList(named_string_t** list)
return(NULL);
}
char** iniGetSectionList(FILE* fp)
char** iniGetSectionList(FILE* fp, const char* prefix)
{
char* p;
char* tp;
......@@ -229,6 +229,11 @@ char** iniGetSectionList(FILE* fp)
if(tp==NULL)
continue;
*tp=0;
if(prefix!=NULL) {
if(strnicmp(p,prefix,strlen(prefix))!=0)
continue;
p+=strlen(prefix);
}
if((np=realloc(lp,sizeof(char*)*(items+2)))==NULL)
break;
lp=np;
......
......@@ -53,7 +53,8 @@ extern "C" {
#endif
/* Read all section names and return as an allocated string list */
char** iniGetSectionList (FILE* fp);
/* Optionally (if prefix!=NULL), returns a subset of section names */
char** iniGetSectionList (FILE* fp, const char* prefix);
/* Read all key names and return as an allocated string list */
char** iniGetKeyList (FILE* fp, 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.
Finish editing this message first!
Please register or to comment