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

Cached page validation, streamed transfer, and publication. More...

#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mdl_fetch.h"
#include "mdl_fetch_body_internal.h"
#include "mdl_fetch_internal.h"
#include "mdl_hash.h"
#include "mdl_net.h"
#include "mdl_storage.h"
#include "mdl_url_guard.h"
#include "mdl_urlname.h"
#include "ra8_attributes.h"
#include "ra8_err.h"
Include dependency graph for mdl_fetch_page.c:

Go to the source code of this file.

Data Structures

struct  mdl_page_outcome_t
 Transfer outcome used to produce one progress event. More...
struct  mdl_page_transfer_t
 Mutable state for one conditional page transfer. More...

Enumerations

enum  mdl_fetch_page_size_t : uint16_t { k_fetch_leaf_bytes = 32 }
 Local page-path buffer size. More...
enum  mdl_fetch_page_bound_t : uint32_t {
  k_http_not_modified = 304U ,
  k_http_status_min = 100U ,
  k_http_status_max = 599U ,
  k_ms_per_sec = 1000U ,
  k_ns_per_ms = 1000000U
}
 Status and time conversions used by page accounting. More...

Functions

static uint32_t internal_mdl_fetch_page_max_u32 (uint32_t a, uint32_t b)
 Larger of two unsigned delay values.
static const char * internal_mdl_fetch_page_host (const char *url, char *buf, size_t cap)
 Governor host key for one page URL.
static int64_t internal_mdl_fetch_mono_ms (const mdl_fetch_ctx_t *ctx)
 Perform the mono ms step.
static ra8_err_t internal_mdl_fetch_emit_progress (const mdl_fetch_ctx_t *ctx, const mdl_run_pos_t *pos, size_t page_index, const mdl_page_outcome_t *out)
 Emit one per-page progress event through the injected sink, if any.
static bool internal_mdl_fetch_copy_file (mdl_storage_t *storage, const char *src, const char *dst)
 Copy one file through the validated portable storage transaction.
static bool internal_mdl_fetch_page_leaf (size_t page_no, const char *url, char *out, size_t cap)
 Compose the page_NNNN.ext leaf for one page; false if it overran.
static bool internal_mdl_fetch_try_reuse (mdl_fetch_ctx_t *ctx, uint64_t url_hash, const char *target_abs, const char *target_rel)
 Reuse an already-held byte-identical page instead of fetching it.
static bool internal_mdl_fetch_discard_stale_page (mdl_storage_t *storage, const char *guessed_abs, const char *actual_abs)
 Remove a superseded URL-derived page only after its replacement committed.
static ra8_err_t internal_mdl_fetch_prepare_page (mdl_fetch_ctx_t *ctx, const char *chapter_url, const char *url, const char *target_abs, const char *target_rel, mdl_page_transfer_t *tx)
 Prepare and execute the initial conditional page request.
static ra8_err_t internal_mdl_fetch_resolve_not_modified (mdl_fetch_ctx_t *ctx, const char *url, const char *target_abs, const char *target_rel, mdl_page_transfer_t *tx, bool *out_done)
 Resolve HTTP 304 by verified reuse or one unconditional retry.
static ra8_err_t internal_mdl_fetch_publish_page (mdl_fetch_ctx_t *ctx, const char *url, const char *target_abs, mdl_page_transfer_t *tx, size_t *out_bytes)
 Validate and atomically publish a nonempty staged page.
static ra8_err_t internal_mdl_fetch_do_fetch_page (mdl_fetch_ctx_t *ctx, const char *chapter_url, const char *url, const char *target_abs, const char *target_rel, size_t *out_bytes, mdl_net_resp_t *out_resp)
 Perform the do fetch page step.
static ra8_err_t internal_mdl_fetch_one_page (mdl_fetch_ctx_t *ctx, const char *chapter_url, const char *dest_abs, const char *dest_rel, size_t page_no, size_t idx, mdl_chapter_rec_t *rec, mdl_fetch_stats_t *stats, mdl_page_outcome_t *out)
 Reuse or fetch page idx and checkpoint its outcome.
ra8_err_t priv_mdl_fetch_chapter_pages (mdl_fetch_ctx_t *ctx, const char *chapter_url, const char *dest_abs, const char *dest_rel, size_t base, mdl_chapter_rec_t *rec, mdl_fetch_stats_t *stats, const mdl_run_pos_t *pos)
 Fetch every page of one chapter; fail (partial) on the first bad page.

