annotate src/util/logview.c @ 5895:cb5e25c3b300 HEAD

Show extension header updates.
author Timo Sirainen <tss@iki.fi>
date Sun, 08 Jul 2007 19:33:18 +0300
parents a42014a7d8be
children 65c69a53a7be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2007 Timo Sirainen */
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
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 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
143 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
144 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
145 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147 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
148 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
149
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
150 prev_intro = *intro;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 printf(" - name = '%.*s'\n",
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
159 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
160 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
161 break;
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 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
164 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
165
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166 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
167 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
168 }
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
169 case MAIL_TRANSACTION_EXT_HDR_UPDATE: {
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
170 const struct mail_transaction_ext_hdr_update *u = data;
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
171
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
172 printf(" - offset = %u, size = %u: ", u->offset, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
173 print_data(u + 1, u->size);
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
174 printf("\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
175 break;
5895
cb5e25c3b300 Show extension header updates.
Timo Sirainen <tss@iki.fi>
parents: 5366
diff changeset
176 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 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
178 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
179 size_t record_size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
180
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
181 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
182 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
183 while (rec < end) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
184 printf(" - %u: ", rec->uid);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
185 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
186 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
187 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
188 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
189 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
190 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
191 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
192 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
193 const uint32_t *uid;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
194 unsigned int uid_offset;
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 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
197 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
198
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
199 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
200 ((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
201 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
202 size -= uid_offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
203
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
204 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
205 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
206 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
207 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
208 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
209 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
210 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
211 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
212
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
213 printf(" - ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214 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
215 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
216 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
217 printf("\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
218 break;
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 default:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 break;
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 }
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 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
226 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
227 off_t offset;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228 ssize_t ret;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
229 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
230 unsigned int orig_size;
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 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
233
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
234 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
235 if (ret == 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
236 return 0;
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 if (ret != sizeof(hdr)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 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
240 ret, sizeof(hdr));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
243 orig_size = hdr.size;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244 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
245 if (hdr.size == 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 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
247 "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
248 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
249 return 0;
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
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
252 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
253 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
254
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 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
256 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
257
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
258 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
259 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
260 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
261 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
262 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
263 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
264 } else {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265 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
266 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 }
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 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
271 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 int fd;
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 lib_init();
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 if (argc < 2)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
277 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
278
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279 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
280 if (fd < 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
281 i_error("open(): %m");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282 return 1;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
283 }
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 dump_hdr(fd);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
286 for (;;) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
287 t_push();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
288 if (!dump_record(fd))
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
290 t_pop();
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 t_pop();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
293 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
294 }