ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_fetch.h
Go to the documentation of this file.
1
35#pragma once
36
37#include <stddef.h>
38#include <stdint.h>
39
40#include "mdl_cache.h"
41#include "mdl_config.h"
42#include "mdl_extract.h"
43#include "mdl_politeness.h"
44#include "mdl_session.h"
45#include "mdl_state.h"
46#include "mdl_storage.h"
47#include "ra8_err.h"
48#include "ra8_io_stream.h"
49
55
73
75typedef enum : uint16_t {
78
90typedef struct {
92 long status;
95
113
125typedef struct {
128 const char* chapter_id;
129 size_t page_index;
130 size_t page_total;
131 uint64_t page_bytes;
132 uint32_t elapsed_ms;
133 bool reused;
135
150typedef ra8_err_t (*mdl_progress_fn)(void* ctx, const mdl_fetch_progress_t* ev);
151
186
218 const char* url,
219 const char* target_abs,
220 const char* referer,
221 mdl_net_resp_t* out_resp,
222 size_t* out_bytes);
223
270 const mdl_url_list_t* chapters,
271 mdl_fetch_layout_t layout,
272 const char* combined_dir_rel,
273 mdl_fetch_stats_t* stats);
Bounded per-host HTTP document cache for the media downloader.
Per-site descriptor loaded from a flat key=value config file.
Extract image URLs and anchor links from an HTML page (v1 scanner).
@ k_mdl_url_max
Max bytes per URL, including the NUL.
Definition mdl_extract.h:25
mdl_fetch_faillog_size_t
Bounded run-failure log capacity (zero dynamic allocation).
Definition mdl_fetch.h:75
@ k_mdl_fetch_fail_max
Failures stored before the log saturates.
Definition mdl_fetch.h:76
ra8_err_t(* mdl_progress_fn)(void *ctx, const mdl_fetch_progress_t *ev)
Injected per-page progress sink; NULL disables all progress output.
Definition mdl_fetch.h:150
ra8_err_t mdl_fetch_run(mdl_fetch_ctx_t *ctx, const mdl_url_list_t *chapters, mdl_fetch_layout_t layout, const char *combined_dir_rel, mdl_fetch_stats_t *stats)
Download a series' chapters incrementally, resuming and deduping.
Definition mdl_fetch.c:947
ra8_err_t mdl_fetch_asset(mdl_fetch_ctx_t *ctx, const char *url, const char *target_abs, const char *referer, mdl_net_resp_t *out_resp, size_t *out_bytes)
Fetch one policy-governed asset to an absolute file path.
Definition mdl_fetch.c:356
mdl_fetch_layout_t
Output directory layout the orchestrator writes.
Definition mdl_fetch.h:51
@ k_mdl_layout_combined
All chapters -> one dir, continuous numbering.
Definition mdl_fetch.h:52
@ k_mdl_layout_separate
Each chapter -> own dir, per-chapter numbering.
Definition mdl_fetch.h:53
Jittered inter-request delay plus the per-host politeness governor.
Session identity (honest User-Agent) and robots.txt gating.
Persistent per-series library state for the media downloader.
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.
Definition ra8_err.h:546
ra8_io targetable byte-stream facade – one writer, many destinations.
One non-reentrant cache binding over caller storage.
Definition mdl_cache.h:92
Everything mdl_fetch_run needs, injected for testability.
Definition mdl_fetch.h:164
mdl_state_t * state
Persistent state, read and updated.
Definition mdl_fetch.h:167
mdl_url_list_t * images
Extracted-image scratch (caller-owned).
Definition mdl_fetch.h:177
const mdl_site_t * site
Selectors + politeness bounds.
Definition mdl_fetch.h:172
mdl_governor_t * gov
Per-host rate/backoff governor, or NULL.
Definition mdl_fetch.h:173
const char * state_path
Atomic checkpoint target, or NULL.
Definition mdl_fetch.h:169
bool update_only
Skip chapters already recorded complete.
Definition mdl_fetch.h:178
void * progress_ctx
Context passed to progress_fn.
Definition mdl_fetch.h:183
mdl_storage_t * storage
Portable storage binding + workspaces.
Definition mdl_fetch.h:166
char * page_buf
Chapter-HTML scratch (caller-owned).
Definition mdl_fetch.h:175
mdl_cache_t * cache
Per-host HTML cache binding.
Definition mdl_fetch.h:168
const char * series_abs_dir
Absolute series dir (paths resolve here).
Definition mdl_fetch.h:170
bool refetch
Ignore local page reuse and hit network.
Definition mdl_fetch.h:179
mdl_fetch_faillog_t * faillog
Caller-cleared failure log, or NULL.
Definition mdl_fetch.h:180
ra8_io_stream_t * diagnostic
Borrowed diagnostic sink.
Definition mdl_fetch.h:181
mdl_session_t * session
Identity + robots + net backend.
Definition mdl_fetch.h:165
const char * series_url
Series URL, sent as the chapter Referer.
Definition mdl_fetch.h:171
size_t page_cap
Capacity of page_buf.
Definition mdl_fetch.h:176
mdl_progress_fn progress_fn
Per-page progress sink, or NULL (silent).
Definition mdl_fetch.h:182
uint32_t timeout_ms
Per-request time budget.
Definition mdl_fetch.h:174
ra8_err_t progress_error
First callback failure from this run.
Definition mdl_fetch.h:184
One recorded page/chapter failure: what failed, and with what status.
Definition mdl_fetch.h:90
ra8_err_t err
Classified failure code (rendered on demand).
Definition mdl_fetch.h:93
char url[k_mdl_url_max]
Failing page or chapter URL (truncation-safe).
Definition mdl_fetch.h:91
long status
HTTP status observed, 0 when none.
Definition mdl_fetch.h:92
Bounded record of every failure in a run (declare at file scope).
Definition mdl_fetch.h:108
size_t count
Stored (<= capacity).
Definition mdl_fetch.h:110
size_t total
Observed (may exceed count).
Definition mdl_fetch.h:111
mdl_fetch_fail_t items[k_mdl_fetch_fail_max]
Stored failures.
Definition mdl_fetch.h:109
One per-page progress event the run emits through mdl_progress_fn.
Definition mdl_fetch.h:125
bool reused
Page served from an already-held file.
Definition mdl_fetch.h:133
size_t chapter_index
1-based chapter position in the run.
Definition mdl_fetch.h:126
uint64_t page_bytes
Bytes transferred (0 when reused).
Definition mdl_fetch.h:131
const char * chapter_id
Chapter identifier (URL leaf).
Definition mdl_fetch.h:128
uint32_t elapsed_ms
Wall time for the transfer (0 when reused).
Definition mdl_fetch.h:132
size_t chapter_total
Total chapters in the run.
Definition mdl_fetch.h:127
size_t page_index
1-based page position within the chapter.
Definition mdl_fetch.h:129
size_t page_total
Pages in the chapter.
Definition mdl_fetch.h:130
Tallies a fetch run reports back (all zero-initialised by the run).
Definition mdl_fetch.h:65
size_t chapters_completed
Chapters finished (all pages present) this run.
Definition mdl_fetch.h:66
size_t chapters_skipped
Chapters skipped as already complete (–update).
Definition mdl_fetch.h:67
size_t pages_fetched
Pages transferred over the network.
Definition mdl_fetch.h:69
size_t pages_reused
Pages served from an already-held verified file.
Definition mdl_fetch.h:70
size_t chapters_failed
Chapters left partial by a page failure.
Definition mdl_fetch.h:68
size_t pages_failed
Page fetches that failed or robots refused.
Definition mdl_fetch.h:71
Closed-loop per-host politeness governor (rate + backoff + concurrency).
Per-transfer response metadata surfaced to the politeness governor.
Definition mdl_net.h:120
One download session's identity and robots.txt state.
Definition mdl_session.h:39
One site's scraping rules (all data, no logic).
Definition mdl_config.h:46
One series' complete persistent state (declare at file scope).
Definition mdl_state.h:175
One non-reentrant downloader filesystem dependency bundle.
Definition mdl_storage.h:40
Bounded list of absolute URLs found on a page.
Definition mdl_extract.h:29
Caller-allocated byte-stream handle binding a sink to its context.