diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-06-18 20:04:18 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-06-18 20:04:18 +0000 |
commit | 577d21f282478d36c8665e0a7a2d2ee07bddd56d (patch) | |
tree | 26f5a27192b873b63fbafb7fae0ffd86e4fc3a25 /src | |
parent | 229e7fbe49b1a1ab7121a57af6e241500c09c1bf (diff) | |
download | gnunet-577d21f282478d36c8665e0a7a2d2ee07bddd56d.tar.gz gnunet-577d21f282478d36c8665e0a7a2d2ee07bddd56d.zip |
-fix
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_jsonapi_lib.h | 12 | ||||
-rw-r--r-- | src/jsonapi/jsonapi_document.c | 1 | ||||
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 29 |
3 files changed, 20 insertions, 22 deletions
diff --git a/src/include/gnunet_jsonapi_lib.h b/src/include/gnunet_jsonapi_lib.h index ce41c33f1..f95bff836 100644 --- a/src/include/gnunet_jsonapi_lib.h +++ b/src/include/gnunet_jsonapi_lib.h | |||
@@ -277,18 +277,6 @@ GNUNET_JSONAPI_document_new (); | |||
277 | 277 | ||
278 | 278 | ||
279 | /** | 279 | /** |
280 | * Create a JSON API primary data from a string | ||
281 | * | ||
282 | * @param data the string of the JSON API data | ||
283 | * @param Pointer where to store new jsonapi Object. | ||
284 | * @return GNUNET_OK on success | ||
285 | */ | ||
286 | int | ||
287 | GNUNET_JSONAPI_document_parse (const char* data, | ||
288 | struct GNUNET_JSONAPI_Document** obj); | ||
289 | |||
290 | |||
291 | /** | ||
292 | * Delete a JSON API primary data | 280 | * Delete a JSON API primary data |
293 | * | 281 | * |
294 | * @param type the JSON API resource type | 282 | * @param type the JSON API resource type |
diff --git a/src/jsonapi/jsonapi_document.c b/src/jsonapi/jsonapi_document.c index faf0bd831..600b7ee6a 100644 --- a/src/jsonapi/jsonapi_document.c +++ b/src/jsonapi/jsonapi_document.c | |||
@@ -408,4 +408,3 @@ GNUNET_JSON_spec_jsonapi_document (struct GNUNET_JSONAPI_Document **jsonapi_obje | |||
408 | return ret; | 408 | return ret; |
409 | } | 409 | } |
410 | 410 | ||
411 | |||
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index 42959bed8..78b6398c6 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -723,8 +723,14 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
723 | struct GNUNET_JSONAPI_Document *json_obj; | 723 | struct GNUNET_JSONAPI_Document *json_obj; |
724 | struct GNUNET_JSONAPI_Resource *json_res; | 724 | struct GNUNET_JSONAPI_Resource *json_res; |
725 | json_t *records_json; | 725 | json_t *records_json; |
726 | json_t *data_js; | ||
727 | json_error_t err; | ||
726 | char term_data[handle->rest_handle->data_size+1]; | 728 | char term_data[handle->rest_handle->data_size+1]; |
727 | 729 | struct GNUNET_JSON_Specification docspec[] = { | |
730 | GNUNET_JSON_spec_jsonapi_document (&json_obj), | ||
731 | GNUNET_JSON_spec_end() | ||
732 | }; | ||
733 | |||
728 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) | 734 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) |
729 | { | 735 | { |
730 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 736 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -741,8 +747,13 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
741 | memcpy (term_data, | 747 | memcpy (term_data, |
742 | handle->rest_handle->data, | 748 | handle->rest_handle->data, |
743 | handle->rest_handle->data_size); | 749 | handle->rest_handle->data_size); |
744 | GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_document_parse (term_data, | 750 | data_js = json_loads (term_data, |
745 | &json_obj)); | 751 | JSON_DECODE_ANY, |
752 | &err); | ||
753 | GNUNET_assert (GNUNET_OK == | ||
754 | GNUNET_JSON_parse (data_js, docspec, | ||
755 | NULL, NULL)); | ||
756 | json_decref (data_js); | ||
746 | if (NULL == json_obj) | 757 | if (NULL == json_obj) |
747 | { | 758 | { |
748 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 759 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -762,7 +773,7 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
762 | } | 773 | } |
763 | json_res = GNUNET_JSONAPI_document_get_resource (json_obj, 0); | 774 | json_res = GNUNET_JSONAPI_document_get_resource (json_obj, 0); |
764 | if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res, | 775 | if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res, |
765 | GNUNET_REST_JSONAPI_NAMESTORE_RECORD)) | 776 | GNUNET_REST_JSONAPI_NAMESTORE_RECORD)) |
766 | { | 777 | { |
767 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 778 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
768 | "Unsupported JSON data type\n"); | 779 | "Unsupported JSON data type\n"); |
@@ -774,7 +785,7 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
774 | } | 785 | } |
775 | handle->name = GNUNET_strdup (GNUNET_JSONAPI_resource_get_id (json_res)); | 786 | handle->name = GNUNET_strdup (GNUNET_JSONAPI_resource_get_id (json_res)); |
776 | records_json = GNUNET_JSONAPI_resource_read_attr (json_res, | 787 | records_json = GNUNET_JSONAPI_resource_read_attr (json_res, |
777 | GNUNET_REST_JSONAPI_NAMESTORE_RECORD); | 788 | GNUNET_REST_JSONAPI_NAMESTORE_RECORD); |
778 | if (NULL == records_json) | 789 | if (NULL == records_json) |
779 | { | 790 | { |
780 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 791 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -817,10 +828,10 @@ namestore_zkey_response (void *cls, | |||
817 | { | 828 | { |
818 | name_json = json_string (label); | 829 | name_json = json_string (label); |
819 | json_res = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_NAMESTORE_REVINFO, | 830 | json_res = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_NAMESTORE_REVINFO, |
820 | handle->zkey_str); | 831 | handle->zkey_str); |
821 | GNUNET_JSONAPI_resource_add_attr (json_res, | 832 | GNUNET_JSONAPI_resource_add_attr (json_res, |
822 | GNUNET_REST_JSONAPI_NAMESTORE_NAME, | 833 | GNUNET_REST_JSONAPI_NAMESTORE_NAME, |
823 | name_json); | 834 | name_json); |
824 | GNUNET_JSONAPI_document_resource_add (json_obj, json_res); | 835 | GNUNET_JSONAPI_document_resource_add (json_obj, json_res); |
825 | json_decref (name_json); | 836 | json_decref (name_json); |
826 | } | 837 | } |
@@ -862,7 +873,7 @@ namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con, | |||
862 | return; | 873 | return; |
863 | } | 874 | } |
864 | handle->zkey_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, | 875 | handle->zkey_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
865 | &key); | 876 | &key); |
866 | if (GNUNET_OK != | 877 | if (GNUNET_OK != |
867 | GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->zkey_str, | 878 | GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->zkey_str, |
868 | strlen (handle->zkey_str), | 879 | strlen (handle->zkey_str), |