Detailed Description

Cached page validation, streamed transfer, and publication.

Implements one-page reuse and conditional-fetch state transitions over injected network and atomic storage contracts without allocation.

Definition in file mdl_fetch_page.c.

Enumeration Type Documentation

◆ mdl_fetch_page_bound_t

enum mdl_fetch_page_bound_t : uint32_t

Status and time conversions used by page accounting.

Enumerator
k_http_not_modified 

Conditional GET reused the held entity.

k_http_status_min 

Smallest valid HTTP response status.

k_http_status_max 

Largest valid HTTP response status.

k_ms_per_sec 

Milliseconds per second.

k_ns_per_ms 

Nanoseconds per millisecond.

Definition at line 32 of file mdl_fetch_page.c.

◆ mdl_fetch_page_size_t

enum mdl_fetch_page_size_t : uint16_t

Local page-path buffer size.

Enumerator
k_fetch_leaf_bytes 

page_NNNN.ext leaf-name bytes.

Definition at line 27 of file mdl_fetch_page.c.

Function Documentation

◆ internal_mdl_fetch_copy_file()

bool internal_mdl_fetch_copy_file ( mdl_storage_t * storage,
const char * src,
const char * dst )
static

Copy one file through the validated portable storage transaction.

Adapts the canonical storage status to the fetcher's reuse boolean; the underlying operation independently hashes the staged bytes before an atomic create or truthful atomic replacement.

Parameters
[in,out]storageInitialized storage binding and workspaces.
[in]srcCanonical regular-file source path.
[in]dstCanonical distinct destination path.
Returns
Whether the complete validated copy was published.
Return values
trueThe destination now contains the exact source snapshot.
falseValidation, I/O, capability, or publication failed.
Precondition
Every pointer is non-null and both paths share one bound filesystem.
storage is exclusively owned for the duration of the copy.
Postcondition
Success publishes no partial destination.
Failure leaves any existing destination untouched.
Note
Not thread-safe against concurrent mutation of either named object.
Since
0.1.0

Definition at line 176 of file mdl_fetch_page.c.

References k_ra8_ok, and mdl_storage_copy_atomic().

Referenced by internal_mdl_fetch_try_reuse().

◆ internal_mdl_fetch_discard_stale_page()

bool internal_mdl_fetch_discard_stale_page ( mdl_storage_t * storage,
const char * guessed_abs,
const char * actual_abs )
static

Remove a superseded URL-derived page only after its replacement committed.

Performs discard stale page under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in]storagePortable storage binding.
[in]guessed_absOriginal URL-derived destination.
[in]actual_absMagic-derived committed destination.
Returns
Whether no conflicting stale page remains.
Return values
truePaths match, the stale path was absent, or a regular stale file was removed.
falseThe stale path names a non-regular object or could not be inspected/removed.
Precondition
Both paths are absolute, NUL-terminated, and share a parent directory.
Supplied capacities cover their referenced bounded buffers.
Postcondition
actual_abs is never modified or removed.
Result status and outputs describe one completed synchronous attempt.
Note
Symbolic links and directories are rejected rather than followed or removed.
Since
0.1.0

Definition at line 309 of file mdl_fetch_page.c.

References fw_fs_stat_t::exists, mdl_storage_t::fs, fw_fs_stat(), fw_fs_unlink(), k_fw_fs_node_file, k_ra8_ok, fw_fs_t::names, RA8_INTERNAL, strcmp(), and fw_fs_stat_t::type.

Referenced by internal_mdl_fetch_publish_page().

◆ internal_mdl_fetch_do_fetch_page()

ra8_err_t internal_mdl_fetch_do_fetch_page ( mdl_fetch_ctx_t * ctx,
const char * chapter_url,
const char * url,
const char * target_abs,
const char * target_rel,
size_t * out_bytes,
mdl_net_resp_t * out_resp )
static

Perform the do fetch page step.

Performs do fetch page under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in,out]ctxBorrowed operation context.
[in]chapter_urlCanonical chapter URL.
[in]urlCanonical input URL.
[in]target_absAbsolute destination path.
[in]target_relLibrary-relative destination path.
[out]out_bytesReceives the transferred byte count.
[out]out_respReceives normalized response metadata.
Returns
Canonical downloader status.
Return values
k_ra8_okThe operation completed.
otherValidation, capacity, network, or storage failed.
Precondition
Required pointer arguments remain valid for the call duration.
Supplied capacities cover their referenced bounded buffers.
Postcondition
No ownership of caller-provided storage is transferred.
Result status and outputs describe one completed synchronous attempt.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 563 of file mdl_fetch_page.c.

