You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be useful to be able to test if a particular section exists before trying to read anything from it. This would allow for creating relevant structures in advance. And it would be especially useful in situations when you cannot rely on any key/value pair being always present if a section exists.
Is this something that could be supported without expanding existing API? e.g.,
I wrote a function to return a list of sections. Perhaps this will be useful.
int get_sections(ini_t *inidata, int maxsect, char *sections[])
{
/* returns a list of INI sections */
char *p;
int i = 0;
for(p = inidata->data; p < inidata->end; p++)
if(*p == '[') {
if(p > inidata->data && *(p - 1)) /* line does not start with [ */
continue;
sections[i++] = strdup(p + 1);
if(i == maxsect)
break;
}
return (i);
}
It'd be useful to be able to test if a particular section exists before trying to read anything from it. This would allow for creating relevant structures in advance. And it would be especially useful in situations when you cannot rely on any key/value pair being always present if a section exists.
Is this something that could be supported without expanding existing API? e.g.,
ini_get(config, "owner", NULL) == NULL // section doesn't exist
ini_get(config, "owner", NULL) != NULL // section exists
If that sounds OK to you I could create a PR.
The text was updated successfully, but these errors were encountered: