linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Mitchell <jumitche@redhat.com>
To: Steve Dickson <steved@redhat.com>
Cc: linux-nfs <linux-nfs@vger.kernel.org>,
	"J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 3/7] nfs-utils: Add get_str with default value
Date: Thu, 14 Sep 2017 15:04:32 +0100	[thread overview]
Message-ID: <1505397872.3665.7.camel@redhat.com> (raw)
In-Reply-To: <1505397745.3665.4.camel@redhat.com>

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 <jumitche@redhat.com>
---
 support/include/conffile.h |  1 +
 support/nfs/conffile.c     | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/support/include/conffile.h b/support/include/conffile.h
index 0e7fa8b..d4cb6b4 100644
--- a/support/include/conffile.h
+++ b/support/include/conffile.h
@@ -58,6 +58,7 @@ extern struct conf_list *conf_get_tag_list(const char *, const char *);
 extern int      conf_get_num(const char *, const char *, int);
 extern _Bool    conf_get_bool(const char *, const char *, _Bool);
 extern char    *conf_get_str(const char *, const char *);
+extern char    *conf_get_str_with_def(const char *, const char *, char *);
 extern char    *conf_get_section(const char *, const char *, const char *);
 extern void     conf_init(const char *);
 extern void     conf_cleanup(void);
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 8239d66..d2f9441 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -639,6 +639,17 @@ 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
  */
-- 
1.8.3.1




  parent reply	other threads:[~2017-09-14 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 14:02 [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils UPDATED Justin Mitchell
2017-09-14 14:03 ` [PATCH 1/7] nfs-utils: const-ify the config handling functions Justin Mitchell
2017-09-14 14:03 ` [PATCH 2/7] nfs-utils: Merge conf_get_str and conf_get_section Justin Mitchell
2017-09-14 14:04 ` Justin Mitchell [this message]
2017-09-14 14:05 ` [PATCH 4/7] nfs-utils: split conffile to a separate convenience lib Justin Mitchell
2017-09-14 14:06 ` [PATCH 6/7] integrate libnfsidmap code with rest of nfs-utils Justin Mitchell
2017-09-14 14:07 ` [PATCH 7/7] nfs-utils: cleanup warnings from merged libnfsidmap code Justin Mitchell
2017-10-02 14:03 ` [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils UPDATED Steve Dickson
2017-10-02 16:38   ` J. Bruce Fields
2017-10-03  8:15     ` Justin Mitchell
2017-10-30 14:49 ` Steve Dickson
  -- strict thread matches above, loose matches on Subject: below --
2017-09-13 13:58 [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils Justin Mitchell
2017-09-13 14:02 ` [PATCH 3/7] nfs-utils: Add get_str with default value Justin Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505397872.3665.7.camel@redhat.com \
    --to=jumitche@redhat.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).