aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2018-11-29 19:15:11 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2018-11-29 19:15:11 +0100
commita67b4de710264a1b18ee80f153dc5d9a806e4a85 (patch)
treee043dff64ef7ff9f1c2c07a45c780f71334e7966 /src
parente5d26483df95c0d4d73334a547bb8cfd0ba2c16b (diff)
downloadgnunet-a67b4de710264a1b18ee80f153dc5d9a806e4a85.tar.gz
gnunet-a67b4de710264a1b18ee80f153dc5d9a806e4a85.zip
JSON: Remove jsonapi headers
Diffstat (limited to 'src')
-rw-r--r--src/include/Makefile.am2
-rw-r--r--src/include/gnunet_jsonapi_lib.h355
-rw-r--r--src/include/gnunet_jsonapi_util.h64
-rw-r--r--src/rest-plugins/plugin_rest_reclaim.c2
4 files changed, 0 insertions, 423 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 9d0c4f8ea..fa29e9737 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -70,8 +70,6 @@ gnunetinclude_HEADERS = \
70 gnunet_identity_service.h \ 70 gnunet_identity_service.h \
71 gnunet_reclaim_service.h \ 71 gnunet_reclaim_service.h \
72 gnunet_json_lib.h \ 72 gnunet_json_lib.h \
73 gnunet_jsonapi_lib.h \
74 gnunet_jsonapi_util.h \
75 gnunet_load_lib.h \ 73 gnunet_load_lib.h \
76 gnunet_cadet_service.h \ 74 gnunet_cadet_service.h \
77 gnunet_microphone_lib.h \ 75 gnunet_microphone_lib.h \
diff --git a/src/include/gnunet_jsonapi_lib.h b/src/include/gnunet_jsonapi_lib.h
deleted file mode 100644
index 1dc89621b..000000000
--- a/src/include/gnunet_jsonapi_lib.h
+++ /dev/null
@@ -1,355 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2014, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18/**
19 * @file gnunet_jsonapi_lib.h
20 * @brief functions to parse jsonapi objects
21 * @author Martin Schanzenbach
22 */
23#ifndef GNUNET_JSONAPI_LIB_H
24#define GNUNET_JSONAPI_LIB_H
25
26#include "gnunet_util_lib.h"
27#include "gnunet_json_lib.h"
28
29#define GNUNET_JSONAPI_KEY_DATA "data"
30
31#define GNUNET_JSONAPI_KEY_ID "id"
32
33#define GNUNET_JSONAPI_KEY_TYPE "type"
34
35#define GNUNET_JSONAPI_KEY_META "meta"
36
37#define GNUNET_JSONAPI_KEY_ATTRIBUTES "attributes"
38
39#define GNUNET_JSONAPI_KEY_CODE "code"
40
41#define GNUNET_JSONAPI_KEY_TITLE "title"
42
43#define GNUNET_JSONAPI_KEY_DETAIL "detail"
44
45#define GNUNET_JSONAPI_KEY_SOURCE "source"
46
47#define GNUNET_JSONAPI_KEY_LINKS "links"
48
49#define GNUNET_JSONAPI_KEY_STATUS "status"
50
51#define GNUNET_JSONAPI_KEY_ERRORS "errors"
52
53/* ****************** JSONAPI parsing ******************* */
54
55struct GNUNET_JSONAPI_Relationship;
56
57struct GNUNET_JSONAPI_Error;
58
59struct GNUNET_JSONAPI_Resource;
60
61struct GNUNET_JSONAPI_Document;
62
63/**
64 * Specification for parsing a jsonapi relationship.
65 *
66 * @param jsonapi_obj where to store the jsonapi relationship
67 */
68struct GNUNET_JSON_Specification
69GNUNET_JSON_spec_jsonapi_relationship (struct GNUNET_JSONAPI_Relationship **jsonapi_obj);
70
71/**
72 * Specification for parsing a jsonapi error.
73 *
74 * @param jsonapi_obj where to store the jsonapi error
75 */
76struct GNUNET_JSON_Specification
77GNUNET_JSON_spec_jsonapi_error (struct GNUNET_JSONAPI_Error **jsonapi_obj);
78
79/**
80 * Specification for parsing a jsonapi resource.
81 *
82 * @param jsonapi_obj where to store the jsonapi resource
83 */
84struct GNUNET_JSON_Specification
85GNUNET_JSON_spec_jsonapi_resource (struct GNUNET_JSONAPI_Resource **jsonapi_obj);
86
87/**
88 * Specification for parsing a jsonapi object.
89 *
90 * @param jsonapi_obj where to store the jsonapi object
91 */
92struct GNUNET_JSON_Specification
93GNUNET_JSON_spec_jsonapi_document (struct GNUNET_JSONAPI_Document **jsonapi_obj);
94
95/**
96 * Delete a JSON API relationship
97 *
98 * @param res the JSON resource
99 * @param result Pointer where the resource should be stored
100 */
101void
102GNUNET_JSONAPI_relationship_delete (struct GNUNET_JSONAPI_Relationship *rel);
103
104
105/****************** jsonapi Error API ********************/
106
107/**
108 * Create a JSON API error
109 *
110 * @param res the JSON error
111 */
112struct GNUNET_JSONAPI_Error*
113GNUNET_JSONAPI_error_new (const char *id,
114 const char *status,
115 const char *code,
116 const char *title,
117 const char *detail,
118 json_t *links,
119 json_t *source,
120 json_t *meta);
121
122/**
123 * Delete a JSON API error
124 *
125 * @param res the JSON error
126 */
127void
128GNUNET_JSONAPI_error_delete (struct GNUNET_JSONAPI_Error *error);
129
130
131/**
132 * Add a JSON API error to document
133 *
134 * @param data The JSON API document to add to
135 * @param res the JSON API error to add
136 * @return the new number of resources
137 */
138void
139GNUNET_JSONAPI_document_error_add (struct GNUNET_JSONAPI_Document *doc,
140 struct GNUNET_JSONAPI_Error *err);
141
142/**
143 * String serialze jsonapi error to json
144 *
145 * @param data the JSON API error
146 * @param result where to store the result
147 * @return GNUNET_SYSERR on error else GNUNET_OK
148 */
149int
150GNUNET_JSONAPI_error_to_json (const struct GNUNET_JSONAPI_Error *err,
151 json_t **result);
152
153/**
154 * Parse json to error object
155 *
156 * @param err_json JSON object
157 * @param[out] err error object
158 * @return GNUNET_OK on success
159 */
160int
161GNUNET_JSONAPI_json_to_error (json_t *err_json,
162 struct GNUNET_JSONAPI_Error **err);
163
164/****************** jsonapi Resource API ********************/
165
166/**
167 * Create a JSON API resource
168 *
169 * @param type the JSON API resource type
170 * @param id the JSON API resource id
171 * @return a new JSON API resource or NULL on error.
172 */
173struct GNUNET_JSONAPI_Resource*
174GNUNET_JSONAPI_resource_new (const char *type, const char *id);
175
176
177/**
178 * Delete a JSON API resource
179 *
180 * @param res the JSON resource
181 * @param result Pointer where the resource should be stored
182 */
183void
184GNUNET_JSONAPI_resource_delete (struct GNUNET_JSONAPI_Resource *resource);
185
186
187/**
188 * String serialze jsonapi to json
189 *
190 * @param data the JSON API resource
191 * @param result where to store the result
192 * @return GNUNET_SYSERR on error else GNUNET_OK
193 */
194int
195GNUNET_JSONAPI_resource_to_json (const struct GNUNET_JSONAPI_Resource *res,
196 json_t **result);
197
198
199/**
200 * Parse json to resource object
201 *
202 * @param res_json JSON object
203 * @param[out] res resource object
204 * @return GNUNET_OK on success
205 */
206int
207GNUNET_JSONAPI_json_to_resource (json_t *res_json,
208 struct GNUNET_JSONAPI_Resource **res);
209
210
211/**
212 * Add a JSON API attribute
213 *
214 * @param res the JSON resource
215 * @param key the key for the attribute
216 * @param json the json_t attribute to add
217 * @return #GNUNET_OK if added successfully
218 * #GNUNET_SYSERR if not
219 */
220int
221GNUNET_JSONAPI_resource_add_attr (struct GNUNET_JSONAPI_Resource *resource,
222 const char* key,
223 json_t *json);
224/**
225 * Read a JSON API attribute
226 *
227 * @param res the JSON resource
228 * @param key the key for the attribute
229 * @return the json attr
230 */
231json_t*
232GNUNET_JSONAPI_resource_read_attr (const struct GNUNET_JSONAPI_Resource *resource,
233 const char* key);
234
235
236/**
237 * Check a JSON API resource id
238 *
239 * @param res the JSON resource
240 * @param id the expected id
241 * @return GNUNET_YES if id matches
242 */
243int
244GNUNET_JSONAPI_resource_check_id (const struct GNUNET_JSONAPI_Resource *resource,
245 const char* id);
246
247/**
248 * Check a JSON API resource id
249 *
250 * @param res the JSON resource
251 * @return the resource id
252 */
253const char*
254GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource);
255
256
257/**
258 * Check a JSON API resource type
259 *
260 * @param res the JSON resource
261 * @param type the expected type
262 * @return GNUNET_YES if id matches
263 */
264int
265GNUNET_JSONAPI_resource_check_type (const struct GNUNET_JSONAPI_Resource *resource,
266 const char* type);
267
268/****************** jsonapi Document API ********************/
269
270/**
271 * Create a JSON API primary data
272 *
273 * @param type the JSON API resource type
274 * @param id the JSON API resource id
275 * @return a new JSON API resource or NULL on error.
276 */
277struct GNUNET_JSONAPI_Document*
278GNUNET_JSONAPI_document_new ();
279
280
281/**
282 * Delete a JSON API primary data
283 *
284 * @param type the JSON API resource type
285 * @param id the JSON API resource id
286 * @return a new JSON API resource or NULL on error.
287 */
288void
289GNUNET_JSONAPI_document_delete (struct GNUNET_JSONAPI_Document *resp);
290
291/**
292 * String serialze jsonapi primary data
293 *
294 * @param data the JSON API primary data
295 * @param result where to store the result
296 * @return GNUNET_SYSERR on error else GNUNET_OK
297 */
298int
299GNUNET_JSONAPI_document_to_json (const struct GNUNET_JSONAPI_Document *doc,
300 json_t **root_json);
301
302/**
303 * Add a JSON API resource to primary data
304 *
305 * @param data The JSON API data to add to
306 * @param res the JSON API resource to add
307 * @return the new number of resources
308 */
309void
310GNUNET_JSONAPI_document_resource_add (struct GNUNET_JSONAPI_Document *resp,
311 struct GNUNET_JSONAPI_Resource *res);
312/**
313 * Get a JSON API object resource count
314 *
315 * @param resp the JSON API object
316 * @return the number of resources
317 */
318int
319GNUNET_JSONAPI_document_resource_count (struct GNUNET_JSONAPI_Document *resp);
320
321/**
322 * Get a JSON API object resource num
323 *
324 * @param resp the JSON API object
325 * @param num the number of the resource
326 * @return the resource
327 */
328struct GNUNET_JSONAPI_Resource*
329GNUNET_JSONAPI_document_get_resource (struct GNUNET_JSONAPI_Document *resp, int num);
330
331
332/**
333 * Add a JSON API resource to primary data
334 *
335 * @param resp The JSON API data to add to
336 * @param res the JSON API resource to add
337 * @return the new number of resources
338 */
339void
340GNUNET_JSONAPI_document_resource_remove (struct GNUNET_JSONAPI_Document *resp,
341 struct GNUNET_JSONAPI_Resource *res);
342
343/**
344 * String serialze jsonapi primary data
345 *
346 * @param data the JSON API primary data
347 * @param result where to store the result
348 * @return GNUNET_SYSERR on error else GNUNET_OK
349 */
350int
351GNUNET_JSONAPI_document_serialize (const struct GNUNET_JSONAPI_Document *resp,
352 char **result);
353
354/* end of gnunet_jsonapi_lib.h */
355#endif
diff --git a/src/include/gnunet_jsonapi_util.h b/src/include/gnunet_jsonapi_util.h
deleted file mode 100644
index 02c82e844..000000000
--- a/src/include/gnunet_jsonapi_util.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2014, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18/**
19 * @file gnunet_jsonapi_util.h
20 * @brief utility functions for jsonapi
21 * @author Martin Schanzenbach
22 */
23#ifndef GNUNET_JSONAPI_UTIL_H
24#define GNUNET_JSONAPI_UTIL_H
25
26#include "gnunet_util_lib.h"
27#include "gnunet_rest_lib.h"
28#include "gnunet_jsonapi_lib.h"
29
30
31/**
32 * Check rest request for validity
33 *
34 * @param req handle to the request
35 * @return GNUNET_OK if valid
36 */
37int
38GNUNET_JSONAPI_check_request_acceptable (struct GNUNET_REST_RequestHandle *req);
39
40/**
41 * Check rest request for validity
42 *
43 * @param req handle to the request
44 * @return GNUNET_OK if valid
45 */
46int
47GNUNET_JSONAPI_check_request_supported (struct GNUNET_REST_RequestHandle *req);
48
49
50/**
51 * Handle jsonapi rest request. Checks request headers for jsonapi compliance
52 *
53 * @param req rest request handle
54 * @param handler rest request handlers
55 * @param cls closure
56 * @return GNUNET_OK if successful
57 */
58int
59GNUNET_JSONAPI_handle_request (struct GNUNET_REST_RequestHandle *req,
60 const struct GNUNET_REST_RequestHandler *handlers,
61 struct GNUNET_REST_RequestHandlerError *err,
62 void *cls);
63
64#endif
diff --git a/src/rest-plugins/plugin_rest_reclaim.c b/src/rest-plugins/plugin_rest_reclaim.c
index ccc2d894b..3919e8ab1 100644
--- a/src/rest-plugins/plugin_rest_reclaim.c
+++ b/src/rest-plugins/plugin_rest_reclaim.c
@@ -30,8 +30,6 @@
30#include "gnunet_gnsrecord_lib.h" 30#include "gnunet_gnsrecord_lib.h"
31#include "gnunet_namestore_service.h" 31#include "gnunet_namestore_service.h"
32#include "gnunet_rest_lib.h" 32#include "gnunet_rest_lib.h"
33#include "gnunet_jsonapi_lib.h"
34#include "gnunet_jsonapi_util.h"
35#include "microhttpd.h" 33#include "microhttpd.h"
36#include <jansson.h> 34#include <jansson.h>
37#include <inttypes.h> 35#include <inttypes.h>