summaryrefslogtreecommitdiff
path: root/src/lib/merchant_api_get_instances.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/merchant_api_get_instances.c')
-rw-r--r--src/lib/merchant_api_get_instances.c77
1 files changed, 22 insertions, 55 deletions
diff --git a/src/lib/merchant_api_get_instances.c b/src/lib/merchant_api_get_instances.c
index 5f26eb48..c0553941 100644
--- a/src/lib/merchant_api_get_instances.c
+++ b/src/lib/merchant_api_get_instances.c
@@ -81,7 +81,6 @@ parse_instances (const json_t *json,
struct TALER_MERCHANT_InstanceInformation iis[GNUNET_NZL (iis_len)];
size_t index;
json_t *value;
- enum GNUNET_GenericReturnValue ret;
struct TALER_MERCHANT_InstancesGetResponse igr = {
.hr.http_status = MHD_HTTP_OK,
.hr.reply = json,
@@ -89,7 +88,6 @@ parse_instances (const json_t *json,
.details.ok.iis = iis
};
- ret = GNUNET_OK;
json_array_foreach (ia, index, value) {
struct TALER_MERCHANT_InstanceInformation *ii = &iis[index];
const char *uts;
@@ -102,8 +100,8 @@ parse_instances (const json_t *json,
&ii->id),
GNUNET_JSON_spec_fixed_auto ("merchant_pub",
&ii->merchant_pub),
- GNUNET_JSON_spec_json ("payment_targets",
- &ii->payment_targets),
+ GNUNET_JSON_spec_array_const ("payment_targets",
+ &ii->payment_targets),
GNUNET_JSON_spec_end ()
};
@@ -113,24 +111,14 @@ parse_instances (const json_t *json,
NULL, NULL))
{
GNUNET_break_op (0);
- ret = GNUNET_SYSERR;
- continue;
+ return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_KYCLOGIC_kyc_user_type_from_string (uts,
&ii->ut))
{
GNUNET_break_op (0);
- ret = GNUNET_SYSERR;
- GNUNET_JSON_parse_free (spec);
- break;
- }
- if (! json_is_array (ii->payment_targets))
- {
- GNUNET_break_op (0);
- ret = GNUNET_SYSERR;
- GNUNET_JSON_parse_free (spec);
- break;
+ return GNUNET_SYSERR;
}
for (unsigned int i = 0; i<json_array_size (ii->payment_targets); i++)
{
@@ -138,27 +126,14 @@ parse_instances (const json_t *json,
i)))
{
GNUNET_break_op (0);
- ret = GNUNET_SYSERR;
- GNUNET_JSON_parse_free (spec);
- break;
+ return GNUNET_SYSERR;
}
}
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_JSON_parse_free (spec);
- break;
- }
- }
- if (GNUNET_OK == ret)
- {
- igh->cb (igh->cb_cls,
- &igr);
- igh->cb = NULL; /* just to be sure */
- }
- for (unsigned int i = 0; i<iis_len; i++)
- if (NULL != iis[i].payment_targets)
- json_decref (iis[i].payment_targets);
- return ret;
+ } /* for all instances */
+ igh->cb (igh->cb_cls,
+ &igr);
+ igh->cb = NULL; /* just to be sure */
+ return GNUNET_OK;
}
@@ -190,10 +165,10 @@ handle_instances_finished (void *cls,
{
case MHD_HTTP_OK:
{
- json_t *instances;
+ const json_t *instances;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("instances",
- &instances),
+ GNUNET_JSON_spec_array_const ("instances",
+ &instances),
GNUNET_JSON_spec_end ()
};
@@ -204,26 +179,18 @@ handle_instances_finished (void *cls,
{
igr.hr.http_status = 0;
igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
}
- else
+ if (GNUNET_OK ==
+ parse_instances (json,
+ instances,
+ igh))
{
- if ( (! json_is_array (instances)) ||
- (GNUNET_OK ==
- parse_instances (json,
- instances,
- igh)) )
- {
- GNUNET_JSON_parse_free (spec);
- TALER_MERCHANT_instances_get_cancel (igh);
- return;
- }
- else
- {
- igr.hr.http_status = 0;
- igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
- }
+ TALER_MERCHANT_instances_get_cancel (igh);
+ return;
}
- GNUNET_JSON_parse_free (spec);
+ igr.hr.http_status = 0;
+ igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
case MHD_HTTP_UNAUTHORIZED: