25typedef enum : uint16_t {
33typedef enum : uint64_t {
40typedef enum : uint8_t {
72 uint64_t state = hash;
73 for (
size_t index = 0U; text[index] !=
'\0'; ++index) {
74 state ^= (uint64_t)(uint8_t)text[index];
99 if (meta !=
nullptr) {
104 const char* fields[] =
108 for (
size_t i = 0U; i < (
sizeof(fields) /
sizeof(fields[0])); ++i) {
115 b[i] = (uint8_t)(h1 >> shift);
124 "urn:uuid:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%"
125 "02x%02x%02x%02x%02x",
175 if (meta->
writer[0] !=
'\0') {
180 snprintf(fragment,
sizeof(fragment),
"<dc:creator opf:role=\"aut\">%s</dc:creator>", escaped);
183 if (meta->
artist[0] !=
'\0') {
188 snprintf(fragment,
sizeof(fragment),
"<dc:creator opf:role=\"art\">%s</dc:creator>", escaped);
192 (void)snprintf(text->
creators,
sizeof(text->
creators),
"<dc:creator>mdl</dc:creator>");
215 if (meta->
summary[0] !=
'\0') {
220 "<dc:description>%s</dc:description>",
230 snprintf(text->
source,
sizeof(text->
source),
"<dc:source>%s</dc:source>", escaped);
258 (void)snprintf(raw_id,
sizeof(raw_id),
"%s", meta->
identifier);
267 const char* raw_title;
273 raw_title =
"chapter";
276 (void)snprintf(text->
title,
sizeof(text->
title),
"chapter");
322 if ((opf_need > opf_cap) || (nav_need > nav_cap)) {
328 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
329 "<package xmlns=\"http://www.idpf.org/2007/opf\" version=\"3.0\" "
330 "unique-identifier=\"bookid\"><metadata "
331 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
332 "xmlns:opf=\"http://www.idpf.org/2007/opf\">"
333 "<dc:identifier id=\"bookid\">%s</dc:identifier>"
334 "<dc:title>%s</dc:title>%s%s%s<dc:language>%s</dc:language>"
335 "<meta property=\"dcterms:modified\">%s</meta>"
336 "<meta property=\"schema:numberOfPages\">%zu</meta>"
337 "</metadata><manifest><item id=\"nav\" href=\"nav.xhtml\" "
338 "media-type=\"application/xhtml+xml\" properties=\"nav\"/>%s</manifest>"
339 "<spine page-progression-direction=\"%s\">%s</spine></package>",
351 const int nav_n = snprintf(navdoc,
353 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
354 "<html xmlns=\"http://www.w3.org/1999/xhtml\" "
355 "xmlns:epub=\"http://www.idpf.org/2007/ops\"><head><title>Contents"
356 "</title></head><body><nav epub:type=\"toc\"><ol>%s</ol></nav>"
363 (mz_zip_writer_finalize_archive(zip) != MZ_FALSE);
379 if (meta !=
nullptr) {
Package a downloaded chapter folder into a reader-openable container.
@ k_mdl_meta_id_max
Stable publication identifier max bytes.
@ k_mdl_meta_title_max
Title (series or chapter) buffer max bytes.
@ k_mdl_meta_name_max
Person name (writer/artist) buffer max bytes.
@ k_mdl_meta_date_max
ISO-8601 modified timestamp max bytes.
@ k_mdl_meta_summary_max
Summary description buffer max bytes.
@ k_mdl_meta_lang_max
BCP-47 language tag buffer max bytes.
@ k_mdl_meta_url_max
Absolute source URL max bytes, including NUL.
@ k_mdl_read_rtl
Right-to-left page progression.
void mdl_meta_init(mdl_export_meta_t *meta)
Initialise a metadata struct to empty/default values.
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.
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.
Private bounded EPUB3 writer contracts for the media downloader.
@ k_epub_base_bytes
Fixed opf/nav overhead.
ra8_err_t priv_mdl_export_validate_source_url(const char *url)
Validate an optional bounded source-attribution URL.
bool priv_mdl_export_snprintf_fit(int written, size_t cap)
Report whether an snprintf result fit its destination.
Neutralise untrusted names before they reach a filesystem or XML sink.
bool mdl_xml_escape(const char *src, char *out, size_t cap)
XML-escape src into out, failing rather than truncating.
Annotation-attribute framework macros for ra8-firmware.
#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_fail
Generic unspecified failure.
@ 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.
size_t strlen(const char *s)
Calculate string length.
Escaped and rendered EPUB publication metadata.
char description[(k_mdl_meta_summary_max *6U)+k_epub_fragment_slack]
Optional escaped <dc:description> fragment.
char modified[k_mdl_meta_date_max *6U]
Escaped modification date.
char identifier[k_mdl_meta_id_max *6U]
Escaped identifier.
char language[k_mdl_meta_lang_max *6U]
Escaped language.
char creators[(k_mdl_meta_name_max *k_epub_creator_factor)+k_epub_creator_slack]
Complete escaped <dc:creator> fragments.
char source[(k_mdl_meta_url_max *6U)+k_epub_fragment_slack]
Optional escaped <dc:source> fragment.
char title[k_mdl_meta_title_max *6U]
Escaped display title.
const char * progression
OPF page progression token.