diff --git a/include/spdk/conf.h b/include/spdk/conf.h index 00d20efe0e..63beea2caa 100644 --- a/include/spdk/conf.h +++ b/include/spdk/conf.h @@ -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); diff --git a/lib/conf/conf.c b/lib/conf/conf.c index 146ec252dd..0ed07891f1 100644 --- a/lib/conf/conf.c +++ b/lib/conf/conf.c @@ -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) {