From: Olivier Matz Date: Fri, 24 Dec 2010 12:15:30 +0000 (+0100) Subject: genconf: properly read the value of the "if" node X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d45ee7aeb6583d8b734489a7a9bc6fb5246ad282;p=libcmdline.git genconf: properly read the value of the "if" node Signed-off-by: Olivier Matz --- diff --git a/src/genconf/confnode_if.c b/src/genconf/confnode_if.c index f9e5f91..4722220 100644 --- a/src/genconf/confnode_if.c +++ b/src/genconf/confnode_if.c @@ -43,6 +43,8 @@ static int confnode_if_new(struct confnode *n, const struct line *line); static int confnode_if_close_dir(struct confnode *parent, const struct line *line); static int confnode_if_dotconfig_write(const struct confnode *n, FILE *f); +static int confnode_if_get_default_strvalue(const struct confnode *n, char *buf, + unsigned buflen); static const char *confnode_if_get_type_str(const struct confnode *n); static void confnode_if_display_short(const struct confnode *n); static void confnode_if_display_long(const struct confnode *n); @@ -58,7 +60,7 @@ static struct confnode_type confnode_if = { .set_user_strvalue = NULL, .get_user_strvalue = NULL, .set_default_strvalue = NULL, - .get_default_strvalue = NULL, + .get_default_strvalue = confnode_if_get_default_strvalue, .get_type_str = confnode_if_get_type_str, .display_short = confnode_if_display_short, .display_long = confnode_if_display_long, @@ -129,6 +131,19 @@ static int confnode_if_dotconfig_write(const struct confnode *n, FILE *f) return 0; } +static int confnode_if_get_default_strvalue(const struct confnode *n, char *buf, + unsigned buflen) +{ + const struct confnode *n2; + + n2 = conf_htable_lookup(n->value); + if (n2 == NULL) + return -1; + + /* XXX evaluate expression here instead */ + return confnode_get_value(n2, buf, buflen); +} + /* Return a string identifying the node type ("config", "menuconfig", * "choice", ...) */ static const char *confnode_if_get_type_str(const struct confnode *n)