annotate src/util/logview.c @ 7812:d10cb44ab446 HEAD

Modseqs are no longer calculated from transaction log sequence + offset. Now they begin from 1 and each "visible" transaction increases it by one.
author Timo Sirainen <tss@iki.fi>
date Wed, 11 Jun 2008 14:35:15 +0300
parents a5bbb3abeff8
children 98aa72f63578
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7086
7ed926ed7aa4 Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents: 6940
diff changeset
1 /* Copyright (c) 2007-2008 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);
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
48 *modseq_r = I_MAX(hdr.initial_modseq, 1);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
51 static bool
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
52 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
53 {
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
54 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
55 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
56 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
57 /* ignore expunge requests */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
58 break;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
59 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
60 case MAIL_TRANSACTION_APPEND:
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
61 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
62 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
63 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
64 /* these changes increase modseq */
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
65 return TRUE;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
66 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
67 return FALSE;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
68 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69 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
70 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 const char *name;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 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
74 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
75 name = "expunge";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
77 case MAIL_TRANSACTION_APPEND:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 name = "append";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80 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
81 name = "flag-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 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
84 name = "header-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 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
87 name = "ext-intro";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
88 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89 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
90 name = "ext-reset";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
92 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
93 name = "ext-hdr";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
94 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 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
96 name = "ext-rec";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
97 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
98 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
99 name = "keyword-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 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
102 name = "keyword-reset";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
103 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105 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
106 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
107 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
108
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
109 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
110 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
111 return name;
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
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
114 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
115 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 size_t i;
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 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
119 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
120 if (size == 4) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 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
122
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 printf(" (dec=%u)", *n);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
125 }
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 static void log_record_print(const 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
128 const void *data)
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 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
131
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
132 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
133 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
134 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
135
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
136 printf(" -");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 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
138 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
139 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
143 case MAIL_TRANSACTION_APPEND: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
144 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
145
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147 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
148 printf("%u", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
149 if (rec->flags != 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
150 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
151 printf(",");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
152 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
153 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
154 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
155 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
156 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
157 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
158
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
159 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
160 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
161 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
162 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
163 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
164 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
165 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
166 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
167
6926
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
168 if (u->offset == offsetof(struct mail_index_header,
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
169 log_file_tail_offset) &&
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
170 u->size == sizeof(uint32_t)) {
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
171 printf(" - log_file_tail_offset = %u\n",
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
172 *(const uint32_t *)(u + 1));
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
173 break;
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
174 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
175 printf(" - offset = %u, size = %u: ", u->offset, u->size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
176 print_data(u + 1, u->size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
178 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
179 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
180 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
181 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
182
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
183 prev_intro = *intro;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184 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
185 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
186 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
187 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
188 printf(" - record_align = %u\n", intro->record_align);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
189 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
190 if (intro->name_size > 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
191 printf(" - name = '%.*s'\n",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
192 intro->name_size, (const char *)(intro+1));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
193 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
194 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
195 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
196 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
197 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
198
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
199 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
200 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
201 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
202 }
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
203 case MAIL_TRANSACTION_EXT_HDR_UPDATE: {
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
204 const struct mail_transaction_ext_hdr_update *u = data;
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
205
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
206 printf(" - offset = %u, size = %u: ", u->offset, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
207 print_data(u + 1, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
208 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
209 break;
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
210 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
211 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
212 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
213 size_t record_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 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
216 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
217 while (rec < end) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
218 printf(" - %u: ", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
219 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
220 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 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
222 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
223 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
225 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
226 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
227 const uint32_t *uid;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228 unsigned int uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
229
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
230 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
231 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
232
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 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
234 ((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
235 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
236 size -= uid_offset;
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 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
239 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
240 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242 break;
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 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
245 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
246
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
247 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 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
249 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
250 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
252 break;
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 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
258
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
259 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
260 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261 off_t offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262 ssize_t ret;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263 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
264 unsigned int orig_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
266 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
267
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 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
269 if (ret == 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
271
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 if (ret != sizeof(hdr)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
273 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
274 ret, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
275 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
276
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
277 orig_size = hdr.size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
278 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
279 if (hdr.size == 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
280 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
281 "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
282 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
283 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
284 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
285
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
286 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
287 offset, log_record_type(hdr.type), hdr.size);
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
288 if (mail_transaction_header_has_modseq(&hdr)) {
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
289 *modseq += 1;
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
290 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
291 }
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
292 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
293
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
294 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
295 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
296
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
297 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
298 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
299 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
300 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
301 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
302 log_record_print(&hdr, buf);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
303 } else {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
304 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
305 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
306 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
307 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
308
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
309 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
310 {
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
311 uint64_t modseq;
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
312 int fd, ret;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
314 lib_init();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
315
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
316 if (argc < 2)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
317 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
318
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
319 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
320 if (fd < 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
321 i_error("open(): %m");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
325 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
326 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
327 T_BEGIN {
7812
d10cb44ab446 Modseqs are no longer calculated from transaction log sequence + offset.
Timo Sirainen <tss@iki.fi>
parents: 7809
diff changeset
328 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
329 } T_END;
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
330 } while (ret > 0);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
331 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
332 }