unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [WIP patch 4/9] lib: add and test function to retrieve current metadata value
Date: Sat,  9 Jan 2016 22:51:36 -0400	[thread overview]
Message-ID: <1452394301-29499-5-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1452394301-29499-1-git-send-email-david@tethera.net>

---
 lib/metadata.cc       | 11 +++++++++++
 lib/notmuch.h         |  7 +++++++
 test/T590-metadata.sh |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/lib/metadata.cc b/lib/metadata.cc
index 20805e5..6236992 100644
--- a/lib/metadata.cc
+++ b/lib/metadata.cc
@@ -227,4 +227,15 @@ notmuch_metadata_key (notmuch_metadata_t *metadata)
 }
 
 const char *
+notmuch_metadata_value (notmuch_metadata_t *metadata)
+{
+    const char *key = notmuch_metadata_key (metadata);
+    char *val;
+    notmuch_status_t status;
+
+    status=notmuch_database_get_metadata (metadata->notmuch, metadata->mclass, key, &val);
+    if (status)
+	return NULL;
+
+    return val;
 }
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 16d0973..dd359c8 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1872,6 +1872,13 @@ notmuch_metadata_valid (notmuch_metadata_t *metadata);
  */
 const char *
 notmuch_metadata_key (notmuch_metadata_t *metadata);
+
+/**
+ * return value for current metadata pair
+ */
+const char *
+notmuch_metadata_value (notmuch_metadata_t *metadata);
+
 /* @} */
 
 NOTMUCH_END_DECLS
diff --git a/test/T590-metadata.sh b/test/T590-metadata.sh
index 2c44746..d2326d4 100755
--- a/test/T590-metadata.sh
+++ b/test/T590-metadata.sh
@@ -62,12 +62,14 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
    RUN(notmuch_database_get_all_metadata (db, NOTMUCH_METADATA_CONFIG, &meta));
    printf("valid = %d\n", notmuch_metadata_valid (meta));
    printf("key = %s\n", notmuch_metadata_key (meta));
+   printf("val = %s\n", notmuch_metadata_value (meta));
 }
 EOF
 cat <<'EOF' >EXPECTED
 == stdout ==
 valid = 1
 key = testkey1
+val = testvalue1
 == stderr ==
 EOF
 test_expect_equal_file EXPECTED OUTPUT
-- 
2.6.4

  parent reply	other threads:[~2016-01-10  2:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10  2:51 WIP: add metadata to dump output David Bremner
2016-01-10  2:51 ` [WIP patch 1/9] lib: initial API for prefixed metadata David Bremner
2016-01-10  2:51 ` [WIP patch 2/9] lib: notmuch_metadata_t: iterators for metadata David Bremner
2016-01-10  2:51 ` [WIP patch 3/9] lib: add and test function to retrive current key David Bremner
2016-01-10  2:51 ` David Bremner [this message]
2016-01-10  2:51 ` [WIP patch 5/9] lib: add notmuch_metadata_move_to_next David Bremner
2016-01-10  2:51 ` [WIP patch 6/9] lib: add notmuch_metadata_destroy David Bremner
2016-01-10  2:51 ` [WIP patch 7/9] CLI: add print_status_database David Bremner
2016-01-10  2:51 ` [WIP patch 8/9] lib: make string representation of metadata class public David Bremner
2016-01-10  2:51 ` [WIP patch 9/9] CLI: add optional metadata to dump output David Bremner
2016-01-10 14:36 ` WIP: add " Tomi Ollila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452394301-29499-5-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).