annotate src/util/logview.c @ 9575:0a00dcc4f0ea HEAD

lib-storage: Allow shared namespace prefix to use %variable modifiers.
author Timo Sirainen <tss@iki.fi>
date Wed, 26 May 2010 17:07:51 +0100
parents 00cd9aacd03c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9532
00cd9aacd03c Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents: 9480
diff changeset
1 /* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "mail-index-private.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "mail-transaction-log.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include <stdio.h>
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 static struct mail_transaction_ext_intro prev_intro;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 uint32_t mail_index_offset_to_uint32(uint32_t offset)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 const unsigned char *buf = (const unsigned char *) &offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 if ((offset & 0x80808080) != 0x80808080)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 return (((uint32_t)buf[3] & 0x7f) << 2) |
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 (((uint32_t)buf[2] & 0x7f) << 9) |
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 (((uint32_t)buf[1] & 0x7f) << 16) |
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 (((uint32_t)buf[0] & 0x7f) << 23);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
24 static void dump_hdr(int fd, uint64_t *modseq_r)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 struct mail_transaction_log_header hdr;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 ssize_t ret;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 ret = read(fd, &hdr, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 if (ret != sizeof(hdr)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 i_fatal("file hdr read() %"PRIuSIZE_T" != %"PRIuSIZE_T,
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32 ret, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 }
7809
a5bbb3abeff8 logview: Handle unexpected header sizes correctly.
Timo Sirainen <tss@iki.fi>
parents: 7565
diff changeset
34 if (hdr.hdr_size < sizeof(hdr)) {
a5bbb3abeff8 logview: Handle unexpected header sizes correctly.
Timo Sirainen <tss@iki.fi>
parents: 7565
diff changeset
35 memset(PTR_OFFSET(&hdr, hdr.hdr_size), 0,
a5bbb3abeff8 logview: Handle unexpected header sizes correctly.
Timo Sirainen <tss@iki.fi>
parents: 7565
diff changeset
36 sizeof(hdr) - hdr.hdr_size);
a5bbb3abeff8 logview: Handle unexpected header sizes correctly.
Timo Sirainen <tss@iki.fi>
parents: 7565
diff changeset
37 }
a5bbb3abeff8 logview: Handle unexpected header sizes correctly.
Timo Sirainen <tss@iki.fi>
parents: 7565
diff changeset
38 lseek(fd, hdr.hdr_size, SEEK_SET);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 printf("version = %u.%u\n", hdr.major_version, hdr.minor_version);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 printf("hdr size = %u\n", hdr.hdr_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42 printf("index id = %u\n", hdr.indexid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 printf("file seq = %u\n", hdr.file_seq);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 printf("prev file = %u/%u\n", hdr.prev_file_seq, hdr.prev_file_offset);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 printf("create stamp = %u\n", hdr.create_stamp);
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
46 printf("initial modseq = %llu\n",
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
47 (unsigned long long)hdr.initial_modseq);
8129
612eb505775f Write CPU endianess to transaction log header and check it's correct when reading.
Timo Sirainen <tss@iki.fi>
parents: 7931
diff changeset
48 printf("compat flags = %x\n", hdr.compat_flags);
7931
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
49 *modseq_r = hdr.initial_modseq;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
52 static bool
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
53 mail_transaction_header_has_modseq(const struct mail_transaction_header *hdr)
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
54 {
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
55 switch (hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
56 case MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
57 if ((hdr->type & MAIL_TRANSACTION_EXTERNAL) == 0) {
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
58 /* ignore expunge requests */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
59 break;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
60 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
61 case MAIL_TRANSACTION_APPEND:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
62 case MAIL_TRANSACTION_FLAG_UPDATE:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
63 case MAIL_TRANSACTION_KEYWORD_UPDATE:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
64 case MAIL_TRANSACTION_KEYWORD_RESET:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
65 /* these changes increase modseq */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
66 return TRUE;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
67 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
68 return FALSE;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
69 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70 static const char *log_record_type(unsigned int type)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 const char *name;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
74 switch (type & MAIL_TRANSACTION_TYPE_MASK) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 case MAIL_TRANSACTION_EXPUNGE|MAIL_TRANSACTION_EXPUNGE_PROT:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76 name = "expunge";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
77 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 case MAIL_TRANSACTION_APPEND:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 name = "append";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81 case MAIL_TRANSACTION_FLAG_UPDATE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 name = "flag-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84 case MAIL_TRANSACTION_HEADER_UPDATE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 name = "header-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87 case MAIL_TRANSACTION_EXT_INTRO:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
88 name = "ext-intro";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 case MAIL_TRANSACTION_EXT_RESET:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91 name = "ext-reset";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
92 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
93 case MAIL_TRANSACTION_EXT_HDR_UPDATE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
94 name = "ext-hdr";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 break;
9480
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
96 case MAIL_TRANSACTION_EXT_HDR_UPDATE32:
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
97 name = "ext-hdr32";
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
98 break;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
99 case MAIL_TRANSACTION_EXT_REC_UPDATE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100 name = "ext-rec";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
102 case MAIL_TRANSACTION_KEYWORD_UPDATE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
103 name = "keyword-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105 case MAIL_TRANSACTION_KEYWORD_RESET:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
106 name = "keyword-reset";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
107 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
108 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
109 name = t_strdup_printf("unknown: %x", type);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
110 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
111 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
112
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
113 if (type & MAIL_TRANSACTION_EXTERNAL)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
114 name = t_strconcat(name, " (ext)", NULL);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 return name;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
117
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
118 static void print_data(const void *data, size_t size)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
120 size_t i;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122 for (i = 0; i < size; i++)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 printf("%02x", ((const unsigned char *)data)[i]);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 if (size == 4) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
125 const uint32_t *n = (const uint32_t *)data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
126
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
127 printf(" (dec=%u)", *n);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
128 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
129 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
130
7853
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
131 static void print_try_uint(const void *data, size_t size)
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
132 {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
133 size_t i;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
134
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
135 switch (size) {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
136 case 1: {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
137 const uint8_t *n = data;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
138 printf("%u", *n);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
139 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
140 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
141 case 2: {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
142 const uint16_t *n = data;
8238
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
143 uint32_t n16;
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
144
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
145 memcpy(&n16, n, sizeof(n16));
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
146 printf("%u", n16);
7853
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
147 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
148 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
149 case 4: {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
150 const uint32_t *n = data;
8238
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
151 uint32_t n32;
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
152
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
153 memcpy(&n32, n, sizeof(n32));
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
154 printf("%u", n32);
7853
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
155 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
156 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
157 case 8: {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
158 const uint64_t *n = data;
8238
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
159 uint64_t n64;
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
160
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
161 memcpy(&n64, n, sizeof(n64));
93e01a80cb8e logview: Crashfix for CPUs requiring proper alignment.
Timo Sirainen <tss@iki.fi>
parents: 8129
diff changeset
162 printf("%llu", (unsigned long long)n64);
7853
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
163 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
164 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
165 default:
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
166 for (i = 0; i < size; i++)
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
167 printf("%02x", ((const unsigned char *)data)[i]);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
168 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
169 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
170
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
171 #define HDRF(field) { \
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
172 #field, offsetof(struct mail_index_header, field), \
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
173 sizeof(((struct mail_index_header *)0)->field) }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
174
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
175 static struct {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
176 const char *name;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
177 unsigned int offset, size;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
178 } header_fields[] = {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
179 HDRF(minor_version),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
180 HDRF(base_header_size),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
181 HDRF(header_size),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
182 HDRF(record_size),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
183 HDRF(compat_flags),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
184 HDRF(indexid),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
185 HDRF(flags),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
186 HDRF(uid_validity),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
187 HDRF(next_uid),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
188 HDRF(messages_count),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
189 HDRF(unused_old_recent_messages_count),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
190 HDRF(seen_messages_count),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
191 HDRF(deleted_messages_count),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
192 HDRF(first_recent_uid),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
193 HDRF(first_unseen_uid_lowwater),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
194 HDRF(first_deleted_uid_lowwater),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
195 HDRF(log_file_seq),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
196 HDRF(log_file_tail_offset),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
197 HDRF(log_file_head_offset),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
198 HDRF(sync_size),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
199 HDRF(sync_stamp),
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
200 HDRF(day_stamp)
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
201 };
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
202
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
203 static void log_header_update(const struct mail_transaction_header_update *u)
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
204 {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
205 const void *data = u + 1;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
206 unsigned int offset = u->offset, size = u->size;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
207 unsigned int i;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
208
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
209 while (size > 0) {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
210 /* don't bother trying to handle header updates that include
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
211 unknown/unexpected fields offsets/sizes */
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
212 for (i = 0; i < N_ELEMENTS(header_fields); i++) {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
213 if (header_fields[i].offset == offset &&
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
214 header_fields[i].size <= size)
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
215 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
216 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
217
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
218 if (i == N_ELEMENTS(header_fields)) {
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
219 printf(" - offset = %u, size = %u: ", offset, size);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
220 print_data(data, size);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
221 printf("\n");
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
222 break;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
223 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
224
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
225 printf(" - %s = ", header_fields[i].name);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
226 print_try_uint(data, header_fields[i].size);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
227 printf("\n");
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
228
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
229 data = CONST_PTR_OFFSET(data, header_fields[i].size);
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
230 offset += header_fields[i].size;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
231 size -= header_fields[i].size;
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
232 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
233 }
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
234
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
235 static void log_record_print(const struct mail_transaction_header *hdr,
7931
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
236 const void *data, uint64_t *modseq)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
237 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238 unsigned int size = hdr->size - sizeof(*hdr);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240 switch (hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 case MAIL_TRANSACTION_EXPUNGE|MAIL_TRANSACTION_EXPUNGE_PROT: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242 const struct mail_transaction_expunge *exp = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244 printf(" -");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
245 for (; size > 0; size -= sizeof(*exp), exp++) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 printf(" %u-%u", exp->uid1, exp->uid2);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
247 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
249 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
250 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 case MAIL_TRANSACTION_APPEND: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
252 const struct mail_index_record *rec = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
254 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 for (; size > 0; size -= sizeof(*rec), rec++) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 printf("%u", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257 if (rec->flags != 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
258 printf(" (flags=%x)", rec->flags);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 printf(",");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
264 case MAIL_TRANSACTION_FLAG_UPDATE: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265 const struct mail_transaction_flag_update *u = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
266
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 for (; size > 0; size -= sizeof(*u), u++) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 printf(" - %u-%u (flags +%x-%x)\n", u->uid1, u->uid2,
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
269 u->add_flags, u->remove_flags);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
271 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
273 case MAIL_TRANSACTION_HEADER_UPDATE: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
274 const struct mail_transaction_header_update *u = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
275
7853
98aa72f63578 logview: Expand header update records to user-readable form.
Timo Sirainen <tss@iki.fi>
parents: 7812
diff changeset
276 log_header_update(u);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
277 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
278 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279 case MAIL_TRANSACTION_EXT_INTRO: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
280 const struct mail_transaction_ext_intro *intro = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
281
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282 prev_intro = *intro;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
283 printf(" - ext_id = %u\n", intro->ext_id);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
284 printf(" - reset_id = %u\n", intro->reset_id);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
285 printf(" - hdr_size = %u\n", intro->hdr_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
286 printf(" - record_size = %u\n", intro->record_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
287 printf(" - record_align = %u\n", intro->record_align);
7897
02bef9a155d7 logview: Show flags field in extension intros.
Timo Sirainen <tss@iki.fi>
parents: 7853
diff changeset
288 printf(" - flags = %u\n", intro->flags);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289 printf(" - name_size = %u\n", intro->name_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
290 if (intro->name_size > 0) {
7931
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
291 const char *name = (const char *)(intro+1);
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
292
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
293 printf(" - name = '%.*s'\n", intro->name_size, name);
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
294 if (*modseq == 0 && intro->name_size == 6 &&
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
295 memcmp(name, "modseq", 6) == 0)
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
296 *modseq = 1;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
297 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
298 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
299 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
300 case MAIL_TRANSACTION_EXT_RESET: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
301 const struct mail_transaction_ext_reset *reset = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
302
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
303 printf(" - new_reset_id = %u\n", reset->new_reset_id);
7565
6930859e7a5a logview: Show ext reset.preserve_data.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
304 printf(" - preserve_data = %u\n", reset->preserve_data);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
305 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
306 }
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
307 case MAIL_TRANSACTION_EXT_HDR_UPDATE: {
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
308 const struct mail_transaction_ext_hdr_update *u = data;
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
309
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
310 printf(" - offset = %u, size = %u: ", u->offset, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
311 print_data(u + 1, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
312 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313 break;
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
314 }
9480
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
315 case MAIL_TRANSACTION_EXT_HDR_UPDATE32: {
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
316 const struct mail_transaction_ext_hdr_update32 *u = data;
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
317
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
318 printf(" - offset = %u, size = %u: ", u->offset, u->size);
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
319 print_data(u + 1, u->size);
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
320 printf("\n");
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
321 break;
e5d38150be58 mail_index_update_header_ext(): Couldn't handle >=64k headers.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
322 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 case MAIL_TRANSACTION_EXT_REC_UPDATE: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 const struct mail_transaction_ext_rec_update *rec = data, *end;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325 size_t record_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
327 end = CONST_PTR_OFFSET(data, size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
328 record_size = (sizeof(*rec) + prev_intro.record_size + 3) & ~3;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
329 while (rec < end) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
330 printf(" - %u: ", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
331 print_data(rec + 1, prev_intro.record_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
332 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
333 rec = CONST_PTR_OFFSET(rec, record_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
334 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
335 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
336 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337 case MAIL_TRANSACTION_KEYWORD_UPDATE: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
338 const struct mail_transaction_keyword_update *u = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
339 const uint32_t *uid;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
340 unsigned int uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
342 printf(" - modify=%d, name=%.*s, ",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 u->modify_type, u->name_size, (const char *)(u+1));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 uid_offset = sizeof(*u) + u->name_size +
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 ((u->name_size % 4) == 0 ? 0 : 4 - (u->name_size%4));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347 uid = (const uint32_t *)((const char *)u + uid_offset);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
348 size -= uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
349
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
350 for (; size > 0; size -= sizeof(*uid)*2, uid += 2) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
351 printf("%u-%u,", uid[0], uid[1]);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
352 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
353 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
355 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
356 case MAIL_TRANSACTION_KEYWORD_RESET: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
357 const struct mail_transaction_keyword_reset *u = data;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
358
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
359 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
360 for (; size > 0; size -= sizeof(*u), u++) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
361 printf("%u-%u, ", u->uid1, u->uid2);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
362 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
363 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
364 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
365 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
366 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
368 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
369 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
370
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
371 static int dump_record(int fd, uint64_t *modseq)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
372 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
373 off_t offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374 ssize_t ret;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
375 struct mail_transaction_header hdr;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
376 unsigned int orig_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
377
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
378 offset = lseek(fd, 0, SEEK_CUR);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
379
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
380 ret = read(fd, &hdr, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
381 if (ret == 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
382 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
383
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
384 if (ret != sizeof(hdr)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
385 i_fatal("rec hdr read() %"PRIuSIZE_T" != %"PRIuSIZE_T,
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
386 ret, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
387 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
388
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
389 orig_size = hdr.size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
390 hdr.size = mail_index_offset_to_uint32(hdr.size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
391 if (hdr.size == 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
392 printf("record: offset=%"PRIuUOFF_T", "
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
393 "type=%s, size=broken (%x)\n",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
394 offset, log_record_type(hdr.type), orig_size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
395 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
396 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
397
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
398 printf("record: offset=%"PRIuUOFF_T", type=%s, size=%u",
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
399 offset, log_record_type(hdr.type), hdr.size);
7931
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
400 if (*modseq > 0 && mail_transaction_header_has_modseq(&hdr)) {
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
401 *modseq += 1;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
402 printf(", modseq=%llu", (unsigned long long)*modseq);
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
403 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
404 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
405
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 if (hdr.size < 1024*1024) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407 unsigned char *buf = t_malloc(hdr.size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
408
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
409 ret = read(fd, buf, hdr.size - sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
410 if (ret != (ssize_t)(hdr.size - sizeof(hdr))) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
411 i_fatal("rec data read() %"PRIuSIZE_T" != %"PRIuSIZE_T,
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 ret, hdr.size - sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
413 }
7931
502cfdcc5650 Keep modseqs as 1 until the first modseq ext intro record enables them.
Timo Sirainen <tss@iki.fi>
parents: 7897
diff changeset
414 log_record_print(&hdr, buf, modseq);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415 } else {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
416 lseek(fd, hdr.size - sizeof(hdr), SEEK_CUR);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
417 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
418 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
419 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
420
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
421 int main(int argc, const char *argv[])
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
422 {
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
423 uint64_t modseq;
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
424 int fd, ret;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
425
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
426 lib_init();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
427
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
428 if (argc < 2)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
429 i_fatal("Usage: logview dovecot.index.log");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
430
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
431 fd = open(argv[1], O_RDONLY);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432 if (fd < 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
433 i_error("open(): %m");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
435 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
436
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
437 dump_hdr(fd, &modseq);
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
438 do {
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
439 T_BEGIN {
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
440 ret = dump_record(fd, &modseq);
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
441 } T_END;
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
442 } while (ret > 0);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
443 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
444 }