From 1db139a7f3b74b2dc4135ab8b42d625415705d63 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 31 Jul 2021 22:50:16 +0200 Subject: -eliminating some legacy json_pack calls from Anastasis --- .../anastasis_authorization_plugin_email.c | 19 ++++++++----------- .../anastasis_authorization_plugin_file.c | 10 +++------- .../anastasis_authorization_plugin_post.c | 20 ++++++++------------ .../anastasis_authorization_plugin_sms.c | 20 ++++++++------------ 4 files changed, 27 insertions(+), 42 deletions(-) (limited to 'src/authorization') diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c index 33c400b..5448b7d 100644 --- a/src/authorization/anastasis_authorization_plugin_email.c +++ b/src/authorization/anastasis_authorization_plugin_email.c @@ -436,22 +436,19 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as, if (TALER_MHD_xmime_matches (mime, "application/json")) { - json_t *body; char *user; user = GNUNET_strndup (as->email, len); - body = json_pack ("{s:I, s:s, s:s}", - "code", - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED, - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), - "detail", - user); + resp = TALER_MHD_MAKE_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)), + GNUNET_JSON_pack_string ("detail", + user)); GNUNET_free (user); - GNUNET_break (NULL != body); - resp = TALER_MHD_make_json (body); } else { diff --git a/src/authorization/anastasis_authorization_plugin_file.c b/src/authorization/anastasis_authorization_plugin_file.c index 210ade7..15c22a1 100644 --- a/src/authorization/anastasis_authorization_plugin_file.c +++ b/src/authorization/anastasis_authorization_plugin_file.c @@ -209,13 +209,9 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as, if (TALER_MHD_xmime_matches (mime, "application/json")) { - json_t *body; - - body = json_pack ("{s:s}", - "filename", - as->filename); - GNUNET_break (NULL != body); - resp = TALER_MHD_make_json (body); + resp = TALER_MHD_MAKE_JSON_PACK ( + GNUNET_JSON_pack_string ("filename", + as->filename)); } else { diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c index 1f20ff3..1240316 100644 --- a/src/authorization/anastasis_authorization_plugin_post.c +++ b/src/authorization/anastasis_authorization_plugin_post.c @@ -500,18 +500,14 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as, if (TALER_MHD_xmime_matches (mime, "application/json")) { - json_t *body; - - body = json_pack ("{s:I, s:s, s:s}", - "code", - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED, - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), - "detail", - zip); - GNUNET_break (NULL != body); - resp = TALER_MHD_make_json (body); + resp = TALER_MHD_MAKE_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)), + GNUNET_JSON_pack_string ("detail", + zip)); } else { diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c index 01b5f73..0cd36c5 100644 --- a/src/authorization/anastasis_authorization_plugin_sms.c +++ b/src/authorization/anastasis_authorization_plugin_sms.c @@ -433,18 +433,14 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as, if (TALER_MHD_xmime_matches (mime, "application/json")) { - json_t *body; - - body = json_pack ("{s:I, s:s, s:s}", - "code", - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED, - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), - "detail", - end); - GNUNET_break (NULL != body); - resp = TALER_MHD_make_json (body); + resp = TALER_MHD_MAKE_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)), + GNUNET_JSON_pack_string ("detail", + end)); } else { -- cgit v1.2.3