EVE 1.0
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  */
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  */
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  */
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  */
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  */
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  */
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
const struct http_content_type_t HttpContentTypeTable[]
Definition: instance.h:39
const char * String
Definition: types.h:62
void * DirectAddress
Definition: types.h:107
const char * String
Definition: types.h:50
const uint8_t HttpRequestCount
Definition: instance.h:30
const struct http_enum_cvt_t HttpReqTypeTable[]
Definition: instance.h:71
uint32_t Type
Definition: types.h:100
const struct http_enum_cvt_t HttpResourceTable[]
Definition: instance.h:55
uint16_t Length
Definition: types.h:51
uint16_t Flags
Definition: types.h:52
struct app_var_context_t * User
Definition: types.h:123
http_req_type_t
Definition: types.h:73
TOC module basic types.
uint16_t Length
Definition: types.h:63
uint16_t Value
Definition: types.h:64
http_content_type_flags_t
Definition: types.h:38
uint32_t Offset
Definition: types.h:105
void * Pointer
Definition: types.h:104
const uint8_t HttpStaticResourceCount
Definition: instance.h:7