dovecot-2.1: doveadm dump index: Dump also mime.parts decoded.

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 4 19:42:07 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/9f739df97593
changeset: 13647:9f739df97593
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 04 19:52:26 2011 +0200
description:
doveadm dump index: Dump also mime.parts decoded.

diffstat:

 src/doveadm/doveadm-dump-index.c |  39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diffs (63 lines):

diff -r 6d483a22134e -r 9f739df97593 src/doveadm/doveadm-dump-index.c
--- a/src/doveadm/doveadm-dump-index.c	Fri Nov 04 19:35:30 2011 +0200
+++ b/src/doveadm/doveadm-dump-index.c	Fri Nov 04 19:52:26 2011 +0200
@@ -5,6 +5,8 @@
 #include "str.h"
 #include "hex-binary.h"
 #include "file-lock.h"
+#include "message-parser.h"
+#include "message-part-serialize.h"
 #include "mail-index-private.h"
 #include "mail-cache-private.h"
 #include "mail-cache-private.h"
@@ -346,6 +348,41 @@
 	}
 }
 
+static void dump_message_part(string_t *str, const struct message_part *part)
+{
+	for (; part != NULL; part = part->next) {
+		str_append_c(str, '(');
+		str_printfa(str, "pos=%"PRIuUOFF_T" ", part->physical_pos);
+		str_printfa(str, "hdr.p=%"PRIuUOFF_T" ", part->header_size.physical_size);
+		str_printfa(str, "hdr.v=%"PRIuUOFF_T" ", part->header_size.virtual_size);
+		str_printfa(str, "body.p=%"PRIuUOFF_T" ", part->body_size.physical_size);
+		str_printfa(str, "body.v=%"PRIuUOFF_T" ", part->body_size.virtual_size);
+		str_printfa(str, "flags=%x", part->flags);
+		if (part->children != NULL) {
+			str_append_c(str, ' ');
+			dump_message_part(str, part->children);
+		}
+		str_append_c(str, ')');
+	}
+}
+
+static void
+dump_cache_mime_parts(string_t *str, const void *data, unsigned int size)
+{
+	const struct message_part *part;
+	const char *error;
+
+	str_append_c(str, ' ');
+
+	part = message_part_deserialize(pool_datastack_create(), data, size, &error);
+	if (part == NULL) {
+		str_printfa(str, "error: %s", error);
+		return;
+	}
+
+	dump_message_part(str, part);
+}
+
 static void dump_cache(struct mail_cache_view *cache_view, unsigned int seq)
 {
 	struct mail_cache_lookup_iterate_ctx iter;
@@ -387,6 +424,8 @@
 		case MAIL_CACHE_FIELD_VARIABLE_SIZE:
 		case MAIL_CACHE_FIELD_BITMASK:
 			str_printfa(str, "(%s)", binary_to_hex(data, size));
+			if (strcmp(field->name, "mime.parts") == 0)
+				dump_cache_mime_parts(str, data, size);
 			break;
 		case MAIL_CACHE_FIELD_STRING:
 			if (size > 0)


More information about the dovecot-cvs mailing list