|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Private bounded EPUB3 writer contracts for the media downloader. More...
Go to the source code of this file.
Enumerations | |
| enum | mdl_epub_size_t : uint32_t { k_epub_name_esc_max = 1536U , k_epub_frag_max = 2048U , k_epub_xhtml_max = 2048U , k_epub_entry_max = 320U , k_epub_base_bytes = 4096U , k_epub_per_page_bytes = 2048U , k_epub_workspace_cap = k_epub_base_bytes + (k_max_pages * k_epub_per_page_bytes) } |
| EPUB string-buffer sizing (grows with the page count). More... | |
Functions | |
| bool | priv_mdl_epub_str_cat (char *dst, size_t cap, const char *text) |
| Append text to NUL-terminated dst; report whether it fully fit. | |
| bool | priv_mdl_epub_add_str (mz_zip_archive *zip, const char *name, const char *body) |
| Add an in-memory string as a stored ZIP entry. | |
| ra8_err_t | priv_mdl_epub_add_meta (mz_zip_archive *zip, const char *mani, const char *spine, const char *nav, size_t page_count, const mdl_export_meta_t *meta, char *opf, size_t opf_buf_cap, char *navdoc, size_t nav_buf_cap) |
| Build EPUB package metadata and finalize the archive. | |
Private bounded EPUB3 writer contracts for the media downloader.
Separates fixed-layout page and ZIP assembly from the package metadata writer, and fixes the bounded XML accumulator sizing that both translation units budget against.
[Ring 4 / Domain] {World: NS}
Definition in file mdl_export_epub_internal.h.
| enum mdl_epub_size_t : uint32_t |
EPUB string-buffer sizing (grows with the page count).
Sized for the WORST case, not the typical page_NNN.jpg: a page filename may be up to k_name_max bytes and, XML-escaped, expand 6x (a name of all "). That escaped name is embedded once in the page's manifest fragment and once in its xhtml document, so both the fragment buffer and the per-page accumulator budget must exceed the fixed template text plus k_epub_name_esc_max. Undersizing here does not truncate silently – priv_mdl_epub_str_cat and priv_mdl_export_snprintf_fit report it and the export fails – but correct sizing is what lets a legitimate long-name chapter package rather than error.
Definition at line 35 of file mdl_export_epub_internal.h.
| ra8_err_t priv_mdl_epub_add_meta | ( | mz_zip_archive * | zip, |
| const char * | mani, | ||
| const char * | spine, | ||
| const char * | nav, | ||
| size_t | page_count, | ||
| const mdl_export_meta_t * | meta, | ||
| char * | opf, | ||
| size_t | opf_buf_cap, | ||
| char * | navdoc, | ||
| size_t | nav_buf_cap ) |
Build EPUB package metadata and finalize the archive.
Escapes deterministic metadata, composes bounded OPF/navigation documents, adds them to the ZIP, and writes the central directory.
| [in,out] | zip | Initialized EPUB ZIP writer. |
| [in] | mani | Complete manifest fragments. |
| [in] | spine | Complete spine fragments. |
| [in] | nav | Complete navigation fragments. |
| [in] | page_count | Logical reading-order page count. |
| [in] | meta | Metadata to encode, or NULL. |
| [out] | opf | Caller workspace for content.opf. |
| [in] | opf_buf_cap | Capacity of opf. |
| [out] | navdoc | Caller workspace for nav.xhtml. |
| [in] | nav_buf_cap | Capacity of navdoc. |
| k_ra8_ok | Both documents were added and ZIP finalized. |
| k_ra8_err_invalid_size | Required bounded XML storage is insufficient. |
| k_ra8_fail | Formatting, member addition, or finalization failed. |
zip is initialized. Definition at line 367 of file mdl_export_epub_meta.c.
References internal_epub_prepare_text(), internal_epub_render_meta(), k_ra8_ok, mdl_meta_init(), priv_mdl_export_validate_source_url(), RA8_PRIV, and mdl_export_meta_t::source_url.
Referenced by priv_mdl_export_epub().
| bool priv_mdl_epub_add_str | ( | mz_zip_archive * | zip, |
| const char * | name, | ||
| const char * | body ) |
Add an in-memory string as a stored ZIP entry.
Passes the complete string length to miniz without compression.
| [in,out] | zip | Initialized ZIP writer. |
| [in] | name | Safe NUL-terminated member name. |
| [in] | body | NUL-terminated member body. |
| true | The entry was added. |
| false | The ZIP writer rejected it. |
zip remains initialized for writing. Definition at line 179 of file mdl_export_epub.c.
References k_ra8_ok, priv_mdl_export_zip_add_memory(), RA8_PRIV, and strlen().
Referenced by internal_epub_render_meta(), internal_epub_write_page_xhtml(), and priv_mdl_export_epub().
| bool priv_mdl_epub_str_cat | ( | char * | dst, |
| size_t | cap, | ||
| const char * | text ) |
Append text to NUL-terminated dst; report whether it fully fit.
Never truncates: if the append (plus its NUL) would not fit in cap it leaves dst unchanged and returns false, so the caller can fail loudly rather than emit a manifest cut off mid-element.
text was appended, false if it would overrun. | [in,out] | dst | Existing NUL-terminated accumulator. |
| [in] | cap | Total writable capacity of dst. |
| [in] | text | NUL-terminated text to append. |
| true | The complete text and terminator fit. |
| false | Capacity is insufficient and dst is unchanged. |
dst and text are non-NULL and do not overlap. dst is NUL-terminated within cap. Definition at line 168 of file mdl_export_epub.c.
References memcpy(), RA8_PRIV, and strlen().
Referenced by internal_epub_add_external_cover(), internal_epub_append_frags(), and internal_epub_prepare_creators().