a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen /* unique index number for the string */
a914bff43644dd9b3977244203839ca74161e40cTimo SirainenARRAY_DEFINE_TYPE(mail_index_strmap_rec, struct mail_index_strmap_rec);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen/* Returns 1 if matches, 0 if not, -1 if one of the records is expunged and
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen the result can't be determined */
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenmail_index_strmap_rec_cmp_t(const struct mail_index_strmap_rec *rec1,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen/* called when string indexes are renumbered. idx_map[old_idx] = new_idx.
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen if new_idx is 0, the record was expunged. As a special case if count=0,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen the strmap was reset. */
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainentypedef void mail_index_strmap_remap_t(const uint32_t *idx_map,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenmail_index_strmap_init(struct mail_index *index, const char *suffix);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenvoid mail_index_strmap_deinit(struct mail_index_strmap **strmap);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen/* Returns strmap records and hash that can be used for read-only access.
19557f192d37cd54a1a090a8a26d9d47265e4413Aki Tuomi The records array always terminates with a record containing zeros (but it's
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen not counted in the array count). */
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenmail_index_strmap_view_open(struct mail_index_strmap *strmap,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen const ARRAY_TYPE(mail_index_strmap_rec) **recs_r,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenvoid mail_index_strmap_view_close(struct mail_index_strmap_view **view);
f24202d1a342ac63fb8c28e6fa74e16d37f29ca3Timo Sirainenvoid mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen/* Return the highest used string index. */
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenuint32_t mail_index_strmap_view_get_highest_idx(struct mail_index_strmap_view *view);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen/* Synchronize strmap: Caller adds missing entries, expunged messages may be
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen removed internally and the changes are written to disk. Note that the strmap
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen recs/hash shouldn't be used until _sync_commit() is called, because the
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen string indexes may be renumbered if another process had already written the
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen same changes as us. */
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenmail_index_strmap_view_sync_init(struct mail_index_strmap_view *view,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenvoid mail_index_strmap_view_sync_add(struct mail_index_strmap_view_sync *sync,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainen const char *key);
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenvoid mail_index_strmap_view_sync_add_unique(struct mail_index_strmap_view_sync *sync,
a914bff43644dd9b3977244203839ca74161e40cTimo Sirainenvoid mail_index_strmap_view_sync_commit(struct mail_index_strmap_view_sync **sync);