ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_rar.h
Go to the documentation of this file.
1
48#pragma once
49
50#include <stddef.h>
51#include <stdint.h>
52
53#include "ra8_err.h"
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
68
88typedef size_t (*ra8_rar_read_fn)(void* ctx, uint64_t offset, void* buf, size_t len);
89
97typedef enum : uint8_t {
102
115
129
151
169typedef struct {
170 uint64_t data_off;
171 uint64_t pack_size;
172 uint64_t unp_size;
173 uint64_t next_off;
174 uint16_t name_len;
175 uint8_t method;
176 uint8_t is_file;
177 uint8_t is_dir;
179
208[[nodiscard]] ra8_err_t
209ra8_rar_open(ra8_rar_t* rar, ra8_rar_read_fn read, void* ctx, uint64_t size);
210
244[[nodiscard]] ra8_err_t ra8_rar_next(const ra8_rar_t* rar,
245 uint64_t off,
246 char* name_buf,
247 uint16_t name_cap,
248 ra8_rar_entry_t* out);
249
283[[nodiscard]] ra8_err_t ra8_rar_extract_stored(const ra8_rar_t* rar,
284 const ra8_rar_entry_t* ent,
285 uint8_t* buf,
286 size_t cap,
287 size_t* got);
288
326[[nodiscard]] ra8_err_t ra8_rar_extract(const ra8_rar_t* rar,
327 const ra8_rar_entry_t* ent,
328 uint8_t* buf,
329 size_t cap,
331 size_t* got);
332
333#ifdef __cplusplus
334}
335#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_rar_limits_t
Fixed sizes and grammar constants for the RAR block walk.
Definition ra8_rar.h:123
@ k_ra8_rar_vint_max
Max bytes in one RAR5 vint (64-bit value).
Definition ra8_rar.h:127
@ k_ra8_rar_sig5_len
"Rar!\x1A\x07\x01\x00" signature length (RAR5).
Definition ra8_rar.h:125
@ k_ra8_rar_sig4_len
"Rar!\x1A\x07\x00" marker length (RAR4).
Definition ra8_rar.h:124
@ k_ra8_rar_hdr_scratch
Per-block header read window (fixed fields).
Definition ra8_rar.h:126
ra8_err_t ra8_rar_next(const ra8_rar_t *rar, uint64_t off, char *name_buf, uint16_t name_cap, ra8_rar_entry_t *out)
Decode the block header at off and advance to the next block.
Definition ra8_rar.c:682
ra8_err_t ra8_rar_open(ra8_rar_t *rar, ra8_rar_read_fn read, void *ctx, uint64_t size)
Detect a RAR archive's generation and locate its first block.
Definition ra8_rar.c:659
size_t(* ra8_rar_read_fn)(void *ctx, uint64_t offset, void *buf, size_t len)
Seek+read backing over the RAR container bytes.
Definition ra8_rar.h:88
ra8_rar_version_t
Which RAR container generation an archive uses.
Definition ra8_rar.h:97
@ k_ra8_rar_ver_none
Not a recognised RAR archive.
Definition ra8_rar.h:98
@ k_ra8_rar_ver_4
RAR 1.5-4.x block format ("RAR4").
Definition ra8_rar.h:99
@ k_ra8_rar_ver_5
RAR 5.0 block format ("RAR5").
Definition ra8_rar.h:100
ra8_err_t ra8_rar_extract(const ra8_rar_t *rar, const ra8_rar_entry_t *ent, uint8_t *buf, size_t cap, ra8_rar5_state_t *st, size_t *got)
Extract any file member – STORE by copy, RAR5-compressed by decode.
Definition ra8_rar.c:840
ra8_err_t ra8_rar_extract_stored(const ra8_rar_t *rar, const ra8_rar_entry_t *ent, uint8_t *buf, size_t cap, size_t *got)
Extract a STORE-method member's data into the caller buffer.
Definition ra8_rar.c:785
ra8_rar_method_t
Normalised compression method of a file member.
Definition ra8_rar.h:111
@ k_ra8_rar_method_compressed
Packed with a RAR compressor (not decoded).
Definition ra8_rar.h:113
@ k_ra8_rar_method_store
Uncompressed: data area is the file bytes.
Definition ra8_rar.h:112
Caller-owned zero-heap scratch for one ra8_rar5_decompress call.
One decoded RAR block: a file member, a directory, or a skipped block.
Definition ra8_rar.h:169
uint8_t method
ra8_rar_method_t (normalised; 0 = store).
Definition ra8_rar.h:175
uint8_t is_file
1 if this block is a file member header.
Definition ra8_rar.h:176
uint64_t unp_size
Unpacked length, bytes.
Definition ra8_rar.h:172
uint64_t data_off
Absolute offset of the member's data area.
Definition ra8_rar.h:170
uint64_t next_off
Absolute offset of the next block header.
Definition ra8_rar.h:173
uint16_t name_len
Name bytes copied into the caller buffer (clamped).
Definition ra8_rar.h:174
uint8_t is_dir
1 if the file member is a directory entry.
Definition ra8_rar.h:177
uint64_t pack_size
Packed (stored/compressed) data length, bytes.
Definition ra8_rar.h:171
One open RAR archive: the backing plus the detected generation.
Definition ra8_rar.h:144
uint64_t size
Container length in bytes.
Definition ra8_rar.h:147
uint64_t first_off
Offset of the first block past the signature.
Definition ra8_rar.h:148
void * ctx
Context for read.
Definition ra8_rar.h:146
ra8_rar_version_t version
Detected container generation.
Definition ra8_rar.h:149
ra8_rar_read_fn read
Byte reader over the container file.
Definition ra8_rar.h:145