aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_helper.c')
-rw-r--r--src/backend/taler-merchant-httpd_helper.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c
index 75639af6..48a42f40 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -34,7 +34,7 @@ TMH_cmp_wire_account (
const struct TMH_WireMethod *wm)
{
const char *credit_facade_url = NULL;
- json_t *credit_facade_credentials = NULL;
+ const json_t *credit_facade_credentials = NULL;
const char *uri;
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_string ("payto_uri",
@@ -44,8 +44,8 @@ TMH_cmp_wire_account (
&credit_facade_url),
NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("credit_facade_credentials",
- &credit_facade_credentials),
+ GNUNET_JSON_spec_object_const ("credit_facade_credentials",
+ &credit_facade_credentials),
NULL),
GNUNET_JSON_spec_end ()
};
@@ -69,7 +69,6 @@ TMH_cmp_wire_account (
strcmp (wm->payto_uri,
uri))
{
- GNUNET_JSON_parse_free (ispec);
return GNUNET_SYSERR;
}
if ( (NULL == credit_facade_url) !=
@@ -77,24 +76,20 @@ TMH_cmp_wire_account (
(NULL == credit_facade_credentials) !=
(NULL == wm->credit_facade_credentials) )
{
- GNUNET_JSON_parse_free (ispec);
return GNUNET_NO;
}
if ( (NULL != credit_facade_url) &&
(0 != strcmp (credit_facade_url,
wm->credit_facade_url)) )
{
- GNUNET_JSON_parse_free (ispec);
return GNUNET_NO;
}
if ( (NULL != credit_facade_credentials) &&
(0 != json_equal (credit_facade_credentials,
wm->credit_facade_credentials)) )
{
- GNUNET_JSON_parse_free (ispec);
return GNUNET_NO;
}
- GNUNET_JSON_parse_free (ispec);
return GNUNET_YES;
}
@@ -115,7 +110,7 @@ TMH_accounts_array_valid (const json_t *accounts)
json_t *payto_uri = json_array_get (accounts,
i);
const char *credit_facade_url = NULL;
- json_t *credit_facade_credentials = NULL;
+ const json_t *credit_facade_credentials = NULL;
const char *uri;
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_string ("payto_uri",
@@ -125,8 +120,8 @@ TMH_accounts_array_valid (const json_t *accounts)
&credit_facade_url),
NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("credit_facade_credentials",
- &credit_facade_credentials),
+ GNUNET_JSON_spec_object_const ("credit_facade_credentials",
+ &credit_facade_credentials),
NULL),
GNUNET_JSON_spec_end ()
};
@@ -158,7 +153,6 @@ TMH_accounts_array_valid (const json_t *accounts)
"payto_uri"))))
{
GNUNET_break_op (0);
- GNUNET_JSON_parse_free (ispec);
return false;
}
}
@@ -173,7 +167,6 @@ TMH_accounts_array_valid (const json_t *accounts)
uri,
err);
GNUNET_free (err);
- GNUNET_JSON_parse_free (ispec);
return false;
}
}
@@ -198,13 +191,11 @@ TMH_accounts_array_valid (const json_t *accounts)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Invalid credit facade URL or credentials `%s'\n",
credit_facade_url);
- GNUNET_JSON_parse_free (ispec);
return false;
}
TALER_MERCHANT_BANK_auth_free (&auth);
}
- GNUNET_JSON_parse_free (ispec);
- }
+ } /* end for all accounts */
return true;
}
@@ -221,7 +212,7 @@ TMH_location_object_valid (const json_t *location)
const char *street = NULL;
const char *building = NULL;
const char *building_no = NULL;
- json_t *lines = NULL;
+ const json_t *lines = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("country",
@@ -260,8 +251,8 @@ TMH_location_object_valid (const json_t *location)
&building_no),
NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("address_lines",
- &lines),
+ GNUNET_JSON_spec_array_const ("address_lines",
+ &lines),
NULL),
GNUNET_JSON_spec_end ()
};
@@ -284,13 +275,6 @@ TMH_location_object_valid (const json_t *location)
size_t idx;
json_t *line;
- if (! json_is_array (lines))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Invalid location for field %s\n",
- "lines");
- return false;
- }
json_array_foreach (lines, idx, line)
{
if (! json_is_string (line))
@@ -326,7 +310,7 @@ TMH_products_array_valid (const json_t *products)
const char *unit = NULL;
struct TALER_Amount price = { .value = 0 };
const char *image_data_url = NULL;
- json_t *taxes = NULL;
+ const json_t *taxes = NULL;
struct GNUNET_TIME_Timestamp delivery_date = { 0 };
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
@@ -353,8 +337,8 @@ TMH_products_array_valid (const json_t *products)
&image_data_url),
NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("taxes",
- &taxes),
+ GNUNET_JSON_spec_array_const ("taxes",
+ &taxes),
NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_timestamp ("delivery_date",