From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 3/6] cli: config: keep track of whether the config is newly created
Date: Sun, 3 Mar 2013 23:55:07 +0200 [thread overview]
Message-ID: <1a1e9d8e37f178b8e1c9e41162366f6b9f326c99.1362347362.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1362347362.git.jani@nikula.org>
In-Reply-To: <cover.1362347362.git.jani@nikula.org>
Keep track of whether the config is newly created, and add
notmuch_config_is_new() accessor function to query this.
This is to support anyone with a config handle to check this, instead
of just whoever called notmuch_config_open().
---
notmuch-client.h | 3 +++
notmuch-config.c | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/notmuch-client.h b/notmuch-client.h
index 5f28836..07367e0 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -256,6 +256,9 @@ notmuch_config_close (notmuch_config_t *config);
int
notmuch_config_save (notmuch_config_t *config);
+notmuch_bool_t
+notmuch_config_is_new (notmuch_config_t *config);
+
const char *
notmuch_config_get_database_path (notmuch_config_t *config);
diff --git a/notmuch-config.c b/notmuch-config.c
index b5c2066..e733e92 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -104,6 +104,7 @@ static const char search_config_comment[] =
struct _notmuch_config {
char *filename;
GKeyFile *key_file;
+ notmuch_bool_t is_new;
char *database_path;
char *user_name;
@@ -266,6 +267,7 @@ notmuch_config_open (void *ctx,
config->key_file = g_key_file_new ();
+ config->is_new = FALSE;
config->database_path = NULL;
config->user_name = NULL;
config->user_primary_email = NULL;
@@ -435,6 +437,8 @@ notmuch_config_open (void *ctx,
if (is_new_ret)
*is_new_ret = is_new;
+ config->is_new = is_new;
+
return config;
}
@@ -482,6 +486,13 @@ notmuch_config_save (notmuch_config_t *config)
return 0;
}
+notmuch_bool_t
+notmuch_config_is_new (notmuch_config_t *config)
+{
+ return config->is_new;
+}
+
+
static const char **
_config_get_list (notmuch_config_t *config,
const char *section, const char *key,
--
1.7.10.4
next prev parent reply other threads:[~2013-03-03 21:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-03 21:55 [PATCH v2 0/6] notmuch cli config changes Jani Nikula
2013-03-03 21:55 ` [PATCH v2 1/6] cli: abstract subcommand finding into a new function Jani Nikula
2013-03-03 21:55 ` [PATCH v2 2/6] cli: plug main notmuch command into subcommand machinery Jani Nikula
2013-03-03 21:55 ` Jani Nikula [this message]
2013-03-03 21:55 ` [PATCH v2 4/6] cli: config: make notmuch_config_open() "is new" parameter input only Jani Nikula
2013-03-07 13:44 ` David Bremner
2013-03-07 14:38 ` Tomi Ollila
2013-03-03 21:55 ` [PATCH v2 5/6] cli: move config open/close to main() from subcommands Jani Nikula
2013-03-08 12:05 ` David Bremner
2013-03-03 21:55 ` [PATCH v2 6/6] cli: add top level --config=FILE option Jani Nikula
2013-03-04 19:53 ` [PATCH] man: document the notmuch --config=FILE global option Jani Nikula
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
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a1e9d8e37f178b8e1c9e41162366f6b9f326c99.1362347362.git.jani@nikula.org \
--to=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/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.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
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 read-only IMAP folder(s) and NNTP newsgroup(s).