References internal_mdl_fetch_prepare_page(), internal_mdl_fetch_publish_page(), internal_mdl_fetch_resolve_not_modified(), k_ra8_ok, RA8_INTERNAL, and mdl_page_transfer_t::resp.

Referenced by internal_mdl_fetch_one_page().

◆ internal_mdl_fetch_emit_progress()

ra8_err_t internal_mdl_fetch_emit_progress ( const mdl_fetch_ctx_t * ctx,
const mdl_run_pos_t * pos,
size_t page_index,
const mdl_page_outcome_t * out )
static

Emit one per-page progress event through the injected sink, if any.

Snapshots chapter position, page position, bytes, duration, and reuse into a stack event and synchronously invokes the optional callback.

Parameters
[in]ctxFetch context containing the optional callback and page count.
[in]posCurrent chapter position and stable identifier.
[in]page_indexZero-based page index.
[in]outCompleted page outcome to report.
Precondition
ctx, pos, and out are non-NULL.
page_index is less than the current extracted page count.
Postcondition
A configured callback observes exactly one complete event.
No callback or context pointer is retained or transferred.
Note
A missing callback is an intentional no-op.
Since
0.1.0
Returns
Operation status.
Return values
k_ra8_okThe operation completed successfully.
otherThe originating validation, storage, stream, or network error.

Definition at line 138 of file mdl_fetch_page.c.

References mdl_page_outcome_t::bytes, mdl_run_pos_t::chapter_id, mdl_run_pos_t::chapter_index, mdl_run_pos_t::chapter_total, mdl_url_list_t::count, mdl_page_outcome_t::elapsed_ms, mdl_fetch_ctx_t::images, k_ra8_ok, mdl_fetch_ctx_t::progress_ctx, mdl_fetch_ctx_t::progress_fn, RA8_INTERNAL, and mdl_page_outcome_t::reused.

Referenced by priv_mdl_fetch_chapter_pages().

◆ internal_mdl_fetch_mono_ms()

int64_t internal_mdl_fetch_mono_ms ( const mdl_fetch_ctx_t * ctx)
static

Perform the mono ms step.

Performs mono ms under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in]ctxBorrowed operation context.
Returns
The bounded result computed from the supplied input.
Return values
otherThe computed result in the function's declared domain.
Precondition
Required pointer arguments remain valid for the call duration.
Supplied capacities cover their referenced bounded buffers.
Postcondition
No ownership of caller-provided storage is transferred.
Result status and outputs describe one completed synchronous attempt.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 106 of file mdl_fetch_page.c.

References k_ms_per_sec, k_ns_per_ms, mdl_fetch_ctx_t::progress_fn, and RA8_INTERNAL.

Referenced by internal_mdl_fetch_one_page().

◆ internal_mdl_fetch_one_page()

ra8_err_t internal_mdl_fetch_one_page ( mdl_fetch_ctx_t * ctx,
const char * chapter_url,
const char * dest_abs,
const char * dest_rel,
size_t page_no,
size_t idx,
mdl_chapter_rec_t * rec,
mdl_fetch_stats_t * stats,
mdl_page_outcome_t * out )
static

Reuse or fetch page idx and checkpoint its outcome.

Composes absolute and relative paths, tries verified hash reuse, otherwise performs a governed conditional fetch, records the page, updates statistics, and checkpoints only the completed outcome.

Parameters
[in,out]ctxFetch dependencies, persistent state, and page list.
[in]chapter_urlCanonical chapter URL used for diagnostics.
[in]dest_absCanonical destination directory.
[in]dest_relLibrary-relative destination directory.
[in]page_noOne-based page number.
[in]idxZero-based index in the extracted page URL list.
[in,out]recChapter record receiving completed-page progress.
[in,out]statsRun counters receiving bytes, reuse, or failure.
[out]outReceives the bounded page outcome.
Returns
Fetch, validation, or checkpoint status.
Return values
k_ra8_okThe page was verified in place, reused, or published and checkpointed.
otherPath construction, transfer, validation, or checkpointing failed.
Precondition
Every pointer is non-NULL and idx is less than the extracted page count.
The storage and network dependencies in ctx are exclusively owned.
Postcondition
Success records one verified page and one successful checkpoint.
Failure never records an incomplete page as complete.
Note
Existing destinations are protected by the injected transaction contract.
Since
0.1.0

