An RTSP header map.
More...
#include <smolrtsp/priv/compiler_attrs.h>
#include <smolrtsp/types/error.h>
#include <smolrtsp/types/header.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <slice99.h>
Go to the source code of this file.
|
SmolRTSP_HeaderMap | SmolRTSP_HeaderMap_empty (void) SMOLRTSP_PRIV_MUST_USE |
| Returns an empty header map suitable for further parsing.
|
|
bool | SmolRTSP_HeaderMap_find (const SmolRTSP_HeaderMap *restrict self, CharSlice99 key, CharSlice99 *restrict value) SMOLRTSP_PRIV_MUST_USE |
| Finds a value associated with key within self . More...
|
|
bool | SmolRTSP_HeaderMap_contains_key (const SmolRTSP_HeaderMap *restrict self, CharSlice99 key) SMOLRTSP_PRIV_MUST_USE |
| Returns whether key is present in self . More...
|
|
void | SmolRTSP_HeaderMap_append (SmolRTSP_HeaderMap *restrict self, SmolRTSP_Header h) |
| Appends a new header to a header map. More...
|
|
ssize_t | SmolRTSP_HeaderMap_serialize (const SmolRTSP_HeaderMap *restrict self, SmolRTSP_Writer w) SMOLRTSP_PRIV_MUST_USE |
| Serialises self into w . More...
|
|
SmolRTSP_ParseResult | SmolRTSP_HeaderMap_parse (SmolRTSP_HeaderMap *restrict self, CharSlice99 input) SMOLRTSP_PRIV_MUST_USE |
| Parses data to self . More...
|
|
bool | SmolRTSP_HeaderMap_eq (const SmolRTSP_HeaderMap *restrict lhs, const SmolRTSP_HeaderMap *restrict rhs) SMOLRTSP_PRIV_MUST_USE |
| Tests lhs and rhs for equality. More...
|
|
bool | SmolRTSP_HeaderMap_is_full (const SmolRTSP_HeaderMap *restrict self) SMOLRTSP_PRIV_MUST_USE |
| Tests whether self is full (no more space left for an additional header) or not. More...
|
|
int | smolrtsp_scanf_header (const SmolRTSP_HeaderMap *restrict headers, CharSlice99 key, const char *restrict fmt,...) SMOLRTSP_PRIV_MUST_USE SMOLRTSP_PRIV_GCC_ATTR(format(scanf |
| Attempts to parse a header. More...
|
|
◆ SmolRTSP_HeaderMap_from_array
#define SmolRTSP_HeaderMap_from_array |
( |
|
... | ) |
|
◆ SmolRTSP_HeaderMap_append()
Appends a new header to a header map.
- Parameters
-
[out] | self | The header map to modify. |
[in] | h | The new header to be appended. |
- Precondition
self != NULL
-
!SmolRTSP_HeaderMap_is_full(self)
◆ SmolRTSP_HeaderMap_contains_key()
bool SmolRTSP_HeaderMap_contains_key |
( |
const SmolRTSP_HeaderMap *restrict |
self, |
|
|
CharSlice99 |
key |
|
) |
| |
Returns whether key
is present in self
.
- Precondition
self != NULL
◆ SmolRTSP_HeaderMap_eq()
Tests lhs
and rhs
for equality.
- Precondition
lhs != NULL
-
rhs != NULL
◆ SmolRTSP_HeaderMap_find()
bool SmolRTSP_HeaderMap_find |
( |
const SmolRTSP_HeaderMap *restrict |
self, |
|
|
CharSlice99 |
key, |
|
|
CharSlice99 *restrict |
value |
|
) |
| |
Finds a value associated with key
within self
.
If key
has been found within self
, this function assigns value
to this key (no copying occurs) and returns true
. Otherwise, returns false
and value
remains unchanged.
- Parameters
-
[in] | self | The header map to be searched for key . |
[in] | key | The key to be searched in self . |
[out] | value | The header value to be assigned, if found. If NULL , no assignment is performed. |
- Precondition
self != NULL
◆ SmolRTSP_HeaderMap_is_full()
Tests whether self
is full (no more space left for an additional header) or not.
- Returns
true
if self
is full, false
otherwise.
- Precondition
self != NULL
◆ SmolRTSP_HeaderMap_parse()
SmolRTSP_ParseResult SmolRTSP_HeaderMap_parse |
( |
SmolRTSP_HeaderMap *restrict |
self, |
|
|
CharSlice99 |
input |
|
) |
| |
Parses data
to self
.
- Precondition
self != NULL
◆ SmolRTSP_HeaderMap_serialize()
ssize_t SmolRTSP_HeaderMap_serialize |
( |
const SmolRTSP_HeaderMap *restrict |
self, |
|
|
SmolRTSP_Writer |
w |
|
) |
| |
Serialises self
into w
.
- Parameters
-
[in] | self | The instance to be serialised. |
[in] | w | The writer to be provided with serialised data. |
- Returns
- The number of bytes written or a negative value on error.
- Precondition
self != NULL
-
w.self && w.vptr
◆ smolrtsp_scanf_header()
int smolrtsp_scanf_header |
( |
const SmolRTSP_HeaderMap *restrict |
headers, |
|
|
CharSlice99 |
key, |
|
|
const char *restrict |
fmt, |
|
|
|
... |
|
) |
| |
Attempts to parse a header.
- Parameters
-
[in] | headers | The header map to search key in. |
[in] | key | The header key to search for. |
[in] | fmt | The scanf- like format string. |
- Returns
- The number of scanned parameters or -1 if
key
is not found.
- Precondition
headers != NULL
-
fmt != NULL