ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
webdav_handler.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/**
5 * @file webdav_handler.h
6 * @brief WebDAV request handling against a mounted filesystem (RFC 4918).
7 *
8 * The server half of WebDAV: it resolves a request path against a ROUTE_DAV mount, dispatches the
9 * method, walks directories for PROPFIND, and streams a PUT body to the file. The wire format it
10 * speaks - method classification, Depth parsing, the 207 Multi-Status builder, and the lock table -
11 * is the pure codec in network_drivers/application/webdav/webdav.h, which this file calls.
12 *
13 * dav(), the mount call an application makes, is public API and is declared in protocore.h.
14 */
15
16#ifndef PROTOCORE_WEBDAV_HANDLER_H
17#define PROTOCORE_WEBDAV_HANDLER_H
18
19#include "protocore_config.h" // the entry point: protocore_types.h for the widths
20
21#if PROTOCORE_ENABLE_WEBDAV
22
24
25// PROTOCORE_WEBDAV_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
26// it into its arena. A caller takes them once and passes the pointer to every call. How they
27// are carved is this module's and is never named here.
28
29/** @brief HttpReq, as the caller already knows it. */
30struct HttpReq;
31
32/** @brief What try_serve_dav takes: slot_id, req. */
33typedef struct
34{
35 uint8_t slot_id;
36 struct HttpReq *req;
37} DavTryServeDavArgs;
38
39/**
40 * @brief WebDAV request handling against a mounted filesystem (RFC 4918).
41 *
42 * A caller sets the members a call takes, invokes it through ::Dav with the bytes it runs
43 * out of, and reads the outcome off the same handle.
44 *
45 * Dav.try_serve_dav_args.slot_id = ...;
46 * Dav.try_serve_dav_args.req = ...;
47 * Dav.try_serve_dav(work);
48 * // Dav.ok is what the call reports
49 *
50 * @var DavNs::try_serve_dav_args what try_serve_dav takes: slot_id, req
51 * @var DavNs::ok a call's true/false outcome
52 * @var DavNs::try_serve_dav if req matches a ROUTE_DAV mount, handle it as WebDAV and return ...
53 *
54 * @c work is PROTOCORE_WEBDAV_BORROW bytes the CALLER took, at an address it knows. It is not held past the call, so
55 * nothing here aliases it. How those bytes are carved is this module's and is never named here.
56 */
57typedef struct
58{
59 DavTryServeDavArgs try_serve_dav_args;
60 proto_bool ok;
61} DavVars;
62
63/** @brief The operands and the outcome. */
64extern DavVars DavV;
65
66/** @brief The entries. */
67typedef struct
68{
69 void (*const try_serve_dav)(uint8_t *work);
70} DavNs;
71
72// What the table binds, defined once in the .c and taking one parameter each: everything
73// else an entry needs is an operand in DavV or a region of the borrow at a fixed offset.
74void protocore_dav_try_serve_dav(uint8_t *work);
75
76// `static const`, initialised HERE rather than `extern` against a definition in the .c: a
77// const object whose initializer every translation unit can see is a COMPILE-TIME FACT, so
78// `Dav.try_serve_dav(work)` resolves to a named function and becomes a DIRECT call. An extern table
79// leaves the call indirect and the symbol live at every level, -O2 -flto included.
80static const DavNs Dav __attribute__((unused)) = {
81 .try_serve_dav = protocore_dav_try_serve_dav,
82};
83
84/**
85 * @brief The PROTOCORE_WEBDAV_BORROW bytes this module's state lives in.
86 *
87 * Stated beside the namespace rather than on it: an entry takes a borrow, and this is where
88 * that borrow comes from. Taken once from the end of the pool, which no mark and no release
89 * walks, so the state lasts the life of the program.
90 *
91 * @return the span.
92 */
93uint8_t *protocore_webdav_handler_span(void);
94
96
97#endif // PROTOCORE_ENABLE_WEBDAV
98
99#endif // PROTOCORE_WEBDAV_HANDLER_H
uint8_t slot_id
Definition http_parser.h:57
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
_Bool proto_bool
The truth value.
Definition types.h:64
#define PROTOCORE_END_DECLS
Definition types.h:97