diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-07-08 08:54:55 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-07-08 08:54:55 +0200 |
commit | 296e27b92ab0367f414dc0e98b185531c8df06f3 (patch) | |
tree | 9f2432f73e4d6018a7d4ecfada3e60096e015c40 | |
parent | b7e2e107126cbd19aff063633c6d91029552e5d0 (diff) |
-simplify parsing, make code compile without new util API
-rw-r--r-- | src/mint-lib/test_mint_api.c | 3 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_parsing.c | 48 | ||||
-rw-r--r-- | src/mint/test-mint-home/master.priv | 1 | ||||
-rw-r--r-- | src/util/json.c | 10 |
4 files changed, 20 insertions, 42 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index 0fe1ad427..d3fbb9cf5 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -29,6 +29,7 @@ #include "taler_util.h" #include "taler_signatures.h" #include "taler_mint_service.h" +#include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> @@ -629,7 +630,7 @@ interpreter_run (void *cls, GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.withdraw_sign.coin_priv.eddsa_priv, &coin_pub.eddsa_pub); cmd->details.withdraw_sign.blinding_key.rsa_blinding_key - = GNUNET_CRYPTO_rsa_blinding_key_create (GNUNET_CRYPTO_rsa_public_key_len (cmd->details.withdraw_sign.pk->key.rsa_public_key)); + = GNUNET_CRYPTO_rsa_blinding_key_create (1024); // FIXME: GNUNET_CRYPTO_rsa_public_key_len (cmd->details.withdraw_sign.pk->key.rsa_public_key)); cmd->details.withdraw_sign.wsh = TALER_MINT_withdraw_sign (mint, diff --git a/src/mint/taler-mint-httpd_parsing.c b/src/mint/taler-mint-httpd_parsing.c index c2f97dd32..6461685f3 100644 --- a/src/mint/taler-mint-httpd_parsing.c +++ b/src/mint/taler-mint-httpd_parsing.c @@ -571,7 +571,7 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection, { ret = (MHD_YES == TMH_RESPONSE_reply_internal_error (connection, - "json_string_value() failed")) + "json_string_value() failed")) ? GNUNET_NO : GNUNET_SYSERR; break; } @@ -818,8 +818,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection, */ int TMH_PARSE_json_data (struct MHD_Connection *connection, - const json_t *root, - struct TMH_PARSE_FieldSpecification *spec) + const json_t *root, + struct TMH_PARSE_FieldSpecification *spec) { unsigned int i; int ret; @@ -1029,18 +1029,9 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection, json_t *f, struct TALER_Amount *amount) { - json_int_t value; - json_int_t fraction; - const char *currency; - - memset (amount, - 0, - sizeof (struct TALER_Amount)); - if (-1 == json_unpack (f, - "{s:I, s:I, s:s}", - "value", &value, - "fraction", &fraction, - "currency", ¤cy)) + if (GNUNET_OK != + TALER_json_to_amount (f, + amount)) { TALER_LOG_WARNING ("Failed to parse JSON amount specification\n"); if (MHD_YES != @@ -1051,21 +1042,7 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection, return GNUNET_SYSERR; return GNUNET_NO; } - if ( (value < 0) || - (fraction < 0) || - (value > UINT64_MAX) || - (fraction > UINT32_MAX) ) - { - TALER_LOG_WARNING ("Amount specified not in allowed range\n"); - if (MHD_YES != - TMH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s}", - "error", "Amount outside of allowed range")) - return GNUNET_SYSERR; - return GNUNET_NO; - } - if (0 != strcmp (currency, + if (0 != strcmp (amount->currency, TMH_mint_currency_string)) { TALER_LOG_WARNING ("Currency specified not supported by this mint\n"); @@ -1074,15 +1051,14 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:s}", "error", "Currency not supported", - "currency", currency)) + "currency", amount->currency)) + { + memset (amount, 0, sizeof (struct TALER_Amount)); return GNUNET_SYSERR; + } + memset (amount, 0, sizeof (struct TALER_Amount)); return GNUNET_NO; } - amount->value = (uint64_t) value; - amount->fraction = (uint32_t) fraction; - GNUNET_assert (strlen (TMH_mint_currency_string) < TALER_CURRENCY_LEN); - strcpy (amount->currency, TMH_mint_currency_string); - (void) TALER_amount_normalize (amount); return GNUNET_OK; } diff --git a/src/mint/test-mint-home/master.priv b/src/mint/test-mint-home/master.priv new file mode 100644 index 000000000..394926938 --- /dev/null +++ b/src/mint/test-mint-home/master.priv @@ -0,0 +1 @@ +p^-33XX!\0qmU_
\ No newline at end of file diff --git a/src/util/json.c b/src/util/json.c index 42f146463..e4b0831a4 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -291,11 +291,11 @@ TALER_json_to_amount (json_t *json, memset (r_amount, 0, sizeof (struct TALER_Amount)); - if (-1 == json_unpack (json, - "{s:I, s:I, s:s}", - "value", &value, - "fraction", &fraction, - "currency", ¤cy)) + if (0 != json_unpack (json, + "{s:I, s:I, s:s}", + "value", &value, + "fraction", &fraction, + "currency", ¤cy)) { GNUNET_break_op (0); return GNUNET_SYSERR; |