aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--notmuch-client.h4
-rw-r--r--notmuch-reply.c8
-rw-r--r--notmuch-show.c19
-rw-r--r--show-message.c7
4 files changed, 17 insertions, 21 deletions
diff --git a/notmuch-client.h b/notmuch-client.h
index 8899ab26..5e8e3e53 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -66,9 +66,9 @@ typedef struct notmuch_show_format {
const char *header_end;
const char *body_start;
void (*part) (GMimeObject *part,
- int *part_count,
- int first);
+ int *part_count);
void (*part_end) (GMimeObject *part);
+ const char *part_sep;
const char *body_end;
const char *message_end;
const char *message_set_sep;
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 064d27e0..b5ca19c4 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -26,14 +26,13 @@
static void
reply_part (GMimeObject *part,
- unused (int *part_count),
- unused (int first));
+ unused (int *part_count));
static const notmuch_show_format_t format_reply = {
NULL,
NULL, NULL,
NULL, NULL, NULL,
- NULL, reply_part, NULL, NULL,
+ NULL, reply_part, NULL, NULL, NULL,
NULL, NULL,
NULL
};
@@ -87,8 +86,7 @@ show_reply_headers (GMimeMessage *message)
static void
reply_part (GMimeObject *part,
- unused (int *part_count),
- unused (int first))
+ unused (int *part_count))
{
GMimeContentDisposition *disposition;
GMimeContentType *content_type;
diff --git a/notmuch-show.c b/notmuch-show.c
index 006ccf9e..412f908d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -30,8 +30,7 @@ format_headers_text (const void *ctx,
static void
format_part_text (GMimeObject *part,
- int *part_count,
- int first);
+ int *part_count);
static void
format_part_end_text (GMimeObject *part);
@@ -40,7 +39,7 @@ static const notmuch_show_format_t format_text = {
"",
"\fmessage{ ", format_message_text,
"\fheader{\n", format_headers_text, "\fheader}\n",
- "\fbody{\n", format_part_text, format_part_end_text, "\fbody}\n",
+ "\fbody{\n", format_part_text, format_part_end_text, "", "\fbody}\n",
"\fmessage}\n", "",
""
};
@@ -55,8 +54,7 @@ format_headers_json (const void *ctx,
static void
format_part_json (GMimeObject *part,
- int *part_count,
- int first);
+ int *part_count);
static void
format_part_end_json (GMimeObject *part);
@@ -65,7 +63,7 @@ static const notmuch_show_format_t format_json = {
"[",
"{", format_message_json,
", \"headers\": {", format_headers_json, "}",
- ", \"body\": [", format_part_json, format_part_end_json, "]",
+ ", \"body\": [", format_part_json, format_part_end_json, ", ", "]",
"}", ", ",
"]"
};
@@ -79,7 +77,7 @@ static const notmuch_show_format_t format_mbox = {
"",
"", format_message_mbox,
"", NULL, "",
- "", NULL, NULL, "",
+ "", NULL, NULL, "", "",
"", "",
""
};
@@ -357,7 +355,7 @@ show_part_content (GMimeObject *part, GMimeStream *stream_out)
}
static void
-format_part_text (GMimeObject *part, int *part_count, unused (int first))
+format_part_text (GMimeObject *part, int *part_count)
{
GMimeContentDisposition *disposition;
GMimeContentType *content_type;
@@ -431,7 +429,7 @@ format_part_end_text (GMimeObject *part)
}
static void
-format_part_json (GMimeObject *part, int *part_count, int first)
+format_part_json (GMimeObject *part, int *part_count)
{
GMimeContentType *content_type;
GMimeContentDisposition *disposition;
@@ -442,9 +440,6 @@ format_part_json (GMimeObject *part, int *part_count, int first)
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
- if (! first)
- fputs (", ", stdout);
-
printf ("{\"id\": %d, \"content-type\": %s",
*part_count,
json_quote_str (ctx, g_mime_content_type_to_string (content_type)));
diff --git a/show-message.c b/show-message.c
index 3c29f26a..c5556d81 100644
--- a/show-message.c
+++ b/show-message.c
@@ -28,12 +28,15 @@ show_message_part (GMimeObject *part,
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, first);
+ 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),
@@ -65,7 +68,7 @@ show_message_part (GMimeObject *part,
*part_count = *part_count + 1;
- format->part (part, part_count, first);
+ format->part (part, part_count);
if (format->part_end)
format->part_end (part);
}