From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GA+wMheeuWBG3gAAgWs5BA (envelope-from ) for ; Fri, 04 Jun 2021 05:29:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id ANzrLReeuWDKMgAA1q6Kng (envelope-from ) for ; Fri, 04 Jun 2021 03:29:27 +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 3BA452661F for ; Fri, 4 Jun 2021 05:29:27 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 715012B22E; Thu, 3 Jun 2021 23:29:15 -0400 (EDT) Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by mail.notmuchmail.org (Postfix) with ESMTPS id 5A21826BE0 for ; Thu, 3 Jun 2021 23:29:07 -0400 (EDT) Received: by mail-oi1-x229.google.com with SMTP id h9so8464530oih.4 for ; Thu, 03 Jun 2021 20:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VFPRtpy9bC5YY4yZYuZV2j7XgP3oNleyvn4VWam1N9o=; b=nLoyjA9HP3eZMP2+3uvn6nX75AuZFfDpCI4MoxwHWGp4bLPLgglWHNkq24LHpLRWmj qkaRcuy5jtW9uDjsgotOWj4PhwYNx4h3W0ePTpWfHgPkKE5ykJoz+g3R4oQgovh+Gv0M bB6uzropto2Qh38rEI03f+fcHwHkMRaI0buXYXIOIy17NDqNw0uGhGXON1JTzTRwv0qJ D1YaBYNQ1XJnvWZFt/WgpQ6y/aqVTyWs9xHq4Tqy2lsGsci8rBW0TZ7DVXoN0tMi/i41 zFbk6BPDMtNOcBQDG5x6WeW3EyNpl4MJL7piFN7FUZBbum9/wfa1hvWlXNfixmMT12yW ENxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VFPRtpy9bC5YY4yZYuZV2j7XgP3oNleyvn4VWam1N9o=; b=R+BVeyUBQzvDitH8zHZ/nk6sMllk2XHZb6gWIGAihD86vfCCS82/ZpVummGMCr41y8 1j2J8Or7jpxGKah204rvsfhsnuWx67R5chC0JzQRhpPjB2sUfFAPYNLt3WyxS64zPYqy cvpzLJJlCk2tNew1m6UWfaW55hbnt3qmzDQt+lTXkH2VdVod0Kpgd0Jhpf/8aJp+XjBk K3b+w5lXyb2r72YBrFZ1Yz/aGPjqJF7ks37mwgSaYS3hELBAYvmydyYsc4nJIC8sC2zU gTyrJhFixG32qMqndD7mDXMb3hp2BnACR9im2WdhTIhHGheDbdI32xM005M46GN4XWA3 qjYQ== X-Gm-Message-State: AOAM532FABPqGJlbp6VpMLHJro6uWwBi8cVYz6oqqRR0Ji+2wzBAEet2 MKYCCLAnLzwhILykIzEkwBBpGhlgQFppLA== X-Google-Smtp-Source: ABdhPJwi39XTSscpZ+TPFP+7GuiAYW3m8Cwcq6UZ0L4an6KC3A9ceTrmk0bjoABrSXLZcvN37zsfNA== X-Received: by 2002:a54:4501:: with SMTP id l1mr1631978oil.19.1622777346368; Thu, 03 Jun 2021 20:29:06 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id u14sm212320oif.41.2021.06.03.20.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 20:29:06 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Cc: David Bremner , Felipe Contreras Subject: [PATCH 2/3] ruby: add db.config Date: Thu, 3 Jun 2021 22:29:00 -0500 Message-Id: <20210604032901.3815539-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc2 In-Reply-To: <20210604032901.3815539-1-felipe.contreras@gmail.com> References: <20210604032901.3815539-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Message-ID-Hash: HVPMGUTURR3AYLI2FW7SLVUXZFPHDTGV X-Message-ID-Hash: HVPMGUTURR3AYLI2FW7SLVUXZFPHDTGV X-MailFrom: felipe.contreras@gmail.com 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-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622777367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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-unsubscribe:list-subscribe:list-post:dkim-signature; bh=S8MUy76qFbTb7pm19QJouLAXTpRK/XuTSIs6BVqeEMA=; b=KkRgpnfdqVTg+7NVCeSRWZ2cFuGN7Lnj6sUsHhRTEEGBwL1aLsu3aOIIGgls8fVjZ7VbyO WHk/dYtxIqIxuLumeawccVlk4Q98pP+byBw8zpXEPhdLvr+lZdHTzMyhJZR9k9lsKovXHf 2qAiHaL3S4oyXAS1ajmivwWT+PXqLBsOOO4jyEXRtQFOZU2pt70nLk7aAKh5/khDhiM76i OnrhWNCStYKHTMZ7hzkZh5JgTiPMiojCVK5XrDY+0A6eYNGyMPThoJ2zEcxMsEMpkXaHw2 J7zkC4n3DV0gyhEkmrsp8mibgLi/3vhD3r0Pgf9VnCOsoHHxYRTyoto9LM4UeA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622777367; a=rsa-sha256; cv=none; b=ZpQE6DRiGg0rVJ75D6D0RU2DHxzKmv/1ROm1PVciuYdiGfskttQfhNPcIewdeUuGkgAJ0g Pg3hiEYOcwXqcCtbqi+LWmIPPnJ+nVYELlG2HSnsrmomRsKpbUEIXrrSj2UdJYyA59PTAL VvZ12vtPCBJA+W2QB1GZsdPKI2xM5bKZR2mrLjJnHpvjBYk1Ao23PHNW+pJAonH14HlOu2 9Frqw0sLY8ijUEnam+UxHFfsPJDC3wQWrmBm3BM8ik58MTtTy76dfkoJDWLSibbP4s7rXA v1e5DfHkXPpQdeY+m5CyMOWQLgb71jBJwxyE8iVRCZUNsefkDs+FbGKqgFMC6Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=nLoyjA9H; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: -0.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=nLoyjA9H; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: 3BA452661F X-Spam-Score: -0.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: RR1cst4jjrU/ In order to use notmuch_config_get_pairs. Signed-off-by: Felipe Contreras --- bindings/ruby/database.c | 31 +++++++++++++++++++++++++++++++ bindings/ruby/defs.h | 4 ++++ bindings/ruby/init.c | 1 + test/T395-ruby.sh | 7 +++++++ 4 files changed, 43 insertions(+) diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index bc0c22cb..934cbfe8 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -479,3 +479,34 @@ notmuch_rb_database_query_create (VALUE self, VALUE qstrv) return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query); } + +/* + * call-seq: DB.config(prefix) {|key, value| block} => nil + * + * Calls +block+ once for each key/value pair. + * + */ +VALUE +notmuch_rb_database_config (int argc, VALUE *argv, VALUE self) +{ + VALUE prefix; + notmuch_database_t *db; + notmuch_config_pairs_t *list; + const char *cprefix; + + Data_Get_Notmuch_Database (self, db); + + rb_scan_args (argc, argv, "01", &prefix); + + cprefix = prefix != Qnil ? RSTRING_PTR (prefix) : ""; + + list = notmuch_config_get_pairs (db, cprefix); + for (; notmuch_config_pairs_valid (list); notmuch_config_pairs_move_to_next (list)) { + const char *key = notmuch_config_pairs_key (list); + const char *value = notmuch_config_pairs_value (list); + rb_yield (rb_ary_new3(2, nm_str_new (key), nm_str_new (value))); + } + notmuch_config_pairs_destroy (list); + + return Qnil; +} diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 78239229..f31e563b 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -57,6 +57,7 @@ extern ID ID_db_mode; /* Simple string helpers */ #define nm_str(str) (str != Qnil ? RSTRING_PTR (str) : NULL) +#define nm_str_new(str) (str ? rb_str_new_cstr (str) : Qnil) extern const rb_data_type_t notmuch_rb_object_type; extern const rb_data_type_t notmuch_rb_database_type; @@ -182,6 +183,9 @@ notmuch_rb_database_get_all_tags (VALUE self); VALUE notmuch_rb_database_query_create (VALUE self, VALUE qstrv); +VALUE +notmuch_rb_database_config (int argc, VALUE *argv, VALUE self); + /* directory.c */ VALUE notmuch_rb_directory_destroy (VALUE self); diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 27c7eba3..4b2f8655 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -277,6 +277,7 @@ Init_notmuch (void) notmuch_rb_database_find_message_by_filename, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */ + rb_define_method (notmuch_rb_cDatabase, "config", notmuch_rb_database_config, -1); /* in database.c */ /* * Document-class: Notmuch::Directory diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index 27ac4cc8..a7b09589 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -88,4 +88,11 @@ test_ruby < EXPECTED +test_ruby <<"EOF" +config_db = Notmuch::Database.open_with_config +config_db.config { |e| puts '%s=%s' % e } +EOF + test_done -- 2.32.0.rc2