aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorGravatar Jameson Graef Rollins <jrollins@finestructure.net>2011-05-22 19:56:53 -0700
committerGravatar Carl Worth <cworth@cworth.org>2011-05-23 14:55:27 -0700
commit6c2417cabc1b35ea4fc9db6493d85354b1039d6d (patch)
tree2294ff3d2ad52b12cb657966d984c29b0acd89c0 /notmuch-show.c
parentd2177d0b22a95989dee4f46a1b2cca68484a2ce3 (diff)
add part_sep formatter to replace "first" argument to part format functions
A new field "part_sep" is added to the notmuch_show_format structure, to be used for part separation. This is cleaner than the "first" argument that was being passed around to the part arguments, and allows the function that handles overall part output formatting (show_message_part) to directly handle when outputting the separator.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c19
1 files changed, 7 insertions, 12 deletions
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)));