Definition at line 621 of file mdl_fetch_page.c.

References mdl_page_rec_t::etag, mdl_fetch_ctx_t::images, internal_mdl_fetch_do_fetch_page(), internal_mdl_fetch_mono_ms(), internal_mdl_fetch_page_leaf(), internal_mdl_fetch_try_reuse(), k_fetch_leaf_bytes, k_http_not_modified, k_mdl_relpath_max, k_ra8_fail, k_ra8_ok, mdl_page_rec_t::last_modified, mdl_hash_str(), mdl_state_find_page(), mdl_chapter_rec_t::pages_done, mdl_fetch_stats_t::pages_failed, mdl_fetch_stats_t::pages_fetched, mdl_fetch_stats_t::pages_reused, priv_mdl_fetch_checkpoint(), RA8_INTERNAL, mdl_fetch_ctx_t::refetch, mdl_fetch_ctx_t::state, mdl_net_resp_t::status, and mdl_url_list_t::urls.

Referenced by priv_mdl_fetch_chapter_pages().

◆ internal_mdl_fetch_page_host()

const char * internal_mdl_fetch_page_host ( const char * url,
char * buf,
size_t cap )
static

Governor host key for one page URL.

Definition at line 88 of file mdl_fetch_page.c.

References mdl_url_host(), and RA8_INTERNAL.

Referenced by internal_mdl_fetch_prepare_page().

◆ internal_mdl_fetch_page_leaf()

bool internal_mdl_fetch_page_leaf ( size_t page_no,
const char * url,
char * out,
size_t cap )
static

Compose the page_NNNN.ext leaf for one page; false if it overran.

Derives the bounded extension from url and renders the one-based page number into caller-owned storage without filesystem access.

Parameters
[in]page_noOne-based page number.
[in]urlCanonical page URL used to derive the extension.
[out]outReceives a NUL-terminated leaf on success.
[in]capCapacity of out in bytes.
Returns
Whether the complete leaf fit.
Return values
trueout contains the complete page leaf.
falseFormatting failed or cap was insufficient.
Precondition
url and out are non-NULL.
cap is nonzero and describes writable storage at out.
Postcondition
Success leaves a NUL-terminated filename within cap.
No pointer ownership is retained or transferred.
Note
Performs no filesystem I/O.
Since
0.1.0

Definition at line 200 of file mdl_fetch_page.c.

References mdl_urlname_ext().

Referenced by internal_mdl_fetch_one_page().

◆ internal_mdl_fetch_page_max_u32()

uint32_t internal_mdl_fetch_page_max_u32 ( uint32_t a,
uint32_t b )
static

Larger of two unsigned delay values.

Performs page max u32 under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in]aFirst unsigned delay operand.
[in]bSecond unsigned delay operand.
Returns
The bounded result computed from the supplied input.
Return values
otherThe computed result in the function's declared domain.
Precondition
Required pointer arguments remain valid for the call duration.
Supplied capacities cover their referenced bounded buffers.
Postcondition
No ownership of caller-provided storage is transferred.
Result status and outputs describe one completed synchronous attempt.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 82 of file mdl_fetch_page.c.

References RA8_INTERNAL.

Referenced by internal_mdl_fetch_prepare_page().

◆ internal_mdl_fetch_prepare_page()

ra8_err_t internal_mdl_fetch_prepare_page ( mdl_fetch_ctx_t * ctx,
const char * chapter_url,
const char * url,
const char * target_abs,
const char * target_rel,
mdl_page_transfer_t * tx )
static

Prepare and execute the initial conditional page request.

Performs prepare page under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in,out]ctxFetch dependencies and state.
[in]chapter_urlChapter URL used as the request Referer.
[in]urlAbsolute page URL.
[in]target_absFinal absolute page path.
[in]target_relFinal relative page path.
[out]txCaller-owned transfer state.
Returns
k_ra8_ok after a response, otherwise the classified failure.
Return values
k_ra8_okThe operation completed.
otherValidation, capacity, network, or storage failed.
Precondition
Every pointer is non-NULL and tx is writable.
Supplied capacities cover their referenced bounded buffers.
Postcondition
Success leaves a response and caller-owned transactional body in tx.
Failure is recorded once and aborts any private transaction stage.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 352 of file mdl_fetch_page.c.

