annotate src/lib-storage/index/mbox/mbox-sync-private.h @ 6410:e4eb71ae8e96 HEAD

Changed .h ifdef/defines to use <NAME>_H format.
author Timo Sirainen <tss@iki.fi>
date Sun, 16 Sep 2007 11:31:27 +0300
parents 5f66277bbe40
children 6a64e64fa3a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
1 #ifndef MBOX_SYNC_PRIVATE_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
2 #define MBOX_SYNC_PRIVATE_H
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
2242
5e2518377c0a Save MD5 sums of some headers for readonly mboxes and use them for syncing
Timo Sirainen <tss@iki.fi>
parents: 2238
diff changeset
4 #include "md5.h"
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "mail-index.h"
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
5374
d217ad85984c Check if mbox has been modified externally before doing any dangerous
Timo Sirainen <tss@iki.fi>
parents: 5301
diff changeset
7 #include <sys/stat.h>
d217ad85984c Check if mbox has been modified externally before doing any dangerous
Timo Sirainen <tss@iki.fi>
parents: 5301
diff changeset
8
2511
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
9 enum mbox_sync_flags {
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
10 MBOX_SYNC_LAST_COMMIT = 0x01,
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
11 MBOX_SYNC_HEADER = 0x02,
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
12 MBOX_SYNC_LOCK_READING = 0x04,
2665
ccf563859be5 Split sync_flag_full into sync_flag_full_read and _write. Closing mailbox
Timo Sirainen <tss@iki.fi>
parents: 2662
diff changeset
13 MBOX_SYNC_UNDIRTY = 0x08,
3341
fa9fd105fae3 If we see mbox offsets break, don't invalidate whole index but rather force
Timo Sirainen <tss@iki.fi>
parents: 3339
diff changeset
14 MBOX_SYNC_REWRITE = 0x10,
fa9fd105fae3 If we see mbox offsets break, don't invalidate whole index but rather force
Timo Sirainen <tss@iki.fi>
parents: 3339
diff changeset
15 MBOX_SYNC_FORCE_SYNC = 0x20
2511
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
16 };
710e0bf25bf8 Added mbox_dirty_syncs setting which delays re-reading the whole mbox when
Timo Sirainen <tss@iki.fi>
parents: 2404
diff changeset
17
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 struct mbox_flag_type {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 char chr;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 enum mail_flags flag;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 enum header_position {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 MBOX_HDR_STATUS,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 MBOX_HDR_X_IMAPBASE,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 MBOX_HDR_X_KEYWORDS,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 MBOX_HDR_X_STATUS,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 MBOX_HDR_X_UID,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 MBOX_HDR_COUNT
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32
3250
3b820e59610e Recent flag handling cleanups. Added some comments.
Timo Sirainen <tss@iki.fi>
parents: 3242
diff changeset
33 /* kludgy. swap MAIL_RECENT with MBOX_NONRECENT_KLUDGE when writing Status
3b820e59610e Recent flag handling cleanups. Added some comments.
Timo Sirainen <tss@iki.fi>
parents: 3242
diff changeset
34 header, because 'O' flag means non-recent but internally we want to use
3b820e59610e Recent flag handling cleanups. Added some comments.
Timo Sirainen <tss@iki.fi>
parents: 3242
diff changeset
35 recent flag. */
3b820e59610e Recent flag handling cleanups. Added some comments.
Timo Sirainen <tss@iki.fi>
parents: 3242
diff changeset
36 #define MBOX_NONRECENT_KLUDGE MAIL_RECENT
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37
3250
3b820e59610e Recent flag handling cleanups. Added some comments.
Timo Sirainen <tss@iki.fi>
parents: 3242
diff changeset
38 #define STATUS_FLAGS_MASK (MAIL_SEEN|MBOX_NONRECENT_KLUDGE)
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 #define XSTATUS_FLAGS_MASK (MAIL_ANSWERED|MAIL_FLAGGED|MAIL_DRAFT|MAIL_DELETED)
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 extern struct mbox_flag_type mbox_status_flags[];
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 extern struct mbox_flag_type mbox_xstatus_flags[];
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
1978
6303ef092c5b mbox code compiles again, but syncing is only partially implemented so
Timo Sirainen <tss@iki.fi>
parents: 1958
diff changeset
43 struct mbox_sync_mail {
5266
0dc6b54bb6aa Cleaned up the code a bit. Fixed sync rewrite crashing with pseudo mails.
Timo Sirainen <tss@iki.fi>
parents: 5240
diff changeset
44 /* uid=0 can mean that this mail describes an expunged area or that
0dc6b54bb6aa Cleaned up the code a bit. Fixed sync rewrite crashing with pseudo mails.
Timo Sirainen <tss@iki.fi>
parents: 5240
diff changeset
45 this is a pseudo message */
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 uint32_t uid;
2610
664c732ae195 Last from offset sync fix broke everything. Another try.
Timo Sirainen <tss@iki.fi>
parents: 2579
diff changeset
47 uint32_t idx_seq;
3519
7addee16b026 Don't crash in some situations with broken X-UID headers.
Timo Sirainen <tss@iki.fi>
parents: 3341
diff changeset
48
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
49 ARRAY_TYPE(keyword_indexes) keywords;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 uint8_t flags;
3519
7addee16b026 Don't crash in some situations with broken X-UID headers.
Timo Sirainen <tss@iki.fi>
parents: 3341
diff changeset
51
5301
3dd58ee1f74b uint8_t:1 is GCC extension, changed back to using unsigned int:1 although it
Timo Sirainen <tss@iki.fi>
parents: 5266
diff changeset
52 unsigned int uid_broken:1;
3dd58ee1f74b uint8_t:1 is GCC extension, changed back to using unsigned int:1 although it
Timo Sirainen <tss@iki.fi>
parents: 5266
diff changeset
53 unsigned int expunged:1;
3dd58ee1f74b uint8_t:1 is GCC extension, changed back to using unsigned int:1 although it
Timo Sirainen <tss@iki.fi>
parents: 5266
diff changeset
54 unsigned int pseudo:1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55
2118
11febaee5e9b Save mbox offsets to index file using extra_records. Some other fixes.
Timo Sirainen <tss@iki.fi>
parents: 2110
diff changeset
56 uoff_t from_offset;
2151
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
57 uoff_t body_size;
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
58
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
59 /* following variables have a bit overloaded functionality:
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
60
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
61 a) space <= 0 : offset points to beginning of headers. space is the
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
62 amount of space missing that is required to be able to rewrite
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
63 the headers
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
64 b) space > 0 : offset points to beginning of whitespace that can
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
65 be removed. space is the amount of data that can be removed from
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
66 there. note that the message may contain more whitespace
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
67 elsewhere. */
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
68 uoff_t offset;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69 off_t space;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 struct mbox_sync_mail_context {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 struct mbox_sync_context *sync_ctx;
1981
eb282832fc75 mbox rewriting is almost working - the hard part is done.
Timo Sirainen <tss@iki.fi>
parents: 1978
diff changeset
74 struct mbox_sync_mail mail;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
75
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76 uint32_t seq;
2579
b0ab37ee418a cleanups
Timo Sirainen <tss@iki.fi>
parents: 2529
diff changeset
77 uoff_t hdr_offset, body_offset;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 size_t header_first_change, header_last_change;
2974
8ef9f3d640e0 Removed X-UIDL header handling. It's not actually used.
Timo Sirainen <tss@iki.fi>
parents: 2972
diff changeset
80 string_t *header;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81
2242
5e2518377c0a Save MD5 sums of some headers for readonly mboxes and use them for syncing
Timo Sirainen <tss@iki.fi>
parents: 2238
diff changeset
82 unsigned char hdr_md5_sum[16];
5e2518377c0a Save MD5 sums of some headers for readonly mboxes and use them for syncing
Timo Sirainen <tss@iki.fi>
parents: 2238
diff changeset
83
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84 uoff_t content_length;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 size_t hdr_pos[MBOX_HDR_COUNT];
5160
2141e1f58c04 Fixed some wrong "uid-last unexpectedly lost" errors.
Timo Sirainen <tss@iki.fi>
parents: 5054
diff changeset
87 uint32_t parsed_uid, last_uid_updated_value;
3265
cb62447e3e75 Large mbox code cleanups, especially related to X-IMAP/X-IMAPbase header
Timo Sirainen <tss@iki.fi>
parents: 3254
diff changeset
88 unsigned int last_uid_value_start_pos;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 unsigned int have_eoh:1;
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91 unsigned int need_rewrite:1;
1981
eb282832fc75 mbox rewriting is almost working - the hard part is done.
Timo Sirainen <tss@iki.fi>
parents: 1978
diff changeset
92 unsigned int seen_imapbase:1;
2110
18d29a565168 some more fixes
Timo Sirainen <tss@iki.fi>
parents: 2107
diff changeset
93 unsigned int updated:1;
2529
23ac04da861f Wrong messages were set recent if another client had modified the mbox.
Timo Sirainen <tss@iki.fi>
parents: 2512
diff changeset
94 unsigned int recent:1;
2662
add94f9aa9e1 Added mbox_lazy_writes setting.
Timo Sirainen <tss@iki.fi>
parents: 2659
diff changeset
95 unsigned int dirty:1;
3265
cb62447e3e75 Large mbox code cleanups, especially related to X-IMAP/X-IMAPbase header
Timo Sirainen <tss@iki.fi>
parents: 3254
diff changeset
96 unsigned int imapbase_rewrite:1;
3339
5cf828dbcd32 If uid-last isn't actually updated while rewriting first message, don't
Timo Sirainen <tss@iki.fi>
parents: 3322
diff changeset
97 unsigned int imapbase_updated:1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
98 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
99
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100 struct mbox_sync_context {
3279
b698ae839a18 Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents: 3265
diff changeset
101 struct mbox_mailbox *mbox;
2662
add94f9aa9e1 Added mbox_lazy_writes setting.
Timo Sirainen <tss@iki.fi>
parents: 2659
diff changeset
102 enum mbox_sync_flags flags;
1978
6303ef092c5b mbox code compiles again, but syncing is only partially implemented so
Timo Sirainen <tss@iki.fi>
parents: 1958
diff changeset
103 struct istream *input, *file_input;
3242
9a08cf5e5f61 i_stream_sync() replaced istream_raw_mbox_flush(). Use i_stream_stat()
Timo Sirainen <tss@iki.fi>
parents: 3230
diff changeset
104 int write_fd;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105
5741
7a57631e2d6c Preserve mbox files' atime when saving/syncing.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
106 time_t orig_mtime, orig_atime;
5240
117c9fd0b633 Keep track of the mbox dirty state better. Also when moving mails inside
Timo Sirainen <tss@iki.fi>
parents: 5203
diff changeset
107 uoff_t orig_size;
5374
d217ad85984c Check if mbox has been modified externally before doing any dangerous
Timo Sirainen <tss@iki.fi>
parents: 5301
diff changeset
108 struct stat last_stat;
5240
117c9fd0b633 Keep track of the mbox dirty state better. Also when moving mails inside
Timo Sirainen <tss@iki.fi>
parents: 5203
diff changeset
109
2124
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
110 struct mail_index_sync_ctx *index_sync_ctx;
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
111 struct mail_index_view *sync_view;
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
112 struct mail_index_transaction *t;
5850
f8caf3c6a5a7 Handle UIDVALIDITY changes by resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5741
diff changeset
113
f8caf3c6a5a7 Handle UIDVALIDITY changes by resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5741
diff changeset
114 struct mail_index_header reset_hdr;
2124
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
115 const struct mail_index_header *hdr;
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
116
2974
8ef9f3d640e0 Removed X-UIDL header handling. It's not actually used.
Timo Sirainen <tss@iki.fi>
parents: 2972
diff changeset
117 string_t *header, *from_line;
2124
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
118
2125
dc18cc3568b0 several fixes and optimizations.
Timo Sirainen <tss@iki.fi>
parents: 2124
diff changeset
119 /* header state: */
dc18cc3568b0 several fixes and optimizations.
Timo Sirainen <tss@iki.fi>
parents: 2124
diff changeset
120 uint32_t base_uid_validity, base_uid_last;
3265
cb62447e3e75 Large mbox code cleanups, especially related to X-IMAP/X-IMAPbase header
Timo Sirainen <tss@iki.fi>
parents: 3254
diff changeset
121 uoff_t base_uid_last_offset;
2125
dc18cc3568b0 several fixes and optimizations.
Timo Sirainen <tss@iki.fi>
parents: 2124
diff changeset
122
dc18cc3568b0 several fixes and optimizations.
Timo Sirainen <tss@iki.fi>
parents: 2124
diff changeset
123 /* mail state: */
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
124 ARRAY_DEFINE(mails, struct mbox_sync_mail);
5898
54ef7dccdfc7 Moved index sync record grouping from mbox to generic code.
Timo Sirainen <tss@iki.fi>
parents: 5850
diff changeset
125 struct index_sync_changes_context *sync_changes;
2124
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
126
4716
79edf40cc2f9 Last keyword pool clearing optimization broke the keywords if we had to move
Timo Sirainen <tss@iki.fi>
parents: 4698
diff changeset
127 /* per-mail pool */
3254
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3250
diff changeset
128 pool_t mail_keyword_pool;
4716
79edf40cc2f9 Last keyword pool clearing optimization broke the keywords if we had to move
Timo Sirainen <tss@iki.fi>
parents: 4698
diff changeset
129 /* used for mails[].keywords */
79edf40cc2f9 Last keyword pool clearing optimization broke the keywords if we had to move
Timo Sirainen <tss@iki.fi>
parents: 4698
diff changeset
130 pool_t saved_keywords_pool;
3254
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3250
diff changeset
131
3322
49071cc19102 If UIDVALIDITY changes, don't invalidate the whole index. Just expunge all
Timo Sirainen <tss@iki.fi>
parents: 3281
diff changeset
132 uint32_t prev_msg_uid, next_uid, idx_next_uid;
2826
e3572b0651f7 restart partial syncs correctly. and cleanups.
Timo Sirainen <tss@iki.fi>
parents: 2743
diff changeset
133 uint32_t seq, idx_seq, need_space_seq;
6038
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
134 uint32_t last_nonrecent_uid;
2124
24651c3ac7f3 major syncing code cleanups. the code finally looks almost readable. logic
Timo Sirainen <tss@iki.fi>
parents: 2118
diff changeset
135 off_t expunged_space, space_diff;
2151
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
136
16287320d080 Several fixes in space/offset logic. Should be much more robust now.
Timo Sirainen <tss@iki.fi>
parents: 2128
diff changeset
137 unsigned int dest_first_mail:1;
4698
8ae46b72a460 Fixes to handling CRLF linefeeds in mboxes.
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
138 unsigned int first_mail_crlf_expunged:1;
2827
811945597b6a cleanup
Timo Sirainen <tss@iki.fi>
parents: 2826
diff changeset
139
811945597b6a cleanup
Timo Sirainen <tss@iki.fi>
parents: 2826
diff changeset
140 /* global flags: */
2662
add94f9aa9e1 Added mbox_lazy_writes setting.
Timo Sirainen <tss@iki.fi>
parents: 2659
diff changeset
141 unsigned int delay_writes:1;
5203
71e110813d7b If next_uid field gets to 2^31-1, handle it without crashing by creating a
Timo Sirainen <tss@iki.fi>
parents: 5171
diff changeset
142 unsigned int renumber_uids:1;
5240
117c9fd0b633 Keep track of the mbox dirty state better. Also when moving mails inside
Timo Sirainen <tss@iki.fi>
parents: 5203
diff changeset
143 unsigned int moved_offsets:1;
5529
fd13f04e1fda Give "mbox file was modified while we were syncing" error only if we detect
Timo Sirainen <tss@iki.fi>
parents: 5374
diff changeset
144 unsigned int ext_modified:1;
5850
f8caf3c6a5a7 Handle UIDVALIDITY changes by resetting index.
Timo Sirainen <tss@iki.fi>
parents: 5741
diff changeset
145 unsigned int index_reset:1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147
3279
b698ae839a18 Moved mbox/maildir-specific variables from struct index_mailbox to
Timo Sirainen <tss@iki.fi>
parents: 3265
diff changeset
148 int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags);
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3677
diff changeset
149 int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty);
5529
fd13f04e1fda Give "mbox file was modified while we were syncing" error only if we detect
Timo Sirainen <tss@iki.fi>
parents: 5374
diff changeset
150 void mbox_sync_set_critical(struct mbox_sync_context *sync_ctx,
fd13f04e1fda Give "mbox file was modified while we were syncing" error only if we detect
Timo Sirainen <tss@iki.fi>
parents: 5374
diff changeset
151 const char *fmt, ...) __attr_format__(2, 3);
2190
755ec9442a58 mailbox_save() and mailbox_copy() functions can now return the saved mail so
Timo Sirainen <tss@iki.fi>
parents: 2164
diff changeset
152
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
153 void mbox_sync_parse_next_mail(struct istream *input,
2214
c0b5573d76e3 fixes for From-line offset updating
Timo Sirainen <tss@iki.fi>
parents: 2211
diff changeset
154 struct mbox_sync_mail_context *ctx);
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
155 bool mbox_sync_parse_match_mail(struct mbox_mailbox *mbox,
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
156 struct mail_index_view *view, uint32_t seq);
2512
abcdec2299bd When mbox syncing is dirty, read the message headers to verify that we've
Timo Sirainen <tss@iki.fi>
parents: 2511
diff changeset
157
3254
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3250
diff changeset
158 void mbox_sync_update_header(struct mbox_sync_mail_context *ctx);
1981
eb282832fc75 mbox rewriting is almost working - the hard part is done.
Timo Sirainen <tss@iki.fi>
parents: 1978
diff changeset
159 void mbox_sync_update_header_from(struct mbox_sync_mail_context *ctx,
eb282832fc75 mbox rewriting is almost working - the hard part is done.
Timo Sirainen <tss@iki.fi>
parents: 1978
diff changeset
160 const struct mbox_sync_mail *mail);
2687
482e1a1fe2ce Bringing some sanity into mbox rewrites. Fixes expunge crashes and reduces
Timo Sirainen <tss@iki.fi>
parents: 2665
diff changeset
161 int mbox_sync_try_rewrite(struct mbox_sync_mail_context *ctx, off_t move_diff);
482e1a1fe2ce Bringing some sanity into mbox rewrites. Fixes expunge crashes and reduces
Timo Sirainen <tss@iki.fi>
parents: 2665
diff changeset
162 int mbox_sync_rewrite(struct mbox_sync_context *sync_ctx,
3677
6f58deb34e8a When rewriting mbox, don't parse the last message again. We already have its
Timo Sirainen <tss@iki.fi>
parents: 3519
diff changeset
163 struct mbox_sync_mail_context *mail_ctx,
2743
2cada6a7f3eb If rewriting began with expunged data areas, we didn't overwrite them which
Timo Sirainen <tss@iki.fi>
parents: 2687
diff changeset
164 uoff_t end_offset, off_t move_diff, uoff_t extra_space,
2164
Timo Sirainen <tss@iki.fi>
parents: 2161
diff changeset
165 uint32_t first_seq, uint32_t last_seq);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166
2155
Timo Sirainen <tss@iki.fi>
parents: 2151
diff changeset
167 int mbox_sync_seek(struct mbox_sync_context *sync_ctx, uoff_t from_offset);
5529
fd13f04e1fda Give "mbox file was modified while we were syncing" error only if we detect
Timo Sirainen <tss@iki.fi>
parents: 5374
diff changeset
168 void mbox_sync_file_update_ext_modified(struct mbox_sync_context *sync_ctx);
5374
d217ad85984c Check if mbox has been modified externally before doing any dangerous
Timo Sirainen <tss@iki.fi>
parents: 5301
diff changeset
169 void mbox_sync_file_updated(struct mbox_sync_context *sync_ctx, bool dirty);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
170 int mbox_move(struct mbox_sync_context *sync_ctx,
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
171 uoff_t dest, uoff_t source, uoff_t size);
2249
cb4dad60f6cd Several fixes for updating mbox. Recent changes also made it corrupt
Timo Sirainen <tss@iki.fi>
parents: 2242
diff changeset
172 void mbox_sync_move_buffer(struct mbox_sync_mail_context *ctx,
cb4dad60f6cd Several fixes for updating mbox. Recent changes also made it corrupt
Timo Sirainen <tss@iki.fi>
parents: 2242
diff changeset
173 size_t pos, size_t need, size_t have);
3254
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3250
diff changeset
174 void mbox_sync_headers_add_space(struct mbox_sync_mail_context *ctx,
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3250
diff changeset
175 size_t size);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
176
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 #endif