aboutsummaryrefslogtreecommitdiff
path: root/src/identity/plugin_rest_identity.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-06-20 07:10:59 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-06-20 07:10:59 +0000
commit5a93ec57b32b9c1f82bd6ae6a806cebdc3b30b3b (patch)
tree04e33d7c1b42779b1135a300f9719997f5a22f23 /src/identity/plugin_rest_identity.c
parent8b09f880d6a04ae8a84665b4319ff9dac12f6e28 (diff)
downloadgnunet-5a93ec57b32b9c1f82bd6ae6a806cebdc3b30b3b.tar.gz
gnunet-5a93ec57b32b9c1f82bd6ae6a806cebdc3b30b3b.zip
- fix warnings
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r--src/identity/plugin_rest_identity.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 6cd2b685c..aa8a5ca60 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -496,9 +496,14 @@ ego_create_cont (struct GNUNET_REST_RequestHandle *con,
496 struct GNUNET_JSONAPI_Document *json_obj; 496 struct GNUNET_JSONAPI_Document *json_obj;
497 struct GNUNET_JSONAPI_Resource *json_res; 497 struct GNUNET_JSONAPI_Resource *json_res;
498 json_t *egoname_json; 498 json_t *egoname_json;
499 json_t *data_js;
500 json_error_t err;
499 const char* egoname; 501 const char* egoname;
500 char term_data[handle->data_size+1]; 502 char term_data[handle->data_size+1];
501 503 struct GNUNET_JSON_Specification docspec[] = {
504 GNUNET_JSON_spec_jsonapi_document (&json_obj),
505 GNUNET_JSON_spec_end()
506 };
502 if (strlen (GNUNET_REST_API_NS_IDENTITY) != strlen (handle->url)) 507 if (strlen (GNUNET_REST_API_NS_IDENTITY) != strlen (handle->url))
503 { 508 {
504 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_RESOURCE_INVALID); 509 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_RESOURCE_INVALID);
@@ -513,8 +518,16 @@ ego_create_cont (struct GNUNET_REST_RequestHandle *con,
513 } 518 }
514 term_data[handle->data_size] = '\0'; 519 term_data[handle->data_size] = '\0';
515 memcpy (term_data, handle->data, handle->data_size); 520 memcpy (term_data, handle->data, handle->data_size);
516 GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_document_parse (term_data, 521 data_js = json_loads (term_data,
517 &json_obj)); 522 JSON_DECODE_ANY,
523 &err);
524 GNUNET_assert (NULL != data_js);
525 GNUNET_assert (GNUNET_OK ==
526 GNUNET_JSON_parse (data_js, docspec,
527 NULL, NULL));
528
529 json_decref (data_js);
530
518 if (NULL == json_obj) 531 if (NULL == json_obj)
519 { 532 {
520 GNUNET_SCHEDULER_add_now (&do_error, handle); 533 GNUNET_SCHEDULER_add_now (&do_error, handle);
@@ -586,11 +599,17 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con,
586 struct MHD_Response *resp; 599 struct MHD_Response *resp;
587 json_t *subsys_json; 600 json_t *subsys_json;
588 json_t *name_json; 601 json_t *name_json;
602 json_t *data_js;
603 json_error_t err;
589 const char *keystring; 604 const char *keystring;
590 const char *subsys; 605 const char *subsys;
591 const char *newname; 606 const char *newname;
592 char term_data[handle->data_size+1]; 607 char term_data[handle->data_size+1];
593 int ego_exists = GNUNET_NO; 608 int ego_exists = GNUNET_NO;
609 struct GNUNET_JSON_Specification docspec[] = {
610 GNUNET_JSON_spec_jsonapi_document (&json_obj),
611 GNUNET_JSON_spec_end()
612 };
594 613
595 if (strlen (GNUNET_REST_API_NS_IDENTITY) > strlen (handle->url)) 614 if (strlen (GNUNET_REST_API_NS_IDENTITY) > strlen (handle->url))
596 { 615 {
@@ -628,8 +647,15 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con,
628 647
629 term_data[handle->data_size] = '\0'; 648 term_data[handle->data_size] = '\0';
630 memcpy (term_data, handle->data, handle->data_size); 649 memcpy (term_data, handle->data, handle->data_size);
631 GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_document_parse (term_data, 650 data_js = json_loads (term_data,
632 &json_obj)); 651 JSON_DECODE_ANY,
652 &err);
653 GNUNET_assert (NULL != data_js);
654 GNUNET_assert (GNUNET_OK ==
655 GNUNET_JSON_parse (data_js, docspec,
656 NULL, NULL));
657
658 json_decref (data_js);
633 659
634 if (NULL == json_obj) 660 if (NULL == json_obj)
635 { 661 {
@@ -657,7 +683,7 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con,
657 683
658 //This is a rename 684 //This is a rename
659 name_json = GNUNET_JSONAPI_resource_read_attr (json_res, 685 name_json = GNUNET_JSONAPI_resource_read_attr (json_res,
660 GNUNET_REST_JSONAPI_IDENTITY_NEWNAME); 686 GNUNET_REST_JSONAPI_IDENTITY_NEWNAME);
661 if ((NULL != name_json) && json_is_string (name_json)) 687 if ((NULL != name_json) && json_is_string (name_json))
662 { 688 {
663 newname = json_string_value (name_json); 689 newname = json_string_value (name_json);