#include "notmuch-client.h"
static void
-show_message_part (GMimeObject *part, int *part_count,
- void (*show_part) (GMimeObject *part, int *part_count))
+show_message_part (GMimeObject *part,
+ int *part_count,
+ const notmuch_show_format_t *format,
+ int first)
{
+ if (!first)
+ fputs (format->part_sep, stdout);
+
if (GMIME_IS_MULTIPART (part)) {
GMimeMultipart *multipart = GMIME_MULTIPART (part);
int i;
+ *part_count = *part_count + 1;
+ format->part (part, part_count);
+
for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {
show_message_part (g_mime_multipart_get_part (multipart, i),
- part_count, show_part);
+ part_count, format, i == 0);
}
+
+ if (format->part_end)
+ format->part_end (part);
+
return;
}
mime_message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
show_message_part (g_mime_message_get_mime_part (mime_message),
- part_count, show_part);
+ part_count, format, first);
return;
}
*part_count = *part_count + 1;
- (*show_part) (part, part_count);
+ format->part (part, part_count);
+ if (format->part_end)
+ format->part_end (part);
}
notmuch_status_t
show_message_body (const char *filename,
- void (*show_part) (GMimeObject *part, int *part_count))
+ const notmuch_show_format_t *format)
{
GMimeStream *stream = NULL;
GMimeParser *parser = NULL;
mime_message = g_mime_parser_construct_message (parser);
show_message_part (g_mime_message_get_mime_part (mime_message),
- &part_count, show_part);
+ &part_count,
+ format,
+ TRUE);
DONE:
if (mime_message)
GMimeMultipart *multipart = GMIME_MULTIPART (part);
int i;
+ *part_count = *part_count + 1;
+
for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {
show_one_part_worker (g_mime_multipart_get_part (multipart, i),
part_count, desired_part);