along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
- */
+ */
/**
* @author Martin Schanzenbach
* @author Philippe Buschmann
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
if (NULL != handle->resp_object)
json_decref (handle->resp_object);
GNUNET_free (ego_tmp->keystring);
GNUNET_free (ego_tmp);
}
- if (NULL != handle->attr_it)
- {
- GNUNET_free (handle->attr_it);
- }
GNUNET_free (handle);
}
collect_finished_cb (void *cls)
{
struct RequestHandle *handle = cls;
+
// Done
handle->attr_it = NULL;
handle->ticket_it = NULL;
char *tmp;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
- tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
+ tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
json_resource = json_object ();
GNUNET_free (tmp);
json_array_append (handle->resp_object, json_resource);
tmp =
GNUNET_STRINGS_data_to_string_alloc (&ticket->identity,
- sizeof (struct
- GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof(struct
+ GNUNET_CRYPTO_EcdsaPublicKey));
value = json_string (tmp);
json_object_set_new (json_resource, "issuer", value);
GNUNET_free (tmp);
tmp =
GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
- sizeof (struct
- GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof(struct
+ GNUNET_CRYPTO_EcdsaPublicKey));
value = json_string (tmp);
json_object_set_new (json_resource, "audience", value);
GNUNET_free (tmp);
- tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t));
+ tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(uint64_t));
value = json_string (tmp);
json_object_set_new (json_resource, "rnd", value);
GNUNET_free (tmp);
json_t *data_json;
json_error_t err;
struct GNUNET_JSON_Specification attrspec[] =
- {GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end ()};
+ { GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end () };
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding an attribute for %s.\n",
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));
+ 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);
}
priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
handle->idp = GNUNET_RECLAIM_connect (cfg);
- memset (&attr, 0, sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
- GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof (uint64_t));
+ memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim));
+ GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
attr.name = "";
handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
priv_key,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
struct RequestHandle *handle = cls;
struct EgoEntry *ego_entry;
- struct GNUNET_RECLAIM_Ticket *ticket;
+ struct GNUNET_RECLAIM_Ticket *ticket = NULL;
struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
char term_data[handle->rest_handle->data_size + 1];
json_t *data_json;
json_error_t err;
struct GNUNET_JSON_Specification tktspec[] =
- {GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()};
+ { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end () };
if (0 >= handle->rest_handle->data_size)
{
handle->rest_handle->data,
handle->rest_handle->data_size);
data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
- if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
+ if ((NULL == data_json) ||
+ (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
{
handle->emsg = GNUNET_strdup ("Not a ticket!\n");
GNUNET_SCHEDULER_add_now (&do_error, handle);
GNUNET_JSON_parse_free (tktspec);
- json_decref (data_json);
+ if (NULL != data_json)
+ json_decref (data_json);
return;
}
json_decref (data_json);
GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
if (0 == memcmp (&ticket->identity,
&tmp_pk,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
break;
}
if (NULL == ego_entry)
json_t *data_json;
json_error_t err;
struct GNUNET_JSON_Specification tktspec[] =
- {GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()};
+ { GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end () };
if (0 >= handle->rest_handle->data_size)
{
GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
if (0 == memcmp (&ticket->audience,
&tmp_pk,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
break;
}
if (NULL == ego_entry)
{
struct GNUNET_REST_RequestHandlerError err;
static const struct GNUNET_REST_RequestHandler handlers[] =
- {{MHD_HTTP_METHOD_GET,
+ { { MHD_HTTP_METHOD_GET,
GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
- &list_attribute_cont},
- {MHD_HTTP_METHOD_POST,
+ &list_attribute_cont },
+ { MHD_HTTP_METHOD_POST,
GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
- &add_attribute_cont},
- {MHD_HTTP_METHOD_DELETE,
+ &add_attribute_cont },
+ { MHD_HTTP_METHOD_DELETE,
GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES,
- &delete_attribute_cont},
- {MHD_HTTP_METHOD_GET,
+ &delete_attribute_cont },
+ { MHD_HTTP_METHOD_GET,
GNUNET_REST_API_NS_IDENTITY_TICKETS,
- &list_tickets_cont},
- {MHD_HTTP_METHOD_POST,
+ &list_tickets_cont },
+ { MHD_HTTP_METHOD_POST,
GNUNET_REST_API_NS_IDENTITY_REVOKE,
- &revoke_ticket_cont},
- {MHD_HTTP_METHOD_POST,
+ &revoke_ticket_cont },
+ { MHD_HTTP_METHOD_POST,
GNUNET_REST_API_NS_IDENTITY_CONSUME,
- &consume_ticket_cont},
- {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont},
- GNUNET_REST_HANDLER_END};
+ &consume_ticket_cont },
+ { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
+ GNUNET_REST_HANDLER_END };
if (GNUNET_NO ==
GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
+
handle->response_code = 0;
handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
handle->proc_cls = proc_cls;
cfg = cls;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
- memset (&plugin, 0, sizeof (struct Plugin));
+ memset (&plugin, 0, sizeof(struct Plugin));
plugin.cfg = cfg;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
{
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
+
plugin->cfg = NULL;
GNUNET_free_non_null (allow_methods);