summaryrefslogtreecommitdiff
path: root/src/restclient/anastasis_api_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/restclient/anastasis_api_config.c')
-rw-r--r--src/restclient/anastasis_api_config.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/restclient/anastasis_api_config.c b/src/restclient/anastasis_api_config.c
index 215d224..f82cd9e 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -86,6 +86,10 @@ handle_config_finished (void *cls,
{
struct ANASTASIS_ConfigOperation *co = cls;
const json_t *json = response;
+ struct ANASTASIS_Config acfg = {
+ .http_status = response_code,
+ .response = json
+ };
co->job = NULL;
switch (response_code)
@@ -99,27 +103,26 @@ handle_config_finished (void *cls,
case MHD_HTTP_OK:
{
const char *name;
- struct ANASTASIS_Config acfg;
const json_t *methods;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
GNUNET_JSON_spec_string ("business_name",
- &acfg.business_name),
+ &acfg.details.ok.business_name),
GNUNET_JSON_spec_string ("version",
- &acfg.version),
+ &acfg.details.ok.version),
GNUNET_JSON_spec_array_const ("methods",
&methods),
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
- &acfg.storage_limit_in_megabytes),
+ &acfg.details.ok.storage_limit_in_megabytes),
TALER_JSON_spec_amount_any ("annual_fee",
- &acfg.annual_fee),
+ &acfg.details.ok.annual_fee),
TALER_JSON_spec_amount_any ("truth_upload_fee",
- &acfg.truth_upload_fee),
+ &acfg.details.ok.truth_upload_fee),
TALER_JSON_spec_amount_any ("liability_limit",
- &acfg.liability_limit),
+ &acfg.details.ok.liability_limit),
GNUNET_JSON_spec_fixed_auto ("provider_salt",
- &acfg.provider_salt),
+ &acfg.details.ok.provider_salt),
GNUNET_JSON_spec_end ()
};
@@ -132,14 +135,16 @@ handle_config_finished (void *cls,
json_dumpf (json,
stderr,
JSON_INDENT (2));
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
if (0 != strcmp (name,
"anastasis"))
{
GNUNET_JSON_parse_free (spec);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
{
@@ -148,7 +153,7 @@ handle_config_finished (void *cls,
unsigned int current;
char dummy;
- if (3 != sscanf (acfg.version,
+ if (3 != sscanf (acfg.details.ok.version,
"%u:%u:%u%c",
&current,
&revision,
@@ -156,7 +161,8 @@ handle_config_finished (void *cls,
&dummy))
{
GNUNET_break_op (0);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
break;
}
if ( (ANASTASIS_PROTOCOL_CURRENT < current) &&
@@ -164,7 +170,8 @@ handle_config_finished (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Provider protocol version too new\n");
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
break;
}
if ( (ANASTASIS_PROTOCOL_CURRENT > current) &&
@@ -173,16 +180,18 @@ handle_config_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Provider protocol version too old\n");
GNUNET_break_op (0);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
break;
}
}
- acfg.methods_length = json_array_size (methods);
+ acfg.details.ok.methods_length = json_array_size (methods);
{
struct ANASTASIS_AuthorizationMethodConfig mcfg[GNUNET_NZL (
- acfg.methods_length)];
+ acfg.details.ok.
+ methods_length)];
- for (unsigned int i = 0; i<acfg.methods_length; i++)
+ for (unsigned int i = 0; i<acfg.details.ok.methods_length; i++)
{
struct ANASTASIS_AuthorizationMethodConfig *m = &mcfg[i];
struct GNUNET_JSON_Specification spec[] = {
@@ -200,16 +209,16 @@ handle_config_finished (void *cls,
NULL, NULL)) )
{
GNUNET_break_op (0);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
goto end;
}
}
- acfg.methods = mcfg;
+ acfg.details.ok.methods = mcfg;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Good backend found at `%s'\n",
co->url);
co->cb (co->cb_cls,
- MHD_HTTP_OK,
&acfg);
ANASTASIS_config_cancel (co);
return;
@@ -236,8 +245,7 @@ handle_config_finished (void *cls,
}
end:
co->cb (co->cb_cls,
- response_code,
- NULL);
+ &acfg);
ANASTASIS_config_cancel (co);
}