diff options
Diffstat (limited to 'src/lib/merchant_api_get_instance.c')
-rw-r--r-- | src/lib/merchant_api_get_instance.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c index 6224e1b4..cf58f828 100644 --- a/src/lib/merchant_api_get_instance.c +++ b/src/lib/merchant_api_get_instance.c @@ -93,13 +93,13 @@ handle_get_instance_finished (void *cls, { case MHD_HTTP_OK: { - json_t *accounts; + const json_t *accounts; const char *uts; - json_t *address; - json_t *jurisdiction; + const json_t *address; + const json_t *jurisdiction; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("accounts", - &accounts), + GNUNET_JSON_spec_array_const ("accounts", + &accounts), GNUNET_JSON_spec_string ("name", &igr.details.ok.details.name), GNUNET_JSON_spec_string ("user_type", @@ -107,10 +107,10 @@ handle_get_instance_finished (void *cls, GNUNET_JSON_spec_fixed_auto ( "merchant_pub", &igr.details.ok.details.merchant_pub), - GNUNET_JSON_spec_json ("address", - &address), - GNUNET_JSON_spec_json ("jurisdiction", - &jurisdiction), + GNUNET_JSON_spec_object_const ("address", + &address), + GNUNET_JSON_spec_object_const ("jurisdiction", + &jurisdiction), TALER_JSON_spec_amount_any ( "default_max_wire_fee", &igr.details.ok.details.default_max_wire_fee), @@ -129,14 +129,13 @@ handle_get_instance_finished (void *cls, GNUNET_JSON_spec_end () }; - if ( (GNUNET_OK == - GNUNET_JSON_parse (json, - spec, - NULL, NULL)) && - (json_is_array (accounts)) ) + if (GNUNET_OK == + GNUNET_JSON_parse (json, + spec, + NULL, NULL)) { unsigned int accounts_length = json_array_size (accounts); - struct TALER_MERCHANT_Account aa[accounts_length]; + struct TALER_MERCHANT_Account aa[GNUNET_NZL (accounts_length)]; size_t index; json_t *value; int ret = GNUNET_OK; @@ -146,7 +145,7 @@ handle_get_instance_finished (void *cls, sizeof (aa)); json_array_foreach (accounts, index, value) { - struct GNUNET_JSON_Specification spec[] = { + struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("salt", &aa[index].salt), GNUNET_JSON_spec_mark_optional ( @@ -164,7 +163,7 @@ handle_get_instance_finished (void *cls, if (GNUNET_OK != GNUNET_JSON_parse (value, - spec, + ispec, NULL, NULL)) { GNUNET_break_op (0); @@ -188,14 +187,12 @@ handle_get_instance_finished (void *cls, ret = GNUNET_SYSERR; igr.hr.http_status = 0; igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; - GNUNET_JSON_parse_free (spec); break; } igr.details.ok.accounts_length = accounts_length; igr.details.ok.accounts = aa; igh->cb (igh->cb_cls, &igr); - GNUNET_JSON_parse_free (spec); TALER_MERCHANT_instance_get_cancel (igh); return; } @@ -203,7 +200,6 @@ handle_get_instance_finished (void *cls, GNUNET_break_op (0); igr.hr.http_status = 0; igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; - GNUNET_JSON_parse_free (spec); break; } case MHD_HTTP_UNAUTHORIZED: |