static notmuch_status_t show_messages (void *ctx, const notmuch_show_format_t *format, sprinter_t *sp, notmuch_messages_t *messages, int indent, notmuch_show_params_t *params) { notmuch_message_t *message; notmuch_bool_t match; notmuch_bool_t excluded; int next_indent; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; sp->begin_list (sp); for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { sp->begin_list (sp); message = notmuch_messages_get (messages); match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH); excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED); next_indent = indent; if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) { status = show_message (ctx, format, sp, message, indent, params); if (status && !res) res = status; next_indent = indent + 1; } else { sp->null (sp); } status = show_messages (ctx, format, sp, notmuch_message_get_replies (message), next_indent, params); if (status && !res) res = status; notmuch_message_destroy (message); sp->end (sp); } sp->end (sp); return res; }
static void show_messages (void *ctx, const notmuch_show_format_t *format, notmuch_messages_t *messages, int indent, notmuch_show_params_t *params) { notmuch_message_t *message; notmuch_bool_t match; int first_set = 1; int next_indent; fputs (format->message_set_start, stdout); for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { if (!first_set) fputs (format->message_set_sep, stdout); first_set = 0; fputs (format->message_set_start, stdout); message = notmuch_messages_get (messages); match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH); next_indent = indent; if (match || params->entire_thread) { show_message (ctx, format, message, indent, params); next_indent = indent + 1; fputs (format->message_set_sep, stdout); } show_messages (ctx, format, notmuch_message_get_replies (message), next_indent, params); notmuch_message_destroy (message); fputs (format->message_set_end, stdout); } fputs (format->message_set_end, stdout); }
/* * add all the replies to a given messages into the display. * Careful, this calls itself recursively to make sure we get * everything. */ static void append_replies(CONTEXT *ctx, notmuch_message_t *top) { notmuch_messages_t *msgs; for (msgs = notmuch_message_get_replies(top); notmuch_messages_valid(msgs); notmuch_messages_move_to_next(msgs)) { notmuch_message_t *m = notmuch_messages_get(msgs); append_message(ctx, m); /* recurse through all the replies to this message too */ append_replies(ctx, m); notmuch_message_destroy(m); } }
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_message_t *message; notmuch_bool_t match; notmuch_bool_t excluded; int first_set = 1; int next_indent; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; if (format->message_set_start) fputs (format->message_set_start, stdout); for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { if (!first_set && format->message_set_sep) fputs (format->message_set_sep, stdout); first_set = 0; if (format->message_set_start) fputs (format->message_set_start, stdout); message = notmuch_messages_get (messages); match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH); excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED); next_indent = indent; if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) { status = show_message (ctx, format, message, indent, params); if (status && !res) res = status; next_indent = indent + 1; if (!status && format->message_set_sep) fputs (format->message_set_sep, stdout); } status = show_messages (ctx, format, notmuch_message_get_replies (message), next_indent, params); if (status && !res) res = status; notmuch_message_destroy (message); if (format->message_set_end) fputs (format->message_set_end, stdout); } if (format->message_set_end) fputs (format->message_set_end, stdout); return res; }