summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Mitchell <jumitche@redhat.com>2017-09-28 14:06:29 -0400
committerSteve Dickson <steved@redhat.com>2017-10-26 08:50:08 -0400
commit45484cb3ca377c03c0c6b1ac5d4f7975b81d3ff5 (patch)
treef7c56cb73e3723096edced04e836bb0e946b4a3f
parentb92df37d104c1790e16ec0f688202dec735d3eaa (diff)
downloadnfs-utils-45484cb3ca377c03c0c6b1ac5d4f7975b81d3ff5.tar.gz
nfs-utils-45484cb3ca377c03c0c6b1ac5d4f7975b81d3ff5.tar.xz
nfs-utils-45484cb3ca377c03c0c6b1ac5d4f7975b81d3ff5.zip
conffile: Merge conf_get_str and conf_get_section
conf_get_section() started as conf_get_str() with one extra search parameter, subsequent patches have not maintained feature parity, combine the code to make a single more generic function and just call that differently where required. Signed-off-by: Justin Mitchell <jumitche@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--support/nfs/conffile.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 4323fbb..8239d66 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -636,28 +636,9 @@ conf_match_num(const char *section, const char *tag, int x)
char *
conf_get_str(const char *section, const char *tag)
{
- struct conf_binding *cb;
-retry:
- cb = LIST_FIRST (&conf_bindings[conf_hash (section)]);
- for (; cb; cb = LIST_NEXT (cb, link)) {
- if (strcasecmp (section, cb->section) == 0
- && strcasecmp (tag, cb->tag) == 0) {
- if (cb->value[0] == '$') {
- /* expand $name from [environment] section,
- * or from environment
- */
- char *env = getenv(cb->value+1);
- if (env && *env)
- return env;
- section = "environment";
- tag = cb->value + 1;
- goto retry;
- }
- return cb->value;
- }
- }
- return 0;
+ return conf_get_section(section, NULL, tag);
}
+
/*
* Find a section that may or may not have an argument
*/
@@ -665,7 +646,7 @@ char *
conf_get_section(const char *section, const char *arg, const char *tag)
{
struct conf_binding *cb;
-
+retry:
cb = LIST_FIRST (&conf_bindings[conf_hash (section)]);
for (; cb; cb = LIST_NEXT (cb, link)) {
if (strcasecmp(section, cb->section) != 0)
@@ -674,6 +655,17 @@ conf_get_section(const char *section, const char *arg, const char *tag)
continue;
if (strcasecmp(tag, cb->tag) != 0)
continue;
+ if (cb->value[0] == '$') {
+ /* expand $name from [environment] section,
+ * or from environment
+ */
+ char *env = getenv(cb->value+1);
+ if (env && *env)
+ return env;
+ section = "environment";
+ tag = cb->value + 1;
+ goto retry;
+ }
return cb->value;
}
return 0;