Re: [PATCH v4 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message)
[notmuch-archives.git] / 57 / 953cdee2d64b2d6fe2417e71502c2a3308e2f0
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 365A76DE1B7F\r
6  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:03:11 -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.519\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.519 tagged_above=-999 required=5 tests=[AWL=0.509, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id 0VnzuO-pRVzu for <notmuch@notmuchmail.org>;\r
16  Sun,  5 Apr 2015 16:03:09 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id ACFBA6DE1BB6\r
20  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:03:01 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1YetYZ-0002pl-PW; Sun, 05 Apr 2015 23:02:19 +0000\r
24 Received: (nullmailer pid 2245 invoked by uid 1000); Sun, 05 Apr 2015\r
25  22:59:25 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [WIP2 05/12] cli: add two sprinter utility functions\r
29 Date: Mon,  6 Apr 2015 07:59:07 +0900\r
30 Message-Id: <1428274754-1698-6-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.1.4\r
32 In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>\r
33 References: <1428274754-1698-1-git-send-email-david@tethera.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.18\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 05 Apr 2015 23:03:11 -0000\r
47 \r
48 These are called directly, rather than via a vtable. They will\r
49 help add common metadata to search/show/reply\r
50 ---\r
51  devel/schemata   |  1 +\r
52  sprinter-utils.c | 41 +++++++++++++++++++++++++++++++++++++++++\r
53  sprinter.h       |  7 +++++++\r
54  3 files changed, 49 insertions(+)\r
55  create mode 100644 sprinter-utils.c\r
56 \r
57 diff --git a/devel/schemata b/devel/schemata\r
58 index 41dc4a6..98a1b2b 100644\r
59 --- a/devel/schemata\r
60 +++ b/devel/schemata\r
61 @@ -147,6 +147,7 @@ search_files = [string*]\r
62  search_tags = [string*]\r
63  \r
64  thread_summary = {\r
65 +    database:       database_metadata\r
66      thread:         threadid,\r
67      timestamp:      unix_time,\r
68      date_relative:  string,   # user-friendly timestamp\r
69 diff --git a/sprinter-utils.c b/sprinter-utils.c\r
70 new file mode 100644\r
71 index 0000000..2ba588e\r
72 --- /dev/null\r
73 +++ b/sprinter-utils.c\r
74 @@ -0,0 +1,41 @@\r
75 +#include "notmuch-client.h"\r
76 +#include "sprinter.h"\r
77 +\r
78 +notmuch_status_t\r
79 +sprinter_start_output (sprinter_t *sp,\r
80 +                      const notmuch_query_t *query,\r
81 +                      const char *query_type)\r
82 +{\r
83 +    long int rev;\r
84 +    const char *uuid;\r
85 +    notmuch_database_t *notmuch;\r
86 +\r
87 +    sp->begin_list (sp);\r
88 +\r
89 +    if (sp->type != NOTMUCH_SPRINTER_TEXT && notmuch_format_version >= 3) {\r
90 +       notmuch = notmuch_query_get_database (query);\r
91 +\r
92 +       rev = notmuch_database_get_revision (notmuch, &uuid);\r
93 +\r
94 +       sp->begin_map (sp);\r
95 +       sp->map_key (sp, "query_type");\r
96 +       sp->string (sp, query_type);\r
97 +\r
98 +       sp->map_key (sp, "uuid");\r
99 +       sp->string (sp, uuid);\r
100 +\r
101 +       sp->map_key (sp, "lastmod");\r
102 +       sp->integer (sp, rev);\r
103 +\r
104 +       sp->end (sp);\r
105 +\r
106 +    }\r
107 +    return NOTMUCH_STATUS_SUCCESS;\r
108 +}\r
109 +\r
110 +notmuch_status_t\r
111 +sprinter_finish_output (sprinter_t *sp)\r
112 +{\r
113 +    sp->end (sp); /* map */\r
114 +    return NOTMUCH_STATUS_SUCCESS;\r
115 +}\r
116 diff --git a/sprinter.h b/sprinter.h\r
117 index 7e58f69..4873f69 100644\r
118 --- a/sprinter.h\r
119 +++ b/sprinter.h\r
120 @@ -91,4 +91,11 @@ sprinter_json_create (const void *ctx, FILE *stream);\r
121  struct sprinter *\r
122  sprinter_sexp_create (const void *ctx, FILE *stream);\r
123  \r
124 +notmuch_status_t\r
125 +sprinter_start_output (struct sprinter *sp,\r
126 +                      const notmuch_query_t *query,\r
127 +                      const char *query_type);\r
128 +\r
129 +notmuch_status_t\r
130 +sprinter_finish_output (struct sprinter *sp);\r
131  #endif // NOTMUCH_SPRINTER_H\r
132 -- \r
133 2.1.4\r
134 \r