ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_rabook_pipeline_fs.c File Reference

Optional ra8_fs publication wrapper for the RABOOK pipeline. More...

#include <stdint.h>
#include "ra8_check.h"
#include "ra8_fs.h"
#include "ra8_rabook_pipeline.h"
#include "ra8_rabook_pipeline_internal.h"
Include dependency graph for ra8_rabook_pipeline_fs.c:

Go to the source code of this file.

Functions

ra8_err_t rabook_compile_from_epub (epub_book_t *epub, const ra8_rabook_buffers_t *buffers, const ra8_rabook_pipeline_scratch_t *scratch, ra8_fs_mount_t *mount, const char *out_path)
 Compile an open EPUB into a RABOOK1 blob written to out_path on the SD filesystem.

Detailed Description

Optional ra8_fs publication wrapper for the RABOOK pipeline.

Keeps filesystem linkage out of the reusable caller-buffer compiler while preserving the original public convenience entry point.

[Ring 4 / EPUB Compiler] {World: NS}

Since
0.1.0

Definition in file ra8_rabook_pipeline_fs.c.

Function Documentation

◆ rabook_compile_from_epub()

ra8_err_t rabook_compile_from_epub ( epub_book_t * epub,
const ra8_rabook_buffers_t * buffers,
const ra8_rabook_pipeline_scratch_t * scratch,
ra8_fs_mount_t * mount,
const char * out_path )

Compile an open EPUB into a RABOOK1 blob written to out_path on the SD filesystem.

Full pipeline, in order:

The stage order mirrors the desktop epub_compile.py so the emitted blob is byte-identical: stylesheets, then images (cover), then chapters, then metadata is interned last.

  1. Initialise the builder context via rabook_compile_init.
  2. For each text/css manifest item (OPF order): load it into scratch->css and add it via ra8_rabook_add_stylesheet.
  3. If a cover image is present: extract raw bytes, decode to 8-bit grey with stb_image (using scratch->img_arena), downscale to at most the caller's opt-in max_image_edge clamp (source resolution when the field is 0, the default) on the longer edge, encode to 4-bpp, and add via ra8_rabook_add_image.
  4. For each spine chapter (0..chapter_count): extract the raw XHTML into scratch->xhtml, look up the matching TOC entry for a title, and call ra8_rabook_xml_parse_chapter.
  5. Read Dublin Core metadata from epub and call ra8_rabook_set_metadata (interned after the chapters).
  6. Finalise the blob via ra8_rabook_finalize.
  7. Write the blob to out_path via ra8_fs_write_file.
Parameters
[in,out]epubOpen book (in_use == 1); chapters are extracted in-place from the ZIP.
[in]buffersBuilder arenas (all non-NULL, sized for the book).
[in]scratchScratch buffers for XHTML load + image decode + gray.
[in,out]mountMounted filesystem volume to write out_path onto.
[in]out_pathFilesystem path of the output .rabook file.
Returns
Error code.
Return values
k_ra8_okBook compiled and written to out_path.
k_ra8_err_null_ptrAny required pointer is NULL.
k_ra8_err_no_memAn arena overflowed, a scratch buffer was too small, or a present cover failed to transcode.
k_ra8_err_not_foundA chapter ZIP entry referenced by the spine is missing.
k_ra8_err_invalid_sizeThe laid-out blob exceeds the output arena (propagated from ra8_rabook_finalize).
Returns
Any other error code is propagated unchanged from the EPUB reader (epub_get_metadata / epub_load_chapter / ...) or from the filesystem write (ra8_fs_write_file).
Precondition
epub->in_use == 1.
All arenas and scratch buffers are non-NULL with valid capacities.
Postcondition
On k_ra8_ok, out_path contains a valid RABOOK1 blob.
On failure, partial output may exist at out_path.
Note
Not thread-safe.
Since
Version 0.1.0

Definition at line 21 of file ra8_rabook_pipeline_fs.c.

References k_ra8_ok, priv_rabook_pipeline_check_common(), RA8_CHECK_NULL_PTR, ra8_fs_write_file(), and rabook_compile_from_epub_to_buffer().

Referenced by rabook_import_compile_adapter().