/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __EROFS_FS_COMPRESS_H
#define __EROFS_FS_COMPRESS_H

#include "internal.h"

struct z_erofs_decompress_req {
	struct erofs_sb_info *sbi;
	const struct erofs_map_blocks *map;
	const void *in;
	size_t inputsize;
	void *out;
	size_t outputsize;
	bool partial_decoding;
};

struct z_erofs_decompressor {
	/* Callbacks return zero or a positive FreeBSD errno. */
	int (*config)(struct erofs_sb_info *, const struct erofs_super_block *,
	    const void *, size_t);
	int (*decompress)(const struct z_erofs_decompress_req *);
	bool supports_subextent;
	const char *name;
};

bool z_erofs_decompress_supports_subextent(
    const struct erofs_map_blocks *map);
int z_erofs_lz4_decompress(const struct z_erofs_decompress_req *rq);
extern const struct z_erofs_decompressor z_erofs_lzma_decomp;
extern const struct z_erofs_decompressor z_erofs_deflate_decomp;
extern const struct z_erofs_decompressor z_erofs_zstd_decomp;

#endif /* __EROFS_FS_COMPRESS_H */
