annotate src/util/logview.c @ 7086:7ed926ed7aa4 HEAD

Updated copyright notices to include year 2008.
author Timo Sirainen <tss@iki.fi>
date Tue, 01 Jan 2008 22:05:21 +0200
parents 414c9d631a81
children e6693a0ec8e1
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
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 static void dump_hdr(int fd)
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 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 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
36 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
37 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
38 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
39 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
40 printf("create stamp = %u\n", hdr.create_stamp);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 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
44 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 const char *name;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 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
48 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
49 name = "expunge";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 case MAIL_TRANSACTION_APPEND:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 name = "append";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 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
55 name = "flag-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 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
58 name = "header-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60 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
61 name = "ext-intro";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 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
64 name = "ext-reset";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
66 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
67 name = "ext-hdr";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
68 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69 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
70 name = "ext-rec";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 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
73 name = "keyword-update";
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
74 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75 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
76 name = "keyword-reset";
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 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 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
80 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 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
84 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
85 return name;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
88 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
89 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 size_t i;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
92 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
93 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
94 if (size == 4) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
95 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
96
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
97 printf(" (dec=%u)", *n);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
98 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
99 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 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
102 const void *data)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
103 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 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
105
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
106 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
107 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
108 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
109
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
110 printf(" -");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
111 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
112 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
113 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
114 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 break;
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 case MAIL_TRANSACTION_APPEND: {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
118 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
119
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
120 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 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
122 printf("%u", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 if (rec->flags != 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 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
125 printf(",");
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("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
128 break;
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 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
131 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
132
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 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
134 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
135 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
136 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
139 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
140 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
141
6926
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
142 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
143 log_file_tail_offset) &&
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
144 u->size == sizeof(uint32_t)) {
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
145 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
146 *(const uint32_t *)(u + 1));
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
147 break;
f90a4e265d00 Show log_file_tail_offset header updates more clearly.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
148 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
149 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
150 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
151 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
152 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
153 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
154 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
155 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
156
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
157 prev_intro = *intro;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 printf(" - name = '%.*s'\n",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166 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
167 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
168 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
169 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
170 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
171 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
172
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
173 printf(" - new_reset_id = %u\n", reset->new_reset_id);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
174 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
175 }
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
176 case MAIL_TRANSACTION_EXT_HDR_UPDATE: {
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
177 const struct mail_transaction_ext_hdr_update *u = data;
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
178
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
179 printf(" - offset = %u, size = %u: ", u->offset, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
180 print_data(u + 1, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
181 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
182 break;
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
183 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184 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
185 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
186 size_t record_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
187
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
188 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
189 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
190 while (rec < end) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
191 printf(" - %u: ", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
192 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
193 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
194 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
195 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
196 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
197 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
198 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
199 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
200 const uint32_t *uid;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
201 unsigned int uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
202
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
203 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
204 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
205
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
206 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
207 ((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
208 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
209 size -= uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
210
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
211 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
212 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
213 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
216 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
217 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
218 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
219
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
220 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 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
222 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
223 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
225 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
226 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
227 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228 break;
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 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
231
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
232 static int dump_record(int fd)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
234 off_t offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
235 ssize_t ret;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
236 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
237 unsigned int orig_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 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
240
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 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
242 if (ret == 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
245 if (ret != sizeof(hdr)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 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
247 ret, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
249
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
250 orig_size = hdr.size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 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
252 if (hdr.size == 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253 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
254 "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
255 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
256 return 0;
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
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 printf("record: offset=%"PRIuUOFF_T", type=%s, size=%u\n",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260 offset, log_record_type(hdr.type), hdr.size);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262 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
263 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
264
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265 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
266 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
267 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
268 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
269 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270 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
271 } else {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 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
273 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
274 return 1;
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 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
278 {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
279 int fd, ret;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
280
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
281 lib_init();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
283 if (argc < 2)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
284 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
285
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
286 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
287 if (fd < 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
288 i_error("open(): %m");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
290 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
291
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
292 dump_hdr(fd);
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
293 do {
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
294 T_FRAME(
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
295 ret = dump_record(fd);
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
296 );
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6926
diff changeset
297 } while (ret > 0);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
298 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
299 }