EVE 1.0
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
types.h
Go to the documentation of this file.
1
#ifndef EVE_HTTP_TYPES_H_INCLUDED
2
#define EVE_HTTP_TYPES_H_INCLUDED
3
4
/**
5
* @file http/types.h
6
* @brief HTTP module basic types
7
*/
8
9
#include <
toc/types.h
>
10
11
/**
12
* \addtogroup http
13
* \{
14
*/
15
16
/**
17
* Convert a string literal to a string / length pair
18
*
19
* \param x the string literal
20
*/
21
#define CSTRING(x) (x), (sizeof(x) - 1)
22
23
/**
24
* String convert entry initializer macro.
25
* \param v numerical identifier
26
* \param s corresponding string literal
27
*/
28
#define ENUM_CVT_ENTRY(v, s) { \
29
.String = (s), \
30
.Length = sizeof(s) - 1, \
31
.Value = (v) \
32
}
33
34
35
/**
36
* Content type flags for fine tunung of HTTP response headers
37
*/
38
enum
http_content_type_flags_t
39
{
40
FILE_FLAGS_DEFAULT
= 0,
/**< Defailt flags, no options set */
41
FILE_FLAGS_GZIP
= (1 << 0),
/**< Set "Content-Encoding: gzip" HTTP header */
42
FILE_FLAGS__FIRST_SYSTEM
= (1 << 1),
/**< First system flag */
43
};
44
45
/**
46
* Entry of \ref HttpContentTypeTable table.
47
*/
48
struct
http_content_type_t
49
{
50
const
char
*
String
;
/**< Pointer to the content-type string */
51
uint16_t
Length
;
/**< Length of the content-type string */
52
uint16_t
Flags
;
/**< \ref http_content_type_flags_t */
53
};
54
55
/**
56
* String convert table entry.
57
*
58
* The entry sets association between a string and a coressponding numerical identifier.
59
*/
60
struct
http_enum_cvt_t
61
{
62
const
char
*
String
;
/**< Pointer to a string */
63
uint16_t
Length
;
/**< Length of the string */
64
uint16_t
Value
;
/**< Numerical identifier associated with the string */
65
};
66
67
/**
68
* HTTP request identifier type
69
*
70
* The engine supports up to 254 unique requests,
71
* each of them is mapped to the corresponding ID.
72
*/
73
enum
http_req_type_t
74
{
75
HTTP_REQ_TOC
,
/**< /json/toc.json */
76
HTTP_REQ_GET
,
/**< /json/get.json */
77
HTTP_REQ_SET
,
/**< /json/set.json */
78
HTTP_REQ_PULL
,
/**< /json/pull.json?Resource */
79
HTTP_REQ_PUSH
,
/**< /json/push.json?Resource */
80
HTTP_REQ_STREAM
,
/**< /json/stream.json */
81
HTTP_REQ__SYSTEM_END
=
HTTP_REQ_STREAM
,
/**< Marks where the system resources ends */
82
HTTP_REQ_UNKNOWN
= 255,
/**< Invalid or unknown request */
83
};
84
85
/**
86
* System part of HTTP resource identifier type
87
*
88
* The only defined resource on the system level is an unknown one.
89
*/
90
enum
91
{
92
HTTP_RESOURCE_UNKNOWN
= 255,
/**< Unknown or invalid resource */
93
};
94
95
/**
96
* Pointer to the data in a JSON segment
97
*/
98
struct
toc_segment_ptr_t
99
{
100
uint32_t
Type
;
/**< Type of segment, typically enum toc_segment_type_t
101
* and (user-defined) app_segment_type_t */
102
union
103
{
104
void
*
Pointer
;
/**< Pointer representation of the address */
105
uint32_t
Offset
;
/**< Offset representation of the address */
106
} Address;
/**< Address of a variable in the segment */
107
void
*
DirectAddress
;
/**< Pointer to the dynamically allocated segment start */
108
109
struct
toc_blob_t
Blob;
110
};
111
112
/**
113
* User-defined context of TOC GET or set operations
114
*/
115
struct
app_var_context_t;
116
117
/**
118
* System context of TOC SET operations
119
*/
120
struct
toc_var_context_t
121
{
122
struct
toc_segment_ptr_t
Cursor;
/**< Current pointer on the segment */
123
struct
app_var_context_t *
User
;
/**< User data */
124
};
125
126
/**
127
* Number of elements in the HttpReqTypeTable table
128
*/
129
extern
const
uint8_t
HttpRequestCount
;
/* = HTTP_REQ__COUNT */
130
131
/**
132
* Number of elements in the HttpResourceTable table
133
*/
134
extern
const
uint8_t
HttpStaticResourceCount
;
/* = HTTP_RESOURCE__COUNT */
135
136
/**
137
* User-defined content type mapping table
138
*/
139
extern
const
struct
http_content_type_t
HttpContentTypeTable
[
/*HTTP_RESOURCE__COUNT*/
];
140
141
/**
142
* User-defined request to ID mapping table
143
*/
144
extern
const
struct
http_enum_cvt_t
HttpReqTypeTable
[
/*HTTP_REQ__COUNT*/
];
145
146
/**
147
* User-defined resource to ID mapping table
148
*/
149
extern
const
struct
http_enum_cvt_t
HttpResourceTable
[
/*HTTP_RESOURCE__COUNT*/
];
150
151
/** @} */
152
153
#endif
HttpContentTypeTable
const struct http_content_type_t HttpContentTypeTable[]
Definition:
instance.h:39
HTTP_REQ_TOC
Definition:
types.h:75
FILE_FLAGS_DEFAULT
Definition:
types.h:40
http_enum_cvt_t::String
const char * String
Definition:
types.h:62
toc_segment_ptr_t::DirectAddress
void * DirectAddress
Definition:
types.h:107
http_content_type_t::String
const char * String
Definition:
types.h:50
HTTP_REQ_SET
Definition:
types.h:77
HttpRequestCount
const uint8_t HttpRequestCount
Definition:
instance.h:30
HTTP_REQ_STREAM
Definition:
types.h:80
FILE_FLAGS__FIRST_SYSTEM
Definition:
types.h:42
HttpReqTypeTable
const struct http_enum_cvt_t HttpReqTypeTable[]
Definition:
instance.h:71
toc_segment_ptr_t::Type
uint32_t Type
Definition:
types.h:100
HttpResourceTable
const struct http_enum_cvt_t HttpResourceTable[]
Definition:
instance.h:55
http_content_type_t::Length
uint16_t Length
Definition:
types.h:51
http_content_type_t::Flags
uint16_t Flags
Definition:
types.h:52
toc_var_context_t::User
struct app_var_context_t * User
Definition:
types.h:123
FILE_FLAGS_GZIP
Definition:
types.h:41
http_req_type_t
http_req_type_t
Definition:
types.h:73
types.h
TOC module basic types.
HTTP_REQ_UNKNOWN
Definition:
types.h:82
http_enum_cvt_t
Definition:
types.h:60
http_enum_cvt_t::Length
uint16_t Length
Definition:
types.h:63
toc_blob_t
Definition:
types.h:64
HTTP_REQ_PUSH
Definition:
types.h:79
http_enum_cvt_t::Value
uint16_t Value
Definition:
types.h:64
toc_var_context_t
Definition:
types.h:120
HTTP_REQ__SYSTEM_END
Definition:
types.h:81
HTTP_RESOURCE_UNKNOWN
Definition:
types.h:92
http_content_type_flags_t
http_content_type_flags_t
Definition:
types.h:38
http_content_type_t
Definition:
types.h:48
toc_segment_ptr_t::Offset
uint32_t Offset
Definition:
types.h:105
toc_segment_ptr_t::Pointer
void * Pointer
Definition:
types.h:104
toc_segment_ptr_t
Definition:
types.h:98
HTTP_REQ_PULL
Definition:
types.h:78
HttpStaticResourceCount
const uint8_t HttpStaticResourceCount
Definition:
instance.h:7
HTTP_REQ_GET
Definition:
types.h:76
Core
Include
http
types.h
Generated on Thu Mar 30 2017 10:16:56 for EVE 1.0 by
1.8.11