From: Peter Wang Date: Wed, 25 Jul 2012 13:42:31 +0000 (+1000) Subject: [PATCH 02/18] insert: open database X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=34925fec7158276155631ffb6eeae530aa0c00d6;p=notmuch-archives.git [PATCH 02/18] insert: open database --- diff --git a/8b/ec94805d8cffd81e7682f073263ec4d8dc0a9a b/8b/ec94805d8cffd81e7682f073263ec4d8dc0a9a new file mode 100644 index 000000000..7fbf0565f --- /dev/null +++ b/8b/ec94805d8cffd81e7682f073263ec4d8dc0a9a @@ -0,0 +1,96 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 570F5431FCB + for ; Wed, 25 Jul 2012 06:43:21 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id zelQQdDvHO-5 for ; + Wed, 25 Jul 2012 06:43:20 -0700 (PDT) +Received: from mail-gg0-f181.google.com (mail-gg0-f181.google.com + [209.85.161.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C1A20431FBD + for ; Wed, 25 Jul 2012 06:43:20 -0700 (PDT) +Received: by ggnv5 with SMTP id v5so882427ggn.26 + for ; Wed, 25 Jul 2012 06:43:20 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=/WZ1gdDJRoXiRaTHZcoq5vyR2k9EM8mHbNXHGtEamW8=; + b=OYW85/RAPFdYAJlzeUDkBJbJ2CYjr5SNcPakCQsSzrnkzHon5+NyO/AYU7AqNBafv4 + tSnUgd1YQyHLA5eGGNO4AbdMzlKOkaG2HAMwscpLXKqcs+CZxQCxAbYWUCldRH8WmWPv + jliu3JyZH4A2tuHaKR2xH4wEf3rRP07BqESJYjikewDoZoSQVk85NEblrcqfjpV2LGKg + 7PKJo9mrG4AbJM9IznSj1kJ64bc5QqYi/QqbspyaitawHY3fHDOwQXKNL5lOFfc03OCr + TaqhGwm0pTFTRMkf0a/tXh4S89Bz43wi3RlXL4JUv+WB33YKJAiD/jHaqSm8GdlVKVve + 48ew== +Received: by 10.66.84.202 with SMTP id b10mr12796641paz.72.1343223799767; + Wed, 25 Jul 2012 06:43:19 -0700 (PDT) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) + by mx.google.com with ESMTPS id ru4sm14405666pbc.66.2012.07.25.06.43.17 + (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 25 Jul 2012 06:43:18 -0700 (PDT) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH 02/18] insert: open database +Date: Wed, 25 Jul 2012 23:42:31 +1000 +Message-Id: <1343223767-9812-2-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.7.4.4 +In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com> +References: <1343223767-9812-1-git-send-email-novalazy@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 25 Jul 2012 13:43:21 -0000 + +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, ¬much)) ++ return 1; ++ ++ notmuch_database_destroy (notmuch); ++ + return 1; + } +-- +1.7.4.4 +