aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-06-18 20:04:18 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-06-18 20:04:18 +0000
commit577d21f282478d36c8665e0a7a2d2ee07bddd56d (patch)
tree26f5a27192b873b63fbafb7fae0ffd86e4fc3a25 /src/namestore
parent229e7fbe49b1a1ab7121a57af6e241500c09c1bf (diff)
downloadgnunet-577d21f282478d36c8665e0a7a2d2ee07bddd56d.tar.gz
gnunet-577d21f282478d36c8665e0a7a2d2ee07bddd56d.zip
-fix
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/plugin_rest_namestore.c29
1 files changed, 20 insertions, 9 deletions
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),