From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id gAcABVWNdGTawgAASxT56A (envelope-from ) for ; Mon, 29 May 2023 13:32:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id wLHUBFWNdGS7AwEA9RJhRA (envelope-from ) for ; Mon, 29 May 2023 13:32:37 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 E5FCE10964 for ; Mon, 29 May 2023 13:32:36 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 95B5E5F3D0; Mon, 29 May 2023 11:32:34 +0000 (UTC) Received: from phubs.tethera.net (phubs.tethera.net [192.99.9.157]) by mail.notmuchmail.org (Postfix) with ESMTPS id B4C1A5F361 for ; Mon, 29 May 2023 11:32:31 +0000 (UTC) Received: from tethera.net (fctnnbsc51w-159-2-164-113.dhcp-dynamic.fibreop.nb.bellaliant.net [159.2.164.113]) by phubs.tethera.net (Postfix) with ESMTPS id 4189E180061; Mon, 29 May 2023 08:32:30 -0300 (ADT) Received: (nullmailer pid 2096317 invoked by uid 1000); Mon, 29 May 2023 11:32:29 -0000 From: David Bremner To: Felipe Contreras , notmuch@notmuchmail.org Subject: Re: [PATCH 3/3] ruby: add db.{set,get}_config In-Reply-To: <20230331205338.174779-4-felipe.contreras@gmail.com> References: <20230331205338.174779-1-felipe.contreras@gmail.com> <20230331205338.174779-4-felipe.contreras@gmail.com> Date: Mon, 29 May 2023 08:32:29 -0300 Message-ID: <87353f1igi.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 2J5O4USISTOUCF65HGT4WFSL2NLAEIZD X-Message-ID-Hash: 2J5O4USISTOUCF65HGT4WFSL2NLAEIZD X-MailFrom: david@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 X-Migadu-Country: DE ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685359956; a=rsa-sha256; cv=none; b=hVljp+yYVTitxwO5vRsv+kjUL6ZaqqBYyFmk0I1LZpf8to5WEJ9yhRBJV7OZo3FXnwYJpY 5G3k5/gujYVoPtNv6Xl/5m7xIZF1dcBrQyfsIJF+sU/A1/hq2T/8JpKTvYhcA5n+TLU5Z2 kuBPcazxYBTz3Bo2BI53kA7SZlXZD4RR+0NWyhtrx9FF3ffN3ArQ+OISzc7EQK72k0owvm xpSWhIVnN8Ahqbb94tsKI4VZxLr4C08N9GLuv0kLgEegAmGtw00Azbppj22vqES7kxV7Rc hw4fbaeqM0YYTpcDy1M5tXRdtOiY4vXDaNXAbSlZZaYGbHqf6Tcvwba3WMS0eQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685359956; 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=sFOboRSNNgMyMOEifNn7HDDBAaumoY8YVBu6Q4bVSYw=; b=e1y06yc35WAIfGWNP6nv96+PmsZP34pI0Z7o54QkmchKGhIWA3gxs7fqQ117o7jIb4HX0F w785BMYJ8mIb49gUQeT/I5GP6eJ4fA30zu3g2hmZJAYA2C1Ck2ESHybLhYgxH5SOjUGEJN f+8K17dABC/WGQ5led7jX02hl9+guQGD47xTyMqIWGWNDY9WNE0WSe3ejJxQ1EeLp6xJko qP8bQRIrDNwTzvEbMR/gkx1wR68ytHi8JtR0c+2U4gcrZXXB/o+IFq10D9uEvIbQVpvZqw tq7qAhKi5isjw4DVjHMKAl3KjbpcWu3OFezrRjhQJl2eXhvOxhASbft4sMhRKw== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.65 X-Spam-Score: -1.65 X-Migadu-Queue-Id: E5FCE10964 X-TUID: fLlDST7d7Lk5 Felipe Contreras writes: > Signed-off-by: Felipe Contreras > --- > bindings/ruby/database.c | 45 ++++++++++++++++++++++++++++++++++++++++ > bindings/ruby/defs.h | 6 ++++++ > bindings/ruby/init.c | 2 ++ > 3 files changed, 53 insertions(+) So, usual request about tests... > +/* > + * call-seq: DB.get_config(key) => String > + * > + * Retrieves a configuration key. > + */ > +VALUE > +notmuch_rb_database_get_config (VALUE self, VALUE key) > +{ > + notmuch_database_t *db; > + notmuch_status_t ret; > + char *value; > + VALUE rvalue; > + > + Data_Get_Notmuch_Database (self, db); > + > + ret = notmuch_database_get_config (db, RSTRING_PTR (key), &value); > + notmuch_rb_status_raise (ret); > + > + rvalue = rb_str_new2 (value); > + free (value); > + > + return rvalue; > +} Just to be clear, there are (confusingly) two APIs for reading configuration. The one you are binding is in some sense the most low level and general but it might be good to encourage use of notmuch_config_get, since the use of an enum makes it less error-prone for well-known configuration values.