64#if !defined(__STDC_IEC_559__) && !defined(__STDC_IEC_60559_BFP__) && !defined(__clang__) && \
66#error "mdl state v3 requires IEC 60559 binary floating-point"
69static_assert(
sizeof(double) == 8U,
"mdl state v3 requires binary64 double");
70static_assert(FLT_RADIX == 2,
"mdl state v3 requires radix-2 floating-point");
72typedef enum : int16_t {
79 "mdl state requires 53-bit binary64 precision");
81 "mdl state requires binary64 exponent range");
83 "mdl state requires binary64 exponent range");
92typedef enum : uint16_t {
108typedef enum : uint8_t {
114typedef enum : uint32_t {
247 const char* site_name,
248 const char* site_host,
249 const char* config_path);
285 const char* cover_url,
286 const char* cover_path,
287 const char* language,
382 bool* out_published);
608 uint64_t content_hash,
609 const char* rel_path,
611 const char* last_modified,
613 uint16_t response_status);
636 uint16_t response_status);
Per-site descriptor loaded from a flat key=value config file.
@ k_mdl_host_max
Host bytes.
@ k_mdl_name_max
Site display name bytes.
Streaming HTTP(S) GET seam (a real function-pointer vtable) for the host manga downloader (v0).
@ k_mdl_last_mod_max
Raw Last-Modified header value buffer bytes.
@ k_mdl_etag_max
Raw ETag header value buffer bytes.
uint16_t mdl_state_chapter_pages(const mdl_state_t *st, const char *id)
Recorded page count for a chapter (0 when unknown).
void mdl_state_coverage(const mdl_state_t *st, char *buf, size_t cap)
Render a one-line coverage summary (chapter span, count, gaps).
bool mdl_state_set_series_metadata(mdl_state_t *st, const char *summary, const char *writer, const char *artist, const char *cover_url, const char *cover_path, const char *language, mdl_state_reading_direction_t direction)
Set the optional rich metadata persisted for a series.
mdl_binary64_parameter_t
IEC 60559 binary64 parameters required by the persisted schema.
@ k_mdl_binary64_min_exponent
Binary64 minimum exponent.
@ k_mdl_binary64_max_exponent
Binary64 maximum exponent.
@ k_mdl_binary64_mantissa_bits
Binary64 significand precision.
mdl_chapter_rec_t * mdl_state_add_chapter(mdl_state_t *st, const char *id, const char *url, long number)
Find or append a chapter record, returning it.
bool mdl_state_set_chapter_metadata(mdl_chapter_rec_t *chapter, const char *title, double number, bool number_known)
Set a chapter's display title and explicit parsed number.
mdl_chapter_rec_t * mdl_state_find_chapter(mdl_state_t *st, const char *id)
Find a chapter record by its stable identifier.
ra8_err_t mdl_state_save(mdl_storage_t *storage, const char *path, const mdl_state_t *st, bool *out_published)
Publish a checksummed successor without sacrificing the newest state.
const mdl_page_rec_t * mdl_state_find_page(const mdl_state_t *st, uint64_t url_hash)
Find a page record by its source-URL hash (the dedup lookup).
bool mdl_state_note_page_response(mdl_state_t *st, uint64_t url_hash, int64_t fetched_at, uint16_t response_status)
Refresh the observed HTTP result for one existing URL cache entry.
mdl_chapter_rec_t * mdl_state_add_chapter_numbered(mdl_state_t *st, const char *id, const char *url, double number, bool number_known)
Find or append a chapter with explicit parsed-number presence.
mdl_state_reading_direction_t
Persisted fixed-layout reading direction.
@ k_mdl_state_read_ltr
Left-to-right page progression.
@ k_mdl_state_read_rtl
Right-to-left page progression.
mdl_state_limit_t
Fixed capacities and the schema version (zero dynamic allocation).
@ k_mdl_language_max
BCP-47 language bytes.
@ k_mdl_state_version
Timestamped cache schema written now.
@ k_mdl_person_max
Writer/artist bytes.
@ k_mdl_summary_max
Series summary bytes.
@ k_mdl_cfgpath_max
Site-descriptor path bytes.
@ k_mdl_state_version_v2
Legacy decimal schema accepted.
@ k_mdl_chapter_id_max
Chapter identifier bytes (sanitised).
@ k_mdl_title_max
Series title bytes.
@ k_mdl_state_version_v3
Legacy cache-metadata schema accepted.
@ k_mdl_state_version_v1
Legacy integral schema accepted.
@ k_mdl_max_chapters
Chapters tracked per series.
@ k_mdl_relpath_max
Page path relative to the series dir.
bool mdl_state_chapter_complete(const mdl_state_t *st, const char *id)
Whether a chapter is recorded fully fetched and verified.
ra8_err_t mdl_state_load(mdl_storage_t *storage, const char *path, mdl_state_t *st)
Load a series' newest valid state through injected portable storage.
mdl_state_pool_t
Page pool capacity (kept separate: it needs a 32-bit count).
@ k_mdl_max_page_recs
Per-page content records per series.
bool mdl_state_add_page(mdl_state_t *st, uint64_t url_hash, uint64_t content_hash, const char *rel_path, const char *etag, const char *last_modified, int64_t fetched_at, uint16_t response_status)
Add or replace a URL-keyed page cache record.
ra8_err_t mdl_state_load_authenticated(mdl_storage_t *storage, const char *path, mdl_state_t *st)
Load only an authenticated checksummed state generation.
void mdl_state_init(mdl_state_t *st)
Reset a state object to an empty, current-version library.
void mdl_state_set_series(mdl_state_t *st, const char *url, const char *title, const char *site_name, const char *site_host, const char *config_path)
Record the series identity and the descriptor used.
ra8_err_t mdl_state_probe(mdl_storage_t *storage, const char *path, bool *out_exists)
Probe the complete two-generation state marker through portable storage.
Injected portable storage resources for downloader domain code.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
One chapter's coverage in library state.
char chapter_id[k_mdl_chapter_id_max]
Stable identifier (URL leaf).
double number
Parsed number; 0 may be valid.
int64_t fetched_at
Completion time (epoch s).
char source_url[k_mdl_url_max]
Chapter page URL.
uint16_t pages_done
Pages fetched and verified.
bool number_known
Whether number is known.
char title[k_mdl_title_max]
Display title, or empty.
uint16_t page_count
Total pages known (0 = ?).
bool complete
All pages present + verified.
One page's dedup/verify record in the series-wide pool.
char etag[k_mdl_etag_max]
Cached ETag for conditional GET.
char last_modified[k_mdl_last_mod_max]
Cached Last-Modified response value.
uint64_t content_hash
FNV-1a 64 of the fetched bytes.
char rel_path[k_mdl_relpath_max]
Path under the series directory.
uint64_t url_hash
FNV-1a 64 of the source URL.
uint16_t response_status
Most recent HTTP status; zero if legacy.
int64_t fetched_at
Most recent HTTP result time (epoch s).
One series' complete persistent state (declare at file scope).
char summary[k_mdl_summary_max]
Series synopsis.
uint16_t chapter_count
Chapters recorded.
char cover_path[k_mdl_relpath_max]
Local cover path.
char series_title[k_mdl_title_max]
Series title.
mdl_chapter_rec_t chapters[k_mdl_max_chapters]
Per-chapter coverage.
char series_url[k_mdl_url_max]
Series page URL.
char site_name[k_mdl_name_max]
Descriptor name.
mdl_state_reading_direction_t reading_direction
Page progression.
char language[k_mdl_language_max]
BCP-47 language tag.
uint16_t version
Schema version.
char artist[k_mdl_person_max]
Artist/illustrator.
uint32_t page_rec_count
Page records recorded.
mdl_page_rec_t pages[k_mdl_max_page_recs]
Per-page identities.
char site_host[k_mdl_host_max]
Site host.
char cover_url[k_mdl_url_max]
Remote cover URL.
char config_path[k_mdl_cfgpath_max]
Descriptor used.
char writer[k_mdl_person_max]
Writer/author.
One non-reentrant downloader filesystem dependency bundle.