[PATCH 02/18] insert: open database

Peter Wang novalazy at gmail.com
Wed Jul 25 06:42:31 PDT 2012


Open the notmuch configuration file and database.
---
 notmuch-insert.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 0e061a0..21424cf 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -23,5 +23,21 @@
 int
 notmuch_insert_command (void *ctx, int argc, char *argv[])
 {
+    notmuch_config_t *config;
+    notmuch_database_t *notmuch;
+    const char *db_path;
+
+    config = notmuch_config_open (ctx, NULL, NULL);
+    if (config == NULL)
+	return 1;
+
+    db_path = notmuch_config_get_database_path (config);
+
+    if (notmuch_database_open (notmuch_config_get_database_path (config),
+			       NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
+	return 1;
+
+    notmuch_database_destroy (notmuch);
+
     return 1;
 }
-- 
1.7.4.4



More information about the notmuch mailing list