mail-index.h revision 7c424aa51c956c628e3512055841aa2f9eef4833
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync /* Rebuild flag is set while index is being rebuilt or when
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync some error is noticed in the index file. If this flag is set,
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync the index shouldn't be used before rebuilding it. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* separate from above, but in same bitmask */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync (((field) & (DATA_FIELD_BODY | DATA_FIELD_BODYSTRUCTURE | \
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* If binary flags are set, it's not checked whether mail is
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync missing CRs. So this flag may be set as an optimization for
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync regular non-binary mails as well if it's known that it contains
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync valid CR+LF line breaks. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Currently this means with mbox format that message flags have
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync been changed in index, but not written into mbox file yet. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Mailbox is locked, will abort in secs_left */
5a2e131a1a9fb4c80eb1ca75668b54428424083cvboxsync /* Mailbox lock looks stale, will override in secs_left */
5a2e131a1a9fb4c80eb1ca75668b54428424083cvboxsync /* Index is locked, will abort in secs_left */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* No errors */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Internal error, see get_error_text() for more information. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Index is now in inconsistent state with the previous known state,
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync meaning that the message IDs etc. may have changed - only way to
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync recover this would be to fully close the mailbox and reopen it.
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync With IMAP this would mean a forced disconnection since we can't do
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync forced CLOSE. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* We ran out of available disk space. */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Mail index locking timeouted */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* Mailbox locking timeouted */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsynctypedef void mail_lock_notify_callback_t(enum mail_lock_notify_type notify_type,
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync /* 0 = version
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync 2 = sizeof(unsigned int),
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync 3 = sizeof(time_t),
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync 4 = sizeof(uoff_t),
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync 5 = MEM_ALIGN_SIZE */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync unsigned int indexid;
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync unsigned int sync_id; /* re-mmap() when changed, required only
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync if file size is changed */
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync unsigned int flags;
46ba5059f2c696c77edfa9d3dc3d018be2ac6952vboxsync unsigned int cache_fields;
c02305690d8da93fff98b226ed11b78f69818f5dvboxsync unsigned int uid_validity;
de15f08344cc532a6e75d2d8d99ae7ed461cb810vboxsync unsigned int next_uid;
a5dc49f41d7d9497f8c5d7daade92867636a090bvboxsync /* these UIDs may not exist and may not even be unseen */
a7a663caa646c45104af01923df3d33f90d97886vboxsync unsigned int indexid;
395d92a7732aad3c0b9baecedfabba5113b84485vboxsync unsigned int uid;
395d92a7732aad3c0b9baecedfabba5113b84485vboxsync unsigned int index_flags; /* enum mail_index_mail_flag */
395d92a7732aad3c0b9baecedfabba5113b84485vboxsync unsigned int data_fields; /* enum mail_data_field */
a7a663caa646c45104af01923df3d33f90d97886vboxsync unsigned int data_size; /* including this header */
206d5dc9a25e44ee35fd2a1abf4033ee004236cavboxsync (sizeof(struct mail_index_data_record) - MEM_ALIGN_SIZE)
c02305690d8da93fff98b226ed11b78f69818f5dvboxsync /* If fast is TRUE, compressing and cache updates are not performed.
a7a663caa646c45104af01923df3d33f90d97886vboxsync Note that opening same index twice in the same process is a bad
a7a663caa646c45104af01923df3d33f90d97886vboxsync idea since they share the same file locks. As soon one of the
c02305690d8da93fff98b226ed11b78f69818f5dvboxsync indexes is closed, the locks in second index are dropped which
c02305690d8da93fff98b226ed11b78f69818f5dvboxsync especially hurts modify log since it keeps locks all the time. */
a7a663caa646c45104af01923df3d33f90d97886vboxsync int (*open)(struct mail_index *index, int update_recent, int fast);
5e1277c8dc1d5200d4c8721dfd05fc04ddd4f741vboxsync /* Free index from memory. */
a7a663caa646c45104af01923df3d33f90d97886vboxsync /* Lock/unlock index. May block. Note that unlocking must not
5e1277c8dc1d5200d4c8721dfd05fc04ddd4f741vboxsync reset error from get_last_error() as unlocking can be done as
5e1277c8dc1d5200d4c8721dfd05fc04ddd4f741vboxsync a cleanup after some other function failed. Index is always
a7a663caa646c45104af01923df3d33f90d97886vboxsync mmap()ed after set_lock() succeeds.
5e1277c8dc1d5200d4c8721dfd05fc04ddd4f741vboxsync Trying to change a shared lock into exclusive lock is a fatal
5e1277c8dc1d5200d4c8721dfd05fc04ddd4f741vboxsync error, since it may create a deadlock. Even though operating
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync system should detect it and fail, it's not a good idea to even
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync let it happen. Better ways to do this would be to a) mark the
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync data to be updated later, b) use try_lock() if the update is
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync preferred but not required, c) unlock + lock again, but make
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync sure that won't create race conditions. */
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync /* Try locking the index. Returns TRUE if the lock was got and
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync FALSE if lock isn't possible to get currently or some other error
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync occured. Never blocks. */
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync /* If we have to wait for the lock, the given lock notify function
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync is called once in a while. */
ea2a3d970d6ff3c9c7c46066041dffb29185be8evboxsync void (*set_lock_notify_callback)(struct mail_index *index,
4a5bd21592a01e05ffecea23584c4e8f0a36f6acvboxsync /* Rebuild the whole index. Note that this changes the indexid
unsigned int seq);
unsigned int first_uid,
unsigned int last_uid,
unsigned int *seq_r);
int external_change);
struct mail_index_update *
unsigned int indexid;
unsigned int sync_id;
unsigned int excl_lock_counter;
int mbox_fd;
unsigned int mbox_lock_counter;
unsigned int mbox_sync_counter;
void *mmap_base;
unsigned int first_recent_uid;
void *lock_notify_context;
unsigned int set_flags;
#ifdef DEV_T_STRUCT
# define MAIL_INDEX_PRIVATE_FILL 0
#define MAIL_INDEX_PRIVATE_FILL \
void *context);
unsigned int seq);
struct mail_index_record *
int external_change);
struct mail_index_update *
void *context);
((struct mail_index_record *) \
((struct mail_index_record *) \
sizeof(struct mail_index_record))
sizeof(struct mail_index_record))
#define INDEX_FILE_MIN_SIZE \
(sizeof(struct mail_index_header) + \