cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenstruct fts_expunge_log *fts_expunge_log_init(const char *path);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenvoid fts_expunge_log_deinit(struct fts_expunge_log **log);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenfts_expunge_log_append_begin(struct fts_expunge_log *log);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenvoid fts_expunge_log_append_next(struct fts_expunge_log_append_ctx *ctx,
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmodyvoid fts_expunge_log_append_range(struct fts_expunge_log_append_ctx *ctx,
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmodyvoid fts_expunge_log_append_record(struct fts_expunge_log_append_ctx *ctx,
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmody const struct fts_expunge_log_read_record *record);
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody/* In-memory flattened structures may have records removed from them,
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody file-backed ones may not. Non-existence of UIDs is not an error,
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody non-existence of mailbox GUID causes an error return of 0. */
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmodyint fts_expunge_log_append_remove(struct fts_expunge_log_append_ctx *ctx,
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody const struct fts_expunge_log_read_record *record);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenint fts_expunge_log_append_commit(struct fts_expunge_log_append_ctx **ctx);
2442c230b6c95b20d26ead752f9de1cb40544a53Phil Carmody/* Do not commit non-backed structures, abort them after use. */
2442c230b6c95b20d26ead752f9de1cb40544a53Phil Carmodyint fts_expunge_log_append_abort(struct fts_expunge_log_append_ctx **ctx);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenint fts_expunge_log_uid_count(struct fts_expunge_log *log,
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainen unsigned int *expunges_r);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenfts_expunge_log_read_begin(struct fts_expunge_log *log);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenfts_expunge_log_read_next(struct fts_expunge_log_read_ctx *ctx);
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainen/* Returns 1 if all ok, 0 if there was corruption, -1 if I/O error.
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainen If end() is called before reading all records, the log isn't unlinked. */
cc2954ad6d8ba0509b870d773ba4b6b16353763cTimo Sirainenint fts_expunge_log_read_end(struct fts_expunge_log_read_ctx **ctx);
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmody/* Read an entire log file, and flatten it into one hash of arrays.
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmody The struct it returns cannot be written, as it has no backing store */
8d4428cee277a9a84450a8c6771f7a4dc68638cfPhil Carmody struct fts_expunge_log_append_ctx **flattened_r);
5433d56d338db3948bf7bc22ef1daaba147dbb5dPhil Carmodybool fts_expunge_log_contains(const struct fts_expunge_log_append_ctx *ctx,
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody/* Modify in-place a flattened log. If non-existent mailbox GUIDs are
ea125b1c394cb6a281c6120f5396faa11fcb268bPhil Carmody encountered, a warning will be logged. */
b22dcc3c0c84919fe500cf877d8dfd9bddbef76fPhil Carmodyint fts_expunge_log_subtract(struct fts_expunge_log_append_ctx *from,
b22dcc3c0c84919fe500cf877d8dfd9bddbef76fPhil Carmody/* Write a modified flattened log as a new file. */
b22dcc3c0c84919fe500cf877d8dfd9bddbef76fPhil Carmodyint fts_expunge_log_flat_write(const struct fts_expunge_log_append_ctx *flattened,
b22dcc3c0c84919fe500cf877d8dfd9bddbef76fPhil Carmody const char *path);