References mdl_page_transfer_t::body, mdl_page_rec_t::etag, mdl_page_transfer_t::got, mdl_page_transfer_t::held, mdl_page_transfer_t::host, mdl_site_t::img_delay_max, mdl_site_t::img_delay_min, internal_mdl_fetch_page_host(), internal_mdl_fetch_page_max_u32(), mdl_page_transfer_t::jmax, mdl_page_transfer_t::jmin, k_ra8_fail, k_ra8_ok, mdl_page_rec_t::last_modified, mdl_hash_str(), mdl_session_url_allowed(), mdl_state_find_page(), nullptr, priv_mdl_fetch_body_abort(), priv_mdl_fetch_body_init_image(), priv_mdl_fetch_body_sink(), priv_mdl_fetch_record_fail(), priv_mdl_fetch_with_retry(), RA8_INTERNAL, mdl_page_transfer_t::recorded, mdl_fetch_ctx_t::refetch, mdl_page_transfer_t::req, mdl_page_transfer_t::resp, mdl_fetch_ctx_t::session, mdl_fetch_ctx_t::site, mdl_fetch_ctx_t::state, mdl_net_resp_t::status, mdl_fetch_ctx_t::storage, mdl_fetch_ctx_t::timeout_ms, and mdl_session_t::user_agent.

Referenced by internal_mdl_fetch_do_fetch_page().

◆ internal_mdl_fetch_publish_page()

ra8_err_t internal_mdl_fetch_publish_page ( mdl_fetch_ctx_t * ctx,
const char * url,
const char * target_abs,
mdl_page_transfer_t * tx,
size_t * out_bytes )
static

Validate and atomically publish a nonempty staged page.

Performs publish page under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in,out]ctxFetch dependencies and persistent state.
[in]urlAbsolute page URL.
[in]target_absURL-derived absolute destination.
[in,out]txCompleted non-304 transfer state.
[out]out_bytesOptional published byte count.
Returns
Publication or validation result.
Return values
k_ra8_okThe operation completed.
otherValidation, capacity, network, or storage failed.
Precondition
Every required pointer is non-NULL.
Supplied capacities cover their referenced bounded buffers.
Postcondition
Success records the magic-derived path and content hash.
Pre-commit failures leave any existing destination untouched.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 488 of file mdl_fetch_page.c.

References mdl_fetch_body_t::actual_abs, mdl_fetch_body_t::actual_rel, mdl_page_transfer_t::body, mdl_net_resp_t::etag, mdl_page_rec_t::etag, mdl_page_transfer_t::got, mdl_storage_txn_t::hash, mdl_page_transfer_t::held, internal_mdl_fetch_discard_stale_page(), k_http_status_max, k_http_status_min, k_mdl_max_page_recs, k_ra8_err_no_mem, k_ra8_err_protocol_error, k_ra8_fail, k_ra8_ok, mdl_net_resp_t::last_modified, mdl_page_rec_t::last_modified, mdl_hash_str(), mdl_state_add_page(), mdl_state_t::page_rec_count, priv_mdl_fetch_body_abort(), priv_mdl_fetch_body_commit(), priv_mdl_fetch_body_prepare(), priv_mdl_fetch_record_fail(), RA8_INTERNAL, mdl_page_transfer_t::recorded, mdl_page_transfer_t::resp, mdl_fetch_ctx_t::state, mdl_net_resp_t::status, mdl_fetch_ctx_t::storage, and mdl_fetch_body_t::writer.

Referenced by internal_mdl_fetch_do_fetch_page().

◆ internal_mdl_fetch_resolve_not_modified()

ra8_err_t internal_mdl_fetch_resolve_not_modified ( mdl_fetch_ctx_t * ctx,
const char * url,
const char * target_abs,
const char * target_rel,
mdl_page_transfer_t * tx,
bool * out_done )
static

Resolve HTTP 304 by verified reuse or one unconditional retry.

Performs resolve not modified under the injected network, governor, and storage contracts; dependency failures are propagated before incomplete bytes are published.

