diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-03-26 16:40:36 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-03-26 16:40:36 +0000 |
commit | 9cbff235e16bb2888aca2ba492f46bca9351142d (patch) | |
tree | 35ad6c7ff0751026c3995cc606fe2d2f5ea6bba1 /src/rest | |
parent | 726b28a61c858b4b251e4a0a006e4021b01886c0 (diff) | |
download | gnunet-9cbff235e16bb2888aca2ba492f46bca9351142d.tar.gz gnunet-9cbff235e16bb2888aca2ba492f46bca9351142d.zip |
-add rename
Diffstat (limited to 'src/rest')
-rw-r--r-- | src/rest/rest.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/rest/rest.c b/src/rest/rest.c index f3251db1a..225798db9 100644 --- a/src/rest/rest.c +++ b/src/rest/rest.c | |||
@@ -188,7 +188,7 @@ int | |||
188 | GNUNET_REST_jsonapi_resource_check_id (const struct JsonApiResource *resource, | 188 | GNUNET_REST_jsonapi_resource_check_id (const struct JsonApiResource *resource, |
189 | const char* id) | 189 | const char* id) |
190 | { | 190 | { |
191 | return check_resource_attr_str (resource, id, GNUNET_REST_JSONAPI_KEY_ID); | 191 | return check_resource_attr_str (resource, GNUNET_REST_JSONAPI_KEY_ID, id); |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
@@ -203,7 +203,7 @@ int | |||
203 | GNUNET_REST_jsonapi_resource_check_type (const struct JsonApiResource *resource, | 203 | GNUNET_REST_jsonapi_resource_check_type (const struct JsonApiResource *resource, |
204 | const char* type) | 204 | const char* type) |
205 | { | 205 | { |
206 | return check_resource_attr_str (resource, type, GNUNET_REST_JSONAPI_KEY_TYPE); | 206 | return check_resource_attr_str (resource, GNUNET_REST_JSONAPI_KEY_TYPE, type); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
@@ -233,10 +233,8 @@ add_json_resource (struct JsonApiObject *obj, | |||
233 | 233 | ||
234 | id_json = json_object_get (res_json, GNUNET_REST_JSONAPI_KEY_ID); | 234 | id_json = json_object_get (res_json, GNUNET_REST_JSONAPI_KEY_ID); |
235 | type_json = json_object_get (res_json, GNUNET_REST_JSONAPI_KEY_TYPE); | 235 | type_json = json_object_get (res_json, GNUNET_REST_JSONAPI_KEY_TYPE); |
236 | |||
237 | if (!json_is_string (id_json) || !json_is_string (type_json)) | 236 | if (!json_is_string (id_json) || !json_is_string (type_json)) |
238 | return; | 237 | return; |
239 | |||
240 | res = GNUNET_new (struct JsonApiResource); | 238 | res = GNUNET_new (struct JsonApiResource); |
241 | res->next = NULL; | 239 | res->next = NULL; |
242 | res->prev = NULL; | 240 | res->prev = NULL; |
@@ -259,7 +257,6 @@ GNUNET_REST_jsonapi_object_parse (const char* data) | |||
259 | json_error_t error; | 257 | json_error_t error; |
260 | int res_count = 0; | 258 | int res_count = 0; |
261 | int i; | 259 | int i; |
262 | |||
263 | if (NULL == data) | 260 | if (NULL == data) |
264 | return NULL; | 261 | return NULL; |
265 | root_json = json_loads (data, 0, &error); | 262 | root_json = json_loads (data, 0, &error); |
@@ -287,7 +284,7 @@ GNUNET_REST_jsonapi_object_parse (const char* data) | |||
287 | add_json_resource (result, json_array_get (data_json, i)); | 284 | add_json_resource (result, json_array_get (data_json, i)); |
288 | } | 285 | } |
289 | json_decref (root_json); | 286 | json_decref (root_json); |
290 | if (0 == res_count) | 287 | if (0 == result->res_count) |
291 | { | 288 | { |
292 | GNUNET_free (result); | 289 | GNUNET_free (result); |
293 | result = NULL; | 290 | result = NULL; |
@@ -366,8 +363,8 @@ GNUNET_REST_jsonapi_object_get_resource (struct JsonApiObject *resp, int num) | |||
366 | struct JsonApiResource *res; | 363 | struct JsonApiResource *res; |
367 | int i; | 364 | int i; |
368 | 365 | ||
369 | if ((0 < resp->res_count) && | 366 | if ((0 == resp->res_count) || |
370 | (num < resp->res_count)) | 367 | (num >= resp->res_count)) |
371 | return NULL; | 368 | return NULL; |
372 | res = resp->res_list_head; | 369 | res = resp->res_list_head; |
373 | for (i = 0; i < num; i++) | 370 | for (i = 0; i < num; i++) |
@@ -505,11 +502,11 @@ GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | |||
505 | for (i = 0; i < count; i++) | 502 | for (i = 0; i < count; i++) |
506 | { | 503 | { |
507 | if (0 != strcasecmp (conn->method, handlers[i].method)) | 504 | if (0 != strcasecmp (conn->method, handlers[i].method)) |
508 | break; | 505 | continue; |
509 | if (strlen (url) < strlen (handlers[i].namespace)) | 506 | if (strlen (url) < strlen (handlers[i].namespace)) |
510 | break; | 507 | continue; |
511 | if (GNUNET_NO == GNUNET_REST_namespace_match (url, handlers[i].namespace)) | 508 | if (GNUNET_NO == GNUNET_REST_namespace_match (url, handlers[i].namespace)) |
512 | break; | 509 | continue; |
513 | //Match | 510 | //Match |
514 | handlers[i].proc (conn, (const char*)url, cls); | 511 | handlers[i].proc (conn, (const char*)url, cls); |
515 | GNUNET_free (url); | 512 | GNUNET_free (url); |