Commit 20f59ee1 authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

conf: Add configuration file iteration functions



These allow linear searches of the configuration file
sections.

Change-Id: I8d8b9594bc8a974c16d999689a6195434c1efac8
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 97421601
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
+21 −0
Original line number Diff line number Diff line
@@ -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)
{