Parameters
[in,out]ctxFetch dependencies and state.
[in]urlAbsolute page URL.
[in]target_absURL-derived absolute destination.
[in]target_relURL-derived relative destination.
[in,out]txCurrent transfer state.
[out]out_doneWhether verified reuse completed the page.
Returns
k_ra8_ok when reusable or followed by a 200 response; otherwise failure.
Return values
k_ra8_okThe operation completed.
otherValidation, capacity, network, or storage failed.
Precondition
Every pointer is non-NULL.
Supplied capacities cover their referenced bounded buffers.
Postcondition
A 304 creates no filesystem transaction.
Any failed unconditional retry is recorded exactly once.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 419 of file mdl_fetch_page.c.

References mdl_page_transfer_t::body, mdl_page_transfer_t::got, mdl_page_transfer_t::held, mdl_page_transfer_t::host, mdl_net_req_t::if_modified_since, mdl_net_req_t::if_none_match, internal_mdl_fetch_try_reuse(), mdl_page_transfer_t::jmax, mdl_page_transfer_t::jmin, k_http_not_modified, k_ra8_err_invalid_state, k_ra8_err_validation_failed, k_ra8_ok, mdl_hash_str(), mdl_state_note_page_response(), priv_mdl_fetch_body_abort(), priv_mdl_fetch_body_sink(), priv_mdl_fetch_record_fail(), priv_mdl_fetch_with_retry(), RA8_INTERNAL, mdl_page_transfer_t::req, mdl_page_transfer_t::resp, mdl_fetch_ctx_t::state, and mdl_net_resp_t::status.

Referenced by internal_mdl_fetch_do_fetch_page().

◆ internal_mdl_fetch_try_reuse()

bool internal_mdl_fetch_try_reuse ( mdl_fetch_ctx_t * ctx,
uint64_t url_hash,
const char * target_abs,
const char * target_rel )
static

Reuse an already-held byte-identical page instead of fetching it.

Content-hash dedup: if a page with the same source URL is recorded and its file still verifies, put those bytes at the target position (a no-op when it is already there, else a copy) and record the new location – no network. Returns false to fall through to a fetch.

Parameters
[in,out]ctxBorrowed operation context.
[in]url_hashStable hash of the canonical source URL.
[in]target_absAbsolute destination path.
[in]target_relLibrary-relative destination path.
Returns
Whether the requested condition or operation succeeded.
Return values
trueThe condition holds or the operation completed.
falseInput was rejected or the condition does not hold.
Precondition
Required pointer arguments remain valid for the call duration.
Supplied capacities cover their referenced bounded buffers.
Postcondition
No ownership of caller-provided storage is transferred.
Result status and outputs describe one completed synchronous attempt.
Note
The function performs no dynamic allocation and retains no caller pointer.
Since
0.1.0

Definition at line 228 of file mdl_fetch_page.c.

References mdl_page_rec_t::content_hash, mdl_page_rec_t::etag, mdl_page_rec_t::fetched_at, internal_mdl_fetch_copy_file(), k_mdl_relpath_max, k_ra8_ok, mdl_page_rec_t::last_modified, mdl_hash_file(), mdl_state_add_page(), mdl_state_find_page(), RA8_INTERNAL, mdl_page_rec_t::rel_path, mdl_page_rec_t::response_status, mdl_fetch_ctx_t::series_abs_dir, mdl_fetch_ctx_t::state, mdl_fetch_ctx_t::storage, strcmp(), and strrchr().

Referenced by internal_mdl_fetch_one_page(), and internal_mdl_fetch_resolve_not_modified().

◆ priv_mdl_fetch_chapter_pages()

ra8_err_t priv_mdl_fetch_chapter_pages ( mdl_fetch_ctx_t * ctx,
const char * chapter_url,
const char * dest_abs,
const char * dest_rel,
size_t base,
mdl_chapter_rec_t * rec,
mdl_fetch_stats_t * stats,
const mdl_run_pos_t * pos )

Fetch every page of one chapter; fail (partial) on the first bad page.

Fetch and checkpoint every extracted page in one chapter.

Definition at line 680 of file mdl_fetch_page.c.

References mdl_url_list_t::count, mdl_fetch_ctx_t::images, internal_mdl_fetch_emit_progress(), internal_mdl_fetch_one_page(), k_ra8_ok, mdl_fetch_ctx_t::progress_error, and RA8_PRIV.

Referenced by internal_mdl_fetch_chapter_pages_and_checkpoint().