From c22efccce8ce864ff8fd84fa968f5c0d44c36d3d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 21:12:27 +0100 Subject: migrate parsing logic to libtalermhd --- src/exchange/Makefile.am | 1 - src/exchange/taler-exchange-httpd.c | 3 +- src/exchange/taler-exchange-httpd_deposit.c | 17 +- src/exchange/taler-exchange-httpd_parsing.c | 286 --------------------- src/exchange/taler-exchange-httpd_parsing.h | 139 ---------- src/exchange/taler-exchange-httpd_payback.c | 17 +- src/exchange/taler-exchange-httpd_refresh_link.c | 11 +- src/exchange/taler-exchange-httpd_refresh_melt.c | 18 +- src/exchange/taler-exchange-httpd_refresh_reveal.c | 57 ++-- src/exchange/taler-exchange-httpd_refund.c | 17 +- src/exchange/taler-exchange-httpd_reserve_status.c | 12 +- .../taler-exchange-httpd_reserve_withdraw.c | 18 +- src/exchange/taler-exchange-httpd_test.c | 123 +++++---- .../taler-exchange-httpd_track_transaction.c | 18 +- src/exchange/taler-exchange-httpd_track_transfer.c | 12 +- 15 files changed, 158 insertions(+), 591 deletions(-) delete mode 100644 src/exchange/taler-exchange-httpd_parsing.c delete mode 100644 src/exchange/taler-exchange-httpd_parsing.h (limited to 'src') diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index 899e98d2e..8e1621821 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -47,7 +47,6 @@ taler_exchange_httpd_SOURCES = \ taler-exchange-httpd_deposit.c taler-exchange-httpd_deposit.h \ taler-exchange-httpd_keystate.c taler-exchange-httpd_keystate.h \ taler-exchange-httpd_mhd.c taler-exchange-httpd_mhd.h \ - taler-exchange-httpd_parsing.c taler-exchange-httpd_parsing.h \ taler-exchange-httpd_payback.c taler-exchange-httpd_payback.h \ taler-exchange-httpd_refresh_link.c taler-exchange-httpd_refresh_link.h \ taler-exchange-httpd_refresh_melt.c taler-exchange-httpd_refresh_melt.h \ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b3f73de60..30efb8bc2 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -28,7 +28,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_deposit.h" #include "taler-exchange-httpd_refund.h" @@ -175,7 +174,7 @@ handle_mhd_completion_callback (void *cls, "Request completed\n"); if (NULL == ecls) return; - TEH_PARSE_post_cleanup_callback (ecls->opaque_post_parsing_context); + TALER_MHD_parse_post_cleanup_callback (ecls->opaque_post_parsing_context); GNUNET_free (ecls); *con_cls = NULL; /* check that we didn't leave any transactions hanging */ diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 1db8d7621..28116e28b 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -30,7 +30,6 @@ #include #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_deposit.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -428,11 +427,11 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || @@ -441,9 +440,9 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, memset (&deposit, 0, sizeof (deposit)); - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_parsing.c b/src/exchange/taler-exchange-httpd_parsing.c deleted file mode 100644 index fb8932b9a..000000000 --- a/src/exchange/taler-exchange-httpd_parsing.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see -*/ - -/** - * @file taler-exchange-httpd_parsing.c - * @brief functions to parse incoming requests (MHD arguments and JSON snippets) - * @author Florian Dold - * @author Benedikt Mueller - * @author Christian Grothoff - */ - -#include "platform.h" -#include -#include -#include "taler_json_lib.h" -#include "taler-exchange-httpd_parsing.h" -#include "taler-exchange-httpd_responses.h" - - -/** - * Maximum POST request size. - */ -#define REQUEST_BUFFER_MAX (1024 * 1024) - - -/** - * Process a POST request containing a JSON object. This function - * realizes an MHD POST processor that will (incrementally) process - * JSON data uploaded to the HTTP server. It will store the required - * state in the @a con_cls, which must be cleaned up using - * #TEH_PARSE_post_cleanup_callback(). - * - * @param connection the MHD connection - * @param con_cls the closure (points to a `struct Buffer *`) - * @param upload_data the POST data - * @param upload_data_size number of bytes in @a upload_data - * @param json the JSON object for a completed request - * @return - * #GNUNET_YES if json object was parsed or at least - * may be parsed in the future (call again); - * `*json` will be NULL if we need to be called again, - * and non-NULL if we are done. - * #GNUNET_NO is request incomplete or invalid - * (error message was generated) - * #GNUNET_SYSERR on internal error - * (we could not even queue an error message, - * close HTTP session with MHD_NO) - */ -int -TEH_PARSE_post_json (struct MHD_Connection *connection, - void **con_cls, - const char *upload_data, - size_t *upload_data_size, - json_t **json) -{ - enum GNUNET_JSON_PostResult pr; - - pr = GNUNET_JSON_post_parser (REQUEST_BUFFER_MAX, - connection, - con_cls, - upload_data, - upload_data_size, - json); - switch (pr) - { - - case GNUNET_JSON_PR_OUT_OF_MEMORY: - return (MHD_NO == TEH_RESPONSE_reply_internal_error - (connection, - TALER_EC_PARSER_OUT_OF_MEMORY, - "out of memory")) ? GNUNET_SYSERR : GNUNET_NO; - - case GNUNET_JSON_PR_CONTINUE: - return GNUNET_YES; - - case GNUNET_JSON_PR_REQUEST_TOO_LARGE: - return (MHD_NO == TEH_RESPONSE_reply_request_too_large - (connection)) ? GNUNET_SYSERR : GNUNET_NO; - - case GNUNET_JSON_PR_JSON_INVALID: - return (MHD_YES == - TEH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; - case GNUNET_JSON_PR_SUCCESS: - GNUNET_break (NULL != *json); - return GNUNET_YES; - } - /* this should never happen */ - GNUNET_break (0); - return GNUNET_SYSERR; -} - - -/** - * Function called whenever we are done with a request - * to clean up our state. - * - * @param con_cls value as it was left by - * #TEH_PARSE_post_json(), to be cleaned up - */ -void -TEH_PARSE_post_cleanup_callback (void *con_cls) -{ - GNUNET_JSON_post_parser_cleanup (con_cls); -} - - -/** - * Extract base32crockford encoded data from request. - * - * Queues an error response to the connection if the parameter is - * missing or invalid. - * - * @param connection the MHD connection - * @param param_name the name of the parameter with the key - * @param[out] out_data pointer to store the result - * @param out_size expected size of data - * @return - * #GNUNET_YES if the the argument is present - * #GNUNET_NO if the argument is absent or malformed - * #GNUNET_SYSERR on internal error (error response could not be sent) - */ -int -TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size) -{ - const char *str; - - str = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - param_name); - if (NULL == str) - { - return (MHD_NO == - TEH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; - } - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (str, - strlen (str), - out_data, - out_size)) - return (MHD_NO == - TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; - return GNUNET_OK; -} - - -/** - * Parse JSON object into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_data (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec) -{ - int ret; - const char *error_json_name; - unsigned int error_line; - - ret = GNUNET_JSON_parse (root, - spec, - &error_json_name, - &error_line); - if (GNUNET_SYSERR == ret) - { - if (NULL == error_json_name) - error_json_name = ""; - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:I, s:s, s:I}", - "error", "parse error", - "code", - (json_int_t) - TALER_EC_JSON_INVALID_WITH_DETAILS, - "field", error_json_name, - "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - return GNUNET_YES; -} - - -/** - * Parse JSON array into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @param ... -1-terminated list of array offsets of type 'int' - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_array (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec, - ...) -{ - int ret; - const char *error_json_name; - unsigned int error_line; - va_list ap; - json_int_t dim; - - va_start (ap, spec); - dim = 0; - while ( (-1 != (ret = va_arg (ap, int))) && - (NULL != root) ) - { - dim++; - root = json_array_get (root, ret); - } - va_end (ap); - if (NULL == root) - { - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:I}", - "error", "parse error", - "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - ret = GNUNET_JSON_parse (root, - spec, - &error_json_name, - &error_line); - if (GNUNET_SYSERR == ret) - { - if (NULL == error_json_name) - error_json_name = ""; - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:s, s:I}", - "error", "parse error", - "field", error_json_name, - "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - return GNUNET_YES; -} - - -/* end of taler-exchange-httpd_parsing.c */ diff --git a/src/exchange/taler-exchange-httpd_parsing.h b/src/exchange/taler-exchange-httpd_parsing.h deleted file mode 100644 index 9c5381756..000000000 --- a/src/exchange/taler-exchange-httpd_parsing.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see -*/ -/** - * @file taler-exchange-httpd_parsing.h - * @brief functions to parse incoming requests - * @author Florian Dold - * @author Benedikt Mueller - * @author Christian Grothoff - */ -#ifndef TALER_EXCHANGE_HTTPD_PARSING_H -#define TALER_EXCHANGE_HTTPD_PARSING_H - -#include -#include -#include "taler_util.h" -#include "taler_json_lib.h" - - -/** - * Process a POST request containing a JSON object. This - * function realizes an MHD POST processor that will - * (incrementally) process JSON data uploaded to the HTTP - * server. It will store the required state in the - * "connection_cls", which must be cleaned up using - * #TEH_PARSE_post_cleanup_callback(). - * - * @param connection the MHD connection - * @param con_cls the closure (points to a `struct Buffer *`) - * @param upload_data the POST data - * @param upload_data_size number of bytes in @a upload_data - * @param json the JSON object for a completed request - * @return - * #GNUNET_YES if json object was parsed or at least - * may be parsed in the future (call again); - * `*json` will be NULL if we need to be called again, - * and non-NULL if we are done. - * #GNUNET_NO is request incomplete or invalid - * (error message was generated) - * #GNUNET_SYSERR on internal error - * (we could not even queue an error message, - * close HTTP session with MHD_NO) - */ -int -TEH_PARSE_post_json (struct MHD_Connection *connection, - void **con_cls, - const char *upload_data, - size_t *upload_data_size, - json_t **json); - - -/** - * Function called whenever we are done with a request - * to clean up our state. - * - * @param con_cls value as it was left by - * #TEH_PARSE_post_json(), to be cleaned up - */ -void -TEH_PARSE_post_cleanup_callback (void *con_cls); - - -/** - * Parse JSON object into components based on the given field - * specification. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param spec field specification for the parser - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_data (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec); - - -/** - * Parse JSON array into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @param ... -1-terminated list of array offsets of type 'int' - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_array (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec, - ...); - - -/** - * Extraxt fixed-size base32crockford encoded data from request. - * - * Queues an error response to the connection if the parameter is missing or - * invalid. - * - * @param connection the MHD connection - * @param param_name the name of the parameter with the key - * @param[out] out_data pointer to store the result - * @param out_size expected size of @a out_data - * @return - * #GNUNET_YES if the the argument is present - * #GNUNET_NO if the argument is absent or malformed - * #GNUNET_SYSERR on internal error (error response could not be sent) - */ -int -TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size); - - -#endif /* TALER_EXCHANGE_HTTPD_PARSING_H */ diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index e8a179f1b..f5f315bed 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -28,7 +28,6 @@ #include #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_payback.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -605,18 +604,18 @@ TEH_PAYBACK_handler_payback (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_refresh_link.c b/src/exchange/taler-exchange-httpd_refresh_link.c index 10aed2df8..c3d36e29b 100644 --- a/src/exchange/taler-exchange-httpd_refresh_link.c +++ b/src/exchange/taler-exchange-httpd_refresh_link.c @@ -25,7 +25,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_link.h" #include "taler-exchange-httpd_responses.h" @@ -204,11 +203,11 @@ TEH_REFRESH_handler_refresh_link (struct TEH_RequestHandler *rh, memset (&ctx, 0, sizeof (ctx)); - res = TEH_PARSE_mhd_request_arg_data (connection, - "coin_pub", - &ctx.coin_pub, - sizeof (struct - TALER_CoinSpendPublicKeyP)); + res = TALER_MHD_parse_request_arg_data (connection, + "coin_pub", + &ctx.coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; if (GNUNET_OK != res) diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 2de5027f1..20e788452 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -24,8 +24,8 @@ #include #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_melt.h" #include "taler-exchange-httpd_responses.h" @@ -482,11 +482,11 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &root); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &root); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || @@ -496,9 +496,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, memset (&rmc, 0, sizeof (rmc)); - res = TEH_PARSE_json_data (connection, - root, - spec); + res = TALER_MHD_parse_json_data (connection, + root, + spec); json_decref (root); if (GNUNET_OK != res) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index a1200f39e..5276a105a 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -25,7 +25,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_reveal.h" #include "taler-exchange-httpd_responses.h" @@ -586,11 +585,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, }; int res; - res = TEH_PARSE_json_array (connection, - tp_json, - trans_spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + tp_json, + trans_spec, + i, + -1); if (GNUNET_OK != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } @@ -627,11 +626,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, unsigned int hc; enum TALER_ErrorCode ec; - res = TEH_PARSE_json_array (connection, - new_denoms_h_json, - spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + new_denoms_h_json, + spec, + i, + -1); if (GNUNET_OK != res) { TEH_KS_release (key_state); @@ -664,11 +663,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_json_array (connection, - coin_evs, - spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + coin_evs, + spec, + i, + -1); if (GNUNET_OK != res) { for (unsigned int j = 0; j #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_refund.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -526,18 +525,18 @@ TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_reserve_status.c b/src/exchange/taler-exchange-httpd_reserve_status.c index 0e46c0b24..60cdd4f5a 100644 --- a/src/exchange/taler-exchange-httpd_reserve_status.c +++ b/src/exchange/taler-exchange-httpd_reserve_status.c @@ -24,8 +24,8 @@ #include #include #include "taler_mhd_lib.h" +#include "taler_json_lib.h" #include "taler-exchange-httpd_reserve_status.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -137,11 +137,11 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, int res; int mhd_ret; - res = TEH_PARSE_mhd_request_arg_data (connection, - "reserve_pub", - &rsc.reserve_pub, - sizeof (struct - TALER_ReservePublicKeyP)); + res = TALER_MHD_parse_request_arg_data (connection, + "reserve_pub", + &rsc.reserve_pub, + sizeof (struct + TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c index 229da564a..120a1e86a 100644 --- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c +++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c @@ -26,9 +26,9 @@ #include "platform.h" #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-exchange-httpd_reserve_withdraw.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -394,18 +394,18 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &root); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &root); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == root) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - root, - spec); + res = TALER_MHD_parse_json_data (connection, + root, + spec); json_decref (root); if (GNUNET_OK != res) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 4d0e7d691..4b3c50b2c 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -27,7 +27,6 @@ #include "taler_mhd_lib.h" #include "taler_signatures.h" #include "taler-exchange-httpd_test.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" @@ -70,18 +69,18 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_CRYPTO_hash (in_ptr, @@ -135,18 +134,18 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, }; char *out; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -215,18 +214,18 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -278,18 +277,18 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -347,18 +346,18 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, }; struct GNUNET_CRYPTO_EddsaPrivateKey *pk; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -482,18 +481,18 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -563,18 +562,18 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, }; struct TALER_TransferSecretP secret; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -609,11 +608,11 @@ TEH_TEST_handler_test (struct TEH_RequestHandler *rh, json_t *json; int res; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) diff --git a/src/exchange/taler-exchange-httpd_track_transaction.c b/src/exchange/taler-exchange-httpd_track_transaction.c index 5a057d665..757f28bad 100644 --- a/src/exchange/taler-exchange-httpd_track_transaction.c +++ b/src/exchange/taler-exchange-httpd_track_transaction.c @@ -23,9 +23,9 @@ #include #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler_signatures.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_track_transaction.h" #include "taler-exchange-httpd_responses.h" @@ -366,18 +366,18 @@ TEH_TRACKING_handler_track_transaction (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); if (GNUNET_OK != res) { json_decref (json); diff --git a/src/exchange/taler-exchange-httpd_track_transfer.c b/src/exchange/taler-exchange-httpd_track_transfer.c index 83521f736..f40d7c819 100644 --- a/src/exchange/taler-exchange-httpd_track_transfer.c +++ b/src/exchange/taler-exchange-httpd_track_transfer.c @@ -24,10 +24,10 @@ #include #include #include "taler_signatures.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_track_transfer.h" #include "taler-exchange-httpd_responses.h" +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler_wire_lib.h" @@ -503,11 +503,11 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, int mhd_ret; memset (&ctx, 0, sizeof (ctx)); - res = TEH_PARSE_mhd_request_arg_data (connection, - "wtid", - &ctx.wtid, - sizeof (struct - TALER_WireTransferIdentifierRawP)); + res = TALER_MHD_parse_request_arg_data (connection, + "wtid", + &ctx.wtid, + sizeof (struct + TALER_WireTransferIdentifierRawP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) -- cgit v1.2.3