summaryrefslogtreecommitdiffstats
path: root/discover/parser-conf.c
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2012-03-18 16:20:38 -0700
committerGeoff Levand <geoff@infradead.org>2012-03-18 16:27:55 -0700
commit24236269ce5126dfa60af60a925da503a7338c4d (patch)
treec6b52b327efc04cd017fccb29d2ad6c9282cc485 /discover/parser-conf.c
parent60384121c27eb92c25955a06e8dea088290f938b (diff)
downloadtalos-petitboot-24236269ce5126dfa60af60a925da503a7338c4d.tar.gz
talos-petitboot-24236269ce5126dfa60af60a925da503a7338c4d.zip
Add new member get_pair to conf parser context
To allow parsers more control over finding paramerter pairs add a new member get_pair to the parser struct conf_context. Initialize get_pair=conf_get_pair_equal for existing parsers. Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'discover/parser-conf.c')
-rw-r--r--discover/parser-conf.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/discover/parser-conf.c b/discover/parser-conf.c
index a21efc4..be19932 100644
--- a/discover/parser-conf.c
+++ b/discover/parser-conf.c
@@ -155,6 +155,9 @@ void conf_init_global_options(struct conf_context *conf)
{
int i;
+ if (!conf->global_options)
+ return;
+
for (i = 0; conf->global_options[i].name; i++)
conf->global_options[i].value = NULL;
}
@@ -171,6 +174,8 @@ int conf_set_global_option(struct conf_context *conf, const char *name,
{
int i;
+ assert(conf->global_options);
+
for (i = 0; conf->global_options[i].name; i++) {
if (streq(name, conf->global_options[i].name)) {
conf->global_options[i].value
@@ -196,6 +201,8 @@ const char *conf_get_global_option(struct conf_context *conf,
{
int i;
+ assert(conf->global_options);
+
for (i = 0; conf->global_options[i].name ;i++)
if (streq(name, conf->global_options[i].name)) {
pb_log("%s: @%s@%s@\n", __func__, name,
@@ -217,8 +224,11 @@ static void conf_parse_buf(struct conf_context *conf)
{
char *pos, *name, *value;
+ assert(conf->get_pair);
+ assert(conf->process_pair);
+
for (pos = conf->buf; pos;) {
- pos = conf_get_pair_equal(conf, pos, &name, &value, '\n');
+ pos = conf->get_pair(conf, pos, &name, &value, '\n');
if (!value)
continue;
OpenPOWER on IntegriCloud