fixing #3876 (no semantic change, just stylistic changes)
This commit is contained in:
parent
ee7e690bff
commit
a74f55754a
@ -113,7 +113,7 @@ TMH_ADMIN_handler_admin_add_incoming (struct TMH_RequestHandler *rh,
|
|||||||
json_t *wire;
|
json_t *wire;
|
||||||
json_t *root;
|
json_t *root;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("reserve_pub", &reserve_pub),
|
TMH_PARSE_member_fixed ("reserve_pub", &reserve_pub),
|
||||||
TMH_PARSE_member_amount ("amount", &amount),
|
TMH_PARSE_member_amount ("amount", &amount),
|
||||||
TMH_PARSE_member_time_abs ("execution_date", &at),
|
TMH_PARSE_member_time_abs ("execution_date", &at),
|
||||||
TMH_PARSE_member_object ("wire", &wire),
|
TMH_PARSE_member_object ("wire", &wire),
|
||||||
|
@ -139,11 +139,11 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &deposit.coin.denom_pub),
|
TMH_PARSE_member_denomination_public_key ("denom_pub", &deposit.coin.denom_pub),
|
||||||
TMH_PARSE_member_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
|
TMH_PARSE_member_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
|
||||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
TMH_PARSE_member_fixed ("coin_pub", &deposit.coin.coin_pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub),
|
TMH_PARSE_member_fixed ("merchant_pub", &deposit.merchant_pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("H_contract", &deposit.h_contract),
|
TMH_PARSE_member_fixed ("H_contract", &deposit.h_contract),
|
||||||
TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire),
|
TMH_PARSE_member_fixed ("H_wire", &deposit.h_wire),
|
||||||
TMH_PARSE_MEMBER_FIXED ("coin_sig", &deposit.csig),
|
TMH_PARSE_member_fixed ("coin_sig", &deposit.csig),
|
||||||
TMH_PARSE_member_uint64 ("transaction_id", &deposit.transaction_id),
|
TMH_PARSE_member_uint64 ("transaction_id", &deposit.transaction_id),
|
||||||
TMH_PARSE_member_time_abs ("timestamp", &deposit.timestamp),
|
TMH_PARSE_member_time_abs ("timestamp", &deposit.timestamp),
|
||||||
TMH_PARSE_member_time_abs ("refund_deadline", &deposit.refund_deadline),
|
TMH_PARSE_member_time_abs ("refund_deadline", &deposit.refund_deadline),
|
||||||
|
@ -167,11 +167,11 @@ release_data (struct TMH_PARSE_FieldSpecification *spec,
|
|||||||
case TMH_PARSE_JNC_RET_DATA:
|
case TMH_PARSE_JNC_RET_DATA:
|
||||||
break;
|
break;
|
||||||
case TMH_PARSE_JNC_RET_DATA_VAR:
|
case TMH_PARSE_JNC_RET_DATA_VAR:
|
||||||
if (0 != spec[i].destination_size_out)
|
if (NULL != spec[i].destination)
|
||||||
{
|
{
|
||||||
GNUNET_free (spec[i].destination);
|
GNUNET_free (* (void**) spec[i].destination);
|
||||||
spec[i].destination = NULL;
|
*(void**) spec[i].destination = NULL;
|
||||||
spec[i].destination_size_out = 0;
|
*spec[i].destination_size_out = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
||||||
@ -490,7 +490,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s, s:o}",
|
"{s:s, s:s, s:O}",
|
||||||
"error", "missing field in JSON",
|
"error", "missing field in JSON",
|
||||||
"field", fname,
|
"field", fname,
|
||||||
"path", path))
|
"path", path))
|
||||||
@ -513,7 +513,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "missing index in JSON",
|
"error", "missing index in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -529,14 +529,13 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
const char *str;
|
const char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
// FIXME: avoidable code duplication here...
|
|
||||||
str = json_string_value (root);
|
str = json_string_value (root);
|
||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "string expected",
|
"error", "string expected",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -549,7 +548,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed binary data in JSON",
|
"error", "malformed binary data in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -564,8 +563,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
void **where = va_arg (argp, void **);
|
void **where = va_arg (argp, void **);
|
||||||
size_t *len = va_arg (argp, size_t *);
|
size_t *len = va_arg (argp, size_t *);
|
||||||
const char *str;
|
const char *str;
|
||||||
|
int res;
|
||||||
|
|
||||||
// FIXME: avoidable code duplication here...
|
|
||||||
str = json_string_value (root);
|
str = json_string_value (root);
|
||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
@ -578,8 +577,6 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
*len = (strlen (str) * 5) / 8;
|
*len = (strlen (str) * 5) / 8;
|
||||||
if (NULL != where)
|
if (NULL != where)
|
||||||
{
|
{
|
||||||
int res;
|
|
||||||
|
|
||||||
*where = GNUNET_malloc (*len);
|
*where = GNUNET_malloc (*len);
|
||||||
res = GNUNET_STRINGS_string_to_data (str,
|
res = GNUNET_STRINGS_string_to_data (str,
|
||||||
strlen (str),
|
strlen (str),
|
||||||
@ -593,7 +590,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed binary data in JSON",
|
"error", "malformed binary data in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -615,7 +612,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:i, s:i, s:o}",
|
"{s:s, s:i, s:i, s:O}",
|
||||||
"error", "wrong JSON field type",
|
"error", "wrong JSON field type",
|
||||||
"type_expected", typ,
|
"type_expected", typ,
|
||||||
"type_actual", json_typeof (root),
|
"type_actual", json_typeof (root),
|
||||||
@ -638,7 +635,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s, s:i, s:o}",
|
"{s:s, s:s, s:i, s:O}",
|
||||||
"error", "wrong JSON field type",
|
"error", "wrong JSON field type",
|
||||||
"type_expected", "integer",
|
"type_expected", "integer",
|
||||||
"type_actual", json_typeof (root),
|
"type_actual", json_typeof (root),
|
||||||
@ -667,7 +664,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "string expected",
|
"error", "string expected",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -685,7 +682,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed binary data in JSON",
|
"error", "malformed binary data in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -699,7 +696,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed RSA public key in JSON",
|
"error", "malformed RSA public key in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -725,7 +722,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "string expected",
|
"error", "string expected",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -743,7 +740,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed binary data in JSON",
|
"error", "malformed binary data in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -757,7 +754,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "malformed RSA signature in JSON",
|
"error", "malformed RSA signature in JSON",
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
@ -778,7 +775,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:O}",
|
||||||
"error", "Bad format",
|
"error", "Bad format",
|
||||||
"path", path))
|
"path", path))
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -790,7 +787,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o, s:s}",
|
"{s:s, s:O, s:s}",
|
||||||
"error", "Currency not supported",
|
"error", "Currency not supported",
|
||||||
"path", path,
|
"path", path,
|
||||||
"currency", where->currency))
|
"currency", where->currency))
|
||||||
@ -816,7 +813,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s, s:o}",
|
"{s:s, s:s, s:O}",
|
||||||
"error", "Bad format",
|
"error", "Bad format",
|
||||||
"hint", "expected absolute time",
|
"hint", "expected absolute time",
|
||||||
"path", path))
|
"path", path))
|
||||||
@ -863,7 +860,6 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
void *ptr;
|
|
||||||
|
|
||||||
ret = GNUNET_YES;
|
ret = GNUNET_YES;
|
||||||
for (i=0; NULL != spec[i].field_name; i++)
|
for (i=0; NULL != spec[i].field_name; i++)
|
||||||
@ -888,26 +884,22 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
|
|||||||
spec[i].destination_size_in);
|
spec[i].destination_size_in);
|
||||||
break;
|
break;
|
||||||
case TMH_PARSE_JNC_RET_DATA_VAR:
|
case TMH_PARSE_JNC_RET_DATA_VAR:
|
||||||
ptr = NULL;
|
|
||||||
ret = TMH_PARSE_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
TMH_PARSE_JNC_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
TMH_PARSE_JNC_RET_DATA_VAR,
|
TMH_PARSE_JNC_RET_DATA_VAR,
|
||||||
&ptr,
|
(void **) spec[i].destination,
|
||||||
&spec[i].destination_size_out);
|
spec[i].destination_size_out);
|
||||||
spec[i].destination = ptr;
|
|
||||||
break;
|
break;
|
||||||
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
||||||
ptr = NULL;
|
|
||||||
ret = TMH_PARSE_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
TMH_PARSE_JNC_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
TMH_PARSE_JNC_RET_TYPED_JSON,
|
TMH_PARSE_JNC_RET_TYPED_JSON,
|
||||||
spec[i].type,
|
spec[i].type,
|
||||||
&ptr);
|
&spec[i].destination);
|
||||||
*((void**)spec[i].destination) = ptr;
|
|
||||||
break;
|
break;
|
||||||
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||||
ret = TMH_PARSE_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
@ -993,7 +985,7 @@ TMH_PARSE_member_uint64 (const char *field,
|
|||||||
uint64_t *u64)
|
uint64_t *u64)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, (void *) u64, sizeof (uint64_t), 0, TMH_PARSE_JNC_RET_UINT64, 0 };
|
{ field, (void *) u64, sizeof (uint64_t), NULL, TMH_PARSE_JNC_RET_UINT64, 0 };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,7 +1002,7 @@ TMH_PARSE_member_object (const char *field,
|
|||||||
json_t **jsonp)
|
json_t **jsonp)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, (void **) jsonp, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_OBJECT };
|
{ field, (void **) jsonp, 0, NULL, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_OBJECT };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1027,7 +1019,7 @@ TMH_PARSE_member_array (const char *field,
|
|||||||
json_t **jsonp)
|
json_t **jsonp)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, jsonp, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY };
|
{ field, jsonp, 0, NULL, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1043,7 +1035,7 @@ TMH_PARSE_member_time_abs (const char *field,
|
|||||||
struct GNUNET_TIME_Absolute *atime)
|
struct GNUNET_TIME_Absolute *atime)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, atime, sizeof(struct GNUNET_TIME_Absolute), 0, TMH_PARSE_JNC_RET_TIME_ABSOLUTE, 0 };
|
{ field, atime, sizeof(struct GNUNET_TIME_Absolute), NULL, TMH_PARSE_JNC_RET_TIME_ABSOLUTE, 0 };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1060,7 +1052,7 @@ TMH_PARSE_member_denomination_public_key (const char *field,
|
|||||||
struct TALER_DenominationPublicKey *pk)
|
struct TALER_DenominationPublicKey *pk)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, pk, 0, 0, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 };
|
{ field, pk, 0, NULL, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1069,7 @@ TMH_PARSE_member_denomination_signature (const char *field,
|
|||||||
struct TALER_DenominationSignature *sig)
|
struct TALER_DenominationSignature *sig)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, sig, 0, 0, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 };
|
{ field, sig, 0, NULL, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,9 +1086,27 @@ TMH_PARSE_member_amount (const char *field,
|
|||||||
struct TALER_Amount *amount)
|
struct TALER_Amount *amount)
|
||||||
{
|
{
|
||||||
struct TMH_PARSE_FieldSpecification ret =
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
{ field, amount, sizeof(struct TALER_Amount), 0, TMH_PARSE_JNC_RET_AMOUNT, 0 };
|
{ field, amount, sizeof(struct TALER_Amount), NULL, TMH_PARSE_JNC_RET_AMOUNT, 0 };
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate line in parser specification for variable-size value.
|
||||||
|
*
|
||||||
|
* @param field name of the field
|
||||||
|
* @param[out] ptr pointer to initialize
|
||||||
|
* @param[out] ptr_size size to initialize
|
||||||
|
* @return corresponding field spec
|
||||||
|
*/
|
||||||
|
struct TMH_PARSE_FieldSpecification
|
||||||
|
TMH_PARSE_member_variable (const char *field,
|
||||||
|
void **ptr,
|
||||||
|
size_t *ptr_size)
|
||||||
|
{
|
||||||
|
struct TMH_PARSE_FieldSpecification ret =
|
||||||
|
{ field, ptr, 0, ptr_size, TMH_PARSE_JNC_RET_DATA_VAR, 0 };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* end of taler-mint-httpd_parsing.c */
|
/* end of taler-mint-httpd_parsing.c */
|
||||||
|
@ -194,7 +194,7 @@ struct TMH_PARSE_FieldSpecification
|
|||||||
* value that was stored in @e destination (useful for
|
* value that was stored in @e destination (useful for
|
||||||
* variable-size allocations).
|
* variable-size allocations).
|
||||||
*/
|
*/
|
||||||
size_t destination_size_out;
|
size_t *destination_size_out;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation command to use to extract the value. Note that
|
* Navigation command to use to extract the value. Note that
|
||||||
@ -250,14 +250,21 @@ TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param value where to store the value
|
* @param value where to store the value
|
||||||
*/
|
*/
|
||||||
#define TMH_PARSE_MEMBER_FIXED(field,value) { field, value, sizeof (*value), 0, TMH_PARSE_JNC_RET_DATA, 0 }
|
#define TMH_PARSE_member_fixed(field,value) { field, value, sizeof (*value), NULL, TMH_PARSE_JNC_RET_DATA, 0 }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for variable-size value.
|
* Generate line in parser specification for variable-size value.
|
||||||
*
|
*
|
||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
|
* @param[out] ptr pointer to initialize
|
||||||
|
* @param[out] ptr_size size to initialize
|
||||||
|
* @return corresponding field spec
|
||||||
*/
|
*/
|
||||||
#define TMH_PARSE_MEMBER_VARIABLE(field) { field, NULL, 0, 0, TMH_PARSE_JNC_RET_DATA_VAR, 0 }
|
struct TMH_PARSE_FieldSpecification
|
||||||
|
TMH_PARSE_member_variable (const char *field,
|
||||||
|
void **ptr,
|
||||||
|
size_t *ptr_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -349,7 +356,7 @@ TMH_PARSE_member_time_abs (const char *field,
|
|||||||
/**
|
/**
|
||||||
* Generate line in parser specification indicating the end of the spec.
|
* Generate line in parser specification indicating the end of the spec.
|
||||||
*/
|
*/
|
||||||
#define TMH_PARSE_MEMBER_END { NULL, NULL, 0, 0, TMH_PARSE_JNC_FIELD, 0 }
|
#define TMH_PARSE_MEMBER_END { NULL, NULL, 0, NULL, TMH_PARSE_JNC_FIELD, 0 }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,10 +173,10 @@ get_coin_public_info (struct MHD_Connection *connection,
|
|||||||
struct TALER_DenominationPublicKey pk;
|
struct TALER_DenominationPublicKey pk;
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &r_melt_detail->coin_info.coin_pub),
|
TMH_PARSE_member_fixed ("coin_pub", &r_melt_detail->coin_info.coin_pub),
|
||||||
TMH_PARSE_member_denomination_signature ("denom_sig", &sig),
|
TMH_PARSE_member_denomination_signature ("denom_sig", &sig),
|
||||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &pk),
|
TMH_PARSE_member_denomination_public_key ("denom_pub", &pk),
|
||||||
TMH_PARSE_MEMBER_FIXED ("confirm_sig", &melt_sig),
|
TMH_PARSE_member_fixed ("confirm_sig", &melt_sig),
|
||||||
TMH_PARSE_member_amount ("value_with_fee", &amount),
|
TMH_PARSE_member_amount ("value_with_fee", &amount),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
@ -819,7 +819,7 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
|||||||
json_t *root;
|
json_t *root;
|
||||||
json_t *transfer_privs;
|
json_t *transfer_privs;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("session_hash", &session_hash),
|
TMH_PARSE_member_fixed ("session_hash", &session_hash),
|
||||||
TMH_PARSE_member_array ("transfer_privs", &transfer_privs),
|
TMH_PARSE_member_array ("transfer_privs", &transfer_privs),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
@ -842,13 +842,13 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
|||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
|
|
||||||
/* Determine dimensionality of the request (kappa and #old coins) */
|
/* Determine dimensionality of the request (kappa and #old coins) */
|
||||||
|
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
||||||
if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1)
|
if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"transfer_privs");
|
"transfer_privs");
|
||||||
}
|
}
|
||||||
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
|
||||||
res = TMH_PARSE_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_privs,
|
transfer_privs,
|
||||||
TMH_PARSE_JNC_INDEX, 0,
|
TMH_PARSE_JNC_INDEX, 0,
|
||||||
|
@ -59,9 +59,11 @@ TMH_TEST_handler_test_base32 (struct TMH_RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
json_t *json;
|
json_t *json;
|
||||||
int res;
|
int res;
|
||||||
|
void *in_ptr;
|
||||||
|
size_t in_ptr_size;
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_VARIABLE ("input"),
|
TMH_PARSE_member_variable ("input", &in_ptr, &in_ptr_size),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,8 +81,8 @@ TMH_TEST_handler_test_base32 (struct TMH_RequestHandler *rh,
|
|||||||
spec);
|
spec);
|
||||||
if (GNUNET_YES != res)
|
if (GNUNET_YES != res)
|
||||||
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
||||||
GNUNET_CRYPTO_hash (spec[0].destination,
|
GNUNET_CRYPTO_hash (in_ptr,
|
||||||
spec[0].destination_size_out,
|
in_ptr_size,
|
||||||
&hc);
|
&hc);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
@ -121,9 +123,11 @@ TMH_TEST_handler_test_encrypt (struct TMH_RequestHandler *rh,
|
|||||||
struct GNUNET_HashCode key;
|
struct GNUNET_HashCode key;
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
||||||
|
void *in_ptr;
|
||||||
|
size_t in_ptr_size;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_VARIABLE ("input"),
|
TMH_PARSE_member_variable ("input", &in_ptr, &in_ptr_size),
|
||||||
TMH_PARSE_MEMBER_FIXED ("key_hash", &key),
|
TMH_PARSE_member_fixed ("key_hash", &key),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
char *out;
|
char *out;
|
||||||
@ -153,15 +157,15 @@ TMH_TEST_handler_test_encrypt (struct TMH_RequestHandler *rh,
|
|||||||
"iv", strlen ("iv"),
|
"iv", strlen ("iv"),
|
||||||
&key, sizeof (key),
|
&key, sizeof (key),
|
||||||
NULL, 0));
|
NULL, 0));
|
||||||
out = GNUNET_malloc (spec[0].destination_size_out);
|
out = GNUNET_malloc (in_ptr_size);
|
||||||
GNUNET_break (spec[0].destination_size_out ==
|
GNUNET_break (in_ptr_size ==
|
||||||
GNUNET_CRYPTO_symmetric_encrypt (spec[0].destination,
|
GNUNET_CRYPTO_symmetric_encrypt (in_ptr,
|
||||||
spec[0].destination_size_out,
|
in_ptr_size,
|
||||||
&skey,
|
&skey,
|
||||||
&iv,
|
&iv,
|
||||||
out));
|
out));
|
||||||
json = TALER_json_from_data (out,
|
json = TALER_json_from_data (out,
|
||||||
spec[0].destination_size_out);
|
in_ptr_size);
|
||||||
GNUNET_free (out);
|
GNUNET_free (out);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
@ -199,8 +203,10 @@ TMH_TEST_handler_test_hkdf (struct TMH_RequestHandler *rh,
|
|||||||
json_t *json;
|
json_t *json;
|
||||||
int res;
|
int res;
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
|
void *in_ptr;
|
||||||
|
size_t in_ptr_size;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_VARIABLE ("input"),
|
TMH_PARSE_member_variable ("input", &in_ptr, &in_ptr_size),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -221,8 +227,8 @@ TMH_TEST_handler_test_hkdf (struct TMH_RequestHandler *rh,
|
|||||||
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
||||||
GNUNET_CRYPTO_kdf (&hc, sizeof (hc),
|
GNUNET_CRYPTO_kdf (&hc, sizeof (hc),
|
||||||
"salty", strlen ("salty"),
|
"salty", strlen ("salty"),
|
||||||
spec[0].destination,
|
in_ptr,
|
||||||
spec[0].destination_size_out,
|
in_ptr_size,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
json = TALER_json_from_data (&hc,
|
json = TALER_json_from_data (&hc,
|
||||||
@ -262,8 +268,8 @@ TMH_TEST_handler_test_ecdhe (struct TMH_RequestHandler *rh,
|
|||||||
struct GNUNET_CRYPTO_EcdhePrivateKey priv;
|
struct GNUNET_CRYPTO_EcdhePrivateKey priv;
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("ecdhe_pub", &pub),
|
TMH_PARSE_member_fixed ("ecdhe_pub", &pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("ecdhe_priv", &priv),
|
TMH_PARSE_member_fixed ("ecdhe_priv", &priv),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -329,8 +335,8 @@ TMH_TEST_handler_test_eddsa (struct TMH_RequestHandler *rh,
|
|||||||
struct GNUNET_CRYPTO_EddsaSignature sig;
|
struct GNUNET_CRYPTO_EddsaSignature sig;
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("eddsa_pub", &pub),
|
TMH_PARSE_member_fixed ("eddsa_pub", &pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("eddsa_sig", &sig),
|
TMH_PARSE_member_fixed ("eddsa_sig", &sig),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
|
||||||
@ -457,8 +463,10 @@ TMH_TEST_handler_test_rsa_sign (struct TMH_RequestHandler *rh,
|
|||||||
json_t *json;
|
json_t *json;
|
||||||
int res;
|
int res;
|
||||||
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
||||||
|
void *in_ptr;
|
||||||
|
size_t in_ptr_size;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_VARIABLE ("blind_ev"),
|
TMH_PARSE_member_variable ("blind_ev", &in_ptr, &in_ptr_size),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -487,8 +495,8 @@ TMH_TEST_handler_test_rsa_sign (struct TMH_RequestHandler *rh,
|
|||||||
"Failed to create RSA key");
|
"Failed to create RSA key");
|
||||||
}
|
}
|
||||||
sig = GNUNET_CRYPTO_rsa_sign (rsa_pk,
|
sig = GNUNET_CRYPTO_rsa_sign (rsa_pk,
|
||||||
spec[0].destination,
|
in_ptr,
|
||||||
spec[0].destination_size_out);
|
in_ptr_size);
|
||||||
if (NULL == sig)
|
if (NULL == sig)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -534,9 +542,9 @@ TMH_TEST_handler_test_transfer (struct TMH_RequestHandler *rh,
|
|||||||
struct TALER_TransferPrivateKeyP trans_priv;
|
struct TALER_TransferPrivateKeyP trans_priv;
|
||||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_FIXED ("secret_enc", &secret_enc),
|
TMH_PARSE_member_fixed ("secret_enc", &secret_enc),
|
||||||
TMH_PARSE_MEMBER_FIXED ("trans_priv", &trans_priv),
|
TMH_PARSE_member_fixed ("trans_priv", &trans_priv),
|
||||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &coin_pub),
|
TMH_PARSE_member_fixed ("coin_pub", &coin_pub),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
struct TALER_LinkSecretP secret;
|
struct TALER_LinkSecretP secret;
|
||||||
|
@ -92,7 +92,7 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
|||||||
struct TALER_WithdrawRequestPS wsrd;
|
struct TALER_WithdrawRequestPS wsrd;
|
||||||
int res;
|
int res;
|
||||||
struct TALER_DenominationPublicKey denomination_pub;
|
struct TALER_DenominationPublicKey denomination_pub;
|
||||||
const char *blinded_msg;
|
char *blinded_msg;
|
||||||
size_t blinded_msg_len;
|
size_t blinded_msg_len;
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
struct TALER_Amount amount_with_fee;
|
struct TALER_Amount amount_with_fee;
|
||||||
@ -102,9 +102,9 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
|||||||
struct TMH_KS_StateHandle *ks;
|
struct TMH_KS_StateHandle *ks;
|
||||||
|
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_VARIABLE ("coin_ev"),
|
TMH_PARSE_member_variable ("coin_ev", (void **) &blinded_msg, &blinded_msg_len),
|
||||||
TMH_PARSE_MEMBER_FIXED ("reserve_pub", &wsrd.reserve_pub),
|
TMH_PARSE_member_fixed ("reserve_pub", &wsrd.reserve_pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("reserve_sig", &signature),
|
TMH_PARSE_member_fixed ("reserve_sig", &signature),
|
||||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &denomination_pub),
|
TMH_PARSE_member_denomination_public_key ("denom_pub", &denomination_pub),
|
||||||
TMH_PARSE_MEMBER_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
@ -124,8 +124,6 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
|||||||
json_decref (root);
|
json_decref (root);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
blinded_msg = spec[0].destination;
|
|
||||||
blinded_msg_len = spec[0].destination_size_out;
|
|
||||||
ks = TMH_KS_acquire ();
|
ks = TMH_KS_acquire ();
|
||||||
dki = TMH_KS_denomination_key_lookup (ks,
|
dki = TMH_KS_denomination_key_lookup (ks,
|
||||||
&denomination_pub,
|
&denomination_pub,
|
||||||
|
Loading…
Reference in New Issue
Block a user