diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_parsing.c')
-rw-r--r-- | src/mint/taler-mint-httpd_parsing.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/mint/taler-mint-httpd_parsing.c b/src/mint/taler-mint-httpd_parsing.c index 6c5f72b32..dedf4af9a 100644 --- a/src/mint/taler-mint-httpd_parsing.c +++ b/src/mint/taler-mint-httpd_parsing.c @@ -680,6 +680,16 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection, break; } + case JNAV_RET_AMOUNT: + { + struct TALER_Amount *where = va_arg (argp, void *); + + ret = TALER_MINT_parse_amount_json (connection, + (json_t *) root, + where); + break; + } + default: GNUNET_break (0); ret = (MHD_YES == @@ -721,6 +731,8 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, ret = GNUNET_YES; for (i=0; NULL != spec[i].field_name; i++) { + if (GNUNET_YES != ret) + break; switch (spec[i].command) { case JNAV_FIELD: @@ -730,8 +742,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, GNUNET_break (0); return GNUNET_SYSERR; case JNAV_RET_DATA: - if (GNUNET_YES != ret) - break; ret = GNUNET_MINT_parse_navigate_json (connection, root, JNAV_FIELD, @@ -741,8 +751,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, spec[i].destination_size_in); break; case JNAV_RET_DATA_VAR: - if (GNUNET_YES != ret) - break; ptr = NULL; ret = GNUNET_MINT_parse_navigate_json (connection, root, @@ -754,8 +762,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, spec[i].destination = ptr; break; case JNAV_RET_TYPED_JSON: - if (GNUNET_YES != ret) - break; ptr = NULL; ret = GNUNET_MINT_parse_navigate_json (connection, root, @@ -767,8 +773,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, *((void**)spec[i].destination) = ptr; break; case JNAV_RET_RSA_PUBLIC_KEY: - if (GNUNET_YES != ret) - break; ptr = NULL; ret = GNUNET_MINT_parse_navigate_json (connection, root, @@ -779,8 +783,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, spec[i].destination = ptr; break; case JNAV_RET_RSA_SIGNATURE: - if (GNUNET_YES != ret) - break; ptr = NULL; ret = GNUNET_MINT_parse_navigate_json (connection, root, @@ -790,6 +792,16 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection, &ptr); spec[i].destination = ptr; break; + case JNAV_RET_AMOUNT: + GNUNET_assert (sizeof (struct TALER_Amount) == + spec[i].destination_size_in); + ret = GNUNET_MINT_parse_navigate_json (connection, + root, + JNAV_FIELD, + spec[i].field_name, + JNAV_RET_AMOUNT, + &spec[i].destination); + break; } } if (GNUNET_YES != ret) @@ -854,6 +866,11 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec) *(void**) spec[i].destination = NULL; } break; + case JNAV_RET_AMOUNT: + memset (spec[i].destination, + 0, + sizeof (struct TALER_Amount)); + break; } } } @@ -878,8 +895,10 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, json_int_t value; json_int_t fraction; const char *currency; - struct TALER_Amount a; + memset (amount, + 0, + sizeof (struct TALER_Amount)); if (-1 == json_unpack (f, "{s:I, s:I, s:s}", "value", &value, @@ -897,7 +916,7 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, } if ( (value < 0) || (fraction < 0) || - (value > UINT32_MAX) || + (value > UINT64_MAX) || (fraction > UINT32_MAX) ) { LOG_WARNING ("Amount specified not in allowed range\n"); @@ -922,11 +941,11 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection, return GNUNET_SYSERR; return GNUNET_NO; } - a.value = (uint32_t) value; - a.fraction = (uint32_t) fraction; + amount->value = (uint64_t) value; + amount->fraction = (uint32_t) fraction; GNUNET_assert (strlen (MINT_CURRENCY) < TALER_CURRENCY_LEN); - strcpy (a.currency, MINT_CURRENCY); - *amount = TALER_amount_normalize (a); + strcpy (amount->currency, MINT_CURRENCY); + TALER_amount_normalize (amount); return GNUNET_OK; } |