SmolRTSP  0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
header_map.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <smolrtsp/priv/compiler_attrs.h>
9 #include <smolrtsp/types/error.h>
10 #include <smolrtsp/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 SmolRTSP_HeaderMap_from_array(...) \
24  ((SmolRTSP_HeaderMap){ \
25  .headers = __VA_ARGS__, \
26  .len = SLICE99_ARRAY_LEN((SmolRTSP_Header[])__VA_ARGS__), \
27  })
28 
32 #define SMOLRTSP_HEADER_MAP_CAPACITY 32
33 
37 typedef struct {
42 
46  size_t len;
48 
52 SmolRTSP_HeaderMap SmolRTSP_HeaderMap_empty(void) SMOLRTSP_PRIV_MUST_USE;
53 
69  const SmolRTSP_HeaderMap *restrict self, CharSlice99 key,
70  CharSlice99 *restrict value) SMOLRTSP_PRIV_MUST_USE;
71 
78  const SmolRTSP_HeaderMap *restrict self,
79  CharSlice99 key) SMOLRTSP_PRIV_MUST_USE;
80 
91  SmolRTSP_HeaderMap *restrict self, SmolRTSP_Header h);
92 
105  const SmolRTSP_HeaderMap *restrict self,
106  SmolRTSP_Writer w) SMOLRTSP_PRIV_MUST_USE;
107 
113 SmolRTSP_ParseResult SmolRTSP_HeaderMap_parse(
114  SmolRTSP_HeaderMap *restrict self,
115  CharSlice99 input) SMOLRTSP_PRIV_MUST_USE;
116 
124  const SmolRTSP_HeaderMap *restrict lhs,
125  const SmolRTSP_HeaderMap *restrict rhs) SMOLRTSP_PRIV_MUST_USE;
126 
136  SMOLRTSP_PRIV_MUST_USE;
137 
151  const SmolRTSP_HeaderMap *restrict headers, CharSlice99 key,
152  const char *restrict fmt, ...) SMOLRTSP_PRIV_MUST_USE
153  SMOLRTSP_PRIV_GCC_ATTR(format(scanf, 3, 4));
Possible parsing errors.
An RTSP header.
bool SmolRTSP_HeaderMap_contains_key(const SmolRTSP_HeaderMap *restrict self, CharSlice99 key) SMOLRTSP_PRIV_MUST_USE
Returns whether key is present in self.
ssize_t SmolRTSP_HeaderMap_serialize(const SmolRTSP_HeaderMap *restrict self, SmolRTSP_Writer w) SMOLRTSP_PRIV_MUST_USE
Serialises self into w.
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.
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.
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.
void SmolRTSP_HeaderMap_append(SmolRTSP_HeaderMap *restrict self, SmolRTSP_Header h)
Appends a new header to a header map.
SmolRTSP_ParseResult SmolRTSP_HeaderMap_parse(SmolRTSP_HeaderMap *restrict self, CharSlice99 input) SMOLRTSP_PRIV_MUST_USE
Parses data to self.
SmolRTSP_HeaderMap SmolRTSP_HeaderMap_empty(void) SMOLRTSP_PRIV_MUST_USE
Returns an empty header map suitable for further parsing.
#define SMOLRTSP_HEADER_MAP_CAPACITY
The maximum number of headers in SmolRTSP_HeaderMap.headers.
Definition: header_map.h:32
bool SmolRTSP_HeaderMap_eq(const SmolRTSP_HeaderMap *restrict lhs, const SmolRTSP_HeaderMap *restrict rhs) SMOLRTSP_PRIV_MUST_USE
Tests lhs and rhs for equality.
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