4#ifndef PROTOCORE_WEBDAV_H
5#define PROTOCORE_WEBDAV_H
40#define PROTOCORE_DAV_DEPTH_INFINITY 0x7fffffff
43#define PROTOCORE_DAV_LOCK_MAX 8
46#define PROTOCORE_DAV_LOCK_PATH_MAX 128
49#define PROTOCORE_DAV_LOCK_TOKEN_MAX 48
90 int (*depth)(uint8_t *,
const char *, int);
91 size_t (*xml_escape)(uint8_t *,
char *, size_t,
const char *);
92 proto_bool (*dest_path)(uint8_t *,
const char *,
char *, size_t);
93 size_t (*ms_begin)(uint8_t *,
char *, size_t, size_t);
94 size_t (*ms_entry)(uint8_t *,
char *, size_t, size_t,
const char *,
proto_bool, uint32_t,
const char *,
96 size_t (*ms_end)(uint8_t *,
char *, size_t, size_t);
97 size_t (*proppatch_ms)(uint8_t *,
char *, size_t,
const char *,
const char *, size_t);
106 proto_bool (*if_token)(uint8_t *,
const char *,
char *, size_t);
108PROTOCORE_NS_LAYOUT(
WebdavNs, method, depth, xml_escape, dest_path, ms_begin, ms_entry, ms_end, proppatch_ms, lock_init,
109 lock_acquire, lock_sweep, lock_refresh, lock_find, lock_release, lock_can_write, if_token);
167 proto_bool is_collection, uint32_t size,
const char *rfc1123_mtime,
168 const char *content_type);
251 const char *presented_token);
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#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.
The server-global lock table (one instance, not per-connection).
One active lock (RFC 4918 §6.4).
proto_bool active
false = free slot
uint32_t expiry_s
monotonic second the lock expires (0 = no timeout); swept by _sweep
proto_bool depth_infinity
the lock covers the whole subtree (Depth: infinity) vs just the resource
proto_bool exclusive
exclusive-write (true) or shared (false)
Dispatch table. Addressed by offset, so the layout is asserted below.
WebDavMethod(* method)(uint8_t *, const char *)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS
proto_bool protocore_webdav_if_token(uint8_t *work, const char *if_header, char *out, size_t cap)
Extract the first lock token from an If header value (RFC 4918 .
size_t protocore_webdav_lock_sweep(uint8_t *work, DavLockTable *t, uint32_t now_s)
Expire and drop every lock whose timeout has passed (RFC 4918 .
#define PROTOCORE_DAV_LOCK_PATH_MAX
Maximum locked-path length, including the NUL.
#define PROTOCORE_DAV_LOCK_TOKEN_MAX
Maximum lock-token length, including the NUL (e.g. "opaquelocktoken:xxxxxxxx-pc").
const DavLock * protocore_webdav_lock_acquire(uint8_t *work, DavLockTable *t, const char *path, const char *token, proto_bool exclusive, proto_bool depth_infinity, uint32_t expiry_s)
Acquire a lock on path with the caller-supplied token (RFC 4918 .
size_t protocore_webdav_ms_end(uint8_t *work, char *buf, size_t cap, size_t len)
Close the <multistatus> element.
size_t protocore_webdav_ms_entry(uint8_t *work, char *buf, size_t cap, size_t len, const char *href, proto_bool is_collection, uint32_t size, const char *rfc1123_mtime, const char *content_type)
Append one <response> describing a resource.
const DavLock * protocore_webdav_lock_refresh(uint8_t *work, DavLockTable *t, const char *token, uint32_t new_expiry_s)
Refresh a held lock's timeout to new_expiry_s, keyed by token (a .
#define PROTOCORE_DAV_LOCK_MAX
Maximum concurrent locks (fixed - a small structural bound, not a per-board tunable).
size_t protocore_webdav_ms_begin(uint8_t *work, char *buf, size_t cap, size_t len)
Write the XML prolog and the open <multistatus> element.
void protocore_webdav_lock_init(uint8_t *work, DavLockTable *t)
Reset a lock table (no locks held).
int protocore_webdav_depth(uint8_t *work, const char *depth_hdr, int dflt)
Parse a Depth header value ("0", "1", or "infinity").
const DavLock * protocore_webdav_lock_find(uint8_t *work, const DavLockTable *t, const char *path)
Find a lock covering path: one on path itself, or a Depth-infinity .
@ DAV_M_UNSUPPORTED
Anything else - answered 405 Method Not Allowed.
size_t protocore_webdav_proppatch_ms(uint8_t *work, char *buf, size_t cap, const char *href, const char *body, size_t body_len)
Build a complete 207 Multi-Status body answering a PROPPATCH. The .
WebDavMethod protocore_webdav_method(uint8_t *work, const char *m)
Classify an HTTP method token (e.g. "PROPFIND") into a WebDavMethod.
PROTOCORE_NS WebdavNs Webdav PROTOCORE_UNUSED
Module namespace.
proto_bool protocore_webdav_lock_release(uint8_t *work, DavLockTable *t, const char *token)
Release the lock whose token equals token (UNLOCK). true if one was .
enum PROTO_ENUM_PACKED WebDavMethod
WebDAV request methods recognized by the server.
proto_bool protocore_webdav_lock_can_write(uint8_t *work, const DavLockTable *t, const char *path, const char *presented_token)
May a write to path proceed given the token the request presented .
proto_bool protocore_webdav_dest_path(uint8_t *work, const char *destination, char *out, size_t cap)
Extract and percent-decode the path of a Destination header. .
size_t protocore_webdav_xml_escape(uint8_t *work, char *dst, size_t cap, const char *src)
XML-escape src into dst (&, <, >, ", ‘’`).