From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id u3ACGjb+eWH6BAAAgWs5BA (envelope-from ) for ; Thu, 28 Oct 2021 03:34:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8E0qFTb+eWHyJgAA1q6Kng (envelope-from ) for ; Thu, 28 Oct 2021 01:34:46 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0C615C279 for ; Thu, 28 Oct 2021 03:34:46 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C37141F857; Wed, 27 Oct 2021 21:34:34 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id C651C1F73C for ; Wed, 27 Oct 2021 21:34:28 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 9D94C5FC48; Wed, 27 Oct 2021 21:34:28 -0400 (EDT) Received: (nullmailer pid 3999835 invoked by uid 1000); Thu, 28 Oct 2021 01:34:25 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/3] lib/open: track which parameters are passed Date: Wed, 27 Oct 2021 22:34:18 -0300 Message-Id: <20211028013419.3996019-3-david@tethera.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211028013419.3996019-1-david@tethera.net> References: <20211028013419.3996019-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: V5D4NJ766NRUPEJUAVQACYQH6GSKPGBY X-Message-ID-Hash: V5D4NJ766NRUPEJUAVQACYQH6GSKPGBY 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; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635384886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=/KUm5e7eaU4FdPlnmwHyBKOKVsJoQ/kFeXIYGZw7BAI=; b=YLK5lD51G7gUw6ZkPafzFgtF0+8xfjiBg5JLUbL2n67Rx8634XERgrUldhOujGmsmCl9ev jrwZdcsUQYthWYXDdY0uuBomRXmbH28qUqGYpah9LwzHLXamh/7Mb/m7LPJ3Wx4dGkhf86 2Rt9p8YNilHaccJrBuoZ/bqhoCGZBh30sAzL6FUoBH9YNMUwTbZkn7LbYBH3JOl0ZtM+SA +F4K6syk8Q22y2teKWpgXvWXyJgNfJ/DKBNM6yLBMrfJ443NYG9RMSakK31Bjohhd41vFI Mv/2UM8Hc0FsBP0GuxSKP4gHrKtWwY5U+80GKyOsXLMxzxTYka14Yj2PTZf4gQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635384886; a=rsa-sha256; cv=none; b=P6a4lXTeK+fCLAMe/RFQS+jrPb5Tk8t4BzWyC5Tf+iRiFqpNrZ8vs39vltQvUtu9IHxOhl 7697ap8bT34Wo4X+6v92rWv7s/RY4wBzkjrZw7evqafxgxahyL0j2XqSozTKQCVHZ7330X 4wrHC29aTqNnBOZnKu6jbfa6yiZUO9s7ZmK1vGS0E/7q8JomUDnQ98GR4zkHO0xbJ0mb8y vK0IUSwmYtwVm/zZ72opRw3Dw2LyuahRgPpNzE2J8tVck1BZDZQIvY43VDy57g9hKrve/G DU6Q62Uzhc3CPngsc44tBDIJ8HRxcIGIafymXnbyA1m6FOHArHh4+Y4hAPcOTg== ARC-Authentication-Results: i=1; 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-Migadu-Spam-Score: -1.15 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-Migadu-Queue-Id: 0C615C279 X-Spam-Score: -1.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7J/S6bz7WJVK This will be used to fine tune the loading of configuration for certain special configuration items (initially just "database.path"). --- lib/database-private.h | 36 ++++++++++++++++++++++++++++++++++++ lib/open.cc | 17 +++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 8b9d67fe..8dd77281 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -190,6 +190,39 @@ operator& (notmuch_field_flag_t a, notmuch_field_flag_t b) Xapian::QueryParser::FLAG_WILDCARD | \ Xapian::QueryParser::FLAG_PURE_NOT) +/* + * Which parameters were explicit when the database was opened */ +typedef enum { + NOTMUCH_PARAM_NONE = 0, + NOTMUCH_PARAM_DATABASE = 1 << 0, + NOTMUCH_PARAM_CONFIG = 1 << 1, + NOTMUCH_PARAM_PROFILE = 1 << 2, +} notmuch_open_param_t; + +/* + * define bitwise operators to hide casts */ + +inline notmuch_open_param_t +operator| (notmuch_open_param_t a, notmuch_open_param_t b) +{ + return static_cast( + static_cast(a) | static_cast(b)); +} + +inline notmuch_open_param_t& +operator|= (notmuch_open_param_t &a, notmuch_open_param_t b) +{ + a = a | b; + return a; +} + +inline notmuch_open_param_t +operator& (notmuch_open_param_t a, notmuch_open_param_t b) +{ + return static_cast( + static_cast(a) & static_cast(b)); +} + struct _notmuch_database { bool exception_reported; @@ -249,6 +282,9 @@ struct _notmuch_database { /* Cached and possibly overridden configuration */ notmuch_string_map_t *config; + + /* Track what parameters were specified when opening */ + notmuch_open_param_t params; }; /* Prior to database version 3, features were implied by the database diff --git a/lib/open.cc b/lib/open.cc index ba32c2f1..a942383b 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -247,7 +247,7 @@ _choose_database_path (void *ctx, } static notmuch_database_t * -_alloc_notmuch () +_alloc_notmuch (const char *database_path, const char *config_path, const char *profile) { notmuch_database_t *notmuch; @@ -263,6 +263,15 @@ _alloc_notmuch () notmuch->transaction_count = 0; notmuch->transaction_threshold = 0; notmuch->view = 1; + + notmuch->params = NOTMUCH_PARAM_NONE; + if (database_path) + notmuch->params |= NOTMUCH_PARAM_DATABASE; + if (config_path) + notmuch->params |= NOTMUCH_PARAM_CONFIG; + if (profile) + notmuch->params |= NOTMUCH_PARAM_PROFILE; + return notmuch; } @@ -510,7 +519,7 @@ notmuch_database_open_with_config (const char *database_path, _notmuch_init (); - notmuch = _alloc_notmuch (); + notmuch = _alloc_notmuch (database_path, config_path, profile); if (! notmuch) { status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; @@ -610,7 +619,7 @@ notmuch_database_create_with_config (const char *database_path, _notmuch_init (); - notmuch = _alloc_notmuch (); + notmuch = _alloc_notmuch (database_path, config_path, profile); if (! notmuch) { status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; @@ -812,7 +821,7 @@ notmuch_database_load_config (const char *database_path, _notmuch_init (); - notmuch = _alloc_notmuch (); + notmuch = _alloc_notmuch (database_path, config_path, profile); if (! notmuch) { status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; -- 2.33.0