mail-index.h revision aa38d1a0945f0bc13a225d043f53fad2eec666b1
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen /* Create index if it doesn't exist */
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen /* Open the index as fast as possible - do only minimal checks and
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen delay opening cache/log files unless they're needed. */
92c49f3005f4dff1a6f576fffa8112ef6d1cae7fTimo Sirainen /* Don't try to mmap() index files */
1d2c463d23f09f15727edae9c78b07ec6a7a27daTimo Sirainen /* Don't try to write() to mmap()ed index files. Required for the few
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen OSes that don't have unified buffer cache
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen (currently OpenBSD <= 3.5) */
9132f9df4e12ed5293c70957813aa3736444a13cTimo Sirainen /* Index file is corrupted, reopen or recreate it. */
9132f9df4e12ed5293c70957813aa3736444a13cTimo Sirainen /* No errors */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Internal error, see get_error_text() for more information. */
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen /* We ran out of available disk space. */
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen (MAIL_ANSWERED | MAIL_FLAGGED | MAIL_DELETED | MAIL_SEEN | MAIL_DRAFT)
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen /* major version is increased only when you can't have backwards
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen compatibility. minor version is increased when header size is
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen increased to contain new non-critical fields. */
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen uint32_t header_size; /* base + extended header size */
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen 1 = sizeof(uoff_t)
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen 2 = sizeof(time_t)
7a94f950fd1dcc81537acfc8adb030b5e703d722Timo Sirainen 3 = unused */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* these UIDs may not exist and may not even be unseen */
baebb412a9a5a44b1756e01cfa3b99f5d8a846b6Timo Sirainen /* We have internal and external sync offsets. External changes are
baebb412a9a5a44b1756e01cfa3b99f5d8a846b6Timo Sirainen synced into index somewhat more often, so int_offset <= ext_offset */
12c6ef6f1268ed4d5b63709bb4215c481b4f078cTimo Sirainen /* daily first UIDs that have been added to index. */
12c6ef6f1268ed4d5b63709bb4215c481b4f078cTimo Sirainen uint8_t flags; /* enum mail_flags | enum mail_index_mail_flags */
12c6ef6f1268ed4d5b63709bb4215c481b4f078cTimo Sirainen unsigned int count;
12c6ef6f1268ed4d5b63709bb4215c481b4f078cTimo Sirainen /* variable sized list of keyword indexes */
5a250816ffc4cc5db203f9410ea99b6601c7b91aTimo Sirainen /* MAIL_INDEX_SYNC_TYPE_FLAGS: */
46ec792dd4ccf6c34706c4774228301fafde6aa9Timo Sirainen /* MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD, .._REMOVE: */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstruct mail_index *mail_index_alloc(const char *dir, const char *prefix);
a05fec120ecd8c4ed6331c42100cba42adf22893Stephan Boschvoid mail_index_free(struct mail_index *index);
a05fec120ecd8c4ed6331c42100cba42adf22893Stephan Boschvoid mail_index_set_permissions(struct mail_index *index,
a05fec120ecd8c4ed6331c42100cba42adf22893Stephan Boschint mail_index_open(struct mail_index *index, enum mail_index_open_flags flags,
a05fec120ecd8c4ed6331c42100cba42adf22893Stephan Boschvoid mail_index_close(struct mail_index *index);
c12d96f12cac9af464ab2e59046bd59b0c06b4eaTimo Sirainenstruct mail_cache *mail_index_get_cache(struct mail_index *index);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Refresh index so mail_index_lookup*() will return latest values. Note that
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen immediately after this call there may already be changes, so if you need to
a05fec120ecd8c4ed6331c42100cba42adf22893Stephan Bosch rely on validity of the returned values, use some external locking for it. */
ddbdc644a15f56f4b43596f1b8c0fc196c101445Timo Sirainenint mail_index_refresh(struct mail_index *index);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen/* View can be used to look into index. Sequence numbers inside view change
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen only when you synchronize it. The view acquires required locks
d3d769026fae5d21c2d29614d3bc4579e8d79e81Timo Sirainen automatically, but you'll have to drop them manually. */
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainenstruct mail_index_view *mail_index_view_open(struct mail_index *index);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_view_close(struct mail_index_view *view);
5a9e240ebf8d0daaf029973973b52e415148070bTimo Sirainen/* Returns the index for given view. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstruct mail_index *mail_index_view_get_index(struct mail_index_view *view);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Call whenever you've done with requesting messages from view for a while. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_view_unlock(struct mail_index_view *view);
9132f9df4e12ed5293c70957813aa3736444a13cTimo Sirainen/* Returns number of mails in view. */
f059a046515f4b2b15a6c2a10a6f12f6166e39a5Timo Sirainenuint32_t mail_index_view_get_messages_count(struct mail_index_view *view);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns TRUE if we lost track of changes for some reason. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_view_is_inconsistent(struct mail_index_view *view);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Transaction has to be opened to be able to modify index. You can have
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen multiple transactions open simultaneously. Note that committed transactions
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainen won't show up until you've synchronized mailbox (mail_index_sync_begin). */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_index_transaction_begin(struct mail_index_view *view,
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainenint mail_index_transaction_commit(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_transaction_rollback(struct mail_index_transaction *t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns a view to transaction. Currently this differs from normal view only
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen in that it contains newly appended messages in transaction. The view can
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen still be used after transaction has been committed. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_index_transaction_open_updated_view(struct mail_index_transaction *t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Begin synchronizing mailbox with index file. This call locks the index
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen exclusively against other modifications. Returns 1 if ok, -1 if error.
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainen If log_file_seq is not (uint32_t)-1 and index is already synchronized up
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen to given log_file_offset, the synchronization isn't started and this
d3d769026fae5d21c2d29614d3bc4579e8d79e81Timo Sirainen function returns 0. This should be done when you wish to sync your previous
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen transaction instead of doing a full mailbox synchronization.
a117008f03ad9e2d54258b30d3fb03ffa502a448Timo Sirainen mail_index_sync_next() returns all changes from previously committed
6da2d4faed507f513c68b94bb56a13caeeb3ff4aTimo Sirainen transactions which haven't yet been committed to the actual mailbox.
6da2d4faed507f513c68b94bb56a13caeeb3ff4aTimo Sirainen They're returned in ascending order and they never overlap (if we add more
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen sync types, then they might). You must go through all of them and update
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen the mailbox accordingly.
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen None of the changes actually show up in index until after successful
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen mail_index_sync_commit().
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen Returned sequence numbers describe the mailbox state at the beginning of
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen synchronization, ie. expunges don't affect them.
c7fca6cbb32388556d9f6d8313486cc4e4a3c058Timo Sirainen You may create a new transaction for the returned view. That transaction
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen acts as "external mailbox changes" transaction. Any changes done there are
c7fca6cbb32388556d9f6d8313486cc4e4a3c058Timo Sirainen expected to describe mailbox's current state. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_sync_begin(struct mail_index *index,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t log_file_seq, uoff_t log_file_offset,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_sync_next(struct mail_index_sync_ctx *ctx,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns 1 if there's more to sync, 0 if not. */
5a9e240ebf8d0daaf029973973b52e415148070bTimo Sirainenint mail_index_sync_have_more(struct mail_index_sync_ctx *ctx);
5a9e240ebf8d0daaf029973973b52e415148070bTimo Sirainen/* Reset syncing to initial state after mail_index_sync_begin(), so you can
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen go through all the sync records again with mail_index_sync_next(). */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_sync_reset(struct mail_index_sync_ctx *ctx);
a75907609d7c410c9e17beedfafbf28b4439fa8aTimo Sirainen/* Commit synchronization by writing all changes to mail index file. */
a75907609d7c410c9e17beedfafbf28b4439fa8aTimo Sirainenint mail_index_sync_commit(struct mail_index_sync_ctx *ctx);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Rollback synchronization - none of the changes listed by sync_next() are
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen actually written to index file. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_sync_rollback(struct mail_index_sync_ctx *ctx);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Mark index file corrupted. Invalidates all views. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_mark_corrupted(struct mail_index *index);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Check and fix any found problems. If index is broken beyond repair, it's
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen marked corrupted and 0 is returned. Otherwise returns -1 if there was some
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen I/O error or 1 if everything went ok. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Synchronize changes in view. You have to go through all records, or view
1093de32efb2a231949566d4bd8aa55a8f43fb70Timo Sirainen will be marked inconsistent. Only sync_mask type records are
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen synchronized. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_view_sync_begin(struct mail_index_view *view,
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch/* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */
2aac7ca853f63b62ea79ef8eae9ded83ed6063a5Timo Sirainenint mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx,
2aac7ca853f63b62ea79ef8eae9ded83ed6063a5Timo Sirainenmail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx,
2aac7ca853f63b62ea79ef8eae9ded83ed6063a5Timo Sirainen unsigned int *count_r);
2aac7ca853f63b62ea79ef8eae9ded83ed6063a5Timo Sirainenvoid mail_index_view_sync_end(struct mail_index_view_sync_ctx *ctx);
4de2a17e0a2aed3b57a6c1057329b6a132b56ae2Timo Sirainen/* Returns the index header. */
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainenmail_index_get_header(struct mail_index_view *view);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns the given message. Returns -1 if error, 1 if ok, 0 if mail was
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen expunged but data was returned from some older index. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup(struct mail_index_view *view, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_full(struct mail_index_view *view, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_keywords(struct mail_index_view *view, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns the UID for given message. May be slightly faster than
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainen mail_index_lookup()->uid. */
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenint mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,
bdb9f7f7fbf828fb85a393bd2803167b1bb8ff0dTimo Sirainen/* Convert UID range to sequence range. If no UIDs are found, sequences are
bdb9f7f7fbf828fb85a393bd2803167b1bb8ff0dTimo Sirainen set to 0. Note that any of the returned sequences may have been expunged
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_uid_range(struct mail_index_view *view,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Find first mail with (mail->flags & flags_mask) == flags. Useful mostly for
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen taking advantage of lowwater-fields in headers. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_first(struct mail_index_view *view, enum mail_flags flags,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Append a new record to index. */
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainenvoid mail_index_append(struct mail_index_transaction *t, uint32_t uid,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Assigns UIDs for appended mails all at once. UID must have been given as 0
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen for mail_index_append(). Returns the next unused UID. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_append_assign_uids(struct mail_index_transaction *t,
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen/* Expunge record from index. Note that this doesn't affect sequence numbers
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen until transaction is committed and mailbox is synced. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_expunge(struct mail_index_transaction *t, uint32_t seq);
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen/* Update flags in index. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_update_flags(struct mail_index_transaction *t, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_update_flags_range(struct mail_index_transaction *t,
6303191abcb37164f435ccdc56e9dbddf1288851Timo Sirainen/* Lookup a keyword, returns TRUE if found, FALSE if not. If autocreate is
6303191abcb37164f435ccdc56e9dbddf1288851Timo Sirainen TRUE, the keyword is automatically created and TRUE is always returned. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_keyword_lookup(struct mail_index *index,
2f90189c6ee66a17f7bf838a8eb8a69868630fb8Timo Sirainen unsigned int *idx_r);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Return a pointer to array of NULL-terminated list of keywords. Note that
b6b7a17731a917958b6479920b3fac5ca991db6aTimo Sirainen the array contents (and thus pointers inside it) may change after calling
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen mail_index_keywords_create() or mail_index_sync_begin(). */
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainenconst array_t *mail_index_get_keywords(struct mail_index *index);
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainen/* Create a keyword list structure. It's freed automatically at the end of
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainen the transaction. */
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainenmail_index_keywords_create(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *const keywords[]);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_index_keywords_create_from_indexes(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Free the keywords. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_keywords_free(struct mail_keywords *keywords);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen/* Update keywords for given message. */
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenvoid mail_index_update_keywords(struct mail_index_transaction *t, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Update field in header. If prepend is TRUE, the header change is visible
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen before message syncing begins. */
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenvoid mail_index_update_header(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns the last error code. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenenum mail_index_error mail_index_get_last_error(struct mail_index *index);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen/* Returns the full error message for last error. This message may
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen contain paths etc. so it shouldn't be shown to users. */
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenconst char *mail_index_get_error_message(struct mail_index *index);
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainen/* Reset the error message. */
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenvoid mail_index_reset_error(struct mail_index *index);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Apply changes in MAIL_INDEX_SYNC_TYPE_FLAGS typed sync records to given
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen flags variable. */
717bb0dbaf4bd3f745669570647845e6d493bfe0Timo Sirainenvoid mail_index_sync_flags_apply(const struct mail_index_sync_rec *sync_rec,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Apply changes in MAIL_INDEX_SYNC_TYPE_KEYWORD_* typed sync records to given
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen keywords array. Returns TRUE If something was changed. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_sync_keywords_apply(const struct mail_index_sync_rec *sync_rec,
73f021723bffa0841bbdf371882b463a449f1ea9Timo Sirainen/* register index extension. name is a unique identifier for the extension.
717bb0dbaf4bd3f745669570647845e6d493bfe0Timo Sirainen returns unique identifier for the name. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenuint32_t mail_index_ext_register(struct mail_index *index, const char *name,
717bb0dbaf4bd3f745669570647845e6d493bfe0Timo Sirainen/* Get current extension sizes. Returns 1 if ok, 0 if extension doesn't exist
717bb0dbaf4bd3f745669570647845e6d493bfe0Timo Sirainenint mail_index_ext_get_size(struct mail_index_view *view, uint32_t ext_id,
717bb0dbaf4bd3f745669570647845e6d493bfe0Timo Sirainen uint32_t *hdr_size_r, uint16_t *record_size_r,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Resize existing extension data. If size is grown, the new data will be
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen zero-filled. If size is shrinked, the data is simply dropped. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_ext_resize(struct mail_index_transaction *t, uint32_t ext_id,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Reset extension records and header. Any updates for this extension which
5da4bfdce070b54ce8dfcd1bf6249798cda86bd6Timo Sirainen were issued before the writer had seen this reset are discarded. reset_id is
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainen used to figure this out, so it must be different every time. */
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainenvoid mail_index_ext_reset(struct mail_index_transaction *t, uint32_t ext_id,
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainen/* Returns extension header. */
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenint mail_index_get_header_ext(struct mail_index_view *view, uint32_t ext_id,
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenint mail_index_map_get_header_ext(struct mail_index_view *view,
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen/* Returns the wanted extension record for given message. If it doesn't exist,
cec3230c9b2a96bac1ea42c69475e8aea4b91eabTimo Sirainen *data_r is set to NULL. Return values are same as for mail_index_lookup(). */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_ext(struct mail_index_view *view, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenint mail_index_lookup_ext_full(struct mail_index_view *view, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t ext_id, struct mail_index_map **map_r,
54533aa265f5c87730022cc7576090bc51370f97Timo Sirainen const void **data_r);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Update extension header field. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_update_header_ext(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Update extension record. If old_data_r is non-NULL and the record extension
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen was already updated in this transaction, it's set to contain the data it's
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen now overwriting. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_update_ext(struct mail_index_transaction *t, uint32_t seq,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t ext_id, const void *data, void *old_data);