diff options
Diffstat (limited to 'firmware/include/inflate.h')
-rw-r--r-- | firmware/include/inflate.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/include/inflate.h b/firmware/include/inflate.h index b56ccf181a..1fce186f34 100644 --- a/firmware/include/inflate.h +++ b/firmware/include/inflate.h @@ -23,6 +23,7 @@ #define _INFLATE_H_ #include <stdint.h> +#include <stddef.h> enum { INFLATE_RAW, @@ -43,4 +44,27 @@ extern const uint32_t inflate_align; // see above enum for possible options. int inflate(struct inflate* it, int st, inflate_reader read, void* rctx, inflate_writer write, void* wctx); +struct inflate_bufferctx { + // initialize this with your input/output buffer. + // the pointer is updated as data is read or written. + void* buf; + + // buffer end marker (= buf + buf_size). + void* end; +}; + +// reader and writer for using an in-memory buffer. +// Use 'inflate_bufferctx' as the context argument. +uint32_t inflate_buffer_reader(void* block, uint32_t block_size, void* ctx); +uint32_t inflate_buffer_writer(const void* block, uint32_t block_size, void* ctx); + +// dummy writer used if you just want to figure out how big the decompressed +// data will be. It does not actually write any data. Example usage: +// +// size_t size = 0; +// inflate(it, st, read, rctx, inflate_getsize_writer, &size); +// +// Now 'size' will be the size of the decompressed data (assuming no errors). +uint32_t inflate_getsize_writer(const void* block, uint32_t block_size, void* ctx); + #endif |