Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
header_map.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <compy/priv/compiler_attrs.h>
9#include <compy/types/error.h>
10#include <compy/types/header.h>
11
12#include <stdbool.h>
13#include <stddef.h>
14#include <stdio.h>
15
16#include <unistd.h>
17
18#include <slice99.h>
19
23#define Compy_HeaderMap_from_array(...) \
24 ((Compy_HeaderMap){ \
25 .headers = __VA_ARGS__, \
26 .len = SLICE99_ARRAY_LEN((Compy_Header[])__VA_ARGS__), \
27 })
28
32#define COMPY_HEADER_MAP_CAPACITY 32
33
37typedef struct {
42
46 size_t len;
48
52Compy_HeaderMap Compy_HeaderMap_empty(void) COMPY_PRIV_MUST_USE;
53
69 const Compy_HeaderMap *restrict self, CharSlice99 key,
70 CharSlice99 *restrict value) COMPY_PRIV_MUST_USE;
71
78 const Compy_HeaderMap *restrict self, CharSlice99 key) COMPY_PRIV_MUST_USE;
79
90
103 const Compy_HeaderMap *restrict self, Compy_Writer w) COMPY_PRIV_MUST_USE;
104
110Compy_ParseResult Compy_HeaderMap_parse(
111 Compy_HeaderMap *restrict self, CharSlice99 input) COMPY_PRIV_MUST_USE;
112
120 const Compy_HeaderMap *restrict lhs,
121 const Compy_HeaderMap *restrict rhs) COMPY_PRIV_MUST_USE;
122
131bool Compy_HeaderMap_is_full(const Compy_HeaderMap *restrict self)
132 COMPY_PRIV_MUST_USE;
133
147 const Compy_HeaderMap *restrict headers, CharSlice99 key,
148 const char *restrict fmt, ...) COMPY_PRIV_MUST_USE
149 COMPY_PRIV_GCC_ATTR(format(scanf, 3, 4));
Possible parsing errors.
An RTSP header.
#define COMPY_HEADER_MAP_CAPACITY
The maximum number of headers in Compy_HeaderMap.headers.
Definition header_map.h:32
Compy_ParseResult Compy_HeaderMap_parse(Compy_HeaderMap *restrict self, CharSlice99 input) COMPY_PRIV_MUST_USE
Parses data to self.
Definition header_map.c:67
bool Compy_HeaderMap_find(const Compy_HeaderMap *restrict self, CharSlice99 key, CharSlice99 *restrict value) COMPY_PRIV_MUST_USE
Finds a value associated with key within self.
Definition header_map.c:19
bool Compy_HeaderMap_eq(const Compy_HeaderMap *restrict lhs, const Compy_HeaderMap *restrict rhs) COMPY_PRIV_MUST_USE
Tests lhs and rhs for equality.
Definition header_map.c:94
void Compy_HeaderMap_append(Compy_HeaderMap *restrict self, Compy_Header h)
Appends a new header to a header map.
Definition header_map.c:42
ssize_t Compy_HeaderMap_serialize(const Compy_HeaderMap *restrict self, Compy_Writer w) COMPY_PRIV_MUST_USE
Serialises self into w.
Definition header_map.c:50
Compy_HeaderMap Compy_HeaderMap_empty(void) COMPY_PRIV_MUST_USE
Returns an empty header map suitable for further parsing.
Definition header_map.c:12
bool Compy_HeaderMap_contains_key(const Compy_HeaderMap *restrict self, CharSlice99 key) COMPY_PRIV_MUST_USE
Returns whether key is present in self.
Definition header_map.c:36
int compy_scanf_header(const Compy_HeaderMap *restrict headers, CharSlice99 key, const char *restrict fmt,...) COMPY_PRIV_MUST_USE COMPY_PRIV_GCC_ATTR(format(scanf
Attempts to parse a header.
bool Compy_HeaderMap_is_full(const Compy_HeaderMap *restrict self) COMPY_PRIV_MUST_USE
Tests whether self is full (no more space left for an additional header) or not.
Definition header_map.c:114
An RTSP header map.
Definition header_map.h:37
size_t len
The count of elements currently in headers.
Definition header_map.h:46
An RTSP header.
Definition header.h:22