aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_rest_lib.h
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-02 16:32:36 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-02 16:32:36 +0000
commitbee208bcd6803829aa26c55a4c8e176a5f2c815f (patch)
tree6974bc9e94a1ec938b5376d2631233d2e75baf7d /src/include/gnunet_rest_lib.h
parentfc9b25be2dbe5392501dbc0b6659c1aa50809bc2 (diff)
downloadgnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.tar.gz
gnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.zip
- Refactor jsonapi into separate module
Diffstat (limited to 'src/include/gnunet_rest_lib.h')
-rw-r--r--src/include/gnunet_rest_lib.h168
1 files changed, 0 insertions, 168 deletions
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index a5afae2c9..ea254cc9b 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -35,12 +35,6 @@
35#include "microhttpd.h" 35#include "microhttpd.h"
36#include <jansson.h> 36#include <jansson.h>
37 37
38#define GNUNET_REST_JSONAPI_KEY_DATA "data"
39
40#define GNUNET_REST_JSONAPI_KEY_ID "id"
41
42#define GNUNET_REST_JSONAPI_KEY_TYPE "type"
43
44#define GNUNET_REST_HANDLER_END {NULL, NULL, NULL} 38#define GNUNET_REST_HANDLER_END {NULL, NULL, NULL}
45 39
46struct RestConnectionDataHandle 40struct RestConnectionDataHandle
@@ -86,168 +80,6 @@ typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
86 struct MHD_Response *resp, 80 struct MHD_Response *resp,
87 int status); 81 int status);
88 82
89
90/**
91 * Resource structs for JSON API
92 */
93struct JsonApiResource;
94
95/**
96 * Responses for JSON API
97 */
98struct JsonApiObject;
99
100/**
101 * Create a JSON API resource
102 *
103 * @param type the JSON API resource type
104 * @param id the JSON API resource id
105 * @return a new JSON API resource or NULL on error.
106 */
107struct JsonApiResource*
108GNUNET_REST_jsonapi_resource_new (const char *type, const char *id);
109
110/**
111 * Delete a JSON API resource
112 *
113 * @param res the JSON resource
114 * @param result Pointer where the resource should be stored
115 */
116void
117GNUNET_REST_jsonapi_resource_delete (struct JsonApiResource *resource);
118
119/**
120 * Add a JSON API attribute
121 *
122 * @param res the JSON resource
123 * @param key the key for the attribute
124 * @param json the json_t attribute to add
125 * @return #GNUNET_OK if added successfully
126 * #GNUNET_SYSERR if not
127 */
128int
129GNUNET_REST_jsonapi_resource_add_attr (const struct JsonApiResource *resource,
130 const char* key,
131 json_t *json);
132/**
133 * Read a JSON API attribute
134 *
135 * @param res the JSON resource
136 * @param key the key for the attribute
137 * @return the json attr
138 */
139json_t*
140GNUNET_REST_jsonapi_resource_read_attr (const struct JsonApiResource *resource,
141 const char* key);
142
143
144/**
145 * Check a JSON API resource id
146 *
147 * @param res the JSON resource
148 * @param id the expected id
149 * @return GNUNET_YES if id matches
150 */
151int
152GNUNET_REST_jsonapi_resource_check_id (const struct JsonApiResource *resource,
153 const char* id);
154
155
156/**
157 * Check a JSON API resource type
158 *
159 * @param res the JSON resource
160 * @param type the expected type
161 * @return GNUNET_YES if id matches
162 */
163int
164GNUNET_REST_jsonapi_resource_check_type (const struct JsonApiResource *resource,
165 const char* type);
166
167
168/**
169 * Create a JSON API primary data
170 *
171 * @param type the JSON API resource type
172 * @param id the JSON API resource id
173 * @return a new JSON API resource or NULL on error.
174 */
175struct JsonApiObject*
176GNUNET_REST_jsonapi_object_new ();
177
178
179/**
180 * Create a JSON API primary data from a string
181 *
182 * @param data the string of the JSON API data
183 * @return a new JSON API resource or NULL on error.
184 */
185struct JsonApiObject*
186GNUNET_REST_jsonapi_object_parse (const char* data);
187
188
189/**
190 * Delete a JSON API primary data
191 *
192 * @param type the JSON API resource type
193 * @param id the JSON API resource id
194 * @return a new JSON API resource or NULL on error.
195 */
196void
197GNUNET_REST_jsonapi_object_delete (struct JsonApiObject *resp);
198
199/**
200 * Add a JSON API resource to primary data
201 *
202 * @param data The JSON API data to add to
203 * @param res the JSON API resource to add
204 * @return the new number of resources
205 */
206void
207GNUNET_REST_jsonapi_object_resource_add (struct JsonApiObject *resp,
208 struct JsonApiResource *res);
209/**
210 * Get a JSON API object resource count
211 *
212 * @param resp the JSON API object
213 * @return the number of resources
214 */
215int
216GNUNET_REST_jsonapi_object_resource_count (struct JsonApiObject *resp);
217
218/**
219 * Get a JSON API object resource num
220 *
221 * @param resp the JSON API object
222 * @param num the number of the resource
223 * @return the resource
224 */
225struct JsonApiResource*
226GNUNET_REST_jsonapi_object_get_resource (struct JsonApiObject *resp, int num);
227
228
229/**
230 * Add a JSON API resource to primary data
231 *
232 * @param resp The JSON API data to add to
233 * @param res the JSON API resource to add
234 * @return the new number of resources
235 */
236void
237GNUNET_REST_jsonapi_data_resource_remove (struct JsonApiObject *resp,
238 struct JsonApiResource *res);
239
240/**
241 * String serialze jsonapi primary data
242 *
243 * @param data the JSON API primary data
244 * @param result where to store the result
245 * @return GNUNET_SYSERR on error else GNUNET_OK
246 */
247int
248GNUNET_REST_jsonapi_data_serialize (const struct JsonApiObject *resp,
249 char **result);
250
251/** 83/**
252 * Check if namespace is in URL. 84 * Check if namespace is in URL.
253 * 85 *