annotate src/lib-index/mailbox-list-index-private.h @ 6076:f1f83c90fd3d HEAD

Moved mailbox_list_index_set_corrupted() to private .h file
author Timo Sirainen <tss@iki.fi>
date Wed, 18 Jul 2007 08:39:01 +0300
parents cdf39128dd91
children e562c6359cd1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 #ifndef __MAILBOX_LIST_INDEX_PRIVATE_H
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 #define __MAILBOX_LIST_INDEX_PRIVATE_H
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
4968
1baf9dd3fc40 Added dotlock_use_excl setting.
Timo Sirainen <tss@iki.fi>
parents: 4929
diff changeset
4 #include "file-dotlock.h"
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "mailbox-list-index.h"
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #define MAILBOX_LIST_INDEX_MAJOR_VERSION 1
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #define MAILBOX_LIST_INDEX_MINOR_VERSION 0
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9
4929
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
10 #define MAILBOX_LIST_COMPRESS_PERCENTAGE 10
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
11 #define MAILBOX_LIST_COMPRESS_MIN_SIZE 1024
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
12
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 struct mailbox_list_index_header {
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 uint8_t major_version;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 uint8_t minor_version;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 uint8_t unused[2];
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 uint32_t header_size;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 uint32_t uid_validity;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 /* locking required to access the fields below: */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 uint32_t next_uid;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 uint32_t used_space;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 uint32_t deleted_space;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 };
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 struct mailbox_list_dir_record {
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 /* If non-zero, contains a pointer to updated directory list.
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 Stored using mail_index_uint32_to_offset(). */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 uint32_t next_offset;
5343
cdf39128dd91 More desyncing fixes
Timo Sirainen <tss@iki.fi>
parents: 5324
diff changeset
32 /* Bytes used by this record, including mailbox names. */
cdf39128dd91 More desyncing fixes
Timo Sirainen <tss@iki.fi>
parents: 5324
diff changeset
33 uint32_t dir_size;
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 uint32_t count;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36 /* The records are sorted by their name_hash */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 /* struct mailbox_list_record records[count]; */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 };
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 struct mailbox_list_record {
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 /* CRC32 hash of the name */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42 uint32_t name_hash;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 uint32_t uid:31;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 /* Set when this record has been marked as deleted. It will be removed
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 permanently the next time a new record is added to this directory
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 or on the next index compression. */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 uint32_t deleted:1;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 /* Points to a NUL-terminated record name */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 uint32_t name_offset;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 /* the dir offset is stored using mail_index_uint32_to_offset()
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 since it may change while we're reading */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 uint32_t dir_offset;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 };
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 struct mailbox_list_index {
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 char *filepath;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 char separator;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 struct mail_index *mail_index;
4896
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
60 struct file_cache *file_cache;
4968
1baf9dd3fc40 Added dotlock_use_excl setting.
Timo Sirainen <tss@iki.fi>
parents: 4929
diff changeset
61 struct dotlock_settings dotlock_set;
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
62
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 int fd;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
64
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
65 void *mmap_base;
4896
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
66 const void *const_mmap_base;
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
67 size_t mmap_size;
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
68 const struct mailbox_list_index_header *hdr;
4896
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
69
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
70 unsigned int mmap_disable:1;
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71 };
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 #define MAILBOX_LIST_RECORDS(dir) \
4896
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
74 ((const struct mailbox_list_record *)(dir + 1))
3d00a9636393 Mailbox list index works now with mmap_disable=yes.
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
75 #define MAILBOX_LIST_RECORDS_MODIFIABLE(dir) \
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
76 ((struct mailbox_list_record *)(dir + 1))
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
77 #define MAILBOX_LIST_RECORD_IDX(dir, rec) \
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 ((rec) - MAILBOX_LIST_RECORDS(dir))
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80 int mailbox_list_index_set_syscall_error(struct mailbox_list_index *index,
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
81 const char *function);
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 int mailbox_list_index_dir_lookup_rec(struct mailbox_list_index *index,
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84 const struct mailbox_list_dir_record *dir,
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 const char *name,
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 const struct mailbox_list_record **rec_r);
5324
4d3294c59939 Fixed desyncing problems with mail index and mailbox list index.
Timo Sirainen <tss@iki.fi>
parents: 4968
diff changeset
87 int mailbox_list_index_get_dir(struct mailbox_list_index_view *view,
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
88 uint32_t *offset,
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
89 const struct mailbox_list_dir_record **dir_r);
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
90 int mailbox_list_index_map(struct mailbox_list_index *index);
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91
4929
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
92 int mailbox_list_index_file_create(struct mailbox_list_index *index,
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
93 uint32_t uid_validity);
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
94 void mailbox_list_index_file_close(struct mailbox_list_index *index);
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
95
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
96 int mailbox_list_index_refresh(struct mailbox_list_index *index);
791c9c8d3a02 Compress list index when its deleted space amount gets too high. Also fixed
Timo Sirainen <tss@iki.fi>
parents: 4896
diff changeset
97
6076
f1f83c90fd3d Moved mailbox_list_index_set_corrupted() to private .h file
Timo Sirainen <tss@iki.fi>
parents: 5343
diff changeset
98 int mailbox_list_index_set_corrupted(struct mailbox_list_index *index,
f1f83c90fd3d Moved mailbox_list_index_set_corrupted() to private .h file
Timo Sirainen <tss@iki.fi>
parents: 5343
diff changeset
99 const char *str);
f1f83c90fd3d Moved mailbox_list_index_set_corrupted() to private .h file
Timo Sirainen <tss@iki.fi>
parents: 5343
diff changeset
100
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 #endif