conf: Add configuration file iteration functions

These allow linear searches of the configuration file
sections.

Change-Id: I8d8b9594bc8a974c16d999689a6195434c1efac8
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-05-12 15:38:22 -07:00 committed by Daniel Verkamp
parent 97421601b7
commit 20f59ee12e
2 changed files with 25 additions and 0 deletions

View File

@ -70,6 +70,10 @@ void spdk_conf_free(struct spdk_conf *cp);
int spdk_conf_read(struct spdk_conf *cp, const char *file);
struct spdk_conf_section *spdk_conf_find_section(struct spdk_conf *cp, const char *name);
/* Configuration file iteration */
struct spdk_conf_section *spdk_conf_first_section(struct spdk_conf *cp);
struct spdk_conf_section *spdk_conf_next_section(struct spdk_conf_section *sp);
bool spdk_conf_section_match_prefix(const struct spdk_conf_section *sp, const char *name_prefix);
char *spdk_conf_section_get_nmval(struct spdk_conf_section *sp, const char *key,
int idx1, int idx2);

View File

@ -215,6 +215,27 @@ spdk_conf_find_section(struct spdk_conf *cp, const char *name)
return NULL;
}
struct spdk_conf_section *
spdk_conf_first_section(struct spdk_conf *cp)
{
cp = CHECK_CP_OR_USE_DEFAULT(cp);
if (cp == NULL) {
return NULL;
}
return cp->section;
}
struct spdk_conf_section *
spdk_conf_next_section(struct spdk_conf_section *sp)
{
if (sp == NULL) {
return NULL;
}
return sp->next;
}
static void
append_cf_section(struct spdk_conf *cp, struct spdk_conf_section *sp)
{