SmolRTSP  0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
error.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <smolrtsp/writer.h>
9 
10 #include <stdbool.h>
11 #include <stddef.h>
12 
13 #include <datatype99.h>
14 #include <slice99.h>
15 
16 #include <smolrtsp/priv/compiler_attrs.h>
17 
21 typedef enum {
26 
31 
37 
41 const char *
42 SmolRTSP_ParseType_str(SmolRTSP_ParseType self) SMOLRTSP_PRIV_MUST_USE;
43 
65 // clang-format off
67  SmolRTSP_ParseError,
68  (SmolRTSP_ParseError_ContentLength, CharSlice99),
69  (SmolRTSP_ParseError_StrMismatch, CharSlice99, CharSlice99),
70  (SmolRTSP_ParseError_TypeMismatch, SmolRTSP_ParseType, CharSlice99),
71  (SmolRTSP_ParseError_HeaderMapOverflow),
72  (SmolRTSP_ParseError_MissingCSeq),
73  (SmolRTSP_ParseError_InvalidCSeq, CharSlice99)
74 );
75 // clang-format on
76 
87 int SmolRTSP_ParseError_print(SmolRTSP_ParseError self, SmolRTSP_Writer w)
88  SMOLRTSP_PRIV_MUST_USE;
89 
102 // clang-format off
104  SmolRTSP_ParseStatus,
105  (SmolRTSP_ParseStatus_Complete, size_t),
106  (SmolRTSP_ParseStatus_Partial)
107 );
108 // clang-format on
109 
113 bool SmolRTSP_ParseStatus_is_complete(SmolRTSP_ParseStatus self)
114  SMOLRTSP_PRIV_MUST_USE;
115 
119 bool SmolRTSP_ParseStatus_is_partial(SmolRTSP_ParseStatus self)
120  SMOLRTSP_PRIV_MUST_USE;
121 
128 // clang-format off
130  SmolRTSP_ParseResult,
131  (SmolRTSP_ParseResult_Success, SmolRTSP_ParseStatus),
132  (SmolRTSP_ParseResult_Failure, SmolRTSP_ParseError)
133 );
134 // clang-format on
135 
139 SmolRTSP_ParseResult SmolRTSP_ParseResult_partial(void) SMOLRTSP_PRIV_MUST_USE;
140 
145 SmolRTSP_ParseResult
146 SmolRTSP_ParseResult_complete(size_t offset) SMOLRTSP_PRIV_MUST_USE;
147 
151 bool SmolRTSP_ParseResult_is_success(SmolRTSP_ParseResult self)
152  SMOLRTSP_PRIV_MUST_USE;
153 
157 bool SmolRTSP_ParseResult_is_failure(SmolRTSP_ParseResult self)
158  SMOLRTSP_PRIV_MUST_USE;
159 
163 bool SmolRTSP_ParseResult_is_partial(SmolRTSP_ParseResult self)
164  SMOLRTSP_PRIV_MUST_USE;
165 
169 bool SmolRTSP_ParseResult_is_complete(SmolRTSP_ParseResult self)
170  SMOLRTSP_PRIV_MUST_USE;
bool SmolRTSP_ParseStatus_is_complete(SmolRTSP_ParseStatus self) SMOLRTSP_PRIV_MUST_USE
Returns whether self is complete.
bool SmolRTSP_ParseResult_is_success(SmolRTSP_ParseResult self) SMOLRTSP_PRIV_MUST_USE
Returns whether self is successful.
int SmolRTSP_ParseError_print(SmolRTSP_ParseError self, SmolRTSP_Writer w) SMOLRTSP_PRIV_MUST_USE
Prints self into w.
SmolRTSP_ParseResult SmolRTSP_ParseResult_partial(void) SMOLRTSP_PRIV_MUST_USE
Creates a successful and partial parse result.
const char * SmolRTSP_ParseType_str(SmolRTSP_ParseType self) SMOLRTSP_PRIV_MUST_USE
Returns a string representation of self.
SmolRTSP_ParseResult SmolRTSP_ParseResult_complete(size_t offset) SMOLRTSP_PRIV_MUST_USE
Creates a successful and complete parse result with the byte offset offset (from the beginning of inp...
bool SmolRTSP_ParseResult_is_partial(SmolRTSP_ParseResult self) SMOLRTSP_PRIV_MUST_USE
Returns whether self is both successful and partial.
bool SmolRTSP_ParseStatus_is_partial(SmolRTSP_ParseStatus self) SMOLRTSP_PRIV_MUST_USE
Returns whether self is partial.
bool SmolRTSP_ParseResult_is_complete(SmolRTSP_ParseResult self) SMOLRTSP_PRIV_MUST_USE
The same as SmolRTSP_ParseResult_is_partial but for a complete result.
datatype99(SmolRTSP_ParseError,(SmolRTSP_ParseError_ContentLength, CharSlice99),(SmolRTSP_ParseError_StrMismatch, CharSlice99, CharSlice99),(SmolRTSP_ParseError_TypeMismatch, SmolRTSP_ParseType, CharSlice99),(SmolRTSP_ParseError_HeaderMapOverflow),(SmolRTSP_ParseError_MissingCSeq),(SmolRTSP_ParseError_InvalidCSeq, CharSlice99))
An error that might occur during parsing.
SmolRTSP_ParseType
Types of data that can be failed to parse.
Definition: error.h:21
@ SmolRTSP_ParseType_Int
An integer (-34, 0, 123).
Definition: error.h:25
@ SmolRTSP_ParseType_HeaderName
A header name (Content-Length, Authorization).
Definition: error.h:35
@ SmolRTSP_ParseType_Ident
An identifier (abc).
Definition: error.h:30
bool SmolRTSP_ParseResult_is_failure(SmolRTSP_ParseResult self) SMOLRTSP_PRIV_MUST_USE
Returns whether self is a failure.
The writer interface.