From: Markus Voggenreiter Date: Fri, 1 Nov 2019 09:59:01 +0000 (+0100) Subject: Listing of References with Attributes X-Git-Tag: v0.12.2~12 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6fad96b4971e3067168932088dcaf6c3cbdcb124;p=oweals%2Fgnunet.git Listing of References with Attributes --- diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c index d958ba7f9..113ec7ef5 100644 --- a/src/reclaim-attribute/reclaim_attribute.c +++ b/src/reclaim-attribute/reclaim_attribute.c @@ -426,7 +426,7 @@ GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name, GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); attr->name = write_ptr; - write_ptr = (char *) &attr[1]; + write_ptr += strlen (attr_name) +1; GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1); attr->reference_value = write_ptr; diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 7dd658886..f7713c284 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c @@ -638,7 +638,7 @@ static void attest_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, - const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, + const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) { struct RequestHandle *handle = cls; @@ -1045,7 +1045,6 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, GNUNET_JSON_parse_free (attrspec); } - /** * Collect all attributes for an ego * @@ -1054,47 +1053,77 @@ static void attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, - const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, + const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) { struct RequestHandle *handle = cls; json_t *attr_obj; const char *type; - char *tmp_value; char *id_str; - if (NULL == attr) + if ((NULL == attr)&& (NULL == reference)) { GNUNET_RECLAIM_get_attributes_next (handle->attr_it); return; } - if ((NULL == attr->name) || (NULL == attr->data)) + if (NULL == attr) { - GNUNET_RECLAIM_get_attributes_next (handle->attr_it); - return; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); + if ((NULL == reference->name) || (NULL == reference->reference_value)) + { + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); + return; + } - tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, - attr->data, - attr->data_size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n", + reference->name); + + + attr_obj = json_object (); + json_object_set_new (attr_obj, "name", json_string (reference->name)); + json_object_set_new (attr_obj, "value", json_string ( + reference->reference_value)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id, sizeof(uint64_t)); + json_object_set_new (attr_obj, "id", json_string (id_str)); + char *flag; + flag = "1"; + json_object_set_new (attr_obj, "flag", json_string (flag)); + type = "String"; + json_object_set_new (attr_obj, "type", json_string (type)); + json_array_append (handle->resp_object, attr_obj); + json_decref (attr_obj); + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); - attr_obj = json_object (); - json_object_set_new (attr_obj, "value", json_string (tmp_value)); - json_object_set_new (attr_obj, "name", json_string (attr->name)); - type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); - json_object_set_new (attr_obj, "type", json_string (type)); - id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); - json_object_set_new (attr_obj, "id", json_string (id_str)); - json_array_append (handle->resp_object, attr_obj); - json_decref (attr_obj); - GNUNET_free (tmp_value); - GNUNET_RECLAIM_get_attributes_next (handle->attr_it); + } + else + { + if ((NULL == attr->name) || (NULL == attr->data)) + { + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); + return; + } + char *tmp_value; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); + + tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, + attr->data, + attr->data_size); + + attr_obj = json_object (); + json_object_set_new (attr_obj, "value", json_string (tmp_value)); + json_object_set_new (attr_obj, "name", json_string (attr->name)); + type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); + json_object_set_new (attr_obj, "type", json_string (type)); + id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); + json_object_set_new (attr_obj, "id", json_string (id_str)); + json_array_append (handle->resp_object, attr_obj); + json_decref (attr_obj); + GNUNET_free (tmp_value); + GNUNET_RECLAIM_get_attributes_next (handle->attr_it); + } } - /** * List attributes for identity request *