From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eFT5IDu0Ll8KZAAA0tVLHw (envelope-from ) for ; Sat, 08 Aug 2020 14:18:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id gFXgHDu0Ll+wJQAAB5/wlQ (envelope-from ) for ; Sat, 08 Aug 2020 14:18:35 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 12E6E940223 for ; Sat, 8 Aug 2020 14:18:35 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 0E72529B6C; Sat, 8 Aug 2020 10:17:54 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 0988E29AF6 for ; Sat, 8 Aug 2020 10:17:25 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 018085FA66; Sat, 8 Aug 2020 10:17:24 -0400 (EDT) Received: (nullmailer pid 1124267 invoked by uid 1000); Sat, 08 Aug 2020 14:17:04 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 06/19] WIP: initial retrieval of database path from config file Date: Sat, 8 Aug 2020 11:16:40 -0300 Message-Id: <20200808141653.1124111-7-david@tethera.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200808141653.1124111-1-david@tethera.net> References: <20200808141653.1124111-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: CD4EXAX6R6GEN6NEZIUBOXJR5KFJTKK7 X-Message-ID-Hash: CD4EXAX6R6GEN6NEZIUBOXJR5KFJTKK7 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: 2YGW+Kvf/QVE --- lib/database.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/database.cc b/lib/database.cc index 350abb11..2ab9170d 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -935,12 +935,27 @@ notmuch_database_open_with_config (const char *database_path, void *local = talloc_new (NULL); notmuch_database_t *notmuch = NULL; char *notmuch_path, *xapian_path, *incompat_features; + char *configured_database_path = NULL; char *message = NULL; struct stat st; int err; unsigned int i, version; + GKeyFile *key_file = NULL; static int initialized = 0; + /* XXX TODO: default locations for NULL case, handle profiles */ + if (config_path != NULL && ! EMPTY_STRING (config_path)) { + key_file = g_key_file_new (); + if (! g_key_file_load_from_file (key_file, config_path, G_KEY_FILE_NONE, NULL)) { + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } + configured_database_path = g_key_file_get_value (key_file, "database", "path", NULL); + } + + if (database_path == NULL) + database_path = configured_database_path; + if (database_path == NULL) { message = strdup ("Error: Cannot open a database for a NULL path.\n"); status = NOTMUCH_STATUS_NULL_POINTER; @@ -1100,6 +1115,9 @@ notmuch_database_open_with_config (const char *database_path, DONE: talloc_free (local); + if (key_file) + g_key_file_free (key_file); + if (message) { if (status_string) *status_string = message; -- 2.28.0