diff options
Diffstat (limited to 'src/lib/merchant_api_get_config.c')
-rw-r--r-- | src/lib/merchant_api_get_config.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/lib/merchant_api_get_config.c b/src/lib/merchant_api_get_config.c index 8eddf9d7..708b7907 100644 --- a/src/lib/merchant_api_get_config.c +++ b/src/lib/merchant_api_get_config.c @@ -104,7 +104,10 @@ handle_config_finished (void *cls, { case MHD_HTTP_OK: { + const json_t *jcs; struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_object_const ("currencies", + &jcs), GNUNET_JSON_spec_string ("currency", &cr.details.ok.ci.currency), GNUNET_JSON_spec_string ("version", @@ -153,8 +156,41 @@ handle_config_finished (void *cls, } } } - vgh->cb (vgh->cb_cls, - &cr); + { + unsigned int nspec = json_object_size (jcs); + struct TALER_CurrencySpecification *cspecs; + unsigned int off = 0; + json_t *obj; + const char *curr; + + cspecs = GNUNET_new_array (nspec, + struct TALER_CurrencySpecification); + cr.details.ok.num_cspecs = nspec; + cr.details.ok.cspecs = cspecs; + json_object_foreach ((json_t *) jcs, curr, obj) + { + struct TALER_CurrencySpecification *cs = &cspecs[off++]; + struct GNUNET_JSON_Specification cspec[] = { + TALER_JSON_spec_currency_specification (curr, + cs), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (jcs, + cspec, + NULL, NULL)) + { + cr.hr.http_status = 0; + cr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + break; + } + } + vgh->cb (vgh->cb_cls, + &cr); + TALER_CONFIG_free_currencies (nspec, + cspecs); + } TALER_MERCHANT_config_get_cancel (vgh); return; } |