There are several levels of function calls between where we create the
sprinter and the call to the part formatter in show_message. This
feeds the sprinter through all of them and into the part formatters.
#define STRINGIFY_(s) #s
typedef struct mime_node mime_node_t;
#define STRINGIFY_(s) #s
typedef struct mime_node mime_node_t;
struct notmuch_show_params;
typedef struct notmuch_show_format {
struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
const char *message_set_start;
struct notmuch_show_params;
typedef struct notmuch_show_format {
struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
const char *message_set_start;
- notmuch_status_t (*part) (const void *ctx,
+ notmuch_status_t (*part) (const void *ctx, struct sprinter *sprinter,
struct mime_node *node, int indent,
const struct notmuch_show_params *params);
const char *message_set_sep;
struct mime_node *node, int indent,
const struct notmuch_show_params *params);
const char *message_set_sep;
show_one_part (const char *filename, int part);
void
show_one_part (const char *filename, int part);
void
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body);
+format_part_json (const void *ctx, struct sprinter *sp, mime_node_t *node,
+ notmuch_bool_t first, notmuch_bool_t output_body);
void
format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
void
format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t reply);
/* Start the original */
printf (", \"original\": ");
/* Start the original */
printf (", \"original\": ");
- format_part_json (ctx, node, TRUE, TRUE);
+ format_part_json (ctx, sp, node, TRUE, TRUE);
/* End */
printf ("}\n");
/* End */
printf ("}\n");
#include "sprinter.h"
static notmuch_status_t
#include "sprinter.h"
static notmuch_status_t
-format_part_text (const void *ctx, mime_node_t *node,
+format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_text = {
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_text = {
};
static notmuch_status_t
};
static notmuch_status_t
-format_part_json_entry (const void *ctx, mime_node_t *node,
+format_part_json_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_json = {
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_json = {
};
static notmuch_status_t
};
static notmuch_status_t
-format_part_mbox (const void *ctx, mime_node_t *node,
+format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_mbox = {
int indent, const notmuch_show_params_t *params);
static const notmuch_show_format_t format_mbox = {
};
static notmuch_status_t
};
static notmuch_status_t
-format_part_raw (unused (const void *ctx), mime_node_t *node,
+format_part_raw (unused (const void *ctx), sprinter_t *sp, mime_node_t *node,
unused (int indent),
unused (const notmuch_show_params_t *params));
unused (int indent),
unused (const notmuch_show_params_t *params));
#endif
static notmuch_status_t
#endif
static notmuch_status_t
-format_part_text (const void *ctx, mime_node_t *node,
+format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
int indent, const notmuch_show_params_t *params)
{
/* The disposition and content-type metadata are associated with
int indent, const notmuch_show_params_t *params)
{
/* The disposition and content-type metadata are associated with
}
for (i = 0; i < node->nchildren; i++)
}
for (i = 0; i < node->nchildren; i++)
- format_part_text (ctx, mime_node_child (node, i), indent, params);
+ format_part_text (ctx, sp, mime_node_child (node, i), indent, params);
if (GMIME_IS_MESSAGE (node->part))
printf ("\fbody}\n");
if (GMIME_IS_MESSAGE (node->part))
printf ("\fbody}\n");
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, notmuch_bool_t output_body)
+format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,
+ notmuch_bool_t first, notmuch_bool_t output_body)
{
/* Any changes to the JSON format should be reflected in the file
* devel/schemata. */
{
/* Any changes to the JSON format should be reflected in the file
* devel/schemata. */
if (output_body) {
printf (", \"body\": [");
if (output_body) {
printf (", \"body\": [");
- format_part_json (ctx, mime_node_child (node, 0), first, TRUE);
+ format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);
printf ("]");
}
printf ("}");
printf ("]");
}
printf ("}");
talloc_free (local);
for (i = 0; i < node->nchildren; i++)
talloc_free (local);
for (i = 0; i < node->nchildren; i++)
- format_part_json (ctx, mime_node_child (node, i), i == 0, TRUE);
+ format_part_json (ctx, sp, mime_node_child (node, i), i == 0, TRUE);
printf ("%s}", terminator);
}
static notmuch_status_t
printf ("%s}", terminator);
}
static notmuch_status_t
-format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent),
+format_part_json_entry (const void *ctx, sprinter_t *sp,
+ mime_node_t *node, unused (int indent),
const notmuch_show_params_t *params)
{
const notmuch_show_params_t *params)
{
- format_part_json (ctx, node, TRUE, params->output_body);
+ format_part_json (ctx, sp, node, TRUE, params->output_body);
return NOTMUCH_STATUS_SUCCESS;
}
return NOTMUCH_STATUS_SUCCESS;
}
* http://qmail.org/qmail-manual-html/man5/mbox.html
*/
static notmuch_status_t
* http://qmail.org/qmail-manual-html/man5/mbox.html
*/
static notmuch_status_t
-format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent),
+format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
+ unused (int indent),
unused (const notmuch_show_params_t *params))
{
notmuch_message_t *message = node->envelope_file;
unused (const notmuch_show_params_t *params))
{
notmuch_message_t *message = node->envelope_file;
}
static notmuch_status_t
}
static notmuch_status_t
-format_part_raw (unused (const void *ctx), mime_node_t *node,
- unused (int indent),
+format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
+ mime_node_t *node, unused (int indent),
unused (const notmuch_show_params_t *params))
{
if (node->envelope_file) {
unused (const notmuch_show_params_t *params))
{
if (node->envelope_file) {
static notmuch_status_t
show_message (void *ctx,
const notmuch_show_format_t *format,
static notmuch_status_t
show_message (void *ctx,
const notmuch_show_format_t *format,
notmuch_message_t *message,
int indent,
notmuch_show_params_t *params)
notmuch_message_t *message,
int indent,
notmuch_show_params_t *params)
goto DONE;
part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
if (part)
goto DONE;
part = mime_node_seek_dfs (root, (params->part < 0 ? 0 : params->part));
if (part)
- status = format->part (local, part, indent, params);
+ status = format->part (local, sp, part, indent, params);
DONE:
talloc_free (local);
return status;
DONE:
talloc_free (local);
return status;
static notmuch_status_t
show_messages (void *ctx,
const notmuch_show_format_t *format,
static notmuch_status_t
show_messages (void *ctx,
const notmuch_show_format_t *format,
notmuch_messages_t *messages,
int indent,
notmuch_show_params_t *params)
notmuch_messages_t *messages,
int indent,
notmuch_show_params_t *params)
next_indent = indent;
if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) {
next_indent = indent;
if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) {
- status = show_message (ctx, format, message, indent, params);
+ status = show_message (ctx, format, sp, message, indent, params);
if (status && !res)
res = status;
next_indent = indent + 1;
if (status && !res)
res = status;
next_indent = indent + 1;
fputs (format->message_set_sep, stdout);
status = show_messages (ctx,
fputs (format->message_set_sep, stdout);
status = show_messages (ctx,
notmuch_message_get_replies (message),
next_indent,
params);
notmuch_message_get_replies (message),
next_indent,
params);
do_show_single (void *ctx,
notmuch_query_t *query,
const notmuch_show_format_t *format,
do_show_single (void *ctx,
notmuch_query_t *query,
const notmuch_show_format_t *format,
notmuch_show_params_t *params)
{
notmuch_messages_t *messages;
notmuch_show_params_t *params)
{
notmuch_messages_t *messages;
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);
- return show_message (ctx, format, message, 0, params) != NOTMUCH_STATUS_SUCCESS;
+ return show_message (ctx, format, sp, message, 0, params)
+ != NOTMUCH_STATUS_SUCCESS;
}
/* Formatted output of threads */
}
/* Formatted output of threads */
do_show (void *ctx,
notmuch_query_t *query,
const notmuch_show_format_t *format,
do_show (void *ctx,
notmuch_query_t *query,
const notmuch_show_format_t *format,
notmuch_show_params_t *params)
{
notmuch_threads_t *threads;
notmuch_show_params_t *params)
{
notmuch_threads_t *threads;
fputs (format->message_set_sep, stdout);
first_toplevel = 0;
fputs (format->message_set_sep, stdout);
first_toplevel = 0;
- status = show_messages (ctx, format, messages, 0, params);
+ status = show_messages (ctx, format, sp, messages, 0, params);
if (status && !res)
res = status;
if (status && !res)
res = status;
/* If a single message is requested we do not use search_excludes. */
if (params.part >= 0)
/* If a single message is requested we do not use search_excludes. */
if (params.part >= 0)
- ret = do_show_single (ctx, query, format, ¶ms);
+ ret = do_show_single (ctx, query, format, sprinter, ¶ms);
else {
/* We always apply set the exclude flag. The
* exclude=true|false option controls whether or not we return
else {
/* We always apply set the exclude flag. The
* exclude=true|false option controls whether or not we return
params.omit_excluded = FALSE;
}
params.omit_excluded = FALSE;
}
- ret = do_show (ctx, query, format, ¶ms);
+ ret = do_show (ctx, query, format, sprinter, ¶ms);
}
notmuch_crypto_cleanup (¶ms.crypto);
}
notmuch_crypto_cleanup (¶ms.crypto);