|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
CBT backend: walk a tar archive (unarch_tar.h) and index its pages. More...
#include <stddef.h>#include <stdint.h>#include "comic.h"#include "comic_internal.h"#include "ra8_attributes.h"#include "ra8_check.h"#include "unarch_tar.h"Go to the source code of this file.
Enumerations | |
| enum | cbt_limits_t : uint32_t { k_cbt_name_max = 256U , k_cbt_max_members = 100000U } |
| Name scratch size for the tar member walk. More... | |
Functions | |
| static ra8_err_t | internal_add_member (comic_t *c, const unarch_tar_entry_t *ent, const char *name, uint16_t nlen) |
| Index one tar member if it is a decodable page-image file. | |
| ra8_err_t | priv_comic_cbt_open (comic_t *c) |
| Open the CBT (tar) backend: walk the archive + build the page index. | |
| ra8_err_t | priv_comic_cbt_extract (comic_t *c, const comic_page_t *p, uint8_t *buf, size_t cap, size_t *got) |
| Extract one CBT page's encoded image (verbatim tar member copy). | |
Variables | |
| static const char *const | s_tag_cbt = "comic_cbt" |
| Log tag for CBT-backend diagnostics. | |
CBT backend: walk a tar archive (unarch_tar.h) and index its pages.
The tar half of the comic facade. priv_comic_cbt_open walks the tar member chain one header at a time through the clean-room streaming walker (unarch_tar_next – ustar / pax / GNU dialects, every block charged against the unified decompression-limits policy), appending each image file member to the shared page index. tar stores members verbatim, so priv_comic_cbt_extract is a bounds-revalidated literal copy – the same demand-paged model as the CBZ / CBR backends, with zero allocation.
Unlike the tolerant CBR walk (RAR archives often carry trailing junk), a malformed tar header rejects the archive: tar's block grammar leaves no legitimate reason for an undecodable header mid-chain.
Definition in file comic_cbt.c.
| enum cbt_limits_t : uint32_t |
Name scratch size for the tar member walk.
| Enumerator | |
|---|---|
| k_cbt_name_max | Longest member name indexed (bytes, incl. path). |
| k_cbt_max_members | Static upper bound on members walked. |
Definition at line 43 of file comic_cbt.c.
|
static |
Index one tar member if it is a decodable page-image file.
Skips directories, non-file members, and non-image / hidden names; otherwise appends the member. tar members are stored verbatim, so pack_size == raw_size and every page decodes.
| [in,out] | c | Comic accumulating its index. |
| [in] | ent | Decoded member from unarch_tar_next. |
| [in] | name | Member name bytes. |
| [in] | nlen | Member name length. |
| k_ra8_ok | Member indexed or intentionally skipped. |
| k_ra8_err_invalid_size | Page index / name arena is full. |
ent came from unarch_tar_next; name holds nlen bytes. c has its buffers bound. Definition at line 68 of file comic_cbt.c.
References unarch_tar_entry_t::data_off, unarch_tar_entry_t::is_file, k_ra8_ok, k_ra8_rar_method_store, priv_comic_is_page_name(), priv_comic_page_add(), and unarch_tar_entry_t::size.
Referenced by priv_comic_cbt_open().
| ra8_err_t priv_comic_cbt_extract | ( | comic_t * | c, |
| const comic_page_t * | p, | ||
| uint8_t * | buf, | ||
| size_t | cap, | ||
| size_t * | got ) |
Extract one CBT page's encoded image (verbatim tar member copy).
Streams the member's literal bytes through unarch_tar_read, which re-validates the (potentially forged) entry bounds against the archive before any copy.
| [in] | c | Comic with a bound CBT walker. |
| [in] | p | Page-index entry (its data_off / raw_size). |
| [out] | buf | Destination for the encoded image bytes. |
| [in] | cap | Capacity of buf; must be >= p->raw_size. |
| [out] | got | Receives the bytes written. |
| k_ra8_ok | Member copied into buf. |
| k_ra8_err_no_mem | cap is smaller than p->raw_size. |
| k_ra8_err_invalid_size | The member overruns the archive / short read. |
p came from this comic's CBT index. buf holds cap writable bytes. Definition at line 116 of file comic_cbt.c.
References comic_page_t::data_off, unarch_tar_entry_t::data_off, unarch_tar_entry_t::is_file, k_ra8_err_invalid_state, unarch_tar_t::live, RA8_CHECK_NULL_PTR, comic_page_t::raw_size, s_tag_cbt, unarch_tar_entry_t::size, comic_t::tar, and unarch_tar_read().
Referenced by comic_page_read().
Open the CBT (tar) backend: walk the archive + build the page index.
Iterates the tar member chain (unarch_tar_next) from offset 0, appending each image file member via priv_comic_page_add. tar stores members verbatim, so every indexed page is extractable == 1 with pack_size == raw_size. The walk (and each member's declared size) is charged against the walker's embedded decompression budget.
| [in,out] | c | Comic with c->tar bound by unarch_tar_open, kind == cbt. |
| k_ra8_ok | Archive walked; index populated. |
| k_ra8_err_invalid_size | The page index / name arena was too small. |
| k_ra8_err_decomp_* | The walk breached the decompression policy. |
| k_ra8_err_* | A tar-walk error (malformed header, ...). |
c). Definition at line 87 of file comic_cbt.c.
References internal_add_member(), k_cbt_max_members, k_cbt_name_max, k_ra8_err_invalid_state, k_ra8_err_not_found, k_ra8_err_validation_failed, k_ra8_ok, unarch_tar_t::live, unarch_tar_entry_t::name_len, unarch_tar_entry_t::next_off, RA8_CHECK_NULL_PTR, RA8_PRIV, s_tag_cbt, comic_t::tar, and unarch_tar_next().
Referenced by internal_open_detect().
|
static |
Log tag for CBT-backend diagnostics.
Definition at line 36 of file comic_cbt.c.
Referenced by priv_comic_cbt_extract(), and priv_comic_cbt_open().