48typedef enum : uint16_t {
86 uint32_t xz_scratch_len,
121 uintptr_t arena_address = 0U;
122 static_assert(
sizeof(arena_address) ==
sizeof(arena),
123 "uintptr_t must preserve pointer representation");
124 (void)
memcpy((
void*)&arena_address, (
const void*)&arena,
sizeof(arena_address));
173 void*
const header_slot = arena;
175 memory->
base = payload;
176 memory->
len = inner_len;
201 uint32_t xz_scratch_len)
204 static const char*
const s_tag_wrap =
"comic_wrap";
212 const size_t got = read(ctx, 0U, sig,
sizeof(sig));
215 if (!is_gzip && !is_xz) {
217 return comic_open(c, read, ctx, size, pages, page_cap, names, names_cap);
224 size_t inner_len = 0U;
Unified demand-paged reader for comic-book archives – CBZ (ZIP) and CBR (RAR).
@ k_comic_wrap_align
Required unwrap-arena alignment, bytes.
size_t(* comic_read_fn)(void *ctx, uint64_t offset, void *buf, size_t len)
Seek+read backing over the comic-archive bytes.
ra8_err_t comic_open(comic_t *c, comic_read_fn read, void *ctx, uint64_t size, comic_page_t *pages, uint32_t page_cap, char *names, uint32_t names_cap)
Open a comic archive (CBZ or CBR) and build its sorted page index.
@ k_comic_magic_len
Bytes read to detect the container magic.
Cross-TU seams between the comic facade and its CBZ / CBR backends.
static ra8_err_t internal_unwrap(comic_read_fn read, void *ctx, uint64_t size, bool is_gzip, uint8_t *payload, size_t payload_cap, void *xz_scratch, uint32_t xz_scratch_len, size_t *out_len)
Decode the gzip / XZ wrapper into the arena's payload region.
ra8_err_t comic_open_wrapped(comic_t *c, comic_read_fn read, void *ctx, uint64_t size, comic_page_t *pages, uint32_t page_cap, char *names, uint32_t names_cap, uint8_t *arena, size_t arena_cap, void *xz_scratch, uint32_t xz_scratch_len)
Open a comic that may be gzip- or XZ-wrapped (.cbt.gz, .tar.xz).
static bool internal_arena_valid(uint8_t *arena, size_t arena_cap)
Check wrapper-arena alignment and payload capacity.
wrap_dims_t
Arena layout constants for the wrapped open.
@ k_wrap_hdr_bytes
Descriptor slot at the arena start (aligned sizeof).
static ra8_err_t internal_open_unwrapped(comic_t *c, uint8_t *payload, size_t inner_len, comic_page_t *pages, uint32_t page_cap, char *names, uint32_t names_cap, uint8_t *arena)
Reject nested wrappers and open the decoded inner comic.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_decomp_depth
Container nesting-depth cap breached (ra8_decomp_limits_t).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
One entry in the resident, sorted page index.
One open comic archive: backing, kind, page index, and backend state.
Bounded flat-memory backing for unarch_read_fn.
const uint8_t * base
First readable byte of the flat view.
size_t len
Readable length in bytes.
Clean-room gzip member decoder (RFC 1952) over the miniz DEFLATE core.
ra8_err_t unarch_gzip_unwrap(unarch_read_fn read, void *ctx, uint64_t size, uint8_t *out, size_t out_cap, const ra8_decomp_limits_t *limits, size_t *out_len)
Decode one whole gzip member from a read seam into a caller arena.
bool unarch_gzip_magic(const uint8_t *sig, size_t sig_len)
Whether sig begins with the gzip member magic (1F 8B).
Shared seek+read seam and flat-memory backing for the unarchivers.
size_t unarch_mem_read(void *ctx, uint64_t offset, void *buf, size_t len)
unarch_read_fn over a flat unarch_mem_t view.
Bounded, fail-closed XZ/LZMA2 decoding over the vendored xz-embedded.
bool unarch_xz_magic(const uint8_t *sig, size_t sig_len)
Whether sig begins with the XZ stream header magic.
ra8_err_t unarch_xz_unwrap(unarch_read_fn read, void *ctx, uint64_t size, uint8_t *out, size_t out_cap, void *scratch, uint32_t scratch_len, const ra8_decomp_limits_t *limits, size_t *out_len)
Decode one whole XZ stream from a read seam into a caller arena.