Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / c0 / 765d861b80014dd0dbf6110fa2afe925984771
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 0D1886DE02D9\r
6  for <notmuch@notmuchmail.org>; Mon, 30 May 2016 04:50:29 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.012\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5\r
12  tests=[AWL=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id IdL_KacHErf7 for <notmuch@notmuchmail.org>;\r
17  Mon, 30 May 2016 04:50:20 -0700 (PDT)\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id CFDBF6DE028C\r
20  for <notmuch@notmuchmail.org>; Mon, 30 May 2016 04:50:11 -0700 (PDT)\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
22  (envelope-from <bremner@tethera.net>)\r
23  id 1b7Lhp-0000PA-0U; Mon, 30 May 2016 07:50:01 -0400\r
24 Received: (nullmailer pid 14848 invoked by uid 1000);\r
25  Mon, 30 May 2016 11:50:06 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [RFC2 Patch 1/5] lib: read "property" terms from messages.\r
29 Date: Mon, 30 May 2016 08:49:55 -0300\r
30 Message-Id: <1464608999-14774-2-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.8.1\r
32 In-Reply-To: <1464608999-14774-1-git-send-email-david@tethera.net>\r
33 References: <1463927339-5441-1-git-send-email-david@tethera.net>\r
34  <1464608999-14774-1-git-send-email-david@tethera.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.20\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Mon, 30 May 2016 11:50:29 -0000\r
48 \r
49 This is a first step towards providing an API to attach\r
50 arbitrary (key,value) pairs to messages and retrieve all of the values\r
51 for a given key.\r
52 ---\r
53  lib/database.cc       |  1 +\r
54  lib/message.cc        | 29 ++++++++++++++++++++++++++++-\r
55  lib/notmuch-private.h |  3 +++\r
56  3 files changed, 32 insertions(+), 1 deletion(-)\r
57 \r
58 diff --git a/lib/database.cc b/lib/database.cc\r
59 index 9630000..7750f50 100644\r
60 --- a/lib/database.cc\r
61 +++ b/lib/database.cc\r
62 @@ -237,6 +237,7 @@ static prefix_t BOOLEAN_PREFIX_INTERNAL[] = {\r
63      { "directory",             "XDIRECTORY" },\r
64      { "file-direntry",         "XFDIRENTRY" },\r
65      { "directory-direntry",    "XDDIRENTRY" },\r
66 +    { "property",               "XPROPERTY"  },\r
67  };\r
68  \r
69  static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {\r
70 diff --git a/lib/message.cc b/lib/message.cc\r
71 index 6839305..47946a3 100644\r
72 --- a/lib/message.cc\r
73 +++ b/lib/message.cc\r
74 @@ -37,6 +37,8 @@ struct visible _notmuch_message {\r
75      notmuch_string_list_t *filename_list;\r
76      char *author;\r
77      notmuch_message_file_t *message_file;\r
78 +    notmuch_string_list_t *property_term_list;\r
79 +    notmuch_string_map_t *property_map;\r
80      notmuch_message_list_t *replies;\r
81      unsigned long flags;\r
82      /* For flags that are initialized on-demand, lazy_flags indicates\r
83 @@ -116,6 +118,8 @@ _notmuch_message_create_for_document (const void *talloc_owner,\r
84      message->filename_list = NULL;\r
85      message->message_file = NULL;\r
86      message->author = NULL;\r
87 +    message->property_term_list = NULL;\r
88 +    message->property_map = NULL;\r
89  \r
90      message->replies = _notmuch_message_list_create (message);\r
91      if (unlikely (message->replies == NULL)) {\r
92 @@ -314,6 +318,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)\r
93         *id_prefix = _find_prefix ("id"),\r
94         *type_prefix = _find_prefix ("type"),\r
95         *filename_prefix = _find_prefix ("file-direntry"),\r
96 +       *property_prefix = _find_prefix ("property"),\r
97         *replyto_prefix = _find_prefix ("replyto");\r
98  \r
99      /* We do this all in a single pass because Xapian decompresses the\r
100 @@ -369,11 +374,21 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)\r
101             _notmuch_database_get_terms_with_prefix (message, i, end,\r
102                                                      filename_prefix);\r
103  \r
104 +\r
105 +    /* Get property terms. Mimic the setup with filenames above */\r
106 +    assert (strcmp (filename_prefix, property_prefix) < 0);\r
107 +    if (!message->property_map && !message->property_term_list)\r
108 +       message->property_term_list =\r
109 +           _notmuch_database_get_terms_with_prefix (message, i, end,\r
110 +                                                    property_prefix);\r
111 +\r
112      /* Get reply to */\r
113 -    assert (strcmp (filename_prefix, replyto_prefix) < 0);\r
114 +    assert (strcmp (property_prefix, replyto_prefix) < 0);\r
115      if (!message->in_reply_to)\r
116         message->in_reply_to =\r
117             _notmuch_message_get_term (message, i, end, replyto_prefix);\r
118 +\r
119 +\r
120      /* It's perfectly valid for a message to have no In-Reply-To\r
121       * header. For these cases, we return an empty string. */\r
122      if (!message->in_reply_to)\r
123 @@ -405,6 +420,18 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message,\r
124         message->filename_term_list = message->filename_list = NULL;\r
125      }\r
126  \r
127 +    if (strcmp ("property", prefix_name) == 0) {\r
128 +\r
129 +       if (message->property_term_list)\r
130 +           talloc_free (message->property_term_list);\r
131 +       message->property_term_list = NULL;\r
132 +\r
133 +       if (message->property_map)\r
134 +           talloc_free (message->property_map);\r
135 +\r
136 +       message->property_map = NULL;\r
137 +    }\r
138 +\r
139      if (strcmp ("replyto", prefix_name) == 0) {\r
140         talloc_free (message->in_reply_to);\r
141         message->in_reply_to = NULL;\r
142 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
143 index 9280797..6f9af91 100644\r
144 --- a/lib/notmuch-private.h\r
145 +++ b/lib/notmuch-private.h\r
146 @@ -537,6 +537,9 @@ _notmuch_string_list_append (notmuch_string_list_t *list,\r
147  void\r
148  _notmuch_string_list_sort (notmuch_string_list_t *list);\r
149  \r
150 +/* string-map.c */\r
151 +typedef struct _notmuch_string_map  notmuch_string_map_t;\r
152 +\r
153  /* tags.c */\r
154  \r
155  notmuch_tags_t *\r
156 -- \r
157 2.8.1\r
158 \r