1 Return-Path: <amdragon@mit.edu>
\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 olra.theworths.org (Postfix) with ESMTP id 71507431FAE
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:16 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id BtzVWpzIRCyh for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jul 2012 19:35:13 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 94D84431FDC
\r
20 for <notmuch@notmuchmail.org>; Tue, 24 Jul 2012 19:35:06 -0700 (PDT)
\r
21 X-AuditID: 1209190d-b7fd56d000000933-56-500f5b5993d5
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id A3.A4.02355.95B5F005; Tue, 24 Jul 2012 22:35:05 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q6P2Z50n002601;
\r
27 Tue, 24 Jul 2012 22:35:05 -0400
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6P2Z2RQ025125
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Tue, 24 Jul 2012 22:35:04 -0400 (EDT)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1StrRG-0004Zs-Gw; Tue, 24 Jul 2012 22:35:02 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 06/13] show: Feed the sprinter down to part formatters
\r
41 Date: Tue, 24 Jul 2012 22:34:46 -0400
\r
42 Message-Id: <1343183693-17134-7-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10
\r
44 In-Reply-To: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1343183693-17134-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsUixCmqrRsZzR9gcHa/msXehnZGi+s3ZzI7
\r
48 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBlXlj9gKXjhU3F0x2a2BsZ1tl2MnBwSAiYS
\r
49 uw5eZYKwxSQu3FvP1sXIxSEksI9R4uTTu0wQzgZGiVmv17FAOI+YJJ7M/QyVmcsoMffEWlaQ
\r
50 fjYBDYlt+5czgtgiAtISO+/OBoszC5hJzP05kQ3EFhZwk2jcOBdsH4uAqkTb8t8sIDavgIPE
\r
51 vbn7oe6Ql3h6vw+snlPAUeL8koVgM4WAanoWX2OfwMi/gJFhFaNsSm6Vbm5iZk5xarJucXJi
\r
52 Xl5qka6RXm5miV5qSukmRnAwSfLuYHx3UOkQowAHoxIP7+8nfAFCrIllxZW5hxglOZiURHkr
\r
53 gvkDhPiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwFoUB5XhTEiurUovyYVLSHCxK4rxXUm76Cwmk
\r
54 J5akZqemFqQWwWRlODiUJHj3RwE1ChalpqdWpGXmlCCkmTg4QYbzAA3fDVLDW1yQmFucmQ6R
\r
55 P8WoKCXOOxckIQCSyCjNg+uFRfsrRnGgV4Qh2nmAiQKu+xXQYCagwc/D+EAGlyQipKQaGE2O
\r
56 pr+rXbMgnM/cTkG7oPCaJPO8giCW4EN/k+LN7LT+1SZeeqwiUeisym1rOesl/9SVeSZGW69N
\r
57 0UovLbrcphQ/X83+3wMl1rDwvEnP7KqTPNVPtvsLthvfve32vLqysWxRdajmxjXLCgNK1Zv+
\r
58 57NoWUX/mft6T5K217yZaoxeU9/2KrUosRRnJBpqMRcVJwIAh0GyItECAAA=
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Wed, 25 Jul 2012 02:35:16 -0000
\r
73 There are several levels of function calls between where we create the
\r
74 sprinter and the call to the part formatter in show_message. This
\r
75 feeds the sprinter through all of them and into the part formatters.
\r
77 notmuch-client.h | 5 +++--
\r
78 notmuch-reply.c | 2 +-
\r
79 notmuch-show.c | 50 +++++++++++++++++++++++++++++---------------------
\r
80 3 files changed, 33 insertions(+), 24 deletions(-)
\r
82 diff --git a/notmuch-client.h b/notmuch-client.h
\r
83 index e4172a2..8eeedf7 100644
\r
84 --- a/notmuch-client.h
\r
85 +++ b/notmuch-client.h
\r
86 @@ -72,7 +72,7 @@ struct notmuch_show_params;
\r
87 typedef struct notmuch_show_format {
\r
88 sprinter_t *(*new_sprinter) (const void *ctx, FILE *stream);
\r
89 const char *message_set_start;
\r
90 - notmuch_status_t (*part) (const void *ctx,
\r
91 + notmuch_status_t (*part) (const void *ctx, sprinter_t *sprinter,
\r
92 struct mime_node *node, int indent,
\r
93 const struct notmuch_show_params *params);
\r
94 const char *message_set_sep;
\r
95 @@ -179,7 +179,8 @@ notmuch_status_t
\r
96 show_one_part (const char *filename, int part);
\r
99 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body);
\r
100 +format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
101 + notmuch_bool_t first, notmuch_bool_t output_body);
\r
104 format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
\r
105 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
106 index e42ba79..07d4452 100644
\r
107 --- a/notmuch-reply.c
\r
108 +++ b/notmuch-reply.c
\r
109 @@ -624,7 +624,7 @@ notmuch_reply_format_json(void *ctx,
\r
110 /* Start the original */
\r
111 printf (", \"original\": ");
\r
113 - format_part_json (ctx, node, TRUE, TRUE);
\r
114 + format_part_json (ctx, sp, node, TRUE, TRUE);
\r
118 diff --git a/notmuch-show.c b/notmuch-show.c
\r
119 index d04943f..b258f65 100644
\r
120 --- a/notmuch-show.c
\r
121 +++ b/notmuch-show.c
\r
123 #include "sprinter.h"
\r
125 static notmuch_status_t
\r
126 -format_part_text (const void *ctx, mime_node_t *node,
\r
127 +format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
128 int indent, const notmuch_show_params_t *params);
\r
130 static const notmuch_show_format_t format_text = {
\r
131 @@ -32,7 +32,7 @@ static const notmuch_show_format_t format_text = {
\r
134 static notmuch_status_t
\r
135 -format_part_json_entry (const void *ctx, mime_node_t *node,
\r
136 +format_part_json_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
137 int indent, const notmuch_show_params_t *params);
\r
139 static const notmuch_show_format_t format_json = {
\r
140 @@ -45,7 +45,7 @@ static const notmuch_show_format_t format_json = {
\r
143 static notmuch_status_t
\r
144 -format_part_mbox (const void *ctx, mime_node_t *node,
\r
145 +format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
146 int indent, const notmuch_show_params_t *params);
\r
148 static const notmuch_show_format_t format_mbox = {
\r
149 @@ -54,7 +54,7 @@ static const notmuch_show_format_t format_mbox = {
\r
152 static notmuch_status_t
\r
153 -format_part_raw (unused (const void *ctx), mime_node_t *node,
\r
154 +format_part_raw (unused (const void *ctx), sprinter_t *sp, mime_node_t *node,
\r
155 unused (int indent),
\r
156 unused (const notmuch_show_params_t *params));
\r
158 @@ -471,7 +471,7 @@ format_part_sigstatus_json (mime_node_t *node)
\r
161 static notmuch_status_t
\r
162 -format_part_text (const void *ctx, mime_node_t *node,
\r
163 +format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
164 int indent, const notmuch_show_params_t *params)
\r
166 /* The disposition and content-type metadata are associated with
\r
167 @@ -553,7 +553,7 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
170 for (i = 0; i < node->nchildren; i++)
\r
171 - format_part_text (ctx, mime_node_child (node, i), indent, params);
\r
172 + format_part_text (ctx, sp, mime_node_child (node, i), indent, params);
\r
174 if (GMIME_IS_MESSAGE (node->part))
\r
175 printf ("\fbody}\n");
\r
176 @@ -564,7 +564,8 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
180 -format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body)
\r
181 +format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
\r
182 + notmuch_bool_t first, notmuch_bool_t output_body)
\r
184 /* Any changes to the JSON format should be reflected in the file
\r
185 * devel/schemata. */
\r
186 @@ -578,7 +579,7 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notm
\r
189 printf (", \"body\": [");
\r
190 - format_part_json (ctx, mime_node_child (node, 0), first, TRUE);
\r
191 + format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
\r
195 @@ -659,16 +660,17 @@ format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notm
\r
196 talloc_free (local);
\r
198 for (i = 0; i < node->nchildren; i++)
\r
199 - format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE);
\r
200 + format_part_json (ctx, sp, mime_node_child (node, i), i == 0, TRUE);
\r
202 printf ("%s}", terminator);
\r
205 static notmuch_status_t
\r
206 -format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),
\r
207 +format_part_json_entry (const void *ctx, sprinter_t *sp,
\r
208 + mime_node_t *node, unused (int indent),
\r
209 const notmuch_show_params_t *params)
\r
211 - format_part_json (ctx, node, TRUE, params->output_body);
\r
212 + format_part_json (ctx, sp, node, TRUE, params->output_body);
\r
214 return NOTMUCH_STATUS_SUCCESS;
\r
216 @@ -679,7 +681,8 @@ format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),
\r
217 * http://qmail.org/qmail-manual-html/man5/mbox.html
\r
219 static notmuch_status_t
\r
220 -format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent),
\r
221 +format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
\r
222 + unused (int indent),
\r
223 unused (const notmuch_show_params_t *params))
\r
225 notmuch_message_t *message = node->envelope_file;
\r
226 @@ -730,8 +733,8 @@ format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent),
\r
229 static notmuch_status_t
\r
230 -format_part_raw (unused (const void *ctx), mime_node_t *node,
\r
231 - unused (int indent),
\r
232 +format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
\r
233 + mime_node_t *node, unused (int indent),
\r
234 unused (const notmuch_show_params_t *params))
\r
236 if (node->envelope_file) {
\r
237 @@ -819,6 +822,7 @@ show_null_message (const notmuch_show_format_t *format)
\r
238 static notmuch_status_t
\r
239 show_message (void *ctx,
\r
240 const notmuch_show_format_t *format,
\r
242 notmuch_message_t *message,
\r
244 notmuch_show_params_t *params)
\r
245 @@ -832,7 +836,7 @@ show_message (void *ctx,
\r
247 part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
\r
249 - status = format->part (local, part, indent, params);
\r
250 + status = format->part (local, sp, part, indent, params);
\r
252 talloc_free (local);
\r
254 @@ -841,6 +845,7 @@ show_message (void *ctx,
\r
255 static notmuch_status_t
\r
256 show_messages (void *ctx,
\r
257 const notmuch_show_format_t *format,
\r
259 notmuch_messages_t *messages,
\r
261 notmuch_show_params_t *params)
\r
262 @@ -874,7 +879,7 @@ show_messages (void *ctx,
\r
263 next_indent = indent;
\r
265 if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) {
\r
266 - status = show_message (ctx, format, message, indent, params);
\r
267 + status = show_message (ctx, format, sp, message, indent, params);
\r
268 if (status && !res)
\r
270 next_indent = indent + 1;
\r
271 @@ -886,7 +891,7 @@ show_messages (void *ctx,
\r
272 fputs (format->message_set_sep, stdout);
\r
274 status = show_messages (ctx,
\r
277 notmuch_message_get_replies (message),
\r
280 @@ -910,6 +915,7 @@ static int
\r
281 do_show_single (void *ctx,
\r
282 notmuch_query_t *query,
\r
283 const notmuch_show_format_t *format,
\r
285 notmuch_show_params_t *params)
\r
287 notmuch_messages_t *messages;
\r
288 @@ -930,7 +936,8 @@ do_show_single (void *ctx,
\r
290 notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);
\r
292 - return show_message (ctx, format, message, 0, params) != NOTMUCH_STATUS_SUCCESS;
\r
293 + return show_message (ctx, format, sp, message, 0, params)
\r
294 + != NOTMUCH_STATUS_SUCCESS;
\r
297 /* Formatted output of threads */
\r
298 @@ -938,6 +945,7 @@ static int
\r
299 do_show (void *ctx,
\r
300 notmuch_query_t *query,
\r
301 const notmuch_show_format_t *format,
\r
303 notmuch_show_params_t *params)
\r
305 notmuch_threads_t *threads;
\r
306 @@ -965,7 +973,7 @@ do_show (void *ctx,
\r
307 fputs (format->message_set_sep, stdout);
\r
308 first_toplevel = 0;
\r
310 - status = show_messages (ctx, format, messages, 0, params);
\r
311 + status = show_messages (ctx, format, sp, messages, 0, params);
\r
312 if (status && !res)
\r
315 @@ -1141,7 +1149,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
317 /* If a single message is requested we do not use search_excludes. */
\r
318 if (params.part >= 0)
\r
319 - ret = do_show_single (ctx, query, format, ¶ms);
\r
320 + ret = do_show_single (ctx, query, format, sprinter, ¶ms);
\r
322 /* We always apply set the exclude flag. The
\r
323 * exclude=true|false option controls whether or not we return
\r
324 @@ -1160,7 +1168,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
325 params.omit_excluded = FALSE;
\r
328 - ret = do_show (ctx, query, format, ¶ms);
\r
329 + ret = do_show (ctx, query, format, sprinter, ¶ms);
\r
332 notmuch_crypto_cleanup (¶ms.crypto);
\r