* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
*/
static int
-parse_attr(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
+parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
{
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
const char *name_str = NULL;
uint32_t type;
size_t data_size;
- GNUNET_assert(NULL != root);
+ GNUNET_assert (NULL != root);
- if (!json_is_object(root))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Error json is not array nor object!\n");
- return GNUNET_SYSERR;
- }
+ if (! json_is_object (root))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error json is not array nor object!\n");
+ return GNUNET_SYSERR;
+ }
// interpret single attribute
- unpack_state = json_unpack(root,
- "{s:s, s?s, s:s, s:s!}",
- "name",
- &name_str,
- "id",
- &id_str,
- "type",
- &type_str,
- "value",
- &val_str);
+ unpack_state = json_unpack (root,
+ "{s:s, s?s, s:s, s:s!}",
+ "name",
+ &name_str,
+ "id",
+ &id_str,
+ "type",
+ &type_str,
+ "value",
+ &val_str);
if ((0 != unpack_state) || (NULL == name_str) || (NULL == val_str) ||
(NULL == type_str))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Error json object has a wrong format!\n");
- return GNUNET_SYSERR;
- }
- type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(type_str);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error json object has a wrong format!\n");
+ return GNUNET_SYSERR;
+ }
+ type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
if (GNUNET_SYSERR ==
- (GNUNET_RECLAIM_ATTRIBUTE_string_to_value(type,
- val_str,
- (void **)&data,
- &data_size)))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n");
- return GNUNET_SYSERR;
- }
- attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new(name_str, type, data, data_size);
- if ((NULL == id_str) || (0 == strlen(id_str)))
+ (GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
+ val_str,
+ (void **) &data,
+ &data_size)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute value invalid!\n");
+ return GNUNET_SYSERR;
+ }
+ attr = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, type, data, data_size);
+ if ((NULL == id_str) || (0 == strlen (id_str)))
attr->id = 0;
else
- GNUNET_STRINGS_string_to_data(id_str,
- strlen(id_str),
- &attr->id,
- sizeof(uint64_t));
+ GNUNET_STRINGS_string_to_data (id_str,
+ strlen (id_str),
+ &attr->id,
+ sizeof(uint64_t));
- *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr = attr;
+ *(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr = attr;
return GNUNET_OK;
}
* @param[out] spec where to free the data
*/
static void
-clean_attr(void *cls, struct GNUNET_JSON_Specification *spec)
+clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
{
struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr;
- attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **)spec->ptr;
+ attr = (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **) spec->ptr;
if (NULL != *attr)
- {
- GNUNET_free(*attr);
- *attr = NULL;
- }
+ {
+ GNUNET_free (*attr);
+ *attr = NULL;
+ }
}
/**
* @return JSON Specification
*/
struct GNUNET_JSON_Specification
-GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
+GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_ATTRIBUTE_Claim **attr)
{
struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
.cleaner = &clean_attr,
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
*/
static int
-parse_ticket(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
+parse_ticket (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
{
struct GNUNET_RECLAIM_Ticket *ticket;
const char *rnd_str;
const char *id_str;
int unpack_state;
- GNUNET_assert(NULL != root);
+ GNUNET_assert (NULL != root);
- if (!json_is_object(root))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Error json is not array nor object!\n");
- return GNUNET_SYSERR;
- }
+ if (! json_is_object (root))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Error json is not array nor object!\n");
+ return GNUNET_SYSERR;
+ }
// interpret single ticket
- unpack_state = json_unpack(root,
- "{s:s, s:s, s:s!}",
- "rnd",
- &rnd_str,
- "audience",
- &aud_str,
- "issuer",
- &id_str);
+ unpack_state = json_unpack (root,
+ "{s:s, s:s, s:s!}",
+ "rnd",
+ &rnd_str,
+ "audience",
+ &aud_str,
+ "issuer",
+ &id_str);
if (0 != unpack_state)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Error json object has a wrong format!\n");
- return GNUNET_SYSERR;
- }
- ticket = GNUNET_new(struct GNUNET_RECLAIM_Ticket);
- if (GNUNET_OK != GNUNET_STRINGS_string_to_data(rnd_str,
- strlen(rnd_str),
- &ticket->rnd,
- sizeof(uint64_t)))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n");
- GNUNET_free(ticket);
- return GNUNET_SYSERR;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Error json object has a wrong format!\n");
+ return GNUNET_SYSERR;
+ }
+ ticket = GNUNET_new (struct GNUNET_RECLAIM_Ticket);
+ if (GNUNET_OK != GNUNET_STRINGS_string_to_data (rnd_str,
+ strlen (rnd_str),
+ &ticket->rnd,
+ sizeof(uint64_t)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rnd invalid\n");
+ GNUNET_free (ticket);
+ return GNUNET_SYSERR;
+ }
if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data(id_str,
- strlen(id_str),
- &ticket->identity,
- sizeof(
- struct GNUNET_CRYPTO_EcdsaPublicKey)))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n");
- GNUNET_free(ticket);
- return GNUNET_SYSERR;
- }
+ GNUNET_STRINGS_string_to_data (id_str,
+ strlen (id_str),
+ &ticket->identity,
+ sizeof(
+ struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity invalid\n");
+ GNUNET_free (ticket);
+ return GNUNET_SYSERR;
+ }
if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data(aud_str,
- strlen(aud_str),
- &ticket->audience,
- sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n");
- GNUNET_free(ticket);
- return GNUNET_SYSERR;
- }
+ GNUNET_STRINGS_string_to_data (aud_str,
+ strlen (aud_str),
+ &ticket->audience,
+ sizeof(struct
+ GNUNET_CRYPTO_EcdsaPublicKey)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience invalid\n");
+ GNUNET_free (ticket);
+ return GNUNET_SYSERR;
+ }
- *(struct GNUNET_RECLAIM_Ticket **)spec->ptr = ticket;
+ *(struct GNUNET_RECLAIM_Ticket **) spec->ptr = ticket;
return GNUNET_OK;
}
* @param[out] spec where to free the data
*/
static void
-clean_ticket(void *cls, struct GNUNET_JSON_Specification *spec)
+clean_ticket (void *cls, struct GNUNET_JSON_Specification *spec)
{
struct GNUNET_RECLAIM_Ticket **ticket;
- ticket = (struct GNUNET_RECLAIM_Ticket **)spec->ptr;
+ ticket = (struct GNUNET_RECLAIM_Ticket **) spec->ptr;
if (NULL != *ticket)
- {
- GNUNET_free(*ticket);
- *ticket = NULL;
- }
+ {
+ GNUNET_free (*ticket);
+ *ticket = NULL;
+ }
}
/**
* @return JSON Specification
*/
struct GNUNET_JSON_Specification
-GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
+GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
{
struct GNUNET_JSON_Specification ret = { .parser = &parse_ticket,
.cleaner = &clean_ticket,