diff options
Diffstat (limited to 'src/exchange')
34 files changed, 148 insertions, 139 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index de251acb..a8e29d30 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -42,7 +42,7 @@ #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_wire.h" #include "taler_exchangedb_plugin.h" - +#include <gnunet/gnunet_mhd_compat.h> /** * Backlog for listen operation on unix domain sockets. @@ -158,7 +158,7 @@ static unsigned long long req_max; * @param root uploaded JSON data * @return MHD result code */ -typedef int +typedef MHD_RESULT (*CoinOpHandler)(struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root); @@ -175,7 +175,7 @@ typedef int * reserve public key, the second one should be "withdraw") * @return MHD result code */ -static int +static MHD_RESULT handle_post_coins (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const json_t *root, @@ -297,7 +297,7 @@ handle_mhd_completion_callback (void *cls, * @param[in,out] upload_data_size number of bytes in @a upload_data * @return MHD result code */ -static int +static MHD_RESULT proceed_with_handler (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *url, @@ -308,7 +308,7 @@ proceed_with_handler (const struct TEH_RequestHandler *rh, const char *args[rh->nargs + 1]; size_t ulen = strlen (url) + 1; json_t *root = NULL; - int ret; + MHD_RESULT ret; /* We do check for "ulen" here, because we'll later stack-allocate a buffer of that size and don't want to enable malicious clients to cause us @@ -331,7 +331,7 @@ proceed_with_handler (const struct TEH_RequestHandler *rh, if (0 == strcasecmp (rh->method, MHD_HTTP_METHOD_POST)) { - int res; + enum GNUNET_GenericReturnValue res; res = TALER_MHD_parse_post_json (connection, inner_cls, @@ -433,7 +433,7 @@ proceed_with_handler (const struct TEH_RequestHandler *rh, * @param con_cls closure for request (a `struct Buffer *`) * @return MHD result code */ -static int +static MHD_RESULT handle_mhd_request (void *cls, struct MHD_Connection *connection, const char *url, @@ -606,7 +606,7 @@ handle_mhd_request (void *cls, /* on repeated requests, check our cache first */ if (NULL != ecls->rh) { - int ret; + MHD_RESULT ret; const char *start; if ('\0' == url[0]) @@ -669,7 +669,7 @@ handle_mhd_request (void *cls, if (0 == strcasecmp (method, rh->method)) { - int ret; + MHD_RESULT ret; /* cache to avoid the loop next time */ ecls->rh = rh; @@ -698,7 +698,7 @@ handle_mhd_request (void *cls, /* No handler matches, generate not found */ { - int ret; + MHD_RESULT ret; ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, @@ -716,7 +716,7 @@ handle_mhd_request (void *cls, * * @return #GNUNET_OK on success */ -static int +static enum GNUNET_GenericReturnValue exchange_serve_process_config (void) { if (GNUNET_OK != diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h index 512fae8f..b1e8079f 100644 --- a/src/exchange/taler-exchange-httpd.h +++ b/src/exchange/taler-exchange-httpd.h @@ -26,6 +26,7 @@ #include <microhttpd.h> #include "taler_json_lib.h" #include "taler_crypto_lib.h" +#include <gnunet/gnunet_mhd_compat.h> /** @@ -100,9 +101,9 @@ struct TEH_RequestHandler * @param args array of arguments, needs to be of length @e args_expected * @return MHD result code */ - int (*get)(const struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - const char *const args[]); + MHD_RESULT (*get)(const struct TEH_RequestHandler *rh, + struct MHD_Connection *connection, + const char *const args[]); /** @@ -115,10 +116,10 @@ struct TEH_RequestHandler * @param args array of arguments, needs to be of length @e args_expected * @return MHD result code */ - int (*post)(const struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - const json_t *root, - const char *const args[]); + MHD_RESULT (*post)(const struct TEH_RequestHandler *rh, + struct MHD_Connection *connection, + const json_t *root, + const char *const args[]); } handler; diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index f9811622..2e8f0a02 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -58,7 +58,7 @@ enum GNUNET_DB_QueryStatus TEH_DB_know_coin_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct TEH_DB_KnowCoinContext *kcc = cls; enum GNUNET_DB_QueryStatus qs; @@ -96,10 +96,10 @@ TEH_DB_know_coin_transaction (void *cls, * @param cb_cls closure for @a cb, must be read-only! * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ -int +enum GNUNET_GenericReturnValue TEH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, + MHD_RESULT *mhd_ret, TEH_DB_TransactionCallback cb, void *cb_cls) { diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 380f00d3..f97f488d 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h @@ -23,6 +23,7 @@ #include <microhttpd.h> #include "taler_exchangedb_plugin.h" +#include <gnunet/gnunet_mhd_compat.h> /** @@ -60,7 +61,7 @@ enum GNUNET_DB_QueryStatus TEH_DB_know_coin_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret); + MHD_RESULT *mhd_ret); /** @@ -82,7 +83,7 @@ typedef enum GNUNET_DB_QueryStatus (*TEH_DB_TransactionCallback)(void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret); + MHD_RESULT *mhd_ret); /** @@ -101,10 +102,10 @@ typedef enum GNUNET_DB_QueryStatus * @param cb_cls closure for @a cb, must be read-only! * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ -int +enum GNUNET_GenericReturnValue TEH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, + MHD_RESULT *mhd_ret, TEH_DB_TransactionCallback cb, void *cb_cls); diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index d3439165..ad5b8286 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -53,7 +53,7 @@ * @param amount_without_fee fraction of coin value to deposit, without the fee * @return MHD result code */ -static int +static MHD_RESULT reply_deposit_success (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct GNUNET_HashCode *h_wire, @@ -133,7 +133,7 @@ static enum GNUNET_DB_QueryStatus deposit_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct DepositContext *dc = cls; const struct TALER_EXCHANGEDB_Deposit *deposit = dc->deposit; @@ -301,7 +301,7 @@ check_timestamp_current (struct GNUNET_TIME_Absolute ts) * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_deposit (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root) @@ -471,7 +471,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, /* make sure coin is 'known' in database */ { - int mhd_ret; + MHD_RESULT mhd_ret; struct TEH_DB_KnowCoinContext kcc = { .coin = &deposit.coin, .connection = connection @@ -524,7 +524,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, /* execute transaction */ dc.deposit = &deposit; { - int mhd_ret; + MHD_RESULT mhd_ret; if (GNUNET_OK != TEH_DB_run_transaction (connection, @@ -541,7 +541,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, /* generate regular response */ { struct TALER_Amount amount_without_fee; - int res; + MHD_RESULT res; GNUNET_assert (0 <= TALER_amount_subtract (&amount_without_fee, diff --git a/src/exchange/taler-exchange-httpd_deposit.h b/src/exchange/taler-exchange-httpd_deposit.h index 642e29dd..a4d598a6 100644 --- a/src/exchange/taler-exchange-httpd_deposit.h +++ b/src/exchange/taler-exchange-httpd_deposit.h @@ -40,7 +40,7 @@ * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_deposit (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root); diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c index 04d24f49..a2226b7e 100644 --- a/src/exchange/taler-exchange-httpd_deposits_get.c +++ b/src/exchange/taler-exchange-httpd_deposits_get.c @@ -45,7 +45,7 @@ * @param exec_time execution time of the wire transfer * @return MHD result code */ -static int +static MHD_RESULT reply_deposit_details (struct MHD_Connection *connection, const struct GNUNET_HashCode *h_contract_terms, const struct GNUNET_HashCode *h_wire, @@ -213,7 +213,7 @@ static enum GNUNET_DB_QueryStatus deposits_get_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct DepositWtidContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -258,13 +258,13 @@ deposits_get_transaction (void *cls, * @param merchant_pub public key from the merchant * @return MHD result code */ -static int +static MHD_RESULT handle_track_transaction_request ( struct MHD_Connection *connection, const struct TALER_DepositTrackPS *tps, const struct TALER_MerchantPublicKeyP *merchant_pub) { - int mhd_ret; + MHD_RESULT mhd_ret; struct DepositWtidContext ctx = { .pending = GNUNET_NO, .tps = tps, @@ -310,12 +310,12 @@ handle_track_transaction_request ( * h_wire, merchant_pub, h_contract_terms and coin_pub) * @return MHD result code */ -int +MHD_RESULT TEH_handler_deposits_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[4]) { - int res; + enum GNUNET_GenericReturnValue res; struct TALER_MerchantSignatureP merchant_sig; struct TALER_DepositTrackPS tps = { .purpose.size = htonl (sizeof (tps)), diff --git a/src/exchange/taler-exchange-httpd_deposits_get.h b/src/exchange/taler-exchange-httpd_deposits_get.h index 36d072aa..a745c5de 100644 --- a/src/exchange/taler-exchange-httpd_deposits_get.h +++ b/src/exchange/taler-exchange-httpd_deposits_get.h @@ -36,7 +36,7 @@ * h_wire, merchant_pub, h_contract_terms and coin_pub) * @return MHD result code */ -int +MHD_RESULT TEH_handler_deposits_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[4]); diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index acdec8d7..152d2dad 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -669,7 +669,7 @@ static enum GNUNET_DB_QueryStatus add_revocations_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct AddRevocationContext *arc = cls; enum GNUNET_DB_QueryStatus qs; @@ -709,7 +709,7 @@ static enum GNUNET_DB_QueryStatus add_denomination_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { const struct TALER_EXCHANGEDB_DenominationKey *dki = cls; enum GNUNET_DB_QueryStatus qs; @@ -2467,12 +2467,12 @@ krd_search_comparator (const void *key, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_keys (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) { - int ret; + MHD_RESULT ret; const char *have_cherrypick; const char *have_fakenow; struct GNUNET_TIME_Absolute last_issue_date; diff --git a/src/exchange/taler-exchange-httpd_keystate.h b/src/exchange/taler-exchange-httpd_keystate.h index 65a006bb..86bdc59b 100644 --- a/src/exchange/taler-exchange-httpd_keystate.h +++ b/src/exchange/taler-exchange-httpd_keystate.h @@ -220,7 +220,7 @@ TEH_KS_sign_ (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_keys (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); diff --git a/src/exchange/taler-exchange-httpd_link.c b/src/exchange/taler-exchange-httpd_link.c index 4738a435..948c8eb0 100644 --- a/src/exchange/taler-exchange-httpd_link.c +++ b/src/exchange/taler-exchange-httpd_link.c @@ -142,7 +142,7 @@ static enum GNUNET_DB_QueryStatus link_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct HTD_Context *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -180,13 +180,13 @@ link_transaction (void *cls, * @param args array of additional options (length: 2, first is the coin_pub, second must be "link") * @return MHD result code */ -int +MHD_RESULT TEH_handler_link (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[2]) { struct HTD_Context ctx; - int mhd_ret; + MHD_RESULT mhd_ret; (void) rh; memset (&ctx, diff --git a/src/exchange/taler-exchange-httpd_link.h b/src/exchange/taler-exchange-httpd_link.h index 6fdcf1cf..4c9651a9 100644 --- a/src/exchange/taler-exchange-httpd_link.h +++ b/src/exchange/taler-exchange-httpd_link.h @@ -36,7 +36,7 @@ * @param args array of additional options (length: 2, first is the coin_pub, second must be "link") * @return MHD result code */ -int +MHD_RESULT TEH_handler_link (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[2]); diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c index c08c9773..3a0195cf 100644 --- a/src/exchange/taler-exchange-httpd_melt.c +++ b/src/exchange/taler-exchange-httpd_melt.c @@ -47,7 +47,7 @@ * @param residual remaining value of the coin (after subtracting @a tl) * @return a MHD result code */ -static int +static MHD_RESULT reply_melt_insufficient_funds ( struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -94,7 +94,7 @@ reply_melt_insufficient_funds ( * @param noreveal_index which index will the client not have to reveal * @return a MHD status code */ -static int +static MHD_RESULT reply_melt_success (struct MHD_Connection *connection, const struct TALER_RefreshCommitmentP *rc, uint32_t noreveal_index) @@ -174,7 +174,7 @@ static enum GNUNET_DB_QueryStatus refresh_check_melt (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, struct MeltContext *rmc, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_Amount spent; @@ -296,7 +296,7 @@ static enum GNUNET_DB_QueryStatus melt_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct MeltContext *rmc = cls; enum GNUNET_DB_QueryStatus qs; @@ -370,7 +370,7 @@ melt_transaction (void *cls, * @param[in,out] rmc details about the melt request * @return MHD result code */ -static int +static MHD_RESULT handle_melt (struct MHD_Connection *connection, struct MeltContext *rmc) { @@ -405,7 +405,7 @@ handle_melt (struct MHD_Connection *connection, /* run database transaction */ { - int mhd_ret; + MHD_RESULT mhd_ret; if (GNUNET_OK != TEH_DB_run_transaction (connection, @@ -431,7 +431,7 @@ handle_melt (struct MHD_Connection *connection, * @param rmc parsed request information * @return MHD status code */ -static int +static MHD_RESULT check_for_denomination_key (struct MHD_Connection *connection, struct MeltContext *rmc) { @@ -572,7 +572,7 @@ check_for_denomination_key (struct MHD_Connection *connection, if (GNUNET_NO == coin_is_dirty) { struct TEH_DB_KnowCoinContext kcc; - int mhd_ret; + MHD_RESULT mhd_ret; kcc.coin = &rmc->refresh_session.coin; kcc.connection = connection; @@ -612,13 +612,14 @@ check_for_denomination_key (struct MHD_Connection *connection, * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_melt (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root) { struct MeltContext rmc; - int res; + enum GNUNET_GenericReturnValue ret; + MHD_RESULT res; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_denomination_signature ("denom_sig", &rmc.refresh_session.coin.denom_sig), @@ -637,11 +638,11 @@ TEH_handler_melt (struct MHD_Connection *connection, 0, sizeof (rmc)); rmc.refresh_session.coin.coin_pub = *coin_pub; - res = TALER_MHD_parse_json_data (connection, + ret = TALER_MHD_parse_json_data (connection, root, spec); - if (GNUNET_OK != res) - return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; + if (GNUNET_OK != ret) + return (GNUNET_SYSERR == ret) ? MHD_NO : MHD_YES; res = check_for_denomination_key (connection, &rmc); diff --git a/src/exchange/taler-exchange-httpd_melt.h b/src/exchange/taler-exchange-httpd_melt.h index ad25b471..0edaf247 100644 --- a/src/exchange/taler-exchange-httpd_melt.h +++ b/src/exchange/taler-exchange-httpd_melt.h @@ -39,7 +39,7 @@ * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_melt (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root); diff --git a/src/exchange/taler-exchange-httpd_mhd.c b/src/exchange/taler-exchange-httpd_mhd.c index 6d5df6ff..c9c6303b 100644 --- a/src/exchange/taler-exchange-httpd_mhd.c +++ b/src/exchange/taler-exchange-httpd_mhd.c @@ -43,7 +43,7 @@ * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_static_response (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) @@ -71,7 +71,7 @@ TEH_handler_static_response (const struct TEH_RequestHandler *rh, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_agpl_redirect (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) diff --git a/src/exchange/taler-exchange-httpd_mhd.h b/src/exchange/taler-exchange-httpd_mhd.h index 1605032a..7547780d 100644 --- a/src/exchange/taler-exchange-httpd_mhd.h +++ b/src/exchange/taler-exchange-httpd_mhd.h @@ -37,7 +37,7 @@ * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_static_response (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); @@ -52,7 +52,7 @@ TEH_handler_static_response (const struct TEH_RequestHandler *rh, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_agpl_redirect (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c index a3014e78..c1f6ff33 100644 --- a/src/exchange/taler-exchange-httpd_recoup.c +++ b/src/exchange/taler-exchange-httpd_recoup.c @@ -123,7 +123,7 @@ static enum GNUNET_DB_QueryStatus recoup_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct RecoupContext *pc = cls; struct TALER_EXCHANGEDB_TransactionList *tl; @@ -260,7 +260,7 @@ recoup_transaction (void *cls, (0 == pc->amount.value) ) { /* Recoup has no effect: coin fully spent! */ - int ret; + enum GNUNET_DB_QueryStatus ret; TEH_plugin->rollback (TEH_plugin->cls, session); @@ -342,7 +342,7 @@ recoup_transaction (void *cls, * @param refreshed #GNUNET_YES if the coin was refreshed * @return MHD result code */ -static int +static MHD_RESULT verify_and_execute_recoup (struct MHD_Connection *connection, const struct TALER_CoinPublicInfo *coin, const struct @@ -453,7 +453,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection, /* make sure coin is 'known' in database */ { struct TEH_DB_KnowCoinContext kcc; - int mhd_ret; + MHD_RESULT mhd_ret; kcc.coin = coin; kcc.connection = connection; @@ -472,7 +472,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection, pc.coin = coin; pc.refreshed = refreshed; { - int mhd_ret; + MHD_RESULT mhd_ret; if (GNUNET_OK != TEH_DB_run_transaction (connection, @@ -512,12 +512,12 @@ verify_and_execute_recoup (struct MHD_Connection *connection, * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_recoup (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root) { - int res; + enum GNUNET_GenericReturnValue ret; struct TALER_CoinPublicInfo coin; struct TALER_DenominationBlindingKeyP coin_bks; struct TALER_CoinSpendSignatureP coin_sig; @@ -538,20 +538,24 @@ TEH_handler_recoup (struct MHD_Connection *connection, }; coin.coin_pub = *coin_pub; - res = TALER_MHD_parse_json_data (connection, + ret = TALER_MHD_parse_json_data (connection, root, spec); - if (GNUNET_SYSERR == res) + if (GNUNET_SYSERR == ret) return MHD_NO; /* hard failure */ - if (GNUNET_NO == res) + if (GNUNET_NO == ret) return MHD_YES; /* failure */ - res = verify_and_execute_recoup (connection, - &coin, - &coin_bks, - &coin_sig, - refreshed); - GNUNET_JSON_parse_free (spec); - return res; + { + MHD_RESULT res; + + res = verify_and_execute_recoup (connection, + &coin, + &coin_bks, + &coin_sig, + refreshed); + GNUNET_JSON_parse_free (spec); + return res; + } } diff --git a/src/exchange/taler-exchange-httpd_recoup.h b/src/exchange/taler-exchange-httpd_recoup.h index 85fdc139..95e60773 100644 --- a/src/exchange/taler-exchange-httpd_recoup.h +++ b/src/exchange/taler-exchange-httpd_recoup.h @@ -37,7 +37,7 @@ * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_recoup (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root); diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index da1b3eb9..916277b9 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -52,7 +52,7 @@ * @param sigs array of @a num_freshcoins signatures revealed * @return a MHD result code */ -static int +static MHD_RESULT reply_refreshes_reveal_success (struct MHD_Connection *connection, unsigned int num_freshcoins, const struct TALER_DenominationSignature *sigs) @@ -235,7 +235,7 @@ static enum GNUNET_DB_QueryStatus refreshes_reveal_preflight (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct RevealContext *rctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -292,7 +292,7 @@ static enum GNUNET_DB_QueryStatus refreshes_reveal_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct RevealContext *rctx = cls; struct TALER_EXCHANGEDB_Melt melt; @@ -482,7 +482,7 @@ static enum GNUNET_DB_QueryStatus refreshes_reveal_persist (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct RevealContext *rctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -532,7 +532,7 @@ refreshes_reveal_persist (void *cls, * @param coin_evs envelopes of gamma-selected coins to be signed * @return MHD result code */ -static int +static MHD_RESULT resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, struct MHD_Connection *connection, struct RevealContext *rctx, @@ -547,7 +547,8 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, struct TALER_RefreshCoinData rcds[num_fresh_coins]; struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins]; struct TALER_EXCHANGEDB_Melt melt; - int res; + enum GNUNET_GenericReturnValue res; + MHD_RESULT ret; /* Parse denomination key hashes */ for (unsigned int i = 0; i<num_fresh_coins; i++) @@ -624,13 +625,13 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, switch (qs) { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - res = TALER_MHD_reply_with_error (connection, + ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, TALER_EC_REVEAL_SESSION_UNKNOWN, "rc"); break; case GNUNET_DB_STATUS_HARD_ERROR: - res = TALER_MHD_reply_with_error (connection, + ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR, "failed to fetch session data"); @@ -638,7 +639,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, case GNUNET_DB_STATUS_SOFT_ERROR: default: GNUNET_break (0); /* should be impossible */ - res = TALER_MHD_reply_with_error (connection, + ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_INTERNAL_INVARIANT_FAILURE, "assertion failed (unexpected database serialization error)"); @@ -683,7 +684,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, &melt.session.coin.coin_pub.eddsa_pub)) { GNUNET_break_op (0); - res = TALER_MHD_reply_with_error (connection, + ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, TALER_EC_REVEAL_LINK_SIGNATURE_INVALID, "link_sig"); @@ -710,7 +711,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, if (NULL == rctx->ev_sigs[i].rsa_signature) { GNUNET_break (0); - res = TALER_MHD_reply_with_error (connection, + ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_REVEAL_SIGNING_ERROR, "internal signing error"); @@ -729,17 +730,17 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, if ( (GNUNET_OK == TEH_DB_run_transaction (connection, "reveal pre-check", - &res, + &ret, &refreshes_reveal_preflight, rctx)) && (GNUNET_YES == rctx->preflight_ok) ) { /* Generate final (positive) response */ GNUNET_assert (NULL != rctx->ev_sigs); - res = reply_refreshes_reveal_success (connection, + ret = reply_refreshes_reveal_success (connection, num_fresh_coins, rctx->ev_sigs); - GNUNET_break (MHD_NO != res); + GNUNET_break (MHD_NO != ret); goto cleanup; /* aka 'break' */ } if (GNUNET_SYSERR == rctx->preflight_ok) @@ -750,7 +751,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, if (GNUNET_OK != TEH_DB_run_transaction (connection, "run reveal", - &res, + &ret, &refreshes_reveal_transaction, rctx)) { @@ -761,13 +762,13 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, if (GNUNET_OK == TEH_DB_run_transaction (connection, "persist reveal", - &res, + &ret, &refreshes_reveal_persist, rctx)) { /* Generate final (positive) response */ GNUNET_assert (NULL != rctx->ev_sigs); - res = reply_refreshes_reveal_success (connection, + ret = reply_refreshes_reveal_success (connection, num_fresh_coins, rctx->ev_sigs); break; @@ -778,7 +779,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state, } /* end for (retries...) */ cleanup: - GNUNET_break (MHD_NO != res); + GNUNET_break (MHD_NO != ret); /* free resources */ if (NULL != rctx->ev_sigs) { @@ -790,7 +791,7 @@ cleanup: } for (unsigned int i = 0; i<num_fresh_coins; i++) GNUNET_free_non_null (rcds[i].coin_ev); - return res; + return ret; } @@ -908,7 +909,7 @@ handle_refreshes_reveal_json (struct MHD_Connection *connection, * @param args array of additional options (length: 2, session hash and the string "reveal") * @return MHD result code */ -int +MHD_RESULT TEH_handler_reveal (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const json_t *root, diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.h b/src/exchange/taler-exchange-httpd_refreshes_reveal.h index 076ec52d..b9806dbd 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.h +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.h @@ -43,7 +43,7 @@ * @param args array of additional options (length: 2, session hash and the string "reveal") * @return MHD result code */ -int +MHD_RESULT TEH_handler_reveal (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const json_t *root, diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 036a0473..7c2b149f 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -43,7 +43,7 @@ * @param refund details about the successful refund * @return MHD result code */ -static int +static MHD_RESULT reply_refund_success (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_EXCHANGEDB_RefundListEntry *refund) @@ -104,7 +104,7 @@ static enum GNUNET_DB_QueryStatus refund_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { const struct TALER_EXCHANGEDB_Refund *refund = cls; struct TALER_EXCHANGEDB_TransactionList *tl; @@ -342,7 +342,7 @@ refund_transaction (void *cls, * @param refund information about the refund * @return MHD result code */ -static int +static MHD_RESULT verify_and_execute_refund (struct MHD_Connection *connection, const struct TALER_EXCHANGEDB_Refund *refund) { @@ -468,7 +468,7 @@ verify_and_execute_refund (struct MHD_Connection *connection, /* Finally run the actual transaction logic */ { - int mhd_ret; + MHD_RESULT mhd_ret; if (GNUNET_OK != TEH_DB_run_transaction (connection, @@ -497,7 +497,7 @@ verify_and_execute_refund (struct MHD_Connection *connection, * @param root uploaded JSON data * @return MHD result code */ -int +MHD_RESULT TEH_handler_refund (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root) @@ -517,7 +517,7 @@ TEH_handler_refund (struct MHD_Connection *connection, refund.coin.coin_pub = *coin_pub; { - int res; + enum GNUNET_GenericReturnValue res; res = TALER_MHD_parse_json_data (connection, root, @@ -549,7 +549,7 @@ TEH_handler_refund (struct MHD_Connection *connection, "refund_amount"); } { - int res; + MHD_RESULT res; res = verify_and_execute_refund (connection, &refund); diff --git a/src/exchange/taler-exchange-httpd_refund.h b/src/exchange/taler-exchange-httpd_refund.h index ad6387d6..92480b77 100644 --- a/src/exchange/taler-exchange-httpd_refund.h +++ b/src/exchange/taler-exchange-httpd_refund.h @@ -38,8 +38,8 @@ * @param coin_pub public key of the coin * @param root uploaded JSON data * @return MHD result code - */ -int + */ +MHD_RESULT TEH_handler_refund (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *root); diff --git a/src/exchange/taler-exchange-httpd_reserves_get.c b/src/exchange/taler-exchange-httpd_reserves_get.c index dbbb7270..cbc6b422 100644 --- a/src/exchange/taler-exchange-httpd_reserves_get.c +++ b/src/exchange/taler-exchange-httpd_reserves_get.c @@ -37,7 +37,7 @@ * @param rh reserve history to return * @return MHD result code */ -static int +static MHD_RESULT reply_reserve_history_success (struct MHD_Connection *connection, const struct TALER_EXCHANGEDB_ReserveHistory *rh) { @@ -100,7 +100,7 @@ static enum GNUNET_DB_QueryStatus reserve_history_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct ReserveHistoryContext *rsc = cls; @@ -124,13 +124,13 @@ reserve_history_transaction (void *cls, * @param args array of additional options (length: 1, just the reserve_pub) * @return MHD result code */ -int +MHD_RESULT TEH_handler_reserves_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[1]) { struct ReserveHistoryContext rsc; - int mhd_ret; + MHD_RESULT mhd_ret; (void) rh; if (GNUNET_OK != diff --git a/src/exchange/taler-exchange-httpd_reserves_get.h b/src/exchange/taler-exchange-httpd_reserves_get.h index e59d3e03..b46a6a44 100644 --- a/src/exchange/taler-exchange-httpd_reserves_get.h +++ b/src/exchange/taler-exchange-httpd_reserves_get.h @@ -38,7 +38,7 @@ * @param args array of additional options (length: 1, just the reserve_pub) * @return MHD result code */ -int +MHD_RESULT TEH_handler_reserves_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[1]); diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 3870db14..06673afc 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -411,7 +411,7 @@ TEH_RESPONSE_compile_transaction_history ( * @param tl transaction list to use to build reply * @return MHD result code */ -int +MHD_RESULT TEH_RESPONSE_reply_coin_insufficient_funds ( struct MHD_Connection *connection, enum TALER_ErrorCode ec, diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h index 5dd98174..6486b5d9 100644 --- a/src/exchange/taler-exchange-httpd_responses.h +++ b/src/exchange/taler-exchange-httpd_responses.h @@ -31,6 +31,7 @@ #include "taler_error_codes.h" #include "taler-exchange-httpd.h" #include "taler-exchange-httpd_db.h" +#include <gnunet/gnunet_mhd_compat.h> /** @@ -59,7 +60,7 @@ TEH_RESPONSE_compile_reserve_history ( * @param tl transaction list to use to build reply * @return MHD result code */ -int +MHD_RESULT TEH_RESPONSE_reply_coin_insufficient_funds ( struct MHD_Connection *connection, enum TALER_ErrorCode ec, diff --git a/src/exchange/taler-exchange-httpd_terms.c b/src/exchange/taler-exchange-httpd_terms.c index 121e1c78..1c703021 100644 --- a/src/exchange/taler-exchange-httpd_terms.c +++ b/src/exchange/taler-exchange-httpd_terms.c @@ -46,7 +46,7 @@ static struct TALER_MHD_Legal *pp; * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_terms (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) @@ -66,7 +66,7 @@ TEH_handler_terms (const struct TEH_RequestHandler *rh, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_privacy (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) diff --git a/src/exchange/taler-exchange-httpd_terms.h b/src/exchange/taler-exchange-httpd_terms.h index 7fe7774a..3cbd3688 100644 --- a/src/exchange/taler-exchange-httpd_terms.h +++ b/src/exchange/taler-exchange-httpd_terms.h @@ -37,7 +37,7 @@ * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_terms (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); @@ -51,7 +51,7 @@ TEH_handler_terms (const struct TEH_RequestHandler *rh, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_privacy (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c index 2aa9a5c9..a5b21244 100644 --- a/src/exchange/taler-exchange-httpd_transfers_get.c +++ b/src/exchange/taler-exchange-httpd_transfers_get.c @@ -83,7 +83,7 @@ struct AggregatedDepositDetail * @param wdd_head linked list with details about the combined deposits * @return MHD result code */ -static int +static MHD_RESULT reply_transfer_details (struct MHD_Connection *connection, const struct TALER_Amount *total, const struct TALER_MerchantPublicKeyP *merchant_pub, @@ -421,7 +421,7 @@ static enum GNUNET_DB_QueryStatus get_transfer_deposits (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct WtidTransactionContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -513,13 +513,13 @@ get_transfer_deposits (void *cls, * @param args array of additional options (length: 1, just the wtid) * @return MHD result code */ -int +MHD_RESULT TEH_handler_transfers_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[1]) { struct WtidTransactionContext ctx; - int mhd_ret; + MHD_RESULT mhd_ret; (void) rh; memset (&ctx, diff --git a/src/exchange/taler-exchange-httpd_transfers_get.h b/src/exchange/taler-exchange-httpd_transfers_get.h index 37f7dfbd..83c17334 100644 --- a/src/exchange/taler-exchange-httpd_transfers_get.h +++ b/src/exchange/taler-exchange-httpd_transfers_get.h @@ -34,7 +34,7 @@ * @param args array of additional options (length: 1, just the wtid) * @return MHD result code */ -int +MHD_RESULT TEH_handler_transfers_get (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[1]); diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index cb63355b..38bbad4a 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -295,7 +295,7 @@ load_account (void *cls, * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_wire (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]) diff --git a/src/exchange/taler-exchange-httpd_wire.h b/src/exchange/taler-exchange-httpd_wire.h index 219f1711..7df87432 100644 --- a/src/exchange/taler-exchange-httpd_wire.h +++ b/src/exchange/taler-exchange-httpd_wire.h @@ -52,7 +52,7 @@ TEH_WIRE_done (void); * @param args array of additional options (must be empty for this function) * @return MHD result code */ -int +MHD_RESULT TEH_handler_wire (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const char *const args[]); diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index 152ebfbb..4d662e71 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -51,7 +51,7 @@ * @param rh reserve history to return * @return MHD result code */ -static int +static MHD_RESULT reply_withdraw_insufficient_funds ( struct MHD_Connection *connection, const struct TALER_Amount *ebalance, @@ -173,7 +173,7 @@ static enum GNUNET_DB_QueryStatus withdraw_transaction (void *cls, struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + MHD_RESULT *mhd_ret) { struct WithdrawContext *wc = cls; struct TALER_EXCHANGEDB_Reserve r; @@ -343,7 +343,7 @@ withdraw_transaction (void *cls, * reserve public key, the second one should be "withdraw") * @return MHD result code */ -int +MHD_RESULT TEH_handler_withdraw (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const json_t *root, @@ -376,7 +376,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, } { - int res; + enum GNUNET_GenericReturnValue res; res = TALER_MHD_parse_json_data (connection, root, @@ -486,7 +486,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, /* run transaction and sign (if not optimistically signed before) */ { - int mhd_ret; + MHD_RESULT mhd_ret; if (GNUNET_OK != TEH_DB_run_transaction (connection, @@ -510,7 +510,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); { - int ret; + MHD_RESULT ret; ret = TALER_MHD_reply_json_pack ( connection, diff --git a/src/exchange/taler-exchange-httpd_withdraw.h b/src/exchange/taler-exchange-httpd_withdraw.h index 7fc2fa01..8b248597 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.h +++ b/src/exchange/taler-exchange-httpd_withdraw.h @@ -42,7 +42,7 @@ * reserve public key, the second one should be "withdraw") * @return MHD result code */ -int +MHD_RESULT TEH_handler_withdraw (const struct TEH_RequestHandler *rh, struct MHD_Connection *connection, const json_t *root, |