ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
http_range.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_HTTP_RANGE_H
5#define PROTOCORE_HTTP_RANGE_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
10
11/**
12 * @file http_range.h
13 * @brief Shared single-range `Range: bytes=...` parser (RFC 7233), used by static file serving and the
14edge cache (PROTOCORE_ENABLE_RANGE).
15 *
16 * One owner for the range math, shared by the filesystem file server and the CDN edge cache. Pure
17 * and size/string-driven - no PC or fs:: dependency.
18 *
19 * @c work is bytes the CALLER holds. This module reads none of them: it carries nothing
20 * between calls, so there is no state to keep and nothing to wipe. The parameter is there so
21 * a caller drives every namespace the same way.
22 *
23 * @author Douglas Quigg (dstroy0)
24 * @date 2026
25 */
26
27// PROTOCORE_HTTP_RANGE_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
28// it into its arena. Its size and its offset are each a static_assert, so a feature
29// combination that does not fit fails to compile rather than overrunning at run time.
30
31/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
32typedef struct
33{
34 int (*http_parse_byte_range)(uint8_t *, const char *, size_t, size_t *, size_t *);
36PROTOCORE_NS_LAYOUT(HttpRangeNs, http_parse_byte_range);
37
38/**
39 * @brief Parse a single-range `Range: bytes=...` header value against a .
40 * @param work PROTOCORE_HTTP_RANGE_BORROW bytes the caller took. Not held past the call.
41 * @param hdr Hdr
42 * @param size Size
43 * @param out_start Out start
44 * @param out_end Out end
45 * @return The int.
46 */
47int protocore_http_range_http_parse_byte_range(uint8_t *work, const char *hdr, size_t size, size_t *out_start,
48 size_t *out_end);
49
50/** @brief Module namespace. */
53
55
56#endif // PROTOCORE_HTTP_RANGE_H
PROTOCORE_NS HttpRangeNs HttpRange PROTOCORE_UNUSED
Module namespace.
Definition http_range.h:51
int protocore_http_range_http_parse_byte_range(uint8_t *work, const char *hdr, size_t size, size_t *out_start, size_t *out_end)
Parse a single-range Range: bytes=... header value against a .
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition http_range.h:33
int(* http_parse_byte_range)(uint8_t *, const char *, size_t, size_t *, size_t *)
Definition http_range.h:34
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97