list_config_entries

Lists the names of all entries in a config section

Description

int list_config_entries(const char *section, const char ***names);
This function can be used to get a list of all entries in the given config section. The names parameter is a pointer to an array of strings. If it points to a NULL pointer, the list will be allocated, else it will be re-allocated. You should free the list again with free_config_entries if you don't need it anymore, or you can pass it again to list_config_entries and the memory will be re-used. See the following example for how you can use it, it will print out the complete contents of the current configuration:
   int i, n;
   char const **sections = NULL;
   char const **entries = NULL;

n = list_config_sections(&sections); /* loop through all section names */ for (i = 0; i < n; i++) { int j, m; printf("%s\n", sections[i]); m = list_config_entries(sections[i], &entries); /* loop through all entries in the section */ for (j = 0; j < m; j++) { printf(" %s=\"%s\"\n", entries[j], get_config_string( sections[i], entries[j], "-")); } } free_config_entries(&sections); free_config_entries(&entries);
Returns the number of valid strings in the names array.

Related Discussions

The following threads each have code containing this keyword: Note: You can click on the numbers to jump directly to the posts that reference this page.