From d1392d80cdd6c40e36c965c6ff000e01a2ee1694 Mon Sep 17 00:00:00 2001 From: Justin Mitchell Date: Thu, 28 Sep 2017 14:09:10 -0400 Subject: conffile: Add get_str with default value The similar config code in libnfsidmap had one additional feature of a get_str function with a default value option, include an equivalent function here to maintain compatibility. Signed-off-by: Justin Mitchell Signed-off-by: Steve Dickson --- support/nfs/conffile.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'support/nfs/conffile.c') diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c index 8239d66..9c5ed8e 100644 --- a/support/nfs/conffile.c +++ b/support/nfs/conffile.c @@ -639,6 +639,18 @@ conf_get_str(const char *section, const char *tag) return conf_get_section(section, NULL, tag); } +/* Return the string value denoted by TAG in section SECTION, + * unless it is not set, in which case return def + */ +char * +conf_get_str_with_def(const char *section, const char *tag, char *def) +{ + char * result = conf_get_section(section, NULL, tag); + if (!result) + return def; + return result; +} + /* * Find a section that may or may not have an argument */ -- cgit