From 24236269ce5126dfa60af60a925da503a7338c4d Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Sun, 18 Mar 2012 16:20:38 -0700 Subject: 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 --- discover/parser-conf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'discover/parser-conf.c') 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; -- cgit v1.2.1