25typedef enum : uint32_t {
96 if ((builder->
chapters ==
nullptr) || (builder->
nodes ==
nullptr) ||
99 (builder->
image_pool ==
nullptr) || (builder->
out ==
nullptr)) {
143 if ((profile->
book ==
nullptr) || (xhtml ==
nullptr) || (raw ==
nullptr) || (arena ==
nullptr) ||
144 (gray ==
nullptr) || (css ==
nullptr) || (xml ==
nullptr)) {
159 .xml_workspace = xml};
194 if ((container->
input ==
nullptr) || (container->
compressed ==
nullptr) ||
259 const char* directory,
262 const char* destination,
268 *temp_exists =
false;
281 return (aborted ==
k_ra8_ok) ? error : aborted;
315 if ((book !=
nullptr) && (book->
in_use != 0U)) {
352 const uint32_t expected_pages = (uint32_t)page_count;
381 const char* temp_path,
387 workspace->
used = 0U;
399 const void* blob =
nullptr;
400 uint32_t length = 0U;
409 error = source.
error;
444 const char* destination,
452 uint64_t container_length = 0U;
468 return (aborted ==
k_ra8_ok) ? error : aborted;
470 bool published =
false;
476 const char* directory,
479 const char* destination,
483 if ((storage ==
nullptr) || (directory ==
nullptr) || (names ==
nullptr) ||
484 (destination ==
nullptr) || (meta ==
nullptr) || (workspace ==
nullptr)) {
491 bool temp_exists =
false;
Flat, execute-in-place container for a build-time "compiled" e-book.
static const book_header_t * book_header(const void *base)
View the blob base as its header.
@ k_book_pixfmt_gray4
4bpp packed grayscale, 2px/byte (default; every pre-field blob).
ra8_err_t book_validate(const void *base, size_t size)
Validate that a byte buffer is a well-formed, intact .rabook blob.
ra8_err_t epub_close(epub_book_t *book)
Close a previously opened EPUB book.
ra8_err_t epub_open_streamed(const epub_stream_media_t *media, const char *path, epub_book_t *out_book)
Open an EPUB book from a seekable stream, with no whole-file residency (#151).
ra8_err_t fw_fs_unlink(const fw_fs_namespace_t *names, const char *path)
Remove one regular file; directories require fw_fs_rmdir.
@ k_fw_fs_path_cap
Largest portable path including its NUL.
void * mdl_export_workspace_take(mdl_export_workspace_t *ws, size_t bytes, size_t alignment)
Reserve aligned bytes from an exporter arena.
struct mdl_export_workspace mdl_export_workspace_t
Caller-owned bounded arena for all exporter scratch state.
ra8_err_t priv_mdl_export_epub(mdl_storage_t *storage, const char *dir, char names[][k_name_max], size_t count, mdl_export_output_t *output, const mdl_export_meta_t *meta, mdl_export_workspace_t *ws)
Package chapter pages into a valid fixed-layout EPUB3.
@ k_name_max
Maximum entry-name bytes.
ra8_err_t priv_mdl_export_output_abort(mdl_export_output_t *output)
Abort one unpublished export stage, retaining cleanup failure.
ra8_err_t priv_mdl_export_output_commit(mdl_export_output_t *output, mdl_export_workspace_t *workspace, bool *out_published)
Structurally validate and publish one completed export stage.
ra8_err_t priv_mdl_export_output_begin(mdl_export_output_t *output, mdl_storage_t *storage, const char *destination, mdl_format_t format)
Bind a validated publication transaction to one destination.
ra8_err_t priv_mdl_export_output_write_at(void *opaque, uint64_t offset, const uint8_t *bytes, uint32_t length, uint32_t *out_written)
Write one complete span at an absolute active-stage offset.
ra8_err_t priv_mdl_export_rabook(mdl_storage_t *storage, const char *directory, char names[][k_name_max], size_t count, const char *destination, const mdl_export_meta_t *meta, mdl_export_workspace_t *workspace)
Compile one page directory into a strict chunked RABOOK artifact.
mdl_rabook_profile_limit_t
Fixed production conversion profile within the 96 MiB CLI arena.
@ k_rabook_string_bytes
Interned metadata/DOM strings.
@ k_rabook_xhtml_bytes
One page XHTML member.
@ k_rabook_flat_bytes
Flat RABOOK1 output.
@ k_rabook_css_bytes
One stylesheet member.
@ k_rabook_offset_entries
RBKC offset table entries.
@ k_rabook_attr_cap
Fixed-page XHTML attributes.
@ k_rabook_chapter_cap
Builder chapter rows.
@ k_rabook_image_cap
Pages plus one external cover.
@ k_rabook_image_pool_bytes
48 gray4 1024-square rasters.
@ k_rabook_style_cap
Stylesheet descriptors.
@ k_rabook_compressed_bytes
One complete zlib stream.
@ k_rabook_node_cap
Fixed-page XHTML DOM nodes.
@ k_rabook_max_image_edge
Output raster long-edge clamp.
@ k_rabook_gray_bytes
1024-square downscale buffer.
@ k_rabook_chunk_bytes
Independent RBKC chunk size.
@ k_rabook_image_arena_bytes
One stb grayscale decode.
@ k_rabook_image_raw_bytes
One encoded image member.
@ k_rabook_page_cap
EPUB manifest-safe page count.
static ra8_err_t internal_allocate_builder(mdl_export_workspace_t *workspace, mdl_rabook_profile_t *profile)
Allocate the builder tables and resident flat-book pools.
static ra8_err_t internal_allocate_profile(mdl_export_workspace_t *workspace, mdl_rabook_profile_t *profile)
Carve the complete fixed conversion profile from caller storage.
static ra8_err_t internal_allocate_pipeline(mdl_export_workspace_t *workspace, mdl_rabook_profile_t *profile)
Allocate the streamed EPUB parser and image-conversion scratch.
static ra8_err_t internal_close_compile_sources(ra8_err_t error, epub_book_t *book, mdl_rabook_epub_source_t *source)
Close both compile-time EPUB readers, preserving the first error.
static ra8_err_t internal_write_temp_epub(mdl_storage_t *storage, const char *directory, char names[][k_name_max], size_t count, const char *destination, const mdl_export_meta_t *meta, mdl_export_workspace_t *workspace, char *temp_path, bool *temp_exists)
Produce and validate one private fixed-layout EPUB intermediate.
static ra8_err_t internal_compile_temp(mdl_storage_t *storage, const char *temp_path, size_t page_count, mdl_export_workspace_t *workspace, mdl_rabook_profile_t *profile, mdl_rabook_flat_source_t *flat)
Compile one temporary EPUB into a validated resident flat RABOOK1.
static ra8_err_t internal_allocate_container(mdl_export_workspace_t *workspace, mdl_rabook_profile_t *profile)
Allocate the independent-chunk RBKC writer workspace.
static ra8_err_t internal_check_compiled_page_count(const void *blob, size_t page_count)
Confirm the compiled flat book matches the source page count.
static ra8_err_t internal_emit_container(mdl_storage_t *storage, const char *destination, mdl_rabook_flat_source_t *flat, mdl_rabook_profile_t *profile, mdl_export_workspace_t *workspace)
Stream one flat book into a strictly validated final RBKC transaction.
Private bounded RABOOK export contracts for the media downloader.
ra8_err_t priv_mdl_rabook_temp_begin(mdl_export_output_t *output, mdl_storage_t *storage, const char *directory, const char *destination, char *path, size_t capacity)
Reserve one collision-free temporary EPUB publication path.
ra8_err_t priv_mdl_rabook_flat_read(void *opaque, uint32_t offset, uint8_t *destination, uint32_t requested, uint32_t *out_read)
Serve one exact flat-blob read to the RBKC writer.
size_t priv_mdl_rabook_epub_read(void *opaque, uint64_t offset, void *destination, size_t length)
Serve one exact random EPUB read to the streamed reader.
ra8_err_t priv_mdl_rabook_epub_close(mdl_rabook_epub_source_t *source)
Close one temporary EPUB stream.
ra8_err_t priv_mdl_rabook_epub_open(mdl_rabook_epub_source_t *source, mdl_storage_t *storage, const char *path)
Open one validated temporary EPUB as a portable random-read stream.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ 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 * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Zero-heap streaming writer for the chunked RBKC .rabook container.
ra8_err_t ra8_rabook_container_write(ra8_rabook_flat_read_fn read, void *read_ctx, uint32_t flat_len, uint32_t chunk_bytes, ra8_rabook_write_at_fn write_at, void *write_ctx, ra8_rabook_container_workspace_t *ws, uint64_t *out_len)
Stream one flat RABOOK1 blob into a chunked RBKC staging object.
End-to-end EPUB -> RABOOK1 compile pipeline (#149).
ra8_err_t rabook_compile_from_epub_to_buffer(epub_book_t *epub, const ra8_rabook_buffers_t *bufs, const ra8_rabook_pipeline_scratch_t *scr, const void **out_blob, uint32_t *out_len)
Compile an open EPUB into a RABOOK1 blob left in bufs->out, with no filesystem write.
One name="value" attribute on an element.
One spine document (a renderable chapter) plus its TOC label.
Descriptor for one transcoded image in the image pool.
A preserved CSS stylesheet and the chapter it scopes to.
uint8_t in_use
1 = open, 0 = closed.
bool is_open
Facade lifecycle guard.
fw_fs_namespace_t names
Namespace operations.
bool active
Begin succeeded.
One validated staged publication, including random ZIP backfill.
uint64_t extent
Greatest written byte edge.
mdl_storage_txn_t writer
Active storage transaction.
size_t used
Current allocation high edge.
Open portable EPUB stream retained during one compile.
uint64_t size_bytes
Immutable complete EPUB extent.
fw_fs_file_t file
Borrowed portable file handle.
ra8_err_t error
First read/seek protocol failure.
Resident flat RABOOK1 source for the chunked container writer.
uint32_t size_bytes
Complete flat blob extent.
All fixed-profile views carved from the export workspace.
epub_book_t * book
Streamed intermediate EPUB.
ra8_rabook_buffers_t builder
Flat-book builder arenas.
ra8_rabook_container_workspace_t container
RBKC writer workspace.
ra8_rabook_pipeline_scratch_t pipeline
EPUB compiler scratch.
ra8_img_arena_t image_arena
stb decode arena descriptor.
One non-reentrant downloader filesystem dependency bundle.
const fw_fs_t * fs
Injected portable filesystem.
fw_fs_transaction_t transaction
Active private filesystem stage.
Caller-owned bump arena backing a single image decode.
Caller-owned, fixed-capacity arenas the builder appends into (no heap).
uint32_t out_cap
Output capacity in bytes.
uint32_t attr_cap
Max attribute records.
uint8_t * image_pool
Image-pool byte arena.
uint32_t chapter_cap
Max chapters.
uint32_t stylesheet_cap
Max stylesheets.
char * string_pool
String-pool byte arena.
uint32_t image_cap
Max image descriptors.
uint32_t image_pool_cap
Image-pool capacity in bytes.
book_image_t * images
Image-table arena.
uint32_t string_cap
String-pool capacity in bytes.
book_stylesheet_t * stylesheets
Stylesheet-table arena.
uint32_t node_cap
Max DOM nodes.
book_node_t * nodes
Node-table arena.
uint8_t * out
Final-blob output buffer.
book_attr_t * attrs
Attribute-table arena.
book_chapter_t * chapters
Chapter-table arena.
Caller-owned transient storage for one RBKC write.
uint32_t compressor_cap
Writable bytes at compressor.
uint8_t * compressed
One complete zlib stream.
uint64_t * offsets
Payload-relative offset table.
uint32_t offset_cap
Number of uint64 entries at offsets.
uint32_t input_cap
Writable bytes at input.
uint32_t compressed_cap
Writable bytes at compressed.
uint8_t * input
One uncompressed flat chunk.
void * compressor
tdefl_compressor storage, 8-byte aligned.
Caller-owned temporary buffers the pipeline stage needs.
Caller-owned storage for one parser invocation.