+ GZPRINTF (output, "=%s", *buffer_p);
+ }
+ notmuch_message_properties_destroy (list);
+
+ if (! first)
+ GZPRINTF (output, "\n", *buffer_p);
+
+ return 0;
+}
+
+static int
+dump_tags_message (void *ctx,
+ notmuch_message_t *message, int output_format,
+ gzFile output,
+ char **buffer_p, size_t *size_p)
+{
+ int first = 1;
+ const char *message_id;
+
+ message_id = notmuch_message_get_message_id (message);
+
+ if (output_format == DUMP_FORMAT_BATCH_TAG &&
+ strchr (message_id, '\n')) {
+ /* This will produce a line break in the output, which
+ * would be difficult to handle in tools. However, it's
+ * also impossible to produce an email containing a line
+ * break in a message ID because of unfolding, so we can
+ * safely disallow it. */
+ fprintf (stderr, "Warning: skipping message id containing line break: \"%s\"\n", message_id);
+ return EXIT_SUCCESS;
+ }
+
+ if (output_format == DUMP_FORMAT_SUP) {
+ GZPRINTF (output, "%s (", message_id);
+ }
+
+ for (notmuch_tags_t *tags = notmuch_message_get_tags (message);
+ notmuch_tags_valid (tags);
+ notmuch_tags_move_to_next (tags)) {
+ const char *tag_str = notmuch_tags_get (tags);
+
+ if (! first)
+ GZPUTS (output, " ");
+
+ first = 0;
+
+ if (output_format == DUMP_FORMAT_SUP) {
+ GZPUTS (output, tag_str);
+ } else {
+ if (hex_encode (ctx, tag_str,
+ buffer_p, size_p) != HEX_SUCCESS) {
+ fprintf (stderr, "Error: failed to hex-encode tag %s\n",
+ tag_str);
+ return EXIT_FAILURE;
+ }
+ GZPRINTF (output, "+%s", *buffer_p);
+ }
+ }
+
+ if (output_format == DUMP_FORMAT_SUP) {
+ GZPUTS (output, ")\n");