annotate src/util/idxview.c @ 9532:00cd9aacd03c HEAD

Updated copyright notices to include year 2010.
author Timo Sirainen <tss@iki.fi>
date Mon, 25 Jan 2010 01:18:58 +0200
parents f16e102e8693
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9532
00cd9aacd03c Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents: 8750
diff changeset
1 /* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "array.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "str.h"
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "hex-binary.h"
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
7 #include "file-lock.h"
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #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
9 #include "mail-cache-private.h"
7629
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
10 #include "mail-cache-private.h"
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
11 #include "mail-index-modseq.h"
5366
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 #include <stdio.h>
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 #include <stdlib.h>
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
15 #include <time.h>
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
17 struct maildir_index_header {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
18 uint32_t new_check_time, new_mtime, new_mtime_nsecs;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
19 uint32_t cur_check_time, cur_mtime, cur_mtime_nsecs;
7516
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
20 uint32_t uidlist_mtime, uidlist_mtime_nsecs, uidlist_size;
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
21 };
8527
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
22 struct mbox_index_header {
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
23 uint64_t sync_size;
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
24 uint32_t sync_mtime;
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
25 uint8_t dirty_flag;
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
26 uint8_t unused[3];
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
27 };
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
28 struct dbox_index_header {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
29 uint32_t last_dirty_flush_stamp;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
30 };
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
31
8498
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
32 struct virtual_mail_index_record {
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
33 uint32_t mailbox_id;
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
34 uint32_t real_uid;
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
35 };
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
36
7561
1a58b18652a6 Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents: 7516
diff changeset
37 static const char *unixdate2str(time_t timestamp)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
39 static char buf[64];
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
40 struct tm *tm;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41
7561
1a58b18652a6 Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents: 7516
diff changeset
42 tm = localtime(&timestamp);
8579
3b16e400fa8c idxview: Show seconds in timestamps (except for cache headers).
Timo Sirainen <tss@iki.fi>
parents: 8547
diff changeset
43 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
44 return buf;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
47 static void dump_hdr(struct mail_index *index)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
49 const struct mail_index_header *hdr = &index->map->hdr;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
50 unsigned int i;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
52 printf("version .................. = %u.%u\n", hdr->major_version, hdr->minor_version);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
53 printf("base header size ......... = %u\n", hdr->base_header_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
54 printf("header size .............. = %u\n", hdr->header_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
55 printf("record size .............. = %u\n", hdr->record_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
56 printf("compat flags ............. = %u\n", hdr->compat_flags);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
57 printf("index id ................. = %u (%s)\n", hdr->indexid, unixdate2str(hdr->indexid));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
58 printf("flags .................... = %u\n", hdr->flags);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
59 printf("uid validity ............. = %u (%s)\n", hdr->uid_validity, unixdate2str(hdr->uid_validity));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
60 printf("next uid ................. = %u\n", hdr->next_uid);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
61 printf("messages count ........... = %u\n", hdr->messages_count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
62 printf("seen messages count ...... = %u\n", hdr->seen_messages_count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
63 printf("deleted messages count ... = %u\n", hdr->deleted_messages_count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
64 printf("first recent uid ......... = %u\n", hdr->first_recent_uid);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
65 printf("first unseen uid lowwater = %u\n", hdr->first_unseen_uid_lowwater);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
66 printf("first deleted uid lowwater = %u\n", hdr->first_deleted_uid_lowwater);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
67 printf("log file seq ............. = %u\n", hdr->log_file_seq);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
68 if (hdr->minor_version == 0) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
69 printf("log file int offset ...... = %u\n", hdr->log_file_tail_offset);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
70 printf("log file ext offset ...... = %u\n", hdr->log_file_head_offset);
5751
a230272b3f28 Updated to use the new head/tail headers
Timo Sirainen <tss@iki.fi>
parents: 5689
diff changeset
71 } else {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
72 printf("log file tail offset ..... = %u\n", hdr->log_file_tail_offset);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
73 printf("log file head offset ..... = %u\n", hdr->log_file_head_offset);
5751
a230272b3f28 Updated to use the new head/tail headers
Timo Sirainen <tss@iki.fi>
parents: 5689
diff changeset
74 }
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
75 printf("sync size ................ = %llu\n", (unsigned long long)hdr->sync_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
76 printf("sync stamp ............... = %u (%s)\n", hdr->sync_stamp, unixdate2str(hdr->sync_stamp));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
77 printf("day stamp ................ = %u (%s)\n", hdr->day_stamp, unixdate2str(hdr->day_stamp));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
78 for (i = 0; i < N_ELEMENTS(hdr->day_first_uid); i++)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
79 printf("day first uid[%u] ......... = %u\n", i, hdr->day_first_uid[i]);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
80 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
82 static void dump_extension_header(struct mail_index *index,
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
83 const struct mail_index_ext *ext)
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
84 {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
85 const void *data;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
86
8547
545cb188f7ab Replaced literal "keywords" strings with a macro.
Timo Sirainen <tss@iki.fi>
parents: 8527
diff changeset
87 if (strcmp(ext->name, MAIL_INDEX_EXT_KEYWORDS) == 0)
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
88 return;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
89
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
90 data = CONST_PTR_OFFSET(index->map->hdr_base, ext->hdr_offset);
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
91 if (strcmp(ext->name, "maildir") == 0) {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
92 const struct maildir_index_header *hdr = data;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
93
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
94 printf("header\n");
7516
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
95 printf(" - new_check_time .... = %s\n", unixdate2str(hdr->new_check_time));
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
96 printf(" - new_mtime ......... = %s\n", unixdate2str(hdr->new_mtime));
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
97 printf(" - new_mtime_nsecs ... = %u\n", hdr->new_mtime_nsecs);
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
98 printf(" - cur_check_time .... = %s\n", unixdate2str(hdr->cur_check_time));
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
99 printf(" - cur_mtime ......... = %s\n", unixdate2str(hdr->cur_mtime));
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
100 printf(" - cur_mtime_nsecs.... = %u\n", hdr->cur_mtime_nsecs);
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
101 printf(" - uidlist_mtime ..... = %s\n", unixdate2str(hdr->uidlist_mtime));
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
102 printf(" - uidlist_mtime_nsecs = %u\n", hdr->uidlist_mtime_nsecs);
7a7cf6662302 Show the new uidlist_* fields in maildir header.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
103 printf(" - uidlist_size ...... = %u\n", hdr->uidlist_size);
8527
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
104 } else if (strcmp(ext->name, "mbox") == 0) {
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
105 const struct mbox_index_header *hdr = data;
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
106
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
107 printf("header\n");
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
108 printf(" - sync_mtime = %s\n", unixdate2str(hdr->sync_mtime));
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
109 printf(" - sync_size = %llu\n",
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
110 (unsigned long long)hdr->sync_size);
6d07bedcdb80 mbox: Added a new index header where dirtyness state is stored.
Timo Sirainen <tss@iki.fi>
parents: 8498
diff changeset
111 printf(" - dirty_flag = %d\n", hdr->dirty_flag);
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
112 } else if (strcmp(ext->name, "dbox-hdr") == 0) {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
113 const struct dbox_index_header *hdr = data;
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
114
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
115 printf("header\n");
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
116 printf(" - last_dirty_flush_stamp = %s\n", unixdate2str(hdr->last_dirty_flush_stamp));
7629
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
117 } else if (strcmp(ext->name, "modseq") == 0) {
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
118 const struct mail_index_modseq_header *hdr = data;
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
119
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
120 printf("header\n");
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
121 printf(" - highest_modseq = %llu\n",
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
122 (unsigned long long)hdr->highest_modseq);
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
123 printf(" - log_seq ...... = %u\n", hdr->log_seq);
bad3a811a148 Added QRESYNC support.
Timo Sirainen <tss@iki.fi>
parents: 7234
diff changeset
124 printf(" - log_offset ... = %u\n", hdr->log_offset);
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
125 } else {
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
126 printf("header ........ = %s\n",
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
127 binary_to_hex(data, ext->hdr_size));
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
128 }
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
129 }
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
130
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
131 static void dump_extensions(struct mail_index *index)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
132 {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
133 const struct mail_index_ext *extensions;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
134 unsigned int i, count;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
135
7234
b8b100c7771c Don't crash if there are no extensions.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
136 if (array_is_created(&index->map->extensions))
b8b100c7771c Don't crash if there are no extensions.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
137 extensions = array_get(&index->map->extensions, &count);
b8b100c7771c Don't crash if there are no extensions.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
138 else
b8b100c7771c Don't crash if there are no extensions.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
139 count = 0;
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
140 if (count == 0) {
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141 printf("no extensions\n");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 return;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
143 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
144
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
145 for (i = 0; i < count; i++) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
146 const struct mail_index_ext *ext = &extensions[i];
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
148 printf("-- Extension %u --\n", i);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
149 printf("name ........ = %s\n", ext->name);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
150 printf("hdr_size .... = %u\n", ext->hdr_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
151 printf("reset_id .... = %u\n", ext->reset_id);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
152 printf("record_offset = %u\n", ext->record_offset);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
153 printf("record_size . = %u\n", ext->record_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
154 printf("record_align = %u\n", ext->record_align);
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
155 if (ext->hdr_size > 0)
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
156 dump_extension_header(index, ext);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
157 }
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
158 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
159
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
160 static void dump_keywords(struct mail_index *index)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
161 {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
162 const unsigned int *kw_indexes;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
163 const char *const *keywords;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
164 unsigned int i, count;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
165
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
166 printf("-- Keywords --\n");
6691
ee9c8e0f25b7 Don't crash if index has no keywords at all.
Timo Sirainen <tss@iki.fi>
parents: 6690
diff changeset
167 if (!array_is_created(&index->map->keyword_idx_map))
ee9c8e0f25b7 Don't crash if index has no keywords at all.
Timo Sirainen <tss@iki.fi>
parents: 6690
diff changeset
168 return;
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
169
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
170 kw_indexes = array_get(&index->map->keyword_idx_map, &count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
171 if (count == 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
172 return;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
173
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
174 keywords = array_idx(&index->keywords, 0);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
175 for (i = 0; i < count; i++)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
176 printf("%3u = %s\n", i, keywords[kw_indexes[i]]);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
178
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
179 static const char *cache_decision2str(enum mail_cache_decision_type type)
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
180 {
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
181 const char *str;
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
182
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
183 switch (type & ~MAIL_CACHE_DECISION_FORCED) {
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
184 case MAIL_CACHE_DECISION_NO:
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
185 str = "no";
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
186 break;
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
187 case MAIL_CACHE_DECISION_TEMP:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
188 str = "tmp";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
189 break;
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
190 case MAIL_CACHE_DECISION_YES:
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
191 str = "yes";
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
192 break;
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
193 default:
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
194 return t_strdup_printf("0x%x", type);
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
195 }
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
196
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
197 if ((type & MAIL_CACHE_DECISION_FORCED) != 0)
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
198 str = t_strconcat(str, "!", NULL);
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
199 return str;
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
200 }
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
201
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
202 #define CACHE_TYPE_IS_FIXED_SIZE(type) \
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
203 ((type) == MAIL_CACHE_FIELD_FIXED_SIZE || \
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
204 (type) == MAIL_CACHE_FIELD_BITMASK)
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
205 static const char *cache_type2str(enum mail_cache_field_type type)
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
206 {
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
207 switch (type) {
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
208 case MAIL_CACHE_FIELD_FIXED_SIZE:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
209 return "fix";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
210 case MAIL_CACHE_FIELD_VARIABLE_SIZE:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
211 return "var";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
212 case MAIL_CACHE_FIELD_STRING:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
213 return "str";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
214 case MAIL_CACHE_FIELD_BITMASK:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
215 return "bit";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
216 case MAIL_CACHE_FIELD_HEADER:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
217 return "hdr";
6292
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
218 default:
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
219 return t_strdup_printf("0x%x", type);
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
220 }
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
221 }
623639306046 Print cache header's fields in more human-readable format.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
222
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
223 static void dump_cache_hdr(struct mail_cache *cache)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
224 {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
225 const struct mail_cache_header *hdr;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
226 const struct mail_cache_field *fields, *field;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
227 unsigned int i, count, cache_idx;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
229 (void)mail_cache_open_and_verify(cache);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
230 if (MAIL_CACHE_IS_UNUSABLE(cache)) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
231 printf("cache is unusable\n");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
232 return;
5366
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
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
235 hdr = cache->hdr;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
236 printf("version .............. = %u\n", hdr->version);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
237 printf("indexid .............. = %u (%s)\n", hdr->indexid, unixdate2str(hdr->indexid));
6923
efd6dfbddf19 Print the number of cache file compressions.
Timo Sirainen <tss@iki.fi>
parents: 6875
diff changeset
238 printf("file_seq ............. = %u (%s) (%d compressions)\n",
efd6dfbddf19 Print the number of cache file compressions.
Timo Sirainen <tss@iki.fi>
parents: 6875
diff changeset
239 hdr->file_seq, unixdate2str(hdr->file_seq),
efd6dfbddf19 Print the number of cache file compressions.
Timo Sirainen <tss@iki.fi>
parents: 6875
diff changeset
240 hdr->file_seq - hdr->indexid);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
241 printf("continued_record_count = %u\n", hdr->continued_record_count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
242 printf("hole_offset .......... = %u\n", hdr->hole_offset);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
243 printf("used_file_size ....... = %u\n", hdr->used_file_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
244 printf("deleted_space ........ = %u\n", hdr->deleted_space);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
245 printf("field_header_offset .. = %u (0x%08x nontranslated)\n",
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
246 mail_index_offset_to_uint32(hdr->field_header_offset),
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
247 hdr->field_header_offset);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
249 printf("-- Cache fields --\n");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
250 fields = mail_cache_register_get_list(cache, pool_datastack_create(),
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
251 &count);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
252 printf(
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
253 " # Name Type Size Dec Last used\n");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
254 for (i = 0; i < cache->file_fields_count; i++) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
255 cache_idx = cache->file_field_map[i];
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
256 field = &fields[cache_idx];
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
258 printf("%2u: %-44s %-4s ", i, field->name,
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
259 cache_type2str(field->type));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
260 if (field->field_size != (uint32_t)-1 ||
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
261 CACHE_TYPE_IS_FIXED_SIZE(field->type))
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
262 printf("%4u ", field->field_size);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
263 else
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
264 printf(" - ");
8579
3b16e400fa8c idxview: Show seconds in timestamps (except for cache headers).
Timo Sirainen <tss@iki.fi>
parents: 8547
diff changeset
265 printf("%-4s %.16s\n",
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
266 cache_decision2str(field->decision),
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
267 unixdate2str(cache->fields[cache_idx].last_used));
5366
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
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
271 static void dump_cache(struct mail_cache_view *cache_view, unsigned int seq)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
272 {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
273 struct mail_cache_lookup_iterate_ctx iter;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
274 const struct mail_cache_record *prev_rec = NULL;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
275 const struct mail_cache_field *field;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
276 struct mail_cache_iterate_field iter_field;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
277 const void *data;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
278 unsigned int size;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279 string_t *str;
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
280 int ret;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
281
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282 str = t_str_new(512);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
283 mail_cache_lookup_iter_init(cache_view, seq, &iter);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
284 while ((ret = mail_cache_lookup_iter_next(&iter, &iter_field)) > 0) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
285 if (iter.rec != prev_rec) {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
286 printf(" - cache offset=%u size=%u, prev_offset = %u\n",
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
287 iter.offset, iter.rec->size,
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
288 iter.rec->prev_offset);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
289 prev_rec = iter.rec;
5366
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
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
292 field = &cache_view->cache->fields[iter_field.field_idx].field;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
293 data = iter_field.data;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
294 size = iter_field.size;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
295
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
296 str_truncate(str, 0);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
297 str_printfa(str, " - %s: ", field->name);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
298 switch (field->type) {
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
299 case MAIL_CACHE_FIELD_FIXED_SIZE:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
300 if (size == sizeof(uint32_t))
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
301 str_printfa(str, "%u ", *((const uint32_t *)data));
7029
595b600ddf8b Show integer output for 64bit fixed fields in cache file.
Timo Sirainen <tss@iki.fi>
parents: 6940
diff changeset
302 else if (size == sizeof(uint64_t))
595b600ddf8b Show integer output for 64bit fixed fields in cache file.
Timo Sirainen <tss@iki.fi>
parents: 6940
diff changeset
303 str_printfa(str, "%llu ", (unsigned long long)*((const uint64_t *)data));
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
304 case MAIL_CACHE_FIELD_VARIABLE_SIZE:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
305 case MAIL_CACHE_FIELD_BITMASK:
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
306 str_printfa(str, "(%s)", binary_to_hex(data, size));
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
307 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
308 case MAIL_CACHE_FIELD_STRING:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
309 if (size > 0)
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
310 str_printfa(str, "%.*s", (int)size, (const char *)data);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
311 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
312 case MAIL_CACHE_FIELD_HEADER: {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
313 const uint32_t *lines = data;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
314 int i;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
315
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
316 for (i = 0;; i++) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
317 if (size < sizeof(uint32_t)) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
318 if (i == 0 && size == 0) {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
319 /* header doesn't exist */
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
320 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
321 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 str_append(str, "\n - BROKEN: header field doesn't end with 0 line");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 size = 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
327
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
328 size -= sizeof(uint32_t);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
329 data = CONST_PTR_OFFSET(data, sizeof(uint32_t));
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
330 if (lines[i] == 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
331 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
332
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
333 if (i > 0)
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
334 str_append(str, ", ");
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
335 str_printfa(str, "%u", lines[i]);
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
336 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
338 if (i == 1 && size > 0 &&
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
339 ((const char *)data)[size-1] == '\n')
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
340 size--;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341 if (size > 0)
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
342 str_printfa(str, ": %.*s", (int)size, (const char *)data);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 case MAIL_CACHE_FIELD_COUNT:
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 i_unreached();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347 break;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
348 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
349
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
350 printf("%s\n", str_c(str));
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
351 }
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
352 if (ret < 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
353 printf(" - broken cache\n");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
355
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
356 static const char *flags2str(enum mail_flags flags)
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
357 {
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
358 string_t *str;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
359
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
360 str = t_str_new(64);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
361 str_append_c(str, '(');
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
362 if ((flags & MAIL_SEEN) != 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
363 str_append(str, "Seen ");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
364 if ((flags & MAIL_ANSWERED) != 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
365 str_append(str, "Answered ");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
366 if ((flags & MAIL_FLAGGED) != 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
367 str_append(str, "Flagged ");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
368 if ((flags & MAIL_DELETED) != 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
369 str_append(str, "Deleted ");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
370 if ((flags & MAIL_DRAFT) != 0)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
371 str_append(str, "Draft ");
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
372 if (str_len(str) == 1)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
373 return "";
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
375 str_truncate(str, str_len(str)-1);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
376 str_append_c(str, ')');
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
377 return str_c(str);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
378 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
379
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
380 static void dump_record(struct mail_index_view *view, unsigned int seq)
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
381 {
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
382 struct mail_index *index = mail_index_view_get_index(view);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
383 const struct mail_index_record *rec;
6767
51793c88b1c7 Fix showing extensions.
Timo Sirainen <tss@iki.fi>
parents: 6691
diff changeset
384 const struct mail_index_registered_ext *ext;
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
385 const void *data;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
386 unsigned int i, ext_count;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
387 string_t *str;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
388 bool expunged;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
389
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
390 rec = mail_index_lookup(view, seq);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
391 printf("RECORD: seq=%u, uid=%u, flags=0x%02x %s\n",
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
392 seq, rec->uid, rec->flags, flags2str(rec->flags));
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
393
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
394 str = t_str_new(256);
6767
51793c88b1c7 Fix showing extensions.
Timo Sirainen <tss@iki.fi>
parents: 6691
diff changeset
395 ext = array_get(&index->extensions, &ext_count);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
396 for (i = 0; i < ext_count; i++) {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
397 mail_index_lookup_ext(view, seq, i, &data, &expunged);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
398 if (data == NULL || ext[i].record_size == 0)
6294
10a5f61d9692 Don't show extensions for records if their record size is 0.
Timo Sirainen <tss@iki.fi>
parents: 6293
diff changeset
399 continue;
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
400
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
401 str_truncate(str, 0);
6688
3cd4b722baab Make output a bit more cleaner.
Timo Sirainen <tss@iki.fi>
parents: 6687
diff changeset
402 str_printfa(str, " - ext %d %-10s: ", i, ext[i].name);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
403 if (ext[i].record_size == sizeof(uint32_t) &&
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
404 ext[i].record_align == sizeof(uint32_t))
6688
3cd4b722baab Make output a bit more cleaner.
Timo Sirainen <tss@iki.fi>
parents: 6687
diff changeset
405 str_printfa(str, "%10u", *((const uint32_t *)data));
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 else if (ext[i].record_size == sizeof(uint64_t) &&
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407 ext[i].record_align == sizeof(uint64_t)) {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
408 uint64_t value = *((const uint64_t *)data);
6688
3cd4b722baab Make output a bit more cleaner.
Timo Sirainen <tss@iki.fi>
parents: 6687
diff changeset
409 str_printfa(str, "%10llu", (unsigned long long)value);
3cd4b722baab Make output a bit more cleaner.
Timo Sirainen <tss@iki.fi>
parents: 6687
diff changeset
410 } else {
3cd4b722baab Make output a bit more cleaner.
Timo Sirainen <tss@iki.fi>
parents: 6687
diff changeset
411 str_append(str, " ");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 }
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
413 str_printfa(str, " (%s)",
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
414 binary_to_hex(data, ext[i].record_size));
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415 printf("%s\n", str_c(str));
8498
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
416 if (strcmp(ext[i].name, "virtual") == 0) {
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
417 const struct virtual_mail_index_record *vrec = data;
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
418 printf(" : mailbox_id = %u\n", vrec->mailbox_id);
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
419 printf(" : real_uid = %u\n", vrec->real_uid);
fb5fedcf4deb idxview: Decode virtual extension records.
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
420 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
421 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
422 }
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
423
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
424 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
425 {
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
426 struct mail_index *index;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
427 struct mail_index_view *view;
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
428 struct mail_cache_view *cache_view;
8750
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
429 struct stat st;
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
430 const char *p;
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
431 unsigned int seq, uid = 0;
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
433 lib_init();
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
435 if (argc < 2)
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
436 i_fatal("Usage: idxview <index dir> [<uid>]");
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
437
8750
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
438 if (stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
439 index = mail_index_alloc(argv[1], "dovecot.index");
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
440 else if ((p = strrchr(argv[1], '/')) != NULL)
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
441 index = mail_index_alloc(t_strdup_until(argv[1], p), p + 1);
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
442 else
f16e102e8693 idxview: Support specifying the name of dovecot.index file.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
443 index = mail_index_alloc(".", argv[1]);
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
444 if (mail_index_open(index, MAIL_INDEX_OPEN_FLAG_READONLY,
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
445 FILE_LOCK_METHOD_FCNTL) <= 0)
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
446 i_fatal("Couldn't open index %s", argv[1]);
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
447 if (argv[2] != NULL)
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
448 uid = atoi(argv[2]);
6689
b19f4de84900 Show extension headers' contents.
Timo Sirainen <tss@iki.fi>
parents: 6688
diff changeset
449
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
450 view = mail_index_view_open(index);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
451 cache_view = mail_cache_view_open(index->cache, view);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
452
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
453 if (uid == 0) {
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
454 printf("-- INDEX: %s\n", index->filepath);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
455 dump_hdr(index);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
456 dump_extensions(index);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
457 dump_keywords(index);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
458
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
459 printf("\n-- CACHE: %s\n", index->cache->filepath);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
460 dump_cache_hdr(index->cache);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
461
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
462 printf("\n-- RECORDS: %u\n", index->map->hdr.messages_count);
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
463 }
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
464 for (seq = 1; seq <= index->map->hdr.messages_count; seq++) {
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
465 if (uid == 0 || mail_index_lookup(view, seq)->uid == uid) {
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
466 T_BEGIN {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6923
diff changeset
467 dump_record(view, seq);
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6923
diff changeset
468 dump_cache(cache_view, seq);
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6923
diff changeset
469 printf("\n");
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
470 } T_END;
6690
040cbd9c4695 Support showing only a single UID's contents.
Timo Sirainen <tss@iki.fi>
parents: 6689
diff changeset
471 }
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
472 }
6687
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
473 mail_cache_view_close(cache_view);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
474 mail_index_view_close(&view);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
475 mail_index_close(index);
294af3a8d974 idxview rewrite. It now uses lib-index functions to read the files.
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
476 mail_index_free(&index);
5366
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
477 return 0;
a42014a7d8be Added idxview and logview to dump index/cache/log file contents.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
478 }